Fix limit_dist overflowing for some mapobjectscale values

This commit is contained in:
indev committed 2025-03-26 22:11:50 +03:00
1 parent 1e8716450f
commit 0d6b42cc3f
3 files changed
+8 -8

No files matched your search

+4 -4
View File
@@ -4430,7 +4430,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
@@ -4446,12 +4446,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
@@ -2061,7 +2061,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)
{
@@ -2900,11 +2900,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);