Merge branch 'game-would-have-crashed' into 'master'

Remove GAME WOULD HAVE CRASHED console message, remove `RANGECHECK`

See merge request KartKrew/Kart!2002
This commit is contained in:
AJ Martinez 2024-03-05 05:42:42 +00:00
commit deb5bfdafa
9 changed files with 36 additions and 82 deletions

View file

@ -579,7 +579,7 @@ target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
# Misc. build options from Makefiles # Misc. build options from Makefiles
if(SRB2_CONFIG_DEBUGMODE) if(SRB2_CONFIG_DEBUGMODE)
target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG -DPARANOIA -DRANGECHECK -DPACKETDROP) target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG -DPARANOIA -DPACKETDROP)
endif() endif()
if(SRB2_CONFIG_TESTERS) if(SRB2_CONFIG_TESTERS)
target_compile_definitions(SRB2SDL2 PRIVATE -DTESTERS) target_compile_definitions(SRB2SDL2 PRIVATE -DTESTERS)

View file

@ -67,12 +67,10 @@ extern "C" {
#if !defined (NDEBUG) #if !defined (NDEBUG)
#define PACKETDROP #define PACKETDROP
#define PARANOIA #define PARANOIA
//#define RANGECHECK
#define ZDEBUG #define ZDEBUG
#endif #endif
// Uncheck this to compile debugging code // Uncheck this to compile debugging code
#define RANGECHECK
//#ifndef PARANOIA //#ifndef PARANOIA
//#define PARANOIA // do some tests that never fail but maybe //#define PARANOIA // do some tests that never fail but maybe
// turn this on by make etc.. DEBUGMODE = 1 or use the Debug profile in the VC++ projects // turn this on by make etc.. DEBUGMODE = 1 or use the Debug profile in the VC++ projects

View file

@ -4740,10 +4740,11 @@ static void HWR_ProjectSprite(mobj_t *thing)
tr_y = FIXED_TO_FLOAT(interp.y); tr_y = FIXED_TO_FLOAT(interp.y);
// decide which patch to use for sprite relative to player // decide which patch to use for sprite relative to player
#ifdef RANGECHECK
if ((unsigned)thing->sprite >= numsprites) if ((unsigned)thing->sprite >= numsprites)
I_Error("HWR_ProjectSprite: invalid sprite number %i ", thing->sprite); {
#endif CONS_Debug(DBG_RENDER, "HWR_ProjectSprite: invalid sprite number %i\n", thing->sprite);
return;
}
rot = thing->frame&FF_FRAMEMASK; rot = thing->frame&FF_FRAMEMASK;
@ -5184,22 +5185,20 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
// decide which patch to use for sprite relative to player // decide which patch to use for sprite relative to player
if ((unsigned)thing->sprite >= numsprites) if ((unsigned)thing->sprite >= numsprites)
#ifdef RANGECHECK {
I_Error("HWR_ProjectPrecipitationSprite: invalid sprite number %i ", CONS_Debug(DBG_RENDER, "HWR_ProjectPrecipitationSprite: invalid sprite number %i\n",
thing->sprite); thing->sprite);
#else
return; return;
#endif }
sprdef = &sprites[thing->sprite]; sprdef = &sprites[thing->sprite];
if ((size_t)(thing->frame&FF_FRAMEMASK) >= sprdef->numframes) if ((size_t)(thing->frame&FF_FRAMEMASK) >= sprdef->numframes)
#ifdef RANGECHECK {
I_Error("HWR_ProjectPrecipitationSprite: invalid sprite frame %i : %i for %s", CONS_Debug(DBG_RENDER, "HWR_ProjectPrecipitationSprite: invalid sprite frame %i : %i for %s\n",
thing->sprite, thing->frame, sprnames[thing->sprite]); thing->sprite, thing->frame, sprnames[thing->sprite]);
#else
return; return;
#endif }
sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK]; sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK];

View file

