mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Rewrote the fix to:
- be comprehensive (still allow rain to be heard against the topleft corner, not just the bottomright corner) - not use volatile (now uses INT64) - not perform this pointinsubsector search if the map has no rain/thunder (yes I tested EHZ with this check dummied out so this bug won't crop up again later)
This commit is contained in:
parent
9c725a0e42
commit
31255a8cf9
1 changed files with 32 additions and 12 deletions
44
src/p_mobj.c
44
src/p_mobj.c
|
|
@ -10486,6 +10486,8 @@ void P_PrecipitationEffects(void)
|
||||||
boolean effects_lightning = (precipprops[curWeather].effects & PRECIPFX_LIGHTNING);
|
boolean effects_lightning = (precipprops[curWeather].effects & PRECIPFX_LIGHTNING);
|
||||||
boolean lightningStrike = false;
|
boolean lightningStrike = false;
|
||||||
|
|
||||||
|
boolean sounds_rain = (rainsfx != sfx_None && (!leveltime || leveltime % rainfreq == 1));
|
||||||
|
|
||||||
// No thunder except every other tic.
|
// No thunder except every other tic.
|
||||||
if (!(leveltime & 1))
|
if (!(leveltime & 1))
|
||||||
{
|
{
|
||||||
|
|
@ -10530,30 +10532,48 @@ void P_PrecipitationEffects(void)
|
||||||
if (sound_disabled)
|
if (sound_disabled)
|
||||||
return; // Sound off? D'aw, no fun.
|
return; // Sound off? D'aw, no fun.
|
||||||
|
|
||||||
|
if (!sounds_rain && !sounds_thunder)
|
||||||
|
return; // no need to calculate volume at ALL
|
||||||
|
|
||||||
if (players[g_localplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum)
|
if (players[g_localplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum)
|
||||||
volume = 255; // Sky above? We get it full blast.
|
volume = 255; // Sky above? We get it full blast.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* GCC is optimizing away y >= yl, FUCK YOU */
|
INT64 x, y, yl, yh, xl, xh;
|
||||||
volatile fixed_t x, y, yl, yh, xl, xh;
|
|
||||||
fixed_t closedist, newdist;
|
fixed_t closedist, newdist;
|
||||||
|
|
||||||
// Essentially check in a 1024 unit radius of the player for an outdoor area.
|
// Essentially check in a 1024 unit radius of the player for an outdoor area.
|
||||||
yl = players[g_localplayers[0]].mo->y - 1024*FRACUNIT;
|
#define RADIUSSTEP (64*FRACUNIT)
|
||||||
yh = players[g_localplayers[0]].mo->y + 1024*FRACUNIT;
|
#define SEARCHRADIUS (16*RADIUSSTEP)
|
||||||
xl = players[g_localplayers[0]].mo->x - 1024*FRACUNIT;
|
yl = yh = players[g_localplayers[0]].mo->y;
|
||||||
xh = players[g_localplayers[0]].mo->x + 1024*FRACUNIT;
|
yl -= SEARCHRADIUS;
|
||||||
closedist = 2048*FRACUNIT;
|
while (yl < INT32_MIN)
|
||||||
for (y = yl; y >= yl && y <= yh; y += FRACUNIT*64)
|
yl += RADIUSSTEP;
|
||||||
for (x = xl; x >= xl && x <= xh; x += FRACUNIT*64)
|
yh += SEARCHRADIUS;
|
||||||
|
while (yh > INT32_MAX)
|
||||||
|
yh -= RADIUSSTEP;
|
||||||
|
|
||||||
|
xl = xh = players[g_localplayers[0]].mo->x;
|
||||||
|
xl -= SEARCHRADIUS;
|
||||||
|
while (xl < INT32_MIN)
|
||||||
|
xl += RADIUSSTEP;
|
||||||
|
xh += SEARCHRADIUS;
|
||||||
|
while (xh > INT32_MAX)
|
||||||
|
xh -= RADIUSSTEP;
|
||||||
|
|
||||||
|
closedist = SEARCHRADIUS*2;
|
||||||
|
#undef SEARCHRADIUS
|
||||||
|
for (y = yl; y <= yh; y += RADIUSSTEP)
|
||||||
|
for (x = xl; x <= xh; x += RADIUSSTEP)
|
||||||
{
|
{
|
||||||
if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum) // Found the outdoors!
|
if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic == skyflatnum) // Found the outdoors!
|
||||||
{
|
{
|
||||||
newdist = S_CalculateSoundDistance(players[g_localplayers[0]].mo->x, players[g_localplayers[0]].mo->y, 0, x, y, 0);
|
newdist = S_CalculateSoundDistance(players[g_localplayers[0]].mo->x, players[g_localplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0);
|
||||||
if (newdist < closedist)
|
if (newdist < closedist)
|
||||||
closedist = newdist;
|
closedist = newdist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#undef RADIUSSTEP
|
||||||
|
|
||||||
volume = 255 - (closedist>>(FRACBITS+2));
|
volume = 255 - (closedist>>(FRACBITS+2));
|
||||||
}
|
}
|
||||||
|
|
@ -10563,7 +10583,7 @@ void P_PrecipitationEffects(void)
|
||||||
else if (volume > 255)
|
else if (volume > 255)
|
||||||
volume = 255;
|
volume = 255;
|
||||||
|
|
||||||
if (rainsfx != sfx_None && (!leveltime || leveltime % rainfreq == 1))
|
if (sounds_rain)
|
||||||
S_StartSoundAtVolume(players[g_localplayers[0]].mo, rainsfx, volume);
|
S_StartSoundAtVolume(players[g_localplayers[0]].mo, rainsfx, volume);
|
||||||
|
|
||||||
if (!sounds_thunder)
|
if (!sounds_thunder)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue