diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf9fa2cfc..b47e248c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -579,7 +579,7 @@ target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG) # Misc. build options from Makefiles if(SRB2_CONFIG_DEBUGMODE) - target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG -DPARANOIA -DRANGECHECK -DPACKETDROP) + target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG -DPARANOIA -DPACKETDROP) endif() if(SRB2_CONFIG_TESTERS) target_compile_definitions(SRB2SDL2 PRIVATE -DTESTERS) diff --git a/src/doomdef.h b/src/doomdef.h index 14c879506..bdaeb556a 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -67,12 +67,10 @@ extern "C" { #if !defined (NDEBUG) #define PACKETDROP #define PARANOIA -//#define RANGECHECK #define ZDEBUG #endif // Uncheck this to compile debugging code -#define RANGECHECK //#ifndef PARANOIA //#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 diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2beed6727..f81a4e2f4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4740,10 +4740,11 @@ static void HWR_ProjectSprite(mobj_t *thing) tr_y = FIXED_TO_FLOAT(interp.y); // decide which patch to use for sprite relative to player -#ifdef RANGECHECK 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; @@ -5184,22 +5185,20 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) // decide which patch to use for sprite relative to player 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); -#else return; -#endif + } sprdef = &sprites[thing->sprite]; 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]); -#else return; -#endif + } sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK]; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 021b8520e..62566c44d 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1427,15 +1427,11 @@ void T_PolyObjRotate(polyrotate_t *th) polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (po->thinker == NULL) @@ -1508,15 +1504,11 @@ void T_PolyObjMove(polymove_t *th) polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (po->thinker == NULL) @@ -1598,15 +1590,11 @@ void T_PolyObjWaypoint(polywaypoint_t *th) fixed_t speed = th->speed; 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (!po->thinker) @@ -1714,15 +1702,11 @@ void T_PolyDoorSlide(polyslidedoor_t *th) polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (po->thinker == NULL) @@ -1819,15 +1803,11 @@ void T_PolyDoorSwing(polyswingdoor_t *th) polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (po->thinker == NULL) @@ -1918,15 +1898,11 @@ void T_PolyObjDisplace(polydisplace_t *th) fixed_t dx, dy; 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (po->thinker == NULL) @@ -1958,15 +1934,11 @@ void T_PolyObjRotDisplace(polyrotdisplace_t *th) fixed_t rotangle; 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (po->thinker == NULL) @@ -2442,15 +2414,11 @@ void T_PolyObjFlag(polymove_t *th) size_t i; 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (po->thinker == NULL) @@ -2549,15 +2517,11 @@ void T_PolyObjFade(polyfade_t *th) polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); 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); P_RemoveThinker(&th->thinker); return; } -#endif // check for displacement due to override and reattach when possible if (po->thinker == NULL) diff --git a/src/p_sight.c b/src/p_sight.c index e23fe13a5..c145ffbfd 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -469,10 +469,11 @@ static boolean P_CrossSubsector(size_t num, register los_t *los, register los_fu seg_t *seg; INT32 count; -#ifdef RANGECHECK 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 seg = segs + subsectors[num].firstline; diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 736037dac..6d5f93214 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -909,14 +909,12 @@ static void R_Subsector(size_t num) 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 if (num >= numsubsectors) + { + CONS_Debug(DBG_RENDER, "R_Subsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); return; + } sub = &subsectors[num]; frontsector = sub->sector; diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp index d9c1cf244..32656bf37 100644 --- a/src/r_draw_column.cpp +++ b/src/r_draw_column.cpp @@ -105,12 +105,10 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) return; } -#ifdef RANGECHECK if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) { return; } -#endif if constexpr (Type & DrawColumnType::DC_LIGHTLIST) { @@ -341,10 +339,8 @@ void R_DrawFogColumn(drawcolumndata_t *dc) if (count < 0) return; -#ifdef RANGECHECK if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) return; -#endif // Framebuffer destination address. // 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. return; -#ifdef RANGECHECK if ((unsigned)dc->x >= (unsigned)vid.width || dc->yl < 0 || dc->yh >= vid.height) return; -#endif // Framebuffer destination address. // Use ylookup LUT to avoid multiply with ScreenWidth. diff --git a/src/r_things.cpp b/src/r_things.cpp index 2e948db57..52cb52521 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1073,9 +1073,7 @@ static void R_DrawVisSprite(vissprite_t *vis) } else if (vis->cut & SC_SHEAR) { -#ifdef RANGECHECK pwidth = patch->width; -#endif // Vertically sheared sprite 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 { -#ifdef RANGECHECK +#if 0 if (vis->x1test && vis->x2test) { 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)); } } -#endif // RANGECHECK +#endif // Non-paper drawing loop 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; -#ifdef RANGECHECK 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])); @@ -1832,10 +1831,11 @@ static void R_ProjectSprite(mobj_t *thing) sortscale = FixedDiv(projectiony[viewssnum], tz); // decide which patch to use for sprite relative to player -#ifdef RANGECHECK 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; @@ -2634,19 +2634,21 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) yscale = FixedDiv(projectiony[viewssnum], tz); // decide which patch to use for sprite relative to player -#ifdef RANGECHECK 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); -#endif + return; + } sprdef = &sprites[thing->sprite]; -#ifdef RANGECHECK 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]); -#endif + return; + } sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK]; diff --git a/src/v_video.cpp b/src/v_video.cpp index 50c431e3d..b37c1ad3c 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -987,10 +987,8 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const UINT8 *dest; const UINT8 *deststop; -#ifdef RANGECHECK if (x < 0 || x + width > vid.width || y < 0 || y + height > vid.height || (unsigned)scrn > 4) I_Error("Bad V_DrawBlock"); -#endif dest = screens[scrn] + y*vid.width + x; deststop = screens[scrn] + vid.rowbytes * vid.height;