@ -1427,15 +1427,11 @@ void T_PolyObjRotate(polyrotate_t *th)
polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); polyobj_t *po = Polyobj_GetForNum(th->polyObjNum);
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyObjRotate: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyObjRotate: thinker with invalid id %d removed.\n", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyObjRotate: thinker with invalid id %d removed.\n", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (po->thinker == NULL) if (po->thinker == NULL)
@ -1508,15 +1504,11 @@ void T_PolyObjMove(polymove_t *th)
polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); polyobj_t *po = Polyobj_GetForNum(th->polyObjNum);
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyObjMove: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyObjMove: thinker with invalid id %d removed.\n", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyObjMove: thinker with invalid id %d removed.\n", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (po->thinker == NULL) if (po->thinker == NULL)
@ -1598,15 +1590,11 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
fixed_t speed = th->speed; fixed_t speed = th->speed;
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyObjWaypoint: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyObjWaypoint: thinker with invalid id %d removed.", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyObjWaypoint: thinker with invalid id %d removed.", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (!po->thinker) if (!po->thinker)
@ -1714,15 +1702,11 @@ void T_PolyDoorSlide(polyslidedoor_t *th)
polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); polyobj_t *po = Polyobj_GetForNum(th->polyObjNum);
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyDoorSlide: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyDoorSlide: thinker with invalid id %d removed.\n", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyDoorSlide: thinker with invalid id %d removed.\n", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (po->thinker == NULL) if (po->thinker == NULL)
@ -1819,15 +1803,11 @@ void T_PolyDoorSwing(polyswingdoor_t *th)
polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); polyobj_t *po = Polyobj_GetForNum(th->polyObjNum);
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyDoorSwing: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyDoorSwing: thinker with invalid id %d removed.\n", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyDoorSwing: thinker with invalid id %d removed.\n", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (po->thinker == NULL) if (po->thinker == NULL)
@ -1918,15 +1898,11 @@ void T_PolyObjDisplace(polydisplace_t *th)
fixed_t dx, dy; fixed_t dx, dy;
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyObjDisplace: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyObjDisplace: thinker with invalid id %d removed.\n", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyObjDisplace: thinker with invalid id %d removed.\n", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (po->thinker == NULL) if (po->thinker == NULL)
@ -1958,15 +1934,11 @@ void T_PolyObjRotDisplace(polyrotdisplace_t *th)
fixed_t rotangle; fixed_t rotangle;
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyObjRotDisplace: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyObjRotDisplace: thinker with invalid id %d removed.\n", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyObjRotDisplace: thinker with invalid id %d removed.\n", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (po->thinker == NULL) if (po->thinker == NULL)
@ -2442,15 +2414,11 @@ void T_PolyObjFlag(polymove_t *th)
size_t i; size_t i;
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyObjFlag: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyObjFlag: thinker with invalid id %d removed.\n", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyObjFlag: thinker with invalid id %d removed.\n", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (po->thinker == NULL) if (po->thinker == NULL)
@ -2549,15 +2517,11 @@ void T_PolyObjFade(polyfade_t *th)
polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); polyobj_t *po = Polyobj_GetForNum(th->polyObjNum);
if (!po) if (!po)
#ifdef RANGECHECK
I_Error("T_PolyObjFade: thinker has invalid id %d\n", th->polyObjNum);
#else
{ {
CONS_Debug(DBG_POLYOBJ, "T_PolyObjFade: thinker with invalid id %d removed.\n", th->polyObjNum); CONS_Debug(DBG_POLYOBJ, "T_PolyObjFade: thinker with invalid id %d removed.\n", th->polyObjNum);
P_RemoveThinker(&th->thinker); P_RemoveThinker(&th->thinker);
return; return;
} }
#endif
// check for displacement due to override and reattach when possible // check for displacement due to override and reattach when possible
if (po->thinker == NULL) if (po->thinker == NULL)

View file

@ -469,10 +469,11 @@ static boolean P_CrossSubsector(size_t num, register los_t *los, register los_fu
seg_t *seg; seg_t *seg;
INT32 count; INT32 count;
#ifdef RANGECHECK
if (num >= numsubsectors) if (num >= numsubsectors)
I_Error("P_CrossSubsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); {
#endif CONS_Debug(DBG_RENDER, "P_CrossSubsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors));
return true;
}
// haleyjd 02/23/06: this assignment should be after the above check // haleyjd 02/23/06: this assignment should be after the above check
seg = segs + subsectors[num].firstline; seg = segs + subsectors[num].firstline;

View file

@ -909,14 +909,12 @@ static void R_Subsector(size_t num)
ZoneScoped; ZoneScoped;
#ifdef RANGECHECK
if (num >= numsubsectors)
I_Error("R_Subsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors));
#endif
// subsectors added at run-time // subsectors added at run-time
if (num >= numsubsectors) if (num >= numsubsectors)
{
CONS_Debug(DBG_RENDER, "R_Subsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors));
return; return;
}
sub = &subsectors[num]; sub = &subsectors[num];
frontsector = sub->sector; frontsector = sub->sector;

View file

@ -105,12 +105,10 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
return; return;
} }
#ifdef RANGECHECK
if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height)
{ {
return; return;
} }
#endif
if constexpr (Type & DrawColumnType::DC_LIGHTLIST) if constexpr (Type & DrawColumnType::DC_LIGHTLIST)
{ {
@ -341,10 +339,8 @@ void R_DrawFogColumn(drawcolumndata_t *dc)
if (count < 0) if (count < 0)
return; return;
#ifdef RANGECHECK
if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height)
return; return;
#endif
// Framebuffer destination address. // Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth. // Use ylookup LUT to avoid multiply with ScreenWidth.
@ -408,10 +404,8 @@ void R_DrawColumn_Flat(drawcolumndata_t *dc)
if (count < 0) // Zero length, column does not exceed a pixel. if (count < 0) // Zero length, column does not exceed a pixel.
return; return;
#ifdef RANGECHECK
if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height)
return; return;
#endif
// Framebuffer destination address. // Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth. // Use ylookup LUT to avoid multiply with ScreenWidth.

