core/PluginSys.h
author Asher Baker <asherkin@gmail.com>
Fri Dec 14 15:15:12 2012 -0500 (2012-12-14)
changeset 3703 391951cdde71
parent 3613 b0740093756d
child 3790 98b099a406d2
permissions -rw-r--r--
Fixed OnLibraryAdded/Removed not being called in all plugins (bug 5431, r=psychonic).
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
asherkin@3703
   134
enum LibraryAction
asherkin@3703
   135
{
asherkin@3703
   136
	LibraryAction_Removed,
asherkin@3703
   137
	LibraryAction_Added
asherkin@3703
   138
};
asherkin@3703
   139
dvander@978
   140
struct AutoConfig
dvander@978
   141
{
dvander@978
   142
	String autocfg;
dvander@978
   143
	String folder;
dvander@978
   144
	bool create;
dvander@978
   145
};
dvander@978
   146
faluco@1112
   147
class CPlugin;
faluco@1112
   148
dvander@2086
   149
class CPlugin : 
dvander@2086
   150
	public IPlugin,
dvander@2086
   151
	public CNativeOwner
dvander@173
   152
{
dvander@174
   153
	friend class CPluginManager;
dvander@176
   154
	friend class CFunction;
dvander@173
   155
public:
dvander@209
   156
	CPlugin(const char *file);
dvander@209
   157
	~CPlugin();
dvander@209
   158
public:
faluco@641
   159
	PluginType GetType();
faluco@641
   160
	SourcePawn::IPluginContext *GetBaseContext();
faluco@641
   161
	sp_context_t *GetContext();
dvander@2193
   162
	void *GetPluginStructure();
faluco@641
   163
	const char *GetFilename();
faluco@641
   164
	bool IsDebugging();
faluco@641
   165
	PluginStatus GetStatus();
fyrenmoo@2675
   166
	bool IsSilentlyFailed();
fyrenmoo@2675
   167
	void SetSilentlyFailed(bool sf);
dvander@2193
   168
	const sm_plugininfo_t *GetPublicInfo();
faluco@641
   169
	bool SetPauseState(bool paused);
faluco@641
   170
	unsigned int GetSerial();
faluco@641
   171
	IdentityToken_t *GetIdentity();
dvander@1766
   172
	unsigned int CalcMemUsage();
faluco@641
   173
	bool SetProperty(const char *prop, void *ptr);
faluco@641
   174
	bool GetProperty(const char *prop, void **ptr, bool remove=false);
dvander@2086
   175
	void DropEverything();
dvander@2193
   176
	SourcePawn::IPluginRuntime *GetRuntime();
dvander@173
   177
public:
dvander@209
   178
	/**
dvander@209
   179
	 * Creates a plugin object with default values.
dvander@209
   180
	 *   If an error buffer is specified, and an error occurs, the error will be copied to the buffer
dvander@209
   181
	 * and NULL will be returned.
dvander@209
   182
	 *   If an error buffer is not specified, the error will be copied to an internal buffer and 
dvander@209
   183
	 * a valid (but error-stated) CPlugin will be returned.
dvander@209
   184
	 */
dvander@209
   185
	static CPlugin *CreatePlugin(const char *file, char *error, size_t maxlength);
dvander@209
   186
public:
dvander@229
   187
dvander@209
   188
	/**
dvander@209
   189
	 * Sets an error state on the plugin
dvander@209
   190
	 */
dvander@209
   191
	void SetErrorState(PluginStatus status, const char *error_fmt, ...);
dvander@211
   192
dvander@211
   193
	/**
dvander@229
   194
	 * Initializes the plugin's identity information
dvander@229
   195
	 */
dvander@229
   196
	void InitIdentity();
dvander@229
   197
dvander@229
   198
	/**
dvander@211
   199
	 * Calls the OnPluginLoad function, and sets any failed states if necessary.
dvander@211
   200
	 * NOTE: Valid pre-states are: Plugin_Created
dvander@282
   201
	 * NOTE: If validated, plugin state is changed to Plugin_Loaded
dvander@211
   202
	 *
dvander@211
   203
	 * If the error buffer is NULL, the error message is cached locally.
dvander@211
   204
	 */
fyrenmoo@2675
   205
	APLRes Call_AskPluginLoad(char *error, size_t maxlength);
dvander@211
   206
dvander@211
   207
	/**
ds@426
   208
	 * Calls the OnPluginStart function.
dvander@211
   209
	 * NOTE: Valid pre-states are: Plugin_Created
dvander@282
   210
	 * NOTE: Post-state will be Plugin_Running
dvander@211
   211
	 */
ds@426
   212
	void Call_OnPluginStart();
dvander@282
   213
dvander@282
   214
	/**
ds@426
   215
	 * Calls the OnPluginEnd function.
dvander@282
   216
	 */
ds@426
   217
	void Call_OnPluginEnd();
faluco@290
   218
faluco@290
   219
	/**
faluco@1221
   220
	 * Calls the OnAllPluginsLoaded function.
faluco@1221
   221
	 */
faluco@1221
   222
	void Call_OnAllPluginsLoaded();
faluco@1221
   223
faluco@1221
   224
	/**
dvander@315
   225
	 * Returns true if a plugin is usable.
dvander@315
   226
	 */
dvander@615
   227
	bool IsRunnable();
faluco@389
   228
faluco@389
   229
	/**
dvander@2042
   230
	 * Get languages info.
dvander@536
   231
	 */
dvander@2042
   232
	IPhraseCollection *GetPhrases();
dvander@211
   233
public:
faluco@333
   234
	/**
dvander@536
   235
	 * Returns the modification time during last plugin load.
dvander@536
   236
	 */
dvander@615
   237
	time_t GetTimeStamp();
faluco@333
   238
faluco@333
   239
	/**
dvander@536
   240
	 * Returns the current modification time of the plugin file.
dvander@536
   241
	 */
faluco@333
   242
	time_t GetFileTimeStamp();
dvander@282
   243
dvander@282
   244
	/** 
dvander@282
   245
	 * Returns true if the plugin was running, but is now invalid.
dvander@282
   246
	 */
dvander@282
   247
	bool WasRunning();
dvander@536
   248
dvander@536
   249
	Handle_t GetMyHandle();
dvander@978
   250
dvander@2086
   251
	bool AddFakeNative(IPluginFunction *pFunc, const char *name, SPVM_FAKENATIVE_FUNC func);
dvander@978
   252
	void AddConfig(bool autoCreate, const char *cfg, const char *folder);
dvander@978
   253
	unsigned int GetConfigCount();
dvander@978
   254
	AutoConfig *GetConfig(unsigned int i);
faluco@1112
   255
	inline void AddLibrary(const char *name)
faluco@1089
   256
	{
faluco@1112
   257
		m_Libraries.push_back(name);
faluco@1089
   258
	}
asherkin@3703
   259
	void LibraryActions(LibraryAction action);
dvander@2342
   260
	void SyncMaxClients(int max_clients);
dvander@173
   261
protected:
dvander@2342
   262
	bool UpdateInfo();
faluco@333
   263
	void SetTimeStamp(time_t t);
dvander@605
   264
	void DependencyDropped(CPlugin *pOwner);
dvander@173
   265
private:
dvander@174
   266
	PluginType m_type;
ds@652
   267
	char m_filename[PLATFORM_MAX_PATH];
dvander@173
   268
	PluginStatus m_status;
fyrenmoo@2675
   269
	bool m_bSilentlyFailed;
dvander@173
   270
	unsigned int m_serial;
dvander@173
   271
	sm_plugininfo_t m_info;
dvander@209
   272
	char m_errormsg[256];
dvander@211
   273
	time_t m_LastAccess;
dvander@229
   274
	IdentityToken_t *m_ident;
dvander@220
   275
	Handle_t m_handle;
dvander@282
   276
	bool m_WasRunning;
dvander@2042
   277
	IPhraseCollection *m_pPhrases;
faluco@1112
   278
	List<String> m_RequiredLibs;
faluco@1112
   279
	List<String> m_Libraries;
dvander@486
   280
	Trie *m_pProps;
dvander@605
   281
	bool m_FakeNativesMissing;
faluco@1112
   282
	bool m_LibraryMissing;
dvander@978
   283
	CVector<AutoConfig *> m_configs;
dvander@1630
   284
	bool m_bGotAllLoaded;
dvander@2105
   285
	int m_FileVersion;
dvander@2105
   286
	char m_DateTime[256];
dvander@2193
   287
	IPluginRuntime *m_pRuntime;
dvander@2193
   288
	IPluginContext *m_pContext;
dvander@2342
   289
	sp_pubvar_t *m_MaxClientsVar;
dvander@601
   290
};
dvander@601
   291
