summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2004-03-18 03:18:37 +0000
committerTim Angus <tim@ngus.net>2004-03-18 03:18:37 +0000
commit9582bcfdfcce0aa7132917c8403c5f12d2be3e79 (patch)
tree1dee3afb7d4c368eead06312400b2a283ad5b9f3 /src
parent62f7a4f9db988a522a534224f14127afb9c49ba5 (diff)
* Possibly fixed the scoreboard not updating
* Possibly fixed the spectator scrolling not working * Spawn queue position is now displayed when queued * Pressing BUTTON_ATTACK removes the client from the spawn queue
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_consolecmds.c6
-rw-r--r--src/cgame/cg_draw.c29
-rw-r--r--src/cgame/cg_local.h2
-rw-r--r--src/cgame/cg_main.c4
-rw-r--r--src/cgame/cg_servercmds.c15
-rw-r--r--src/cgame/cg_weapons.c4
-rw-r--r--src/game/bg_public.h7
-rw-r--r--src/game/g_active.c33
-rw-r--r--src/game/g_buildable.c2
-rw-r--r--src/game/g_cmds.c50
-rw-r--r--src/game/g_main.c33
11 files changed, 155 insertions, 30 deletions
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c
index 468cdeac..3e654c90 100644
--- a/src/cgame/cg_consolecmds.c
+++ b/src/cgame/cg_consolecmds.c
@@ -83,12 +83,16 @@ static void CG_ScoresDown_f( void )
// the scores are more than two seconds out of data,
// so request new ones
cg.scoresRequestTime = cg.time;
- trap_SendClientCommand( "score" );
+ //TA: added \n SendClientCommand doesn't call flush( )?
+ trap_SendClientCommand( "score\n" );
// leave the current scores up if they were already
// displayed, but if this is the first hit, clear them out
if( !cg.showScores )
{
+ if( cg_debugRandom.integer )
+ CG_Printf( "CG_ScoresDown_f: scores out of date\n" );
+
cg.showScores = qtrue;
cg.numScores = 0;
}
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 2158379c..4608893f 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -2874,6 +2874,34 @@ static qboolean CG_DrawFollow( void )
return qtrue;
}
+/*
+=================
+CG_DrawQueue
+=================
+*/
+static qboolean CG_DrawQueue( void )
+{
+ float w;
+ vec4_t color;
+ char buffer[ MAX_STRING_CHARS ];
+
+ if( !( cg.snap->ps.pm_flags & PMF_QUEUED ) )
+ return qfalse;
+
+ color[ 0 ] = 1;
+ color[ 1 ] = 1;
+ color[ 2 ] = 1;
+ color[ 3 ] = 1;
+
+ Com_sprintf( buffer, MAX_STRING_CHARS, "You are in position %d of the spawn queue.",
+ cg.snap->ps.persistant[ PERS_QUEUEPOS ] + 1 );
+
+ w = CG_Text_Width( buffer, 0.7f, 0 );
+ CG_Text_Paint( 320 - w / 2, 400, 0.7f, color, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED );
+
+ return qtrue;
+}
+
//==================================================================================
#define SPECTATOR_STRING "SPECTATOR"
@@ -2932,6 +2960,7 @@ static void CG_Draw2D( void )
CG_DrawVote( );
CG_DrawTeamVote( );
CG_DrawFollow( );
+ CG_DrawQueue( );
// don't draw center string if scoreboard is up
cg.scoreBoardShowing = CG_DrawScoreboard( );
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 1f1fe409..c3fd240e 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1442,6 +1442,8 @@ extern vmCvar_t ui_voteActive;
extern vmCvar_t ui_alienTeamVoteActive;
extern vmCvar_t ui_humanTeamVoteActive;
+extern vmCvar_t cg_debugRandom;
+
//
// cg_main.c
//
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 1b11f17e..725cc195 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -212,6 +212,8 @@ vmCvar_t ui_voteActive;
vmCvar_t ui_alienTeamVoteActive;
vmCvar_t ui_humanTeamVoteActive;
+vmCvar_t cg_debugRandom;
+
typedef struct
{
@@ -313,6 +315,8 @@ static cvarTable_t cvarTable[ ] =
{ &ui_humanTeamVoteActive, "ui_humanTeamVoteActive", "0", 0 },
{ &ui_alienTeamVoteActive, "ui_alienTeamVoteActive", "0", 0 },
+ { &cg_debugRandom, "cg_debugRandom", "0", 0 },
+
// the following variables are created in other parts of the system,
// but we also reference them here
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 187c6395..da0ef801 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -39,6 +39,9 @@ static void CG_ParseScores( void )
memset( cg.scores, 0, sizeof( cg.scores ) );
+ if( cg_debugRandom.integer )
+ CG_Printf( "cg.numScores: %d\n", cg.numScores );
+
for( i = 0; i < cg.numScores; i++ )
{
//
@@ -575,6 +578,18 @@ void CG_Menu( int menu )
case MN_H_BUILD: trap_SendConsoleCommand( "menu tremulous_humanbuild\n" ); break;
case MN_H_ARMOURY: trap_SendConsoleCommand( "menu tremulous_humanarmoury\n" ); break;
+ case MN_A_TEAMFULL:
+ trap_Cvar_Set( "ui_dialog", "The alien team has too many players. Please wait until "
+ "slots become available or join the human team." );
+ trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" );
+ break;
+
+ case MN_H_TEAMFULL:
+ trap_Cvar_Set( "ui_dialog", "The human team has too many players. Please wait until "
+ "slots become available or join the alien team." );
+ trap_SendConsoleCommand( "menu tremulous_human_dialog\n" );
+ break;
+
case MN_H_NOROOM:
if( !cg_disableBuildWarnings.integer )
{
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index 4a24f12c..e01339db 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -1515,7 +1515,7 @@ void CG_NextWeapon_f( void )
if( cg.snap->ps.pm_flags & PMF_FOLLOW )
{
- trap_SendClientCommand( "followprev" );
+ trap_SendClientCommand( "followprev\n" );
return;
}
@@ -1559,7 +1559,7 @@ void CG_PrevWeapon_f( void )
if( cg.snap->ps.pm_flags & PMF_FOLLOW )
{
- trap_SendClientCommand( "follownext" );
+ trap_SendClientCommand( "follownext\n" );
return;
}
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 6a119b27..ff3ecf62 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -136,7 +136,7 @@ typedef enum
#define PMF_USE_ITEM_HELD 1024
#define PMF_WEAPON_RELOAD 2048 //TA: force a weapon switch
#define PMF_FOLLOW 4096 // spectate following another player
-#define PMF_SCOREBOARD 8192 // spectate as a scoreboard
+#define PMF_QUEUED 8192 //TA: player is queued
#define PMF_TIME_WALLJUMP 16384 //TA: for limiting wall jumping
#define PMF_CHARGE 32768 //TA: keep track of pouncing
#define PMF_WEAPON_SWITCH 65536 //TA: force a weapon switch
@@ -256,7 +256,8 @@ typedef enum
//TA:
PERS_STATE,
PERS_CREDIT, //TA: human credit
- PERS_BANK //TA: human credit in the bank
+ PERS_BANK, //TA: human credit in the bank
+ PERS_QUEUEPOS //TA: position in the spawn queue
} persEnum_t;
#define PS_WALLCLIMBINGFOLLOW 0x00000001
@@ -562,6 +563,8 @@ typedef enum
typedef enum
{
MN_TEAM,
+ MN_A_TEAMFULL,
+ MN_H_TEAMFULL,
//alien stuff
MN_A_CLASS,
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 9a1e625c..aeb69cd5 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -348,7 +348,18 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd )
if( ( client->buttons & BUTTON_ATTACK ) && !( client->oldbuttons & BUTTON_ATTACK ) )
{
- if( client->pers.classSelection == PCL_NONE )
+ //if waiting in a queue remove from the queue
+ if( client->ps.pm_flags & PMF_QUEUED )
+ {
+ if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
+ G_RemoveFromSpawnQueue( &level.alienSpawnQueue, client->ps.clientNum );
+ else if( client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
+ G_RemoveFromSpawnQueue( &level.humanSpawnQueue, client->ps.clientNum );
+
+ client->pers.classSelection = PCL_NONE;
+ client->ps.stats[ STAT_PCLASS ] = PCL_NONE;
+ }
+ else if( client->pers.classSelection == PCL_NONE )
{
if( client->pers.teamSelection == PTE_NONE )
G_TriggerMenu( client->ps.clientNum, MN_TEAM );
@@ -975,6 +986,21 @@ void ClientThink_real( gentity_t *ent )
}
}
+ //set the queue position for the client side
+ if( client->ps.pm_flags & PMF_QUEUED )
+ {
+ if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
+ {
+ client->ps.persistant[ PERS_QUEUEPOS ] =
+ G_GetPosInSpawnQueue( &level.alienSpawnQueue, client->ps.clientNum );
+ }
+ else if( client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
+ {
+ client->ps.persistant[ PERS_QUEUEPOS ] =
+ G_GetPosInSpawnQueue( &level.humanSpawnQueue, client->ps.clientNum );
+ }
+ }
+
// set speed
client->ps.speed = g_speed.value * BG_FindSpeedForClass( client->ps.stats[ STAT_PCLASS ] );
@@ -1319,11 +1345,6 @@ void SpectatorClientEndFrame( gentity_t *ent )
}
}
}
-
- if( ent->client->sess.spectatorState == SPECTATOR_SCOREBOARD )
- ent->client->ps.pm_flags |= PMF_SCOREBOARD;
- else
- ent->client->ps.pm_flags &= ~PMF_SCOREBOARD;
}
/*
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index fba8a54a..c35e64ec 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -1636,7 +1636,7 @@ void HMedistat_Think( gentity_t *self )
self->active = qfalse;
}
- else //heal!
+ else if( self->enemy ) //heal!
self->enemy->health++;
}
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 8630329b..5e7f4138 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -431,6 +431,12 @@ void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam )
if( oldTeam != newTeam )
{
+ //if the client is in a queue make sure they are removed from it before changing
+ if( oldTeam == PTE_ALIENS )
+ G_RemoveFromSpawnQueue( &level.alienSpawnQueue, ent->client->ps.clientNum );
+ else if( oldTeam == PTE_HUMANS )
+ G_RemoveFromSpawnQueue( &level.humanSpawnQueue, ent->client->ps.clientNum );
+
level.bankCredits[ ent->client->ps.clientNum ] = 0;
ent->client->ps.persistant[ PERS_CREDIT ] = 0;
ent->client->pers.classSelection = PCL_NONE;
@@ -465,8 +471,7 @@ void Cmd_Team_f( gentity_t *ent )
{
if( g_teamForceBalance.integer && level.numAlienClients > level.numHumanClients )
{
- //FIXME: pleasant dialog
- trap_SendServerCommand( ent-g_entities, "print \"The alien team has too many players\n\"" );
+ G_TriggerMenu( ent->client->ps.clientNum, MN_A_TEAMFULL );
return;
}
@@ -476,8 +481,7 @@ void Cmd_Team_f( gentity_t *ent )
{
if( g_teamForceBalance.integer && level.numHumanClients > level.numAlienClients )
{
- //FIXME: pleasant dialog
- trap_SendServerCommand( ent-g_entities, "print \"The human team has too many players\n\"" );
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_TEAMFULL );
return;
}
@@ -495,7 +499,8 @@ void Cmd_Team_f( gentity_t *ent )
G_ChangeTeam( ent, team );
- //FIXME: put some team change broadcast code here.
+ if( team == PTE_ALIENS || team == PTE_HUMANS )
+ trap_SendServerCommand( -1, va( "print \"%s joined the %s.\n\"", ent->client->pers.netname, s ) );
}
@@ -1611,6 +1616,22 @@ void Cmd_Sell_f( gentity_t *ent )
{
BG_removeItem( upgrade, ent->client->ps.stats );
+ if( upgrade == UP_BATTPACK )
+ {
+ int j;
+
+ //remove energy
+ for( j = WP_NONE; j < WP_NUM_WEAPONS; j++ )
+ {
+ if( BG_gotWeapon( j, ent->client->ps.stats ) &&
+ BG_FindUsesEnergyForWeapon( j ) &&
+ !BG_FindInfinteAmmoForWeapon( j ) )
+ {
+ BG_packAmmoArray( j, ent->client->ps.ammo, ent->client->ps.powerups, 0, 0, 0 );
+ }
+ }
+ }
+
//add to funds
ent->client->ps.persistant[ PERS_CREDIT ] += (short)BG_FindPriceForUpgrade( upgrade );
}
@@ -1649,6 +1670,22 @@ void Cmd_Sell_f( gentity_t *ent )
{
BG_removeItem( i, ent->client->ps.stats );
+ if( i == UP_BATTPACK )
+ {
+ int j;
+
+ //remove energy
+ for( j = WP_NONE; j < WP_NUM_WEAPONS; j++ )
+ {
+ if( BG_gotWeapon( j, ent->client->ps.stats ) &&
+ BG_FindUsesEnergyForWeapon( j ) &&
+ !BG_FindInfinteAmmoForWeapon( j ) )
+ {
+ BG_packAmmoArray( j, ent->client->ps.ammo, ent->client->ps.powerups, 0, 0, 0 );
+ }
+ }
+ }
+
//add to funds
ent->client->ps.persistant[ PERS_CREDIT ] += (short)BG_FindPriceForUpgrade( i );
}
@@ -2022,7 +2059,8 @@ void ClientCommand( int clientNum )
// ignore all other commands when at intermission
if( level.intermissiontime )
{
- Cmd_Say_f( ent, qfalse, qtrue );
+ //TA: prevent menu babble at the end of games
+ /*Cmd_Say_f( ent, qfalse, qtrue );*/
return;
}
diff --git a/src/game/g_main.c b/src/game/g_main.c
index fcbeb7cf..7b45b28e 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -452,14 +452,16 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
{
int i;
- G_Printf( "------- Game Initialization -------\n" );
- G_Printf( "gamename: %s\n", GAMEVERSION );
- G_Printf( "gamedate: %s\n", __DATE__ );
-
srand( randomSeed );
G_RegisterCvars( );
+ //TA: moved after G_RegisterCvars since G_Printf
+ // now depends on the value of g_dedicated
+ G_Printf( "------- Game Initialization -------\n" );
+ G_Printf( "gamename: %s\n", GAMEVERSION );
+ G_Printf( "gamedate: %s\n", __DATE__ );
+
G_ProcessIPBans( );
G_InitMemory( );
@@ -676,8 +678,14 @@ Initialise a spawn queue
*/
void G_InitSpawnQueue( spawnQueue_t *sq )
{
+ int i;
+
sq->back = sq->front = 0;
sq->back = QUEUE_MINUS1( sq->back );
+
+ //0 is a valid clientNum, so use something else
+ for( i = 0; i < MAX_CLIENTS; i++ )
+ sq->clients[ i ] = -1;
}
/*
@@ -689,10 +697,7 @@ Return tha length of a spawn queue
*/
int G_GetSpawnQueueLength( spawnQueue_t *sq )
{
-/* if( sq->back < sq->front )
- return ( sq->back + MAX_CLIENTS - sq->front + 1 ) % MAX_CLIENTS;
- else*/
- return ( sq->back - sq->front + 1 ) % MAX_CLIENTS;
+ return ( sq->back - sq->front + 1 ) % MAX_CLIENTS;
}
/*
@@ -709,6 +714,7 @@ int G_PopSpawnQueue( spawnQueue_t *sq )
if( G_GetSpawnQueueLength( sq ) > 0 )
{
sq->front = QUEUE_PLUS1( sq->front );
+ g_entities[ sq->clients[ popee ] ].client->ps.pm_flags &= ~PMF_QUEUED;
return sq->clients[ popee ];
}
else
@@ -726,6 +732,8 @@ void G_PushSpawnQueue( spawnQueue_t *sq, int clientNum )
{
sq->back = QUEUE_PLUS1( sq->back );
sq->clients[ sq->back ] = clientNum;
+
+ g_entities[ clientNum ].client->ps.pm_flags |= PMF_QUEUED;
}
/*
@@ -743,22 +751,23 @@ qboolean G_RemoveFromSpawnQueue( spawnQueue_t *sq, int clientNum )
{
if( sq->clients[ i ] == clientNum )
{
- //and this kids, is why it would have
+ //and this kids is why it would have
//been better to use an LL for internal
//representation
do
{
sq->clients[ i ] = sq->clients[ QUEUE_PLUS1( i ) ];
- i = QUEUE_PLUS1( 1 );
+ i = QUEUE_PLUS1( i );
} while( i != sq->back );
sq->back = QUEUE_MINUS1( sq->back );
+ g_entities[ clientNum ].client->ps.pm_flags &= ~PMF_QUEUED;
return qtrue;
}
- i = QUEUE_PLUS1( 1 );
+ i = QUEUE_PLUS1( i );
} while( i != QUEUE_PLUS1( sq->back ) );
return qfalse;
@@ -785,7 +794,7 @@ int G_GetPosInSpawnQueue( spawnQueue_t *sq, int clientNum )
return i - sq->front + 1;
}
- i = QUEUE_PLUS1( 1 );
+ i = QUEUE_PLUS1( i );
} while( i != QUEUE_PLUS1( sq->back ) );
return -1;