core/sm_globals.h
author David Anderson <dvander@alliedmods.net>
Wed Aug 01 02:12:47 2007 +0000 (2007-08-01)
changeset 1231 17badaf66ce4
parent 1157 61c7092246c6
child 1330 ab94316bb52b
permissions -rw-r--r--
updated more header files (mostly internal now)
dvander@370
     1
/**
ds@653
     2
 * vim: set ts=4 :
dvander@1231
     3
 * ================================================================
dvander@1231
     4
 * SourceMod
dvander@1231
     5
 * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
dvander@1231
     6
 * ================================================================
dvander@370
     7
 *
dvander@1231
     8
 * This program is free software; you can redistribute it and/or 
dvander@1231
     9
 * modify it under the terms of the GNU General Public License, 
dvander@1231
    10
 * version 3.0, as published by the Free Software Foundation.
dvander@1231
    11
 * 
dvander@1231
    12
 * This program is distributed in the hope that it will be useful,
dvander@1231
    13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
dvander@1231
    14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dvander@1231
    15
 * GNU General Public License for more details.
dvander@1231
    16
 *
dvander@1231
    17
 * You should have received a copy of the GNU General Public License
dvander@1231
    18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1231
    19
 *
dvander@1231
    20
 * As a special exception, AlliedModders LLC gives you permission to 
dvander@1231
    21
 * link the code of this program (as well as its derivative works) to 
dvander@1231
    22
 * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any 
dvander@1231
    23
 * Game MODs that run on software by the Valve Corporation.  You must 
dvander@1231
    24
 * obey the GNU General Public License in all respects for all other 
dvander@1231
    25
 * code used. Additionally, AlliedModders LLC grants this exception 
dvander@1231
    26
 * to all derivative works. AlliedModders LLC defines further 
dvander@1231
    27
 * exceptions, found in LICENSE.txt (as of this writing, version 
dvander@1231
    28
 * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
dvander@370
    29
 *
dvander@370
    30
 * Version: $Id$
dvander@370
    31
 */
dvander@370
    32
dvander@160
    33
#ifndef _INCLUDE_SOURCEMOD_GLOBALS_H_
dvander@160
    34
#define _INCLUDE_SOURCEMOD_GLOBALS_H_
dvander@160
    35
dvander@162
    36
/**
dvander@162
    37
 * @file Contains global headers that most files in SourceMod will need.
dvander@162
    38
 */
dvander@162
    39
dvander@160
    40
#include <sp_vm_types.h>
dvander@160
    41
#include <sp_vm_api.h>
dvander@160
    42
#include "sm_platform.h"
dvander@324
    43
#include <IShareSys.h>
dvander@160
    44
dvander@160
    45
using namespace SourcePawn;
dvander@160
    46
using namespace SourceMod;
dvander@160
    47
ds@675
    48
class IServerPluginCallbacks;
ds@675
    49
ds@661
    50
/**
ds@669
    51
 * @brief Lists result codes possible from attempting to set a core configuration option.
dvander@663
    52
 */
dvander@663
    53
enum ConfigResult
ds@661
    54
{
ds@669
    55
	ConfigResult_Accept = 0,	/**< Config option was successfully set */
ds@669
    56
	ConfigResult_Reject = 1,	/**< Config option was given an invalid value and was rejected */
ds@669
    57
	ConfigResult_Ignore = 2		/**< Config option was invalid, but ignored */
dvander@663
    58
};
dvander@663
    59
ds@669
    60
/**
ds@669
    61
 * @brief Lists possible sources of a config option change
ds@669
    62
 */
dvander@663
    63
enum ConfigSource
dvander@663
    64
{
ds@669
    65
	ConfigSource_File = 0,		/**< Config option was set from config file (core.cfg) */
ds@669
    66
	ConfigSource_Console = 1,	/**< Config option was set from console command (sm config) */
ds@661
    67
};
ds@661
    68
dvander@229
    69
/** 
dvander@229
    70
 * @brief Any class deriving from this will be automatically initiated/shutdown by SourceMod
dvander@229
    71
 */
dvander@229
    72
