Remember the player's color after a team gametype

This commit is contained in:
Lactozilla 2023-08-07 13:30:32 -03:00
parent 57592a566a
commit 3377fa986a
9 changed files with 31 additions and 82 deletions

View file

@ -1071,7 +1071,6 @@ static inline void AM_drawPlayers(void)
return; return;
} }
// multiplayer (how??)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (!playeringame[i] || players[i].spectator) if (!playeringame[i] || players[i].spectator)

View file

@ -1233,15 +1233,6 @@ static void SendNameAndColor(void)
p = buf; p = buf;
// normal player colors
if (G_GametypeHasTeams())
{
if (players[consoleplayer].ctfteam == 1 && cv_playercolor.value != skincolor_redteam)
CV_StealthSetValue(&cv_playercolor, skincolor_redteam);
else if (players[consoleplayer].ctfteam == 2 && cv_playercolor.value != skincolor_blueteam)
CV_StealthSetValue(&cv_playercolor, skincolor_blueteam);
}
// don't allow inaccessible colors // don't allow inaccessible colors
if (!skincolors[cv_playercolor.value].accessible) if (!skincolors[cv_playercolor.value].accessible)
{ {
@ -1367,16 +1358,6 @@ static void SendNameAndColor2(void)
else // HACK else // HACK
secondplaya = 1; secondplaya = 1;
// normal player colors
if (G_GametypeHasTeams())
{
if (players[secondplaya].ctfteam == 1 && cv_playercolor2.value != skincolor_redteam)
CV_StealthSetValue(&cv_playercolor2, skincolor_redteam);
else if (players[secondplaya].ctfteam == 2 && cv_playercolor2.value != skincolor_blueteam)
CV_StealthSetValue(&cv_playercolor2, skincolor_blueteam);
}
// don't allow inaccessible colors
if (!skincolors[cv_playercolor2.value].accessible) if (!skincolors[cv_playercolor2.value].accessible)
{ {
if (players[secondplaya].skincolor && skincolors[players[secondplaya].skincolor].accessible) if (players[secondplaya].skincolor && skincolors[players[secondplaya].skincolor].accessible)
@ -1498,7 +1479,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
// set color // set color
p->skincolor = color % numskincolors; p->skincolor = color % numskincolors;
if (p->mo) if (p->mo)
p->mo->color = (UINT16)p->skincolor; p->mo->color = P_GetPlayerColor(p);
// normal player colors // normal player colors
if (server && (p != &players[consoleplayer] && p != &players[secondarydisplayplayer])) if (server && (p != &players[consoleplayer] && p != &players[secondarydisplayplayer]))
@ -1507,15 +1488,6 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
UINT32 unlockShift = 0; UINT32 unlockShift = 0;
UINT32 i; UINT32 i;
// team colors
if (G_GametypeHasTeams())
{
if (p->ctfteam == 1 && p->skincolor != skincolor_redteam)
kick = true;
else if (p->ctfteam == 2 && p->skincolor != skincolor_blueteam)
kick = true;
}
// don't allow inaccessible colors // don't allow inaccessible colors
if (skincolors[p->skincolor].accessible == false) if (skincolors[p->skincolor].accessible == false)
kick = true; kick = true;
@ -2904,17 +2876,6 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
displayplayer = consoleplayer; displayplayer = consoleplayer;
} }
if (G_GametypeHasTeams())
{
if (NetPacket.packet.newteam)
{
if (playernum == consoleplayer) //CTF and Team Match colors.
CV_SetValue(&cv_playercolor, NetPacket.packet.newteam + 5);
else if (playernum == secondarydisplayplayer)
CV_SetValue(&cv_playercolor2, NetPacket.packet.newteam + 5);
}
}
// In tag, check to see if you still have a game. // In tag, check to see if you still have a game.
if (G_TagGametype()) if (G_TagGametype())
P_CheckSurvivors(); P_CheckSurvivors();

View file

@ -2748,25 +2748,6 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
//if ((netgame || multiplayer) && !p->spectator) -- moved into P_SpawnPlayer to account for forced changes there //if ((netgame || multiplayer) && !p->spectator) -- moved into P_SpawnPlayer to account for forced changes there
//p->powers[pw_flashing] = flashingtics-1; // Babysitting deterrent //p->powers[pw_flashing] = flashingtics-1; // Babysitting deterrent
// Check to make sure their color didn't change somehow...
if (G_GametypeHasTeams())
{
if (p->ctfteam == 1 && p->skincolor != skincolor_redteam)
{
if (p == &players[consoleplayer])
CV_SetValue(&cv_playercolor, skincolor_redteam);
else if (p == &players[secondarydisplayplayer])
CV_SetValue(&cv_playercolor2, skincolor_redteam);
}
else if (p->ctfteam == 2 && p->skincolor != skincolor_blueteam)
{
if (p == &players[consoleplayer])
CV_SetValue(&cv_playercolor, skincolor_blueteam);
else if (p == &players[secondarydisplayplayer])
CV_SetValue(&cv_playercolor2, skincolor_blueteam);
}
}
if (betweenmaps) if (betweenmaps)
return; return;

View file

@ -5248,7 +5248,7 @@ void A_SignPlayer(mobj_t *actor)
return; return;
skin = &skins[actor->target->player->skin]; skin = &skins[actor->target->player->skin];
facecolor = actor->target->player->skincolor; facecolor = P_GetPlayerColor(actor->target->player);
if (signcolor) if (signcolor)
; ;
@ -9059,7 +9059,7 @@ void A_Dye(mobj_t *actor)
if (!color) if (!color)
{ {
target->colorized = false; target->colorized = false;
target->color = target->player ? target->player->skincolor : SKINCOLOR_NONE; target->color = target->player ? P_GetPlayerColor(target->player) : SKINCOLOR_NONE;
} }
else if (!(target->player)) else if (!(target->player))
{ {

View file

@ -2630,7 +2630,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
} }
} }
target->color = target->player->skincolor; target->color = P_GetPlayerColor(target->player);
target->colorized = false; target->colorized = false;
G_GhostAddColor(GHC_NORMAL); G_GhostAddColor(GHC_NORMAL);
@ -3323,7 +3323,7 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage)
// Get rid of shield // Get rid of shield
player->powers[pw_shield] = SH_NONE; player->powers[pw_shield] = SH_NONE;
player->mo->color = player->skincolor; player->mo->color = P_GetPlayerColor(player);
// Get rid of emeralds // Get rid of emeralds
player->powers[pw_emeralds] = 0; player->powers[pw_emeralds] = 0;
@ -3440,7 +3440,7 @@ void P_RemoveShield(player_t *player)
{ // Second layer shields { // Second layer shields
if (((player->powers[pw_shield] & SH_STACK) == SH_FIREFLOWER) && !(player->powers[pw_super] || (mariomode && player->powers[pw_invulnerability]))) if (((player->powers[pw_shield] & SH_STACK) == SH_FIREFLOWER) && !(player->powers[pw_super] || (mariomode && player->powers[pw_invulnerability])))
{ {
player->mo->color = player->skincolor; player->mo->color = P_GetPlayerColor(player);
G_GhostAddColor(GHC_NORMAL); G_GhostAddColor(GHC_NORMAL);
} }
player->powers[pw_shield] = SH_NONE; player->powers[pw_shield] = SH_NONE;

View file

@ -146,6 +146,7 @@ void P_ForceLocalAngle(player_t *player, angle_t angle);
boolean P_PlayerFullbright(player_t *player); boolean P_PlayerFullbright(player_t *player);
boolean P_PlayerCanEnterSpinGaps(player_t *player); boolean P_PlayerCanEnterSpinGaps(player_t *player);
boolean P_PlayerShouldUseSpinHeight(player_t *player); boolean P_PlayerShouldUseSpinHeight(player_t *player);
UINT16 P_GetPlayerColor(player_t *player);
boolean P_IsObjectInGoop(mobj_t *mo); boolean P_IsObjectInGoop(mobj_t *mo);
boolean P_IsObjectOnGround(mobj_t *mo); boolean P_IsObjectOnGround(mobj_t *mo);

View file

@ -11564,8 +11564,6 @@ void P_SpawnPlayer(INT32 playernum)
// Spawn as a spectator, // Spawn as a spectator,
// yes even in splitscreen mode // yes even in splitscreen mode
p->spectator = true; p->spectator = true;
if (playernum&1) p->skincolor = skincolor_redteam;
else p->skincolor = skincolor_blueteam;
// but immediately send a team change packet. // but immediately send a team change packet.
NetPacket.packet.playernum = playernum; NetPacket.packet.playernum = playernum;
@ -11585,13 +11583,6 @@ void P_SpawnPlayer(INT32 playernum)
// Fix stupid non spectator spectators. // Fix stupid non spectator spectators.
if (!p->spectator && !p->ctfteam) if (!p->spectator && !p->ctfteam)
p->spectator = true; p->spectator = true;
// Fix team colors.
// This code isn't being done right somewhere else. Oh well.
if (p->ctfteam == 1)
p->skincolor = skincolor_redteam;
else if (p->ctfteam == 2)
p->skincolor = skincolor_blueteam;
} }
if ((netgame || multiplayer) && ((gametyperules & GTR_SPAWNINVUL) || leveltime) && !p->spectator && !(maptol & TOL_NIGHTS)) if ((netgame || multiplayer) && ((gametyperules & GTR_SPAWNINVUL) || leveltime) && !p->spectator && !(maptol & TOL_NIGHTS))
@ -11603,7 +11594,7 @@ void P_SpawnPlayer(INT32 playernum)
mobj->angle = 0; mobj->angle = 0;
// set color translations for player sprites // set color translations for player sprites
mobj->color = p->skincolor; mobj->color = P_GetPlayerColor(p);
// set 'spritedef' override in mobj for player skins.. (see ProjectSprite) // set 'spritedef' override in mobj for player skins.. (see ProjectSprite)
// (usefulness: when body mobj is detached from player (who respawns), // (usefulness: when body mobj is detached from player (who respawns),

View file

@ -686,7 +686,7 @@ static void P_DeNightserizePlayer(player_t *player)
player->mo->skin = &skins[player->skin]; player->mo->skin = &skins[player->skin];
player->followitem = skins[player->skin].followitem; player->followitem = skins[player->skin].followitem;
player->mo->color = player->skincolor; player->mo->color = P_GetPlayerColor(player);
G_GhostAddColor(GHC_RETURNSKIN); G_GhostAddColor(GHC_RETURNSKIN);
// Restore aiming angle // Restore aiming angle
@ -3029,7 +3029,7 @@ static void P_CheckInvincibilityTimer(player_t *player)
} }
else else
{ {
player->mo->color = player->skincolor; player->mo->color = P_GetPlayerColor(player);
G_GhostAddColor(GHC_NORMAL); G_GhostAddColor(GHC_NORMAL);
} }
} }
@ -4302,7 +4302,7 @@ static void P_DoSuperStuff(player_t *player)
} }
else else
{ {
player->mo->color = player->skincolor; player->mo->color = P_GetPlayerColor(player);
G_GhostAddColor(GHC_NORMAL); G_GhostAddColor(GHC_NORMAL);
} }
@ -4352,7 +4352,7 @@ static void P_DoSuperStuff(player_t *player)
} }
else else
{ {
player->mo->color = player->skincolor; player->mo->color = P_GetPlayerColor(player);
G_GhostAddColor(GHC_NORMAL); G_GhostAddColor(GHC_NORMAL);
} }
@ -13113,3 +13113,16 @@ boolean P_PlayerShouldUseSpinHeight(player_t *player)
&& player->dashmode >= DASHMODE_THRESHOLD && player->mo->state-states == S_PLAY_DASH) && player->dashmode >= DASHMODE_THRESHOLD && player->mo->state-states == S_PLAY_DASH)
|| JUMPCURLED(player)); || JUMPCURLED(player));
} }
UINT16 P_GetPlayerColor(player_t *player)
{
if (G_GametypeHasTeams() && player->ctfteam)
{
if (player->ctfteam == 1)
return skincolor_redteam;
else if (player->ctfteam == 2)
return skincolor_blueteam;
}
return player->skincolor;
}

