core/sm_globals.h
author Scott Ehlert <ds@alliedmods.net>
Thu Apr 05 03:02:00 2007 +0000 (2007-04-05)
changeset 661 5c0988b9bf0c
parent 653 ef60870067ff
child 663 b526b82e256e
permissions -rw-r--r--
Ugh, initial import of core config file stuff
Warning: This is positively terrible code.
It works, but needs A LOT of work still :\
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@661
    31
* @brief Lists error codes possible from attempting to set a core configuration option.
ds@661
    32
*/
ds@661
    33
enum CoreConfigErr
ds@661
    34
{
ds@661
    35
	CoreConfig_Okay = 0,			/**< No error */
ds@661
    36
	CoreConfig_NoRuntime = 1,		/**< Cannot set config option while SourceMod is running */
ds@661
    37
	CoreConfig_InvalidValue = 2,	/**< Invalid value specified for config option */
ds@661
    38
	CoreConfig_InvalidOption = 3,	/**< Invalid config option specified */
ds@661
    39
	/* -------------------- */
ds@661
    40
	CoreConfig_TOTAL				/**< Total number of core config error codes */
ds@661
    41
};
ds@661
    42
dvander@229
    43
/** 
dvander@229
    44
 * @brief Any class deriving from this will be automatically initiated/shutdown by SourceMod
dvander@229
    45
 */
dvander@229
    46
class SMGlobalClass
dvander@229
    47
{
dvander@229
    48
	friend class SourceModBase;
ds@661
    49
	friend class CoreConfig;
dvander@229
    50
public:
dvander@229
    51
	SMGlobalClass();
dvander@229
    52
public:
dvander@229
    53
	/**
dvander@229
    54
	 * @brief Called when SourceMod is initially loading
dvander@229
    55
	 */
dvander@229
    56
	virtual void OnSourceModStartup(bool late)
dvander@229
    57
	{
dvander@229
    58
	}
dvander@229
    59
dvander@229
    60
	/**
dvander@229
    61
	 * @brief Called after all global classes have initialized
dvander@229
    62
	 */
dvander@229
    63
	virtual void OnSourceModAllInitialized()
dvander@229
    64
	{
dvander@229
    65
	}
dvander@229
    66
dvander@229
    67
	/**
dvander@229
    68
	 * @brief Called when SourceMod is shutting down
dvander@229
    69
	 */
dvander@229
    70
	virtual void OnSourceModShutdown()
dvander@229
    71
	{
dvander@229
    72
	}
faluco@281
    73
faluco@281
    74
	/**
ds@661
    75
	 * @brief Called after SourceMod is completely shut down
ds@661
    76
	 */
faluco@281
    77
	virtual void OnSourceModAllShutdown()
faluco@281
    78
	{
faluco@281
    79
	}
ds@661
    80
ds@661
    81
	/**
ds@661
    82
	 * @brief Called when a core config option is changed.
ds@661
    83
	 * @note This is called once BEFORE OnSourceModStartup() when SourceMod is loading
ds@661
    84
	 * @note It can then be called again when the 'sm config' command is used
ds@661
    85
	 */
ds@661
    86
	virtual CoreConfigErr OnSourceModConfigChanged(const char *option, const char *value)
ds@661
    87
	{
ds@661
    88
		return CoreConfig_InvalidOption;
ds@661
    89
	}
dvander@229
    90
private:
dvander@229
    91
	SMGlobalClass *m_pGlobalClassNext;
dvander@229
    92
	static SMGlobalClass *head;
dvander@229
    93
};
dvander@229
    94
dvander@160
    95
extern ISourcePawnEngine *g_pSourcePawn;
dvander@160
    96
extern IVirtualMachine *g_pVM;
dvander@252
    97
extern IdentityToken_t *g_pCoreIdent;
dvander@160
    98
dvander@233
    99
#include "sm_autonatives.h"
dvander@233
   100
dvander@160
   101
#endif //_INCLUDE_SOURCEMOD_GLOBALS_H_