View file

@ -1073,9 +1073,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
} }
else if (vis->cut & SC_SHEAR) else if (vis->cut & SC_SHEAR)
{ {
#ifdef RANGECHECK
pwidth = patch->width; pwidth = patch->width;
#endif
// Vertically sheared sprite // Vertically sheared sprite
for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, frac += vis->xiscale, dc.texturemid -= vis->shear.tan) for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, frac += vis->xiscale, dc.texturemid -= vis->shear.tan)
@ -1093,7 +1091,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
else else
{ {
#ifdef RANGECHECK #if 0
if (vis->x1test && vis->x2test) if (vis->x1test && vis->x2test)
{ {
INT32 x1test = vis->x1test; INT32 x1test = vis->x1test;
@ -1112,7 +1110,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
CONS_Printf("THE GAME WOULD HAVE CRASHED, %d (old) vs %d (new)\n", (x2test - x1test), (vis->x2 - vis->x1)); CONS_Printf("THE GAME WOULD HAVE CRASHED, %d (old) vs %d (new)\n", (x2test - x1test), (vis->x2 - vis->x1));
} }
} }
#endif // RANGECHECK #endif
// Non-paper drawing loop // Non-paper drawing loop
for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan) for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan)
@ -1191,10 +1189,11 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
{ {
texturecolumn = frac>>FRACBITS; texturecolumn = frac>>FRACBITS;
#ifdef RANGECHECK
if (texturecolumn < 0 || texturecolumn >= patch->width) if (texturecolumn < 0 || texturecolumn >= patch->width)
I_Error("R_DrawPrecipitationSpriteRange: bad texturecolumn"); {
#endif CONS_Debug(DBG_RENDER, "R_DrawPrecipitationSpriteRange: bad texturecolumn\n");
break;
}
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn]));
@ -1832,10 +1831,11 @@ static void R_ProjectSprite(mobj_t *thing)
sortscale = FixedDiv(projectiony[viewssnum], tz); sortscale = FixedDiv(projectiony[viewssnum], tz);
// decide which patch to use for sprite relative to player // decide which patch to use for sprite relative to player
#ifdef RANGECHECK
if ((size_t)(thing->sprite) >= numsprites) if ((size_t)(thing->sprite) >= numsprites)
I_Error("R_ProjectSprite: invalid sprite number %d ", thing->sprite); {
#endif CONS_Debug(DBG_RENDER, "R_ProjectSprite: invalid sprite number %d\n", thing->sprite);
return;
}
frame = thing->frame&FF_FRAMEMASK; frame = thing->frame&FF_FRAMEMASK;
@ -2634,19 +2634,21 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
yscale = FixedDiv(projectiony[viewssnum], tz); yscale = FixedDiv(projectiony[viewssnum], tz);
// decide which patch to use for sprite relative to player // decide which patch to use for sprite relative to player
#ifdef RANGECHECK
if ((unsigned)thing->sprite >= numsprites) if ((unsigned)thing->sprite >= numsprites)
I_Error("R_ProjectPrecipitationSprite: invalid sprite number %d ", {
CONS_Debug(DBG_RENDER, "R_ProjectPrecipitationSprite: invalid sprite number %d\n",
thing->sprite); thing->sprite);
#endif return;
}
sprdef = &sprites[thing->sprite]; sprdef = &sprites[thing->sprite];
#ifdef RANGECHECK
if ((UINT8)(thing->frame&FF_FRAMEMASK) >= sprdef->numframes) if ((UINT8)(thing->frame&FF_FRAMEMASK) >= sprdef->numframes)
I_Error("R_ProjectPrecipitationSprite: invalid sprite frame %d : %d for %s", {
CONS_Debug(DBG_RENDER, "R_ProjectPrecipitationSprite: invalid sprite frame %d : %d for %s\n",
thing->sprite, thing->frame, sprnames[thing->sprite]); thing->sprite, thing->frame, sprnames[thing->sprite]);
#endif return;
}
sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK]; sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK];

View file

@ -987,10 +987,8 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const
UINT8 *dest; UINT8 *dest;
const UINT8 *deststop; const UINT8 *deststop;
#ifdef RANGECHECK
if (x < 0 || x + width > vid.width || y < 0 || y + height > vid.height || (unsigned)scrn > 4) if (x < 0 || x + width > vid.width || y < 0 || y + height > vid.height || (unsigned)scrn > 4)
I_Error("Bad V_DrawBlock"); I_Error("Bad V_DrawBlock");
#endif
dest = screens[scrn] + y*vid.width + x; dest = screens[scrn] + y*vid.width + x;
deststop = screens[scrn] + vid.rowbytes * vid.height; deststop = screens[scrn] + vid.rowbytes * vid.height;