[iortcw] 74/89: All: Don't require to be a local client to use g_localTeamPref
Simon McVittie
smcv at debian.org
Fri Sep 8 10:44:32 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to tag 1.51b
in repository iortcw.
commit 82cf63874f26c4a0caab8fedf056fdbee97e9d7a
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date: Fri Jul 28 20:34:27 2017 -0400
All: Don't require to be a local client to use g_localTeamPref
Fix g_teamAutoJoin
Sync g_teamForceBalance code from MP into SP
---
MP/code/game/g_cmds.c | 5 +++++
MP/code/game/g_main.c | 1 +
MP/code/game/g_session.c | 2 +-
SP/code/game/g_client.c | 27 +++++++++++++++++++++++++++
SP/code/game/g_cmds.c | 28 ++++++++++++++++++++++++++++
SP/code/game/g_local.h | 1 +
SP/code/game/g_main.c | 3 +++
SP/code/game/g_session.c | 2 +-
8 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/MP/code/game/g_cmds.c b/MP/code/game/g_cmds.c
index 80d02de..c856676 100644
--- a/MP/code/game/g_cmds.c
+++ b/MP/code/game/g_cmds.c
@@ -694,6 +694,11 @@ void SetTeam( gentity_t *ent, const char *s ) {
// get and distribute relevent paramters
ClientUserinfoChanged( clientNum );
+ // client hasn't spawned yet, they sent an early team command, teampref userinfo, or g_teamAutoJoin is enabled
+ if ( client->pers.connected != CON_CONNECTED ) {
+ return;
+ }
+
ClientBegin( clientNum );
}
diff --git a/MP/code/game/g_main.c b/MP/code/game/g_main.c
index 01662ef..f3a8166 100644
--- a/MP/code/game/g_main.c
+++ b/MP/code/game/g_main.c
@@ -205,6 +205,7 @@ cvarTable_t gameCvarTable[] = {
{ &g_friendlyFire, "g_friendlyFire", "1", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue },
+ { &g_teamAutoJoin, "g_teamAutoJoin", "0", CVAR_ARCHIVE },
{ &g_teamForceBalance, "g_teamForceBalance", "0", CVAR_ARCHIVE }, // NERVE - SMF - merge from team arena
{ &g_warmup, "g_warmup", "20", CVAR_ARCHIVE, 0, qtrue },
diff --git a/MP/code/game/g_session.c b/MP/code/game/g_session.c
index af9e3c2..cfda965 100644
--- a/MP/code/game/g_session.c
+++ b/MP/code/game/g_session.c
@@ -150,7 +150,7 @@ void G_InitSessionData( gclient_t *client, char *userinfo ) {
value = Info_ValueForKey( userinfo, "teampref" );
// check for human's team preference set by start server menu
- if ( !value[0] && g_localTeamPref.string[0] && client->pers.localClient ) {
+ if ( !value[0] && g_localTeamPref.string[0] /*&& client->pers.localClient*/ ) {
value = g_localTeamPref.string;
// clear team so it's only used once
diff --git a/SP/code/game/g_client.c b/SP/code/game/g_client.c
index 7c1e4ac..692da79 100644
--- a/SP/code/game/g_client.c
+++ b/SP/code/game/g_client.c
@@ -684,6 +684,33 @@ void ClientRespawn( gentity_t *ent ) {
ClientSpawn( ent );
}
+// NERVE - SMF - merge from team arena
+/*
+================
+TeamCount
+
+Returns number of players on a team
+================
+*/
+int TeamCount( int ignoreClientNum, team_t team ) {
+ int i;
+ int count = 0;
+
+ for ( i = 0 ; i < level.maxclients ; i++ ) {
+ if ( i == ignoreClientNum ) {
+ continue;
+ }
+ if ( level.clients[i].pers.connected == CON_DISCONNECTED ) {
+ continue;
+ }
+ if ( level.clients[i].sess.sessionTeam == team ) {
+ count++;
+ }
+ }
+
+ return count;
+}
+// -NERVE - SMF
/*
================
diff --git a/SP/code/game/g_cmds.c b/SP/code/game/g_cmds.c
index d59afbf..fa82b43 100644
--- a/SP/code/game/g_cmds.c
+++ b/SP/code/game/g_cmds.c
@@ -603,6 +603,29 @@ void SetTeam( gentity_t *ent, const char *s ) {
// pick the team with the least number of players
team = PickTeam( clientNum );
}
+
+ // NERVE - SMF - merge from team arena
+ if ( g_teamForceBalance.integer && !client->pers.localClient && !( ent->r.svFlags & SVF_BOT ) ) {
+ int counts[TEAM_NUM_TEAMS];
+
+ counts[TEAM_BLUE] = TeamCount( clientNum, TEAM_BLUE );
+ counts[TEAM_RED] = TeamCount( clientNum, TEAM_RED );
+
+ // We allow a spread of one
+ if ( team == TEAM_RED && counts[TEAM_RED] - counts[TEAM_BLUE] >= 1 ) {
+ trap_SendServerCommand( clientNum,
+ "cp \"The Axis has too many players.\n\"" );
+ return; // ignore the request
+ }
+ if ( team == TEAM_BLUE && counts[TEAM_BLUE] - counts[TEAM_RED] >= 1 ) {
+ trap_SendServerCommand( clientNum,
+ "cp \"The Allies have too many players.\n\"" );
+ return; // ignore the request
+ }
+
+ // It's ok, the team we are switching to has less or same number of players
+ }
+ // -NERVE - SMF
} else {
// force them to spectators if there aren't any spots free
team = TEAM_FREE;
@@ -663,6 +686,11 @@ void SetTeam( gentity_t *ent, const char *s ) {
// get and distribute relevent paramters
ClientUserinfoChanged( clientNum );
+ // client hasn't spawned yet, they sent an early team command, teampref userinfo, or g_teamAutoJoin is enabled
+ if ( client->pers.connected != CON_CONNECTED ) {
+ return;
+ }
+
ClientBegin( clientNum );
}
diff --git a/SP/code/game/g_local.h b/SP/code/game/g_local.h
index cefca7e..8818c31 100644
--- a/SP/code/game/g_local.h
+++ b/SP/code/game/g_local.h
@@ -915,6 +915,7 @@ void CalcMuzzlePointForActivate( gentity_t *ent, vec3_t forward, vec3_t right, v
//
// g_client.c
//
+int TeamCount( int ignoreClientNum, team_t team );
team_t PickTeam( int ignoreClientNum );
void SetClientViewAngle( gentity_t *ent, vec3_t angle );
gentity_t *SelectSpawnPoint( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
diff --git a/SP/code/game/g_main.c b/SP/code/game/g_main.c
index abe3073..675357f 100644
--- a/SP/code/game/g_main.c
+++ b/SP/code/game/g_main.c
@@ -188,6 +188,9 @@ cvarTable_t gameCvarTable[] = {
{ &g_friendlyFire, "g_friendlyFire", "1", CVAR_ARCHIVE, 0, qtrue },
+ { &g_teamAutoJoin, "g_teamAutoJoin", "0", CVAR_ARCHIVE },
+ { &g_teamForceBalance, "g_teamForceBalance", "0", CVAR_ARCHIVE }, // NERVE - SMF - merge from team arena
+
{ &g_warmup, "g_warmup", "20", CVAR_ARCHIVE, 0, qtrue },
{ &g_doWarmup, "g_doWarmup", "0", CVAR_ARCHIVE, 0, qtrue },
{ &g_logfile, "g_log", "games.log", CVAR_ARCHIVE, 0, qfalse },
diff --git a/SP/code/game/g_session.c b/SP/code/game/g_session.c
index 1864ffe..ead3bbf 100644
--- a/SP/code/game/g_session.c
+++ b/SP/code/game/g_session.c
@@ -116,7 +116,7 @@ void G_InitSessionData( gclient_t *client, char *userinfo ) {
value = Info_ValueForKey( userinfo, "teampref" );
// check for human's team preference set by start server menu
- if ( !value[0] && g_localTeamPref.string[0] && client->pers.localClient ) {
+ if ( !value[0] && g_localTeamPref.string[0] /*&& client->pers.localClient*/ ) {
value = g_localTeamPref.string;
// clear team so it's only used once
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git
More information about the Pkg-games-commits
mailing list