1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-04-09 21:54:54 +00:00

Fix challenge's incomplete stage.tbl

This commit is contained in:
dawnDus 2022-02-10 18:02:45 -05:00
parent 8e2088adb4
commit fe3e60ecbf
No known key found for this signature in database
GPG key ID: 972AABDE81848F21
2 changed files with 58 additions and 43 deletions

View file

@ -551,7 +551,9 @@ impl SharedGameState {
}
pub fn get_save_filename(&self, slot: usize) -> String {
if slot == 1 {
if let Some(mod_path) = &self.mod_path {
format!("/Profile{}.dat", mod_path.replace("/", "")) // Until we have mod names
} else if slot == 1 {
"/Profile.dat".to_owned()
} else {
format!("/Profile{}.dat", slot)

View file

@ -281,11 +281,16 @@ impl StageData {
let mrmap_bin_path = "/mrmap.bin";
let stage_dat_path = "/stage.dat";
if let Ok(mut file) = filesystem::open_find(ctx, roots, stage_tbl_path) {
if filesystem::exists_find(ctx, roots, stage_tbl_path) {
// Cave Story+ stage table.
// Mod stage.tbl expects to overwrite from base stage.tbl
let mut stages = Vec::new();
info!("Loading Cave Story+ stage table from {}", &stage_tbl_path);
for path in roots.iter().rev() {
if let Ok(mut file) = filesystem::open(ctx, [path, stage_tbl_path].join("")) {
info!("Loading Cave Story+ stage table from {}", &path);
let mut new_stages = Vec::new();
let mut data = Vec::new();
file.read_to_end(&mut data)?;
@ -330,7 +335,15 @@ impl StageData {
npc1: NpcType::new(&npc1),
npc2: NpcType::new(&npc2),
};
stages.push(stage);
new_stages.push(stage);
}
if new_stages.len() >= stages.len() {
stages = new_stages;
} else {
let _ = stages.splice(0..new_stages.len(), new_stages);
}
}
}
return Ok(stages);