From 37cb57490725cee68fb3e092bef849aad1a0dd25 Mon Sep 17 00:00:00 2001 From: Alula <6276139+alula@users.noreply.github.com> Date: Sat, 12 Feb 2022 10:12:30 +0100 Subject: [PATCH] special treatment for cs+ challenges --- src/engine_constants/mod.rs | 21 ++++++++++++++++++++- src/shared_game_state.rs | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/engine_constants/mod.rs b/src/engine_constants/mod.rs index 6a7fe41..624c759 100644 --- a/src/engine_constants/mod.rs +++ b/src/engine_constants/mod.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::io::{BufRead, BufReader, Cursor, Read}; -use byteorder::{ReadBytesExt, LE}; +use byteorder::{LE, ReadBytesExt}; use case_insensitive_hashmap::CaseInsensitiveHashMap; use crate::case_insensitive_hashmap; @@ -1679,6 +1679,7 @@ impl EngineConstants { self.soundtracks.insert("Ridiculon".to_owned(), "/base/ogg_ridic/".to_owned()); self.animated_face_table.push(AnimatedFace { face_id: 5, anim_id: 4, anim_frames: vec![(4, 0)] }); // Teethrog fix self.game.tile_offset_x = 3; + self.game.new_game_player_pos = (13, 8); } pub fn rebuild_path_list(&mut self, mod_path: Option, season: Season, settings: &Settings) { @@ -1708,6 +1709,24 @@ impl EngineConstants { } } + pub fn special_treatment_for_csplus_mods(&mut self, mod_path: Option<&String>) { + if !self.is_cs_plus { + return; + } + + let mut pos = if self.is_switch { (13, 8) } else { (10, 8) }; + + if let Some(mod_path) = mod_path { + if mod_path == "/TimeTrial/mod/" { + pos = (8, 9); + } else if mod_path == "/boss/mod/" { + pos = (57, 21); + } + } + + self.game.new_game_player_pos = pos; + } + pub fn apply_constant_json_files(&mut self) {} /// Loads bullet.tbl and arms_level.tbl from CS+ files, diff --git a/src/shared_game_state.rs b/src/shared_game_state.rs index 103a576..95b067a 100644 --- a/src/shared_game_state.rs +++ b/src/shared_game_state.rs @@ -312,6 +312,7 @@ impl SharedGameState { pub fn reload_resources(&mut self, ctx: &mut Context) -> GameResult { self.constants.rebuild_path_list(self.mod_path.clone(), self.season, &self.settings); + self.constants.special_treatment_for_csplus_mods(self.mod_path.as_ref()); self.constants.load_csplus_tables(ctx)?; self.constants.load_animated_faces(ctx)?; let stages = StageData::load_stage_table(ctx, &self.constants.base_paths)?;