Skip to content

Commit

Permalink
New helper function, *_IsAFFAGametype, it's effectively the contrar…
Browse files Browse the repository at this point in the history
…y to `*_IsATeamGametype`, but it should help locate errors. (#270)
  • Loading branch information
NeonKnightOA authored Mar 23, 2024
1 parent 3d9b971 commit 4a317a7
Show file tree
Hide file tree
Showing 24 changed files with 91 additions and 48 deletions.
1 change: 1 addition & 0 deletions code/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,7 @@ void trap_R_LFX_ParticleEffect( int effect, const vec3_t origin, const vec3_t ve

/* Neon_Knight: Useful check in order to have code consistency. */
qboolean CG_IsATeamGametype(int check); /* Whether the gametype is team-based or not.*/
qboolean CG_IsAFFAGametype(int check); /* Whether the gametype is NOT team-based or not.*/
qboolean CG_UsesTeamFlags(int check); /* Whether the gametype uses the red and blue flags. */
qboolean CG_UsesTheWhiteFlag(int check); /* Whether the gametype uses the neutral flag. */
qboolean CG_IsARoundBasedGametype(int check); /* Whether the gametype uses the neutral flag. */
Expand Down
10 changes: 10 additions & 0 deletions code/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2724,6 +2724,16 @@ qboolean CG_IsATeamGametype(int gametype) {
}
/*
===================
CG_IsAFFAGametype
Checks if the gametype is NOT a team-based game.
===================
*/
qboolean CG_IsAFFAGametype(int gametype) {
return !GAMETYPE_IS_A_TEAM_GAME(gametype);
}
/*
===================
CG_UsesTeamFlags
Checks if the gametype makes use of the red and blue flags.
Expand Down
8 changes: 4 additions & 4 deletions code/cgame/cg_newdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void CG_SetPrintString(int type, const char *p)

void CG_CheckOrderPending(void)
{
if (!CG_IsATeamGametype(cgs.gametype)) {
if (CG_IsAFFAGametype(cgs.gametype)) {
return;
}
if (cgs.orderPending) {
Expand Down Expand Up @@ -872,7 +872,7 @@ static void CG_DrawCTFPowerUp(rectDef_t *rect)
{
int value;

if (!CG_IsATeamGametype(cgs.gametype)) {
if (CG_IsAFFAGametype(cgs.gametype)) {
return;
}
value = cg.snap->ps.stats[STAT_PERSISTANT_POWERUP];
Expand Down Expand Up @@ -1120,7 +1120,7 @@ qboolean CG_OwnerDrawVisible(int flags)
}

if (flags & CG_SHOW_ANYNONTEAMGAME) {
if(!CG_IsATeamGametype(cgs.gametype)) {
if(CG_IsAFFAGametype(cgs.gametype)) {
return qtrue;
}
}
Expand Down Expand Up @@ -1309,7 +1309,7 @@ static void CG_Draw2ndPlace(rectDef_t *rect, float scale, vec4_t color, qhandle_
const char *CG_GetGameStatusText(void)
{
const char *s = "";
if (!CG_IsATeamGametype(cgs.gametype)) {
if (CG_IsAFFAGametype(cgs.gametype)) {
if (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR ) {
s = va("%s place with %i",CG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ),cg.snap->ps.persistant[PERS_SCORE] );
}
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ static qboolean CG_ScanForExistingClientInfo(clientInfo_t *ci) {
&& Q_strequal(ci->headSkinName, match->headSkinName)
&& Q_strequal(ci->blueTeam, match->blueTeam)
&& Q_strequal(ci->redTeam, match->redTeam)
&& (!CG_IsATeamGametype(cgs.gametype) || ci->team == match->team)) {
&& (CG_IsAFFAGametype(cgs.gametype) || ci->team == match->team)) {
// this clientinfo is identical, so use it's handles

ci->deferred = qfalse;
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_playerstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops ) {
if ( !cg.warmup ) {
// never play lead changes during warmup
if ( ps->persistant[PERS_RANK] != ops->persistant[PERS_RANK] ) {
if (!CG_IsATeamGametype(cgs.gametype)) {
if (CG_IsAFFAGametype(cgs.gametype)) {
if ( ps->persistant[PERS_RANK] == 0 ) {
CG_AddBufferedSound(cgs.media.takenLeadSound);
} else if ( ps->persistant[PERS_RANK] == RANK_TIED_FLAG && cgs.gametype != GT_POSSESSION ) {
Expand Down
2 changes: 1 addition & 1 deletion code/cgame/cg_scoreboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ qboolean CG_DrawOldScoreboard(void) {
}

// current rank
if (!CG_IsATeamGametype(cgs.gametype)) {
if (CG_IsAFFAGametype(cgs.gametype)) {
if (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR) {
s = va("%s place with %i",
CG_PlaceString(cg.snap->ps.persistant[PERS_RANK] + 1),
Expand Down
28 changes: 14 additions & 14 deletions code/game/ai_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ void BotMatch_JoinSubteam(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];
int client;

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match)) return;
//get the sub team name
Expand All @@ -646,7 +646,7 @@ void BotMatch_LeaveSubteam(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];
int client;

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match)) return;
//
Expand All @@ -666,7 +666,7 @@ BotMatch_WhichTeam
==================
*/
void BotMatch_WhichTeam(bot_state_t *bs, bot_match_t *match) {
if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match)) return;

Expand All @@ -692,7 +692,7 @@ void BotMatch_CheckPoint(bot_state_t *bs, bot_match_t *match) {
vec3_t position;
bot_waypoint_t *cp;

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//
trap_BotMatchVariable(match, POSITION, buf, MAX_MESSAGE_SIZE);
VectorClear(position);
Expand Down Expand Up @@ -746,7 +746,7 @@ void BotMatch_FormationSpace(bot_state_t *bs, bot_match_t *match) {
char buf[MAX_MESSAGE_SIZE];
float space;

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match)) return;
//
Expand All @@ -769,7 +769,7 @@ void BotMatch_Dismiss(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];
int client;

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match)) return;
trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
Expand All @@ -794,7 +794,7 @@ void BotMatch_Suicide(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];
int client;

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match)) return;
//
Expand All @@ -816,7 +816,7 @@ void BotMatch_StartTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
int client;
char teammate[MAX_MESSAGE_SIZE];

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if chats for him or herself
if (match->subtype & ST_I) {
//get the team mate that will be the team leader
Expand All @@ -842,7 +842,7 @@ void BotMatch_StopTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
char teammate[MAX_MESSAGE_SIZE];
char netname[MAX_MESSAGE_SIZE];

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//get the team mate that stops being the team leader
trap_BotMatchVariable(match, TEAMMATE, teammate, sizeof(teammate));
//if chats for him or herself
Expand Down Expand Up @@ -870,7 +870,7 @@ BotMatch_WhoIsTeamLeader
void BotMatch_WhoIsTeamLeader(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;

ClientName(bs->client, netname, sizeof(netname));
//if this bot IS the team leader
Expand Down Expand Up @@ -1079,7 +1079,7 @@ void BotMatch_WhereAreYou(bot_state_t *bs, bot_match_t *match) {
NULL
};
//
if (!G_IsATeamGametype(gametype))
if (G_IsAFFAGametype(gametype))
return;

//if not addressed to this bot
Expand Down Expand Up @@ -1141,7 +1141,7 @@ void BotMatch_LeadTheWay(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE], teammate[MAX_MESSAGE_SIZE];
int client, areanum, other;

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match)) return;
//if someone asks for someone else
Expand Down Expand Up @@ -1210,7 +1210,7 @@ void BotMatch_Kill(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];
int client;

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match)) return;

