Skip to content

Commit

Permalink
- RR: clear jaildoors array on map start.
Browse files Browse the repository at this point in the history
this was leaving stale data behind which could cause nasty crashes.
  • Loading branch information
coelckers committed May 22, 2022
1 parent 79c671b commit af89c25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions source/core/savegamehelp.h
Expand Up @@ -24,17 +24,18 @@ void M_Autosave();

template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname, sectortype*& w, sectortype** def)
{
assert(arc.isReading() || w == nullptr || (w >= &sector[0] && w <= &sector.Last()));
int ndx = w ? sectnum(w) : -1;
arc(keyname, ndx);
w = ndx == -1 ? nullptr : &sector[ndx];
w = !validSectorIndex(ndx) ? nullptr : &sector[ndx];
return arc;
}

template<> inline FSerializer& Serialize(FSerializer& arc, const char* keyname, walltype*& w, walltype** def)
{
int ndx = w ? wallnum(w) : -1;
arc(keyname, ndx);
w = ndx == -1 ? nullptr : &wall[ndx];
w = !validWallIndex(ndx) ? nullptr : &wall[ndx];
return arc;
}

Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/actors_lava.cpp
Expand Up @@ -36,7 +36,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
BEGIN_DUKE_NS

static int torchcnt;
static int jaildoorcnt;
static int lightnincnt;

static sectortype* torchsector[64];
Expand Down Expand Up @@ -84,7 +83,7 @@ static int windertime;

void lava_cleararrays()
{
jaildoorcnt = 0;
jaildoors.Clear();
minecarts.Clear();
torchcnt = 0;
lightnincnt = 0;
Expand Down Expand Up @@ -274,6 +273,7 @@ void dojaildoor(void)
for(auto& jd : jaildoors)
{
auto sectp = jd.sect;
if (!sectp) continue; // this is only for allowing old, broken savegames to work, this would crash otherwise.
double speed = max(2, jd.speed) * maptoworld;

if (jd.open == 1 || jd.open == 3)
Expand Down

0 comments on commit af89c25

Please sign in to comment.