mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2025-01-18 21:51:37 +00:00
Fix player queueing for tournament play (#4939)
This commit is contained in:
parent
806a849bf2
commit
31ec563999
4 changed files with 38 additions and 11 deletions
|
@ -583,10 +583,10 @@ void SetTeam( gentity_t *ent, char *s ) {
|
||||||
player_die (ent, ent, ent, 100000, MOD_SUICIDE);
|
player_die (ent, ent, ent, 100000, MOD_SUICIDE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// they go to the end of the line for tournements
|
// they go to the end of the line for tournements
|
||||||
if ( team == TEAM_SPECTATOR ) {
|
if(team == TEAM_SPECTATOR && oldTeam != team)
|
||||||
client->sess.spectatorTime = level.time;
|
AddTournamentQueue(client);
|
||||||
}
|
|
||||||
|
|
||||||
client->sess.sessionTeam = team;
|
client->sess.sessionTeam = team;
|
||||||
client->sess.spectatorState = specState;
|
client->sess.spectatorState = specState;
|
||||||
|
|
|
@ -225,7 +225,7 @@ typedef struct {
|
||||||
// MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
|
// MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
|
||||||
typedef struct {
|
typedef struct {
|
||||||
team_t sessionTeam;
|
team_t sessionTeam;
|
||||||
int spectatorTime; // for determining next-in-line to play
|
int spectatorNum; // for determining next-in-line to play
|
||||||
spectatorState_t spectatorState;
|
spectatorState_t spectatorState;
|
||||||
int spectatorClient; // for chasecam and follow mode
|
int spectatorClient; // for chasecam and follow mode
|
||||||
int wins, losses; // tournament stats
|
int wins, losses; // tournament stats
|
||||||
|
@ -623,6 +623,7 @@ void FindIntermissionPoint( void );
|
||||||
void SetLeader(int team, int client);
|
void SetLeader(int team, int client);
|
||||||
void CheckTeamLeader( int team );
|
void CheckTeamLeader( int team );
|
||||||
void G_RunThink (gentity_t *ent);
|
void G_RunThink (gentity_t *ent);
|
||||||
|
void AddTournamentQueue(gclient_t *client);
|
||||||
void QDECL G_LogPrintf( const char *fmt, ... );
|
void QDECL G_LogPrintf( const char *fmt, ... );
|
||||||
void SendScoreboardMessageToAllClients( void );
|
void SendScoreboardMessageToAllClients( void );
|
||||||
void QDECL G_Printf( const char *fmt, ... );
|
void QDECL G_Printf( const char *fmt, ... );
|
||||||
|
|
|
@ -602,9 +602,8 @@ void AddTournamentPlayer( void ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !nextInLine || client->sess.spectatorTime < nextInLine->sess.spectatorTime ) {
|
if(!nextInLine || client->sess.spectatorNum > nextInLine->sess.spectatorNum)
|
||||||
nextInLine = client;
|
nextInLine = client;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !nextInLine ) {
|
if ( !nextInLine ) {
|
||||||
|
@ -617,6 +616,33 @@ void AddTournamentPlayer( void ) {
|
||||||
SetTeam( &g_entities[ nextInLine - level.clients ], "f" );
|
SetTeam( &g_entities[ nextInLine - level.clients ], "f" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=======================
|
||||||
|
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
|
RemoveTournamentLoser
|
||||||
|
@ -716,10 +742,10 @@ int QDECL SortRanks( const void *a, const void *b ) {
|
||||||
|
|
||||||
// then spectators
|
// then spectators
|
||||||
if ( ca->sess.sessionTeam == TEAM_SPECTATOR && cb->sess.sessionTeam == TEAM_SPECTATOR ) {
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
if ( ca->sess.spectatorTime > cb->sess.spectatorTime ) {
|
if ( ca->sess.spectatorNum < cb->sess.spectatorNum ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -46,7 +46,7 @@ void G_WriteClientSessionData( gclient_t *client ) {
|
||||||
|
|
||||||
s = va("%i %i %i %i %i %i %i",
|
s = va("%i %i %i %i %i %i %i",
|
||||||
client->sess.sessionTeam,
|
client->sess.sessionTeam,
|
||||||
client->sess.spectatorTime,
|
client->sess.spectatorNum,
|
||||||
client->sess.spectatorState,
|
client->sess.spectatorState,
|
||||||
client->sess.spectatorClient,
|
client->sess.spectatorClient,
|
||||||
client->sess.wins,
|
client->sess.wins,
|
||||||
|
@ -78,7 +78,7 @@ void G_ReadSessionData( gclient_t *client ) {
|
||||||
|
|
||||||
sscanf( s, "%i %i %i %i %i %i %i",
|
sscanf( s, "%i %i %i %i %i %i %i",
|
||||||
&sessionTeam,
|
&sessionTeam,
|
||||||
&client->sess.spectatorTime,
|
&client->sess.spectatorNum,
|
||||||
&spectatorState,
|
&spectatorState,
|
||||||
&client->sess.spectatorClient,
|
&client->sess.spectatorClient,
|
||||||
&client->sess.wins,
|
&client->sess.wins,
|
||||||
|
@ -144,7 +144,7 @@ void G_InitSessionData( gclient_t *client, char *userinfo ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sess->spectatorState = SPECTATOR_FREE;
|
sess->spectatorState = SPECTATOR_FREE;
|
||||||
sess->spectatorTime = level.time;
|
AddTournamentQueue(client);
|
||||||
|
|
||||||
G_WriteClientSessionData( client );
|
G_WriteClientSessionData( client );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue