core/PluginSys.h
author Asher Baker <asherkin@gmail.com>
Sat Sep 08 21:02:46 2012 +0100 (2012-09-08)
changeset 3652 e0a6517dcd89
parent 3613 b0740093756d
child 3703 391951cdde71
permissions -rw-r--r--
Include the auto-version file in the build, so 3rd party plugins compiled aginst the includes get useful versioning info (bug 5453, r=dvander).
dvander@370
     1
/**
ds@653
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
ds@3099
     5
 * Copyright (C) 2004-2010 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@173
    32
#ifndef _INCLUDE_SOURCEMOD_PLUGINSYSTEM_H_
dvander@173
    33
#define _INCLUDE_SOURCEMOD_PLUGINSYSTEM_H_
dvander@173
    34
dvander@211
    35
#include <time.h>
faluco@333
    36
#include <errno.h>
faluco@333
    37
#include <sys/stat.h>
dvander@173
    38
#include <IPluginSys.h>
dvander@220
    39
#include <IHandleSys.h>
ds@611
    40
#include <IForwardSys.h>
dvander@174
    41
#include <sh_list.h>
dvander@174
    42
#include <sh_stack.h>
faluco@389
    43
#include <sh_vector.h>
dvander@601
    44
#include <sh_string.h>
dvander@173
    45
#include "sm_globals.h"
dvander@203
    46
#include "PluginInfoDatabase.h"
dvander@211
    47
#include "sm_trie.h"
dvander@220
    48
#include "sourcemod.h"
dvander@309
    49
#include <IRootConsoleMenu.h>
skamonkey@3515
    50
#if SOURCE_ENGINE >= SE_ALIENSWARM
ds@3099
    51
#include "convar_sm_swarm.h"
skamonkey@3613
    52
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
ds@2400
    53
#include "convar_sm_l4d.h"
skamonkey@3613
    54
#elif SOURCE_ENGINE >= SE_ORANGEBOX
faluco@1541
    55
#include "convar_sm_ob.h"
faluco@1541
    56
#else
ds@457
    57
#include "convar_sm.h"
faluco@1541
    58
#endif
dvander@2042
    59
#include "ITranslator.h"
asherkin@3601
    60
#include "IGameConfigs.h"
dvander@2086
    61
#include "NativeOwner.h"
dvander@2086
    62
#include "ShareSys.h"
dvander@173
    63
dvander@2547
    64
class CPlayer;
dvander@2547
    65
dvander@174
    66
using namespace SourceHook;
dvander@174
    67
dvander@209
    68
/**
dvander@209
    69
 * NOTES:
dvander@209
    70
 *
dvander@1923
    71
 * UPDATE 2008-03-11: These comments are horribly out of date.  They paint a good overall 
dvander@1923
    72
 * picture of how PluginSys works, but things like dependencies and fake natives have 
dvander@1923
    73
 * complicated things quite a bit.
dvander@1923
    74
 *
dvander@209
    75
 *  Currently this system needs a lot of work but it's good skeletally.  Plugin creation 
dvander@209
    76
 * is done without actually compiling anything.  This is done by Load functions in the 
dvander@209
    77
 * manager.  This will need a rewrite when we add context switching.
dvander@209
    78
 *
dvander@209
    79
 *  The plugin object itself has a few things to note.  The most important is that it stores
dvander@209
    80
 * a table of function objects.  The manager marshals allocation and freeing of these objects.
dvander@209
    81
 * The plugin object can be in erroneous states, they are:
dvander@209
    82
 *   Plugin_Error   --> Some error occurred any time during or after compilation.
dvander@209
    83
 *						This error can be cleared since the plugin itself is valid.
dvander@209
    84
 *						However, the state itself being set prevents any runtime action.
dvander@209
    85
 *   Plugin_BadLoad	--> The plugin failed to load entirely and nothing can be done to save it.
dvander@209
    86
 *
dvander@209
    87
 *  If a plugin fails to load externally, it is never added to the internal tracker.  However, 
dvander@209
    88
 * plugins that failed to load from the internal loading mechanism are always tracked.  This 
dvander@209
    89
 * allows users to see which automatically loaded plugins failed, and makes the interface a bit
dvander@209
    90
 * more flexible.
dvander@211
    91
 *
dvander@211
    92
 *  Once a plugin is compiled, it sets its own state to Plugin_Created.  This state is still invalid
dvander@211
    93
 * for execution.  SourceMod is a two pass system, and even though the second pass is not implemented
dvander@211
    94
 * yet, it is structured so Plugin_Created must be switched to Plugin_Running in the second pass.  When
dvander@211
    95
 * implemented, a Created plugin will be switched to Error in the second pass if it not loadable.
dvander@211
    96
 *
dvander@211
    97
 *  The two pass loading mechanism is described below.  Modules/natives are not implemented yet.
dvander@211
    98
 * PASS ONE: All loadable plugins are found and have the following steps performed:
dvander@211
    99
 *			 1.  Loading and compilation is attempted.
dvander@211
   100
 *			 2.  If successful, all natives from Core are added.
dvander@211
   101
 *			 3.  OnPluginLoad() is called.
dvander@211
   102
 *			 4.  If failed, any user natives are scrapped and the process halts here.
dvander@211
   103
 *			 5.  If successful, the plugin is ready for Pass 2.
dvander@211
   104
 * INTERMEDIATE:
dvander@211
   105
 *			 1.  All forced modules are loaded.
dvander@211
   106
 * PASS TWO: All loaded plugins are found and have these steps performed:
dvander@211
   107
 *			 1. Any modules referenced in the plugin that are not already loaded, are loaded.
dvander@211
   108
 *			 2. If any module fails to load and the plugin requires it, load fails and jump to step 6.
dvander@211
   109
 *			 3. If any natives are unresolved, check if they are found in the user-natives pool.
dvander@211
   110
 *			 4. If yes, load succeeds.  If not, natives are passed through a native acceptance filter.
dvander@211
   111
 *			 5. If the filter fails, the plugin is marked as failed.
dvander@211
   112
 *			 6. If the plugin has failed to load at this point, any dynamic natives it has added are scrapped.
dvander@211
   113
 *			    Furthermore, any plugin that referenced these natives must now have pass 2 re-ran.
dvander@211
   114
 * PASS THREE (not a real pass):
ds@426
   115
 *			 7. Once all plugins are deemed to be loaded, OnPluginStart() is called
dvander@209
   116
 */
