dvander@370: /**
dvander@4029: * vim: set ts=4 sw=4 tw=99 noet:
ds@1330: * =============================================================================
dvander@1231: * SourceMod
ds@3104: * Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
dvander@370: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
dvander@1231: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
dvander@1231: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
dvander@1231: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
dvander@370: *
dvander@370: * Version: $Id$
dvander@370: */
dvander@370:
dvander@159: #ifndef _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
dvander@159: #define _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
dvander@159:
dvander@160: #include "sm_globals.h"
dvander@317: #include
faluco@484: #include
dvander@1904: #include
faluco@484: #include "CDataPack.h"
faluco@484:
faluco@484: using namespace SourceHook;
dvander@159:
dvander@2474: #if defined _DEBUG
dvander@2474: # define IF_DEBUG_SPEW
dvander@2474: # define ENDIF_DEBUG_SPEW
dvander@2474: #else
dvander@2474: # define IF_DEBUG_SPEW \
dvander@2474: if (sm_show_debug_spew) \
dvander@2474: {
dvander@2474: # define ENDIF_DEBUG_SPEW \
dvander@2474: }
dvander@2474: #endif
dvander@2474:
dvander@162: /**
dvander@162: * @brief Implements SourceMod's global overall management, API, and logic
dvander@162: */
dvander@162:
ds@661: class SourceModBase :
ds@661: public ISourceMod,
ds@661: public SMGlobalClass
dvander@160: {
dvander@160: public:
dvander@209: SourceModBase();
dvander@209: public:
dvander@160: /**
dvander@160: * @brief Initializes SourceMod, or returns an error on failure.
dvander@160: */
ds@755: bool InitializeSourceMod(char *error, size_t maxlength, bool late);
dvander@209:
dvander@209: /**
dvander@209: * @brief Starts everything SourceMod needs to run
dvander@209: */
dvander@209: void StartSourceMod(bool late);
dvander@209:
faluco@289: /**
dvander@448: * @brief Shuts down all SourceMod components
dvander@448: */
faluco@289: void CloseSourceMod();
faluco@289:
dvander@209: /**
dvander@209: * @brief Map change hook
dvander@209: */
dvander@209: bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
dvander@209:
faluco@333: /**
dvander@448: * @brief Level shutdown hook
dvander@448: */
faluco@333: void LevelShutdown();
faluco@333:
dvander@209: /**
faluco@484: * @brief Returns whether or not a map load is in progress
dvander@209: */
faluco@484: bool IsMapLoading() const;
dvander@209:
faluco@422: /**
dvander@448: * @brief Stores the global target index.
dvander@448: */
dvander@1690: unsigned int SetGlobalTarget(unsigned int index);
faluco@422:
faluco@422: /**
dvander@448: * @brief Returns the global target index.
dvander@448: */
faluco@422: unsigned int GetGlobalTarget() const;
ds@661: public: // SMGlobalClass
dvander@663: ConfigResult OnSourceModConfigChanged(const char *key,
dvander@663: const char *value,
dvander@663: ConfigSource source,
dvander@663: char *error,
dvander@663: size_t maxlength);
ds@661: public: // ISourceMod
ds@729: const char *GetGamePath() const;
faluco@484: const char *GetSourceModPath() const;
ds@1411: size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...);
dvander@317: void LogMessage(IExtension *pExt, const char *format, ...);
dvander@317: void LogError(IExtension *pExt, const char *format, ...);
dvander@347: size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param);
faluco@484: IDataPack *CreateDataPack();
faluco@484: void FreeDataPack(IDataPack *pack);
faluco@484: HandleType_t GetDataPackHandleType(bool readonly=false);
faluco@682: KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false);
ds@729: const char *GetGameFolderName() const;
faluco@733: ISourcePawnEngine *GetScriptingEngine();
faluco@733: IVirtualMachine *GetScriptingVM();
dvander@893: void AllPluginsLoaded();
dvander@1371: time_t GetAdjustedTime();
dvander@1630: void GlobalPause();
dvander@1630: void GlobalUnpause();
dvander@209: void DoGlobalPluginLoads();
dvander@1904: void AddGameFrameHook(GAME_FRAME_HOOK hook);
dvander@1904: void RemoveGameFrameHook(GAME_FRAME_HOOK hook);
dvander@1904: void ProcessGameFrameHooks(bool simulating);
dvander@2555: size_t Format(char *buffer, size_t maxlength, const char *fmt, ...);
dvander@2555: size_t FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap);
dvander@2562: void AddFrameAction(FRAMEACTION fn, void *data);
dvander@2574: const char *GetCoreConfigValue(const char *key);
dvander@2628: int GetPluginId();
ds@3104: int GetShApiVersion();
skamonkey@3401: bool IsMapRunning();
dvander@209: private:
dvander@4029: void ShutdownServices();
dvander@4029: private:
faluco@484: CStack m_freepacks;
ds@652: char m_SMBaseDir[PLATFORM_MAX_PATH];
ds@652: char m_SMRelDir[PLATFORM_MAX_PATH];
ds@696: char m_ModDir[32];
dvander@209: bool m_IsMapLoading;
faluco@333: bool m_ExecPluginReload;
faluco@786: bool m_ExecOnMapEnd;
faluco@422: unsigned int m_target;
ds@661: bool m_GotBasePath;
dvander@1904: CVector m_frame_hooks;
dvander@211: };
dvander@211:
dvander@1581: extern bool g_Loaded;
dvander@2474: extern bool sm_show_debug_spew;
dvander@160: extern SourceModBase g_SourceMod;
dvander@159:
dvander@159: #endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_