use branch instrincts for P_MobjThinker
based on observations from kart stuff
This commit is contained in:
1 parent
3ce8b9f09c
commit
307c333c50
1 file changed
+47
-55
+47
-55
@@ -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)
|
||||
@@ -1916,11 +1916,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;
|
||||
@@ -3367,6 +3365,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
|
||||
thiscam->ceilingz = thiscam->z + thiscam->height;
|
||||
thiscam->floorz = thiscam->z;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3392,7 +3391,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;
|
||||
@@ -3402,7 +3401,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
|
||||
P_CheckPosition(mobj, mobj->x, mobj->y);
|
||||
goto animonly;
|
||||
}
|
||||
else if (mobj->player->pflags & PF_MACESPIN && mobj->tracer)
|
||||
else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN && mobj->tracer))
|
||||
{
|
||||
P_CheckPosition(mobj, mobj->x, mobj->y);
|
||||
goto animonly;
|
||||
@@ -3421,7 +3420,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)
|
||||
@@ -3468,6 +3467,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (thereiswater)
|
||||
{
|
||||
for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next)
|
||||
@@ -6015,7 +6015,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);
|
||||
@@ -6041,7 +6042,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))
|
||||
{
|
||||
@@ -6050,9 +6052,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;
|
||||
}
|
||||
@@ -6065,7 +6067,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.
|
||||
@@ -6087,10 +6089,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);
|
||||
@@ -8810,7 +8811,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y);
|
||||
}
|
||||
|
||||
if (mobj->flags & MF_AMBIENT)
|
||||
if (UNLIKELY(mobj->flags & MF_AMBIENT))
|
||||
{
|
||||
if (!(leveltime % mobj->health) && mobj->info->seesound)
|
||||
S_StartSound(mobj, mobj->info->seesound);
|
||||
@@ -9051,21 +9052,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_FALLINGROCK) {
|
||||
|| mobj->type == MT_CANNONBALLDECOR)
|
||||
|| mobj->type == MT_FALLINGROCK)
|
||||
{
|
||||
P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly
|
||||
//if (mobj->standingslope) CONS_Printf("slope physics on mobj\n");
|
||||
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;
|
||||
@@ -9074,10 +9075,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)
|
||||
{
|
||||
@@ -9095,30 +9096,21 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
if (P_MobjWasRemoved(mobj))
|
||||
return;
|
||||
|
||||
switch (mobj->type)
|
||||
if (UNLIKELY(P_WeaponOrPanel(mobj->type)))
|
||||
{
|
||||
case MT_BOUNCEPICKUP:
|
||||
case MT_RAILPICKUP:
|
||||
case MT_AUTOPICKUP:
|
||||
case MT_EXPLODEPICKUP:
|
||||
case MT_SCATTERPICKUP:
|
||||
case 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9933,8 +9925,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;
|
||||
}
|
||||
@@ -9966,14 +9957,14 @@ void P_RemoveMobj(mobj_t *mobj)
|
||||
mobj->thinker.function.acp1 = (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;
|
||||
@@ -9995,13 +9986,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
|
||||
@@ -10013,6 +10004,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