View file

@ -827,6 +827,8 @@ static void ST_drawLivesArea(void)
V_DrawSmallScaledPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y, V_DrawSmallScaledPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y,
hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, livesback); hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, livesback);
UINT16 facecolor = P_GetPlayerColor(stplyr);
// face // face
if (stplyr->spectator) if (stplyr->spectator)
{ {
@ -856,10 +858,10 @@ static void ST_drawLivesArea(void)
} }
} }
} }
else if (stplyr->skincolor) else if (facecolor)
{ {
// skincolor face // skincolor face
UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE); UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, facecolor, GTC_CACHE);
V_DrawSmallMappedPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y, V_DrawSmallMappedPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y,
hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, faceprefix[stplyr->skin], colormap); hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, faceprefix[stplyr->skin], colormap);
} }
@ -1030,7 +1032,8 @@ static void ST_drawLivesArea(void)
static void ST_drawInput(void) static void ST_drawInput(void)
{ {
const INT32 accent = V_SNAPTOLEFT|V_SNAPTOBOTTOM|(stplyr->skincolor ? skincolors[stplyr->skincolor].ramp[4] : 0); UINT16 color = P_GetPlayerColor(stplyr);
const INT32 accent = V_SNAPTOLEFT|V_SNAPTOBOTTOM|(color ? skincolors[color].ramp[4] : 0);
INT32 col; INT32 col;
UINT8 offs; UINT8 offs;