core/sourcemod.h
changeset 1952 b7aa2b626807
child 2289 44045ead61cd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/sourcemod.h	Sun Mar 30 07:00:22 2008 +0000
     1.3 @@ -0,0 +1,139 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod
     1.8 + * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     1.9 + * =============================================================================
    1.10 + *
    1.11 + * This program is free software; you can redistribute it and/or modify it under
    1.12 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 + * Free Software Foundation.
    1.14 + * 
    1.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 + * details.
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License along with
    1.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 + *
    1.23 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 + * or <http://www.sourcemod.net/license.php>.
    1.31 + *
    1.32 + * Version: $Id$
    1.33 + */
    1.34 +
    1.35 +#ifndef _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
    1.36 +#define _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
    1.37 +
    1.38 +#include "sm_globals.h"
    1.39 +#include <ISourceMod.h>
    1.40 +#include <sh_stack.h>
    1.41 +#include <sh_vector.h>
    1.42 +#include "CDataPack.h"
    1.43 +
    1.44 +using namespace SourceHook;
    1.45 +
    1.46 +/**
    1.47 + * @brief Implements SourceMod's global overall management, API, and logic
    1.48 + */
    1.49 +
    1.50 +class SourceModBase : 
    1.51 +	public ISourceMod,
    1.52 +	public SMGlobalClass
    1.53 +{
    1.54 +public:
    1.55 +	SourceModBase();
    1.56 +public:
    1.57 +	/**
    1.58 +	 * @brief Initializes SourceMod, or returns an error on failure.
    1.59 +	 */
    1.60 +	bool InitializeSourceMod(char *error, size_t maxlength, bool late);
    1.61 +
    1.62 +	/** 
    1.63 +	 * @brief Starts everything SourceMod needs to run
    1.64 +	 */
    1.65 +	void StartSourceMod(bool late);
    1.66 +
    1.67 +	/** 
    1.68 +	 * @brief Shuts down all SourceMod components
    1.69 +	 */
    1.70 +	void CloseSourceMod();
    1.71 +
    1.72 +	/**
    1.73 +	 * @brief Map change hook
    1.74 +	 */
    1.75 +	bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
    1.76 +
    1.77 +	/**
    1.78 +	 * @brief Level shutdown hook
    1.79 +	 */
    1.80 +	void LevelShutdown();
    1.81 +
    1.82 +	/** 
    1.83 +	 * @brief Returns whether or not a map load is in progress
    1.84 +	 */
    1.85 +	bool IsMapLoading() const;
    1.86 +
    1.87 +	/** 
    1.88 +	 * @brief Stores the global target index.
    1.89 +	 */
    1.90 +	unsigned int SetGlobalTarget(unsigned int index);
    1.91 +
    1.92 +	/** 
    1.93 +	 * @brief Returns the global target index.
    1.94 +	 */
    1.95 +	unsigned int GetGlobalTarget() const;
    1.96 +public: // SMGlobalClass
    1.97 +	ConfigResult OnSourceModConfigChanged(const char *key, 
    1.98 +										  const char *value, 
    1.99 +										  ConfigSource source, 
   1.100 +										  char *error, 
   1.101 +										  size_t maxlength);
   1.102 +public: // ISourceMod
   1.103 +	const char *GetGamePath() const;
   1.104 +	const char *GetSourceModPath() const;
   1.105 +	size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...);
   1.106 +	void LogMessage(IExtension *pExt, const char *format, ...);
   1.107 +	void LogError(IExtension *pExt, const char *format, ...);
   1.108 +	size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param);
   1.109 +	IDataPack *CreateDataPack();
   1.110 +	void FreeDataPack(IDataPack *pack);
   1.111 +	HandleType_t GetDataPackHandleType(bool readonly=false);
   1.112 +	KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false);
   1.113 +	const char *GetGameFolderName() const;
   1.114 +	ISourcePawnEngine *GetScriptingEngine();
   1.115 +	IVirtualMachine *GetScriptingVM();
   1.116 +	void AllPluginsLoaded();
   1.117 +	time_t GetAdjustedTime();
   1.118 +	void GlobalPause();
   1.119 +	void GlobalUnpause();
   1.120 +	void DoGlobalPluginLoads();
   1.121 +	void AddGameFrameHook(GAME_FRAME_HOOK hook);
   1.122 +	void RemoveGameFrameHook(GAME_FRAME_HOOK hook);
   1.123 +	void ProcessGameFrameHooks(bool simulating);
   1.124 +private:
   1.125 +	CStack<CDataPack *> m_freepacks;
   1.126 +	char m_SMBaseDir[PLATFORM_MAX_PATH];
   1.127 +	char m_SMRelDir[PLATFORM_MAX_PATH];
   1.128 +	char m_ModDir[32];
   1.129 +	bool m_IsMapLoading;
   1.130 +	bool m_ExecPluginReload;
   1.131 +	bool m_ExecOnMapEnd;
   1.132 +	unsigned int m_target;
   1.133 +	bool m_GotBasePath;
   1.134 +	CVector<GAME_FRAME_HOOK> m_frame_hooks;
   1.135 +};
   1.136 +
   1.137 +extern bool g_Loaded;
   1.138 +extern SourceModBase g_SourceMod;
   1.139 +extern HandleType_t g_WrBitBufType;		//:TODO: find a better place for this
   1.140 +extern HandleType_t g_RdBitBufType;		//:TODO: find a better place for this
   1.141 +
   1.142 +#endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_