dvander@370: /**
ds@653: * vim: set ts=4 :
dvander@1231: * ================================================================
dvander@1231: * SourceMod
dvander@1231: * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
dvander@1231: * ================================================================
dvander@370: *
dvander@1231: * This program is free software; you can redistribute it and/or
dvander@1231: * modify it under the terms of the GNU General Public License,
dvander@1231: * version 3.0, as published by the Free Software Foundation.
dvander@1231: *
dvander@1231: * This program is distributed in the hope that it will be useful,
dvander@1231: * but WITHOUT ANY WARRANTY; without even the implied warranty of
dvander@1231: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dvander@1231: * GNU General Public License for more details.
dvander@1231: *
dvander@1231: * You should have received a copy of the GNU General Public License
dvander@1231: * along with this program. If not, see .
dvander@1231: *
dvander@1231: * As a special exception, AlliedModders LLC gives you permission to
dvander@1231: * link the code of this program (as well as its derivative works) to
dvander@1231: * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
dvander@1231: * Game MODs that run on software by the Valve Corporation. You must
dvander@1231: * obey the GNU General Public License in all respects for all other
dvander@1231: * code used. Additionally, AlliedModders LLC grants this exception
dvander@1231: * to all derivative works. AlliedModders LLC defines further
dvander@1231: * exceptions, found in LICENSE.txt (as of this writing, version
dvander@1231: * JULY-31-2007), 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
faluco@484: #include "CDataPack.h"
faluco@484:
faluco@484: using namespace SourceHook;
dvander@159:
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: */
faluco@422: void SetGlobalTarget(unsigned int index);
faluco@422:
faluco@422: /**
dvander@448: * @brief Returns the global target index.
dvander@448: */
faluco@422: unsigned int GetGlobalTarget() const;
faluco@484:
faluco@484: /**
ds@675: * @brief Sets whether if SoureMod needs to check player auths.
ds@675: */
faluco@484: void SetAuthChecking(bool set);
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;
dvander@317: size_t BuildPath(PathType type, char *buffer, size_t maxlength, 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@209: private:
dvander@209: /**
dvander@209: * @brief Loading plugins
dvander@209: */
dvander@209: void DoGlobalPluginLoads();
ds@661:
ds@661: /**
ds@661: * @brief GameFrame hook
ds@661: */
dvander@448: void GameFrame(bool simulating);
dvander@209: 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;
dvander@448: bool m_CheckingAuth;
ds@661: bool m_GotBasePath;
dvander@211: };
dvander@211:
dvander@160: extern SourceModBase g_SourceMod;
dvander@685: extern HandleType_t g_WrBitBufType; //:TODO: find a better place for this
dvander@685: extern HandleType_t g_RdBitBufType; //:TODO: find a better place for this
dvander@159:
dvander@159: #endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_