dvander@220
   292
class CPluginManager : 
dvander@220
   293
	public IPluginManager,
dvander@220
   294
	public SMGlobalClass,
dvander@309
   295
	public IHandleTypeDispatch,
dvander@309
   296
	public IRootConsoleCommand
dvander@174
   297
{
dvander@176
   298
	friend class CPlugin;
dvander@174
   299
public:
dvander@174
   300
	CPluginManager();
dvander@176
   301
	~CPluginManager();
dvander@174
   302
public:
dvander@203
   303
	/* Implements iterator class */
dvander@174
   304
	class CPluginIterator : public IPluginIterator
dvander@174
   305
	{
dvander@174
   306
	public:
dvander@213
   307
		CPluginIterator(List<CPlugin *> *mylist);
dvander@174
   308
		virtual ~CPluginIterator();
dvander@174
   309
		virtual bool MorePlugins();
dvander@174
   310
		virtual IPlugin *GetPlugin();
dvander@174
   311
		virtual void NextPlugin();
dvander@282
   312
		void Release();
dvander@174
   313
	public:
dvander@174
   314
		void Reset();
dvander@174
   315
	private:
dvander@213
   316
		List<CPlugin *> *mylist;
dvander@213
   317
		List<CPlugin *>::iterator current;
dvander@174
   318
	};
dvander@174
   319
	friend class CPluginManager::CPluginIterator;
dvander@203
   320
public: //IPluginManager
dvander@282
   321
	IPlugin *LoadPlugin(const char *path, 
dvander@174
   322
								bool debug,
dvander@174
   323
								PluginType type,
dvander@174
   324
								char error[],
ds@755
   325
								size_t maxlength,
faluco@383
   326
								bool *wasloaded);
dvander@282
   327
	bool UnloadPlugin(IPlugin *plugin);
dvander@282
   328
	IPlugin *FindPluginByContext(const sp_context_t *ctx);
dvander@282
   329
	unsigned int GetPluginCount();
dvander@282
   330
	IPluginIterator *GetPluginIterator();
dvander@282
   331
	void AddPluginsListener(IPluginsListener *listener);
dvander@282
   332
	void RemovePluginsListener(IPluginsListener *listener);
dvander@220
   333
public: //SMGlobalClass
dvander@282
   334
	void OnSourceModAllInitialized();
dvander@282
   335
	void OnSourceModShutdown();
asherkin@3601
   336
	ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
dvander@2342
   337
	void OnSourceModMaxPlayersChanged(int newvalue);
dvander@220
   338
public: //IHandleTypeDispatch
dvander@282
   339
	void OnHandleDestroy(HandleType_t type, void *object);
dvander@1766
   340
	bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
dvander@309
   341
public: //IRootConsoleCommand
faluco@1541
   342
	void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
dvander@190
   343
public:
dvander@203
   344
	/**
dvander@211
   345
	 * Loads all plugins not yet loaded
dvander@203
   346
	 */
dvander@211
   347
	void LoadAll_FirstPass(const char *config, const char *basedir);
dvander@211
   348
dvander@211
   349
	/**
dvander@211
   350
	 * Runs the second loading pass for all plugins
dvander@211
   351
	 */
dvander@211
   352
	void LoadAll_SecondPass();
dvander@203
   353
dvander@203
   354
	/**
dvander@203
   355
	 * Tests a plugin file mask against a local folder.
dvander@203
   356
	 * The alias is searched backwards from localdir - i.e., given this input:
dvander@203
   357
	 *   csdm/ban        csdm/ban
dvander@203
   358
	 *   ban             csdm/ban
dvander@203
   359
	 *   csdm/ban        optional/csdm/ban
dvander@203
   360
	 * All of these will return true for an alias match.  
dvander@203
   361
	 * Wildcards are allowed in the filename.
dvander@203
   362
	 */
dvander@209
   363
	bool TestAliasMatch(const char *alias, const char *localdir);
dvander@211
   364
dvander@211
   365
	/** 
dvander@211
   366
	 * Returns whether anything loaded will be a late load.
dvander@211
   367
	 */
faluco@290
   368
	bool IsLateLoadTime() const;
dvander@233
   369
dvander@233
   370
	/**
dvander@247
   371
	 * Converts a Handle to an IPlugin if possible.
dvander@247
   372
	 */
dvander@247
   373
	IPlugin *PluginFromHandle(Handle_t handle, HandleError *err);
faluco@290
   374
faluco@290
   375
	/**
dvander@309
   376
	 * Finds a plugin based on its index. (starts on index 1)
dvander@309
   377
	 */
faluco@290
   378
	CPlugin *GetPluginByOrder(int num);
dvander@309
   379
dvander@1638
   380
	int GetOrderOfPlugin(IPlugin *pl);
dvander@1638
   381
ds@457
   382
	/** 
ds@457
   383
	 * Internal version of FindPluginByContext()
ds@457
   384
	 */
dvander@2193
   385
	CPlugin *GetPluginByCtx(const sp_context_t *ctx);
ds@457
   386
dvander@309
   387
	/**
dvander@309
   388
	 * Gets status text for a status code 
dvander@309
   389
	 */
dvander@309
   390
	const char *GetStatusText(PluginStatus status);
dvander@315
   391
faluco@333
   392
	/**
faluco@333
   393
	* Reload or update plugins on level shutdown.
faluco@333
   394
	*/
faluco@333
   395
	void ReloadOrUnloadPlugins();
faluco@333
   396
ds@611
   397
	/**
ds@611
   398
	 * Add public functions from all running or paused
ds@611
   399
	 * plugins to the specified forward if the names match.
ds@611
   400
	 */
ds@611
   401
	void AddFunctionsToForward(const char *name, IChangeableForward *pForward);
ds@611
   402
faluco@1221
   403
	/**
faluco@1221
   404
	 * Iterates through plugins to call OnAllPluginsLoaded.
faluco@1221
   405
	 */
faluco@1221
   406
	void AllPluginsLoaded();
faluco@1221
   407
dvander@900
   408
	CPlugin *GetPluginFromIdentity(IdentityToken_t *pToken);
dvander@900
   409
dvander@1018
   410
	void Shutdown();
dvander@1018
   411
asherkin@3703
   412
	void OnLibraryAction(const char *lib, LibraryAction action);
dvander@1124
   413
dvander@1124
   414
	bool LibraryExists(const char *lib);
faluco@1348
   415
faluco@1348
   416
	bool ReloadPlugin(CPlugin *pl);
dvander@1630
   417
dvander@1630
   418
	void UnloadAll();
dvander@1902
   419
dvander@1902
   420
	CPlugin *FindPluginByConsoleArg(const char *arg);
dvander@2342
   421
dvander@2342
   422
	void SyncMaxClients(int max_clients);
dvander@2547
   423
dvander@2547
   424
	void ListPluginsToClient(CPlayer *player, const CCommand &args);
dvander@209
   425
private:
ds@755
   426
	LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength);
