3 * =============================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
33 #define _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
35 #include "sm_globals.h"
36 #include <ISourceMod.h>
38 #include "CDataPack.h"
40 using namespace SourceHook;
43 * @brief Implements SourceMod's global overall management, API, and logic
54 * @brief Initializes SourceMod, or returns an error on failure.
56 bool InitializeSourceMod(char *error, size_t maxlength, bool late);
59 * @brief Starts everything SourceMod needs to run
61 void StartSourceMod(bool late);
64 * @brief Shuts down all SourceMod components
66 void CloseSourceMod();
69 * @brief Map change hook
71 bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
74 * @brief Level shutdown hook
79 * @brief Returns whether or not a map load is in progress
81 bool IsMapLoading() const;
84 * @brief Stores the global target index.
86 void SetGlobalTarget(unsigned int index);
89 * @brief Returns the global target index.
91 unsigned int GetGlobalTarget() const;
94 * @brief Sets whether if SoureMod needs to check player auths.
96 void SetAuthChecking(bool set);
97 public: // SMGlobalClass
98 ConfigResult OnSourceModConfigChanged(const char *key,
103 public: // ISourceMod
104 const char *GetGamePath() const;
105 const char *GetSourceModPath() const;
106 size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...);
107 void LogMessage(IExtension *pExt, const char *format, ...);
108 void LogError(IExtension *pExt, const char *format, ...);
109 size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param);
110 IDataPack *CreateDataPack();
111 void FreeDataPack(IDataPack *pack);
112 HandleType_t GetDataPackHandleType(bool readonly=false);
113 KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false);
114 const char *GetGameFolderName() const;
115 ISourcePawnEngine *GetScriptingEngine();
116 IVirtualMachine *GetScriptingVM();
117 void AllPluginsLoaded();
118 time_t GetAdjustedTime();
121 * @brief Loading plugins
123 void DoGlobalPluginLoads();
126 * @brief GameFrame hook
128 void GameFrame(bool simulating);
130 CStack<CDataPack *> m_freepacks;
131 char m_SMBaseDir[PLATFORM_MAX_PATH];
132 char m_SMRelDir[PLATFORM_MAX_PATH];
135 bool m_ExecPluginReload;
137 unsigned int m_target;
142 extern SourceModBase g_SourceMod;
143 extern HandleType_t g_WrBitBufType; //:TODO: find a better place for this
144 extern HandleType_t g_RdBitBufType; //:TODO: find a better place for this
146 #endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_