Pull request #35. Replaces all the complicated gametype checks with helper functions

Squashed commit of the following:

commit c05ffecf38
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Fri Nov 30 22:53:54 2018 -0300

    This is also not needed anymore.

commit 14abe7715a
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Fri Nov 30 22:29:26 2018 -0300

    Last checks found. Hopefully that's enough.

commit cad2ab0c5a
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Fri Nov 30 22:14:33 2018 -0300

    We don't need g_ffa_gt anymore.

commit 2577547db4
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Fri Nov 30 22:04:09 2018 -0300

    More checks located.

commit d9c96477c6
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Fri Nov 30 21:29:41 2018 -0300

    Had to do this just to get it to compile.

commit 2089039745
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Fri Nov 30 21:18:25 2018 -0300

    Fixing several syntax errors.

commit 0edba34607
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Fri Nov 30 21:07:23 2018 -0300

    Oops... my mistakes. -.-

commit 05e9ef79d4
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Fri Nov 30 21:00:00 2018 -0300

    New checks for team flags, team obelisks, control points and rounds.

commit 06e325ab00
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Thu Nov 29 17:10:48 2018 -0300

    Some syntax errors fixed.

commit e394d4fc54
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Thu Nov 29 17:00:01 2018 -0300

    Finished the splitting.

commit 5e267d161f
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Thu Nov 29 16:34:01 2018 -0300

    Splitting the function.

commit 7c643f14aa
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Thu Nov 29 12:36:14 2018 -0300

    Syntax error.

commit aba598fde4
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Thu Nov 29 12:26:58 2018 -0300

    All the isTeam checks were moved to a centralized function.

commit b9a61dbe45
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Wed Nov 28 21:26:34 2018 -0300

    Revert "Toggleable missionpack checks. Disables team models and relevant checks interfering with testing. Some comments were also modified in order to work with SciTE."

    This reverts commit fe4c340e35.

commit fe4c340e35
Author: Neon_Knight <openarena.arg@gmail.com>
Date:   Wed Nov 28 21:21:31 2018 -0300

    Toggleable missionpack checks. Disables team models and relevant checks interfering with testing. Some comments were also modified in order to work with SciTE.
This commit is contained in:
sago007 2018-12-01 10:43:03 +01:00
parent 0d43362795
commit 0bee41a517
48 changed files with 739 additions and 333 deletions

View file

@ -400,7 +400,7 @@ static void CG_DenyOrder_f(void) {
}
static void CG_TaskOffense_f(void) {
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_1FCTF) {
if (CG_UsesTeamFlags(cgs.gametype)) {
trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONGETFLAG));
} else {
trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONOFFENSE));

View file

