1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-05-13 15:17:45 +00:00

Update and use the nice, new Physis ColumnData API

Now the GameData::get_warp function looks much closer to how I want it
to!
This commit is contained in:
Joshua Goins 2025-05-09 18:03:25 -04:00
parent 93923ff7a8
commit 99c92d1b67
3 changed files with 8 additions and 11 deletions

2
Cargo.lock generated
View file

@ -1017,7 +1017,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]] [[package]]
name = "physis" name = "physis"
version = "0.4.0" version = "0.4.0"
source = "git+https://github.com/redstrate/physis#70343e12125c70cffa1998e68ff28a8d2dc4f3df" source = "git+https://github.com/redstrate/physis#309726163a0d76f26831236f43740a2c8bd1b01d"
dependencies = [ dependencies = [
"binrw", "binrw",
"bitflags", "bitflags",

View file

@ -132,19 +132,14 @@ impl GameData {
} }
/// Returns the pop range object id that's associated with the warp id /// Returns the pop range object id that's associated with the warp id
pub fn get_warp(&mut self, warp_id: u32) -> (u32, u16) { pub fn get_warp(&mut self, warp_id: u32) -> Option<(u32, u16)> {
let warp_sheet = Warp::read_from(&mut self.game_data, Language::English); let warp_sheet = Warp::read_from(&mut self.game_data, Language::English);
let row = warp_sheet.get_row(warp_id); let row = warp_sheet.get_row(warp_id);
let physis::exd::ColumnData::UInt32(pop_range_id) = row.PopRange() else { let pop_range_id = row.PopRange().into_u32()?;
panic!("Unexpected type!"); let zone_id = row.TerritoryType().into_u16()?;
};
let physis::exd::ColumnData::UInt16(zone_id) = row.TerritoryType() else { Some((*pop_range_id, *zone_id))
panic!("Unexpected type!");
};
(*pop_range_id, *zone_id)
} }
} }

View file

@ -434,7 +434,9 @@ impl ZoneConnection {
// find the pop range on the other side // find the pop range on the other side
{ {
let mut game_data = self.gamedata.lock().unwrap(); let mut game_data = self.gamedata.lock().unwrap();
let (pop_range_id, zone_id) = game_data.get_warp(warp_id); let (pop_range_id, zone_id) = game_data
.get_warp(warp_id)
.expect("Failed to find the warp!");
let new_zone = Zone::load(&mut game_data.game_data, zone_id); let new_zone = Zone::load(&mut game_data.game_data, zone_id);