core/sourcemod.h
author David Anderson <dvander@alliedmods.net>
Mon Oct 22 05:35:31 2007 +0000 (2007-10-22)
changeset 1630 2f2fe925f377
parent 1581 2562512b4a44
child 1690 7cc4f79a0416
permissions -rw-r--r--
- fixed a bug where OnConfigsExecuted() could be ran before OnAllPluginsLoaded()
- added new commands for amb1036, war mode
- fixed a bug in the admin menu
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@159
    32
#ifndef _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
dvander@159
    33
#define _INCLUDE_SOURCEMOD_GLOBALHEADER_H_
dvander@159
    34
dvander@160
    35
#include "sm_globals.h"
dvander@317
    36
#include <ISourceMod.h>
faluco@484
    37
#include <sh_stack.h>
faluco@484
    38
#include "CDataPack.h"
faluco@484
    39
faluco@484
    40
using namespace SourceHook;
dvander@159
    41
dvander@162
    42
/**
dvander@162
    43
 * @brief Implements SourceMod's global overall management, API, and logic
dvander@162
    44
 */
dvander@162
    45
ds@661
    46
class SourceModBase : 
ds@661
    47
	public ISourceMod,
ds@661
    48
	public SMGlobalClass
dvander@160
    49
{
dvander@160
    50
public:
dvander@209
    51
	SourceModBase();
dvander@209
    52
public:
dvander@160
    53
	/**
dvander@160
    54
	 * @brief Initializes SourceMod, or returns an error on failure.
dvander@160
    55
	 */
ds@755
    56
	bool InitializeSourceMod(char *error, size_t maxlength, bool late);
dvander@209
    57
dvander@209
    58
	/** 
dvander@209
    59
	 * @brief Starts everything SourceMod needs to run
dvander@209
    60
	 */
dvander@209
    61
	void StartSourceMod(bool late);
dvander@209
    62
faluco@289
    63
	/** 
dvander@448
    64
	 * @brief Shuts down all SourceMod components
dvander@448
    65
	 */
faluco@289
    66
	void CloseSourceMod();
faluco@289
    67
dvander@209
    68
	/**
dvander@209
    69
	 * @brief Map change hook
dvander@209
    70
	 */
dvander@209
    71
	bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
dvander@209
    72
faluco@333
    73
	/**
dvander@448
    74
	 * @brief Level shutdown hook
dvander@448
    75
	 */
faluco@333
    76
	void LevelShutdown();
faluco@333
    77
dvander@209
    78
	/** 
faluco@484
    79
	 * @brief Returns whether or not a map load is in progress
dvander@209
    80
	 */
faluco@484
    81
	bool IsMapLoading() const;
dvander@209
    82
faluco@422
    83
	/** 
dvander@448
    84
	 * @brief Stores the global target index.
dvander@448
    85
	 */
faluco@422
    86
	void SetGlobalTarget(unsigned int index);
faluco@422
    87
faluco@422
    88
	/** 
dvander@448
    89
	 * @brief Returns the global target index.
dvander@448
    90
	 */
faluco@422
    91
	unsigned int GetGlobalTarget() const;
ds@661
    92
public: // SMGlobalClass
dvander@663
    93
	ConfigResult OnSourceModConfigChanged(const char *key, 
dvander@663
    94
										  const char *value, 
dvander@663
    95
										  ConfigSource source, 
dvander@663
    96
										  char *error, 
dvander@663
    97
										  size_t maxlength);
ds@661
    98
public: // ISourceMod
ds@729
    99
	const char *GetGamePath() const;
faluco@484
   100
	const char *GetSourceModPath() const;
ds@1411
   101
	size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...);
dvander@317
   102
	void LogMessage(IExtension *pExt, const char *format, ...);
dvander@317
   103
	void LogError(IExtension *pExt, const char *format, ...);
dvander@347
   104
	size_t FormatString(char *buffer, size_t maxlength, IPluginContext *pContext, const cell_t *params, unsigned int param);
faluco@484
   105
	IDataPack *CreateDataPack();
faluco@484
   106
	void FreeDataPack(IDataPack *pack);
faluco@484
   107
	HandleType_t GetDataPackHandleType(bool readonly=false);
faluco@682
   108
	KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false);
ds@729
   109
	const char *GetGameFolderName() const;
faluco@733
   110
	ISourcePawnEngine *GetScriptingEngine();
faluco@733
   111
	IVirtualMachine *GetScriptingVM();
dvander@893
   112
	void AllPluginsLoaded();
dvander@1371
   113
	time_t GetAdjustedTime();
dvander@1630
   114
	void GlobalPause();
dvander@1630
   115
	void GlobalUnpause();
dvander@209
   116
	void DoGlobalPluginLoads();
dvander@209
   117
private:
faluco@484
   118
	CStack<CDataPack *> m_freepacks;
ds@652
   119
	char m_SMBaseDir[PLATFORM_MAX_PATH];
ds@652
   120
	char m_SMRelDir[PLATFORM_MAX_PATH];
ds@696
   121
	char m_ModDir[32];
dvander@209
   122
	bool m_IsMapLoading;
faluco@333
   123
	bool m_ExecPluginReload;
faluco@786
   124
	bool m_ExecOnMapEnd;
faluco@422
   125
	unsigned int m_target;
ds@661
   126
	bool m_GotBasePath;
dvander@211
   127
};
dvander@211
   128
dvander@1581
   129
extern bool g_Loaded;
dvander@160
   130
extern SourceModBase g_SourceMod;
dvander@685
   131
extern HandleType_t g_WrBitBufType;		//:TODO: find a better place for this
dvander@685
   132
extern HandleType_t g_RdBitBufType;		//:TODO: find a better place for this
dvander@159
   133
dvander@159
   134
#endif //_INCLUDE_SOURCEMOD_GLOBALHEADER_H_