core/sm_globals.h
author David Anderson <dvander@alliedmods.net>
Fri Feb 22 02:28:33 2008 +0000 (2008-02-22)
changeset 1877 ff0bbf1bc094
parent 1581 2562512b4a44
child 1915 ab031366cfd1
permissions -rw-r--r--
added sourcemod's VDF file. yay
dvander@370
     1
/**
ds@653
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
dvander@1231
     5
 * Copyright (C) 2004-2007 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;
dvander@229
    77
public:
dvander@229
    78
	SMGlobalClass();
dvander@229
    79
public:
dvander@229
    80
	/**
dvander@229
    81
	 * @brief Called when SourceMod is initially loading
dvander@229
    82
	 */
dvander@229
    83
	virtual void OnSourceModStartup(bool late)
dvander@229
    84
	{
dvander@229
    85
	}
dvander@229
    86
dvander@229
    87
	/**
dvander@229
    88
	 * @brief Called after all global classes have initialized
dvander@229
    89
	 */
dvander@229
    90
	virtual void OnSourceModAllInitialized()
dvander@229
    91
	{
dvander@229
    92
	}
dvander@229
    93
dvander@229
    94
	/**
dvander@229
    95
	 * @brief Called when SourceMod is shutting down
dvander@229
    96
	 */
dvander@229
    97
	virtual void OnSourceModShutdown()
dvander@229
    98
	{
dvander@229
    99
	}
faluco@281
   100
faluco@281
   101
	/**
ds@661
   102
	 * @brief Called after SourceMod is completely shut down
ds@661
   103
	 */
faluco@281
   104
	virtual void OnSourceModAllShutdown()
faluco@281
   105
	{
faluco@281
   106
	}
ds@661
   107
ds@661
   108
	/**
ds@661
   109
	 * @brief Called when a core config option is changed.
ds@661
   110
	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
ds@661
   111
	 * @note It can then be called again when the 'sm config' command is used
ds@661
   112
	 */
dvander@663
   113
	virtual ConfigResult OnSourceModConfigChanged(const char *key, 
dvander@663
   114
												  const char *value, 
dvander@663
   115
												  ConfigSource source,
dvander@663
   116
												  char *error, 
dvander@663
   117
												  size_t maxlength)
ds@661
   118
	{
dvander@663
   119
		return ConfigResult_Ignore;
ds@661
   120
	}
dvander@673
   121
dvander@673
   122
	/**
dvander@673
   123
	 * @brief Called when the level changes.
dvander@673
   124
	 */
dvander@673
   125
	virtual void OnSourceModLevelChange(const char *mapName)
dvander@673
   126
	{
dvander@673
   127
	}
dvander@673
   128
dvander@673
   129
	/**
dvander@916
   130
	 * @brief Called when the level ends.
dvander@916
   131
	 */
dvander@916
   132
	virtual void OnSourceModLevelEnd()
dvander@916
   133
	{
dvander@916
   134
	}
dvander@916
   135
dvander@916
   136
	/**
dvander@673
   137
	 * @brief Called after plugins are loaded on mapchange.
dvander@673
   138
	 */
dvander@673
   139
	virtual void OnSourceModPluginsLoaded()
dvander@673
   140
	{
dvander@673
   141
	}
ds@675
   142
ds@675
   143
	/**
ds@675
   144
	 * @brief Called when SourceMod receives a pointer to IServerPluginCallbacks from SourceMM
ds@675
   145
	 */
dvander@1581
   146
	virtual void OnSourceModVSPReceived()
ds@675
   147
	{
ds@675
   148
	}
dvander@893
   149
dvander@893
   150
	/**
dvander@893
   151
	 * @brief Called once all MM:S plugins are loaded.
dvander@893
   152
	 */
dvander@893
   153
	virtual void OnSourceModGameInitialized()
dvander@893
   154
	{
dvander@893
   155
	}
dvander@1157
   156
dvander@1157
   157
	/**
dvander@1157
   158
	 * @brief Called when an identity is dropped (right now, extensions only)
dvander@1157
   159
	 */
dvander@1157
   160
	virtual void OnSourceModIdentityDropped(IdentityToken_t *pToken)
dvander@1157
   161
	{
dvander@1157
   162
	}
dvander@229
   163
private:
dvander@229
   164
	SMGlobalClass *m_pGlobalClassNext;
dvander@229
   165
	static SMGlobalClass *head;
dvander@229
   166
};
dvander@229
   167
dvander@160
   168
extern ISourcePawnEngine *g_pSourcePawn;
dvander@160
   169
extern IVirtualMachine *g_pVM;
dvander@252
   170
extern IdentityToken_t *g_pCoreIdent;
dvander@160
   171
dvander@233
   172
#include "sm_autonatives.h"
dvander@233
   173
dvander@160
   174
#endif //_INCLUDE_SOURCEMOD_GLOBALS_H_