diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2010-12-08 20:02:11 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:17:47 +0000 |
commit | 733c839dc1ed0524c669ee0a2f366f9c0967c10a (patch) | |
tree | 57bced0bc838ac081c9bf6d40c1da873d330de5f /src | |
parent | 419fef4d61933c1b4cb01d3bfe3f9a62496bec7b (diff) |
* (bug 4815) Add /pause admin command
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_admin.c | 33 | ||||
-rw-r--r-- | src/game/g_admin.h | 1 | ||||
-rw-r--r-- | src/game/g_buildable.c | 2 | ||||
-rw-r--r-- | src/game/g_cmds.c | 3 | ||||
-rw-r--r-- | src/game/g_local.h | 1 | ||||
-rw-r--r-- | src/game/g_main.c | 29 |
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; |