From 789e26b42f59f51706289c1745bdac3a42f85a8f Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 10 May 2013 12:31:37 +0000 Subject: [PATCH] Mapster32 corruptcheck: on nextsector/nextwall oob, suggest making wall white. ... in the auto-correction. Also, - make two similar corruptions level 5 (wallptr oob, wallptr+wallnum oob). - in drawscreen_drawwall(), do a more strict bound check, not only >=0. git-svn-id: https://svn.eduke32.com/eduke32@3745 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 6 ++-- polymer/eduke32/source/astub.c | 56 ++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index ea42de8f9..844c1a2d9 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -15665,7 +15665,7 @@ void draw2dgrid(int32_t posxe, int32_t posye, int32_t posze, int16_t cursectnum, static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t posze, int32_t zoome, int32_t grayp) { const walltype *wal = &wall[i]; - int32_t sect=0, j, x1, y1, x2, y2, dz = 0, dz2 = 0; + int32_t j, x1, y1, x2, y2, dz = 0, dz2 = 0; int32_t fz=0,fzn=0; // intptr_t tempint; char col; @@ -15701,7 +15701,7 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t col = 33; if ((wal->cstat&1) != 0) col = 5; - if (wal->nextwall >= 0 && ((wal->cstat^wall[j].cstat)&1)) + if ((unsigned)wal->nextwall < MAXWALLS && ((wal->cstat^wall[j].cstat)&1)) col = 2; if ((i == linehighlight) || ((linehighlight >= 0) && (i == wall[linehighlight].nextwall))) if (totalclock & 16) @@ -15734,7 +15734,7 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t { // draw vertical line to neighboring wall int32_t fz2; - sect = sectorofwall(i); + int32_t sect = sectorofwall(i); fz = getflorzofslope(sect, wal->x,wal->y); fz2 = getflorzofslope(sect, wall[wal->point2].x,wall[wal->point2].y); diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index d69f6dc89..8fe3a19f2 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -11573,6 +11573,9 @@ static int32_t check_spritelist_consistency() return 0; } +#define TRYFIX_NONE() (tryfixing == 0ull) +#define TRYFIX_CNUM(onumct) (onumct < MAXCORRUPTTHINGS && (tryfixing & (1ull<= MAXWALLS) CORRUPTCHK_PRINT(5, CORRUPT_SECTOR|i, "SECTOR[%d].WALLPTR=%d INVALID!!!", i, w0); else - CORRUPTCHK_PRINT(4, CORRUPT_SECTOR|i, "SECTOR[%d].WALLPTR=%d out of range (numwalls=%d)", i, w0, numw); + CORRUPTCHK_PRINT(5, CORRUPT_SECTOR|i, "SECTOR[%d].WALLPTR=%d out of range (numwalls=%d)", i, w0, numw); } if (w0 != ewall) @@ -11642,7 +11645,7 @@ int32_t CheckMapCorruption(int32_t printfromlev, uint64_t tryfixing) endwall = w0 + numw; if (endwall > numwalls) - CORRUPTCHK_PRINT(4, CORRUPT_SECTOR|i, "SECTOR[%d]: wallptr+wallnum=%d out of range: numwalls=%d", i, endwall, numwalls); + CORRUPTCHK_PRINT(5, CORRUPT_SECTOR|i, "SECTOR[%d]: wallptr+wallnum=%d out of range: numwalls=%d", i, endwall, numwalls); // inconsistent cstat&2 and heinum checker { @@ -11697,26 +11700,49 @@ int32_t CheckMapCorruption(int32_t printfromlev, uint64_t tryfixing) } nw = wall[j].nextwall; - ns = wall[j].nextsector; if (nw >= numwalls) { - if (nw >= MAXWALLS) - CORRUPTCHK_PRINT(5, CORRUPT_WALL|j, "WALL[%d].NEXTWALL=%d INVALID!!!", - j, nw); - else - CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTWALL=%d out of range: numwalls=%d", - j, nw, numwalls); + int32_t onumct = numcorruptthings; + + if (TRYFIX_NONE()) + { + if (nw >= MAXWALLS) + CORRUPTCHK_PRINT(5, CORRUPT_WALL|j, "WALL[%d].NEXTWALL=%d INVALID!!!", + j, nw); + else + CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTWALL=%d out of range: numwalls=%d", + j, nw, numwalls); + OSD_Printf(" will make wall %d white on tryfix\n", j); + } + else if (TRYFIX_CNUM(onumct)) // CODEDUP MAKE_WALL_WHITE + { + wall[j].nextwall = wall[j].nextsector = -1; + OSD_Printf(CCHK_CORRECTED "auto-correction: made wall %d white\n", j); + } } + ns = wall[j].nextsector; + if (ns >= numsectors) { - if (ns >= MAXSECTORS) - CORRUPTCHK_PRINT(5, CORRUPT_WALL|j, "WALL[%d].NEXTSECTOR=%d INVALID!!!", - j, ns); - else - CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTSECTOR=%d out of range: numsectors=%d", - j, ns, numsectors); + int32_t onumct = numcorruptthings; + + if (TRYFIX_NONE()) + { + if (ns >= MAXSECTORS) + CORRUPTCHK_PRINT(5, CORRUPT_WALL|j, "WALL[%d].NEXTSECTOR=%d INVALID!!!", + j, ns); + else + CORRUPTCHK_PRINT(4, CORRUPT_WALL|j, "WALL[%d].NEXTSECTOR=%d out of range: numsectors=%d", + j, ns, numsectors); + OSD_Printf(" will make wall %d white on tryfix\n", j); + } + else if (TRYFIX_CNUM(onumct)) // CODEDUP MAKE_WALL_WHITE + { + wall[j].nextwall = wall[j].nextsector = -1; + OSD_Printf(CCHK_CORRECTED "auto-correction: made wall %d white\n", j); + } } if (nw>=w0 && nw<=endwall)