small notice to srvcommands

preparation for extension system import

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40299
This commit is contained in:
David Anderson 2007-01-15 22:33:50 +00:00
parent f4cd98191e
commit 9331fe2a5c
5 changed files with 233 additions and 150 deletions

View File

@ -0,0 +1,165 @@
#ifndef _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
#define _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
#include <IShareSys.h>
#include <ILibrarySys.h>
namespace SourceMod
{
class IExtensionInterface;
/**
* @brief Encapsulates an IExtension.
*/
class IExtension
{
public:
/**
* @brief Returns the extension's API interface
*
* @return An IExtensionInterface pointer.
*/
virtual IExtensionInterface *GetAPI() =0;
/**
* @brief Returns the filename of the extension, relative to the
* extension folder.
*
* @return A string containing the extension file name.
*/
virtual const char *GetFilename() =0;
/**
* @brief Returns the extension's identity token.
*
* @return An IdentityToken_t pointer.
*/
virtual IdentityToken_t *GetIdentity() =0;
};
#define SMINTERFACE_EXTENSIONAPI_VERSION 1
/**
* @brief The interface an extension must expose.
*/
class IExtensionInterface
{
public:
/**
* @brief Called when the extension is loaded.
*
* @param me Pointer back to extension.
* @param sys Pointer to interface sharing system of SourceMod.
* @param error Error buffer to print back to, if any.
* @param err_max Maximum size of error buffer.
* @param late If this extension was loaded "late" (i.e. manually).
* @return True if load should continue, false otherwise.
*/
virtual bool OnExtensionLoad(IExtension *me,
IShareSys *sys,
char *error,
size_t err_max,
bool late) =0;
/**
* @brief Called when the extension is about to be unloaded.
*/
virtual void OnExtensionUnload() =0;
/**
* @brief Called when all extensions are loaded (loading cycle is done).
* If loaded late, this will be called right after OnExtensionLoad().
*/
virtual void OnExtensionsAllLoaded() =0;
/**
* @brief Called when your pause state is about to change.
*
* @param pause True if pausing, false if unpausing.
*/
virtual void OnExtensionPauseChange(bool pause) =0;
virtual unsigned int GetExtensionVersion()
{
return SMINTERFACE_EXTENSIONAPI_VERSION;
}
/**
* @brief Returns true if the extension is Metamod-dependent.
*/
virtual bool IsMetamodExtension() =0;
public:
virtual const char *GetExtensionName() =0;
virtual const char *GetExtensionURL() =0;
virtual const char *GetExtensionTag() =0;
virtual const char *GetExtensionAuthor() =0;
virtual const char *GetExtensionVerString() =0;
virtual const char *GetExtensionDescription() =0;
virtual const char *GetExtensionDateString() =0;
};
#define SMINTERFACE_EXTENSIONMANAGER_NAME "IExtensionManager"
#define SMINTERFACE_EXTENSIONMANAGER_VERSION 1
enum ExtensionLifetime
{
ExtLifetime_Forever, //Extension will never be unloaded automatically
ExtLifetime_Map, //Extension will be unloaded at the end of the map
};
class IExtensionManager : public SMInterface
{
public:
virtual const char *GetInterfaceName()
{
return SMINTERFACE_EXTENSIONMANAGER_NAME;
}
virtual unsigned int GetInterfaceVersion()
{
return SMINTERFACE_EXTENSIONMANAGER_VERSION;
}
public:
/**
* @brief Loads a extension into the extension system.
*
* @param path Path to extension file, relative to the extensions folder.
* @param lifetime Lifetime of the extension.
* @param error Error buffer.
* @param err_max Maximum error buffer length.
* @return New IExtension on success, NULL on failure.
*/
virtual IExtension *LoadModule(const char *path,
ExtensionLifetime lifetime,
char *error,
size_t err_max) =0;
/**
* @brief Returns the number of plugins that will be unloaded when this
* module is unloaded.
*
* @param pExt IExtension pointer.
* @param optional Optional pointer to be filled with # of plugins that
* are dependent, but will continue safely. NOT YET USED.
* @return Total number of dependent plugins.
*/
virtual unsigned int NumberOfPluginDependents(IExtension *pExt, unsigned int *optional) =0;
/**
* @brief Returns whether or not the extension can be unloaded.
*
* @param pExt IExtension pointer.
* @return True if unloading is possible, false otherwise.
*/
virtual bool IsExtensionUnloadable(IExtension *pExtension) =0;
/**
* @brief Attempts to unload a module.
*
* @param pExt IExtension pointer.
* @return True if successful, false otherwise.
*/
virtual bool UnloadModule(IExtension *pExt) =0;
};
};
#endif //_INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_

View File

