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