MT_SIGN: Improve player property grabbing

Instead of using the skin of the object and the color of the player, use a direct player reference to get both skin and color from.
Now correctly tracks Heavy Magicians at all times, not just after exiting.
This commit is contained in:
toaster 2023-09-18 17:21:32 +01:00
parent de60a2dbba
commit 5b7b57e580

View file

@ -8631,9 +8631,8 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
case MT_SIGN: // Kart's unique sign behavior case MT_SIGN: // Kart's unique sign behavior
if (mobj->movecount != 0) if (mobj->movecount != 0)
{ {
mobj_t *cur = mobj->hnext; player_t *newplayer = NULL;
SINT8 newskin = -1;
UINT8 newcolor = SKINCOLOR_NONE;
angle_t endangle = FixedAngle(mobj->extravalue1 << FRACBITS); angle_t endangle = FixedAngle(mobj->extravalue1 << FRACBITS);
if (mobj->movecount == 1) if (mobj->movecount == 1)
@ -8647,8 +8646,11 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
mobj->momz = 0; mobj->momz = 0;
mobj->movecount = 2; mobj->movecount = 2;
newskin = ((skin_t*)mobj->target->skin) - skins; if (!P_MobjWasRemoved(mobj->target))
newcolor = mobj->target->player->skincolor; {
// Guarantee correct display of the player
newplayer = mobj->target->player;
}
} }
else else
{ {
@ -8675,8 +8677,11 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{ {
if (ticstilimpact <= 8) if (ticstilimpact <= 8)
{ {
newskin = ((skin_t*)mobj->target->skin) - skins; if (!P_MobjWasRemoved(mobj->target))
newcolor = mobj->target->player->skincolor; {
// In anticipation of final declaration...
newplayer = mobj->target->player;
}
} }
else else
{ {
@ -8688,25 +8693,33 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i] && !players[i].spectator) if (!playeringame[i])
{ continue;
plist[plistlen] = i; if (players[i].spectator == true)
plistlen++; continue;
}
plist[plistlen++] = i;
} }
if (plistlen <= 1) if (plistlen)
{
if (plistlen > 1)
{
// Pick another player in the server!
plistlen = P_RandomKey(PR_SPARKLE, plistlen+1);
}
else
{
// One entry, grab the head.
plistlen = 0;
}
newplayer = &players[plist[plistlen]];
}
else if (!P_MobjWasRemoved(mobj->target))
{ {
// Default to the winner // Default to the winner
newskin = ((skin_t*)mobj->target->skin) - skins; newplayer = mobj->target->player;
newcolor = mobj->target->player->skincolor;
}
else
{
// Pick another player in the server!
player_t *p = &players[plist[P_RandomKey(PR_SPARKLE, plistlen)]];
newskin = ((skin_t*)p->mo->skin) - skins;
newcolor = p->skincolor;
} }
} }
} }
@ -8718,6 +8731,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
mobj->angle += ANGLE_11hh; mobj->angle += ANGLE_11hh;
} }
mobj_t *cur = mobj->hnext;
while (cur && !P_MobjWasRemoved(cur)) while (cur && !P_MobjWasRemoved(cur))
{ {
fixed_t amt = cur->extravalue1 * mobj->scale; fixed_t amt = cur->extravalue1 * mobj->scale;
@ -8726,10 +8740,10 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
if (cur->state == &states[S_SIGN_FACE]) if (cur->state == &states[S_SIGN_FACE])
{ {
if (newcolor != SKINCOLOR_NONE) if (newplayer != NULL)
{ {
cur->color = skincolors[newcolor].invcolor; cur->color = skincolors[newplayer->skincolor].invcolor;
cur->frame = cur->state->frame + skincolors[newcolor].invshade; cur->frame = cur->state->frame + skincolors[newplayer->skincolor].invshade;
} }
} }
else if (cur->state == &states[S_KART_SIGN]) else if (cur->state == &states[S_KART_SIGN])
@ -8737,10 +8751,10 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
z += (5*mobj->scale); z += (5*mobj->scale);
amt += 1; amt += 1;
if (newskin != -1) if (newplayer != NULL)
{ {
cur->skin = &skins[newskin]; cur->skin = &skins[newplayer->skin];
cur->color = newcolor; cur->color = newplayer->skincolor;
} }
} }
else if (cur->state == &states[S_SIGN_ERROR]) else if (cur->state == &states[S_SIGN_ERROR])