Permalink
Browse files

added unpause countdown. Closes #1365

  • Loading branch information...
oy committed Jul 13, 2015
1 parent 205dbce commit 56e366a639dee74080b22307adb5d3ad9f3510ea
@@ -68,6 +68,18 @@ void CHud::RenderPauseNotification()
float FontSize = 20.0f;
float w = TextRender()->TextWidth(0, FontSize,pText, -1);
TextRender()->Text(0, 150.0f*Graphics()->ScreenAspect()+-w/2.0f, 50.0f, FontSize, pText, -1);
if(m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer)
{
char Buf[256];
int Seconds = m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer/SERVER_TICK_SPEED;
if(Seconds < 5)
str_format(Buf, sizeof(Buf), "%d.%d", Seconds, (m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer*10/SERVER_TICK_SPEED)%10);
else
str_format(Buf, sizeof(Buf), "%d", Seconds);
w = TextRender()->TextWidth(0, FontSize, Buf, -1);
TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 75, FontSize, Buf, -1);
}
}
}
@@ -240,7 +252,7 @@ void CHud::RenderScoreHud()
void CHud::RenderWarmupTimer()
{
// render warmup timer
if(m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer)
if(!(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED) && m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer)
{
char Buf[256];
float FontSize = 20.0f;
@@ -1067,11 +1067,7 @@ void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData)
void CGameContext::ConPause(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(pSelf->m_pController->IsGameOver())
return;
pSelf->m_World.m_Paused ^= 1;
pSelf->m_pController->TogglePause();
}
void CGameContext::ConChangeMap(IConsole::IResult *pResult, void *pUserData)
@@ -18,6 +18,7 @@ IGameController::IGameController(class CGameContext *pGameServer)
//
DoWarmup(g_Config.m_SvWarmup);
m_UnpauseTimer = 0;
m_GameOverTick = -1;
m_SuddenDeath = 0;
m_RoundStartTick = Server()->Tick();
@@ -376,6 +377,30 @@ void IGameController::DoWarmup(int Seconds)
m_Warmup = Seconds*Server()->TickSpeed();
}
void IGameController::TogglePause()
{
if(IsGameOver())
return;
if(GameServer()->m_World.m_Paused)
{
// unpause
if(g_Config.m_SvUnpauseTimer > 0)
m_UnpauseTimer = g_Config.m_SvUnpauseTimer*Server()->TickSpeed();
else
{
GameServer()->m_World.m_Paused = false;
m_UnpauseTimer = 0;
}
}
else
{
// pause
GameServer()->m_World.m_Paused = true;
m_UnpauseTimer = 0;
}
}
bool IGameController::IsFriendlyFire(int ClientID1, int ClientID2)
{
if(ClientID1 == ClientID2)
@@ -412,7 +437,7 @@ bool IGameController::CanBeMovedOnBalance(int ClientID)
void IGameController::Tick()
{
// do warmup
if(m_Warmup)
if(!GameServer()->m_World.m_Paused && m_Warmup)
{
m_Warmup--;
if(!m_Warmup)
@@ -429,6 +454,12 @@ void IGameController::Tick()
m_RoundCount++;
}
}
else if(GameServer()->m_World.m_Paused && m_UnpauseTimer)
{
--m_UnpauseTimer;
if(!m_UnpauseTimer)
GameServer()->m_World.m_Paused = false;
}
// game is Paused
if(GameServer()->m_World.m_Paused)
@@ -561,7 +592,7 @@ void IGameController::Snap(int SnappingClient)
if(GameServer()->m_World.m_Paused)
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_PAUSED;
pGameInfoObj->m_RoundStartTick = m_RoundStartTick;
pGameInfoObj->m_WarmupTimer = m_Warmup;
pGameInfoObj->m_WarmupTimer = GameServer()->m_World.m_Paused ? m_UnpauseTimer : m_Warmup;
pGameInfoObj->m_ScoreLimit = g_Config.m_SvScorelimit;
pGameInfoObj->m_TimeLimit = g_Config.m_SvTimelimit;
@@ -54,6 +54,7 @@ class IGameController
int m_aTeamscore[2];
int m_Warmup;
int m_UnpauseTimer;
int m_RoundCount;
int m_GameFlags;
@@ -72,6 +73,7 @@ class IGameController
virtual void DoWincheck();
void DoWarmup(int Seconds);
void TogglePause();
void StartRound();
void EndRound();
View
@@ -57,6 +57,7 @@ MACRO_CONFIG_INT(GfxNoclip, gfx_noclip, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "D
// server
MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, 0, 0, CFGFLAG_SERVER, "Number of seconds to do warmup before round starts")
MACRO_CONFIG_INT(SvUnpauseTimer, sv_unpause_timer, 0, 0, 0, CFGFLAG_SERVER, "Number of seconds till the game continues")
MACRO_CONFIG_STR(SvMotd, sv_motd, 900, "", CFGFLAG_SERVER, "Message of the day to display for the clients")
MACRO_CONFIG_INT(SvTeamdamage, sv_teamdamage, 0, 0, 1, CFGFLAG_SERVER, "Team damage")
MACRO_CONFIG_STR(SvMaprotation, sv_maprotation, 768, "", CFGFLAG_SERVER, "Maps to rotate between")

0 comments on commit 56e366a

Please sign in to comment.