Properly replace MT_REDFLAG and MT_BLUEFLAG with the flags of the current teams

This commit is contained in:
Lactozilla 2023-08-06 21:48:46 -03:00
parent b31afd6e6e
commit 69944f1521
3 changed files with 14 additions and 5 deletions

View file

@ -3941,6 +3941,8 @@ void G_InitTeam(UINT8 team)
G_FreeTeamData(team); G_FreeTeamData(team);
memset(&teams[team], 0, sizeof(team_t)); memset(&teams[team], 0, sizeof(team_t));
teams[team].flag = 1 << (team - 1);
} }
UINT8 G_AddTeam(const char *name) UINT8 G_AddTeam(const char *name)

View file

@ -12066,7 +12066,7 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i)
} }
else if (i == MT_BLUEFLAG || i == MT_REDFLAG || i == MT_TEAMFLAG) else if (i == MT_BLUEFLAG || i == MT_REDFLAG || i == MT_TEAMFLAG)
{ {
UINT8 team = i == MT_TEAMFLAG ? mthing->args[0] : mobjinfo[i].mass; UINT8 team = i == MT_TEAMFLAG ? mthing->args[0] : G_GetTeam(mobjinfo[i].mass);
if (team == TEAM_NONE || team >= numteams) if (team == TEAM_NONE || team >= numteams)
return false; return false;
else if (flagmobjs[team] && !P_MobjWasRemoved(flagmobjs[team])) else if (flagmobjs[team] && !P_MobjWasRemoved(flagmobjs[team]))
@ -12161,6 +12161,13 @@ static mobjtype_t P_GetMobjtypeSubstitute(mapthing_t *mthing, mobjtype_t i)
return MT_NULL; return MT_NULL;
return teams[team].flag_mobj_type; return teams[team].flag_mobj_type;
} }
else if (i == MT_BLUEFLAG || i == MT_REDFLAG)
{
INT32 team = G_GetTeam(mobjinfo[i].mass);
if (team == TEAM_NONE || team >= numteams)
return MT_NULL;
return teams[team].flag_mobj_type;
}
if (!(gametyperules & GTR_TEAMS)) if (!(gametyperules & GTR_TEAMS))
{ {

View file

@ -3947,7 +3947,7 @@ void P_SetupSignExit(player_t *player)
// //
boolean P_TeamHasFlagAtBase(UINT8 team) boolean P_TeamHasFlagAtBase(UINT8 team)
{ {
if (team == TEAM_NONE || team >= teamsingame) if (team == TEAM_NONE || team >= numteams)
return false; return false;
thinker_t *think; thinker_t *think;
@ -4739,7 +4739,7 @@ static void P_ProcessExitSector(player_t *player, mtag_t sectag)
static void P_ProcessTeamBase(player_t *player, UINT8 team) static void P_ProcessTeamBase(player_t *player, UINT8 team)
{ {
if (team == TEAM_NONE || team >= teamsingame) if (team == TEAM_NONE || team >= numteams)
return; return;
if (!(gametyperules & GTR_TEAMFLAGS)) if (!(gametyperules & GTR_TEAMFLAGS))
@ -4795,14 +4795,14 @@ static void P_ProcessTeamBase(player_t *player, UINT8 team)
if (totalcaptured == 1) if (totalcaptured == 1)
{ {
UINT8 otherteam = teamscaptured[0]; UINT8 otherteam = teamscaptured[0];
HU_DoCEcho(va(M_GetText("%s%s\200\\captured the %s%s\200.\\\\\\\\"), GetChatColorForSkincolor(G_GetTeamColor(team)), player_names[player-players], GetChatColorForSkincolor(G_GetTeamColor(otherteam)), G_GetTeamFlagName(otherteam))); HU_DoCEcho(va(M_GetText("%s%s\200\\captured the %s%s\200.\\\\\\\\"), GetChatColorForSkincolor(G_GetTeamColor(player->ctfteam)), player_names[player-players], GetChatColorForSkincolor(G_GetTeamColor(otherteam)), G_GetTeamFlagName(otherteam)));
} }
else else
{ {
char *buffer = NULL; char *buffer = NULL;
size_t buffer_size = 0; size_t buffer_size = 0;
const char *text = va(M_GetText("%s%s\200 captured the:\\"), GetChatColorForSkincolor(G_GetTeamColor(team)), player_names[player-players]); const char *text = va(M_GetText("%s%s\200 captured the:\\"), GetChatColorForSkincolor(G_GetTeamColor(player->ctfteam)), player_names[player-players]);
buffer_size += strlen(text) + 1; buffer_size += strlen(text) + 1;
buffer = Z_Realloc(buffer, buffer_size, PU_STATIC, NULL); buffer = Z_Realloc(buffer, buffer_size, PU_STATIC, NULL);
strcpy(buffer, text); strcpy(buffer, text);