core/sourcemod.h
author Scott Ehlert <ds@alliedmods.net>
Sat Feb 17 05:33:31 2007 +0000 (2007-02-17)
changeset 511 c29f8796bcf4
parent 505 9fb8a1ccd4ec
child 598 991d7e247a2c
permissions -rw-r--r--
Initial fixes to ensure static strings passed to new convars
Also fixed minor warning in smn_bitbuffer.cpp
     1 /**
     2  * ===============================================================
     3  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     4  * ===============================================================
     5  *
     6  * This file is not open source and may not be copied without explicit
     7  * written permission of AlliedModders LLC.  This file may not be redistributed 
     8  * in whole or significant part.
     9  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    10  *
    11  * Version: $Id$
    12  */
    13 
    14 #ifndef _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
    15 #define _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
    16 
    17 #include "sm_globals.h"
    18 #include <ISourceMod.h>
    19 #include <sh_stack.h>
    20 #include "CDataPack.h"
    21 
    22 using namespace SourceHook;
    23 
    24 /**
    25  * @brief Implements SourceMod's global overall management, API, and logic
    26  */
    27 
    28 class SourceModBase : public ISourceMod
    29 {
    30 public:
    31 	SourceModBase();
    32 public:
    33 	/**
    34 	 * @brief Initializes SourceMod, or returns an error on failure.
    35 	 */
    36 	bool InitializeSourceMod(char *error, size_t err_max, bool late);
    37 
    38 	/** 
    39 	 * @brief Starts everything SourceMod needs to run
    40 	 */
    41 	void StartSourceMod(bool late);
    42 
    43 	/** 
    44 	 * @brief Shuts down all SourceMod components
    45 	 */
    46 	void CloseSourceMod();
    47 
    48 	/**
    49 	 * @brief Map change hook
    50 	 */
    51 	bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
    52 
    53 	/**
    54 	 * @brief Level shutdown hook
    55 	 */
    56 	void LevelShutdown();
    57 
    58 	/** 
    59 	 * @brief Returns whether or not a map load is in progress
    60 	 */
    61 	bool IsMapLoading() const;
    62 
    63 	/** 
    64 	 * @brief Stores the global target index.
    65 	 */
    66 	void SetGlobalTarget(unsigned int index);
    67 
    68 	/** 
    69 	 * @brief Returns the global target index.
    70 	 */
    71 	unsigned int GetGlobalTarget() const;
    72 	
    73 	/** 
    74 	* @brief Sets whether if SoureMod needs to check player auths.
    75 	*/
    76 	void SetAuthChecking(bool set);
    77 public: //ISourceMod
    78 	const char *GetModPath() const;
    79 	const char *GetSourceModPath() const;
    80 	size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...);
    81 	void LogMessage(IExtension *pExt, const char *format, ...);
    82 	void LogError(IExtension *pExt, const char *format, ...);
    83 	size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param);
    84 	IDataPack *CreateDataPack();
    85 	void FreeDataPack(IDataPack *pack);
    86 	HandleType_t GetDataPackHandleType(bool readonly=false);
    87 private:
    88 	/**
    89 	 * @brief Loading plugins
    90 	 */
    91 	void DoGlobalPluginLoads();
    92 	void GameFrame(bool simulating);
    93 private:
    94 	CStack<CDataPack *> m_freepacks;
    95 	char m_SMBaseDir[PLATFORM_MAX_PATH+1];
    96 	char m_SMRelDir[PLATFORM_MAX_PATH+1];
    97 	bool m_IsMapLoading;
    98 	bool m_ExecPluginReload;
    99 	unsigned int m_target;
   100 	bool m_CheckingAuth;
   101 };
   102 
   103 extern SourceModBase g_SourceMod;
   104 extern HandleType_t g_WrBitBufType;
   105 
   106 #endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_