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

Begin using Physis Sheets, port warp finding code to it

Kawari is starting to have more and more Excel-based code, so having a
nicer way to access it is nice. This only works for simple cases for
now, and easy one is finding a warp.
This commit is contained in:
Joshua Goins 2025-05-09 17:48:56 -04:00
parent 7f729bfd99
commit 93923ff7a8
3 changed files with 18 additions and 11 deletions

11
Cargo.lock generated
View file

@ -724,6 +724,7 @@ dependencies = [
"minijinja",
"mlua",
"physis",
"physis-sheets",
"reqwest",
"rkon",
"rusqlite",
@ -1016,7 +1017,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "physis"
version = "0.4.0"
source = "git+https://github.com/redstrate/physis#e751ffa765ccd316112b3cb6ccdbb7a80fab8ccf"
source = "git+https://github.com/redstrate/physis#70343e12125c70cffa1998e68ff28a8d2dc4f3df"
dependencies = [
"binrw",
"bitflags",
@ -1024,6 +1025,14 @@ dependencies = [
"libz-rs-sys",
]
[[package]]
name = "physis-sheets"
version = "0.0.0"
source = "git+https://github.com/redstrate/PhysisSheets#1b746c17e8ae8abf4ac613165e63de9f047e567e"
dependencies = [
"physis",
]
[[package]]
name = "pin-project-lite"
version = "0.2.16"

View file

@ -102,3 +102,6 @@ rkon = { version = "0.1" }
# For serving static files on the website
tower-http = { version = "0.6", features = ["fs"] }
# excel sheet data
physis-sheets = { git = "https://github.com/redstrate/PhysisSheets", features = ["Warp"], default-features = false }

View file

@ -1,6 +1,7 @@
use physis::common::{Language, Platform};
use physis::exd::{EXD, ExcelRowKind};
use physis::exh::EXH;
use physis_sheets::Warp::Warp;
use crate::{common::Attributes, config::get_config};
@ -132,21 +133,15 @@ impl GameData {
/// Returns the pop range object id that's associated with the warp id
pub fn get_warp(&mut self, warp_id: u32) -> (u32, u16) {
let exh = self.game_data.read_excel_sheet_header("Warp").unwrap();
let exd = self
.game_data
.read_excel_sheet("Warp", &exh, Language::English, 0)
.unwrap();
let warp_sheet = Warp::read_from(&mut self.game_data, Language::English);
let ExcelRowKind::SingleRow(row) = &exd.get_row(warp_id).unwrap() else {
panic!("Expected a single row!")
};
let row = warp_sheet.get_row(warp_id);
let physis::exd::ColumnData::UInt32(pop_range_id) = &row.columns[0] else {
let physis::exd::ColumnData::UInt32(pop_range_id) = row.PopRange() else {
panic!("Unexpected type!");
};
let physis::exd::ColumnData::UInt16(zone_id) = &row.columns[1] else {
let physis::exd::ColumnData::UInt16(zone_id) = row.TerritoryType() else {
panic!("Unexpected type!");
};