class SMGlobalClass
dvander@229
    73
{
ds@675
    74
	friend class SourceMod_Core;
dvander@229
    75
	friend class SourceModBase;
ds@661
    76
	friend class CoreConfig;
dvander@1157
    77
	friend class CExtensionManager;
dvander@229
    78
public:
dvander@229
    79
	SMGlobalClass();
dvander@229
    80
public:
dvander@229
    81
	/**
dvander@229
    82
	 * @brief Called when SourceMod is initially loading
dvander@229
    83
	 */
dvander@229
    84
	virtual void OnSourceModStartup(bool late)
dvander@229
    85
	{
dvander@229
    86
	}
dvander@229
    87
dvander@229
    88
	/**
dvander@229
    89
	 * @brief Called after all global classes have initialized
dvander@229
    90
	 */
dvander@229
    91
	virtual void OnSourceModAllInitialized()
dvander@229
    92
	{
dvander@229
    93
	}
dvander@229
    94
dvander@229
    95
	/**
dvander@229
    96
	 * @brief Called when SourceMod is shutting down
dvander@229
    97
	 */
dvander@229
    98
	virtual void OnSourceModShutdown()
dvander@229
    99
	{
dvander@229
   100
	}
faluco@281
   101
faluco@281
   102
	/**
ds@661
   103
	 * @brief Called after SourceMod is completely shut down
ds@661
   104
	 */
faluco@281
   105
	virtual void OnSourceModAllShutdown()
faluco@281
   106
	{
faluco@281
   107
	}
ds@661
   108
ds@661
   109
	/**
ds@661
   110
	 * @brief Called when a core config option is changed.
ds@661
   111
	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
ds@661
   112
	 * @note It can then be called again when the 'sm config' command is used
ds@661
   113
	 */
dvander@663
   114
	virtual ConfigResult OnSourceModConfigChanged(const char *key, 
dvander@663
   115
												  const char *value, 
dvander@663
   116
												  ConfigSource source,
dvander@663
   117
												  char *error, 
dvander@663
   118
												  size_t maxlength)
ds@661
   119
	{
dvander@663
   120
		return ConfigResult_Ignore;
ds@661
   121
	}
dvander@673
   122
dvander@673
   123
	/**
dvander@673
   124
	 * @brief Called when the level changes.
dvander@673
   125
	 */
dvander@673
   126
	virtual void OnSourceModLevelChange(const char *mapName)
dvander@673
   127
	{
dvander@673
   128
	}
dvander@673
   129
dvander@673
   130
	/**
dvander@916
   131
	 * @brief Called when the level ends.
dvander@916
   132
	 */
dvander@916
   133
	virtual void OnSourceModLevelEnd()
dvander@916
   134
	{
dvander@916
   135
	}
dvander@916
   136
dvander@916
   137
	/**
dvander@673
   138
	 * @brief Called after plugins are loaded on mapchange.
dvander@673
   139
	 */
dvander@673
   140
	virtual void OnSourceModPluginsLoaded()
dvander@673
   141
	{
dvander@673
   142
	}
ds@675
   143
ds@675
   144
	/**
ds@675
   145
	 * @brief Called when SourceMod receives a pointer to IServerPluginCallbacks from SourceMM
ds@675
   146
	 */
ds@675
   147
	virtual void OnSourceModVSPReceived(IServerPluginCallbacks *iface)
ds@675
   148
	{
ds@675
   149
	}
dvander@893
   150
dvander@893
   151
	/**
dvander@893
   152
	 * @brief Called once all MM:S plugins are loaded.
dvander@893
   153
	 */
dvander@893
   154
	virtual void OnSourceModGameInitialized()
dvander@893
   155
	{
dvander@893
   156
	}
dvander@1157
   157
dvander@1157
   158
	/**
dvander@1157
   159
	 * @brief Called when an identity is dropped (right now, extensions only)
dvander@1157
   160
	 */
dvander@1157
   161
	virtual void OnSourceModIdentityDropped(IdentityToken_t *pToken)
dvander@1157
   162
	{
dvander@1157
   163
	}
dvander@229
   164
private:
dvander@229
   165
	SMGlobalClass *m_pGlobalClassNext;
dvander@229
   166
	static SMGlobalClass *head;
dvander@229
   167
};
dvander@229
   168
dvander@160
   169
extern ISourcePawnEngine *g_pSourcePawn;
dvander@160
   170
extern IVirtualMachine *g_pVM;
dvander@252
   171
extern IdentityToken_t *g_pCoreIdent;
dvander@160
   172
dvander@233
   173
#include "sm_autonatives.h"
dvander@233
   174
dvander@160
   175
#endif //_INCLUDE_SOURCEMOD_GLOBALS_H_