dvander@298
   427
dvander@298
   428
	void LoadAutoPlugin(const char *plugin);
dvander@298
   429
dvander@209
   430
	/**
dvander@209
   431
	 * Recursively loads all plugins in the given directory.
dvander@209
   432
	 */
dvander@209
   433
	void LoadPluginsFromDir(const char *basedir, const char *localdir);
dvander@209
   434
dvander@209
   435
	/**
dvander@211
   436
	 * Adds a plugin object.  This is wrapped by LoadPlugin functions.
dvander@211
   437
	 */
dvander@211
   438
	void AddPlugin(CPlugin *pPlugin);
dvander@211
   439
dvander@211
   440
	/**
dvander@211
   441
	 * Runs the second loading pass on a plugin.
dvander@209
   442
	 */
dvander@298
   443
	bool RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength);
dvander@211
   444
dvander@211
   445
	/**
dvander@315
   446
	 * Runs an extension pass on a plugin.
dvander@315
   447
	 */
dvander@315
   448
	bool LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass, char *error, size_t maxlength);
faluco@430
   449
faluco@1112
   450
	/**
faluco@1112
   451
	* Manages required natives.
faluco@1112
   452
	*/
faluco@1112
   453
	bool FindOrRequirePluginDeps(CPlugin *pPlugin, char *error, size_t maxlength);