Expand Down Expand Up @@ -1552,7 +1552,7 @@ void BotMatch_AcknowledgeOrder(bot_state_t *bs, bot_match_t *match, int ltgType,
bot_match_t teammatematch;

// Orders can only be given in team-based modes.
if (!G_IsATeamGametype(gametype)) {
if (G_IsAFFAGametype(gametype)) {
return;
}
// Gametype order restriction zone.
Expand Down
2 changes: 1 addition & 1 deletion code/game/ai_dmq3.c
Original file line number Diff line number Diff line change
Expand Up @@ -4834,7 +4834,7 @@ void BotCheckConsoleMessages(bot_state_t *bs) {
}
} //if at a valid chat position and not chatting already and not in teamplay
else if (bs->ainode != AINode_Stand && BotValidChatPosition(bs) &&
!G_IsATeamGametype(gametype)) {
G_IsAFFAGametype(gametype)) {
chat_reply = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_REPLY, 0, 1);
if (random() < 1.5 / (NumBots() + 1) && random() < chat_reply) {
//if bot replies with a chat message
Expand Down
2 changes: 1 addition & 1 deletion code/game/ai_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,7 @@ void BotTeamAI(bot_state_t *bs) {
}

//
if (!G_IsATeamGametype(gametype))
if (G_IsAFFAGametype(gametype))
return;
// make sure we've got a valid team leader
if (!BotValidTeamLeader(bs)) {
Expand Down
4 changes: 2 additions & 2 deletions code/game/ai_vcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ BotVoiceChat_WhoIsLeader
void BotVoiceChat_WhoIsLeader(bot_state_t *bs, int client, int mode) {
char netname[MAX_MESSAGE_SIZE];

if (!G_IsATeamGametype(gametype)) return;
if (G_IsAFFAGametype(gametype)) return;

ClientName(bs->client, netname, sizeof(netname));
//if this bot IS the team leader
Expand Down Expand Up @@ -646,7 +646,7 @@ int BotVoiceChatCommand(bot_state_t *bs, int mode, char *voiceChat) {
int i, clientNum;
char *ptr, buf[MAX_MESSAGE_SIZE], *cmd;

if (!G_IsATeamGametype(gametype)) {
if (G_IsAFFAGametype(gametype)) {
return qfalse;
}

Expand Down
2 changes: 1 addition & 1 deletion code/game/g_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ void ClientBegin( int clientNum ) {
countFree = TeamCount(-1,TEAM_FREE);
countRed = TeamCount(-1,TEAM_RED);
countBlue = TeamCount(-1,TEAM_BLUE);
if(!G_IsATeamGametype(g_gametype.integer))
if(G_IsAFFAGametype(g_gametype.integer))
{
if(countFree>level.teamSize)
level.teamSize=countFree;
Expand Down
6 changes: 3 additions & 3 deletions code/game/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
return;
}

if ( !G_IsATeamGametype(g_gametype.integer) && mode == SAY_TEAM ) {
if ( G_IsAFFAGametype(g_gametype.integer) && mode == SAY_TEAM ) {
mode = SAY_ALL;
}

Expand Down Expand Up @@ -1394,7 +1394,7 @@ void G_Voice( gentity_t *ent, gentity_t *target, int mode, const char *id, qbool
int j;
gentity_t *other;

if ( !G_IsATeamGametype(g_gametype.integer) && mode == SAY_TEAM ) {
if ( G_IsAFFAGametype(g_gametype.integer) && mode == SAY_TEAM ) {
mode = SAY_ALL;
}

Expand Down Expand Up @@ -1919,7 +1919,7 @@ void Cmd_CallVote_f( gentity_t *ent ) {
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "Kick %s?" , level.clients[i].pers.netname );
}
else if ( Q_strequal( arg1, "shuffle" ) ) {
if(!G_IsATeamGametype(g_gametype.integer)) { //Not a team game
if(G_IsAFFAGametype(g_gametype.integer)) { //Not a team game
trap_SendServerCommand( ent-g_entities, "print \"Can only be used in team games.\n\"" );
return;
}
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_combat.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void AddScore( gentity_t *ent, vec3_t origin, int score )
return;
}
// show score plum
if( level.numNonSpectatorClients<3 && score < 0 && !G_IsATeamGametype(g_gametype.integer)) {
if( level.numNonSpectatorClients<3 && score < 0 && G_IsAFFAGametype(g_gametype.integer)) {
for ( i = 0 ; i < level.maxclients ; i++ ) {
if ( level.clients[ i ].pers.connected != CON_CONNECTED )
continue; //Client was not connected
Expand Down
1 change: 1 addition & 0 deletions code/game/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,7 @@ void monster_die (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, in

/* Neon_Knight: Useful check in order to have code consistency. */
qboolean G_IsATeamGametype(int check); /* Whether the gametype is team-based or not.*/
qboolean G_IsAFFAGametype(int check); /* Whether the gametype is NOT team-based or not.*/
qboolean G_UsesTeamFlags(int check); /* Whether the gametype uses the red and blue flags. */
qboolean G_UsesTheWhiteFlag(int check); /* Whether the gametype uses the neutral flag. */
qboolean G_IsARoundBasedGametype(int check); /* Whether the gametype uses the neutral flag. */
Expand Down
12 changes: 11 additions & 1 deletion code/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2371,7 +2371,7 @@ void CheckTournament( void )
int counts[TEAM_NUM_TEAMS];
qboolean notEnough = qfalse;

if(!G_IsATeamGametype(g_gametype.integer)) {
if(G_IsAFFAGametype(g_gametype.integer)) {
counts[TEAM_BLUE] = TeamCount( -1, TEAM_BLUE );
counts[TEAM_RED] = TeamCount( -1, TEAM_RED );

Expand Down Expand Up @@ -2844,6 +2844,16 @@ qboolean G_IsATeamGametype(int check) {
}
/*
===================
G_IsAFFAGametype
Checks if the gametype is NOT a team-based game.
===================
*/
qboolean G_IsAFFAGametype(int check) {
return !GAMETYPE_IS_A_TEAM_GAME(check);
}
/*
===================
G_UsesTeamFlags
Checks if the gametype makes use of the red and blue flags.
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ static int countCtfSpawnpoints(void) {
}

int MinSpawnpointCount(void) {
if(!G_IsATeamGametype(g_gametype.integer)) {
if(G_IsAFFAGametype(g_gametype.integer)) {
return countFfaSpawnpoints();
}
if(g_gametype.integer == GT_DOUBLE_D ) {
Expand Down
4 changes: 2 additions & 2 deletions code/game/g_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ qboolean OnSameTeam( const gentity_t *ent1, const gentity_t *ent2 )
return qfalse;
}

if (!G_IsATeamGametype(g_gametype.integer)) {
if (G_IsAFFAGametype(g_gametype.integer)) {
return qfalse;
}

Expand Down Expand Up @@ -2426,7 +2426,7 @@ void ShuffleTeams(void)
int nextTeam = TEAM_RED;
int count = 0;

if (!G_IsATeamGametype(g_gametype.integer)) {
if (G_IsAFFAGametype(g_gametype.integer)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion code/q3_ui/ui_ingame.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void InGame_MenuInit( void ) {
s_ingame.teamorders.string = "TEAM ORDERS";
s_ingame.teamorders.color = color_red;
s_ingame.teamorders.style = UI_CENTER|UI_SMALLFONT;
if(!UI_IsATeamGametype(gametype)) {
if(UI_IsAFFAGametype(gametype)) {
s_ingame.teamorders.generic.flags |= QMF_GRAYED;
}
else {
Expand Down
1 change: 1 addition & 0 deletions code/q3_ui/ui_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,7 @@ void UI_RankStatusMenu( void );

/* Neon_Knight: Useful check in order to have code consistency. */
qboolean UI_IsATeamGametype(int check); /* Whether the gametype is team-based or not.*/
qboolean UI_IsAFFAGametype(int check); /* Whether the gametype is NOT team-based or not.*/
qboolean UI_UsesTeamFlags(int check); /* Whether the gametype uses the red and blue flags. */
qboolean UI_UsesTheWhiteFlag(int check); /* Whether the gametype uses the neutral flag. */
qboolean UI_IsARoundBasedGametype(int check); /* Whether the gametype uses the neutral flag. */
Expand Down
10 changes: 10 additions & 0 deletions code/q3_ui/ui_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,16 @@ qboolean UI_IsATeamGametype(int check) {
}
/*
===================
UI_IsAFFAGametype
Checks if the gametype is NOT a team-based game.
===================
*/
qboolean UI_IsAFFAGametype(int check) {
return !GAMETYPE_IS_A_TEAM_GAME(check);
}
/*
===================
UI_UsesTeamFlags
Checks if the gametype makes use of the red and blue flags.
Expand Down
Loading

0 comments on commit 4a317a7

Please sign in to comment.