When loading a game, DON'T restore 'adult' TV tiles. This fixes the recent

crashes.

Usually, after loading a game, some wall tiles are tweaked depending on whether
adult mode is enabled or not.  If it's not, those wall picnums are replaced
with blank or broken screens.  If it is, they are restored from the wall's
.extra member.  Apparently though, Mapster32 leaves some .extra members
floating around even after deleting a TROR nextwall link (it's used as the
'lower wall index').  Because MAXWALLS is greater than MAXTILES, this may
produce out-of-bounds accesses and corrupt memory (besides setting wall
tilenums to nonsensical values) later in the game.

Other than that, the change only affects loading savegames created with adult
mode OFF. Kinky TV screenies simply won't be restored then.

git-svn-id: https://svn.eduke32.com/eduke32@2235 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-01-05 20:48:37 +00:00
parent b5f2955895
commit 146e1f1c09
3 changed files with 22 additions and 16 deletions

View file

@ -5266,13 +5266,7 @@ void G_RestoreMapState(mapstate_t *save)
screenpeek = myconnectindex;
if (ud.lockout == 0)
{
for (x=g_numAnimWalls-1; x>=0; x--)
if (wall[animwall[x].wallnum].extra >= 0)
wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra;
}
else
if (ud.lockout)
{
for (x=g_numAnimWalls-1; x>=0; x--)
switch (DynamicTileMap[wall[animwall[x].wallnum].picnum])
@ -5286,6 +5280,14 @@ void G_RestoreMapState(mapstate_t *save)
break;
}
}
#if 0
else
{
for (x=g_numAnimWalls-1; x>=0; x--)
if (wall[animwall[x].wallnum].extra >= 0)
wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra;
}
#endif
G_ResetInterpolations();

View file

@ -1395,14 +1395,14 @@ void M_DisplayMenus(void)
{
ud.lockout = 0;
buf[0] = 0;
#if 0
for (x=0; x<g_numAnimWalls; x++)
if (wall[animwall[x].wallnum].picnum != W_SCREENBREAK &&
wall[animwall[x].wallnum].picnum != W_SCREENBREAK+1 &&
wall[animwall[x].wallnum].picnum != W_SCREENBREAK+2)
if (wall[animwall[x].wallnum].extra >= 0)
wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra;
#endif
}
g_currentMenu = 10000;
KB_ClearKeyDown(sc_Enter);
@ -1419,12 +1419,14 @@ void M_DisplayMenus(void)
if (ud.pwlockout[0] == 0)
{
ud.lockout = 0;
#if 0
for (x=0; x<g_numAnimWalls; x++)
if (wall[animwall[x].wallnum].picnum != W_SCREENBREAK &&
wall[animwall[x].wallnum].picnum != W_SCREENBREAK+1 &&
wall[animwall[x].wallnum].picnum != W_SCREENBREAK+2)
if (wall[animwall[x].wallnum].extra >= 0)
wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra;
#endif
}
else
{

View file

@ -2620,13 +2620,7 @@ static void postloadplayer(int32_t savegamep)
//4
if (savegamep)
{
if (ud.lockout == 0)
{
for (i=0; i<g_numAnimWalls; i++)
if (wall[animwall[i].wallnum].extra >= 0)
wall[animwall[i].wallnum].picnum = wall[animwall[i].wallnum].extra;
}
else
if (ud.lockout)
{
for (i=0; i<g_numAnimWalls; i++)
switch (DynamicTileMap[wall[animwall[i].wallnum].picnum])
@ -2640,6 +2634,14 @@ static void postloadplayer(int32_t savegamep)
break;
}
}
#if 0
else
{
for (i=0; i<g_numAnimWalls; i++)
if (wall[animwall[i].wallnum].extra >= 0)
wall[animwall[i].wallnum].picnum = wall[animwall[i].wallnum].extra;
}
#endif
}
//5