faluco@1112
   454
faluco@430
   455
	void _SetPauseState(CPlugin *pPlugin, bool pause);
dvander@174
   456
protected:
dvander@209
   457
	/**
dvander@209
   458
	 * Caching internal objects
dvander@209
   459
	 */
dvander@174
   460
	void ReleaseIterator(CPluginIterator *iter);
dvander@900
   461
public:
dvander@229
   462
	inline IdentityToken_t *GetIdentity()
dvander@229
   463
	{
dvander@229
   464
		return m_MyIdent;
dvander@229
   465
	}
dvander@601
   466
private:
faluco@1112
   467
	void TryRefreshDependencies(CPlugin *pOther);
dvander@174
   468
private:
dvander@174
   469
	List<IPluginsListener *> m_listeners;
dvander@213
   470
	List<CPlugin *> m_plugins;
dvander@174
   471
	CStack<CPluginManager::CPluginIterator *> m_iters;
dvander@203
   472
	CPluginInfoDatabase m_PluginInfo;
dvander@211
   473
	Trie *m_LoadLookup;
dvander@211
   474
	bool m_AllPluginsLoaded;
dvander@229
   475
	IdentityToken_t *m_MyIdent;
dvander@601
   476
dvander@601
   477
	/* Dynamic native stuff */
dvander@601
   478
	List<FakeNative *> m_Natives;
dvander@601
   479
dvander@1630
   480
	bool m_LoadingLocked;
asherkin@3601
   481
	
asherkin@3601
   482
	// Config
asherkin@3601
   483
	bool m_bBlockBadPlugins;
asherkin@3703
   484
	
asherkin@3703
   485
	// Forwards
asherkin@3703
   486
	IForward *m_pOnLibraryAdded;
asherkin@3703
   487
	IForward *m_pOnLibraryRemoved;
dvander@174
   488
};
dvander@174
   489
dvander@211
   490
extern CPluginManager g_PluginSys;
dvander@174
   491
dvander@173
   492
#endif //_INCLUDE_SOURCEMOD_PLUGINSYSTEM_H_
dvander@2906
   493