2001-12-31 16:16:59 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
2001-12-31 16:28:42 +00:00
|
|
|
// $Log$
|
2002-10-26 22:03:43 +00:00
|
|
|
// Revision 1.23 2002/10/26 22:03:43 jbravo
|
|
|
|
// Made TeamDM work RQ3 style.
|
|
|
|
//
|
2002-10-21 21:00:39 +00:00
|
|
|
// Revision 1.22 2002/10/21 21:00:39 slicer
|
|
|
|
// New MM features and bug fixes
|
|
|
|
//
|
2002-09-29 16:06:45 +00:00
|
|
|
// Revision 1.21 2002/09/29 16:06:45 jbravo
|
|
|
|
// Work done at the HPWorld expo
|
|
|
|
//
|
2002-08-23 14:25:05 +00:00
|
|
|
// Revision 1.20 2002/08/23 14:25:05 slicer
|
|
|
|
// Added a new Referee System with multiple ref support
|
|
|
|
//
|
2002-08-21 07:00:07 +00:00
|
|
|
// Revision 1.19 2002/08/21 07:00:07 jbravo
|
|
|
|
// Added CTB respawn queue and fixed game <-> cgame synch problem in CTB
|
|
|
|
//
|
2002-07-20 05:06:01 +00:00
|
|
|
// Revision 1.18 2002/07/20 05:06:01 niceass
|
|
|
|
// scoreboard remembering your team in CTB but lying is fixed
|
|
|
|
//
|
2002-07-11 04:29:41 +00:00
|
|
|
// Revision 1.17 2002/07/11 04:29:41 niceass
|
|
|
|
// removed auto-joining teams for things like ctb
|
|
|
|
//
|
2002-06-16 20:06:15 +00:00
|
|
|
// Revision 1.16 2002/06/16 20:06:14 jbravo
|
|
|
|
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
|
|
|
|
//
|
2002-05-11 15:00:04 +00:00
|
|
|
// Revision 1.15 2002/05/11 15:00:04 jbravo
|
|
|
|
// Fix for autojoin and a very minir for for Obits
|
|
|
|
//
|
2002-05-05 15:51:16 +00:00
|
|
|
// Revision 1.14 2002/05/05 15:51:16 slicer
|
|
|
|
// Captain and subs get saved on map_restarts ( moved to "sess" )
|
|
|
|
//
|
2002-03-30 21:51:42 +00:00
|
|
|
// Revision 1.13 2002/03/30 21:51:42 jbravo
|
|
|
|
// Removed all those ifdefs for zcam.
|
|
|
|
//
|
2002-03-26 11:32:05 +00:00
|
|
|
// Revision 1.12 2002/03/26 11:32:05 jbravo
|
|
|
|
// Remember specstate between rounds.
|
|
|
|
//
|
2002-03-18 17:52:36 +00:00
|
|
|
// Revision 1.11 2002/03/18 17:52:36 slicer
|
|
|
|
// Saved sess.savedTeam throught map changes for matchmode
|
|
|
|
//
|
2002-03-11 18:02:33 +00:00
|
|
|
// Revision 1.10 2002/03/11 18:02:33 slicer
|
|
|
|
// Fixed team changes and scoreboard bugs
|
|
|
|
//
|
2002-02-25 19:41:53 +00:00
|
|
|
// Revision 1.9 2002/02/25 19:41:53 jbravo
|
|
|
|
// Fixed the use ESC and join menu to join teams when dead players are
|
|
|
|
// spectating in TP mode.
|
|
|
|
// Tuned the autorespawn system a bit. Now dead ppl. are dead for a very
|
|
|
|
// small time before they are made into spectators.
|
|
|
|
//
|
2002-02-09 00:10:12 +00:00
|
|
|
// Revision 1.8 2002/02/09 00:10:12 jbravo
|
|
|
|
// Fixed spectator follow and free and updated zcam to 1.04 and added the
|
|
|
|
// missing zcam files.
|
|
|
|
//
|
2002-02-03 21:23:51 +00:00
|
|
|
// Revision 1.7 2002/02/03 21:23:51 slicer
|
|
|
|
// More Matchmode code and fixed 2 bugs in TP
|
2002-02-02 20:39:09 +00:00
|
|
|
//
|
2002-01-11 19:48:33 +00:00
|
|
|
// Revision 1.5 2002/01/11 19:48:30 jbravo
|
|
|
|
// Formatted the source in non DOS format.
|
|
|
|
//
|
2001-12-31 16:28:42 +00:00
|
|
|
// Revision 1.4 2001/12/31 16:28:42 jbravo
|
|
|
|
// I made a Booboo with the Log tag.
|
|
|
|
//
|
2001-12-31 16:16:59 +00:00
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
2001-05-06 20:50:27 +00:00
|
|
|
// Copyright (C) 1999-2000 Id Software, Inc.
|
|
|
|
//
|
|
|
|
#include "g_local.h"
|
2002-02-09 00:10:12 +00:00
|
|
|
#include "zcam.h"
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
/*
|
|
|
|
=======================================================================
|
|
|
|
|
|
|
|
SESSION DATA
|
|
|
|
|
|
|
|
Session data is the only data that stays persistant across level loads
|
|
|
|
and tournament restarts.
|
|
|
|
=======================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
G_WriteClientSessionData
|
|
|
|
|
|
|
|
Called on game shutdown
|
|
|
|
================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void G_WriteClientSessionData(gclient_t * client)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
const char *var;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-03-11 18:02:33 +00:00
|
|
|
//Slicer how about savedTeam ?!
|
|
|
|
|
2002-10-26 22:03:43 +00:00
|
|
|
if (!g_RQ3_matchmode.integer && g_gametype.integer >= GT_TEAM) {
|
2002-03-18 17:52:36 +00:00
|
|
|
//Reset teams on map changes / map_restarts, except on matchmode
|
2002-06-16 20:06:15 +00:00
|
|
|
client->sess.savedTeam = TEAM_SPECTATOR;
|
2002-03-18 17:52:36 +00:00
|
|
|
}
|
2002-08-23 14:25:05 +00:00
|
|
|
s = va("%i %i %i %i %i %i %i %i %i %i %i",
|
2002-06-16 20:06:15 +00:00
|
|
|
client->sess.sessionTeam,
|
|
|
|
client->sess.spectatorTime,
|
|
|
|
client->sess.spectatorState,
|
|
|
|
client->sess.spectatorClient, client->sess.wins, client->sess.losses, client->sess.teamLeader,
|
|
|
|
//Adding saved Team
|
2002-08-23 14:25:05 +00:00
|
|
|
client->sess.savedTeam, client->sess.captain, client->sess.sub,client->sess.referee
|
2002-06-16 20:06:15 +00:00
|
|
|
//Captain and sub
|
|
|
|
);
|
|
|
|
|
2011-03-07 03:59:31 +00:00
|
|
|
var = va( "session%i", (int)(client - level.clients) );
|
2002-06-16 20:06:15 +00:00
|
|
|
|
|
|
|
trap_Cvar_Set(var, s);
|
|
|
|
|
|
|
|
camera_state_save(client);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
G_ReadSessionData
|
|
|
|
|
|
|
|
Called on a reconnect
|
|
|
|
================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void G_ReadSessionData(gclient_t * client)
|
|
|
|
{
|
|
|
|
char s[MAX_STRING_CHARS];
|
|
|
|
const char *var;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2001-08-01 19:52:17 +00:00
|
|
|
// bk001205 - format
|
|
|
|
int teamLeader;
|
|
|
|
int spectatorState;
|
|
|
|
int sessionTeam;
|
2002-06-16 20:06:15 +00:00
|
|
|
|
2002-03-11 18:02:33 +00:00
|
|
|
//Slicer
|
|
|
|
int savedTeam;
|
2002-05-05 15:51:16 +00:00
|
|
|
int captain;
|
|
|
|
int sub;
|
2002-08-23 14:25:05 +00:00
|
|
|
int ref;
|
2001-08-01 19:52:17 +00:00
|
|
|
|
2011-03-07 03:59:31 +00:00
|
|
|
var = va("session%i", (int)(client - level.clients));
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_Cvar_VariableStringBuffer(var, s, sizeof(s));
|
2002-03-11 18:02:33 +00:00
|
|
|
//Slicer: Reading savedTeam also.
|
2002-08-23 14:25:05 +00:00
|
|
|
sscanf(s, "%i %i %i %i %i %i %i %i %i %i %i", &sessionTeam, // bk010221 - format
|
2002-06-16 20:06:15 +00:00
|
|
|
&client->sess.spectatorTime, &spectatorState, // bk010221 - format
|
|
|
|
&client->sess.spectatorClient, &client->sess.wins, &client->sess.losses, &teamLeader, // bk010221 - format
|
2002-08-23 14:25:05 +00:00
|
|
|
&savedTeam, &captain, &sub, &ref);
|
2001-08-01 19:52:17 +00:00
|
|
|
|
|
|
|
// bk001205 - format issues
|
2002-07-11 04:29:41 +00:00
|
|
|
|
|
|
|
// Only noticable on non-roundbased games like CTB.
|
2002-07-20 05:06:01 +00:00
|
|
|
client->sess.sessionTeam = (team_t) sessionTeam;
|
2002-07-11 04:29:41 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
client->sess.spectatorState = (spectatorState_t) spectatorState;
|
|
|
|
client->sess.teamLeader = (qboolean) teamLeader;
|
|
|
|
|
|
|
|
client->sess.savedTeam = (team_t) savedTeam;
|
|
|
|
client->sess.captain = (team_t) captain;
|
|
|
|
client->sess.sub = (team_t) sub;
|
2002-08-23 14:25:05 +00:00
|
|
|
client->sess.referee = ref;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-07-20 05:06:01 +00:00
|
|
|
if (g_gametype.integer == GT_CTF) {
|
|
|
|
client->sess.sessionTeam = TEAM_SPECTATOR;
|
|
|
|
client->sess.savedTeam = TEAM_SPECTATOR;
|
|
|
|
client->sess.captain = TEAM_FREE;
|
|
|
|
client->sess.sub = TEAM_FREE;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
camera_state_load(client);
|
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
G_InitSessionData
|
|
|
|
|
|
|
|
Called on a first-time connect
|
|
|
|
================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void G_InitSessionData(gclient_t * client, char *userinfo)
|
|
|
|
{
|
|
|
|
clientSession_t *sess;
|
|
|
|
const char *value;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
sess = &client->sess;
|
|
|
|
|
2002-02-03 21:23:51 +00:00
|
|
|
//Slicer: init savedTeam also
|
|
|
|
|
2002-02-02 20:39:09 +00:00
|
|
|
sess->savedTeam = TEAM_SPECTATOR;
|
|
|
|
|
2002-05-05 15:51:16 +00:00
|
|
|
//Slicer: init Matchmode stuff
|
|
|
|
|
|
|
|
sess->captain = TEAM_FREE;
|
|
|
|
sess->sub = TEAM_FREE;
|
2002-08-23 14:25:05 +00:00
|
|
|
sess->referee = 0;
|
2002-10-21 21:00:39 +00:00
|
|
|
sess->refHear = qfalse;
|
|
|
|
sess->refReady = 0;
|
2002-05-05 15:51:16 +00:00
|
|
|
|
2002-02-25 19:41:53 +00:00
|
|
|
// JBravo: adding PERS_SAVEDTEAM
|
|
|
|
client->ps.persistant[PERS_SAVEDTEAM] = TEAM_SPECTATOR;
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
// initial team determination
|
2002-06-16 20:06:15 +00:00
|
|
|
if (g_gametype.integer >= GT_TEAM) {
|
2012-10-04 16:06:03 +00:00
|
|
|
if ( g_teamAutoJoin.integer && !(g_entities[ client - level.clients ].r.svFlags & SVF_BOT) ) {
|
2002-05-11 15:00:04 +00:00
|
|
|
if (g_gametype.integer == GT_TEAMPLAY) {
|
2002-06-16 20:06:15 +00:00
|
|
|
sess->savedTeam = PickTeam(-1);
|
2002-05-11 15:00:04 +00:00
|
|
|
client->ps.persistant[PERS_SAVEDTEAM] = sess->savedTeam;
|
2002-10-26 22:03:43 +00:00
|
|
|
} else if (g_gametype.integer == GT_CTF || g_gametype.integer == GT_TEAM) {
|
2002-08-21 07:00:07 +00:00
|
|
|
sess->savedTeam = PickTeam(-1);
|
|
|
|
client->ps.persistant[PERS_SAVEDTEAM] = sess->savedTeam;
|
|
|
|
sess->sessionTeam = sess->savedTeam;
|
2002-05-11 15:00:04 +00:00
|
|
|
} else
|
2002-06-16 20:06:15 +00:00
|
|
|
sess->sessionTeam = PickTeam(-1);
|
|
|
|
BroadcastTeamChange(client, -1);
|
2001-05-06 20:50:27 +00:00
|
|
|
} else {
|
|
|
|
// always spawn as spectator in team games
|
2002-06-16 20:06:15 +00:00
|
|
|
sess->sessionTeam = TEAM_SPECTATOR;
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-06-16 20:06:15 +00:00
|
|
|
value = Info_ValueForKey(userinfo, "team");
|
|
|
|
if (value[0] == 's') {
|
2001-05-06 20:50:27 +00:00
|
|
|
// a willing spectator, not a waiting-in-line
|
|
|
|
sess->sessionTeam = TEAM_SPECTATOR;
|
|
|
|
} else {
|
2002-06-16 20:06:15 +00:00
|
|
|
switch (g_gametype.integer) {
|
2001-05-06 20:50:27 +00:00
|
|
|
default:
|
|
|
|
case GT_FFA:
|
|
|
|
case GT_SINGLE_PLAYER:
|
2002-06-16 20:06:15 +00:00
|
|
|
if (g_maxGameClients.integer > 0 &&
|
|
|
|
level.numNonSpectatorClients >= g_maxGameClients.integer) {
|
2001-05-06 20:50:27 +00:00
|
|
|
sess->sessionTeam = TEAM_SPECTATOR;
|
|
|
|
} else {
|
|
|
|
sess->sessionTeam = TEAM_FREE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GT_TOURNAMENT:
|
|
|
|
// if the game is full, go into a waiting mode
|
2002-06-16 20:06:15 +00:00
|
|
|
if (level.numNonSpectatorClients >= 2) {
|
2001-05-06 20:50:27 +00:00
|
|
|
sess->sessionTeam = TEAM_SPECTATOR;
|
|
|
|
} else {
|
|
|
|
sess->sessionTeam = TEAM_FREE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sess->spectatorState = SPECTATOR_FREE;
|
2002-03-26 11:32:05 +00:00
|
|
|
client->specMode = SPECTATOR_FREE;
|
2001-05-06 20:50:27 +00:00
|
|
|
sess->spectatorTime = level.time;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
G_WriteClientSessionData(client);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
G_InitWorldSession
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void G_InitWorldSession(void)
|
|
|
|
{
|
|
|
|
char s[MAX_STRING_CHARS];
|
|
|
|
int gt;
|
|
|
|
|
|
|
|
trap_Cvar_VariableStringBuffer("session", s, sizeof(s));
|
|
|
|
gt = atoi(s);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// if the gametype changed since the last session, don't use any
|
|
|
|
// client sessions
|
2002-06-16 20:06:15 +00:00
|
|
|
if (g_gametype.integer != gt) {
|
2001-05-06 20:50:27 +00:00
|
|
|
level.newSession = qtrue;
|
2002-06-16 20:06:15 +00:00
|
|
|
G_Printf("Gametype changed, clearing session data.\n");
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
G_WriteSessionData
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void G_WriteSessionData(void)
|
|
|
|
{
|
|
|
|
int i;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_Cvar_Set("session", va("%i", g_gametype.integer));
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
for (i = 0; i < level.maxclients; i++) {
|
|
|
|
if (level.clients[i].pers.connected == CON_CONNECTED) {
|
|
|
|
G_WriteClientSessionData(&level.clients[i]);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|