@ -1,93 +0,0 @@
#ifndef _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
#define _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
#include <IShareSys.h>
#include <ILibrarySys.h>
namespace SourceMod
{
class IModuleInterface;
class IModule
{
public:
virtual IModuleInterface *GetModuleInfo() =0;
virtual const char *GetFilename() =0;
virtual IdentityToken_t GetIdentityToken() =0;
};
class IModuleInterface
{
public:
/**
* @brief Called when the module is loaded.
*
* @param me Pointer back to module.
* @param token Identity token handle.
* @param sys Pointer to interface sharing system of SourceMod.
* @param error Error buffer to print back to, if any.
* @param err_max Maximum size of error buffer.
* @param late If this module was loaded "late" (i.e. manually).
* @return True if load should continue, false otherwise.
*/
virtual bool OnModuleLoad(IModule *me,
IdentityToken_t token,
IShareSys *sys,
char *error,
size_t err_max,
bool late) =0;
/**
* @brief Called when the module is unloaded.
*
* @param force True if this unload will be forced.
* @param error Error message buffer.
* @param err_max Maximum siez of error buffer.
* @return True on success, false to request no unload.
*/
virtual bool OnModuleUnload(bool force, char *error, size_t err_max) =0;
/**
* @brief Called when your pause state is about to change.
*
* @param pause True if pausing, false if unpausing.
*/
virtual void OnPauseChange(bool pause) =0;
public:
virtual const char *GetModuleName() =0;
virtual const char *GetModuleVersion() =0;
virtual const char *GetModuleURL() =0;
virtual const char *GetModuleTags() =0;
virtual const char *GetModuleAuthor() =0;
};
#define SMINTERFACE_MODULEMANAGER_NAME "IModuleManager"
#define SMINTERFACE_MODULEMANAGER_VERSION 1
enum ModuleLifetime
{
ModuleLifetime_Forever, //Module will never be unloaded automatically
ModuleLifetime_Map, //Module will be unloaded at the end of the map
ModuleLifetime_Dependent, //Module will be unloaded once its dependencies are gone
};
class IModuleManager : public SMInterface
{
public:
/**
* @brief Loads a module into the module system.
*
* @param path Path to module file, relative to the modules folder.
* @param lifetime Lifetime of the module.
* @param error Error buffer.
* @param err_max Maximum error buffer length.
* @return New IModule on success, NULL on failure.
*/
virtual IModule *LoadModule(const char *path,
ModuleLifetime lifetime,
char *error,
size_t err_max);
};
};
#endif //_INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="sourcemod_mm"
ProjectGUID="{E39527CD-7CAB-4420-97CC-DA1B93B260BC}"
RootNamespace="sourcemod_mm"
@ -118,8 +118,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\interfaces;..\"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
AdditionalIncludeDirectories="..\interfaces;..\;..\systems;..\..\sourcepawn\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;SOURCEMOD_BUILD"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -340,6 +340,10 @@
RelativePath="..\systems\CFunction.h"
>
</File>
<File
RelativePath="..\systems\ExtensionSys.h"
>
</File>
<File
RelativePath="..\systems\ForwardSys.h"
>
@ -372,6 +376,10 @@
RelativePath="..\systems\CFunction.cpp"
>
</File>
<File
RelativePath="..\systems\ExtensionSys.cpp"
>
</File>
<File
RelativePath="..\systems\ForwardSys.cpp"
>
@ -430,6 +438,58 @@
</File>
</Filter>
</Filter>
<Filter
Name="SourcePawn"
>
<Filter
Name="Header Files"
>
<File
RelativePath="..\vm\sp_vm_basecontext.h"
>
</File>
<File
RelativePath="..\vm\sp_vm_engine.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath="..\vm\sp_vm_basecontext.cpp"
>
</File>
<File
RelativePath="..\vm\sp_vm_engine.cpp"
>
</File>
</Filter>
<Filter
Name="SDK"
>
<File
RelativePath="..\..\sourcepawn\include\sp_file_headers.h"
>
</File>
<File
RelativePath="..\..\sourcepawn\include\sp_typeutil.h"
>
</File>
<File
RelativePath="..\..\sourcepawn\include\sp_vm_api.h"
>
</File>
<File
RelativePath="..\..\sourcepawn\include\sp_vm_base.h"
>
</File>
<File
RelativePath="..\..\sourcepawn\include\sp_vm_types.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="zlib"
>
@ -530,58 +590,6 @@
</File>
</Filter>
</Filter>
<Filter
Name="SourcePawn"
>
<Filter
Name="Header Files"
>
<File
RelativePath="..\vm\sp_vm_basecontext.h"
>
</File>
<File
RelativePath="..\vm\sp_vm_engine.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath="..\vm\sp_vm_basecontext.cpp"
>
</File>
<File
RelativePath="..\vm\sp_vm_engine.cpp"
>
</File>
</Filter>
<Filter
Name="SDK"
>
<File
RelativePath="..\..\sourcepawn\include\sp_file_headers.h"
>
</File>
<File
RelativePath="..\..\sourcepawn\include\sp_typeutil.h"
>
</File>
<File
RelativePath="..\..\sourcepawn\include\sp_vm_api.h"
>
</File>
<File
RelativePath="..\..\sourcepawn\include\sp_vm_base.h"
>
</File>
<File
RelativePath="..\..\sourcepawn\include\sp_vm_types.h"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -23,6 +23,7 @@
#define PLATFORM_MAX_PATH MAX_PATH
#define PLATFORM_SEP_CHAR '\\'
#define PLATFORM_SEP_ALTCHAR '/'
#define PLATFORM_EXTERN_C extern "C" __declspec(dllexport)
#else if defined __linux__
#define PLATFORM_LINUX
#define PLATFORM_POSIX
@ -32,6 +33,7 @@
#define PLATFORM_LIB_EXT "so"
#define PLATFORM_SEP_CHAR '/'
#define PLATFORM_SEP_ALTCHAR '\\'
#define PLATFORM_EXTERN_C extern "C" __attribute__((visibility("default")))
#endif
#endif //_INCLUDE_SOURCEMOD_PLATFORM_H_

View File

@ -227,10 +227,11 @@ CON_COMMAND(sm, "SourceMod Menu")
if (pl->ToggleDebugMode(debug))
{
META_CONPRINTF("Toggled debug mode on plugin %s successfully.\n", pl->GetFilename());
META_CONPRINTF("Successfully toggled debug mode on plugin %s.\n", pl->GetFilename());
return;
} else {
META_CONPRINTF("Could not toggle debug mode in plugin %s.\n", pl->GetFilename());
/* :TODO: ... we should be getting an actual error message here */
META_CONPRINTF("Could not toggle debug mode on plugin %s.\n", pl->GetFilename());
return;
}
}