core/sm_globals.h
author David Anderson <dvander@alliedmods.net>
Thu Aug 08 22:02:42 2013 -0700 (2013-08-08)
changeset 3980 dc7dfcd855dc
parent 3010 8ea042c00c80
permissions -rw-r--r--
More Windows build fix.
dvander@370
     1
/**
dvander@2726
     2
 * vim: set ts=4 sw=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
dvander@2726
     5
 * Copyright (C) 2004-2009 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@2726
    79
	SMGlobalClass()
dvander@2726
    80
	{
dvander@2726
    81
		m_pGlobalClassNext = SMGlobalClass::head;
dvander@2726
    82
		SMGlobalClass::head = this;
dvander@2726
    83
	}
dvander@229
    84
public:
dvander@229
    85
	/**
dvander@229
    86
	 * @brief Called when SourceMod is initially loading
dvander@229
    87
	 */
dvander@229
    88
	virtual void OnSourceModStartup(bool late)
dvander@229
    89
	{
dvander@229
    90
	}
dvander@229
    91
dvander@229
    92
	/**
dvander@1915
    93
	 * @brief Called after all global classes have been started up
dvander@1915
    94
	 */
dvander@1915
    95
	virtual void OnSourceModAllInitialized()
dvander@1915
    96
	{
dvander@1915
    97
	}
dvander@1915
    98
dvander@1915
    99
	/**
dvander@229
   100
	 * @brief Called after all global classes have initialized
dvander@229
   101
	 */
dvander@1915
   102
	virtual void OnSourceModAllInitialized_Post()
dvander@229
   103
	{
dvander@229
   104
	}
dvander@229
   105
dvander@229
   106
	/**
dvander@229
   107
	 * @brief Called when SourceMod is shutting down
dvander@229
   108
	 */
dvander@229
   109
	virtual void OnSourceModShutdown()
dvander@229
   110
	{
dvander@229
   111
	}
faluco@281
   112
faluco@281
   113
	/**
ds@661
   114
	 * @brief Called after SourceMod is completely shut down
ds@661
   115
	 */
faluco@281
   116
	virtual void OnSourceModAllShutdown()
faluco@281
   117
	{
faluco@281
   118
	}
ds@661
   119
ds@661
   120
	/**
ds@661
   121
	 * @brief Called when a core config option is changed.
ds@661
   122
	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
ds@661
   123
	 * @note It can then be called again when the 'sm config' command is used
ds@661
   124
	 */
dvander@663
   125
	virtual ConfigResult OnSourceModConfigChanged(const char *key, 
dvander@663
   126
												  const char *value, 
dvander@663
   127
												  ConfigSource source,
dvander@663
   128
												  char *error, 
dvander@663
   129
												  size_t maxlength)
ds@661
   130
	{
dvander@663
   131
		return ConfigResult_Ignore;
ds@661
   132
	}
dvander@673
   133
dvander@673
   134
	/**
dvander@673
   135
	 * @brief Called when the level changes.
dvander@673
   136
	 */
dvander@673
   137
	virtual void OnSourceModLevelChange(const char *mapName)
dvander@673
   138
	{
dvander@673
   139
	}
dvander@673
   140
dvander@673
   141
	/**
dvander@2476
   142
	 * @brief Called when the level has activated.
dvander@2476
   143
	 */
dvander@2476
   144
	virtual void OnSourceModLevelActivated()
dvander@2476
   145
	{
dvander@2476
   146
	}
dvander@2476
   147
dvander@2476
   148
	/**
dvander@916
   149
	 * @brief Called when the level ends.
dvander@916
   150
	 */
dvander@916
   151
	virtual void OnSourceModLevelEnd()
dvander@916
   152
	{
dvander@916
   153
	}
dvander@916
   154
dvander@916
   155
	/**
dvander@673
   156
	 * @brief Called after plugins are loaded on mapchange.
dvander@673
   157
	 */
dvander@673
   158
	virtual void OnSourceModPluginsLoaded()
dvander@673
   159
	{
dvander@673
   160
	}
ds@675
   161
ds@675
   162
	/**
ds@675
   163
	 * @brief Called when SourceMod receives a pointer to IServerPluginCallbacks from SourceMM
ds@675
   164
	 */
dvander@1581
   165
	virtual void OnSourceModVSPReceived()
ds@675
   166
	{
ds@675
   167
	}
dvander@893
   168
dvander@893
   169
	/**
dvander@893
   170
	 * @brief Called once all MM:S plugins are loaded.
dvander@893
   171
	 */
dvander@893
   172
	virtual void OnSourceModGameInitialized()
dvander@893
   173
	{
dvander@893
   174
	}
dvander@1157
   175
dvander@1157
   176
	/**
dvander@1157
   177
	 * @brief Called when an identity is dropped (right now, extensions only)
dvander@1157
   178
	 */
dvander@1157
   179
	virtual void OnSourceModIdentityDropped(IdentityToken_t *pToken)
dvander@1157
   180
	{
dvander@1157
   181
	}
pred@2323
   182
pred@2323
   183
	/**
pred@2323
   184
	 * @brief Called when the server maxplayers changes
pred@2323
   185
	 *
pred@2323
   186
	 * @param newvalue		New maxplayers value.
pred@2323
   187
	 */
pred@2323
   188
	virtual void OnSourceModMaxPlayersChanged(int newvalue)
pred@2323
   189
	{
pred@2323
   190
	}
dvander@2726
   191
public:
dvander@229
   192
	SMGlobalClass *m_pGlobalClassNext;
dvander@229
   193
	static SMGlobalClass *head;
dvander@229
   194
};
dvander@229
   195
dvander@160
   196
extern ISourcePawnEngine *g_pSourcePawn;
dvander@2193
   197
extern ISourcePawnEngine2 *g_pSourcePawn2;
dvander@252
   198
extern IdentityToken_t *g_pCoreIdent;
dvander@160
   199
dvander@2726
   200
namespace SourceMod
dvander@2726
   201
{
dvander@2726
   202
	class IThreader;
dvander@2726
   203
	class ITextParsers;
dvander@2726
   204
}
dvander@2726
   205
dvander@2726
   206
extern IThreader *g_pThreader;
dvander@2726
   207
extern ITextParsers *textparsers;
dvander@2726
   208
dvander@233
   209
#include "sm_autonatives.h"
dvander@233
   210
dvander@160
   211
#endif //_INCLUDE_SOURCEMOD_GLOBALS_H_
dvander@2726
   212