core/TimerSys.cpp
changeset 1462 c5feb60740cf
parent 1459 8132c2259758
child 1480 30701001f41a
     1.1 --- a/core/TimerSys.cpp	Sun Sep 23 19:35:22 2007 +0000
     1.2 +++ b/core/TimerSys.cpp	Sun Sep 23 20:11:48 2007 +0000
     1.3 @@ -152,6 +152,7 @@
     1.4  {
     1.5  	m_pMapTimer = NULL;
     1.6  	m_bHasMapTickedYet = false;
     1.7 +	m_bHasMapSimulatedYet = false;
     1.8  	m_fLastTickedTime = 0.0f;
     1.9  	m_LastExecTime = 0.0f;
    1.10  }
    1.11 @@ -198,6 +199,7 @@
    1.12  void TimerSystem::OnSourceModLevelEnd()
    1.13  {
    1.14  	m_bHasMapTickedYet = false;
    1.15 +	m_bHasMapSimulatedYet = false;
    1.16  }
    1.17  
    1.18  void TimerSystem::GameFrame(bool simulating)
    1.19 @@ -205,6 +207,11 @@
    1.20  	if (simulating && m_bHasMapTickedYet)
    1.21  	{
    1.22  		g_fUniversalTime += gpGlobals->curtime - m_fLastTickedTime;
    1.23 +		if (!m_bHasMapSimulatedYet)
    1.24 +		{
    1.25 +			m_bHasMapSimulatedYet = true;
    1.26 +			MapTimeLeftChanged();
    1.27 +		}
    1.28  	}
    1.29  	else 
    1.30  	{
    1.31 @@ -450,13 +457,21 @@
    1.32  
    1.33  bool TimerSystem::GetMapTimeLeft(float *time_left)
    1.34  {
    1.35 -	int time_limit;
    1.36 -	if (!m_pMapTimer || (time_limit = m_pMapTimer->GetMapTimeLimit()) < 1)
    1.37 +	if (!m_pMapTimer)
    1.38  	{
    1.39  		return false;
    1.40  	}
    1.41  
    1.42 -	*time_left = (g_fGameStartTime + time_limit * 60.0f) - gpGlobals->curtime;
    1.43 +	int time_limit;
    1.44 +	if (!m_bHasMapSimulatedYet || (time_limit = m_pMapTimer->GetMapTimeLimit()) < 1)
    1.45 +	{
    1.46 +		*time_left = -1.0f;
    1.47 +	}
    1.48 +	else
    1.49 +	{
    1.50 +		*time_left = (g_fGameStartTime + time_limit * 60.0f) - gpGlobals->curtime;
    1.51 +	}
    1.52  
    1.53  	return true;
    1.54  }
    1.55 +