diff --git a/src/k_kart.c b/src/k_kart.c index 90d3de9ca..12dbb5f32 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6843,10 +6843,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_KartDrift(player, onground); - if ((!player->kartstuff[k_aizdriftstrat]) || (!P_IsObjectOnGround(player->mo)) || (player->kartstuff[k_drift])) + if (player->sliproll && ((!player->kartstuff[k_aizdriftstrat]) || (!P_IsObjectOnGround(player->mo)) || (player->kartstuff[k_drift]))) { - if (player->sliproll && (player->sliproll > 0)) - player->sliproll -= (4*ANG1); + player->sliproll -= (4*ANG1); } // funneh Saturn sprite stuff diff --git a/src/p_mobj.c b/src/p_mobj.c index 1b4b1c947..8ca51ef6c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8995,6 +8995,8 @@ void P_MobjThinker(mobj_t *mobj) tmfloorthing = tmhitthing = NULL; + const sector_t *sec1 = mobj->subsector ? mobj->subsector->sector : NULL; + // 970 allows ANY mobj to trigger a linedef exec if (UNLIKELY(sec1 && GETSECSPECIAL(sec1->special, 2) == 8)) { @@ -10322,9 +10324,11 @@ void P_PrecipitationEffects(void) P_SpawnLightningFlash(ss); // Spawn a quick flash thinker } + const mobj_t *pmo = players[displayplayers[0]].mo; + // Local effects from here on out! // If we're not in game fully yet, we don't worry about them. - if (!playeringame[displayplayers[0]] || !players[displayplayers[0]].mo) + if (!playeringame[displayplayers[0]] || !pmo) return; if (sound_disabled) @@ -10333,7 +10337,7 @@ void P_PrecipitationEffects(void) if (!sounds_rain && !sounds_thunder) return; // no need to calculate volume at ALL - if (players[displayplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum) + if (pmo->subsector->sector->ceilingpic == skyflatnum) volume = 255; // Sky above? We get it full blast. else { @@ -10344,7 +10348,7 @@ void P_PrecipitationEffects(void) // Essentially check in a 1024 unit radius of the player for an outdoor area. #define RADIUSSTEP (64*FRACUNIT) #define SEARCHRADIUS (16*RADIUSSTEP) - yl = yh = players[displayplayers[0]].mo->y; + yl = yh = pmo->y; yl -= SEARCHRADIUS; while (yl < INT32_MIN) yl += RADIUSSTEP; @@ -10352,7 +10356,7 @@ void P_PrecipitationEffects(void) while (yh > INT32_MAX) yh -= RADIUSSTEP; - xl = xh = players[displayplayers[0]].mo->x; + xl = xh = pmo->x; xl -= SEARCHRADIUS; while (xl < INT32_MIN) xl += RADIUSSTEP; @@ -10368,20 +10372,19 @@ void P_PrecipitationEffects(void) if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! continue; - newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0); + newdist = S_CalculateSoundDistance(pmo->x, pmo->y, 0, (fixed_t)x, (fixed_t)y, 0); if (newdist < closedist) closedist = newdist; } volume = 255 - (closedist>>(FRACBITS+2)); + volume = CLAMP(volume, 0, 255); } #undef RADIUSSTEP - volume = CLAMP(volume, 0, 255); - if (sounds_rain) - S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume); + S_StartSoundAtVolume(pmo, sfx_rainin, volume); if (!sounds_thunder) return; @@ -10389,7 +10392,7 @@ void P_PrecipitationEffects(void) if (effects_lightning && lightningStrike && volume) { // Large, close thunder sounds to go with our lightning. - S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_litng1 + M_RandomKey(4), volume); + S_StartSoundAtVolume(pmo, sfx_litng1 + M_RandomKey(4), volume); } else if (thunderchance < 20) { @@ -10397,7 +10400,7 @@ void P_PrecipitationEffects(void) if (volume < 80) volume = 80; - S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_athun1 + M_RandomKey(2), volume); + S_StartSoundAtVolume(pmo, sfx_athun1 + M_RandomKey(2), volume); } }