dvander@209
   117
faluco@383
   118
enum LoadRes
faluco@383
   119
{
faluco@383
   120
	LoadRes_Successful,
faluco@383
   121
	LoadRes_AlreadyLoaded,
dvander@1436
   122
	LoadRes_Failure,
fyrenmoo@2675
   123
	LoadRes_SilentFailure,
dvander@1436
   124
	LoadRes_NeverLoad
faluco@383
   125
};
faluco@383
   126
fyrenmoo@2675
   127
enum APLRes
fyrenmoo@2675
   128
{
fyrenmoo@2675
   129
	APLRes_Success,
fyrenmoo@2675
   130
	APLRes_Failure,
fyrenmoo@2675
   131
	APLRes_SilentFailure
fyrenmoo@2675
   132
};
fyrenmoo@2675
   133
dvander@978
   134
struct AutoConfig
dvander@978
   135
{
dvander@978
   136
	String autocfg;
dvander@978
   137
	String folder;
dvander@978
   138
	bool create;
dvander@978
   139
};
dvander@978
   140
faluco@1112
   141
class CPlugin;
faluco@1112
   142
dvander@2086
   143
class CPlugin : 
dvander@2086
   144
	public IPlugin,
dvander@2086
   145
	public CNativeOwner
dvander@173
   146
{
dvander@174
   147
	friend class CPluginManager;
dvander@176
   148
	friend class CFunction;
dvander@173
   149
public:
dvander@209
   150
	CPlugin(const char *file);
dvander@209
   151
	~CPlugin();
dvander@209
   152
public:
faluco@641
   153
	PluginType GetType();
faluco@641
   154
	SourcePawn::IPluginContext *GetBaseContext();
faluco@641
   155
	sp_context_t *GetContext();
dvander@2193
   156
	void *GetPluginStructure();
faluco@641
   157
	const char *GetFilename();
faluco@641
   158
	bool IsDebugging();
faluco@641
   159
	PluginStatus GetStatus();
fyrenmoo@2675
   160
	bool IsSilentlyFailed();
fyrenmoo@2675
   161
	void SetSilentlyFailed(bool sf);
dvander@2193
   162
	const sm_plugininfo_t *GetPublicInfo();
faluco@641
   163
	bool SetPauseState(bool paused);
faluco@641
   164
	unsigned int GetSerial();
faluco@641
   165
	IdentityToken_t *GetIdentity();
dvander@1766
   166
	unsigned int CalcMemUsage();
faluco@641
   167
	bool SetProperty(const char *prop, void *ptr);
faluco@641
   168
	bool GetProperty(const char *prop, void **ptr, bool remove=false);
dvander@2086
   169
	void DropEverything();
dvander@2193
   170
	SourcePawn::IPluginRuntime *GetRuntime();
dvander@173
   171
public:
dvander@209
   172
	/**
dvander@209
   173
	 * Creates a plugin object with default values.
dvander@209
   174
	 *   If an error buffer is specified, and an error occurs, the error will be copied to the buffer
dvander@209
   175
	 * and NULL will be returned.
dvander@209
   176
	 *   If an error buffer is not specified, the error will be copied to an internal buffer and 
dvander@209
   177
	 * a valid (but error-stated) CPlugin will be returned.
dvander@209
   178
	 */
dvander@209
   179
	static CPlugin *CreatePlugin(const char *file, char *error, size_t maxlength);
dvander@209
   180
public:
dvander@229
   181
dvander@209
   182
	/**
dvander@209
   183
	 * Sets an error state on the plugin
dvander@209
   184
	 */
dvander@209
   185
	void SetErrorState(PluginStatus status, const char *error_fmt, ...);
dvander@211
   186
dvander@211
   187
	/**
dvander@229
   188
	 * Initializes the plugin's identity information
dvander@229
   189
	 */
dvander@229
   190
	void InitIdentity();
dvander@229
   191
dvander@229
   192
	/**
dvander@211
   193
	 * Calls the OnPluginLoad function, and sets any failed states if necessary.
dvander@211
   194
	 * NOTE: Valid pre-states are: Plugin_Created
dvander@282
   195
	 * NOTE: If validated, plugin state is changed to Plugin_Loaded
dvander@211
   196
	 *
dvander@211
   197
	 * If the error buffer is NULL, the error message is cached locally.
dvander@211
   198
	 */
fyrenmoo@2675
   199
	APLRes Call_AskPluginLoad(char *error, size_t maxlength);
dvander@211
   200
dvander@211
   201
	/**
ds@426
   202
	 * Calls the OnPluginStart function.
dvander@211
   203
	 * NOTE: Valid pre-states are: Plugin_Created
dvander@282
   204
	 * NOTE: Post-state will be Plugin_Running
dvander@211
   205
	 */
ds@426
   206
	void Call_OnPluginStart();
dvander@282
   207
dvander@282
   208
	/**
ds@426
   209
	 * Calls the OnPluginEnd function.
dvander@282
   210
	 */
ds@426
   211
	void Call_OnPluginEnd();
faluco@290
   212
faluco@290
   213
	/**
faluco@1221
   214
	 * Calls the OnAllPluginsLoaded function.
faluco@1221
   215
	 */
faluco@1221
   216
	void Call_OnAllPluginsLoaded();
faluco@1221
   217
faluco@1221
   218
	/**
dvander@315
   219
	 * Returns true if a plugin is usable.
dvander@315
   220
	 */
dvander@615
   221
	bool IsRunnable();
faluco@389
   222
faluco@389
   223
	/**
dvander@2042
   224
	 * Get languages info.
dvander@536
   225
	 */
dvander@2042
   226
	IPhraseCollection *GetPhrases();
dvander@211
   227
public:
faluco@333
   228
	/**
dvander@536
   229
	 * Returns the modification time during last plugin load.
dvander@536
   230
	 */
dvander@615
   231
	time_t GetTimeStamp();
faluco@333
   232
faluco@333
   233
	/**
dvander@536
   234
	 * Returns the current modification time of the plugin file.
dvander@536
   235
	 */
faluco@333
   236
	time_t GetFileTimeStamp();
dvander@282
   237
dvander@282
   238
	/** 
dvander@282
   239
	 * Returns true if the plugin was running, but is now invalid.
dvander@282
   240
	 */
dvander@282
   241
	bool WasRunning();
dvander@536
   242
dvander@536
   243
	Handle_t GetMyHandle();
dvander@978
   244
dvander@2086
   245
	bool AddFakeNative(IPluginFunction *pFunc, const char *name, SPVM_FAKENATIVE_FUNC func);
dvander@978
   246
	void AddConfig(bool autoCreate, const char *cfg, const char *folder);
dvander@978
   247
	unsigned int GetConfigCount();
dvander@978
   248
	AutoConfig *GetConfig(unsigned int i);
faluco@1112
   249
	inline void AddLibrary(const char *name)
faluco@1089
   250
	{
faluco@1112
   251
		m_Libraries.push_back(name);
faluco@1089
   252
	}
dvander@1124
   253
	void LibraryActions(bool dropping);
dvander@2342
   254
	void SyncMaxClients(int max_clients);
dvander@173
   255
protected:
dvander@2342
   256
	bool UpdateInfo();
faluco@333
   257
	void SetTimeStamp(time_t t);
dvander@605
   258
	void DependencyDropped(CPlugin *pOwner);
dvander@173
   259
private:
dvander@174
   260
	PluginType m_type;
ds@652
   261
	char m_filename[PLATFORM_MAX_PATH];
dvander@173
   262
	PluginStatus m_status;
fyrenmoo@2675
   263
	bool m_bSilentlyFailed;
dvander@173
   264
	unsigned int m_serial;
dvander@173
   265
	sm_plugininfo_t m_info;
dvander@209
   266
	char m_errormsg[256];
dvander@211
   267
	time_t m_LastAccess;
dvander@229
   268
	IdentityToken_t *m_ident;
dvander@220
   269
	Handle_t m_handle;
dvander@282
   270
	bool m_WasRunning;
dvander@2042
   271
	IPhraseCollection *m_pPhrases;
faluco@1112
   272
	List<String> m_RequiredLibs;
faluco@1112
   273
	List<String> m_Libraries;
dvander@486
   274
	Trie *m_pProps;
dvander@605
   275
	bool m_FakeNativesMissing;
faluco@1112
   276
	bool m_LibraryMissing;
dvander@978
   277
	CVector<AutoConfig *> m_configs;
dvander@1630
   278
	bool m_bGotAllLoaded;
dvander@2105
   279
	int m_FileVersion;
dvander@2105
   280
	char m_DateTime[256];
dvander@2193
   281
	IPluginRuntime *m_pRuntime;
dvander@2193
   282
	IPluginContext *m_pContext;
dvander@2342
   283
	sp_pubvar_t *m_MaxClientsVar;
dvander@601
   284
};
dvander@601
   285
