core/sourcemod.h
author David Anderson <dvander@alliedmods.net>
Wed Jun 06 06:27:47 2007 +0000 (2007-06-06)
changeset 884 a5f3239cef1a
parent 786 a04118454f26
child 893 a3bc816549a8
permissions -rw-r--r--
- vote menus now get cancelled properly (and get a new callback with it)
- added api for seeing if a menu is in a VoteDisplay
- fixed another item count bug
- removed some cruft from the vote handler header
     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 : 
    30 	public ISourceMod,
    31 	public SMGlobalClass
    32 {
    33 public:
    34 	SourceModBase();
    35 public:
    36 	/**
    37 	 * @brief Initializes SourceMod, or returns an error on failure.
    38 	 */
    39 	bool InitializeSourceMod(char *error, size_t maxlength, bool late);
    40 
    41 	/** 
    42 	 * @brief Starts everything SourceMod needs to run
    43 	 */
    44 	void StartSourceMod(bool late);
    45 
    46 	/** 
    47 	 * @brief Shuts down all SourceMod components
    48 	 */
    49 	void CloseSourceMod();
    50 
    51 	/**
    52 	 * @brief Map change hook
    53 	 */
    54 	bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
    55 
    56 	/**
    57 	 * @brief Level shutdown hook
    58 	 */
    59 	void LevelShutdown();
    60 
    61 	/** 
    62 	 * @brief Returns whether or not a map load is in progress
    63 	 */
    64 	bool IsMapLoading() const;
    65 
    66 	/** 
    67 	 * @brief Stores the global target index.
    68 	 */
    69 	void SetGlobalTarget(unsigned int index);
    70 
    71 	/** 
    72 	 * @brief Returns the global target index.
    73 	 */
    74 	unsigned int GetGlobalTarget() const;
    75 	
    76 	/** 
    77 	 * @brief Sets whether if SoureMod needs to check player auths.
    78 	 */
    79 	void SetAuthChecking(bool set);
    80 public: // SMGlobalClass
    81 	ConfigResult OnSourceModConfigChanged(const char *key, 
    82 										  const char *value, 
    83 										  ConfigSource source, 
    84 										  char *error, 
    85 										  size_t maxlength);
    86 public: // ISourceMod
    87 	const char *GetGamePath() const;
    88 	const char *GetSourceModPath() const;
    89 	size_t BuildPath(PathType type, char *buffer, size_t maxlength, char *format, ...);
    90 	void LogMessage(IExtension *pExt, const char *format, ...);
    91 	void LogError(IExtension *pExt, const char *format, ...);
    92 	size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param);
    93 	IDataPack *CreateDataPack();
    94 	void FreeDataPack(IDataPack *pack);
    95 	HandleType_t GetDataPackHandleType(bool readonly=false);
    96 	KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false);
    97 	const char *GetGameFolderName() const;
    98 	ISourcePawnEngine *GetScriptingEngine();
    99 	IVirtualMachine *GetScriptingVM();
   100 private:
   101 	/**
   102 	 * @brief Loading plugins
   103 	 */
   104 	void DoGlobalPluginLoads();
   105 
   106 	/**
   107 	 * @brief GameFrame hook
   108 	 */
   109 	void GameFrame(bool simulating);
   110 private:
   111 	CStack<CDataPack *> m_freepacks;
   112 	char m_SMBaseDir[PLATFORM_MAX_PATH];
   113 	char m_SMRelDir[PLATFORM_MAX_PATH];
   114 	char m_ModDir[32];
   115 	bool m_IsMapLoading;
   116 	bool m_ExecPluginReload;
   117 	bool m_ExecOnMapEnd;
   118 	unsigned int m_target;
   119 	bool m_CheckingAuth;
   120 	bool m_GotBasePath;
   121 };
   122 
   123 extern SourceModBase g_SourceMod;
   124 extern HandleType_t g_WrBitBufType;		//:TODO: find a better place for this
   125 extern HandleType_t g_RdBitBufType;		//:TODO: find a better place for this
   126 
   127 #endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_