@ -1443,7 +1443,7 @@ static float CG_DrawFollowMessage(float y) {
char *s;
int w;
if (!(cg.snap->ps.pm_flags & PMF_FOLLOW) || ((cgs.elimflags & EF_NO_FREESPEC) && (cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION))) {
if (!(cg.snap->ps.pm_flags & PMF_FOLLOW) || ((cgs.elimflags & EF_NO_FREESPEC) && CG_IsARoundBasedGametype(cgs.gametype) && CG_IsATeamGametype(cgs.gametype))) {
return y;
}
@ -1582,7 +1582,7 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame) {
y = 0;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype) && cg_drawTeamOverlay.integer == 1) {
y = CG_DrawTeamOverlay(y, qtrue, qtrue);
}
/*if ( cgs.gametype == GT_DOUBLE_D ) {
@ -1607,7 +1607,7 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame) {
if (cg_drawFPS.integer && (stereoFrame == STEREO_CENTER || stereoFrame == STEREO_RIGHT)) {
y = CG_DrawFPS(y);
}
if (cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_LMS) {
if (CG_IsARoundBasedGametype(cgs.gametype)) {
y = CG_DrawEliminationTimer(y);
/*if (cgs.clientinfo[ cg.clientNum ].isDead)
y = CG_DrawEliminationDeathMessage( y);*/
@ -1665,7 +1665,7 @@ static float CG_DrawScores(float y) {
y1 = y;
// draw from the right side to left
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
x = 640;
color[0] = 0.0f;
color[1] = 0.0f;
@ -1680,7 +1680,7 @@ static float CG_DrawScores(float y) {
}
CG_DrawBigString(x + 4, y, s, 1.0F);
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION) {
if (CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) {
// Display flag status
item = BG_FindItemForPowerup(PW_BLUEFLAG);
@ -1714,7 +1714,7 @@ static float CG_DrawScores(float y) {
}
CG_DrawBigString(x + 4, y, s, 1.0F);
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION) {
if (CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) {
// Display flag status
item = BG_FindItemForPowerup(PW_REDFLAG);
@ -1752,7 +1752,7 @@ static float CG_DrawScores(float y) {
if (cgs.gametype >= GT_CTF && cgs.ffa_gt == 0) {
if (CG_IsATeamGametype(cgs.gametype)) {
v = cgs.capturelimit;
} else {
v = cgs.fraglimit;
@ -1950,7 +1950,7 @@ static void CG_DrawLowerRight(void) {
y = 480 - ICON_SIZE;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 2) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype) && cg_drawTeamOverlay.integer == 2) {
y = CG_DrawTeamOverlay(y, qtrue, qfalse);
}
@ -2005,7 +2005,7 @@ static void CG_DrawLowerLeft(void) {
y = 480 - ICON_SIZE;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 3) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype) && cg_drawTeamOverlay.integer == 3) {
y = CG_DrawTeamOverlay(y, qfalse, qfalse);
}
@ -2965,7 +2965,7 @@ static void CG_DrawSpectator(void) {
CG_DrawBigString(320 - 9 * 8, 440, "SPECTATOR", 1.0F);
if (cgs.gametype == GT_TOURNAMENT) {
CG_DrawBigString(320 - 15 * 8, 460, "waiting to play", 1.0F);
} else if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
} else if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
CG_DrawBigString(320 - 39 * 8, 460, "press ESC and use the JOIN menu to play", 1.0F);
}
}
@ -3080,7 +3080,7 @@ static qboolean CG_DrawScoreboard(void) {
if (menuScoreboard == NULL) {
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
menuScoreboard = Menus_FindByName("teamscore_menu");
} else {
menuScoreboard = Menus_FindByName("score_menu");
@ -3104,7 +3104,7 @@ static qboolean CG_DrawScoreboard(void) {
#else
char *s;
int w;
if (cg.respawnTime && cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR && (cgs.gametype < GT_ELIMINATION || cgs.gametype > GT_LMS)) {
if (cg.respawnTime && cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR && (!CG_IsARoundBasedGametype(cgs.gametype))) {
if (cg.respawnTime > cg.time) {
s = va("Respawn in: %2.2f", ((double) cg.respawnTime - (double) cg.time) / 1000.0);
w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH;
@ -3529,7 +3529,7 @@ static void CG_Draw2D(stereoFrame_t stereoFrame) {
CG_DrawReward();
}
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
#ifndef MISSIONPACK
CG_DrawTeamInfo();
#endif

View file

@ -819,15 +819,11 @@ CG_TeamBase
*/
static void CG_TeamBase( centity_t *cent ) {
refEntity_t model;
//#ifdef MISSIONPACK
vec3_t angles;
int t, h;
float c;
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF ) {
//#else
// if ( cgs.gametype == GT_CTF) {
//#endif
if ( CG_UsesTeamFlags(cgs.gametype) ) {
// show the flag base
memset(&model, 0, sizeof(model));
model.reType = RT_MODEL;
@ -845,7 +841,6 @@ static void CG_TeamBase( centity_t *cent ) {
}
trap_R_AddRefEntityToScene( &model );
}
//#ifdef MISSIONPACK
else if ( cgs.gametype == GT_OBELISK ) {
// show the obelisk
memset(&model, 0, sizeof(model));
@ -962,7 +957,6 @@ static void CG_TeamBase( centity_t *cent ) {
}
trap_R_AddRefEntityToScene( &model );
}
//#endif
}
/*

View file

@ -254,7 +254,7 @@ static void CG_Obituary(entityState_t *ent) {
if (attacker == cg.snap->ps.clientNum) {
char *s;
if (cgs.gametype < GT_TEAM) {
if (!(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype))) {
s = va("You fragged %s\n%s place with %i", targetName,
CG_PlaceString(cg.snap->ps.persistant[PERS_RANK] + 1),
cg.snap->ps.persistant[PERS_SCORE]);
@ -1290,18 +1290,14 @@ void CG_EntityEvent(centity_t *cent, vec3_t position) {
if (cg.snap->ps.powerups[PW_BLUEFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) {
} else {
if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE) {
//#ifdef MISSIONPACK
if (cgs.gametype == GT_1FCTF)
CG_AddBufferedSound(cgs.media.yourTeamTookTheFlagSound);
else
//#endif
CG_AddBufferedSound(cgs.media.enemyTookYourFlagSound);
} else if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED) {
//#ifdef MISSIONPACK
if (cgs.gametype == GT_1FCTF)
CG_AddBufferedSound(cgs.media.enemyTookTheFlagSound);
else
//#endif
CG_AddBufferedSound(cgs.media.yourTeamTookEnemyFlagSound);
}
}
@ -1311,18 +1307,14 @@ void CG_EntityEvent(centity_t *cent, vec3_t position) {
if (cg.snap->ps.powerups[PW_REDFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) {
} else {
if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED) {
//#ifdef MISSIONPACK
if (cgs.gametype == GT_1FCTF)
CG_AddBufferedSound(cgs.media.yourTeamTookTheFlagSound);
else
//#endif
CG_AddBufferedSound(cgs.media.enemyTookYourFlagSound);
} else if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE) {
//#ifdef MISSIONPACK
if (cgs.gametype == GT_1FCTF)
CG_AddBufferedSound(cgs.media.enemyTookTheFlagSound);
else
//#endif
CG_AddBufferedSound(cgs.media.yourTeamTookEnemyFlagSound);
}
}

View file

@ -250,7 +250,6 @@ void CG_DrawInformation( void ) {
case GT_CTF:
s = "Capture The Flag";
break;
//#ifdef MISSIONPACK
case GT_1FCTF:
s = "One Flag CTF";
break;
@ -260,7 +259,6 @@ void CG_DrawInformation( void ) {
case GT_HARVESTER:
s = "Harvester";
break;
//#endif
case GT_ELIMINATION:
s = "Elimination";
break;
@ -294,7 +292,7 @@ void CG_DrawInformation( void ) {
y += PROP_HEIGHT;
}
if (cgs.gametype < GT_CTF || cgs.ffa_gt>0) {
if (!CG_IsATeamGametype(cgs.gametype)) {
value = atoi( Info_ValueForKey( info, "fraglimit" ) );
if ( value ) {
UI_DrawProportionalString( 320, y, va( "fraglimit %i", value ),
@ -303,7 +301,7 @@ void CG_DrawInformation( void ) {
}
}
if (cgs.gametype >= GT_CTF && cgs.ffa_gt == 0) {
if (CG_IsATeamGametype(cgs.gametype)) {
value = atoi( Info_ValueForKey( info, "capturelimit" ) );
if ( value ) {
UI_DrawProportionalString( 320, y, va( "capturelimit %i", value ),

View file

@ -1206,9 +1206,6 @@ typedef struct {
int levelStartTime;
//Forced FFA
int ffa_gt;
//Elimination
int roundStartTime;
int roundtime;
@ -2058,3 +2055,12 @@ void trap_R_LFX_ParticleEffect( int effect, const vec3_t origin, const vec3_t ve
// LEILEI ENHANCEMENT
/* 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_UsesKeyObjectives(int check); /* Whether the gametype uses key objectives 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. */
qboolean CG_UsesTeamObelisks(int check); /* Whether the gametype uses team obelisks. */
qboolean CG_UsesControlPoints(int check); /* Whether the gametype uses control points. */
/* /Neon_Knight */

View file

@ -787,7 +787,7 @@ static void CG_RegisterSounds(void) {
// N_G: Another condition that makes no sense to me, see for
// yourself if you really meant this
// Sago: Makes perfect sense: Load team game stuff if the gametype is a teamgame and not an exception (like GT_LMS)
if (((cgs.gametype >= GT_TEAM) && (cgs.ffa_gt != 1)) ||
if ((CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) ||
cg_buildScript.integer) {
cgs.media.captureAwardSound = trap_S_RegisterSound("sound/teamplay/flagcapture_yourteam.wav", qtrue);
@ -808,7 +808,7 @@ static void CG_RegisterSounds(void) {
cgs.media.takenYourTeamSound = trap_S_RegisterSound("sound/teamplay/flagtaken_yourteam.wav", qtrue);
cgs.media.takenOpponentSound = trap_S_RegisterSound("sound/teamplay/flagtaken_opponent.wav", qtrue);
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cg_buildScript.integer) {
if ((CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) || cg_buildScript.integer) {
cgs.media.redFlagReturnedSound = trap_S_RegisterSound("sound/teamplay/voc_red_returned.wav", qtrue);
cgs.media.blueFlagReturnedSound = trap_S_RegisterSound("sound/teamplay/voc_blue_returned.wav", qtrue);
cgs.media.enemyTookYourFlagSound = trap_S_RegisterSound("sound/teamplay/voc_enemy_flag.wav", qtrue);
@ -834,7 +834,7 @@ static void CG_RegisterSounds(void) {
}
if (cgs.gametype == GT_1FCTF || cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_POSSESSION || cg_buildScript.integer) {
if (CG_UsesTeamFlags(cgs.gametype) || CG_UsesTheWhiteFlag(cgs.gametype) || cg_buildScript.integer) {
cgs.media.youHaveFlagSound = trap_S_RegisterSound("sound/teamplay/voc_you_flag.wav", qtrue);
cgs.media.holyShitSound = trap_S_RegisterSound("sound/feedback/voc_holyshit.wav", qtrue);
}
@ -1150,14 +1150,14 @@ static void CG_RegisterGraphics(void) {
cgs.media.regenShader = trap_R_RegisterShader("powerups/regen");
cgs.media.hastePuffShader = trap_R_RegisterShader("hasteSmokePuff");
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_1FCTF || cgs.gametype == GT_HARVESTER || cg_buildScript.integer) {
if (CG_UsesTeamFlags(cgs.gametype) || cgs.gametype == GT_HARVESTER || cg_buildScript.integer) {
cgs.media.redCubeModel = trap_R_RegisterModel("models/powerups/orb/r_orb.md3");
cgs.media.blueCubeModel = trap_R_RegisterModel("models/powerups/orb/b_orb.md3");
cgs.media.redCubeIcon = trap_R_RegisterShader("icons/skull_red");
cgs.media.blueCubeIcon = trap_R_RegisterShader("icons/skull_blue");
}
if ((cgs.gametype >= GT_TEAM) && (cgs.ffa_gt != 1)) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
cgs.media.redOverlay = trap_R_RegisterShader("playeroverlays/playerSuit1_Red");
cgs.media.blueOverlay = trap_R_RegisterShader("playeroverlays/playerSuit1_Blue");
} else {
@ -1177,8 +1177,7 @@ static void CG_RegisterGraphics(void) {
cgs.media.ddPointSkinB[TEAM_NONE] = trap_R_RegisterShaderNoMip("icons/noammo");
}
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_1FCTF || cgs.gametype == GT_POSSESSION
|| cgs.gametype == GT_HARVESTER || cg_buildScript.integer) {
if (CG_UsesTeamFlags(cgs.gametype) || CG_UsesTheWhiteFlag(cgs.gametype) || cgs.gametype == GT_HARVESTER || cg_buildScript.integer) {
cgs.media.redFlagModel = trap_R_RegisterModel("models/flags/r_flag.md3");
cgs.media.blueFlagModel = trap_R_RegisterModel("models/flags/b_flag.md3");
cgs.media.neutralFlagModel = trap_R_RegisterModel("models/flags/n_flag.md3");
@ -1200,7 +1199,7 @@ static void CG_RegisterGraphics(void) {
cgs.media.neutralFlagBaseModel = trap_R_RegisterModel("models/mapobjects/flagbase/ntrl_base.md3");
}
if (cgs.gametype == GT_1FCTF || cgs.gametype == GT_POSSESSION || cg_buildScript.integer) {
if (CG_UsesTheWhiteFlag(cgs.gametype) || cg_buildScript.integer) {
cgs.media.neutralFlagModel = trap_R_RegisterModel("models/flags/n_flag.md3");
cgs.media.flagShader[0] = trap_R_RegisterShaderNoMip("icons/iconf_neutral1");
cgs.media.flagShader[1] = trap_R_RegisterShaderNoMip("icons/iconf_red2");
@ -1226,7 +1225,7 @@ static void CG_RegisterGraphics(void) {
cgs.media.redKamikazeShader = trap_R_RegisterShader("models/weaphits/kamikred");
cgs.media.dustPuffShader = trap_R_RegisterShader("hasteSmokePuff");
if (((cgs.gametype >= GT_TEAM) && (cgs.ffa_gt != 1)) ||
if ((CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) ||
cg_buildScript.integer) {
cgs.media.friendShader = trap_R_RegisterShader("sprites/foe");
@ -2034,7 +2033,7 @@ void CG_SetScoreSelection(void *p) {
return;
}
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
int feeder = FEEDER_REDTEAM_LIST;
i = red;
if (cg.scores[cg.selectedScore].team == TEAM_BLUE) {
@ -2051,7 +2050,7 @@ void CG_SetScoreSelection(void *p) {
static clientInfo_t * CG_InfoFromScoreIndex(int index, int team, int *scoreIndex) {
int i, count;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
count = 0;
for (i = 0; i < cg.numScores; i++) {
if (cg.scores[i].team == team) {
@ -2158,7 +2157,7 @@ static qhandle_t CG_FeederItemImage(float feederID, int index) {
}
static void CG_FeederSelection(float feederID, int index) {
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
int i, count;
int team = (feederID == FEEDER_REDTEAM_LIST) ? TEAM_RED : TEAM_BLUE;
count = 0;
@ -2694,3 +2693,112 @@ void CG_FairCvars() {
do_vid_restart = qtrue;
}
/* Neon_Knight: Useful check in order to have code consistency. */
/*
===================
CG_IsATeamGametype
Checks if the gametype is a team-based game.
===================
*/
qboolean CG_IsATeamGametype(int check) {
if (check != GT_FFA && check != GT_TOURNAMENT && check != GT_SINGLE_PLAYER && check != GT_LMS && check != GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesKeyObjectives
Checks if the gametype makes use of gametype-specific objectives.
===================
*/
qboolean CG_UsesKeyObjectives(int check) {
if (check != GT_FFA && check != GT_TOURNAMENT && check != GT_SINGLE_PLAYER && check != GT_TEAM && check != GT_LMS && check != GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesTeamFlags
Checks if the gametype makes use of the red and blue flags.
===================
*/
qboolean CG_UsesTeamFlags(int check) {
if (check == GT_CTF || check == GT_1FCTF || check == GT_CTF_ELIMINATION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesTheWhiteFlag
Checks if the gametype makes use of the neutral flag.
===================
*/
qboolean CG_UsesTheWhiteFlag(int check) {
if (check == GT_1FCTF || check == GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_IsARoundBasedGametype
Checks if the gametype has a round-based system.
===================
*/
qboolean CG_IsARoundBasedGametype(int check) {
if (check == GT_ELIMINATION || check == GT_CTF_ELIMINATION || check == GT_LMS) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesTeamObelisks
Checks if the gametype uses team-colored obelisks.
===================
*/
qboolean CG_UsesTeamObelisks(int check) {
if (check == GT_HARVESTER || check == GT_OBELISK) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesControlPoints
Checks if the gametype uses team-colored obelisks.
===================
*/
qboolean CG_UsesControlPoints(int check) {
if (check == GT_DOUBLE_D || check == GT_DOMINATION) {
return qtrue;
}
else {
return qfalse;
}
}
/* /Neon_Knight */

View file

@ -60,7 +60,7 @@ void CG_SetPrintString(int type, const char *p)
void CG_CheckOrderPending(void)
{
if (cgs.gametype < GT_CTF || cgs.ffa_gt>0) {
if (!CG_IsATeamGametype(cgs.gametype)) {
return;
}
if (cgs.orderPending) {
@ -695,7 +695,7 @@ static void CG_DrawBlueFlagName(rectDef_t *rect, float scale, vec4_t color, int
static void CG_DrawBlueFlagStatus(rectDef_t *rect, qhandle_t shader)
{
if (cgs.gametype != GT_CTF && cgs.gametype != GT_CTF_ELIMINATION && cgs.gametype != GT_1FCTF) {
if (!CG_UsesTeamFlags(cgs.gametype)) {
if (cgs.gametype == GT_HARVESTER) {
vec4_t color = {0, 0, 1, 1};
trap_R_SetColor(color);
@ -750,7 +750,7 @@ static void CG_DrawRedFlagName(rectDef_t *rect, float scale, vec4_t color, int t
static void CG_DrawRedFlagStatus(rectDef_t *rect, qhandle_t shader)
{
if (cgs.gametype != GT_CTF && cgs.gametype != GT_CTF_ELIMINATION && cgs.gametype != GT_1FCTF) {
if (!CG_UsesTeamFlags(cgs.gametype)) {
if (cgs.gametype == GT_HARVESTER) {
vec4_t color = {1, 0, 0, 1};
trap_R_SetColor(color);
@ -840,7 +840,7 @@ static void CG_HarvesterSkulls(rectDef_t *rect, float scale, vec4_t color, qbool
static void CG_OneFlagStatus(rectDef_t *rect)
{
if (cgs.gametype != GT_1FCTF && cgs.gametype != GT_POSSESSION) {
if (!CG_UsesTheWhiteFlag(cgs.gametype)) {
return;
}
else {
@ -872,7 +872,7 @@ static void CG_DrawCTFPowerUp(rectDef_t *rect)
{
int value;
if (cgs.gametype < GT_CTF || cgs.ffa_gt>0) {
if (!CG_IsATeamGametype(cgs.gametype)) {
return;
}
value = cg.snap->ps.stats[STAT_PERSISTANT_POWERUP];
@ -1019,7 +1019,7 @@ float CG_GetValue(int ownerDraw)
qboolean CG_OtherTeamHasFlag(void)
{
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_1FCTF) {
if (CG_UsesTeamFlags(cgs.gametype)) {
int team = cg.snap->ps.persistant[PERS_TEAM];
if (cgs.gametype == GT_1FCTF) {
if (team == TEAM_RED && cgs.flagStatus == FLAG_TAKEN_BLUE) {
@ -1049,7 +1049,7 @@ qboolean CG_OtherTeamHasFlag(void)
qboolean CG_YourTeamHasFlag(void)
{
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_1FCTF) {
if (CG_UsesTeamFlags(cgs.gametype)) {
int team = cg.snap->ps.persistant[PERS_TEAM];
if (cgs.gametype == GT_1FCTF) {
if (team == TEAM_RED && cgs.flagStatus == FLAG_TAKEN_RED) {
@ -1109,13 +1109,13 @@ qboolean CG_OwnerDrawVisible(int flags)
}
if (flags & CG_SHOW_ANYTEAMGAME) {
if( cgs.gametype >= GT_TEAM && cgs.ffa_gt!=1) {
if(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
return qtrue;
}
}
if (flags & CG_SHOW_ANYNONTEAMGAME) {
if( cgs.gametype < GT_TEAM || cgs.ffa_gt==1) {
if(!(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype))) {
return qtrue;
}
}
@ -1139,7 +1139,7 @@ qboolean CG_OwnerDrawVisible(int flags)
}
if (flags & CG_SHOW_CTF) {
if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION) {
if(CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) {
return qtrue;
}
}
@ -1242,7 +1242,7 @@ static void CG_DrawKiller(rectDef_t *rect, float scale, vec4_t color, qhandle_t
static void CG_DrawCapFragLimit(rectDef_t *rect, float scale, vec4_t color, qhandle_t shader, int textStyle)
{
int limit = (cgs.gametype >= GT_CTF && cgs.ffa_gt==0) ? cgs.capturelimit : cgs.fraglimit;
int limit = (CG_IsATeamGametype(cgs.gametype)) ? cgs.capturelimit : cgs.fraglimit;
CG_Text_Paint(rect->x, rect->y, scale, color, va("%2i", limit),0, 0, textStyle);
}
@ -1263,7 +1263,7 @@ static void CG_Draw2ndPlace(rectDef_t *rect, float scale, vec4_t color, qhandle_
const char *CG_GetGameStatusText(void)
{
const char *s = "";
if ( cgs.gametype < GT_TEAM || cgs.ffa_gt==1) {
if (!(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(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] );
}
@ -1972,9 +1972,9 @@ static void CG_DrawCaptureLimit( rectDef_t *rect, float text_x, float text_y, ve
int value;
info = CG_ConfigString( CS_SERVERINFO );
value = atoi( Info_ValueForKey( info, "capturelimit" ) );
if (cgs.gametype >= GT_CTF && cgs.ffa_gt == 0)
if (CG_IsATeamGametype(cgs.gametype))
value = atoi( Info_ValueForKey( info, "capturelimit" ) );
if (cgs.gametype < GT_CTF || cgs.ffa_gt>0)
if (!CG_IsATeamGametype(cgs.gametype))
value = atoi( Info_ValueForKey( info, "fraglimit" ) );
if ( value ) {
CG_DrawLoadingString( rect, text_x, text_y, color, scale, align, textStyle, va( "%i", value ));

View file

@ -466,7 +466,7 @@ static qboolean CG_FindClientModelFile(char *filename, int length, clientInfo_t
char *team, *charactersFolder;
int i;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
switch (ci->team) {
case TEAM_BLUE:
{
@ -495,7 +495,7 @@ static qboolean CG_FindClientModelFile(char *filename, int length, clientInfo_t
if (CG_FileExists(filename)) {
return qtrue;
}
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
if (i == 0 && teamName && *teamName) {
// "models/players/characters/sergei/stroggs/lower_red.skin"
Com_sprintf(filename, length, "models/players/%s%s/%s%s_%s.%s", charactersFolder, modelName, teamName, base, team, ext);
@ -538,7 +538,7 @@ static qboolean CG_FindClientHeadFile(char *filename, int length, clientInfo_t *
char *team, *headsFolder;
int i;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
switch (ci->team) {
case TEAM_BLUE:
{
@ -571,7 +571,7 @@ static qboolean CG_FindClientHeadFile(char *filename, int length, clientInfo_t *
if (CG_FileExists(filename)) {
return qtrue;
}
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
if (i == 0 && teamName && *teamName) {
Com_sprintf(filename, length, "models/players/%s%s/%s%s_%s.%s", headsFolder, headModelName, teamName, base, team, ext);
} else {
@ -857,7 +857,7 @@ static void CG_LoadClientInfo(int clientNum, clientInfo_t *ci) {
teamname[0] = 0;
#ifdef MISSIONPACK
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
if (ci->team == TEAM_BLUE) {
Q_strncpyz(teamname, cg_blueTeamName.string, sizeof (teamname));
} else {
@ -875,7 +875,7 @@ static void CG_LoadClientInfo(int clientNum, clientInfo_t *ci) {
}
// fall back to default team name
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
// keep skin name
if (ci->team == TEAM_BLUE) {
Q_strncpyz(teamname, DEFAULT_BLUETEAM_NAME, sizeof (teamname));
@ -904,7 +904,7 @@ static void CG_LoadClientInfo(int clientNum, clientInfo_t *ci) {
// sounds
dir = ci->modelName;
fallback = (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) ? DEFAULT_TEAM_MODEL : DEFAULT_MODEL;
fallback = (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) ? DEFAULT_TEAM_MODEL : DEFAULT_MODEL;
for (i = 0; i < MAX_CUSTOM_SOUNDS; i++) {
s = cg_customSoundNames[i];
@ -981,7 +981,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)
&& (cgs.gametype < GT_TEAM || cgs.ffa_gt == 1 || ci->team == match->team)) {
&& (!(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) || ci->team == match->team)) {
// this clientinfo is identical, so use it's handles
ci->deferred = qfalse;
@ -1017,7 +1017,7 @@ static void CG_SetDeferredClientInfo(int clientNum, clientInfo_t *ci) {
}
if (!Q_strequal(ci->skinName, match->skinName) ||
!Q_strequal(ci->modelName, match->modelName) ||
(cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && ci->team != match->team)) {
(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype) && ci->team != match->team)) {
continue;
}
// just load the real info cause it uses the same models and skins
@ -1026,14 +1026,14 @@ static void CG_SetDeferredClientInfo(int clientNum, clientInfo_t *ci) {
}
// if we are in teamplay, only grab a model if the skin is correct
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
for (i = 0; i < cgs.maxclients; i++) {
match = &cgs.clientinfo[ i ];
if (!match->infoValid || match->deferred) {
continue;
}
if (!Q_strequal(ci->skinName, match->skinName) ||
(cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && ci->team != match->team)) {
(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype) && ci->team != match->team)) {
continue;
}
ci->deferred = qtrue;
@ -1143,7 +1143,7 @@ void CG_NewClientInfo(int clientNum) {
char modelStr[MAX_QPATH];
char *skin;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
Q_strncpyz(newInfo.modelName, DEFAULT_TEAM_MODEL, sizeof ( newInfo.modelName));
Q_strncpyz(newInfo.skinName, "default", sizeof ( newInfo.skinName));
} else {
@ -1158,7 +1158,7 @@ void CG_NewClientInfo(int clientNum) {
Q_strncpyz(newInfo.modelName, modelStr, sizeof ( newInfo.modelName));
}
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
// keep skin name
slash = strchr(v, '/');
if (slash) {
@ -1187,7 +1187,7 @@ void CG_NewClientInfo(int clientNum) {
char modelStr[MAX_QPATH];
char *skin;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
Q_strncpyz(newInfo.headModelName, DEFAULT_TEAM_MODEL, sizeof ( newInfo.headModelName));
Q_strncpyz(newInfo.headSkinName, "default", sizeof ( newInfo.headSkinName));
} else {
@ -1202,7 +1202,7 @@ void CG_NewClientInfo(int clientNum) {
Q_strncpyz(newInfo.headModelName, modelStr, sizeof ( newInfo.headModelName));
}
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
// keep skin name
slash = strchr(v, '/');
if (slash) {
@ -2242,7 +2242,7 @@ static void CG_PlayerSprites(centity_t *cent) {
team = cgs.clientinfo[ cent->currentState.clientNum ].team;
if (!(cent->currentState.eFlags & EF_DEAD) &&
cg.snap->ps.persistant[PERS_TEAM] == team &&
cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
if (cg_drawFriend.integer) {
CG_PlayerFloatSprite(cent, cgs.media.friendShader);
}

View file

@ -432,7 +432,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 ( cgs.gametype < GT_TEAM || cgs.ffa_gt==1) {
if (!(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(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 ) {
@ -465,7 +465,7 @@ void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops ) {
}
// fraglimit warnings
if ( cgs.fraglimit > 0 && cgs.gametype < GT_CTF) {
if (!CG_IsATeamGametype(cgs.gametype)) {
highScore = cgs.scores1;
if (cgs.gametype == GT_TEAM && cgs.scores2 > highScore) {

View file

@ -263,7 +263,7 @@ static void CG_TouchItem( centity_t *cent ) {
//For instantgib
qboolean canBePicked;
if(cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_LMS)
if(CG_IsARoundBasedGametype(cgs.gametype) && !CG_UsesTeamFlags(cgs.gametype))
return; //No weapon pickup in elimination
//normally we can
@ -304,7 +304,7 @@ static void CG_TouchItem( centity_t *cent ) {
}
}
if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_HARVESTER ) {
if((CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) || cgs.gametype == GT_HARVESTER ) {
if (cg.predictedPlayerState.persistant[PERS_TEAM] == TEAM_RED &&
item->giType == IT_TEAM && item->giTag == PW_REDFLAG)
return;

View file

@ -190,8 +190,7 @@ static void CG_DrawClientScore(int y, score_t *score, float *color, float fade,
localClient = qtrue;
if ((cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR) ||
((cgs.gametype >= GT_TEAM) &&
(cgs.ffa_gt != 1))) {
(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype))) {
// Sago: I think this means that it doesn't matter if two players are tied in team game - only team score counts
rank = -1;
} else {
@ -325,7 +324,7 @@ qboolean CG_DrawOldScoreboard(void) {
}
// current rank
if (cgs.gametype < GT_TEAM || cgs.ffa_gt == 1) {
if (!(CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(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),
@ -375,7 +374,7 @@ qboolean CG_DrawOldScoreboard(void) {
localClient = qfalse;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
//
// teamplay scoreboard
//
@ -506,7 +505,7 @@ void CG_DrawOldTourneyScoreboard(void) {
// print the two scores
y = 160;
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
if (CG_IsATeamGametype(cgs.gametype) && CG_UsesKeyObjectives(cgs.gametype)) {
//
// teamplay scoreboard
//

View file

@ -79,7 +79,7 @@ static void CG_ParseScores( void ) {
cgs.roundStartTime = atoi( CG_Argv( 4 ) );
//Update thing in lower-right corner
if(cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION)
if(CG_IsARoundBasedGametype(cgs.gametype) && CG_IsATeamGametype(cgs.gametype))
{
cgs.scores1 = cg.teamScores[0];
cgs.scores2 = cg.teamScores[1];
@ -145,7 +145,7 @@ CG_ParseElimination
=================
*/
static void CG_ParseElimination( void ) {
if(cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION)
if(CG_IsARoundBasedGametype(cgs.gametype) && CG_IsATeamGametype(cgs.gametype))
{
cgs.scores1 = atoi( CG_Argv( 1 ) );
cgs.scores2 = atoi( CG_Argv( 2 ) );
@ -352,12 +352,6 @@ void CG_ParseServerinfo( void ) {
info = CG_ConfigString( CS_SERVERINFO );
cgs.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
//By default do as normal:
cgs.ffa_gt = 0;
//See if ffa gametype
if (cgs.gametype == GT_LMS || cgs.gametype == GT_POSSESSION) {
cgs.ffa_gt = 1;
}
trap_Cvar_Set("g_gametype", va("%i", cgs.gametype));
cgs.dmflags = atoi( Info_ValueForKey( info, "dmflags" ) );
cgs.videoflags = atoi( Info_ValueForKey( info, "videoflags" ) );
@ -406,7 +400,7 @@ static void CG_ParseWarmup( void ) {
} else if ( warmup > 0 && cg.warmup <= 0 ) {
#ifdef MISSIONPACK
if (cgs.gametype >= GT_CTF && cgs.gametype < GT_MAX_GAME_TYPE && !cgs.ffa_gt) {
if (CG_IsATeamGametype(cgs.gametype)) {
trap_S_StartLocalSound( cgs.media.countPrepareTeamSound, CHAN_ANNOUNCER );
} else
#endif
@ -431,13 +425,13 @@ void CG_SetConfigValues( void ) {
cgs.scores1 = atoi( CG_ConfigString( CS_SCORES1 ) );
cgs.scores2 = atoi( CG_ConfigString( CS_SCORES2 ) );
cgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) );
if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_DOUBLE_D) {
if((CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) || cgs.gametype == GT_DOUBLE_D) {
s = CG_ConfigString( CS_FLAGSTATUS );
cgs.redflag = s[0] - '0';
cgs.blueflag = s[1] - '0';
}
//#ifdef MISSIONPACK
else if( cgs.gametype == GT_1FCTF || cgs.gametype == GT_POSSESSION ) {
else if( CG_UsesTheWhiteFlag(cgs.gametype) ) {
s = CG_ConfigString( CS_FLAGSTATUS );
cgs.flagStatus = s[0] - '0';
}
@ -557,16 +551,14 @@ static void CG_ConfigStringModified( void ) {
CG_NewClientInfo( num - CS_PLAYERS );
CG_BuildSpectatorString();
} else if ( num == CS_FLAGSTATUS ) {
if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_DOUBLE_D) {
if((CG_UsesTeamFlags(cgs.gametype) && CG_UsesTheWhiteFlag(cgs.gametype)) || cgs.gametype == GT_DOUBLE_D) {
// format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped
cgs.redflag = str[0] - '0';
cgs.blueflag = str[1] - '0';
}
//#ifdef MISSIONPACK
else if( cgs.gametype == GT_1FCTF || cgs.gametype == GT_POSSESSION ) {
else if( CG_UsesTheWhiteFlag(cgs.gametype) ) {
cgs.flagStatus = str[0] - '0';
}
//#endif
}
else if ( num == CS_SHADERSTATE ) {
CG_ShaderStateChanged();

View file

@ -261,8 +261,7 @@ static void CG_OffsetThirdPersonView( void ) {
VectorCopy( cg.refdefViewAngles, focusAngles );
// if dead, look at killer
if ( (cg.predictedPlayerState.stats[STAT_HEALTH] <= 0) &&
(cgs.gametype !=GT_ELIMINATION && cgs.gametype !=GT_CTF_ELIMINATION && cgs.gametype !=GT_LMS) ) {
if ( (cg.predictedPlayerState.stats[STAT_HEALTH] <= 0) && !CG_IsARoundBasedGametype(cgs.gametype) ) {
focusAngles[YAW] = cg.predictedPlayerState.stats[STAT_DEAD_YAW];
cg.refdefViewAngles[YAW] = cg.predictedPlayerState.stats[STAT_DEAD_YAW];
}
@ -431,7 +430,7 @@ static void CG_OffsetFirstPersonView( void ) {
VectorAdd (angles, cg.kick_angles, angles);
// add angles based on damage kick
if ( cg.damageTime && cgs.gametype!=GT_ELIMINATION && cgs.gametype!=GT_CTF_ELIMINATION && cgs.gametype!=GT_LMS) {
if ( cg.damageTime && !CG_IsARoundBasedGametype(cgs.gametype)) {
ratio = cg.time - cg.damageTime;
if ( ratio < DAMAGE_DEFLECT_TIME ) {
ratio /= DAMAGE_DEFLECT_TIME;

View file

@ -3409,7 +3409,7 @@ void CG_FireWeapon( centity_t *cent )
int c;
weaponInfo_t *weap;
if((cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION) && cgs.roundStartTime>=cg.time)
if(CG_IsARoundBasedGametype(cgs.gametype) && CG_IsATeamGametype(cgs.gametype) && cgs.roundStartTime>=cg.time)
return; //if we havn't started in ELIMINATION then do not fire
ent = &cent->currentState;

View file

@ -936,7 +936,7 @@ void BotMatch_GetFlag(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];
int client;
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
if (!ctf_redflag.areanum || !ctf_blueflag.areanum)
return;
}
@ -968,7 +968,7 @@ void BotMatch_GetFlag(bot_state_t *bs, bot_match_t *match) {
//set the team goal time
bs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;
// get an alternate route in ctf
if (gametype == GT_CTF || gametype == GT_1FCTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype)) {
//get an alternative route goal towards the enemy base
BotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));
}
@ -990,10 +990,10 @@ void BotMatch_AttackEnemyBase(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];
int client;
if (gametype == GT_CTF|| gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
BotMatch_GetFlag(bs, match);
}
else if (gametype == GT_1FCTF || gametype == GT_OBELISK || gametype == GT_HARVESTER) {
else if (gametype == GT_1FCTF || G_UsesTeamObelisks(gametype)) {
if (!redobelisk.areanum || !blueobelisk.areanum)
return;
}
@ -1077,7 +1077,7 @@ void BotMatch_RushBase(bot_state_t *bs, bot_match_t *match) {
char netname[MAX_MESSAGE_SIZE];
int client;
if (gametype == GT_CTF|| gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
if (!ctf_redflag.areanum || !ctf_blueflag.areanum)
return;
}
@ -1171,7 +1171,7 @@ void BotMatch_ReturnFlag(bot_state_t *bs, bot_match_t *match) {
int client;
//if not in CTF mode
if (gametype != GT_CTF && gametype != GT_CTF_ELIMINATION && gametype != GT_1FCTF)
if (G_UsesTeamFlags(gametype))
return;
//if not addressed to this bot
if (!BotAddressedToBot(bs, match))
@ -1678,9 +1678,7 @@ void BotMatch_WhereAreYou(bot_state_t *bs, bot_match_t *match) {
}
}
if (bestitem != -1) {
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION
|| gametype == GT_1FCTF
) {
if (G_UsesTeamFlags(gametype)) {
redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_redflag.areanum, TFL_DEFAULT);
bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, ctf_blueflag.areanum, TFL_DEFAULT);
if (redtt < (redtt + bluett) * 0.4) {
@ -1693,7 +1691,7 @@ void BotMatch_WhereAreYou(bot_state_t *bs, bot_match_t *match) {
BotAI_BotInitialChat(bs, "location", nearbyitems[bestitem], NULL);
}
}
else if (gametype == GT_OBELISK || gametype == GT_HARVESTER) {
else if (G_UsesTeamObelisks(gametype)) {
redtt = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, redobelisk.areanum, TFL_DEFAULT);
bluett = trap_AAS_AreaTravelTimeToGoalArea(bs->areanum, bs->origin, blueobelisk.areanum, TFL_DEFAULT);
if (redtt < (redtt + bluett) * 0.4) {
@ -1831,7 +1829,7 @@ void BotMatch_CTF(bot_state_t *bs, bot_match_t *match) {
char flag[128], netname[MAX_NETNAME];
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
trap_BotMatchVariable(match, FLAG, flag, sizeof(flag));
if (match->subtype & ST_GOTFLAG) {
if (Q_strequal(flag, "red")) {
@ -1863,7 +1861,7 @@ void BotMatch_CTF(bot_state_t *bs, bot_match_t *match) {
bs->flagstatuschanged = 1;
}
}
else if (gametype == GT_1FCTF || gametype == GT_POSSESSION) {
else if (G_UsesTheWhiteFlag(gametype)) {
if (match->subtype & ST_1FCTFGOTFLAG) {
trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
bs->flagcarrier = ClientFromName(netname);

View file

@ -838,7 +838,7 @@ int BotGetLongTermGoal(bot_state_t *bs, int tfl, int retreat, bot_goal_t *goal)
return qtrue;
}
#ifdef CTF
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//if going for enemy flag
if (bs->ltgtype == LTG_GETFLAG) {
//check for bot typing status message
@ -1963,13 +1963,13 @@ int AINode_Seek_LTG(bot_state_t *bs)
else range = 150;
//
#ifdef CTF
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//if carrying a flag the bot shouldn't be distracted too much
if (BotCTFCarryingFlag(bs))
range = 50;
}
#endif //CTF
else if (gametype == GT_1FCTF || GT_POSSESSION) {
else if (G_UsesTheWhiteFlag(gametype)) {
if (Bot1FCTFCarryingFlag(bs))
range = 50;
}
@ -2483,13 +2483,13 @@ int AINode_Battle_Retreat(bot_state_t *bs) {
bs->check_time = FloatTime() + 1;
range = 150;
#ifdef CTF
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//if carrying a flag the bot shouldn't be distracted too much
if (BotCTFCarryingFlag(bs))
range = 50;
}
#endif //CTF
else if (gametype == GT_1FCTF || gametype == GT_POSSESSION) {
else if (G_UsesTheWhiteFlag(gametype)) {
if (Bot1FCTFCarryingFlag(bs))
range = 50;
}

View file

@ -158,7 +158,7 @@ BotCTFCarryingFlag
==================
*/
int BotCTFCarryingFlag(bot_state_t *bs) {
if (gametype != GT_CTF && gametype != GT_CTF_ELIMINATION) return CTF_FLAG_NONE;
if (!G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) return CTF_FLAG_NONE;
if (bs->inventory[INVENTORY_REDFLAG] > 0) return CTF_FLAG_RED;
else if (bs->inventory[INVENTORY_BLUEFLAG] > 0) return CTF_FLAG_BLUE;
@ -341,7 +341,7 @@ Bot1FCTFCarryingFlag
==================
*/
int Bot1FCTFCarryingFlag(bot_state_t *bs) {
if (gametype != GT_1FCTF && gametype != GT_POSSESSION) return qfalse;
if (!G_UsesTheWhiteFlag(gametype)) return qfalse;
if (bs->inventory[INVENTORY_NEUTRALFLAG] > 0) return qtrue;
return qfalse;
@ -392,8 +392,8 @@ void BotSetTeamStatus(bot_state_t *bs) {
break;
case LTG_TEAMACCOMPANY:
BotEntityInfo(bs->teammate, &entinfo);
if (((gametype == GT_CTF || gametype == GT_CTF_ELIMINATION || gametype == GT_1FCTF) && EntityCarriesFlag(&entinfo))
|| (gametype == GT_HARVESTER && EntityCarriesCubes(&entinfo))) {
if ((G_UsesTeamFlags(gametype) && EntityCarriesFlag(&entinfo)) ||
(gametype == GT_HARVESTER && EntityCarriesCubes(&entinfo))) {
teamtask = TEAMTASK_ESCORT;
} else {
teamtask = TEAMTASK_FOLLOW;
@ -454,7 +454,7 @@ BotSetLastOrderedTask
*/
int BotSetLastOrderedTask(bot_state_t *bs) {
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
// don't go back to returning the flag if it's at the base
if (bs->lastgoal_ltgtype == LTG_RETURNFLAG) {
if (BotTeam(bs) == TEAM_RED) {
@ -478,7 +478,7 @@ int BotSetLastOrderedTask(bot_state_t *bs) {
bs->teamgoal_time = FloatTime() + 300;
BotSetTeamStatus(bs);
//
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
if (bs->ltgtype == LTG_GETFLAG) {
bot_goal_t *tb, *eb;
int tt, et;
@ -1414,7 +1414,7 @@ BotTeamGoals
void BotTeamGoals(bot_state_t *bs, int retreat) {
if (retreat) {
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
BotCTFRetreatGoals(bs);
} else if (gametype == GT_1FCTF) {
Bot1FCTFRetreatGoals(bs);
@ -1424,10 +1424,10 @@ void BotTeamGoals(bot_state_t *bs, int retreat) {
BotHarvesterRetreatGoals(bs);
}
} else {
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//decide what to do in CTF mode
BotCTFSeekGoals(bs);
} else if (gametype == GT_1FCTF || gametype == GT_POSSESSION) {
} else if (G_UsesTheWhiteFlag(gametype)) {
Bot1FCTFSeekGoals(bs);
} else if (gametype == GT_OBELISK) {
BotObeliskSeekGoals(bs);
@ -1619,9 +1619,7 @@ int BotSynonymContext(bot_state_t *bs) {
context = CONTEXT_NORMAL | CONTEXT_NEARBYITEM | CONTEXT_NAMES;
//
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION
|| gametype == GT_1FCTF
) {
if (G_UsesTeamFlags(gametype)) {
if (BotTeam(bs) == TEAM_RED) context |= CONTEXT_CTFREDTEAM;
else context |= CONTEXT_CTFBLUETEAM;
} else if (gametype == GT_OBELISK) {
@ -1704,7 +1702,7 @@ BotCheckItemPickup
void BotCheckItemPickup(bot_state_t *bs, int *oldinventory) {
int offence, leader;
if (gametype <= GT_TEAM && g_ffa_gt == 0)
if (!G_UsesKeyObjectives(gametype))
return;
offence = -1;
@ -1745,8 +1743,7 @@ void BotCheckItemPickup(bot_state_t *bs, int *oldinventory) {
if ((bs->ltgtype != LTG_GETFLAG) &&
(bs->ltgtype != LTG_ATTACKENEMYBASE) &&
(bs->ltgtype != LTG_HARVEST) &&
(((gametype != GT_CTF) &&
(gametype != GT_CTF_ELIMINATION)) ||
((!(G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype))) ||
((bs->redflagstatus == 0) &&
(bs->blueflagstatus == 0))) &&
((gametype != GT_1FCTF) ||
@ -1770,8 +1767,7 @@ void BotCheckItemPickup(bot_state_t *bs, int *oldinventory) {
//trap_BotEnterChat(bs->cs, leader, CHAT_TELL);
} else if ((g_spSkill.integer <= 3) &&
(bs->ltgtype != LTG_DEFENDKEYAREA) &&
(((gametype != GT_CTF) &&
(gametype != GT_CTF_ELIMINATION)) ||
((!(G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype))) ||
((bs->redflagstatus == 0) &&
(bs->blueflagstatus == 0))) &&
((gametype != GT_1FCTF) ||
@ -1897,7 +1893,7 @@ void BotUseKamikaze(bot_state_t *bs) {
if (bs->kamikaze_time > FloatTime())
return;
bs->kamikaze_time = FloatTime() + 0.2;
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//never use kamikaze if the team flag carrier is visible
if (BotCTFCarryingFlag(bs))
return;
@ -2003,7 +1999,7 @@ void BotUseInvulnerability(bot_state_t *bs) {
if (bs->invulnerability_time > FloatTime())
return;
bs->invulnerability_time = FloatTime() + 0.2;
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//never use kamikaze if the team flag carrier is visible
if (BotCTFCarryingFlag(bs))
return;
@ -2258,7 +2254,7 @@ TeamPlayIsOn
==================
*/
int TeamPlayIsOn(void) {
return ( gametype >= GT_TEAM && g_ffa_gt != 1);
return (G_IsATeamGametype(gametype) && G_UsesKeyObjectives(gametype));
}
/*
@ -2338,11 +2334,11 @@ BotWantsToRetreat
int BotWantsToRetreat(bot_state_t *bs) {
aas_entityinfo_t entinfo;
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//always retreat when carrying a CTF flag
if (BotCTFCarryingFlag(bs))
return qtrue;
} else if (gametype == GT_1FCTF || gametype == GT_POSSESSION) {
} else if (G_UsesTheWhiteFlag(gametype)) {
//if carrying the flag then always retreat
if (Bot1FCTFCarryingFlag(bs))
return qtrue;
@ -2390,7 +2386,7 @@ BotWantsToChase
int BotWantsToChase(bot_state_t *bs) {
aas_entityinfo_t entinfo;
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//never chase when carrying a CTF flag
if (BotCTFCarryingFlag(bs))
return qfalse;
@ -2460,8 +2456,7 @@ int BotCanAndWantsToRocketJump(bot_state_t *bs) {
//if low on rockets
if (bs->inventory[INVENTORY_ROCKETS] < 3) return qfalse;
//Sago: Special rule - always happy to rocket jump in elimination, eCTF end LMS if
if ((g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_LMS)
&& g_elimination_selfdamage.integer == 0) {
if (G_IsARoundBasedGametype(g_gametype.integer) && g_elimination_selfdamage.integer == 0) {
return qtrue;
}
//never rocket jump with the Quad
@ -2845,7 +2840,7 @@ int BotSameTeam(bot_state_t *bs, int entnum) {
//BotAI_Print(PRT_ERROR, "BotSameTeam: client out of range\n");
return qfalse;
}
if (gametype >= GT_TEAM && g_ffa_gt != 1) {
if (G_IsATeamGametype(gametype) && G_UsesKeyObjectives(gametype)) {
/*Sago: I don't know why they decided to check the configstring instead of the real value.
For some reason bots sometimes gets a wrong config string when chaning gametypes.
Now we check the real value: */
@ -4837,7 +4832,7 @@ void BotCheckEvents(bot_state_t *bs, entityState_t *state) {
bs->enemysuicide = qtrue;
}
//
if (gametype == GT_1FCTF || gametype == GT_POSSESSION) {
if (G_UsesTheWhiteFlag(gametype)) {
//
BotEntityInfo(target, &entinfo);
if (entinfo.powerups & (1 << PW_NEUTRALFLAG)) {
@ -4880,7 +4875,7 @@ void BotCheckEvents(bot_state_t *bs, entityState_t *state) {
}
case EV_GLOBAL_TEAM_SOUND:
{
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
switch (state->eventParm) {
case GTS_RED_CAPTURE:
bs->blueflagstatus = 0;
@ -5139,7 +5134,7 @@ void BotSetupAlternativeRouteGoals(void) {
if (altroutegoals_setup)
return;
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
if (trap_BotGetLevelItemGoal(-1, "Neutral Flag", &ctf_neutralflag) < 0)
BotAI_Print(PRT_WARNING, "No alt routes without Neutral Flag\n");
if (ctf_neutralflag.areanum) {
@ -5413,7 +5408,7 @@ void BotSetupDeathmatchAI(void) {
trap_Cvar_Register(&bot_predictobstacles, "bot_predictobstacles", "1", 0);
trap_Cvar_Register(&g_spSkill, "g_spSkill", "2", 0);
//
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
if (untrap_BotGetLevelItemGoal(-1, "Red Flag", &ctf_redflag) < 0)
BotAI_Print(PRT_WARNING, "CTF without Red Flag\n");
if (untrap_BotGetLevelItemGoal(-1, "Blue Flag", &ctf_blueflag) < 0)

View file

@ -188,7 +188,7 @@ int BotAI_GetEntityState( int entityNum, entityState_t *state ) {
memset( state, 0, sizeof(entityState_t) );
if (!ent->inuse) return qfalse;
if (!ent->r.linked) return qfalse;
if ( !(g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_LMS ||g_instantgib.integer || g_rockets.integer || g_elimination_allgametypes.integer || g_gametype.integer==GT_CTF_ELIMINATION)
if ( !(G_IsARoundBasedGametype(g_gametype.integer) ||g_instantgib.integer || g_rockets.integer || g_elimination_allgametypes.integer)
&& (ent->r.svFlags & SVF_NOCLIENT) ) {
return qfalse;
}
@ -292,7 +292,7 @@ void BotReportStatus(bot_state_t *bs) {
}
strcpy(flagstatus, " ");
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
if (BotCTFCarryingFlag(bs)) {
if (BotTeam(bs) == TEAM_RED) strcpy(flagstatus, S_COLOR_RED"F ");
else strcpy(flagstatus, S_COLOR_BLUE"F ");
@ -454,12 +454,12 @@ void BotSetInfoConfigString(bot_state_t *bs) {
}
strcpy(carrying, " ");
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
if (BotCTFCarryingFlag(bs)) {
strcpy(carrying, "F ");
}
}
else if (gametype == GT_1FCTF || gametype == GT_POSSESSION) {
else if (G_UsesTheWhiteFlag(gametype)) {
if (Bot1FCTFCarryingFlag(bs)) {
strcpy(carrying, "F ");
}
@ -1519,7 +1519,7 @@ int BotAIStartFrame(int time) {
trap_BotLibUpdateEntity(i, NULL);
continue;
}
if ( !(g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_LMS ||g_instantgib.integer || g_rockets.integer || g_elimination_allgametypes.integer || g_gametype.integer==GT_CTF_ELIMINATION)
if ( !(G_IsARoundBasedGametype(g_gametype.integer) ||g_instantgib.integer || g_rockets.integer || g_elimination_allgametypes.integer)
&& ent->r.svFlags & SVF_NOCLIENT) {
trap_BotLibUpdateEntity(i, NULL);
continue;

View file

@ -131,7 +131,7 @@ int BotSortTeamMatesByBaseTravelTime(bot_state_t *bs, int *teammates, int maxtea
int traveltimes[MAX_CLIENTS];
bot_goal_t *goal = NULL;
if (gametype == GT_CTF || gametype == GT_1FCTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype)) {
if (BotTeam(bs) == TEAM_RED)
goal = &ctf_redflag;
else
@ -2112,7 +2112,7 @@ void BotTeamAI(bot_state_t *bs) {
if (bot_nochat.integer>2) return;
//
if ( gametype < GT_TEAM || g_ffa_gt == 1 )
if (!(G_IsATeamGametype(gametype) && G_UsesKeyObjectives(gametype)))
return;
// make sure we've got a valid team leader
if (!BotValidTeamLeader(bs)) {

View file

@ -71,7 +71,7 @@ BotVoiceChat_GetFlag
*/
void BotVoiceChat_GetFlag(bot_state_t *bs, int client, int mode) {
//
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
if (!ctf_redflag.areanum || !ctf_blueflag.areanum)
return;
}
@ -93,7 +93,7 @@ void BotVoiceChat_GetFlag(bot_state_t *bs, int client, int mode) {
//set the team goal time
bs->teamgoal_time = FloatTime() + CTF_GETFLAG_TIME;
// get an alternate route in ctf
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(gametype) && !G_UsesTheWhiteFlag(gametype)) {
//get an alternative route goal towards the enemy base
BotGetAlternateRouteGoal(bs, BotOppositeTeam(bs));
}
@ -112,7 +112,7 @@ BotVoiceChat_Offense
==================
*/
void BotVoiceChat_Offense(bot_state_t *bs, int client, int mode) {
if ( gametype == GT_CTF || gametype == GT_CTF_ELIMINATION || gametype == GT_1FCTF ) {
if (G_UsesTeamFlags(gametype)) {
BotVoiceChat_GetFlag(bs, client, mode);
return;
}
@ -162,7 +162,7 @@ BotVoiceChat_Defend
==================
*/
void BotVoiceChat_Defend(bot_state_t *bs, int client, int mode) {
if ( gametype == GT_OBELISK || gametype == GT_HARVESTER) {
if (G_UsesTeamObelisks(gametype)) {
//
switch(BotTeam(bs)) {
case TEAM_RED: memcpy(&bs->teamgoal, &redobelisk, sizeof(bot_goal_t)); break;
@ -171,7 +171,7 @@ void BotVoiceChat_Defend(bot_state_t *bs, int client, int mode) {
}
}
else
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION || gametype == GT_1FCTF ) {
if (G_UsesTeamFlags(gametype)) {
//
switch(BotTeam(bs)) {
case TEAM_RED: memcpy(&bs->teamgoal, &ctf_redflag, sizeof(bot_goal_t)); break;
@ -368,7 +368,7 @@ BotVoiceChat_ReturnFlag
*/
void BotVoiceChat_ReturnFlag(bot_state_t *bs, int client, int mode) {
//if not in CTF mode
if ( gametype != GT_CTF && gametype != GT_CTF_ELIMINATION && gametype != GT_1FCTF ) {
if (!G_UsesTeamFlags(gametype)) {
return;
}
//

View file

@ -1288,6 +1288,9 @@ qboolean BG_CanItemBeGrabbed(int gametype, const entityState_t *ent, const playe
}
}
}
/* Neon_Knight: For some reason, this doesn't work:
if (G_IsARoundBasedGametype(gametype) && G_IsATeamGametype(gametype)) {
*/
if (gametype == GT_CTF || gametype == GT_CTF_ELIMINATION) {
// ent->modelindex2 is non-zero on items if they are dropped
// we need to know this because we can pick up our dropped flag (and return it)

View file

@ -320,7 +320,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {
client = ent->client;
if ( ( g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) &&
if ( G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer) &&
client->sess.spectatorState != SPECTATOR_FOLLOW &&
g_elimination_lockspectator.integer>1 &&
ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
@ -358,7 +358,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {
}
if ( ( client->buttons & BUTTON_USE_HOLDABLE ) && ! ( client->oldbuttons & BUTTON_USE_HOLDABLE ) ) {
if ( ( g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) &&
if ( G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer) &&
g_elimination_lockspectator.integer>1 &&
ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
return;
@ -452,7 +452,7 @@ static void ClientTimerActions( gentity_t *ent, int msec ) {
if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] ) {
ent->health--;
}
if ( (g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_LMS) && level.humansEliminated ) {
if ( G_IsARoundBasedGametype(g_gametype.integer) && level.humansEliminated ) {
ent->damage=5;
G_Damage (ent, NULL, NULL, NULL, NULL, ent->damage, DAMAGE_NO_KNOCKBACK, MOD_UNKNOWN);
}
@ -1128,9 +1128,7 @@ void ClientThink_real( gentity_t *ent ) {
if ( ( level.time > client->respawnTime ) &&
( ( ( g_forcerespawn.integer > 0 ) &&
( level.time - client->respawnTime > g_forcerespawn.integer * 1000 ) ) ||
( ( ( g_gametype.integer == GT_LMS ) ||
( g_gametype.integer == GT_ELIMINATION ) ||
( g_gametype.integer == GT_CTF_ELIMINATION ) ) &&
( G_IsARoundBasedGametype(g_gametype.integer) &&
( level.time - client->respawnTime > 0 ) ) ||
( ucmd->buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) ) ) ) {

View file

@ -84,7 +84,7 @@ void UpdateTournamentInfo( void ) {
}
#ifdef MISSIONPACK
won = qfalse;
if (g_gametype.integer >= GT_CTF && g_ffa_gt==0) {
if (G_IsATeamGametype(g_gametype.integer)) {
score1 = level.teamScores[TEAM_RED];
score2 = level.teamScores[TEAM_BLUE];
if (level.clients[playerClientNum].sess.sessionTeam == TEAM_RED) {

View file

@ -419,7 +419,7 @@ void G_CheckMinimumPlayers( void ) {
return; //If no AAS then don't even try
}
if (g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
if (minplayers >= g_maxclients.integer / 2) {
minplayers = (g_maxclients.integer / 2) -1;
}
@ -459,7 +459,7 @@ void G_CheckMinimumPlayers( void ) {
}
}
}
else if (g_gametype.integer == GT_FFA || g_ffa_gt == 1) {
else if (g_gametype.integer == GT_FFA) {
if (minplayers >= g_maxclients.integer) {
minplayers = g_maxclients.integer-1;
}
@ -671,7 +671,7 @@ static void G_AddBot( const char *name, float skill, const char *team, int delay
// initialize the bot settings
if( !team || !*team ) {
if( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
if( PickTeam(clientNum) == TEAM_RED) {
team = "red";
}
@ -1030,9 +1030,9 @@ void G_InitBots( qboolean restart ) {
trap_Cvar_Set("bot_minplayers","2"); //Always 2 for Tourney
} else {
basedelay = MinSpawnpointCount()/2;
if(basedelay < 3 && (g_gametype.integer < GT_TEAM || g_ffa_gt) )
if(basedelay < 3 && !(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)))
basedelay = 3; //Minimum 3 for FFA
if(basedelay < 2 && !(g_gametype.integer < GT_TEAM || g_ffa_gt) )
if(basedelay < 2 && !(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)))
basedelay = 2; //Minimum 2 for TEAM
trap_Cvar_Set("bot_minplayers",va("%i",basedelay) );
}

View file

@ -446,7 +446,7 @@ respawn
void ClientRespawn( gentity_t *ent ) {
gentity_t *tent;
if((g_gametype.integer!=GT_ELIMINATION && g_gametype.integer!=GT_CTF_ELIMINATION && g_gametype.integer !=GT_LMS) && !ent->client->isEliminated)
if( !G_IsARoundBasedGametype(g_gametype.integer) && !ent->client->isEliminated)
{
ent->client->isEliminated = qtrue; //must not be true in warmup
} else {
@ -478,14 +478,13 @@ void ClientRespawn( gentity_t *ent ) {
}
}
if((g_gametype.integer==GT_ELIMINATION || g_gametype.integer==GT_CTF_ELIMINATION || g_gametype.integer==GT_LMS)
&& ent->client->ps.pm_type == PM_SPECTATOR && ent->client->ps.stats[STAT_HEALTH] > 0) {
if(G_IsARoundBasedGametype(g_gametype.integer) && ent->client->ps.pm_type == PM_SPECTATOR && ent->client->ps.stats[STAT_HEALTH] > 0) {
return;
}
ClientSpawn(ent);
// add a teleportation effect
if(g_gametype.integer!=GT_ELIMINATION && g_gametype.integer!=GT_CTF_ELIMINATION && g_gametype.integer!=GT_LMS)
if(!G_IsARoundBasedGametype(g_gametype.integer))
{
tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
tent->s.clientNum = ent->s.clientNum;
@ -508,7 +507,7 @@ void respawnRound( gentity_t *ent ) {
ClientSpawn(ent);
// add a teleportation effect
if(g_gametype.integer!=GT_ELIMINATION && g_gametype.integer!=GT_CTF_ELIMINATION && g_gametype.integer!=GT_LMS)
if(!G_IsARoundBasedGametype(g_gametype.integer))
{
tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
tent->s.clientNum = ent->s.clientNum;
@ -1175,7 +1174,7 @@ void ClientUserinfoChanged( int clientNum ) {
if ( ( ( client->sess.sessionTeam == TEAM_SPECTATOR ) ||
( ( ( client->isEliminated ) /*||
( client->ps.pm_type == PM_SPECTATOR )*/ ) && //Sago: If this is true client.isEliminated or TEAM_SPECTATOR is true to and this is redundant
( g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_LMS) ) ) &&
G_IsARoundBasedGametype(g_gametype.integer) ) ) &&
( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) ) {
Q_strncpyz( client->pers.netname, "scoreboard", sizeof(client->pers.netname) );
@ -1201,7 +1200,7 @@ void ClientUserinfoChanged( int clientNum ) {
client->ps.stats[STAT_MAX_HEALTH] = client->pers.maxHealth;
// set model
if( g_gametype.integer >= GT_TEAM && g_ffa_gt==0) {
if(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
Q_strncpyz( model, Info_ValueForKey (userinfo, "team_model"), sizeof( model ) );
Q_strncpyz( headModel, Info_ValueForKey (userinfo, "team_headmodel"), sizeof( headModel ) );
} else {
@ -1210,7 +1209,7 @@ void ClientUserinfoChanged( int clientNum ) {
}
// bots set their team a few frames later
if (g_gametype.integer >= GT_TEAM && g_ffa_gt==0 && g_entities[clientNum].r.svFlags & SVF_BOT) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer) && g_entities[clientNum].r.svFlags & SVF_BOT) {
s = Info_ValueForKey( userinfo, "team" );
if ( Q_strequal( s, "red" ) || Q_strequal( s, "r" ) ) {
team = TEAM_RED;
@ -1226,7 +1225,7 @@ void ClientUserinfoChanged( int clientNum ) {
team = client->sess.sessionTeam;
}
if (g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
client->pers.teamInfo = qtrue;
} else {
s = Info_ValueForKey( userinfo, "teamoverlay" );
@ -1243,7 +1242,7 @@ void ClientUserinfoChanged( int clientNum ) {
teamLeader = client->sess.teamLeader;
// colors
if( g_gametype.integer >= GT_TEAM && g_ffa_gt==0 && g_instantgib.integer) {
if(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer) && g_instantgib.integer) {
switch(team) {
case TEAM_RED:
c1[0] = COLOR_BLUE;
@ -1410,8 +1409,7 @@ char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {
trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " connected\n\"", client->pers.netname) );
}
if ( g_gametype.integer >= GT_TEAM &&
client->sess.sessionTeam != TEAM_SPECTATOR ) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer) && client->sess.sessionTeam != TEAM_SPECTATOR ) {
BroadcastTeamChange( client, -1 );
}
@ -1524,7 +1522,7 @@ void ClientBegin( int clientNum ) {
countFree = TeamCount(-1,TEAM_FREE);
countRed = TeamCount(-1,TEAM_RED);
countBlue = TeamCount(-1,TEAM_BLUE);
if(g_gametype.integer < GT_TEAM || g_ffa_gt)
if(!(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)))
{
if(countFree>level.teamSize)
level.teamSize=countFree;
@ -1559,9 +1557,7 @@ void ClientBegin( int clientNum ) {
if( ( client->sess.sessionTeam != TEAM_SPECTATOR ) &&
( ( !( client->isEliminated ) /*&&
( ( !client->ps.pm_type ) == PM_SPECTATOR ) */ ) || //Sago: Yes, it made no sense
( ( g_gametype.integer != GT_ELIMINATION || level.intermissiontime) &&
( g_gametype.integer != GT_CTF_ELIMINATION || level.intermissiontime) &&
( g_gametype.integer != GT_LMS || level.intermissiontime ) ) ) ) {
( (!G_IsARoundBasedGametype(g_gametype.integer) || level.intermissiontime) ) ) ) {
// send event
tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
tent->s.clientNum = ent->s.clientNum;
@ -1625,15 +1621,7 @@ void ClientSpawn(gentity_t *ent) {
//In Elimination the player should not spawn if he have already spawned in the round (but not for spectators)
// N_G: You've obviously wanted something ELSE
//Sago: Yes, the !level.intermissiontime is currently redundant but it might still be the bast place to make the test, CheckElimination in g_main makes sure the next if will fail and the rest of the things this block does might not affect if in Intermission (I'll just test that)
if(
(
(
g_gametype.integer == GT_ELIMINATION ||
g_gametype.integer == GT_CTF_ELIMINATION || (g_gametype.integer == GT_LMS && client->isEliminated)) &&
(!level.intermissiontime || level.warmupTime != 0)
) &&
( client->sess.sessionTeam != TEAM_SPECTATOR )
)
if((((G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer)) || (g_gametype.integer == GT_LMS && client->isEliminated)) && (!level.intermissiontime || level.warmupTime != 0)) && ( client->sess.sessionTeam != TEAM_SPECTATOR))
{
// N_G: Another condition that makes no sense to me, see for
// yourself if you really meant this
@ -1694,8 +1682,8 @@ void ClientSpawn(gentity_t *ent) {
// find a spawn point
// do it before setting health back up, so farthest
// ranging doesn't count this client
if ((client->sess.sessionTeam == TEAM_SPECTATOR)
|| ( (client->ps.pm_type == PM_SPECTATOR || client->isEliminated ) && (g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) ) ) {
if ((client->sess.sessionTeam == TEAM_SPECTATOR) || ((client->ps.pm_type == PM_SPECTATOR || client->isEliminated ) &&
(G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer)))) {
spawnPoint = SelectSpectatorSpawnPoint ( spawn_origin, spawn_angles);
} else if (g_gametype.integer == GT_DOUBLE_D) {
//Double Domination uses special spawn points:
@ -1703,7 +1691,7 @@ void ClientSpawn(gentity_t *ent) {
} else if (g_gametype.integer == GT_DOMINATION) {
//Domination uses special spawn points:
spawnPoint = SelectDominationSpawnPoint (client->sess.sessionTeam, spawn_origin, spawn_angles);
} else if (g_gametype.integer >= GT_CTF && g_ffa_gt==0 ) {
} else if (G_IsATeamGametype(g_gametype.integer)) {
// all base oriented team games use the CTF spawn points
spawnPoint = SelectCTFSpawnPoint (
client->sess.sessionTeam,
@ -1810,7 +1798,7 @@ void ClientSpawn(gentity_t *ent) {
client->ps.clientNum = index;
if(g_gametype.integer != GT_ELIMINATION && g_gametype.integer != GT_CTF_ELIMINATION && g_gametype.integer != GT_LMS && !g_elimination_allgametypes.integer)
if(!G_IsARoundBasedGametype(g_gametype.integer) && !g_elimination_allgametypes.integer)
{
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MACHINEGUN );
if ( g_gametype.integer == GT_TEAM ) {
@ -1906,14 +1894,15 @@ void ClientSpawn(gentity_t *ent) {
// the respawned flag will be cleared after the attack and jump keys come up
client->ps.pm_flags |= PMF_RESPAWNED;
if(g_gametype.integer==GT_ELIMINATION || g_gametype.integer==GT_CTF_ELIMINATION || g_gametype.integer==GT_LMS)
if(G_IsARoundBasedGametype(g_gametype.integer)) {
client->ps.pm_flags |= PMF_ELIMWARMUP;
}
trap_GetUsercmd( client - level.clients, &ent->client->pers.cmd );
SetClientViewAngle( ent, spawn_angles );
if ( (ent->client->sess.sessionTeam == TEAM_SPECTATOR) || ((client->ps.pm_type == PM_SPECTATOR || client->isEliminated) &&
(g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_LMS) ) ) {
G_IsARoundBasedGametype(g_gametype.integer))) {
} else {
G_KillBox( ent );
trap_LinkEntity (ent);
@ -1960,8 +1949,8 @@ void ClientSpawn(gentity_t *ent) {
ClientThink( ent-g_entities );
// positively link the client, even if the command times are weird
if ( (ent->client->sess.sessionTeam != TEAM_SPECTATOR) || ( (!client->isEliminated || client->ps.pm_type != PM_SPECTATOR)&&
(g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_LMS) ) ) {
if ( (ent->client->sess.sessionTeam != TEAM_SPECTATOR) || ( (!client->isEliminated || client->ps.pm_type != PM_SPECTATOR) &&
G_IsARoundBasedGametype(g_gametype.integer) ) ) {
BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );
VectorCopy( ent->client->ps.origin, ent->r.currentOrigin );
trap_LinkEntity( ent );

View file

@ -776,7 +776,7 @@ void SetTeam( gentity_t *ent, char *s ) {
team = TEAM_SPECTATOR;
specState = SPECTATOR_FREE;
}
else if ( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
else if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
// if running a team game, assign player to one of the teams
specState = SPECTATOR_NOT;
if ( Q_strequal( s, "red" ) || Q_strequal( s, "r" ) ) {
@ -919,7 +919,7 @@ to free floating spectator mode
=================
*/
void StopFollowing( gentity_t *ent ) {
if(g_gametype.integer<GT_ELIMINATION || g_gametype.integer>GT_LMS)
if(!G_IsARoundBasedGametype(g_gametype.integer))
{
//Shouldn't this already be the case?
ent->client->ps.persistant[ PERS_TEAM ] = TEAM_SPECTATOR;
@ -1022,7 +1022,7 @@ void Cmd_Follow_f( gentity_t *ent ) {
return;
}
if ( (g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) && g_elimination_lockspectator.integer
if ( G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer) && g_elimination_lockspectator.integer
&& ((ent->client->sess.sessionTeam == TEAM_RED && level.clients[ i ].sess.sessionTeam == TEAM_BLUE) ||
(ent->client->sess.sessionTeam == TEAM_BLUE && level.clients[ i ].sess.sessionTeam == TEAM_RED) ) ) {
return;
@ -1124,7 +1124,7 @@ void Cmd_FollowCycle_f( gentity_t *ent ) {
}
//Stop players from spectating players on the enemy team in elimination modes.
if ( (g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) && g_elimination_lockspectator.integer
if ( (G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer)) && g_elimination_lockspectator.integer
&& ((ent->client->sess.sessionTeam == TEAM_RED && level.clients[ clientnum ].sess.sessionTeam == TEAM_BLUE) ||
(ent->client->sess.sessionTeam == TEAM_BLUE && level.clients[ clientnum ].sess.sessionTeam == TEAM_RED) ) ) {
continue;
@ -1190,7 +1190,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
if ((ent->r.svFlags & SVF_BOT) && trap_Cvar_VariableValue( "bot_nochat" )>1) return;
if ( (g_gametype.integer < GT_TEAM || g_ffa_gt == 1) && mode == SAY_TEAM ) {
if ( !(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) && mode == SAY_TEAM ) {
mode = SAY_ALL;
}
@ -1212,7 +1212,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
color = COLOR_CYAN;
break;
case SAY_TELL:
if (target && target->inuse && target->client && g_gametype.integer >= GT_TEAM && g_ffa_gt != 1 &&
if (target && target->inuse && target->client && G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer) &&
target->client->sess.sessionTeam == ent->client->sess.sessionTeam &&
Team_GetLocationMsg(ent, location, sizeof(location)))
Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"] (%s)"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
@ -1350,7 +1350,7 @@ void G_Voice( gentity_t *ent, gentity_t *target, int mode, const char *id, qbool
int j;
gentity_t *other;
if ( (g_gametype.integer < GT_TEAM || g_ffa_gt==1 ) && mode == SAY_TEAM ) {
if ( !(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) && mode == SAY_TEAM ) {
mode = SAY_ALL;
}
@ -1510,7 +1510,7 @@ static void Cmd_VoiceTaunt_f( gentity_t *ent ) {
}
}
if (g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
// praise a team mate who just got a reward
for(i = 0; i < MAX_CLIENTS; i++) {
who = g_entities + i;
@ -1875,7 +1875,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_gametype.integer<GT_TEAM || g_ffa_gt==1) { //Not a team game
if(!G_IsATeamGametype(g_gametype.integer)) { //Not a team game
trap_SendServerCommand( ent-g_entities, "print \"Can only be used in team games.\n\"" );
return;
}

View file

@ -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_gametype.integer<GT_TEAM || g_ffa_gt==1)) {
if( level.numNonSpectatorClients<3 && score < 0 && !G_IsATeamGametype(g_gametype.integer)) {
for ( i = 0 ; i < level.maxclients ; i++ ) {
if ( level.clients[ i ].pers.connected != CON_CONNECTED )
continue; //Client was not connected
@ -117,7 +117,7 @@ void TossClientItems( gentity_t *self )
weapon = self->s.weapon;
//Never drop in elimination or last man standing mode!
if( g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_LMS)
if(G_IsARoundBasedGametype(g_gametype.integer) && !G_UsesTeamFlags(g_gametype.integer))
return;
// make a special check to see if they are changing to a new
@ -406,7 +406,7 @@ void CheckAlmostCapture( gentity_t *self, gentity_t *attacker )
self->client->ps.powerups[PW_BLUEFLAG] ||
self->client->ps.powerups[PW_NEUTRALFLAG] ) {
// get the goal flag this player should have been going for
if ( g_gametype.integer == GT_CTF || g_gametype.integer == GT_CTF_ELIMINATION) {
if (G_UsesTeamFlags(g_gametype.integer) && !G_UsesTheWhiteFlag(g_gametype.integer)) {
if ( self->client->sess.sessionTeam == TEAM_BLUE ) {
classname = "team_CTF_blueflag";
}
@ -559,7 +559,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
ent->s.otherEntityNum2 = killer;
//Sago: Hmmm... generic? Can I transmit anything I like? Like if it is a team kill? Let's try
ent->s.generic1 = OnSameTeam (self, attacker);
if( !((g_gametype.integer==GT_ELIMINATION || g_gametype.integer==GT_CTF_ELIMINATION) && level.time < level.roundStartTime) ) {
if( !((G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer)) && level.time < level.roundStartTime) ) {
ent->r.svFlags = SVF_BROADCAST; // send to everyone (if not an elimination gametype during active warmup)
}
else {
@ -574,8 +574,8 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
attacker->client->lastkilled_client = self->s.number;
if ( attacker == self || OnSameTeam (self, attacker ) ) {
if(g_gametype.integer!=GT_LMS && g_gametype.integer != GT_POSSESSION && !((g_gametype.integer==GT_ELIMINATION || g_gametype.integer==GT_CTF_ELIMINATION) && level.time < level.roundStartTime)) {
if( (g_gametype.integer <GT_TEAM && g_ffa_gt!=1 && self->client->ps.persistant[PERS_SCORE]>0) || level.numNonSpectatorClients<3) {
if(g_gametype.integer != GT_POSSESSION && !G_IsARoundBasedGametype(g_gametype.integer) && level.time < level.roundStartTime) {
if( (G_IsATeamGametype(g_gametype.integer) && self->client->ps.persistant[PERS_SCORE]>0) || level.numNonSpectatorClients<3) {
//Cannot get negative scores by suicide
AddScore( attacker, self->r.currentOrigin, -1 );
}
@ -754,8 +754,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
}
}
else {
if(g_gametype.integer!=GT_LMS && g_gametype.integer != GT_POSSESSION &&
!((g_gametype.integer==GT_ELIMINATION || g_gametype.integer==GT_CTF_ELIMINATION) && level.time < level.roundStartTime)) {
if(g_gametype.integer != GT_POSSESSION && !G_IsARoundBasedGametype(g_gametype.integer) && level.time < level.roundStartTime) {
if(self->client->ps.persistant[PERS_SCORE]>0 || level.numNonSpectatorClients<3) {
//Cannot get negative scores by suicide
AddScore( self, self->r.currentOrigin, -1 );
@ -832,7 +831,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
self->client->respawnTime = i*g_respawntime.integer*1000;
}
//However during warm up, we should respawn quicker!
if(g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_LMS) {
if(G_IsARoundBasedGametype(g_gametype.integer)) {
if(level.time<=level.roundStartTime && level.time>level.roundStartTime-1000*g_elimination_activewarmup.integer) {
self->client->respawnTime = level.time + rand()%800;
}
@ -1186,7 +1185,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
// if TF_NO_FRIENDLY_FIRE is set, don't do damage to the target
// if the attacker was on the same team
if ( mod != MOD_JUICED && mod != MOD_CRUSH && targ != attacker && !(dflags & DAMAGE_NO_TEAM_PROTECTION) && OnSameTeam (targ, attacker) ) {
if ( ( !g_friendlyFire.integer && g_gametype.integer != GT_ELIMINATION && g_gametype.integer != GT_CTF_ELIMINATION ) || ( g_elimination_selfdamage.integer<2 && (g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) ) ) {
if ( ( !g_friendlyFire.integer && !(G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer)) ) || ( g_elimination_selfdamage.integer<2 && G_IsARoundBasedGametype(g_gametype.integer) ) ) {
return;
}
}
@ -1262,14 +1261,14 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
damage = 0;
}
if ((g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_LMS || g_elimination_allgametypes.integer)
&& g_elimination_selfdamage.integer<1 && ( targ == attacker || mod == MOD_FALLING )) {
if ((G_IsARoundBasedGametype(g_gametype.integer) || g_elimination_allgametypes.integer) &&
g_elimination_selfdamage.integer<1 && ( targ == attacker || mod == MOD_FALLING )) {
damage = 0;
}
//So people can be telefragged!
if ((g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_LMS) && level.time < level.roundStartTime && ((mod == MOD_LAVA) || (mod == MOD_SLIME)) ) {
if (G_IsARoundBasedGametype(g_gametype.integer) && level.time < level.roundStartTime && ((mod == MOD_LAVA) || (mod == MOD_SLIME)) ) {
damage = 1000;
}
@ -1313,7 +1312,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
}
// See if it's the player hurting the emeny flag carrier
if( g_gametype.integer == GT_CTF || g_gametype.integer == GT_1FCTF || g_gametype.integer == GT_CTF_ELIMINATION) {
if(G_UsesTeamFlags(g_gametype.integer)) {
Team_CheckHurtCarrier(targ, attacker);
}

View file

@ -188,8 +188,7 @@ void CheckElimination(void) {
int countHumans;
if ( level.numPlayingClients < 1 ) {
if( (g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) &&
( level.time+1000*g_elimination_warmup.integer-500>level.roundStartTime )) {
if( G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer) && ( level.time+1000*g_elimination_warmup.integer-500>level.roundStartTime )) {
RestartEliminationRound(); //For spectators
}
return;
@ -204,7 +203,7 @@ void CheckElimination(void) {
return;
}
if(g_gametype.integer != GT_ELIMINATION && g_gametype.integer != GT_CTF_ELIMINATION) {
if(!(G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer))) {
return;
}

View file

@ -88,7 +88,7 @@ int Pickup_Powerup( gentity_t *ent, gentity_t *other )
// if same team in team game, no sound
// cannot use OnSameTeam as it expects to g_entities, not clients
if ( g_gametype.integer >= GT_TEAM && g_ffa_gt==0 && other->client->sess.sessionTeam == client->sess.sessionTeam ) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer) && other->client->sess.sessionTeam == client->sess.sessionTeam ) {
continue;
}
@ -444,7 +444,7 @@ void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace)
(other->client->sess.sessionTeam==TEAM_RED && (level.eliminationSides+level.roundNumber)%2 != 0 ) ))
return;
if (g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_LMS)
if (G_IsARoundBasedGametype(g_gametype.integer) && !G_UsesTeamFlags(g_gametype.integer))
return; //nothing to pick up in elimination
if (!other->client)
@ -631,8 +631,7 @@ gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity )
VectorCopy( velocity, dropped->s.pos.trDelta );
dropped->s.eFlags |= EF_BOUNCE_HALF;
if ((g_gametype.integer == GT_CTF || g_gametype.integer == GT_1FCTF ||
g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_DOUBLE_D || g_gametype.integer == GT_POSSESSION)
if ((G_UsesTeamFlags(g_gametype.integer) || G_UsesTheWhiteFlag(g_gametype.integer) || g_gametype.integer == GT_DOUBLE_D)
&& item->giType == IT_TEAM) { // Special case for CTF flags
dropped->think = Team_DroppedFlagThink;
dropped->nextthink = level.time + 30000;
@ -742,8 +741,7 @@ void FinishSpawningItem( gentity_t *ent )
// powerups don't spawn in for a while (but not in elimination)
if(g_gametype.integer != GT_ELIMINATION && g_gametype.integer != GT_CTF_ELIMINATION && g_gametype.integer != GT_LMS
&& !g_instantgib.integer && !g_elimination_allgametypes.integer && !g_rockets.integer )
if(!G_IsARoundBasedGametype(g_gametype.integer) && !g_instantgib.integer && !g_elimination_allgametypes.integer && !g_rockets.integer )
if ( ent->item->giType == IT_POWERUP ) {
float respawn;
@ -773,7 +771,7 @@ void G_CheckTeamItems( void )
// Set up team stuff
Team_InitGame();
if( g_gametype.integer == GT_CTF || g_gametype.integer == GT_CTF_ELIMINATION || g_gametype.integer == GT_DOUBLE_D) {
if( (G_UsesTeamFlags(g_gametype.integer) && !G_UsesTheWhiteFlag(g_gametype.integer)) || g_gametype.integer == GT_DOUBLE_D) {
gitem_t *item;
// check for the two flags
@ -869,8 +867,7 @@ void ClearRegisteredItems( void )
// players always start with the base weapon
RegisterItem( BG_FindItemForWeapon( WP_MACHINEGUN ) );
RegisterItem( BG_FindItemForWeapon( WP_GAUNTLET ) );
if(g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION
|| g_gametype.integer == GT_LMS || g_elimination_allgametypes.integer) {
if(G_IsARoundBasedGametype(g_gametype.integer) || g_elimination_allgametypes.integer) {
RegisterItem( BG_FindItemForWeapon( WP_SHOTGUN ) );
RegisterItem( BG_FindItemForWeapon( WP_GRENADE_LAUNCHER ) );
RegisterItem( BG_FindItemForWeapon( WP_ROCKET_LAUNCHER ) );
@ -997,7 +994,7 @@ void G_SpawnItem (gentity_t *ent, gitem_t *item)
ent->physicsBounce = 0.50; // items are bouncy
if (g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_LMS ||
if ((G_IsARoundBasedGametype(g_gametype.integer) && !G_UsesTeamFlags(g_gametype.integer)) ||
( item->giType != IT_TEAM && (g_instantgib.integer || g_rockets.integer || g_elimination_allgametypes.integer || g_gametype.integer==GT_CTF_ELIMINATION) ) ) {
ent->s.eFlags |= EF_NODRAW; //Invisible in elimination
ent->r.svFlags |= SVF_NOCLIENT; //Don't broadcast
@ -1008,7 +1005,7 @@ void G_SpawnItem (gentity_t *ent, gitem_t *item)
ent->s.eFlags |= EF_NODRAW; //Don't draw the flag models/persistant powerups
}
if( g_gametype.integer != GT_1FCTF && g_gametype.integer != GT_POSSESSION && strequals(ent->classname, "team_CTF_neutralflag")) {
if( !G_UsesTheWhiteFlag(g_gametype.integer) && strequals(ent->classname, "team_CTF_neutralflag")) {
ent->s.eFlags |= EF_NODRAW; // Don't draw the flag in CTF_elimination
}

View file

@ -288,7 +288,7 @@ void G_RunStreakLogic( gentity_t *attacker, gentity_t *victim )
&& ( attacker != victim ) ) {
//Check the gametype--If FFA enabled, everybody's on the same team.
if( g_gametype.integer >= GT_TEAM && g_ffa_gt!= 1 ) {
if(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
//If they are on the same team we don't want to count it towards a killing spree.
if( OnSameTeam( victim, attacker ) ) {
return;

View file

@ -1126,8 +1126,6 @@ extern vmCvar_t g_vampire;
extern vmCvar_t g_vampireMaxHealth;
//new in elimination Beta3
extern vmCvar_t g_regen;
//Free for all gametype
extern int g_ffa_gt; //0 = TEAM GAME, 1 = FFA, 2 = TEAM GAME without bases
extern vmCvar_t g_lms_lives;
@ -1439,4 +1437,12 @@ void MapInfoPrint(mapinfo_result_t *info);
void monster_die (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
/* 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_UsesKeyObjectives(int check); /* Whether the gametype uses key objectives 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. */
qboolean G_UsesTeamObelisks(int check); /* Whether the gametype uses team obelisks. */
qboolean G_UsesControlPoints(int check); /* Whether the gametype uses control points. */
/* /Neon_Knight */

View file

@ -140,7 +140,6 @@ vmCvar_t g_vampire;
vmCvar_t g_vampireMaxHealth;
//Regen
vmCvar_t g_regen;
int g_ffa_gt; //Are this a FFA gametype even if gametype is high?
vmCvar_t g_lms_lives;
vmCvar_t g_lms_mode;
vmCvar_t g_elimination_ctf_oneway;
@ -600,14 +599,6 @@ void G_RegisterCvars( void )
trap_Cvar_Set( "g_gametype", "0" );
}
//set FFA status for high gametypes:
if ( g_gametype.integer == GT_LMS || g_gametype.integer == GT_POSSESSION ) {
g_ffa_gt = 1; //Last Man standig is a FFA gametype
}
else {
g_ffa_gt = 0; //If >GT_CTF use bases
}
level.warmupModificationCount = g_warmup.modificationCount;
}
@ -857,7 +848,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
// make sure we have flags for CTF, etc
if ( g_gametype.integer == GT_POSSESSION ||
(g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) ) {
(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer))) {
G_CheckTeamItems();
}
@ -1206,7 +1197,7 @@ int QDECL SortRanks( const void *a, const void *b )
}
//In elimination and CTF elimination, sort dead players last
if((g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION)
if(G_UsesTeamFlags(g_gametype.integer) && !G_UsesTheWhiteFlag(g_gametype.integer)
&& level.roundNumber==level.roundNumberStarted && (ca->isEliminated != cb->isEliminated)) {
if( ca->isEliminated )
return 1;
@ -1289,7 +1280,7 @@ void CalculateRanks( void )
sizeof(level.sortedClients[0]), SortRanks );
// set the rank value for all clients that are connected and not spectators
if ( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
// in team games, rank is just the order of the teams, 0=red, 1=blue, 2=tied
for ( i = 0; i < level.numConnectedClients; i++ ) {
cl = &level.clients[ level.sortedClients[i] ];
@ -1328,7 +1319,7 @@ void CalculateRanks( void )
}
// set the CS_SCORES1/2 configstrings, which will be visible to everyone
if ( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
trap_SetConfigstring( CS_SCORES1, va("%i", level.teamScores[TEAM_RED] ) );
trap_SetConfigstring( CS_SCORES2, va("%i", level.teamScores[TEAM_BLUE] ) );
}
@ -1452,7 +1443,7 @@ static void SendVictoryChallenge( void )
default:
return;
};
if ( g_gametype.integer!=GT_FFA && g_gametype.integer!=GT_TOURNAMENT && g_gametype.integer!=GT_LMS && g_gametype.integer!=GT_POSSESSION ) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
//Team games
for ( i = 0 ; i < level.maxclients ; i++ ) {
cl = &level.clients[i];
@ -1858,7 +1849,7 @@ void LogExit( const char *string )
numSorted = 32;
}
if ( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
G_LogPrintf( "red:%i blue:%i\n",
level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE] );
}
@ -1890,7 +1881,7 @@ void LogExit( const char *string )
#ifdef MISSIONPACK
if (g_singlePlayer.integer) {
if (g_gametype.integer >= GT_CTF && g_ffa_gt==0) {
if (G_IsATeamGametype(g_gametype.integer)) {
won = level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE];
}
trap_SendConsoleCommand( EXEC_APPEND, (won) ? "spWin\n" : "spLose\n" );
@ -2014,7 +2005,7 @@ qboolean ScoreIsTied( void )
level.teamScores[TEAM_RED] == level.teamScores[TEAM_BLUE]-1);
}
if ( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
return level.teamScores[TEAM_RED] == level.teamScores[TEAM_BLUE];
}
@ -2088,7 +2079,7 @@ void CheckExitRules( void )
return;
}
if ( (g_gametype.integer < GT_CTF || g_ffa_gt>0 ) && g_fraglimit.integer ) {
if (!G_IsATeamGametype(g_gametype.integer) && g_fraglimit.integer ) {
if ( level.teamScores[TEAM_RED] >= g_fraglimit.integer ) {
trap_SendServerCommand( -1, "print \"Red hit the fraglimit.\n\"" );
LogExit( "Fraglimit hit." );
@ -2119,7 +2110,7 @@ void CheckExitRules( void )
}
}
if ( (g_gametype.integer >= GT_CTF && g_ffa_gt<1) && g_capturelimit.integer ) {
if ( G_IsATeamGametype(g_gametype.integer) && g_capturelimit.integer ) {
if ( level.teamScores[TEAM_RED] >= g_capturelimit.integer ) {
trap_SendServerCommand( -1, "print \"Red hit the capturelimit.\n\"" );
@ -2325,7 +2316,7 @@ void CheckTournament( void )
int counts[TEAM_NUM_TEAMS];
qboolean notEnough = qfalse;
if ( g_gametype.integer > GT_TEAM && !g_ffa_gt ) {
if(!G_IsATeamGametype(g_gametype.integer)) {
counts[TEAM_BLUE] = TeamCount( -1, TEAM_BLUE );
counts[TEAM_RED] = TeamCount( -1, TEAM_RED );
@ -2601,7 +2592,7 @@ void G_RunFrame( int levelTime )
// get any cvar changes
G_UpdateCvars();
if( (g_gametype.integer==GT_ELIMINATION || g_gametype.integer==GT_CTF_ELIMINATION) && !(g_elimflags.integer & EF_NO_FREESPEC) && g_elimination_lockspectator.integer>1)
if( (G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer)) && !(g_elimflags.integer & EF_NO_FREESPEC) && g_elimination_lockspectator.integer>1)
trap_Cvar_Set("elimflags",va("%i",g_elimflags.integer|EF_NO_FREESPEC));
else if( (g_elimflags.integer & EF_NO_FREESPEC) && g_elimination_lockspectator.integer<2)
trap_Cvar_Set("elimflags",va("%i",g_elimflags.integer&(~EF_NO_FREESPEC) ) );
@ -2784,3 +2775,111 @@ void MapInfoPrint(mapinfo_result_t *info)
G_Printf("Capturelimit: %i\n",info->captureLimit);
G_Printf("minTeamSize: %i\n",info->minTeamSize);
}
/* Neon_Knight: Useful check in order to have code consistency. */
/*
===================
G_IsATeamGametype
Checks if the gametype is a team-based game.
===================
*/
qboolean G_IsATeamGametype(int check) {
if (check != GT_FFA && check != GT_TOURNAMENT && check != GT_SINGLE_PLAYER && check != GT_LMS && check != GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
G_UsesKeyObjectives
Checks if the gametype makes use of gametype-specific objectives.
===================
*/
qboolean G_UsesKeyObjectives(int check) {
if (check != GT_FFA && check != GT_TOURNAMENT && check != GT_SINGLE_PLAYER && check != GT_TEAM && check != GT_LMS && check != GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
G_UsesTeamFlags
Checks if the gametype makes use of the red and blue flags.
===================
*/
qboolean G_UsesTeamFlags(int check) {
if (check == GT_CTF || check == GT_1FCTF || check == GT_CTF_ELIMINATION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
G_UsesTheWhiteFlag
Checks if the gametype makes use of the neutral flag.
===================
*/
qboolean G_UsesTheWhiteFlag(int check) {
if (check == GT_1FCTF || check == GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
G_IsARoundBasedGametype
Checks if the gametype has a round-based system.
===================
*/
qboolean G_IsARoundBasedGametype(int check) {
if (check == GT_ELIMINATION || check == GT_CTF_ELIMINATION || check == GT_LMS) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
G_UsesTeamObelisks
Checks if the gametype uses team-colored obelisks.
===================
*/
qboolean G_UsesTeamObelisks(int check) {
if (check == GT_HARVESTER || check == GT_OBELISK) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
G_UsesControlPoints
Checks if the gametype uses team-colored obelisks.
===================
*/
qboolean G_UsesControlPoints(int check) {
if (check == GT_DOUBLE_D || check == GT_DOMINATION) {
return qtrue;
}
else {
return qfalse;
}
}
/* /Neon_Knight */

View file

@ -569,7 +569,7 @@ static int countCtfSpawnpoints(void) {
}
int MinSpawnpointCount(void) {
if(g_gametype.integer < GT_CTF || g_ffa_gt > 0) {
if(!G_IsATeamGametype(g_gametype.integer)) {
return countFfaSpawnpoints();
}
if(g_gametype.integer == GT_DOUBLE_D ) {

View file

@ -142,7 +142,7 @@ void ProximityMine_Trigger( gentity_t *trigger, gentity_t *other, trace_t *trace
}
if ( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
// don't trigger same team mines
if (trigger->parent->s.generic1 == other->client->sess.sessionTeam) {
return;
@ -189,11 +189,11 @@ static void ProximityMine_Activate( gentity_t *ent )
c = NULL;
}
if (g_gametype.integer == GT_TEAM || g_gametype.integer == GT_DOMINATION || g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_DOUBLE_D) {
if (g_gametype.integer == GT_TEAM || g_gametype.integer == GT_ELIMINATION || G_UsesControlPoints(g_gametype.integer)) {
c = NULL;
}
if (g_gametype.integer == GT_OBELISK || g_gametype.integer == GT_HARVESTER) {
if (G_UsesTeamObelisks(g_gametype.integer)) {
switch (ent->s.generic1) {
case TEAM_RED:
c = "team_redobelisk";

View file

@ -1004,7 +1004,7 @@ void SP_func_door (gentity_t *ent)
ent->wait = 99999999;
if ( g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) {
if (G_IsARoundBasedGametype(g_gametype.integer) && G_IsATeamGametype(g_gametype.integer)) {
char* value;
//Classic part to make the
if ( strequals(ent->targetname, ELIMINATION_ACTIVE_TARGETNAME ) ) {

View file

@ -105,7 +105,7 @@ void G_RankRunFrame()
break;
case QGR_STATUS_ACTIVE:
if( (ent->client->sess.sessionTeam == TEAM_SPECTATOR || (client->isEliminated)) &&
(g_gametype.integer < GT_TEAM) )
!(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) )
{
SetTeam( ent, "free" );
}

View file

@ -109,7 +109,7 @@ void G_InitSessionData( gclient_t *client, char *userinfo ) {
sess = &client->sess;
// initial team determination
if ( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
if ( g_teamAutoJoin.integer && !(g_entities[ client - level.clients ].r.svFlags & SVF_BOT) ) {
sess->sessionTeam = PickTeam( -1 );
BroadcastTeamChange( client, -1 );

View file

@ -451,9 +451,8 @@ void G_SpawnGEntityFromSpawnVars( void ) {
return;
}
}
// check for "notteam" flag (GT_FFA, GT_TOURNAMENT, GT_SINGLE_PLAYER)
if ( g_gametype.integer >= GT_TEAM && !g_ffa_gt ) {
/* if ( g_gametype.integer!=GT_FFA && g_gametype.integer!=GT_TOURNAMENT && g_gametype.integer!=GT_LMS && g_gametype.integer!=GT_POSSESSION ) { */
// check for "notteam" flag
if (G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)) {
G_SpawnInt( "notteam", "0", &i );
if ( i ) {
G_FreeEntity( ent );

View file

@ -231,7 +231,7 @@ qboolean OnSameTeam( const gentity_t *ent1, const gentity_t *ent2 )
return qfalse;
}
if ( g_gametype.integer < GT_TEAM || g_ffa_gt==1) {
if (!(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer))) {
return qfalse;
}
@ -277,7 +277,7 @@ void Team_SetFlagStatus( int team, flagStatus_t status )
if( modified ) {
char st[4];
if( g_gametype.integer == GT_CTF || g_gametype.integer == GT_CTF_ELIMINATION) {
if(G_UsesTeamFlags(g_gametype.integer) && !G_UsesTheWhiteFlag(g_gametype.integer)) {
st[0] = ctfFlagStatusRemap[teamgame.redStatus];
st[1] = ctfFlagStatusRemap[teamgame.blueStatus];
st[2] = 0;
@ -407,7 +407,7 @@ void Team_FragBonuses(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker
enemy_flag_pw = PW_REDFLAG;
}
if (g_gametype.integer == GT_1FCTF || g_gametype.integer == GT_POSSESSION) {
if (G_UsesTheWhiteFlag(g_gametype.integer)) {
enemy_flag_pw = PW_NEUTRALFLAG;
}
@ -965,11 +965,11 @@ static void Team_DD_makeB2team( gentity_t *target, int team )
static void Team_ResetFlags( void )
{
if( g_gametype.integer == GT_CTF || g_gametype.integer == GT_CTF_ELIMINATION) {
if(G_UsesTeamFlags(g_gametype.integer) && !G_UsesTheWhiteFlag(g_gametype.integer)) {
Team_ResetFlag( TEAM_RED );
Team_ResetFlag( TEAM_BLUE );
}
else if( g_gametype.integer == GT_1FCTF || g_gametype.integer == GT_POSSESSION ) {
else if(G_UsesTheWhiteFlag(g_gametype.integer)) {
Team_ResetFlag( TEAM_FREE );
}
}
@ -1280,7 +1280,7 @@ int Team_TouchOurFlag( gentity_t *ent, gentity_t *other, int team )
gclient_t *cl = other->client;
int enemy_flag;
if( g_gametype.integer == GT_1FCTF || g_gametype.integer == GT_POSSESSION ) {
if(G_UsesTheWhiteFlag(g_gametype.integer)) {
enemy_flag = PW_NEUTRALFLAG;
}
else {
@ -2303,7 +2303,7 @@ void SP_team_redobelisk( gentity_t *ent )
{
gentity_t *obelisk;
if ( g_gametype.integer <= GT_TEAM || g_ffa_gt>0) {
if (!G_UsesKeyObjectives(g_gametype.integer)) {
G_FreeEntity(ent);
return;
}
@ -2329,7 +2329,7 @@ void SP_team_blueobelisk( gentity_t *ent )
{
gentity_t *obelisk;
if ( g_gametype.integer <= GT_TEAM || g_ffa_gt>0) {
if (!G_UsesKeyObjectives(g_gametype.integer)) {
G_FreeEntity(ent);
return;
}
@ -2353,7 +2353,7 @@ void SP_team_blueobelisk( gentity_t *ent )
*/
void SP_team_neutralobelisk( gentity_t *ent )
{
if ( g_gametype.integer != GT_1FCTF && g_gametype.integer != GT_HARVESTER && g_gametype.integer != GT_POSSESSION ) {
if (!G_UsesTheWhiteFlag(g_gametype.integer) && g_gametype.integer != GT_HARVESTER ) {
G_FreeEntity(ent);
return;
}
@ -2434,7 +2434,7 @@ void ShuffleTeams(void)
int i;
int assignedClients=1, nextTeam=TEAM_RED;
if ( g_gametype.integer < GT_TEAM || g_ffa_gt==1)
if (!(G_IsATeamGametype(g_gametype.integer) && G_UsesKeyObjectives(g_gametype.integer)))
return; //Can only shuffle team games!
for( i=0; i < level.numConnectedClients; i++ ) {

View file

@ -333,7 +333,7 @@ static void UI_AddBotsMenu_Init( void ) {
addBotsMenuInfo.team.generic.y = y;
addBotsMenuInfo.team.generic.name = "Team: ";
addBotsMenuInfo.team.generic.id = ID_TEAM;
if( gametype >= GT_TEAM && gametype!=GT_LMS && gametype!=GT_POSSESSION) {
if(UI_IsATeamGametype(gametype) && UI_UsesKeyObjectives(gametype)) {
addBotsMenuInfo.team.itemnames = teamNames2;
}
else {

View file

@ -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( !(gametype >= GT_TEAM) || gametype == GT_LMS || gametype == GT_POSSESSION ) {
if(!(UI_IsATeamGametype(gametype) && UI_UsesKeyObjectives(gametype))) {
s_ingame.teamorders.generic.flags |= QMF_GRAYED;
}
else {

View file

@ -181,10 +181,6 @@ extern vmCvar_t ui_browserOnlyHumans;
#define QMF_UPPERCASE (unsigned int)0x00080000 // edit field is all upper case
#define QMF_SILENT (unsigned int)0x00100000
//for cgs.ffa_gt and g_ffa kinda leary about this...
//#define FREEFORALL (s_serveroptions.gametype==GT_LMS)
//#define TRAP_FREEFORALL (trap_Cvar_VariableValue( "g_gametype" ) == GT_LMS)
// callback notifications
#define QM_GOTFOCUS 1
#define QM_LOSTFOCUS 2
@ -918,3 +914,13 @@ void RankStatus_Cache( void );
void UI_RankStatusMenu( void );
#endif
/* 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_UsesKeyObjectives(int check); /* Whether the gametype uses key objectives 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. */
qboolean UI_UsesTeamObelisks(int check); /* Whether the gametype uses team obelisks. */
qboolean UI_UsesControlPoints(int check); /* Whether the gametype uses control points. */
/* /Neon_Knight */

View file

@ -330,3 +330,111 @@ void UI_SetDefaultCvar(const char* cvar, const char* value) {
trap_Cvar_Set(cvar,value);
}
}
/* Neon_Knight: Useful check in order to have code consistency. */
/*
===================
UI_IsATeamGametype
Checks if the gametype is a team-based game.
===================
*/
qboolean UI_IsATeamGametype(int check) {
if (check != GT_FFA && check != GT_TOURNAMENT && check != GT_SINGLE_PLAYER && check != GT_LMS && check != GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
UI_UsesKeyObjectives
Checks if the gametype makes use of gametype-specific objectives.
===================
*/
qboolean UI_UsesKeyObjectives(int check) {
if (check != GT_FFA && check != GT_TOURNAMENT && check != GT_SINGLE_PLAYER && check != GT_TEAM && check != GT_LMS && check != GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
UI_UsesTeamFlags
Checks if the gametype makes use of the red and blue flags.
===================
*/
qboolean UI_UsesTeamFlags(int check) {
if (check == GT_CTF || check == GT_1FCTF || check == GT_CTF_ELIMINATION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
UI_UsesTheWhiteFlag
Checks if the gametype makes use of the neutral flag.
===================
*/
qboolean UI_UsesTheWhiteFlag(int check) {
if (check == GT_1FCTF || check == GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
UI_IsARoundBasedGametype
Checks if the gametype has a round-based system.
===================
*/
qboolean UI_IsARoundBasedGametype(int check) {
if (check == GT_ELIMINATION || check == GT_CTF_ELIMINATION || check == GT_LMS) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesTeamObelisks
Checks if the gametype uses team-colored obelisks.
===================
*/
qboolean UI_UsesTeamObelisks(int check) {
if (check == GT_HARVESTER || check == GT_OBELISK) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesControlPoints
Checks if the gametype uses team-colored obelisks.
===================
*/
qboolean UI_UsesControlPoints(int check) {
if (check == GT_DOUBLE_D || check == GT_DOMINATION) {
return qtrue;
}
else {
return qfalse;
}
}
/* /Neon_Knight */

View file

@ -232,6 +232,11 @@ static int GametypeBits( char *string ) {
bits |= 1 << GT_DOMINATION;
continue;
}
if( Q_strequal( token, "pos" ) ) {
bits |= 1 << GT_POSSESSION;
continue;
}
}
return bits;
}
@ -872,7 +877,7 @@ static qboolean BotAlreadySelected( const char *checkName ) {
if( s_serveroptions.playerType[n].curvalue != 1 ) {
continue;
}
if( (s_serveroptions.gametype >= GT_TEAM) && s_serveroptions.gametype != GT_LMS && s_serveroptions.gametype != GT_POSSESSION &&
if(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype) &&
(s_serveroptions.playerTeam[n].curvalue != s_serveroptions.playerTeam[s_serveroptions.newBotIndex].curvalue ) ) {
continue;
}
@ -1065,7 +1070,7 @@ static void ServerOptions_Start( void ) {
if( s_serveroptions.playerNameBuffers[n][0] == '-' ) {
continue;
}
if( s_serveroptions.gametype >= GT_TEAM && s_serveroptions.gametype != GT_LMS && s_serveroptions.gametype != GT_POSSESSION ) {
if(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype)) {
Com_sprintf( buf, sizeof(buf), "addbot %s %i %s\n", s_serveroptions.playerNameBuffers[n], skill,
playerTeam_list[s_serveroptions.playerTeam[n].curvalue] );
}
@ -1076,8 +1081,7 @@ static void ServerOptions_Start( void ) {
}
// set player's team
if( /*dedicated == 0 &&*/ s_serveroptions.gametype >= GT_TEAM && s_serveroptions.gametype != GT_LMS
&& s_serveroptions.gametype != GT_POSSESSION ) {
if( /*dedicated == 0 &&*/ UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype)) {
trap_Cmd_ExecuteText( EXEC_APPEND, va( "wait 5; team %s\n", playerTeam_list[s_serveroptions.playerTeam[0].curvalue] ) );
}
}
@ -1104,7 +1108,7 @@ static void ServerOptions_InitPlayerItems( void ) {
s_serveroptions.playerType[n].curvalue = v;
}
if( s_serveroptions.multiplayer && (s_serveroptions.gametype < GT_TEAM || s_serveroptions.gametype == GT_LMS ) ) {
if(s_serveroptions.multiplayer && !(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype))) {
for( n = 8; n < PLAYER_SLOTS; n++ ) {
s_serveroptions.playerType[n].curvalue = 2;
}
@ -1118,7 +1122,7 @@ static void ServerOptions_InitPlayerItems( void ) {
Q_CleanStr( s_serveroptions.playerNameBuffers[0] );
// init teams
if( s_serveroptions.gametype >= GT_TEAM && s_serveroptions.gametype != GT_LMS && s_serveroptions.gametype != GT_POSSESSION ) {
if(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype)) {
for( n = 0; n < (PLAYER_SLOTS / 2); n++ ) {
s_serveroptions.playerTeam[n].curvalue = 0;
}
@ -1158,7 +1162,7 @@ static void ServerOptions_SetPlayerItems( void ) {
}
// teams
if( s_serveroptions.gametype < GT_TEAM || s_serveroptions.gametype == GT_LMS || s_serveroptions.gametype == GT_POSSESSION ) {
if(!(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype))) {
return;
}
for( n = start; n < PLAYER_SLOTS; n++ ) {
@ -1340,7 +1344,7 @@ static void ServerOptions_InitBotNames( void ) {
char bots[MAX_INFO_STRING];
//this SHOULD work
if( s_serveroptions.gametype >= GT_TEAM && s_serveroptions.gametype != GT_LMS && s_serveroptions.gametype != GT_POSSESSION ) {
if(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype)) {
Q_strncpyz( s_serveroptions.playerNameBuffers[1], "gargoyle", 16 );
Q_strncpyz( s_serveroptions.playerNameBuffers[2], "kyonshi", 16 );
Q_strncpyz( s_serveroptions.playerNameBuffers[3], "grism", 16 );
@ -1656,7 +1660,7 @@ static void ServerOptions_MenuInit( qboolean multiplayer ) {
s_serveroptions.picframe.focuspic = GAMESERVER_SELECT;
y = 268;
if( s_serveroptions.gametype < GT_CTF || s_serveroptions.gametype== GT_LMS) {
if(!UI_IsATeamGametype(s_serveroptions.gametype)) {
s_serveroptions.fraglimit.generic.type = MTYPE_FIELD;
s_serveroptions.fraglimit.generic.name = "Frag Limit:";
s_serveroptions.fraglimit.generic.flags = QMF_NUMBERSONLY|QMF_PULSEIFFOCUS|QMF_SMALLFONT;
@ -1697,8 +1701,7 @@ static void ServerOptions_MenuInit( qboolean multiplayer ) {
s_serveroptions.timelimit.field.widthInChars = 3;
s_serveroptions.timelimit.field.maxchars = 3;
if( s_serveroptions.gametype >= GT_TEAM && s_serveroptions.gametype != GT_LMS && s_serveroptions.gametype != GT_POSSESSION
&& s_serveroptions.gametype != GT_ELIMINATION && s_serveroptions.gametype != GT_CTF_ELIMINATION) {
if(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype) && !(UI_IsARoundBasedGametype(s_serveroptions.gametype) && UI_IsATeamGametype(s_serveroptions.gametype))) {
y += BIGCHAR_HEIGHT+2;
s_serveroptions.friendlyfire.generic.type = MTYPE_RADIOBUTTON;
s_serveroptions.friendlyfire.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
@ -1876,20 +1879,19 @@ static void ServerOptions_MenuInit( qboolean multiplayer ) {
Menu_AddItem( &s_serveroptions.menu, &s_serveroptions.playerType[n] );
}
Menu_AddItem( &s_serveroptions.menu, &s_serveroptions.playerName[n] );
if( s_serveroptions.gametype >= GT_TEAM && s_serveroptions.gametype != GT_LMS ) {
if(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype)) {
Menu_AddItem( &s_serveroptions.menu, &s_serveroptions.playerTeam[n] );
}
}
if( s_serveroptions.gametype < GT_CTF || s_serveroptions.gametype == GT_LMS || s_serveroptions.gametype == GT_POSSESSION ) {
if(!UI_IsATeamGametype(s_serveroptions.gametype)) {
Menu_AddItem( &s_serveroptions.menu, &s_serveroptions.fraglimit );
}
else {
Menu_AddItem( &s_serveroptions.menu, &s_serveroptions.flaglimit );
}
Menu_AddItem( &s_serveroptions.menu, &s_serveroptions.timelimit );
if( s_serveroptions.gametype >= GT_TEAM && s_serveroptions.gametype != GT_LMS && s_serveroptions.gametype != GT_POSSESSION
&& s_serveroptions.gametype != GT_ELIMINATION && s_serveroptions.gametype != GT_CTF_ELIMINATION) {
if(UI_IsATeamGametype(s_serveroptions.gametype) && UI_UsesKeyObjectives(s_serveroptions.gametype) && !(UI_IsARoundBasedGametype(s_serveroptions.gametype) && UI_IsATeamGametype(s_serveroptions.gametype))) {
Menu_AddItem( &s_serveroptions.menu, &s_serveroptions.friendlyfire );
}
Menu_AddItem( &s_serveroptions.menu, &s_serveroptions.pure );

View file

@ -357,13 +357,13 @@ static void UI_TeamOrdersMenu_ListEvent( void *ptr, int event )
if( id == ID_LIST_BOTS ) {
teamOrdersMenuInfo.selectedBot = selection;
if( teamOrdersMenuInfo.gametype == GT_CTF || teamOrdersMenuInfo.gametype == GT_CTF_ELIMINATION ) {
if(UI_UsesTeamFlags(teamOrdersMenuInfo.gametype) && !UI_UsesTheWhiteFlag(teamOrdersMenuInfo.gametype)) {
UI_TeamOrdersMenu_SetList( ID_LIST_CTF_ORDERS );
}
if( teamOrdersMenuInfo.gametype == GT_1FCTF ) {
UI_TeamOrdersMenu_SetList( ID_LIST_CTF1F_ORDERS );
}
if( teamOrdersMenuInfo.gametype == GT_OBELISK || teamOrdersMenuInfo.gametype == GT_HARVESTER ) {
if( UI_UsesTeamObelisks(teamOrdersMenuInfo.gametype) ) {
UI_TeamOrdersMenu_SetList( ID_LIST_BASE_ORDERS );
}
if( teamOrdersMenuInfo.gametype == GT_TEAM || teamOrdersMenuInfo.gametype == GT_ELIMINATION || teamOrdersMenuInfo.gametype == GT_DOMINATION ) {
@ -548,7 +548,7 @@ void UI_TeamOrdersMenu_f( void )
// make sure it's a team game
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
teamOrdersMenuInfo.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
if( teamOrdersMenuInfo.gametype < GT_TEAM || teamOrdersMenuInfo.gametype == GT_LMS || teamOrdersMenuInfo.gametype == GT_POSSESSION) {
if(!(UI_IsATeamGametype(teamOrdersMenuInfo.gametype) && UI_UsesKeyObjectives(teamOrdersMenuInfo.gametype))) {
return;
}

View file

@ -1281,3 +1281,13 @@ typedef struct postGameInfo_s {
#endif
/* 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_UsesKeyObjectives(int check); /* Whether the gametype uses key objectives 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. */
qboolean UI_UsesTeamObelisks(int check); /* Whether the gametype uses team obelisks. */
qboolean UI_UsesControlPoints(int check); /* Whether the gametype uses control points. */
/* /Neon_Knight */

View file

@ -1602,7 +1602,7 @@ static void UI_DrawTeamMember(rectDef_t *rect, float scale, vec4_t color, qboole
else {
value -= 2;
if (ui_actualNetGameType.integer >= GT_TEAM && ui_actualNetGameType.integer != GT_LMS && ui_actualNetGameType.integer != GT_POSSESSION ) {
if (UI_IsATeamGametype(ui_actualNetGameType.integer) && UI_UsesKeyObjectives(ui_actualNetGameType.integer)) {
if (value >= uiInfo.characterCount) {
value = 0;
}
@ -2415,7 +2415,7 @@ static void UI_DrawBotName(rectDef_t *rect, float scale, vec4_t color, int textS
int value = uiInfo.botIndex;
int game = trap_Cvar_VariableValue("g_gametype");
const char *text = "";
if (game >= GT_TEAM && game != GT_LMS && game != GT_POSSESSION) {
if (UI_IsATeamGametype(game) && UI_UsesKeyObjectives(game)) {
if (value >= uiInfo.characterCount) {
value = 0;
}
@ -2870,14 +2870,14 @@ static qboolean UI_OwnerDrawVisible(int flags)
while (flags) {
if (flags & UI_SHOW_FFA) {
if (trap_Cvar_VariableValue("g_gametype") != GT_FFA || trap_Cvar_VariableValue("g_gametype") != GT_LMS || trap_Cvar_VariableValue("g_gametype") != GT_POSSESSION ) {
if (UI_IsATeamGametype(trap_Cvar_VariableValue("g_gametype")) || trap_Cvar_VariableValue("g_gametype") == GT_TOURNAMENT) {
vis = qfalse;
}
flags &= ~UI_SHOW_FFA;
}
if (flags & UI_SHOW_NOTFFA) {
if (trap_Cvar_VariableValue("g_gametype") == GT_FFA || trap_Cvar_VariableValue("g_gametype") == GT_LMS || trap_Cvar_VariableValue("g_gametype") == GT_POSSESSION ) {
if (!UI_IsATeamGametype(trap_Cvar_VariableValue("g_gametype")) && trap_Cvar_VariableValue("g_gametype") != GT_TOURNAMENT) {
vis = qfalse;
}
flags &= ~UI_SHOW_NOTFFA;
@ -2922,25 +2922,25 @@ static qboolean UI_OwnerDrawVisible(int flags)
flags &= ~UI_SHOW_NOTFAVORITESERVERS;
}
if (flags & UI_SHOW_ANYTEAMGAME) {
if (uiInfo.gameTypes[ui_gameType.integer].gtEnum <= GT_TEAM || uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_LMS || uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_POSSESSION ) {
if (!UI_IsATeamGametype(uiInfo.gameTypes[ui_gameType.integer].gtEnum)) {
vis = qfalse;
}
flags &= ~UI_SHOW_ANYTEAMGAME;
}
if (flags & UI_SHOW_ANYNONTEAMGAME) {
if (uiInfo.gameTypes[ui_gameType.integer].gtEnum > GT_TEAM && uiInfo.gameTypes[ui_gameType.integer].gtEnum != GT_LMS && uiInfo.gameTypes[ui_gameType.integer].gtEnum != GT_POSSESSION ) {
if (UI_IsATeamGametype(uiInfo.gameTypes[ui_gameType.integer].gtEnum)) {
vis = qfalse;
}
flags &= ~UI_SHOW_ANYNONTEAMGAME;
}
if (flags & UI_SHOW_NETANYTEAMGAME) {
if (uiInfo.gameTypes[ui_netGameType.integer].gtEnum <= GT_TEAM || uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_LMS || uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_POSSESSION ) {
if (!UI_IsATeamGametype(uiInfo.gameTypes[ui_netGameType.integer].gtEnum)) {
vis = qfalse;
}
flags &= ~UI_SHOW_NETANYTEAMGAME;
}
if (flags & UI_SHOW_NETANYNONTEAMGAME) {
if (uiInfo.gameTypes[ui_netGameType.integer].gtEnum > GT_TEAM && uiInfo.gameTypes[ui_gameType.integer].gtEnum != GT_LMS && uiInfo.gameTypes[ui_gameType.integer].gtEnum != GT_POSSESSION ) {
if (UI_IsATeamGametype(uiInfo.gameTypes[ui_netGameType.integer].gtEnum)) {
vis = qfalse;
}
flags &= ~UI_SHOW_NETANYNONTEAMGAME;
@ -3238,7 +3238,7 @@ static qboolean UI_TeamMember_HandleKey(int flags, float *special, int key, qboo
else {
value++;
}
if (ui_actualNetGameType.integer >= GT_TEAM && ui_actualNetGameType.integer != GT_LMS && ui_actualNetGameType.integer != GT_POSSESSION) {
if (UI_IsATeamGametype(ui_actualNetGameType.integer) && UI_UsesKeyObjectives(ui_actualNetGameType.integer)) {
if (value >= uiInfo.characterCount + 2) {
value = 0;
}
@ -3343,7 +3343,7 @@ static qboolean UI_BotName_HandleKey(int flags, float *special, int key)
value++;
}
if (game >= GT_TEAM && game != GT_LMS && game != GT_POSSESSION) {
if (UI_IsATeamGametype(game) && UI_UsesKeyObjectives(game)) {
if (value >= uiInfo.characterCount + 2) {
value = 0;
}
@ -3779,7 +3779,7 @@ static void UI_StartSkirmish(qboolean next, char *name)
Com_sprintf( buff, sizeof(buff), "wait ; addbot %s %f "", %i \n", uiInfo.mapList[ui_currentMap.integer].opponentName, skill, delay);
trap_Cmd_ExecuteText( EXEC_APPEND, buff );
}
else if (g == GT_FFA || g == GT_LMS || g == GT_POSSESSION) { // leilei - parse the opponentname as a list of bots instead like q3_ui's arena parsing
else if (!UI_IsATeamGametype(g) && g != GT_TOURNAMENT) { // leilei - parse the opponentname as a list of bots instead like q3_ui's arena parsing
char *p;
char *bot;
const char *botInfo;
@ -3843,7 +3843,7 @@ static void UI_StartSkirmish(qboolean next, char *name)
delay += 500;
}
}
if (g >= GT_TEAM ) {
if (UI_IsATeamGametype(g) && UI_UsesKeyObjectives(g)) {
trap_Cmd_ExecuteText( EXEC_APPEND, "wait 5; team Red\n" );
}
}
@ -4048,7 +4048,7 @@ static void UI_RunMenuScript(char **args)
for (i = 0; i < PLAYERS_PER_TEAM; i++) {
int bot = trap_Cvar_VariableValue( va("ui_blueteam%i", i+1));
if (bot > 1) {
if (ui_actualNetGameType.integer >= GT_TEAM && ui_actualNetGameType.integer != GT_LMS && ui_actualNetGameType.integer != GT_POSSESSION ) {
if (UI_IsATeamGametype(ui_actualNetGameType.integer) && UI_UsesKeyObjectives(ui_actualNetGameType.integer)) {
Com_sprintf( buff, sizeof(buff), "addbot %s %f %s\n", uiInfo.characterList[bot-2].name, skill, "Blue");
}
else {
@ -4058,7 +4058,7 @@ static void UI_RunMenuScript(char **args)
}
bot = trap_Cvar_VariableValue( va("ui_redteam%i", i+1));
if (bot > 1) {
if (ui_actualNetGameType.integer >= GT_TEAM && ui_actualNetGameType.integer != GT_LMS && ui_actualNetGameType.integer != GT_POSSESSION ) {
if (UI_IsATeamGametype(ui_actualNetGameType.integer) && UI_UsesKeyObjectives(ui_actualNetGameType.integer)) {
Com_sprintf( buff, sizeof(buff), "addbot %s %f %s\n", uiInfo.characterList[bot-2].name, skill, "Red");
}
else {
@ -4391,7 +4391,7 @@ static void UI_RunMenuScript(char **args)
}
}
else if (Q_strequal(name, "addBot") ) {
if (trap_Cvar_VariableValue("g_gametype") >= GT_TEAM || GT_LMS || GT_POSSESSION ) {
if (UI_IsATeamGametype(trap_Cvar_VariableValue("g_gametype")) && UI_UsesKeyObjectives(trap_Cvar_VariableValue("g_gametype"))) {
trap_Cmd_ExecuteText( EXEC_APPEND, va("addbot %s %i %s\n", uiInfo.characterList[uiInfo.botIndex].name, uiInfo.skillIndex+1, (uiInfo.redBlue == 0) ? "Red" : "Blue") );
}
else {
@ -7430,3 +7430,113 @@ static void UI_StartServerRefresh(qboolean full)
}
}
/* Neon_Knight: Useful check in order to have code consistency. */
/*
===================
UI_IsATeamGametype
Checks if the gametype is a team-based game.
(UI_IsATeamGame(check,qtrue))
===================
*/
qboolean UI_IsATeamGametype(int check) {
if (check != GT_FFA && check != GT_TOURNAMENT && check != GT_SINGLE_PLAYER && check != GT_LMS && check != GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
UI_UsesKeyObjectives
Checks if the gametype makes use of gametype-specific objectives.
(Flags, obelisks, control points...)
(UI_IsATeamGame(check,qfalse))
===================
*/
qboolean UI_UsesKeyObjectives(int check) {
if (check != GT_FFA && check != GT_TOURNAMENT && check != GT_SINGLE_PLAYER && check != GT_TEAM && check != GT_LMS && check != GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
UI_UsesTeamFlags
Checks if the gametype makes use of the red and blue flags.
===================
*/
qboolean UI_UsesTeamFlags(int check) {
if (check == GT_CTF || check == GT_1FCTF || check == GT_CTF_ELIMINATION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
UI_UsesTheWhiteFlag
Checks if the gametype makes use of the neutral flag.
===================
*/
qboolean UI_UsesTheWhiteFlag(int check) {
if (check == GT_1FCTF || check == GT_POSSESSION) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
UI_IsARoundBasedGametype
Checks if the gametype has a round-based system.
===================
*/
qboolean UI_IsARoundBasedGametype(int check) {
if (check == GT_ELIMINATION || check == GT_CTF_ELIMINATION || check == GT_LMS) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesTeamObelisks
Checks if the gametype uses team-colored obelisks.
===================
*/
qboolean UI_UsesTeamObelisks(int check) {
if (check == GT_HARVESTER || check == GT_OBELISK) {
return qtrue;
}
else {
return qfalse;
}
}
/*
===================
CG_UsesControlPoints
Checks if the gametype uses team-colored obelisks.
===================
*/
qboolean UI_UsesControlPoints(int check) {
if (check == GT_DOUBLE_D || check == GT_DOMINATION) {
return qtrue;
}
else {
return qfalse;
}
}
/* /Neon_Knight */