dvander@220
   286
class CPluginManager : 
dvander@220
   287
	public IPluginManager,
dvander@220
   288
	public SMGlobalClass,
dvander@309
   289
	public IHandleTypeDispatch,
dvander@309
   290
	public IRootConsoleCommand
dvander@174
   291
{
dvander@176
   292
	friend class CPlugin;
dvander@174
   293
public:
dvander@174
   294
	CPluginManager();
dvander@176
   295
	~CPluginManager();
dvander@174
   296
public:
dvander@203
   297
	/* Implements iterator class */
dvander@174
   298
	class CPluginIterator : public IPluginIterator
dvander@174
   299
	{
dvander@174
   300
	public:
dvander@213
   301
		CPluginIterator(List<CPlugin *> *mylist);
dvander@174
   302
		virtual ~CPluginIterator();
dvander@174
   303
		virtual bool MorePlugins();
dvander@174
   304
		virtual IPlugin *GetPlugin();
dvander@174
   305
		virtual void NextPlugin();
dvander@282
   306
		void Release();
dvander@174
   307
	public:
dvander@174
   308
		void Reset();
dvander@174
   309
	private:
dvander@213
   310
		List<CPlugin *> *mylist;
dvander@213
   311
		List<CPlugin *>::iterator current;
dvander@174
   312
	};
dvander@174
   313
	friend class CPluginManager::CPluginIterator;
dvander@203
   314
public: //IPluginManager
dvander@282
   315
	IPlugin *LoadPlugin(const char *path, 
dvander@174
   316
								bool debug,
dvander@174
   317
								PluginType type,
dvander@174
   318
								char error[],
ds@755
   319
								size_t maxlength,
faluco@383
   320
								bool *wasloaded);
dvander@282
   321
	bool UnloadPlugin(IPlugin *plugin);
dvander@282
   322
	IPlugin *FindPluginByContext(const sp_context_t *ctx);
dvander@282
   323
	unsigned int GetPluginCount();
dvander@282
   324
	IPluginIterator *GetPluginIterator();
dvander@282
   325
	void AddPluginsListener(IPluginsListener *listener);
dvander@282
   326
	void RemovePluginsListener(IPluginsListener *listener);
dvander@220
   327
public: //SMGlobalClass
dvander@282
   328
	void OnSourceModAllInitialized();
dvander@282
   329
	void OnSourceModShutdown();
asherkin@3601
   330
	ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
dvander@2342
   331
	void OnSourceModMaxPlayersChanged(int newvalue);
dvander@220
   332
public: //IHandleTypeDispatch
dvander@282
   333
	void OnHandleDestroy(HandleType_t type, void *object);
dvander@1766
   334
	bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
dvander@309
   335
public: //IRootConsoleCommand
faluco@1541
   336
	void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
dvander@190
   337
public:
dvander@203
   338
	/**
dvander@211
   339
	 * Loads all plugins not yet loaded
dvander@203
   340
	 */
dvander@211
   341
	void LoadAll_FirstPass(const char *config, const char *basedir);
dvander@211
   342
dvander@211
   343
	/**
dvander@211
   344
	 * Runs the second loading pass for all plugins
dvander@211
   345
	 */
dvander@211
   346
	void LoadAll_SecondPass();
dvander@203
   347
dvander@203
   348
	/**
dvander@203
   349
	 * Tests a plugin file mask against a local folder.
dvander@203
   350
	 * The alias is searched backwards from localdir - i.e., given this input:
dvander@203
   351
	 *   csdm/ban        csdm/ban
dvander@203
   352
	 *   ban             csdm/ban
dvander@203
   353
	 *   csdm/ban        optional/csdm/ban
dvander@203
   354
	 * All of these will return true for an alias match.  
dvander@203
   355
	 * Wildcards are allowed in the filename.
dvander@203
   356
	 */
dvander@209
   357
	bool TestAliasMatch(const char *alias, const char *localdir);
dvander@211
   358
dvander@211
   359
	/** 
dvander@211
   360
	 * Returns whether anything loaded will be a late load.
dvander@211
   361
	 */
faluco@290
   362
	bool IsLateLoadTime() const;
dvander@233
   363
dvander@233
   364
	/**
dvander@247
   365
	 * Converts a Handle to an IPlugin if possible.
dvander@247
   366
	 */
dvander@247
   367
	IPlugin *PluginFromHandle(Handle_t handle, HandleError *err);
faluco@290
   368
faluco@290
   369
	/**
dvander@309
   370
	 * Finds a plugin based on its index. (starts on index 1)
dvander@309
   371
	 */
faluco@290
   372
	CPlugin *GetPluginByOrder(int num);
dvander@309
   373
dvander@1638
   374
	int GetOrderOfPlugin(IPlugin *pl);
dvander@1638
   375
ds@457
   376
	/** 
ds@457
   377
	 * Internal version of FindPluginByContext()
ds@457
   378
	 */
dvander@2193
   379
	CPlugin *GetPluginByCtx(const sp_context_t *ctx);
ds@457
   380
dvander@309
   381
	/**
dvander@309
   382
	 * Gets status text for a status code 
dvander@309
   383
	 */
dvander@309
   384
	const char *GetStatusText(PluginStatus status);
dvander@315
   385
faluco@333
   386
	/**
faluco@333
   387
	* Reload or update plugins on level shutdown.
faluco@333
   388
	*/
faluco@333
   389
	void ReloadOrUnloadPlugins();
faluco@333
   390
ds@611
   391
	/**
ds@611
   392
	 * Add public functions from all running or paused
ds@611
   393
	 * plugins to the specified forward if the names match.
ds@611
   394
	 */
ds@611
   395
	void AddFunctionsToForward(const char *name, IChangeableForward *pForward);
ds@611
   396
faluco@1221
   397
	/**
faluco@1221
   398
	 * Iterates through plugins to call OnAllPluginsLoaded.
faluco@1221
   399
	 */
faluco@1221
   400
	void AllPluginsLoaded();
faluco@1221
   401
dvander@900
   402
	CPlugin *GetPluginFromIdentity(IdentityToken_t *pToken);
dvander@900
   403
dvander@1018
   404
	void Shutdown();
dvander@1018
   405
dvander@1572
   406
	void OnLibraryAction(const char *lib, bool is_a_plugin, bool drop);
dvander@1124
   407
dvander@1124
   408
	bool LibraryExists(const char *lib);
faluco@1348
   409
faluco@1348
   410
	bool ReloadPlugin(CPlugin *pl);
dvander@1630
   411
dvander@1630
   412
	void UnloadAll();
dvander@1902
   413
dvander@1902
   414
	CPlugin *FindPluginByConsoleArg(const char *arg);
dvander@2342
   415
dvander@2342
   416
	void SyncMaxClients(int max_clients);
dvander@2547
   417
dvander@2547
   418
	void ListPluginsToClient(CPlayer *player, const CCommand &args);
dvander@209
   419
private:
ds@755
   420
	LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength);
