summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/g_admin.c33
-rw-r--r--src/game/g_admin.h1
-rw-r--r--src/game/g_buildable.c2
-rw-r--r--src/game/g_cmds.c3
-rw-r--r--src/game/g_local.h1
-rw-r--r--src/game/g_main.c29
6 files changed, 64 insertions, 5 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 99975c63..a7ec5587 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -144,6 +144,11 @@ g_admin_cmd_t g_admin_cmds[ ] =
"pass a vote currently taking place",
"(^5a|h^7)"
},
+
+ {"pause", G_admin_pause, "pause",
+ "Pause (or unpause) the game.",
+ ""
+ },
{"putteam", G_admin_putteam, "putteam",
"move a player to a specified team",
@@ -2913,6 +2918,34 @@ qboolean G_admin_builder( gentity_t *ent )
return qtrue;
}
+qboolean G_admin_pause( gentity_t *ent )
+{
+ if( !level.pausedTime )
+ {
+ AP( va( "print \"^3!pause: ^7%s^7 paused the game.\n\"",
+ ( ent ) ? ent->client->pers.netname : "console" ) );
+ level.pausedTime = 1;
+ trap_SendServerCommand( -1, "cp \"The game has been paused. Please wait.\"" );
+ }
+ else
+ {
+ // Prevent accidental pause->unpause race conditions by two admins
+ if( level.pausedTime < 1000 )
+ {
+ ADMP( "^3pause: ^7Unpausing so soon assumed accidental and ignored.\n" );
+ return qfalse;
+ }
+
+ AP( va( "print \"^3!pause: ^7%s^7 unpaused the game (Paused for %d msec) \n\"",
+ ( ent ) ? ent->client->pers.netname : "console",level.pausedTime ) );
+ trap_SendServerCommand( -1, "cp \"The game has been unpaused!\"" );
+
+ level.pausedTime = 0;
+ }
+
+ return qtrue;
+}
+
static char *fates[] =
{
"^2built^7",
diff --git a/src/game/g_admin.h b/src/game/g_admin.h
index d6b587a1..0ff45796 100644
--- a/src/game/g_admin.h
+++ b/src/game/g_admin.h
@@ -171,6 +171,7 @@ qboolean G_admin_restart( gentity_t *ent );
qboolean G_admin_nextmap( gentity_t *ent );
qboolean G_admin_namelog( gentity_t *ent );
qboolean G_admin_lock( gentity_t *ent );
+qboolean G_admin_pause( gentity_t *ent );
qboolean G_admin_builder( gentity_t *ent );
qboolean G_admin_buildlog( gentity_t *ent );
qboolean G_admin_revert( gentity_t *ent );
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index e0a2e93e..da21798d 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -2660,7 +2660,7 @@ void G_BuildableThink( gentity_t *ent, int msec )
int buildTime = BG_Buildable( ent->s.modelindex )->buildTime;
//toggle spawned flag for buildables
- if( !ent->spawned && ent->health > 0 )
+ if( !ent->spawned && ent->health > 0 && !level.pausedTime )
{
if( ent->buildTime + buildTime < level.time )
{
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index c6eb69fe..49bbe3f8 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -3089,7 +3089,8 @@ void ClientCommand( int clientNum )
// do tests here to reduce the amount of repeated code
- if( !( command->cmdFlags & CMD_INTERMISSION ) && level.intermissiontime )
+ if( !( command->cmdFlags & CMD_INTERMISSION ) &&
+ ( level.intermissiontime || level.pausedTime ) )
return;
if( command->cmdFlags & CMD_CHEAT && !g_cheats.integer )
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 81edb7c3..bd6ac4ba 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -649,6 +649,7 @@ typedef struct
qboolean uncondHumanWin;
qboolean alienTeamLocked;
qboolean humanTeamLocked;
+ int pausedTime;
int unlaggedIndex;
int unlaggedTimes[ MAX_UNLAGGED_MARKERS ];
diff --git a/src/game/g_main.c b/src/game/g_main.c
index ae9486a3..6bdbdea9 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -2275,14 +2275,37 @@ Advances the non-player objects in the world
*/
void G_RunFrame( int levelTime )
{
- int i;
- gentity_t *ent;
- int msec;
+ int i;
+ gentity_t *ent;
+ int msec;
+ static int ptime3000 = 0;
// if we are waiting for the level to restart, do nothing
if( level.restarted )
return;
+ if( level.pausedTime )
+ {
+ msec = levelTime - level.time - level.pausedTime;
+ level.pausedTime = levelTime - level.time;
+
+ ptime3000 += msec;
+ while( ptime3000 > 3000 )
+ {
+ ptime3000 -= 3000;
+ trap_SendServerCommand( -1, "cp \"The game has been paused. Please wait.\"" );
+ }
+
+ // Prevents clients from getting lagged-out messages
+ for( i = 0; i < level.maxclients; i++ )
+ {
+ if( level.clients[ i ].pers.connected == CON_CONNECTED )
+ level.clients[ i ].ps.commandTime = levelTime;
+ }
+
+ return;
+ }
+
level.framenum++;
level.previousTime = level.time;
level.time = levelTime;