move a bunch of stuff after early returns

+ add some branching instrincts to stuff

maybe saves a bit of time if we dont need the thing
This commit is contained in:
Alug committed 2025-07-21 11:49:44 +02:00
1 parent d9d2f043fa
commit 4fa0ca2304
4 files changed
+107 -76

No files matched your search

+45 -23
View File
@@ -1612,7 +1612,7 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo)
// we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF.
// Reminder that an FOF's floor is its bottom, silly!
if ( ((s2->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == cel) // "floor" check
if ( ((s2->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == cel) // "floor" check
|| ((s2->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == flr) ) // "ceiling" check.
for (i = 2; i < 5; i++) // check for sector special
@@ -1696,10 +1696,10 @@ static void K_SpawnDashDustRelease(player_t *player)
I_Assert(player->mo != NULL);
I_Assert(!P_MobjWasRemoved(player->mo));
if (!P_IsObjectOnGround(player->mo))
if (!player->speed && !player->kartstuff[k_startboost])
return;
if (!player->speed && !player->kartstuff[k_startboost])
if (!P_IsObjectOnGround(player->mo))
return;
travelangle = player->mo->angle;
@@ -1929,11 +1929,11 @@ static void K_PlayGenericCombatSound(mobj_t *source, mobj_t *other, sfxenum_t sf
boolean alwaysHear = false;
if (other != NULL && P_MobjWasRemoved(other) == false && other->player != NULL)
if (cv_kartvoices.value && !P_MobjWasRemoved(other) && other->player != NULL)
{
alwaysHear = P_IsDisplayPlayer(other->player);
if (cv_kartvoices.value)
S_StartSound(alwaysHear ? NULL : source, skin->soundsid[S_sfx[sfx_id].skinsound]);
}
K_RegularVoiceTimers(source->player);
}
@@ -1955,7 +1955,7 @@ void K_PlayAttackTaunt(mobj_t *source)
void K_PlayBoostTaunt(mobj_t *source)
{
sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons
boolean tasteful = (!source->player || !source->player->kartstuff[k_tauntvoices]);
const boolean tasteful = (!source->player || !source->player->kartstuff[k_tauntvoices]);
if (cv_kartvoices.value && (tasteful || cv_kartvoices.value == 2))
S_StartSound(source, sfx_kbost1+pick);
@@ -1968,8 +1968,6 @@ void K_PlayBoostTaunt(mobj_t *source)
void K_PlayOvertakeSound(mobj_t *source)
{
boolean tasteful = (!source->player || !source->player->kartstuff[k_voices]);
if (!G_RaceGametype()) // Only in race
return;
@@ -1977,6 +1975,8 @@ void K_PlayOvertakeSound(mobj_t *source)
if (leveltime < starttime+(10*TICRATE))
return;
const boolean tasteful = (!source->player || !source->player->kartstuff[k_voices]);
if (cv_kartvoices.value && (tasteful || cv_kartvoices.value == 2))
S_StartSound(source, sfx_kslow);
@@ -2212,6 +2212,7 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower)
if (doboostpower)
return FixedMul(finalspeed, player->kartstuff[k_boostpower]+player->kartstuff[k_speedboost]);
return finalspeed;
}
@@ -2248,10 +2249,14 @@ fixed_t K_3dKartMovement(player_t *player, boolean onground, fixed_t forwardmove
{
fixed_t accelmax = 4000;
fixed_t newspeed, oldspeed, finalspeed;
fixed_t p_speed = K_GetKartSpeed(player, true);
fixed_t p_accel = K_GetKartAccel(player);
fixed_t p_speed, p_accel;
if (!onground) return 0; // If the player isn't on the ground, there is no change in speed
// If the player isn't on the ground, there is no change in speed
if (!onground)
return 0;
p_speed = K_GetKartSpeed(player, true);
p_accel = K_GetKartAccel(player);
// ACCELCODE!!!1!11!
oldspeed = R_PointToDist2(0, 0, player->rmomx, player->rmomy); // FixedMul(P_AproxDistance(player->rmomx, player->rmomy), player->mo->scale);
@@ -2355,6 +2360,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto
if (P_MobjWasRemoved(player->mo))
return; // mobj was removed (in theory that shouldn't happen)
if (shouldForce == 1)
force = true;
else if (shouldForce == 2)
@@ -2495,8 +2501,10 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor)
// PS: Inflictor is unused for all purposes here and is actually only ever relevant to Lua. It may be nil too.
boolean force = false; // Used to check if Lua ShouldSquish should get us damaged reguardless of flashtics or heck knows what.
UINT8 shouldForce = LUA_HookShouldSquish(player, inflictor, source);
if (P_MobjWasRemoved(player->mo))
return; // mobj was removed (in theory that shouldn't happen)
if (shouldForce == 1)
force = true;
else if (shouldForce == 2)
@@ -2609,6 +2617,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b
if (P_MobjWasRemoved(player->mo))
return; // mobj was removed (in theory that shouldn't happen)
if (shouldForce == 1)
force = true;
else if (shouldForce == 2)
@@ -2694,6 +2703,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b
player->powers[pw_flashing] = K_GetKartFlashing(player);
upgoer = (18*mapobjectscale*P_MobjFlip(player->mo));
if (player->mo->eflags & MFE_UNDERWATER)
upgoer = (117 * upgoer) / 200;
@@ -3629,7 +3639,6 @@ void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent)
void K_DriftDustHandling(mobj_t *spawner)
{
angle_t anglediff;
const INT16 spawnrange = spawner->radius>>FRACBITS;
if (!P_IsObjectOnGround(spawner) || leveltime % 2 != 0)
return;
@@ -3666,6 +3675,8 @@ void K_DriftDustHandling(mobj_t *spawner)
if (anglediff > ANGLE_180)
anglediff = InvAngle(anglediff);
const INT16 spawnrange = spawner->radius>>FRACBITS;
if (anglediff > ANG10*4) // Trying to turn further than 40 degrees
{
fixed_t spawnx = P_RandomRange(-spawnrange, spawnrange)<<FRACBITS;
@@ -3925,9 +3936,8 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map
void K_PuntMine(mobj_t *thismine, mobj_t *punter)
{
angle_t fa = R_PointToAngle2(0, 0, punter->momx, punter->momy) >> ANGLETOFINESHIFT;
fixed_t z = 30*mapobjectscale + punter->momz;
fixed_t spd;
angle_t fa;
fixed_t z, spd;
mobj_t *mine;
if (P_MobjWasRemoved(thismine))
@@ -3962,6 +3972,9 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter)
if (P_MobjWasRemoved(mine))
return;
fa = R_PointToAngle2(0, 0, punter->momx, punter->momy) >> ANGLETOFINESHIFT;
z = 30*mapobjectscale + punter->momz;
spd = K_GetProjectileSpeed();
mine->flags |= MF_NOCLIPTHING;
@@ -4173,8 +4186,10 @@ static void K_DoShrink(player_t *user)
{
if (!playeringame[i] || players[i].spectator || !players[i].mo)
continue;
if (&players[i] == user)
continue;
if (players[i].kartstuff[k_position] < user->kartstuff[k_position])
{
//P_FlashPal(&players[i], PAL_NUKE, 10);
@@ -5059,6 +5074,7 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source)
// Find the angle, see who's got the best.
thisang = actor->angle - R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y);
if (thisang > ANGLE_180)
thisang = InvAngle(thisang);
@@ -5255,10 +5271,11 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
static void K_UpdateInvincibilitySounds(player_t *player)
{
INT32 sfxnum = sfx_None;
const boolean localplayer = P_IsLocalPlayer(player);
if (player->mo->health > 0)
{
const boolean localplayer = P_IsLocalPlayer(player);
if (player->kartstuff[k_growshrinktimer] > 0 && (!localplayer || cv_growmusic.value == 2)) // Prioritize Grow
sfxnum = cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow;
else if (player->kartstuff[k_invincibilitytimer] > 0 && (!localplayer || cv_supermusic.value == 2))
@@ -5797,7 +5814,7 @@ boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y)
static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer)
{
INT16 basedrift, driftangle;
fixed_t driftweight = player->kartweight*14; // 12
fixed_t driftweight;
// If they aren't drifting or on the ground this doesn't apply
if (player->kartstuff[k_drift] == 0 || !P_IsObjectOnGround(player->mo))
@@ -5808,6 +5825,8 @@ static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer)
return -266*player->kartstuff[k_drift]; // Drift has ended and we are tweaking their angle back a bit
}
driftweight = player->kartweight*14; // 12
//basedrift = 90*player->kartstuff[k_drift]; // 450
//basedrift = 93*player->kartstuff[k_drift] - driftweight*3*player->kartstuff[k_drift]/10; // 447 - 303
basedrift = 83*player->kartstuff[k_drift] - (driftweight - 14)*player->kartstuff[k_drift]/5; // 415 - 303
@@ -5818,6 +5837,9 @@ static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer)
INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue)
{
fixed_t p_topspeed, p_curspeed, p_maxspeed;
fixed_t adjustangle;
if (player->spectator)
return turnvalue;
@@ -5836,10 +5858,10 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue)
return turnvalue;
}
fixed_t p_topspeed = K_GetKartSpeed(player, false);
fixed_t p_curspeed = min(player->speed, p_topspeed * 2);
fixed_t p_maxspeed = p_topspeed * 3;
fixed_t adjustangle = FixedDiv((p_maxspeed>>16) - (p_curspeed>>16), (p_maxspeed>>16) + player->kartweight);
p_topspeed = K_GetKartSpeed(player, false);
p_curspeed = min(player->speed, p_topspeed * 2);
p_maxspeed = p_topspeed * 3;
adjustangle = FixedDiv((p_maxspeed>>16) - (p_curspeed>>16), (p_maxspeed>>16) + player->kartweight);
turnvalue = FixedMul(turnvalue, adjustangle); // Weight has a small effect on turning
@@ -6241,7 +6263,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
K_KartUpdatePosition(player);
if (!player->exiting)
if (LIKELY(!player->exiting))
{
if (player->kartstuff[k_oldposition] < player->kartstuff[k_position]) // But first, if you lost a place,
{
+20 -14
View File
@@ -371,7 +371,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state)
//
boolean P_WeaponOrPanel(mobjtype_t type)
{
if (type >= MT_BOUNCERING && type <= MT_GRENADEPICKUP)
if (UNLIKELY(type >= MT_BOUNCERING && type <= MT_GRENADEPICKUP)) // doubt those get used at all in kart tbh
return true;
return false;
@@ -461,6 +461,7 @@ void P_ExplodeMissile(mobj_t *mo)
boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_EXISTS))
return false;
@@ -1735,9 +1736,6 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp
if (!(rover->flags & FF_EXISTS))
continue;
topheight = P_GetFOFTopZ(mo, sector, rover, mo->x, mo->y, NULL);
bottomheight = P_GetFOFBottomZ(mo, sector, rover, mo->x, mo->y, NULL);
if (mo->player && P_CheckSolidLava(mo, rover)) // only the player should be affected
;
else if (motype != 0 && rover->flags & FF_SWIMMABLE) // "scenery" only
@@ -1747,6 +1745,10 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp
else if (!((rover->flags & FF_BLOCKPLAYER && mo->player) // solid to players?
|| (rover->flags & FF_BLOCKOTHERS && !mo->player))) // solid to others?
continue;
topheight = P_GetFOFTopZ(mo, sector, rover, mo->x, mo->y, NULL);
bottomheight = P_GetFOFBottomZ(mo, sector, rover, mo->x, mo->y, NULL);
if (rover->flags & FF_QUICKSAND)
{
switch (motype)
@@ -1770,6 +1772,7 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp
delta1 = mo->z - (bottomheight + ((topheight - bottomheight)/2));
delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2));
if (topheight > mo->floorz && abs(delta1) < abs(delta2)
&& !(rover->flags & FF_REVERSEPLATFORM)
&& ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference)
@@ -1803,7 +1806,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec)
thingtop = mo->z + mo->height;
while(po)
while (po)
{
if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID))
{
@@ -1855,6 +1858,7 @@ static void P_RingZMovement(mobj_t *mo)
mo->momz += mo->pmomz;
mo->eflags &= ~MFE_APPLYPMOMZ;
}
mo->z += mo->momz;
// clip movement
@@ -1925,6 +1929,7 @@ static boolean P_ZMovement(mobj_t *mo)
mo->momz += mo->pmomz;
mo->eflags &= ~MFE_APPLYPMOMZ;
}
mo->z += mo->momz;
if (mo->standingslope)
@@ -3114,8 +3119,6 @@ static boolean P_CameraCheckHeat(camera_t *thiscam)
if (!thiscam || !thiscam->subsector)
return false;
halfheight = thiscam->z + (thiscam->height >> 1);
// see if we are in water
sector = thiscam->subsector->sector;
@@ -3126,6 +3129,8 @@ static boolean P_CameraCheckHeat(camera_t *thiscam)
{
ffloor_t *rover;
halfheight = thiscam->z + (thiscam->height >> 1);
for (rover = sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
@@ -3152,8 +3157,6 @@ static boolean P_CameraCheckWater(camera_t *thiscam)
if (!thiscam || !thiscam->subsector)
return false;
halfheight = thiscam->z + (thiscam->height >> 1);
// see if we are in water
sector = thiscam->subsector->sector;
@@ -3161,6 +3164,8 @@ static boolean P_CameraCheckWater(camera_t *thiscam)
{
ffloor_t *rover;
halfheight = thiscam->z + (thiscam->height >> 1);
for (rover = sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKOTHERS)
@@ -5403,8 +5408,6 @@ static void P_GimmeAxisXYPos(mobj_t *closestaxis, degenmobj_t *mobj)
static void P_MoveHoop(mobj_t *mobj)
{
const fixed_t fuse = (mobj->fuse*mobj->extravalue2);
const angle_t fa = mobj->movedir*(FINEANGLES/mobj->extravalue1);
TVector v;
TVector *res;
fixed_t finalx, finaly, finalz;
@@ -5414,6 +5417,9 @@ static void P_MoveHoop(mobj_t *mobj)
if (!mobj->target) /// \todo DEBUG ME! Target was P_RemoveMobj'd at some point, and therefore no longer valid!
return;
const fixed_t fuse = (mobj->fuse*mobj->extravalue2);
const angle_t fa = mobj->movedir*(FINEANGLES/mobj->extravalue1);
x = mobj->target->x;
y = mobj->target->y;
z = mobj->target->z+mobj->target->height/2;
@@ -9194,6 +9200,9 @@ void P_PushableThinker(mobj_t *mobj)
I_Assert(mobj != NULL);
I_Assert(!P_MobjWasRemoved(mobj));
if (!mobj)
return;
sec = mobj->subsector->sector;
if (GETSECSPECIAL(sec->special, 2) == 1 && mobj->z == sec->floorheight)
@@ -9210,9 +9219,6 @@ void P_PushableThinker(mobj_t *mobj)
if (mobj->flags & MF_PUSHABLE && !(mobj->momx || mobj->momy))
P_TryMove(mobj, mobj->x, mobj->y, true);
if (!mobj)
return;
if (mobj->fuse == 1) // it would explode in the MobjThinker code
{
mobj_t *spawnmo;
+12 -11
View File
@@ -190,7 +190,7 @@ void Command_CountMobjs_f(void)
void P_InitThinkers(void)
{
thinkercap.prev = thinkercap.next = &thinkercap;
precipcap.prev = precipcap.next = &precipcap;
precipcap.prev = precipcap.next = &precipcap;
waypointcap = NULL;
}
@@ -735,8 +735,10 @@ void P_Ticker(boolean run)
PS_START_TIMING(ps_playerthink_time);
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && !P_MobjWasRemoved(players[i].mo))
P_PlayerThink(&players[i]);
if (!playeringame[i] || P_MobjWasRemoved(players[i].mo))
continue;
P_PlayerThink(&players[i]);
}
PS_STOP_TIMING(ps_playerthink_time);
}
@@ -757,8 +759,10 @@ void P_Ticker(boolean run)
// Run any "after all the other thinkers" stuff
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && !P_MobjWasRemoved(players[i].mo))
P_PlayerAfterThink(&players[i]);
if (!playeringame[i] || P_MobjWasRemoved(players[i].mo))
continue;
P_PlayerAfterThink(&players[i]);
}
// Apply rumble to local players
@@ -837,12 +841,12 @@ void P_Ticker(boolean run)
if (demo.recording)
{
INT32 axis = JoyAxis(AXISLOOKBACK, 1);
G_WriteAllGhostTics();
if (cv_recordmultiplayerdemos.value)
{
const INT32 axis = JoyAxis(AXISLOOKBACK, 1);
if (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE)
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (cv_usejoystick[0].value && axis > 0)))
demo.savemode = DSM_TITLEENTRY;
@@ -958,10 +962,7 @@ void P_PreTicker(INT32 frames)
// Run any "after all the other thinkers" stuff
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
if (P_MobjWasRemoved(players[i].mo))
if (!playeringame[i] || P_MobjWasRemoved(players[i].mo))
continue;
P_PlayerAfterThink(&players[i]);
+30 -28
View File
@@ -73,7 +73,7 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move)
mo->momx += FixedMul(move, FINECOSINE(angle));
if (!(twodlevel || (mo->flags2 & MF2_TWOD)))
if (LIKELY(!(twodlevel || (mo->flags2 & MF2_TWOD))))
mo->momy += FixedMul(move, FINESINE(angle));
}
@@ -90,7 +90,7 @@ void P_InstaThrust(mobj_t *mo, angle_t angle, fixed_t move)
mo->momx = FixedMul(move, FINECOSINE(angle));
if (!(twodlevel || (mo->flags2 & MF2_TWOD)))
if (LIKELY(!(twodlevel || (mo->flags2 & MF2_TWOD))))
mo->momy = FixedMul(move,FINESINE(angle));
}
@@ -1287,13 +1287,14 @@ boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand
{
sector_t *sector = mo->subsector->sector;
fixed_t topheight, bottomheight;
fixed_t flipoffset = ((mo->eflags & MFE_VERTICALFLIP) ? (mo->height/2) : 0);
fixed_t flipoffset;
if (sector->ffloors)
{
ffloor_t *rover;
flipoffset = ((mo->eflags & MFE_VERTICALFLIP) ? (mo->height/2) : 0);
for (rover = sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
@@ -1682,6 +1683,7 @@ static void P_DoBubbleBreath(player_t *player)
bubble = P_SpawnMobj(player->mo->x, player->mo->y, zh, MT_SMALLBUBBLE);
else if (P_RandomChance(3*FRACUNIT/256))
bubble = P_SpawnMobj(player->mo->x, player->mo->y, zh, MT_MEDIUMBUBBLE);
if (bubble)
{
bubble->threshold = 42;
@@ -1689,8 +1691,8 @@ static void P_DoBubbleBreath(player_t *player)
P_SetScale(bubble, bubble->destscale);
}
if (player->pflags & PF_NIGHTSMODE) // NiGHTS Super doesn't spawn flight bubbles
return;
//if (player->pflags & PF_NIGHTSMODE) // NiGHTS Super doesn't spawn flight bubbles
//return;
}
//
@@ -2159,7 +2161,7 @@ static void P_MovePlayer(player_t *player)
}
// note: don't unset stasis here
if (!player->spectator && G_TagGametype())
if (UNLIKELY(!player->spectator && G_TagGametype()))
{
// If we have stasis already here, it's because it's forced on us
// by a linedef executor or what have you
@@ -2219,7 +2221,7 @@ static void P_MovePlayer(player_t *player)
player->lturn_max[leveltime%MAXPREDICTTICS] = player->rturn_max[leveltime%MAXPREDICTTICS] = 0;
}
if (leveltime >= starttime)
if (LIKELY(leveltime >= starttime))
{
// KART: Don't directly apply angleturn! It may have been either A) forged by a malicious client, or B) not be a smooth turn due to a player dropping frames.
// Instead, turn the player only up to the amount they're supposed to turn accounting for latency. Allow exactly 1 extra turn unit to try to keep old replays synced.
@@ -2258,7 +2260,7 @@ static void P_MovePlayer(player_t *player)
P_3dMovement(player);
}
if (maptol & TOL_2D)
if (UNLIKELY(maptol & TOL_2D)) // psure this doesent even work at all
runspd = FixedMul(runspd, 2*FRACUNIT/3);
/////////////////////////
@@ -2319,10 +2321,10 @@ static void P_MovePlayer(player_t *player)
// Drifting sound
// Start looping the sound now.
if (leveltime % 50 == 0 && onground && player->kartstuff[k_drift] != 0)
if (onground && leveltime % 50 == 0 && player->kartstuff[k_drift] != 0)
S_StartSound(player->mo, sfx_drift);
// Leveltime being 50 might take a while at times. We'll start it up once, isntantly.
else if (!S_SoundPlaying(player->mo, sfx_drift) && onground && player->kartstuff[k_drift] != 0)
else if (onground && !S_SoundPlaying(player->mo, sfx_drift) && player->kartstuff[k_drift] != 0)
S_StartSound(player->mo, sfx_drift);
// Ok, we'll stop now.
else if (player->kartstuff[k_drift] == 0 || !onground)
@@ -2347,7 +2349,7 @@ static void P_MovePlayer(player_t *player)
P_SetPlayerMobjState(player->mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND
}
if (player->gotflag) // If you can't glide, then why the heck would you be gliding?
if (UNLIKELY(player->gotflag)) // If you can't glide, then why the heck would you be gliding?
{
player->pflags &= ~PF_GLIDING;
player->glidetime = 0;
@@ -2708,8 +2710,8 @@ boolean P_LookForEnemies(player_t *player)
player->mo->z-mo->z) > FixedMul(RING_DIST, player->mo->scale))
continue; // out of range
if ((twodlevel || player->mo->flags2 & MF2_TWOD)
&& abs(player->mo->y-mo->y) > player->mo->radius)
if (UNLIKELY((twodlevel || player->mo->flags2 & MF2_TWOD)
&& abs(player->mo->y-mo->y) > player->mo->radius))
continue; // not in your 2d plane
if (mo->type == MT_PLAYER) // Don't chase after other players!
@@ -4081,7 +4083,7 @@ boolean P_SpectatorJoinGame(player_t *player)
// Team changing in Team Match and CTF
// Pressing fire assigns you to a team that needs players if allowed.
// Partial code reproduction from p_tick.c autobalance code.
else if (G_GametypeHasTeams())
else if (UNLIKELY(G_GametypeHasTeams()))
{
INT32 changeto = 0;
INT32 z, numplayersred = 0, numplayersblue = 0;
@@ -4323,10 +4325,10 @@ static INT32 Quaketilt(player_t *player)
if (abs(delta) > ANGLE_90)
delta = (INT32)(( moma + ANGLE_180 ) - player->mo->angle );
const boolean sliptiding = player->kartstuff[k_drift] ? 0 : player->kartstuff[k_aizdriftstrat];
if (P_IsObjectOnGround(player->mo))
{
const boolean sliptiding = player->kartstuff[k_drift] ? 0 : player->kartstuff[k_aizdriftstrat];
if (sliptiding)
{
tilt = ANGLE_45;
@@ -4479,8 +4481,8 @@ void P_PlayerThink(player_t *player)
{
seenplayer = NULL;
if (cv_seenames.value && cv_allowseenames.value &&
!(G_TagGametype() && (player->pflags & PF_TAGIT)))
if (UNLIKELY(cv_seenames.value && cv_allowseenames.value &&
!(G_TagGametype() && (player->pflags & PF_TAGIT))))
{
mobj_t *mo = P_SpawnNameFinder(player->mo, MT_NAMECHECK);
@@ -4769,8 +4771,8 @@ void P_PlayerThink(player_t *player)
}
// Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot.
if (!objectplacing && !((netgame || multiplayer) && player->spectator)
&& maptol & TOL_NIGHTS && (!(player->pflags & PF_NIGHTSMODE) || player->powers[pw_nights_helper]))
if (UNLIKELY(!objectplacing && !((netgame || multiplayer) && player->spectator)
&& maptol & TOL_NIGHTS && (!(player->pflags & PF_NIGHTSMODE) || player->powers[pw_nights_helper])))
{
thinker_t *th;
mobj_t *mo2;
@@ -4835,7 +4837,7 @@ void P_PlayerThink(player_t *player)
player->pflags &= ~PF_FULLSTASIS;
if (player->onconveyor == 1)
player->cmomy = player->cmomx = 0;
player->cmomy = player->cmomx = 0;
P_DoBubbleBreath(player); // Spawn Sonic's bubbles
P_CheckInvincibilityTimer(player); // Spawn Invincibility Sparkles
@@ -4872,7 +4874,7 @@ void P_PlayerThink(player_t *player)
#endif
// check for use
if (!(player->pflags & PF_NIGHTSMODE))
if (LIKELY(!(player->pflags & PF_NIGHTSMODE)))
{
if (cmd->buttons & BT_BRAKE)
player->pflags |= PF_USEDOWN;
@@ -5044,6 +5046,11 @@ void P_PlayerAfterThink(player_t *player)
P_PlayerInSpecialSector(player);
#endif
if (player->playerstate == PST_DEAD)
{
return;
}
for (i = 0; i <= splitscreen; i++)
{
if (player == &players[displayplayers[i]])
@@ -5053,11 +5060,6 @@ void P_PlayerAfterThink(player_t *player)
}
}
if (player->playerstate == PST_DEAD)
{
return;
}
if (player->pflags & PF_NIGHTSMODE)
{
player->powers[pw_gravityboots] = 0;