dvander@298
   421
dvander@298
   422
	void LoadAutoPlugin(const char *plugin);
dvander@298
   423
dvander@209
   424
	/**
dvander@209
   425
	 * Recursively loads all plugins in the given directory.
dvander@209
   426
	 */
dvander@209
   427
	void LoadPluginsFromDir(const char *basedir, const char *localdir);
dvander@209
   428
dvander@209
   429
	/**
dvander@211
   430
	 * Adds a plugin object.  This is wrapped by LoadPlugin functions.
dvander@211
   431
	 */
dvander@211
   432
	void AddPlugin(CPlugin *pPlugin);
dvander@211
   433
dvander@211
   434
	/**
dvander@211
   435
	 * Runs the second loading pass on a plugin.
dvander@209
   436
	 */
dvander@298
   437
	bool RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength);
dvander@211
   438
dvander@211
   439
	/**
dvander@315
   440
	 * Runs an extension pass on a plugin.
dvander@315
   441
	 */
dvander@315
   442
	bool LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass, char *error, size_t maxlength);
faluco@430
   443
faluco@1112
   444
	/**
faluco@1112
   445
	* Manages required natives.
faluco@1112
   446
	*/
faluco@1112
   447
	bool FindOrRequirePluginDeps(CPlugin *pPlugin, char *error, size_t maxlength);
