ds@1952: /** ds@1952: * vim: set ts=4 : ds@1952: * ============================================================================= ds@1952: * SourceMod ds@1952: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. ds@1952: * ============================================================================= ds@1952: * ds@1952: * This program is free software; you can redistribute it and/or modify it under ds@1952: * the terms of the GNU General Public License, version 3.0, as published by the ds@1952: * Free Software Foundation. ds@1952: * ds@1952: * This program is distributed in the hope that it will be useful, but WITHOUT ds@1952: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ds@1952: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ds@1952: * details. ds@1952: * ds@1952: * You should have received a copy of the GNU General Public License along with ds@1952: * this program. If not, see . ds@1952: * ds@1952: * As a special exception, AlliedModders LLC gives you permission to link the ds@1952: * code of this program (as well as its derivative works) to "Half-Life 2," the ds@1952: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software ds@1952: * by the Valve Corporation. You must obey the GNU General Public License in ds@1952: * all respects for all other code used. Additionally, AlliedModders LLC grants ds@1952: * this exception to all derivative works. AlliedModders LLC defines further ds@1952: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), ds@1952: * or . ds@1952: * ds@1952: * Version: $Id$ ds@1952: */ ds@1952: ds@1952: #ifndef _INCLUDE_SOURCEMOD_GLOBALHEADER_H_ ds@1952: #define _INCLUDE_SOURCEMOD_GLOBALHEADER_H_ ds@1952: ds@1952: #include "sm_globals.h" ds@1952: #include ds@1952: #include ds@1952: #include ds@1952: #include "CDataPack.h" ds@1952: ds@1952: using namespace SourceHook; ds@1952: ds@1952: /** ds@1952: * @brief Implements SourceMod's global overall management, API, and logic ds@1952: */ ds@1952: ds@1952: class SourceModBase : ds@1952: public ISourceMod, ds@1952: public SMGlobalClass ds@1952: { ds@1952: public: ds@1952: SourceModBase(); ds@1952: public: ds@1952: /** ds@1952: * @brief Initializes SourceMod, or returns an error on failure. ds@1952: */ ds@1952: bool InitializeSourceMod(char *error, size_t maxlength, bool late); ds@1952: ds@1952: /** ds@1952: * @brief Starts everything SourceMod needs to run ds@1952: */ ds@1952: void StartSourceMod(bool late); ds@1952: ds@1952: /** ds@1952: * @brief Shuts down all SourceMod components ds@1952: */ ds@1952: void CloseSourceMod(); ds@1952: ds@1952: /** ds@1952: * @brief Map change hook ds@1952: */ ds@1952: bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background); ds@1952: ds@1952: /** ds@1952: * @brief Level shutdown hook ds@1952: */ ds@1952: void LevelShutdown(); ds@1952: ds@1952: /** ds@1952: * @brief Returns whether or not a map load is in progress ds@1952: */ ds@1952: bool IsMapLoading() const; ds@1952: ds@1952: /** ds@1952: * @brief Stores the global target index. ds@1952: */ ds@1952: unsigned int SetGlobalTarget(unsigned int index); ds@1952: ds@1952: /** ds@1952: * @brief Returns the global target index. ds@1952: */ ds@1952: unsigned int GetGlobalTarget() const; ds@1952: public: // SMGlobalClass ds@1952: ConfigResult OnSourceModConfigChanged(const char *key, ds@1952: const char *value, ds@1952: ConfigSource source, ds@1952: char *error, ds@1952: size_t maxlength); ds@1952: public: // ISourceMod ds@1952: const char *GetGamePath() const; ds@1952: const char *GetSourceModPath() const; ds@1952: size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...); ds@1952: void LogMessage(IExtension *pExt, const char *format, ...); ds@1952: void LogError(IExtension *pExt, const char *format, ...); ds@1952: size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param); ds@1952: IDataPack *CreateDataPack(); ds@1952: void FreeDataPack(IDataPack *pack); ds@1952: HandleType_t GetDataPackHandleType(bool readonly=false); ds@1952: KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false); ds@1952: const char *GetGameFolderName() const; ds@1952: ISourcePawnEngine *GetScriptingEngine(); ds@1952: IVirtualMachine *GetScriptingVM(); ds@1952: void AllPluginsLoaded(); ds@1952: time_t GetAdjustedTime(); ds@1952: void GlobalPause(); ds@1952: void GlobalUnpause(); ds@1952: void DoGlobalPluginLoads(); ds@1952: void AddGameFrameHook(GAME_FRAME_HOOK hook); ds@1952: void RemoveGameFrameHook(GAME_FRAME_HOOK hook); ds@1952: void ProcessGameFrameHooks(bool simulating); ds@1952: private: ds@1952: CStack m_freepacks; ds@1952: char m_SMBaseDir[PLATFORM_MAX_PATH]; ds@1952: char m_SMRelDir[PLATFORM_MAX_PATH]; ds@1952: char m_ModDir[32]; ds@1952: bool m_IsMapLoading; ds@1952: bool m_ExecPluginReload; ds@1952: bool m_ExecOnMapEnd; ds@1952: unsigned int m_target; ds@1952: bool m_GotBasePath; ds@1952: CVector m_frame_hooks; ds@1952: }; ds@1952: ds@1952: extern bool g_Loaded; ds@1952: extern SourceModBase g_SourceMod; ds@1952: extern HandleType_t g_WrBitBufType; //:TODO: find a better place for this ds@1952: extern HandleType_t g_RdBitBufType; //:TODO: find a better place for this ds@1952: ds@1952: #endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_