core/sm_globals.h
author Scott Ehlert <ds@alliedmods.net>
Thu Apr 05 10:55:40 2007 +0000 (2007-04-05)
changeset 669 ce01c2eb020c
parent 663 b526b82e256e
child 673 fc1d50579d06
permissions -rw-r--r--
Various things:
- Fixed inline translations when using %T
- "Improved" caching of server language
- Renamed Translator::GetServerLanguageCode() to GetServerLanguage()
- Added some more comments to sm_globals.h
- Natives folder in project file mysteriously was moved inside Interfaces, so moved it back o_O
- DS hates empty if statements :o
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@661
    30
/**
ds@669
    31
 * @brief Lists result codes possible from attempting to set a core configuration option.
dvander@663
    32
 */
dvander@663
    33
enum ConfigResult
ds@661
    34
{
ds@669
    35
	ConfigResult_Accept = 0,	/**< Config option was successfully set */
ds@669
    36
	ConfigResult_Reject = 1,	/**< Config option was given an invalid value and was rejected */
ds@669
    37
	ConfigResult_Ignore = 2		/**< Config option was invalid, but ignored */
dvander@663
    38
};
dvander@663
    39
ds@669
    40
/**
ds@669
    41
 * @brief Lists possible sources of a config option change
ds@669
    42
 */
dvander@663
    43
enum ConfigSource
dvander@663
    44
{
ds@669
    45
	ConfigSource_File = 0,		/**< Config option was set from config file (core.cfg) */
ds@669
    46
	ConfigSource_Console = 1,	/**< Config option was set from console command (sm config) */
ds@661
    47
};
ds@661
    48
dvander@229
    49
/** 
dvander@229
    50
 * @brief Any class deriving from this will be automatically initiated/shutdown by SourceMod
dvander@229
    51
 */
dvander@229
    52
class SMGlobalClass
dvander@229
    53
{
dvander@229
    54
	friend class SourceModBase;
ds@661
    55
	friend class CoreConfig;
dvander@229
    56
public:
dvander@229
    57
	SMGlobalClass();
dvander@229
    58
public:
dvander@229
    59
	/**
dvander@229
    60
	 * @brief Called when SourceMod is initially loading
dvander@229
    61
	 */
dvander@229
    62
	virtual void OnSourceModStartup(bool late)
dvander@229
    63
	{
dvander@229
    64
	}
dvander@229
    65
dvander@229
    66
	/**
dvander@229
    67
	 * @brief Called after all global classes have initialized
dvander@229
    68
	 */
dvander@229
    69
	virtual void OnSourceModAllInitialized()
dvander@229
    70
	{
dvander@229
    71
	}
dvander@229
    72
dvander@229
    73
	/**
dvander@229
    74
	 * @brief Called when SourceMod is shutting down
dvander@229
    75
	 */
dvander@229
    76
	virtual void OnSourceModShutdown()
dvander@229
    77
	{
dvander@229
    78
	}
faluco@281
    79
faluco@281
    80
	/**
ds@661
    81
	 * @brief Called after SourceMod is completely shut down
ds@661
    82
	 */
faluco@281
    83
	virtual void OnSourceModAllShutdown()
faluco@281
    84
	{
faluco@281
    85
	}
ds@661
    86
ds@661
    87
	/**
ds@661
    88
	 * @brief Called when a core config option is changed.
ds@661
    89
	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
ds@661
    90
	 * @note It can then be called again when the 'sm config' command is used
ds@661
    91
	 */
dvander@663
    92
	virtual ConfigResult OnSourceModConfigChanged(const char *key, 
dvander@663
    93
												  const char *value, 
dvander@663
    94
												  ConfigSource source,
dvander@663
    95
												  char *error, 
dvander@663
    96
												  size_t maxlength)
ds@661
    97
	{
dvander@663
    98
		return ConfigResult_Ignore;
ds@661
    99
	}
dvander@229
   100
private:
dvander@229
   101
	SMGlobalClass *m_pGlobalClassNext;
dvander@229
   102
	static SMGlobalClass *head;
dvander@229
   103
};
dvander@229
   104
dvander@160
   105
extern ISourcePawnEngine *g_pSourcePawn;
dvander@160
   106
extern IVirtualMachine *g_pVM;
dvander@252
   107
extern IdentityToken_t *g_pCoreIdent;
dvander@160
   108
dvander@233
   109
#include "sm_autonatives.h"
dvander@233
   110
dvander@160
   111
#endif //_INCLUDE_SOURCEMOD_GLOBALS_H_