- Duke/RR: fixed: animates array must be cleared on map change.

There was also some undefined behavior when an entry was deleted, this seems to originate from the original code.
This commit is contained in:
Christoph Oelckers 2022-12-10 10:20:01 +01:00
parent dc41057984
commit 7d82ae28f4
3 changed files with 13 additions and 3 deletions

View file

@ -81,6 +81,15 @@ MapRecord *FindMapByName(const char *nm)
return map.Data();
}
}
// retry with the path being removed.
FString s = ExtractFileBase(nm);
for (auto& map : mapList)
{
if (map->labelName.CompareNoCase(s) == 0)
{
return map.Data();
}
}
return nullptr;
}

View file

@ -426,6 +426,7 @@ void resetprestat(int snum,int g)
paused = 0;
ud.cameraactor =nullptr;
mspos.Clear();
animates.Clear();
camsprite =nullptr;
earthquaketime = 0;

View file

@ -355,6 +355,7 @@ void doanimations(void)
double a = getanimatevalue(i);
double const v = animates[i].vel * TICSPERFRAME;
auto dasectp = animates[i].sect;
int type = animates[i].type;
if (a == animates[i].goal)
{
@ -362,9 +363,8 @@ void doanimations(void)
animates[i] = animates.Last();
animates.Pop();
dasectp = animates[i].sect;
if (dasectp->lotag == ST_18_ELEVATOR_DOWN || dasectp->lotag == ST_19_ELEVATOR_UP)
if (animates[i].type == anim_ceilingz)
if (type == anim_ceilingz)
continue;
if ((dasectp->lotag & 0xff) != ST_22_SPLITTING_DOOR)
@ -376,7 +376,7 @@ void doanimations(void)
if (v > 0) { a = min(a + v, animates[i].goal); }
else { a = max(a + v, animates[i].goal); }
if (animates[i].type == anim_floorz)
if (type == anim_floorz)
{
for (auto p = connecthead; p >= 0; p = connectpoint2[p])
if (ps[p].cursector == dasectp)