faluco@1112
   448
faluco@430
   449
	void _SetPauseState(CPlugin *pPlugin, bool pause);
dvander@174
   450
protected:
dvander@209
   451
	/**
dvander@209
   452
	 * Caching internal objects
dvander@209
   453
	 */
dvander@174
   454
	void ReleaseIterator(CPluginIterator *iter);
dvander@900
   455
public:
dvander@229
   456
	inline IdentityToken_t *GetIdentity()
dvander@229
   457
	{
dvander@229
   458
		return m_MyIdent;
dvander@229
   459
	}
dvander@601
   460
private:
faluco@1112
   461
	void TryRefreshDependencies(CPlugin *pOther);
dvander@174
   462
private:
dvander@174
   463
	List<IPluginsListener *> m_listeners;
dvander@213
   464
	List<CPlugin *> m_plugins;
dvander@174
   465
	CStack<CPluginManager::CPluginIterator *> m_iters;
dvander@203
   466
	CPluginInfoDatabase m_PluginInfo;
dvander@211
   467
	Trie *m_LoadLookup;
dvander@211
   468
	bool m_AllPluginsLoaded;
dvander@229
   469
	IdentityToken_t *m_MyIdent;
dvander@601
   470
dvander@601
   471
	/* Dynamic native stuff */
dvander@601
   472
	List<FakeNative *> m_Natives;
dvander@601
   473
dvander@1630
   474
	bool m_LoadingLocked;
asherkin@3601
   475
	
asherkin@3601
   476
	// Config
asherkin@3601
   477
	bool m_bBlockBadPlugins;
dvander@174
   478
};
dvander@174
   479
dvander@211
   480
extern CPluginManager g_PluginSys;
dvander@174
   481
dvander@173
   482
#endif //_INCLUDE_SOURCEMOD_PLUGINSYSTEM_H_
dvander@2906
   483