Fix limit_dist overflowing for some mapobjectscale values

This commit is contained in:
indev authored and Alug committed 2025-03-26 20:22:16 +01:00
1 parent 60ff34d7de
commit 6661d98e5f
3 files changed
+8 -8

No files matched your search

+4 -4
View File
@@ -4463,7 +4463,7 @@ static void HWR_DrawModels(void)
static void HWR_AddSprites(sector_t *sec)
{
mobj_t *thing;
fixed_t limit_dist;
INT32 limit_dist;
// BSP is traversed by subsector.
// A sector might have been split into several
@@ -4479,12 +4479,12 @@ static void HWR_AddSprites(sector_t *sec)
{
// Use the smaller setting
if (cv_drawdist.value)
limit_dist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) * mapobjectscale);
limit_dist = min(current_bsp_culling_distance/mapobjectscale, cv_drawdist.value);
else
limit_dist = (fixed_t)current_bsp_culling_distance;
limit_dist = current_bsp_culling_distance/mapobjectscale;
}
else
limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale;
limit_dist = cv_drawdist.value;
// Handle all things in sector.
for (thing = sec->thinglist; thing; thing = thing->snext)
+3 -3
View File
@@ -2069,7 +2069,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel)
// Handle all things in sector.
// If a limit exists, handle things a tiny bit different.
const fixed_t limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale;
const INT32 limit_dist = cv_drawdist.value;
for (thing = sec->thinglist; thing; thing = thing->snext)
{
@@ -2905,11 +2905,11 @@ boolean R_ThingVisible (mobj_t *thing)
return true;
}
boolean R_ThingWithinDist(mobj_t *thing, fixed_t limit_dist)
boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist)
{
if (limit_dist)
{
if (P_AproxDistance(viewx-thing->x, viewy-thing->y) > limit_dist)
if (P_AproxDistance(viewx-thing->x, viewy-thing->y)/mapobjectscale > limit_dist)
{
return false;
}
+1 -1
View File
@@ -77,7 +77,7 @@ void R_ClearSprites(void);
void R_DrawMasked(void);
boolean R_ThingVisible (mobj_t *thing);
boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist);
boolean R_ThingWithinDist (mobj_t *thing, INT32 limit_dist);
boolean R_ThingIsFullBright (mobj_t *thing);
boolean R_ThingIsSemiBright (mobj_t *thing);