clarified and fixed the meaning of timelimit/timeleft when no frames have been processed
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401468
This commit is contained in:
+18
-3
@@ -152,6 +152,7 @@ TimerSystem::TimerSystem()
|
||||
{
|
||||
m_pMapTimer = NULL;
|
||||
m_bHasMapTickedYet = false;
|
||||
m_bHasMapSimulatedYet = false;
|
||||
m_fLastTickedTime = 0.0f;
|
||||
m_LastExecTime = 0.0f;
|
||||
}
|
||||
@@ -198,6 +199,7 @@ void TimerSystem::OnSourceModLevelChange(const char *mapName)
|
||||
void TimerSystem::OnSourceModLevelEnd()
|
||||
{
|
||||
m_bHasMapTickedYet = false;
|
||||
m_bHasMapSimulatedYet = false;
|
||||
}
|
||||
|
||||
void TimerSystem::GameFrame(bool simulating)
|
||||
@@ -205,6 +207,11 @@ void TimerSystem::GameFrame(bool simulating)
|
||||
if (simulating && m_bHasMapTickedYet)
|
||||
{
|
||||
g_fUniversalTime += gpGlobals->curtime - m_fLastTickedTime;
|
||||
if (!m_bHasMapSimulatedYet)
|
||||
{
|
||||
m_bHasMapSimulatedYet = true;
|
||||
MapTimeLeftChanged();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -450,13 +457,21 @@ float TimerSystem::GetTickedTime()
|
||||
|
||||
bool TimerSystem::GetMapTimeLeft(float *time_left)
|
||||
{
|
||||
int time_limit;
|
||||
if (!m_pMapTimer || (time_limit = m_pMapTimer->GetMapTimeLimit()) < 1)
|
||||
if (!m_pMapTimer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
*time_left = (g_fGameStartTime + time_limit * 60.0f) - gpGlobals->curtime;
|
||||
int time_limit;
|
||||
if (!m_bHasMapSimulatedYet || (time_limit = m_pMapTimer->GetMapTimeLimit()) < 1)
|
||||
{
|
||||
*time_left = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
*time_left = (g_fGameStartTime + time_limit * 60.0f) - gpGlobals->curtime;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ private:
|
||||
|
||||
/* This is stuff for our manual ticking escapades. */
|
||||
bool m_bHasMapTickedYet; /** Has the map ticked yet? */
|
||||
bool m_bHasMapSimulatedYet; /** Has the map simulated yet? */
|
||||
float m_fLastTickedTime; /** Last time that the game currently gave
|
||||
us while ticking.
|
||||
*/
|
||||
|
||||
+6
-11
@@ -260,23 +260,17 @@ static cell_t smn_GetTickedTime(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
static cell_t smn_GetMapTimeLeft(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cell_t *addr;
|
||||
pContext->LocalToPhysAddr(params[1], &addr);
|
||||
|
||||
float time_left;
|
||||
int int_time;
|
||||
if (!g_Timers.GetMapTimeLeft(&time_left))
|
||||
{
|
||||
int_time = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int_time = (int)time_left;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*addr = int_time;
|
||||
cell_t *addr;
|
||||
pContext->LocalToPhysAddr(params[1], &addr);
|
||||
*addr = (int)time_left;
|
||||
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_GetMapTimeLimit(IPluginContext *pContext, const cell_t *params)
|
||||
@@ -327,3 +321,4 @@ REGISTER_NATIVES(timernatives)
|
||||
{"IsServerProcessing", smn_IsServerProcessing},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user