summaryrefslogtreecommitdiff
path: root/src/game
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/game
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/game')
-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
5 files changed, 98 insertions, 27 deletions
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;