core/sm_globals.h
author David Anderson <dvander@alliedmods.net>
Sun May 06 06:15:48 2007 +0000 (2007-05-06)
changeset 743 a2804c2faba2
parent 675 40b8bc6ac247
child 893 a3bc816549a8
permissions -rw-r--r--
added request amb251
dvander@370
     1
/**
ds@653
     2
 * vim: set ts=4 :
dvander@370
     3
 * ===============================================================
dvander@370
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
dvander@370
     5
 * ===============================================================
dvander@370
     6
 *
dvander@370
     7
 * This file is not open source and may not be copied without explicit
dvander@370
     8
 * written permission of AlliedModders LLC.  This file may not be redistributed 
dvander@370
     9
 * in whole or significant part.
dvander@370
    10
 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
dvander@370
    11
 *
dvander@370
    12
 * Version: $Id$
dvander@370
    13
 */
dvander@370
    14
dvander@160
    15
#ifndef _INCLUDE_SOURCEMOD_GLOBALS_H_
dvander@160
    16
#define _INCLUDE_SOURCEMOD_GLOBALS_H_
dvander@160
    17
dvander@162
    18
/**
dvander@162
    19
 * @file Contains global headers that most files in SourceMod will need.
dvander@162
    20
 */
dvander@162
    21
dvander@160
    22
#include <sp_vm_types.h>
dvander@160
    23
#include <sp_vm_api.h>
dvander@160
    24
#include "sm_platform.h"
dvander@324
    25
#include <IShareSys.h>
dvander@160
    26
dvander@160
    27
using namespace SourcePawn;
dvander@160
    28
using namespace SourceMod;
dvander@160
    29
ds@675
    30
class IServerPluginCallbacks;
ds@675
    31
ds@661
    32
/**
ds@669
    33
 * @brief Lists result codes possible from attempting to set a core configuration option.
dvander@663
    34
 */
dvander@663
    35
enum ConfigResult
ds@661
    36
{
ds@669
    37
	ConfigResult_Accept = 0,	/**< Config option was successfully set */
ds@669
    38
	ConfigResult_Reject = 1,	/**< Config option was given an invalid value and was rejected */
ds@669
    39
	ConfigResult_Ignore = 2		/**< Config option was invalid, but ignored */
dvander@663
    40
};
dvander@663
    41
ds@669
    42
/**
ds@669
    43
 * @brief Lists possible sources of a config option change
ds@669
    44
 */
dvander@663
    45
enum ConfigSource
dvander@663
    46
{
ds@669
    47
	ConfigSource_File = 0,		/**< Config option was set from config file (core.cfg) */
ds@669
    48
	ConfigSource_Console = 1,	/**< Config option was set from console command (sm config) */
ds@661
    49
};
ds@661
    50
dvander@229
    51
/** 
dvander@229
    52
 * @brief Any class deriving from this will be automatically initiated/shutdown by SourceMod
dvander@229
    53
 */
dvander@229
    54
class SMGlobalClass
dvander@229
    55
{
ds@675
    56
	friend class SourceMod_Core;
dvander@229
    57
	friend class SourceModBase;
ds@661
    58
	friend class CoreConfig;
dvander@229
    59
public:
dvander@229
    60
	SMGlobalClass();
dvander@229
    61
public:
dvander@229
    62
	/**
dvander@229
    63
	 * @brief Called when SourceMod is initially loading
dvander@229
    64
	 */
dvander@229
    65
	virtual void OnSourceModStartup(bool late)
dvander@229
    66
	{
dvander@229
    67
	}
dvander@229
    68
dvander@229
    69
	/**
dvander@229
    70
	 * @brief Called after all global classes have initialized
dvander@229
    71
	 */
dvander@229
    72
	virtual void OnSourceModAllInitialized()
dvander@229
    73
	{
dvander@229
    74
	}
dvander@229
    75
dvander@229
    76
	/**
dvander@229
    77
	 * @brief Called when SourceMod is shutting down
dvander@229
    78
	 */
dvander@229
    79
	virtual void OnSourceModShutdown()
dvander@229
    80
	{
dvander@229
    81
	}
faluco@281
    82
faluco@281
    83
	/**
ds@661
    84
	 * @brief Called after SourceMod is completely shut down
ds@661
    85
	 */
faluco@281
    86
	virtual void OnSourceModAllShutdown()
faluco@281
    87
	{
faluco@281
    88
	}
ds@661
    89
ds@661
    90
	/**
ds@661
    91
	 * @brief Called when a core config option is changed.
ds@661
    92
	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
ds@661
    93
	 * @note It can then be called again when the 'sm config' command is used
ds@661
    94
	 */
dvander@663
    95
	virtual ConfigResult OnSourceModConfigChanged(const char *key, 
dvander@663
    96
												  const char *value, 
dvander@663
    97
												  ConfigSource source,
dvander@663
    98
												  char *error, 
dvander@663
    99
												  size_t maxlength)
ds@661
   100
	{
dvander@663
   101
		return ConfigResult_Ignore;
ds@661
   102
	}
dvander@673
   103
dvander@673
   104
	/**
dvander@673
   105
	 * @brief Called when the level changes.
dvander@673
   106
	 */
dvander@673
   107
	virtual void OnSourceModLevelChange(const char *mapName)
dvander@673
   108
	{
dvander@673
   109
	}
dvander@673
   110
dvander@673
   111
	/**
dvander@673
   112
	 * @brief Called after plugins are loaded on mapchange.
dvander@673
   113
	 */
dvander@673
   114
	virtual void OnSourceModPluginsLoaded()
dvander@673
   115
	{
dvander@673
   116
	}
ds@675
   117
ds@675
   118
	/**
ds@675
   119
	 * @brief Called when SourceMod receives a pointer to IServerPluginCallbacks from SourceMM
ds@675
   120
	 */
ds@675
   121
	virtual void OnSourceModVSPReceived(IServerPluginCallbacks *iface)
ds@675
   122
	{
ds@675
   123
	}
dvander@229
   124
private:
dvander@229
   125
	SMGlobalClass *m_pGlobalClassNext;
dvander@229
   126
	static SMGlobalClass *head;
dvander@229
   127
};
dvander@229
   128
dvander@160
   129
extern ISourcePawnEngine *g_pSourcePawn;
dvander@160
   130
extern IVirtualMachine *g_pVM;
dvander@252
   131
extern IdentityToken_t *g_pCoreIdent;
dvander@160
   132
dvander@233
   133
#include "sm_autonatives.h"
dvander@233
   134
dvander@160
   135
#endif //_INCLUDE_SOURCEMOD_GLOBALS_H_