core/sourcemod.h
author Scott Ehlert <ds@alliedmods.net>
Thu Mar 22 21:50:20 2007 +0000 (2007-03-22)
changeset 653 ef60870067ff
parent 652 d62a08ba6318
child 661 5c0988b9bf0c
permissions -rw-r--r--
More consistency of some sort...

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