Skip to content

Commit

Permalink
Fixed level<->episode invalidation from MAPINFO parsing; alternate vo…
Browse files Browse the repository at this point in the history
…odoo scroller fix for AAA and other boom scrollers
  • Loading branch information
dashodanger committed Oct 17, 2023
1 parent 4233980 commit 7f0da69
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 21 deletions.
2 changes: 2 additions & 0 deletions source_files/edge/p_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 16 additions & 14 deletions source_files/edge/p_mobj.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions source_files/edge/p_plane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

#include <algorithm>

#define BOOM_CARRY_FACTOR 0.09375f

typedef enum
{
RES_Ok,
Expand Down
2 changes: 0 additions & 2 deletions source_files/edge/p_spec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@

#include "AlmostEquals.h"

#define BOOM_CARRY_FACTOR 0.09375f

extern cvar_c r_doubleframes;

// Level exit timer
Expand Down
4 changes: 2 additions & 2 deletions source_files/edge/p_umapinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
34 changes: 33 additions & 1 deletion source_files/edge/w_wad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
23 changes: 23 additions & 0 deletions source_files/epi/str_compare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions source_files/epi/str_compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7f0da69

Please sign in to comment.