core/sm_globals.h
author David Anderson <dvander@alliedmods.net>
Sun Jul 29 02:44:37 2007 +0000 (2007-07-29)
changeset 1209 abcf0a55a177
parent 1157 61c7092246c6
child 1231 17badaf66ce4
permissions -rw-r--r--
fixed linux build for mysql
     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_GLOBALS_H_
    16 #define _INCLUDE_SOURCEMOD_GLOBALS_H_
    17 
    18 /**
    19  * @file Contains global headers that most files in SourceMod will need.
    20  */
    21 
    22 #include <sp_vm_types.h>
    23 #include <sp_vm_api.h>
    24 #include "sm_platform.h"
    25 #include <IShareSys.h>
    26 
    27 using namespace SourcePawn;
    28 using namespace SourceMod;
    29 
    30 class IServerPluginCallbacks;
    31 
    32 /**
    33  * @brief Lists result codes possible from attempting to set a core configuration option.
    34  */
    35 enum ConfigResult
    36 {
    37 	ConfigResult_Accept = 0,	/**< Config option was successfully set */
    38 	ConfigResult_Reject = 1,	/**< Config option was given an invalid value and was rejected */
    39 	ConfigResult_Ignore = 2		/**< Config option was invalid, but ignored */
    40 };
    41 
    42 /**
    43  * @brief Lists possible sources of a config option change
    44  */
    45 enum ConfigSource
    46 {
    47 	ConfigSource_File = 0,		/**< Config option was set from config file (core.cfg) */
    48 	ConfigSource_Console = 1,	/**< Config option was set from console command (sm config) */
    49 };
    50 
    51 /** 
    52  * @brief Any class deriving from this will be automatically initiated/shutdown by SourceMod
    53  */
    54 class SMGlobalClass
    55 {
    56 	friend class SourceMod_Core;
    57 	friend class SourceModBase;
    58 	friend class CoreConfig;
    59 	friend class CExtensionManager;
    60 public:
    61 	SMGlobalClass();
    62 public:
    63 	/**
    64 	 * @brief Called when SourceMod is initially loading
    65 	 */
    66 	virtual void OnSourceModStartup(bool late)
    67 	{
    68 	}
    69 
    70 	/**
    71 	 * @brief Called after all global classes have initialized
    72 	 */
    73 	virtual void OnSourceModAllInitialized()
    74 	{
    75 	}
    76 
    77 	/**
    78 	 * @brief Called when SourceMod is shutting down
    79 	 */
    80 	virtual void OnSourceModShutdown()
    81 	{
    82 	}
    83 
    84 	/**
    85 	 * @brief Called after SourceMod is completely shut down
    86 	 */
    87 	virtual void OnSourceModAllShutdown()
    88 	{
    89 	}
    90 
    91 	/**
    92 	 * @brief Called when a core config option is changed.
    93 	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
    94 	 * @note It can then be called again when the 'sm config' command is used
    95 	 */
    96 	virtual ConfigResult OnSourceModConfigChanged(const char *key, 
    97 												  const char *value, 
    98 												  ConfigSource source,
    99 												  char *error, 
   100 												  size_t maxlength)
   101 	{
   102 		return ConfigResult_Ignore;
   103 	}
   104 
   105 	/**
   106 	 * @brief Called when the level changes.
   107 	 */
   108 	virtual void OnSourceModLevelChange(const char *mapName)
   109 	{
   110 	}
   111 
   112 	/**
   113 	 * @brief Called when the level ends.
   114 	 */
   115 	virtual void OnSourceModLevelEnd()
   116 	{
   117 	}
   118 
   119 	/**
   120 	 * @brief Called after plugins are loaded on mapchange.
   121 	 */
   122 	virtual void OnSourceModPluginsLoaded()
   123 	{
   124 	}
   125 
   126 	/**
   127 	 * @brief Called when SourceMod receives a pointer to IServerPluginCallbacks from SourceMM
   128 	 */
   129 	virtual void OnSourceModVSPReceived(IServerPluginCallbacks *iface)
   130 	{
   131 	}
   132 
   133 	/**
   134 	 * @brief Called once all MM:S plugins are loaded.
   135 	 */
   136 	virtual void OnSourceModGameInitialized()
   137 	{
   138 	}
   139 
   140 	/**
   141 	 * @brief Called when an identity is dropped (right now, extensions only)
   142 	 */
   143 	virtual void OnSourceModIdentityDropped(IdentityToken_t *pToken)
   144 	{
   145 	}
   146 private:
   147 	SMGlobalClass *m_pGlobalClassNext;
   148 	static SMGlobalClass *head;
   149 };
   150 
   151 extern ISourcePawnEngine *g_pSourcePawn;
   152 extern IVirtualMachine *g_pVM;
   153 extern IdentityToken_t *g_pCoreIdent;
   154 
   155 #include "sm_autonatives.h"
   156 
   157 #endif //_INCLUDE_SOURCEMOD_GLOBALS_H_