finalized (i hope) new map timer api
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401421
This commit is contained in:
+13
-6
@@ -120,7 +120,12 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
g_Timers.MapTimeLimitExtended(atoi(old_value) * 60, pVar->GetInt() * 60);
|
||||
if (atoi(old_value) == pVar->GetInt())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_Timers.MapTimeLeftChanged();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -436,10 +441,12 @@ IMapTimer *TimerSystem::GetMapTimer()
|
||||
return m_pMapTimer;
|
||||
}
|
||||
|
||||
void TimerSystem::MapTimeLimitExtended(int old_limit, int new_limit)
|
||||
void TimerSystem::MapTimeLeftChanged()
|
||||
{
|
||||
if (old_limit == new_limit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float TimerSystem::GetTickedTime()
|
||||
{
|
||||
return g_fUniversalTime;
|
||||
}
|
||||
|
||||
+2
-1
@@ -74,8 +74,9 @@ public: //ITimerSystem
|
||||
ITimer *CreateTimer(ITimedEvent *pCallbacks, float fInterval, void *pData, int flags);
|
||||
void KillTimer(ITimer *pTimer);
|
||||
void FireTimerOnce(ITimer *pTimer, bool delayExec=false);
|
||||
void MapTimeLimitExtended(int old_limit, int new_limit);
|
||||
void MapTimeLeftChanged();
|
||||
IMapTimer *SetMapTimer(IMapTimer *pTimer);
|
||||
float GetTickedTime();
|
||||
public:
|
||||
void RunFrame();
|
||||
void MapChange(bool real_mapchange);
|
||||
|
||||
@@ -258,11 +258,68 @@ static cell_t smn_GetTickedTime(IPluginContext *pContext, const cell_t *params)
|
||||
return sp_ftoc(*g_pUniversalTime);
|
||||
}
|
||||
|
||||
static cell_t smn_GetMapTimeLeft(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IMapTimer *pMapTimer = g_Timers.GetMapTimer();
|
||||
|
||||
if (!pMapTimer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cell_t *addr;
|
||||
pContext->LocalToPhysAddr(params[1], &addr);
|
||||
|
||||
int time_left;
|
||||
if (!pMapTimer->GetMapTimeLeft(&time_left))
|
||||
{
|
||||
time_left = -1;
|
||||
}
|
||||
|
||||
*addr = time_left;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static cell_t smn_GetMapTimeLimit(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IMapTimer *pMapTimer = g_Timers.GetMapTimer();
|
||||
|
||||
if (!pMapTimer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cell_t *addr;
|
||||
pContext->LocalToPhysAddr(params[1], &addr);
|
||||
|
||||
*addr = pMapTimer->GetMapTimeLimit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_ExtendMapTimeLimit(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IMapTimer *pMapTimer = g_Timers.GetMapTimer();
|
||||
|
||||
if (!pMapTimer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
pMapTimer->ExtendMapTimeLimit(params[1]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
REGISTER_NATIVES(timernatives)
|
||||
{
|
||||
{"CreateTimer", smn_CreateTimer},
|
||||
{"KillTimer", smn_KillTimer},
|
||||
{"TriggerTimer", smn_TriggerTimer},
|
||||
{"GetTickedTime", smn_GetTickedTime},
|
||||
{"GetMapTimeLeft", smn_GetMapTimeLeft},
|
||||
{"GetMapTimeLimit", smn_GetMapTimeLimit},
|
||||
{"ExtendMapTimeLimit", smn_ExtendMapTimeLimit},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user