From 7f0da69f55789fe72edb563e2c0a39e40cc7bea6 Mon Sep 17 00:00:00 2001 From: dashodanger Date: Tue, 17 Oct 2023 09:27:59 -0600 Subject: [PATCH] Fixed level<->episode invalidation from MAPINFO parsing; alternate voodoo scroller fix for AAA and other boom scrollers --- source_files/edge/p_local.h | 2 ++ source_files/edge/p_mobj.cc | 30 +++++++++++++++-------------- source_files/edge/p_plane.cc | 2 -- source_files/edge/p_spec.cc | 2 -- source_files/edge/p_umapinfo.cc | 4 ++-- source_files/edge/w_wad.cc | 34 ++++++++++++++++++++++++++++++++- source_files/epi/str_compare.cc | 23 ++++++++++++++++++++++ source_files/epi/str_compare.h | 5 +++++ 8 files changed, 81 insertions(+), 21 deletions(-) diff --git a/source_files/edge/p_local.h b/source_files/edge/p_local.h index ff9bca240..b79c71533 100644 --- a/source_files/edge/p_local.h +++ b/source_files/edge/p_local.h @@ -40,6 +40,8 @@ #define DEATHVIEWHEIGHT 6.0f #define CROUCH_SLOWDOWN 0.5f +#define BOOM_CARRY_FACTOR 0.09375f + #define MLOOK_LIMIT FLOAT_2_ANG(75.0f) #define MAXMOVE (200.0f) diff --git a/source_files/edge/p_mobj.cc b/source_files/edge/p_mobj.cc index d4ab0aa90..91b3b52be 100644 --- a/source_files/edge/p_mobj.cc +++ b/source_files/edge/p_mobj.cc @@ -692,18 +692,7 @@ void P_CalcFullProperties(const mobj_t *mo, region_properties_t *new_p) new_p->viscosity = 0; new_p->drag = 0; - new_p->push.x = new_p->push.y = new_p->push.z = 0; // Original calcs - Dasho - - // 2023.05.31 - Test preservation of some push value when transitioning sectors - // In particular, this seems to fix AAA MAP07's exit voodoo scroller, which would - // otherwise become stuck on the narrow section that is not a pusher - Dasho - // 2023.06.08 - Test only doing this for voodoo dolls - if (mo->is_voodoo) - { - new_p->push.x = (mo->props->push.x + sector->props.push.x) / 2; - new_p->push.y = (mo->props->push.y + sector->props.push.y) / 2; - new_p->push.z = (mo->props->push.z + sector->props.push.z) / 2; - } + new_p->push.x = new_p->push.y = new_p->push.z = 0; new_p->type = 0; // these shouldn't be used new_p->special = NULL; @@ -1412,8 +1401,21 @@ static void P_MobjThinker(mobj_t * mobj, bool extra_tic) if (!extra_tic || !r_doubleframes.d) { - mobj->mom.x += player_props.push.x; - mobj->mom.y += player_props.push.y; + // Dasho 2023.10.17 - This is a small gamble, but I think it's safe to assume + // that for EC the only time a voodoo would be on such a sector is a Boom scroller. + // This sets the voodoo to move at the same speed as the scroller and I think is a + // 'better' solution for stuff like AAA MAP07 than my previous attempt using + // push preservation when transitioning sectors + if (mobj->is_voodoo) + { + mobj->mom.x += (player_props.push.x / BOOM_CARRY_FACTOR); + mobj->mom.y += (player_props.push.y / BOOM_CARRY_FACTOR); + } + else + { + mobj->mom.x += player_props.push.x; + mobj->mom.y += player_props.push.y; + } mobj->mom.z += player_props.push.z; } diff --git a/source_files/edge/p_plane.cc b/source_files/edge/p_plane.cc index 783f51dd8..3299a0a54 100644 --- a/source_files/edge/p_plane.cc +++ b/source_files/edge/p_plane.cc @@ -37,8 +37,6 @@ #include -#define BOOM_CARRY_FACTOR 0.09375f - typedef enum { RES_Ok, diff --git a/source_files/edge/p_spec.cc b/source_files/edge/p_spec.cc index f3fd64d6d..ffee1917a 100644 --- a/source_files/edge/p_spec.cc +++ b/source_files/edge/p_spec.cc @@ -52,8 +52,6 @@ #include "AlmostEquals.h" -#define BOOM_CARRY_FACTOR 0.09375f - extern cvar_c r_doubleframes; // Level exit timer diff --git a/source_files/edge/p_umapinfo.cc b/source_files/edge/p_umapinfo.cc index d3b2a7aee..6f575b391 100644 --- a/source_files/edge/p_umapinfo.cc +++ b/source_files/edge/p_umapinfo.cc @@ -1058,7 +1058,7 @@ static void ParseMAPINFOEntry(epi::lexer_c& lex, MapEntry *val) else if (epi::case_cmp(key, "music") == 0) { Z_Clear(val->music, char, 9); - if (epi::strncmp(value, "$MUSIC_", 7) == 0) + if (epi::case_cmp_n(value, "$MUSIC_", 7) == 0) { std::string music_sub = language["MusicPrefix"]; music_sub.append(value.substr(7)); @@ -1547,7 +1547,7 @@ static void ParseZMAPINFOEntry(epi::lexer_c& lex, MapEntry *val) else if (epi::case_cmp(key, "music") == 0) { Z_Clear(val->music, char, 9); - if (epi::strncmp(value, "$MUSIC_", 7) == 0) + if (epi::case_cmp_n(value, "$MUSIC_", 7) == 0) { std::string music_sub = language["MusicPrefix"]; music_sub.append(value.substr(7)); diff --git a/source_files/edge/w_wad.cc b/source_files/edge/w_wad.cc index aa6edd1b9..b54253613 100644 --- a/source_files/edge/w_wad.cc +++ b/source_files/edge/w_wad.cc @@ -1850,7 +1850,7 @@ void W_ReadUMAPINFOLumps(void) { for (int g=gamedefs.GetSize()-1; g >= 0; g--) { - if (gamedefs[g]->name != "TEMPEPI" && epi::strncmp(gamedefs[g]->firstmap, temp_level->name, 3) == 0) + if (gamedefs[g]->name != "TEMPEPI" && epi::case_cmp_n(gamedefs[g]->firstmap, temp_level->name, 3) == 0) { if (atoi(gamedefs[g]->firstmap.substr(3).c_str()) > atoi(temp_level->name.substr(3).c_str())) continue; @@ -1869,6 +1869,38 @@ void W_ReadUMAPINFOLumps(void) } } } + else // Validate episode entry to make sure it wasn't renamed or removed + { + bool good_epi = false; + for (int g = 0; g < gamedefs.GetSize(); g++) + { + if (temp_level->episode_name == gamedefs[g]->name) + { + good_epi = true; + break; + } + } + if (!good_epi) // Find a suitable episode + { + for (int g=gamedefs.GetSize()-1; g >= 0; g--) + { + if (epi::case_cmp_n(gamedefs[g]->firstmap, temp_level->name, 3) == 0) + { + if (atoi(gamedefs[g]->firstmap.substr(3).c_str()) > atoi(temp_level->name.substr(3).c_str())) + continue; + else + { + temp_level->episode = gamedefs[g]; + temp_level->episode_name = gamedefs[g]->name; + good_epi = true; + break; + } + } + } + } + if (!good_epi) + I_Error("MAPINFO: No valid episode found for level %s\n", temp_level->name.c_str()); + } } FreeMapList(); diff --git a/source_files/epi/str_compare.cc b/source_files/epi/str_compare.cc index 3d3f5eaf5..84aa53bfe 100644 --- a/source_files/epi/str_compare.cc +++ b/source_files/epi/str_compare.cc @@ -110,6 +110,29 @@ int case_cmp(const std::string& A, const std::string& B) //---------------------------------------------------------------------------- +int case_cmp_n(const char *A, const char *B, size_t n) +{ + SYS_ASSERT(A && B && strlen(A) > n && strlen(B) > n); + return epi::case_cmp(std::string(A).substr(0, n), std::string(B).substr(0, n)); +} + +int case_cmp_n(const char *A, const std::string& B, size_t n) +{ + return epi::case_cmp_n(A, B.c_str(), n); +} + +int case_cmp_n(const std::string& A, const char *B, size_t n) +{ + return epi::case_cmp_n(A.c_str(), B, n); +} + +int case_cmp_n(const std::string& A, const std::string& B, size_t n) +{ + return epi::case_cmp_n(A.c_str(), B.c_str(), n); +} + +//---------------------------------------------------------------------------- + int prefix_cmp(const char *A, const char *B) { SYS_ASSERT(A && B); diff --git a/source_files/epi/str_compare.h b/source_files/epi/str_compare.h index f0c5ff381..addd923e5 100644 --- a/source_files/epi/str_compare.h +++ b/source_files/epi/str_compare.h @@ -44,6 +44,11 @@ int case_cmp(const char *A, const std::string& B); int case_cmp(const std::string& A, const char *B); int case_cmp(const std::string& A, const std::string& B); +int case_cmp_n(const char *A, const char *B, size_t n); +int case_cmp_n(const char *A, const std::string& B, size_t n); +int case_cmp_n(const std::string& A, const char *B, size_t n); +int case_cmp_n(const std::string& A, const std::string& B, size_t n); + int prefix_cmp(const char *A, const char *B); int prefix_cmp(const char *A, const std::string& B); int prefix_cmp(const std::string& A, const char *B);