045ee262a8
--HG-- rename : core/ExtensionSys.cpp => core/logic/ExtensionSys.cpp rename : core/ExtensionSys.h => core/logic/ExtensionSys.h rename : core/HandleSys.cpp => core/logic/HandleSys.cpp rename : core/HandleSys.h => core/logic/HandleSys.h rename : core/NativeInvoker.cpp => core/logic/NativeInvoker.cpp rename : core/NativeInvoker.h => core/logic/NativeInvoker.h rename : core/NativeOwner.cpp => core/logic/NativeOwner.cpp rename : core/NativeOwner.h => core/logic/NativeOwner.h rename : core/PluginSys.cpp => core/logic/PluginSys.cpp rename : core/PluginSys.h => core/logic/PluginSys.h rename : core/ShareSys.cpp => core/logic/ShareSys.cpp rename : core/ShareSys.h => core/logic/ShareSys.h rename : core/smn_fakenatives.cpp => core/logic/smn_fakenatives.cpp rename : core/logic/AutoHandleRooter.h => public/AutoHandleRooter.h
111 lines
3.5 KiB
C++
111 lines
3.5 KiB
C++
/**
|
|
* vim: set ts=4 :
|
|
* =============================================================================
|
|
* SourceMod
|
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
* =============================================================================
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
* Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
* details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
*
|
|
* Version: $Id$
|
|
*/
|
|
|
|
#ifndef _INCLUDE_SOURCEMOD_CTIMERSYS_H_
|
|
#define _INCLUDE_SOURCEMOD_CTIMERSYS_H_
|
|
|
|
#include <ITimerSystem.h>
|
|
#include <sh_stack.h>
|
|
#include <sh_list.h>
|
|
#include "sourcemm_api.h"
|
|
#include "sm_globals.h"
|
|
|
|
using namespace SourceHook;
|
|
using namespace SourceMod;
|
|
|
|
typedef List<ITimer *> TimerList;
|
|
typedef List<ITimer *>::iterator TimerIter;
|
|
|
|
class SourceMod::ITimer
|
|
{
|
|
public:
|
|
void Initialize(ITimedEvent *pCallbacks, float fInterval, float fToExec, void *pData, int flags);
|
|
ITimedEvent *m_Listener;
|
|
void *m_pData;
|
|
float m_Interval;
|
|
double m_ToExec;
|
|
int m_Flags;
|
|
bool m_InExec;
|
|
bool m_KillMe;
|
|
};
|
|
|
|
class TimerSystem :
|
|
public ITimerSystem,
|
|
public SMGlobalClass
|
|
{
|
|
public:
|
|
TimerSystem();
|
|
~TimerSystem();
|
|
public: //SMGlobalClass
|
|
void OnSourceModAllInitialized();
|
|
void OnSourceModLevelEnd();
|
|
void OnSourceModGameInitialized();
|
|
void OnSourceModShutdown();
|
|
public: //ITimerSystem
|
|
ITimer *CreateTimer(ITimedEvent *pCallbacks, float fInterval, void *pData, int flags);
|
|
void KillTimer(ITimer *pTimer);
|
|
void FireTimerOnce(ITimer *pTimer, bool delayExec=false);
|
|
void MapTimeLeftChanged();
|
|
IMapTimer *SetMapTimer(IMapTimer *pTimer);
|
|
float GetTickedTime();
|
|
void NotifyOfGameStart(float offset /* = 0.0f */);
|
|
bool GetMapTimeLeft(float *pTime);
|
|
IMapTimer *GetMapTimer();
|
|
public:
|
|
void RunFrame();
|
|
void RemoveMapChangeTimers();
|
|
void GameFrame(bool simulating);
|
|
private:
|
|
List<ITimer *> m_SingleTimers;
|
|
List<ITimer *> m_LoopTimers;
|
|
CStack<ITimer *> m_FreeTimers;
|
|
IMapTimer *m_pMapTimer;
|
|
|
|
/* 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.
|
|
*/
|
|
|
|
IForward *m_pOnGameFrame;
|
|
IForward *m_pOnMapTimeLeftChanged;
|
|
};
|
|
|
|
time_t GetAdjustedTime(time_t *buf = NULL);
|
|
|
|
extern const double *g_pUniversalTime;
|
|
extern TimerSystem g_Timers;
|
|
extern int g_TimeLeftMode;
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_CTIMERSYS_H_
|
|
|