use branch instrincts for P_MobjThinker
based on observations from kart stuff
This commit is contained in:
1 parent
22d762b696
commit
a722992c02
1 file changed
+44
-46
+44
-46
@@ -178,7 +178,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
|
||||
// Set animation state
|
||||
// The pflags version of this was just as convoluted.
|
||||
// Rewriten for SRB2kart ... though I don't know what this is.
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case S_KART_STND1...S_KART_STND2_R:
|
||||
case S_KART_SQUISH:
|
||||
@@ -203,7 +203,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
|
||||
|
||||
do
|
||||
{
|
||||
if (state == S_NULL)
|
||||
if (UNLIKELY(state == S_NULL))
|
||||
{ // Bad SOC!
|
||||
CONS_Alert(CONS_ERROR, "Cannot remove player mobj by setting its state to S_NULL.\n");
|
||||
//P_RemoveMobj(mobj);
|
||||
@@ -239,7 +239,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
|
||||
state = st->nextstate;
|
||||
} while (!mobj->tics && !seenstate[state]);
|
||||
|
||||
if (!mobj->tics)
|
||||
if (UNLIKELY(!mobj->tics))
|
||||
CONS_Alert(CONS_WARNING, M_GetText("State cycle detected, exiting.\n"));
|
||||
|
||||
if (!--recursion)
|
||||
@@ -306,7 +306,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
|
||||
state = st->nextstate;
|
||||
} while (!mobj->tics && !seenstate[state]);
|
||||
|
||||
if (!mobj->tics)
|
||||
if (UNLIKELY(!mobj->tics))
|
||||
CONS_Alert(CONS_WARNING, M_GetText("State cycle detected, exiting.\n"));
|
||||
|
||||
if (!--recursion)
|
||||
@@ -1872,11 +1872,9 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover)
|
||||
I_Assert(mo != NULL);
|
||||
I_Assert(!P_MobjWasRemoved(mo));
|
||||
|
||||
fixed_t topheight = P_GetFFloorTopZAt(rover, mo->x, mo->y);
|
||||
|
||||
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3
|
||||
&& !(rover->master->flags & ML_BLOCKMONSTERS)
|
||||
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale)))
|
||||
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > P_GetFFloorTopZAt(rover, mo->x, mo->y) - FixedMul(16*FRACUNIT, mo->scale)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -3390,6 +3388,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
|
||||
thiscam->ceilingz = thiscam->z + thiscam->height;
|
||||
thiscam->floorz = thiscam->z;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3415,7 +3414,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
|
||||
mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN;
|
||||
|
||||
// Zoom tube
|
||||
if (mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT)
|
||||
if (UNLIKELY(mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT))
|
||||
{
|
||||
P_UnsetThingPosition(mobj);
|
||||
mobj->x += mobj->momx;
|
||||
@@ -3444,7 +3443,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
|
||||
else
|
||||
P_TryMove(mobj, mobj->x, mobj->y, true);
|
||||
|
||||
if (!(netgame && mobj->player->spectator))
|
||||
if (LIKELY(!(netgame && mobj->player->spectator)))
|
||||
{
|
||||
// Crumbling platforms
|
||||
for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next)
|
||||
@@ -3491,6 +3490,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (thereiswater)
|
||||
{
|
||||
for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next)
|
||||
@@ -6023,7 +6023,8 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
|
||||
return 0;
|
||||
|
||||
// if mobj doesent have any of those, no need to do the rest
|
||||
if (mobj->roll == 0 && mobj->pitch == 0 && mobj->sloperoll == 0 && mobj->slopepitch == 0)
|
||||
if (mobj->roll == 0 && mobj->pitch == 0
|
||||
&& mobj->sloperoll == 0 && mobj->slopepitch == 0)
|
||||
return 0;
|
||||
|
||||
size_t rot = (mobj->frame & FF_FRAMEMASK);
|
||||
@@ -6049,7 +6050,8 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
|
||||
sprframe = &sprdef->spriteframes[rot];
|
||||
|
||||
// No sprite frame? I guess it is possible
|
||||
if (!sprframe) return 0;
|
||||
if (!sprframe)
|
||||
return 0;
|
||||
|
||||
if (sprframe->rotate != SRF_SINGLE || (mobj->frame & FF_PAPERSPRITE))
|
||||
{
|
||||
@@ -6058,9 +6060,9 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
|
||||
}
|
||||
|
||||
return_angle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mobj->roll)
|
||||
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch)
|
||||
+ FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
|
||||
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
|
||||
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch)
|
||||
+ FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
|
||||
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
|
||||
|
||||
return return_angle;
|
||||
}
|
||||
@@ -9048,7 +9050,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
I_Assert(mobj != NULL);
|
||||
I_Assert(!P_MobjWasRemoved(mobj));
|
||||
|
||||
if (mobj->flags & MF_NOTHINK)
|
||||
if (UNLIKELY(mobj->flags & MF_NOTHINK))
|
||||
return;
|
||||
|
||||
// Remove dead target/tracer.
|
||||
@@ -9070,10 +9072,9 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
const sector_t *sec1 = mobj->subsector ? mobj->subsector->sector : NULL;
|
||||
|
||||
// 970 allows ANY mobj to trigger a linedef exec
|
||||
if (sec1 && GETSECSPECIAL(sec1->special, 2) == 8)
|
||||
if (UNLIKELY(sec1 && GETSECSPECIAL(sec1->special, 2) == 8))
|
||||
{
|
||||
sector_t *sec2;
|
||||
|
||||
sec2 = P_ThingOnSpecial3DFloor(mobj);
|
||||
if (sec2 && GETSECSPECIAL(sec2->special, 2) == 1)
|
||||
P_LinedefExecute(sec2->tag, mobj, sec2);
|
||||
@@ -9137,7 +9138,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
if (mobj->flags2 & MF2_FIRING && mobj->target && mobj->health > 0)
|
||||
P_FiringThink(mobj);
|
||||
|
||||
if (mobj->flags & MF_AMBIENT)
|
||||
if (UNLIKELY(mobj->flags & MF_AMBIENT))
|
||||
{
|
||||
if (leveltime % mobj->health)
|
||||
return;
|
||||
@@ -9181,21 +9182,21 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
mobj->eflags &= ~MFE_JUSTHITFLOOR;
|
||||
}
|
||||
|
||||
if (mobj->type == MT_FLINGRING
|
||||
if (UNLIKELY(mobj->type == MT_FLINGRING
|
||||
|| mobj->type == MT_FLINGCOIN
|
||||
|| P_WeaponOrPanel(mobj->type)
|
||||
|| mobj->type == MT_FLINGEMERALD
|
||||
|| mobj->type == MT_BIGTUMBLEWEED
|
||||
|| mobj->type == MT_LITTLETUMBLEWEED
|
||||
|| mobj->type == MT_CANNONBALLDECOR
|
||||
|| mobj->type == MT_CANNONBALLDECOR)
|
||||
|| mobj->type == MT_FALLINGROCK)
|
||||
{
|
||||
P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly
|
||||
P_ButteredSlope(mobj);
|
||||
}
|
||||
|
||||
if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health
|
||||
&& P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz
|
||||
if (UNLIKELY(mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health
|
||||
&& P_CheckDeathPitCollide(mobj))) // extra pit check in case these didn't have momz
|
||||
{
|
||||
P_KillMobj(mobj, NULL, NULL);
|
||||
return;
|
||||
@@ -9204,10 +9205,10 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
// Crush enemies!
|
||||
if (mobj->ceilingz - mobj->floorz < mobj->height)
|
||||
{
|
||||
if ((
|
||||
if (UNLIKELY((
|
||||
(mobj->flags & (MF_ENEMY|MF_BOSS)
|
||||
&& mobj->flags & MF_SHOOTABLE)
|
||||
|| mobj->type == MT_EGGSHIELD)
|
||||
|| mobj->type == MT_EGGSHIELD))
|
||||
&& !(mobj->flags & MF_NOCLIPHEIGHT)
|
||||
&& mobj->health > 0)
|
||||
{
|
||||
@@ -9225,25 +9226,21 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
if (P_MobjWasRemoved(mobj))
|
||||
return;
|
||||
|
||||
switch (mobj->type)
|
||||
if (UNLIKELY(P_WeaponOrPanel(mobj->type)))
|
||||
{
|
||||
case MT_BOUNCEPICKUP ... MT_GRENADEPICKUP:
|
||||
if (mobj->health == 0) // Fading tile
|
||||
{
|
||||
INT32 value = mobj->info->damage/10;
|
||||
value = mobj->fuse/value;
|
||||
value = 10-value;
|
||||
value--;
|
||||
if (mobj->health == 0) // Fading tile
|
||||
{
|
||||
INT32 value = mobj->info->damage/10;
|
||||
value = mobj->fuse/value;
|
||||
value = 10-value;
|
||||
value--;
|
||||
|
||||
if (value <= 0)
|
||||
value = 1;
|
||||
if (value <= 0)
|
||||
value = 1;
|
||||
|
||||
mobj->frame &= ~FF_TRANSMASK;
|
||||
mobj->frame |= value << FF_TRANSSHIFT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
mobj->frame &= ~FF_TRANSMASK;
|
||||
mobj->frame |= value << FF_TRANSSHIFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10068,7 +10065,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
|
||||
mobj->precipflags |= PCF_FOF;
|
||||
else
|
||||
{
|
||||
INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1);
|
||||
const INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1);
|
||||
|
||||
if (special == 7 || special == 6 || mobj->subsector->sector->floorpic == skyflatnum)
|
||||
mobj->precipflags |= PCF_PIT;
|
||||
@@ -10101,14 +10098,14 @@ void P_RemoveMobj(mobj_t *mobj)
|
||||
mobj->thinker.function = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work.
|
||||
|
||||
// Rings only, please!
|
||||
if (mobj->spawnpoint &&
|
||||
if (UNLIKELY(mobj->spawnpoint &&
|
||||
(mobj->type == MT_RING
|
||||
|| mobj->type == MT_COIN
|
||||
|| mobj->type == MT_BLUEBALL
|
||||
|| mobj->type == MT_REDTEAMRING
|
||||
|| mobj->type == MT_BLUETEAMRING
|
||||
|| P_WeaponOrPanel(mobj->type))
|
||||
&& !(mobj->flags2 & MF2_DONTRESPAWN))
|
||||
&& !(mobj->flags2 & MF2_DONTRESPAWN)))
|
||||
{
|
||||
itemrespawnque[iquehead] = mobj->spawnpoint;
|
||||
itemrespawntime[iquehead] = leveltime;
|
||||
@@ -10130,13 +10127,13 @@ void P_RemoveMobj(mobj_t *mobj)
|
||||
}
|
||||
}
|
||||
|
||||
if (mobj->type == MT_OVERLAY)
|
||||
if (UNLIKELY(mobj->type == MT_OVERLAY))
|
||||
P_RemoveOverlay(mobj);
|
||||
|
||||
if (mobj->type == MT_SHADOW)
|
||||
if (UNLIKELY(mobj->type == MT_SHADOW))
|
||||
P_RemoveShadow(mobj);
|
||||
|
||||
if (mobj->type == MT_SPB)
|
||||
if (UNLIKELY(mobj->type == MT_SPB))
|
||||
spbplace = -1;
|
||||
|
||||
mobj->health = 0; // Just because
|
||||
@@ -10148,6 +10145,7 @@ void P_RemoveMobj(mobj_t *mobj)
|
||||
P_DelSeclist(sector_list);
|
||||
sector_list = NULL;
|
||||
}
|
||||
|
||||
mobj->flags |= MF_NOSECTOR|MF_NOBLOCKMAP;
|
||||
mobj->subsector = NULL;
|
||||
mobj->state = NULL;
|
||||
|
||||
Reference in new issue
Block a user