2007-01-25 23:36:38 +01:00
|
|
|
/**
|
2007-03-22 22:50:20 +01:00
|
|
|
* vim: set ts=4 :
|
2007-08-15 08:19:30 +02:00
|
|
|
* =============================================================================
|
2007-08-01 04:12:47 +02:00
|
|
|
* SourceMod
|
|
|
|
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
2007-08-15 08:19:30 +02:00
|
|
|
* =============================================================================
|
2007-01-25 23:36:38 +01:00
|
|
|
*
|
2007-08-15 08:19:30 +02:00
|
|
|
* 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.
|
2007-08-01 04:12:47 +02:00
|
|
|
*
|
2007-08-15 08:19:30 +02:00
|
|
|
* 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.
|
2007-08-01 04:12:47 +02:00
|
|
|
*
|
2007-08-15 08:19:30 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
2007-08-01 04:12:47 +02:00
|
|
|
*
|
2007-08-15 08:19:30 +02:00
|
|
|
* 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>.
|
2007-01-25 23:36:38 +01:00
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
2006-11-08 07:30:20 +01:00
|
|
|
#ifndef _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
|
|
|
|
|
2006-11-08 08:32:44 +01:00
|
|
|
#include "sm_globals.h"
|
2007-01-19 03:14:50 +01:00
|
|
|
#include <ISourceMod.h>
|
2007-02-13 17:11:04 +01:00
|
|
|
#include <sh_stack.h>
|
|
|
|
#include "CDataPack.h"
|
|
|
|
|
|
|
|
using namespace SourceHook;
|
2006-11-08 07:30:20 +01:00
|
|
|
|
2006-11-08 08:44:26 +01:00
|
|
|
/**
|
|
|
|
* @brief Implements SourceMod's global overall management, API, and logic
|
|
|
|
*/
|
|
|
|
|
2007-04-05 05:02:00 +02:00
|
|
|
class SourceModBase :
|
|
|
|
public ISourceMod,
|
|
|
|
public SMGlobalClass
|
2006-11-08 08:32:44 +01:00
|
|
|
{
|
2006-12-13 12:16:20 +01:00
|
|
|
public:
|
|
|
|
SourceModBase();
|
2006-11-08 08:32:44 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Initializes SourceMod, or returns an error on failure.
|
|
|
|
*/
|
2007-05-08 02:21:44 +02:00
|
|
|
bool InitializeSourceMod(char *error, size_t maxlength, bool late);
|
2006-12-13 12:16:20 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Starts everything SourceMod needs to run
|
|
|
|
*/
|
|
|
|
void StartSourceMod(bool late);
|
|
|
|
|
2007-01-13 05:28:13 +01:00
|
|
|
/**
|
2007-02-07 09:44:48 +01:00
|
|
|
* @brief Shuts down all SourceMod components
|
|
|
|
*/
|
2007-01-13 05:28:13 +01:00
|
|
|
void CloseSourceMod();
|
|
|
|
|
2006-12-13 12:16:20 +01:00
|
|
|
/**
|
|
|
|
* @brief Map change hook
|
|
|
|
*/
|
|
|
|
bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
|
|
|
|
|
2007-01-20 03:12:53 +01:00
|
|
|
/**
|
2007-02-07 09:44:48 +01:00
|
|
|
* @brief Level shutdown hook
|
|
|
|
*/
|
2007-01-20 03:12:53 +01:00
|
|
|
void LevelShutdown();
|
|
|
|
|
2006-12-13 12:16:20 +01:00
|
|
|
/**
|
2007-02-13 17:11:04 +01:00
|
|
|
* @brief Returns whether or not a map load is in progress
|
2006-12-13 12:16:20 +01:00
|
|
|
*/
|
2007-02-13 17:11:04 +01:00
|
|
|
bool IsMapLoading() const;
|
2006-12-13 12:16:20 +01:00
|
|
|
|
2007-01-30 19:04:53 +01:00
|
|
|
/**
|
2007-02-07 09:44:48 +01:00
|
|
|
* @brief Stores the global target index.
|
|
|
|
*/
|
2007-11-17 06:33:47 +01:00
|
|
|
unsigned int SetGlobalTarget(unsigned int index);
|
2007-01-30 19:04:53 +01:00
|
|
|
|
|
|
|
/**
|
2007-02-07 09:44:48 +01:00
|
|
|
* @brief Returns the global target index.
|
|
|
|
*/
|
2007-01-30 19:04:53 +01:00
|
|
|
unsigned int GetGlobalTarget() const;
|
2007-04-05 05:02:00 +02:00
|
|
|
public: // SMGlobalClass
|
2007-04-05 07:25:11 +02:00
|
|
|
ConfigResult OnSourceModConfigChanged(const char *key,
|
|
|
|
const char *value,
|
|
|
|
ConfigSource source,
|
|
|
|
char *error,
|
|
|
|
size_t maxlength);
|
2007-04-05 05:02:00 +02:00
|
|
|
public: // ISourceMod
|
2007-05-03 05:45:53 +02:00
|
|
|
const char *GetGamePath() const;
|
2007-02-13 17:11:04 +01:00
|
|
|
const char *GetSourceModPath() const;
|
2007-09-12 09:22:38 +02:00
|
|
|
size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...);
|
2007-01-19 03:14:50 +01:00
|
|
|
void LogMessage(IExtension *pExt, const char *format, ...);
|
|
|
|
void LogError(IExtension *pExt, const char *format, ...);
|
2007-01-25 07:19:17 +01:00
|
|
|
size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param);
|
2007-02-13 17:11:04 +01:00
|
|
|
IDataPack *CreateDataPack();
|
|
|
|
void FreeDataPack(IDataPack *pack);
|
|
|
|
HandleType_t GetDataPackHandleType(bool readonly=false);
|
2007-04-12 02:45:53 +02:00
|
|
|
KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false);
|
2007-05-03 05:45:53 +02:00
|
|
|
const char *GetGameFolderName() const;
|
2007-05-04 03:28:08 +02:00
|
|
|
ISourcePawnEngine *GetScriptingEngine();
|
|
|
|
IVirtualMachine *GetScriptingVM();
|
2007-06-07 00:16:15 +02:00
|
|
|
void AllPluginsLoaded();
|
2007-08-26 20:41:57 +02:00
|
|
|
time_t GetAdjustedTime();
|
2007-10-22 07:35:31 +02:00
|
|
|
void GlobalPause();
|
|
|
|
void GlobalUnpause();
|
2006-12-13 12:16:20 +01:00
|
|
|
void DoGlobalPluginLoads();
|
|
|
|
private:
|
2007-02-13 17:11:04 +01:00
|
|
|
CStack<CDataPack *> m_freepacks;
|
2007-03-22 22:12:17 +01:00
|
|
|
char m_SMBaseDir[PLATFORM_MAX_PATH];
|
|
|
|
char m_SMRelDir[PLATFORM_MAX_PATH];
|
2007-04-14 06:27:47 +02:00
|
|
|
char m_ModDir[32];
|
2006-12-13 12:16:20 +01:00
|
|
|
bool m_IsMapLoading;
|
2007-01-20 03:12:53 +01:00
|
|
|
bool m_ExecPluginReload;
|
2007-05-13 19:23:42 +02:00
|
|
|
bool m_ExecOnMapEnd;
|
2007-01-30 19:04:53 +01:00
|
|
|
unsigned int m_target;
|
2007-04-05 05:02:00 +02:00
|
|
|
bool m_GotBasePath;
|
2006-12-15 14:38:04 +01:00
|
|
|
};
|
|
|
|
|
2007-10-16 00:15:22 +02:00
|
|
|
extern bool g_Loaded;
|
2006-11-08 08:32:44 +01:00
|
|
|
extern SourceModBase g_SourceMod;
|
2007-04-12 18:28:29 +02:00
|
|
|
extern HandleType_t g_WrBitBufType; //:TODO: find a better place for this
|
|
|
|
extern HandleType_t g_RdBitBufType; //:TODO: find a better place for this
|
2006-11-08 07:30:20 +01:00
|
|
|
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_
|