mirror of
https://github.com/OpenArena/gamecode
synced 2026-08-20 18:23:03 -04:00
Squashed commit of the following: commitc05ffecf38Author: Neon_Knight <openarena.arg@gmail.com> Date: Fri Nov 30 22:53:54 2018 -0300 This is also not needed anymore. commit14abe7715aAuthor: Neon_Knight <openarena.arg@gmail.com> Date: Fri Nov 30 22:29:26 2018 -0300 Last checks found. Hopefully that's enough. commitcad2ab0c5aAuthor: Neon_Knight <openarena.arg@gmail.com> Date: Fri Nov 30 22:14:33 2018 -0300 We don't need g_ffa_gt anymore. commit2577547db4Author: Neon_Knight <openarena.arg@gmail.com> Date: Fri Nov 30 22:04:09 2018 -0300 More checks located. commitd9c96477c6Author: 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. commit2089039745Author: Neon_Knight <openarena.arg@gmail.com> Date: Fri Nov 30 21:18:25 2018 -0300 Fixing several syntax errors. commit0edba34607Author: Neon_Knight <openarena.arg@gmail.com> Date: Fri Nov 30 21:07:23 2018 -0300 Oops... my mistakes. -.- commit05e9ef79d4Author: 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. commit06e325ab00Author: Neon_Knight <openarena.arg@gmail.com> Date: Thu Nov 29 17:10:48 2018 -0300 Some syntax errors fixed. commite394d4fc54Author: Neon_Knight <openarena.arg@gmail.com> Date: Thu Nov 29 17:00:01 2018 -0300 Finished the splitting. commit5e267d161fAuthor: Neon_Knight <openarena.arg@gmail.com> Date: Thu Nov 29 16:34:01 2018 -0300 Splitting the function. commit7c643f14aaAuthor: Neon_Knight <openarena.arg@gmail.com> Date: Thu Nov 29 12:36:14 2018 -0300 Syntax error. commitaba598fde4Author: 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. commitb9a61dbe45Author: 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 commitfe4c340e35. commitfe4c340e35Author: 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.
194 lines
4.8 KiB
C
194 lines
4.8 KiB
C
/*
|
|
===========================================================================
|
|
Copyright (C) 1999-2005 Id Software, Inc.
|
|
|
|
This file is part of Quake III Arena source code.
|
|
|
|
Quake III Arena source code is free software; you can redistribute it
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
or (at your option) any later version.
|
|
|
|
Quake III Arena source code is distributed in the hope that it will be
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Quake III Arena source code; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
===========================================================================
|
|
*/
|
|
//
|
|
#include "g_local.h"
|
|
|
|
|
|
/*
|
|
=======================================================================
|
|
|
|
SESSION DATA
|
|
|
|
Session data is the only data that stays persistant across level loads
|
|
and tournament restarts.
|
|
=======================================================================
|
|
*/
|
|
|
|
/*
|
|
================
|
|
G_WriteClientSessionData
|
|
|
|
Called on game shutdown
|
|
================
|
|
*/
|
|
static void G_WriteClientSessionData( const gclient_t *client ) {
|
|
const char *s;
|
|
const char *var;
|
|
|
|
s = va("%i %i %i %i %i %i %i",
|
|
client->sess.sessionTeam,
|
|
client->sess.spectatorNum,
|
|
client->sess.spectatorState,
|
|
client->sess.spectatorClient,
|
|
client->sess.wins,
|
|
client->sess.losses,
|
|
client->sess.teamLeader
|
|
);
|
|
|
|
var = va( "session%i", (int)(client - level.clients) );
|
|
|
|
trap_Cvar_Set( var, s );
|
|
}
|
|
|
|
/*
|
|
================
|
|
G_ReadSessionData
|
|
|
|
Called on a reconnect
|
|
================
|
|
*/
|
|
void G_ReadSessionData( gclient_t *client ) {
|
|
char s[MAX_STRING_CHARS];
|
|
const char *var;
|
|
|
|
// bk001205 - format
|
|
int teamLeader;
|
|
int spectatorState;
|
|
int sessionTeam;
|
|
|
|
var = va( "session%i", (int)(client - level.clients) );
|
|
trap_Cvar_VariableStringBuffer( var, s, sizeof(s) );
|
|
|
|
sscanf( s, "%i %i %i %i %i %i %i",
|
|
&sessionTeam, // bk010221 - format
|
|
&client->sess.spectatorNum,
|
|
&spectatorState, // bk010221 - format
|
|
&client->sess.spectatorClient,
|
|
&client->sess.wins,
|
|
&client->sess.losses,
|
|
&teamLeader // bk010221 - format
|
|
);
|
|
|
|
// bk001205 - format issues
|
|
client->sess.sessionTeam = (team_t)sessionTeam;
|
|
client->sess.spectatorState = (spectatorState_t)spectatorState;
|
|
client->sess.teamLeader = (qboolean)teamLeader;
|
|
}
|
|
|
|
|
|
/*
|
|
================
|
|
G_InitSessionData
|
|
|
|
Called on a first-time connect
|
|
================
|
|
*/
|
|
void G_InitSessionData( gclient_t *client, char *userinfo ) {
|
|
clientSession_t *sess;
|
|
const char *value;
|
|
|
|
sess = &client->sess;
|
|
|
|
// initial team determination
|
|
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 );
|
|
} else {
|
|
// always spawn as spectator in team games
|
|
sess->sessionTeam = TEAM_SPECTATOR;
|
|
}
|
|
} else {
|
|
value = Info_ValueForKey( userinfo, "team" );
|
|
if ( value[0] == 's' ) {
|
|
// a willing spectator, not a waiting-in-line
|
|
sess->sessionTeam = TEAM_SPECTATOR;
|
|
} else {
|
|
switch ( g_gametype.integer ) {
|
|
default:
|
|
case GT_FFA:
|
|
case GT_LMS:
|
|
case GT_SINGLE_PLAYER:
|
|
if ( g_maxGameClients.integer > 0 &&
|
|
level.numNonSpectatorClients >= g_maxGameClients.integer ) {
|
|
sess->sessionTeam = TEAM_SPECTATOR;
|
|
} else {
|
|
sess->sessionTeam = TEAM_FREE;
|
|
}
|
|
break;
|
|
case GT_TOURNAMENT:
|
|
// if the game is full, go into a waiting mode
|
|
if ( level.numNonSpectatorClients >= 2 ) {
|
|
sess->sessionTeam = TEAM_SPECTATOR;
|
|
} else {
|
|
sess->sessionTeam = TEAM_FREE;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
sess->spectatorState = SPECTATOR_FREE;
|
|
AddTournamentQueue(client);
|
|
|
|
G_WriteClientSessionData( client );
|
|
}
|
|
|
|
|
|
/*
|
|
==================
|
|
G_InitWorldSession
|
|
|
|
==================
|
|
*/
|
|
void G_InitWorldSession( void ) {
|
|
char s[MAX_STRING_CHARS];
|
|
int gt;
|
|
|
|
trap_Cvar_VariableStringBuffer( "session", s, sizeof(s) );
|
|
gt = atoi( s );
|
|
|
|
// if the gametype changed since the last session, don't use any
|
|
// client sessions
|
|
if ( g_gametype.integer != gt ) {
|
|
level.newSession = qtrue;
|
|
G_Printf( "Gametype changed, clearing session data.\n" );
|
|
}
|
|
}
|
|
|
|
/*
|
|
==================
|
|
G_WriteSessionData
|
|
|
|
==================
|
|
*/
|
|
void G_WriteSessionData( void ) {
|
|
int i;
|
|
|
|
trap_Cvar_Set( "session", va("%i", g_gametype.integer) );
|
|
|
|
for ( i = 0 ; i < level.maxclients ; i++ ) {
|
|
if ( level.clients[i].pers.connected == CON_CONNECTED ) {
|
|
G_WriteClientSessionData( &level.clients[i] );
|
|
}
|
|
}
|
|
}
|