[quake3-commits] r1939 - trunk/code/game

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Apr 7 19:41:32 EDT 2011


Author: thilo
Date: 2011-04-07 19:41:32 -0400 (Thu, 07 Apr 2011)
New Revision: 1939

Modified:
   trunk/code/game/g_cmds.c
   trunk/code/game/g_local.h
   trunk/code/game/g_main.c
   trunk/code/game/g_session.c
Log:
Fix player queueing for tournament play (#4939)


Modified: trunk/code/game/g_cmds.c
===================================================================
--- trunk/code/game/g_cmds.c	2011-03-30 22:23:58 UTC (rev 1938)
+++ trunk/code/game/g_cmds.c	2011-04-07 23:41:32 UTC (rev 1939)
@@ -583,10 +583,10 @@
 		player_die (ent, ent, ent, 100000, MOD_SUICIDE);
 
 	}
+
 	// they go to the end of the line for tournements
-	if ( team == TEAM_SPECTATOR ) {
-		client->sess.spectatorTime = level.time;
-	}
+	if(team == TEAM_SPECTATOR && oldTeam != team)
+		AddTournamentQueue(client);
 
 	client->sess.sessionTeam = team;
 	client->sess.spectatorState = specState;

Modified: trunk/code/game/g_local.h
===================================================================
--- trunk/code/game/g_local.h	2011-03-30 22:23:58 UTC (rev 1938)
+++ trunk/code/game/g_local.h	2011-04-07 23:41:32 UTC (rev 1939)
@@ -225,7 +225,7 @@
 // MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
 typedef struct {
 	team_t		sessionTeam;
-	int			spectatorTime;		// for determining next-in-line to play
+	int			spectatorNum;		// for determining next-in-line to play
 	spectatorState_t	spectatorState;
 	int			spectatorClient;	// for chasecam and follow mode
 	int			wins, losses;		// tournament stats
@@ -623,6 +623,7 @@
 void SetLeader(int team, int client);
 void CheckTeamLeader( int team );
 void G_RunThink (gentity_t *ent);
+void AddTournamentQueue(gclient_t *client);
 void QDECL G_LogPrintf( const char *fmt, ... );
 void SendScoreboardMessageToAllClients( void );
 void QDECL G_Printf( const char *fmt, ... );

Modified: trunk/code/game/g_main.c
===================================================================
--- trunk/code/game/g_main.c	2011-03-30 22:23:58 UTC (rev 1938)
+++ trunk/code/game/g_main.c	2011-04-07 23:41:32 UTC (rev 1939)
@@ -602,9 +602,8 @@
 			continue;
 		}
 
-		if ( !nextInLine || client->sess.spectatorTime < nextInLine->sess.spectatorTime ) {
+		if(!nextInLine || client->sess.spectatorNum > nextInLine->sess.spectatorNum)
 			nextInLine = client;
-		}
 	}
 
 	if ( !nextInLine ) {
@@ -619,6 +618,33 @@
 
 /*
 =======================
+RequeueTournamentLoser
+
+Add client to end of tournament queue
+=======================
+*/
+
+void AddTournamentQueue(gclient_t *client)
+{
+	int index;
+	gclient_t *curclient;
+	
+	for(index = 0; index < level.maxclients; index++)
+	{
+		curclient = &level.clients[index];
+		
+		if(curclient->pers.connected != CON_DISCONNECTED)
+		{
+			if(curclient == client)
+				curclient->sess.spectatorNum = 0;
+			else if(curclient->sess.sessionTeam == TEAM_SPECTATOR)
+				curclient->sess.spectatorNum++;
+		}
+	}
+}
+
+/*
+=======================
 RemoveTournamentLoser
 
 Make the loser a spectator at the back of the line
@@ -716,10 +742,10 @@
 
 	// then spectators
 	if ( ca->sess.sessionTeam == TEAM_SPECTATOR && cb->sess.sessionTeam == TEAM_SPECTATOR ) {
-		if ( ca->sess.spectatorTime < cb->sess.spectatorTime ) {
+		if ( ca->sess.spectatorNum > cb->sess.spectatorNum ) {
 			return -1;
 		}
-		if ( ca->sess.spectatorTime > cb->sess.spectatorTime ) {
+		if ( ca->sess.spectatorNum < cb->sess.spectatorNum ) {
 			return 1;
 		}
 		return 0;

Modified: trunk/code/game/g_session.c
===================================================================
--- trunk/code/game/g_session.c	2011-03-30 22:23:58 UTC (rev 1938)
+++ trunk/code/game/g_session.c	2011-04-07 23:41:32 UTC (rev 1939)
@@ -46,7 +46,7 @@
 
 	s = va("%i %i %i %i %i %i %i", 
 		client->sess.sessionTeam,
-		client->sess.spectatorTime,
+		client->sess.spectatorNum,
 		client->sess.spectatorState,
 		client->sess.spectatorClient,
 		client->sess.wins,
@@ -78,7 +78,7 @@
 
 	sscanf( s, "%i %i %i %i %i %i %i",
 		&sessionTeam,
-		&client->sess.spectatorTime,
+		&client->sess.spectatorNum,
 		&spectatorState,
 		&client->sess.spectatorClient,
 		&client->sess.wins,
@@ -144,7 +144,7 @@
 	}
 
 	sess->spectatorState = SPECTATOR_FREE;
-	sess->spectatorTime = level.time;
+	AddTournamentQueue(client);
 
 	G_WriteClientSessionData( client );
 }



More information about the quake3-commits mailing list