From 146e1f1c09ec76078086bb8c1e8c2610f8045fc0 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 5 Jan 2012 20:48:37 +0000 Subject: [PATCH] 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 --- polymer/eduke32/source/gameexec.c | 16 +++++++++------- polymer/eduke32/source/menus.c | 6 ++++-- polymer/eduke32/source/savegame.c | 16 +++++++++------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 2d90336b2..2458c3c95 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -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(); diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index f950febaa..3d05a8eb8 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -1395,14 +1395,14 @@ void M_DisplayMenus(void) { ud.lockout = 0; buf[0] = 0; - +#if 0 for (x=0; x= 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= 0) wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra; +#endif } else { diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index c4d2c7c68..3c249c24c 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -2620,13 +2620,7 @@ static void postloadplayer(int32_t savegamep) //4 if (savegamep) { - if (ud.lockout == 0) - { - for (i=0; i= 0) - wall[animwall[i].wallnum].picnum = wall[animwall[i].wallnum].extra; - } - else + if (ud.lockout) { for (i=0; i= 0) + wall[animwall[i].wallnum].picnum = wall[animwall[i].wallnum].extra; + } +#endif } //5