1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core/interfaces/ILibrarySys.h Sun Nov 05 00:29:44 2006 +0000
1.3 @@ -0,0 +1,114 @@
1.4 +#ifndef _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
1.5 +#define _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
1.6 +
1.7 +#include <IShareSys.h>
1.8 +
1.9 +namespace SourceMod
1.10 +{
1.11 + #define SMINTERFACE_LIBRARYSYS_NAME "ILibrarySys"
1.12 + #define SMINTERFACE_LIBRARYSYS_VERSION 1
1.13 +
1.14 + class ILibrary
1.15 + {
1.16 + public:
1.17 + /**
1.18 + * @brief Closes dynamic library and invalidates pointer.
1.19 + */
1.20 + virtual void CloseLibrary() =0;
1.21 +
1.22 + /**
1.23 + * @brief Retrieves a symbol pointer from the dynamic library.
1.24 + *
1.25 + * @param symname Symbol name.
1.26 + * @return Symbol pointer, NULL if not found.
1.27 + */
1.28 + virtual void *GetSymbolAddress(const char *symname) =0;
1.29 + };
1.30 +
1.31 + /**
1.32 + * @brief Directory browsing abstraction.
1.33 + */
1.34 + class IDirectory
1.35 + {
1.36 + public:
1.37 + /**
1.38 + * @brief Returns true if there are more files to read, false otherwise.
1.39 + */
1.40 + virtual bool MoreFiles() =0;
1.41 +
1.42 + /**
1.43 + * @brief Advances to the next entry in the stream.
1.44 + */
1.45 + virtual void NextEntry() =0;
1.46 +
1.47 + /**
1.48 + * @brief Returns the name of the current entry.
1.49 + */
1.50 + virtual const char *GetEntryName() =0;
1.51 +
1.52 + /**
1.53 + * @brief Returns whether the current entry is a directory.
1.54 + */
1.55 + virtual bool IsEntryDirectory() =0;
1.56 +
1.57 + /**
1.58 + * @brief Returns whether the current entry is a file.
1.59 + */
1.60 + virtual bool IsEntryFile() =0;
1.61 + };
1.62 +
1.63 + /**
1.64 + * @brief Contains various operating system specific code.
1.65 + */
1.66 + class ILibrarySys : public SMInterface
1.67 + {
1.68 + public:
1.69 + virtual const char *GetInterfaceName()
1.70 + {
1.71 + return SMINTERFACE_LIBRARYSYS_NAME;
1.72 + }
1.73 + virtual unsigned int GetInterfaceVersion()
1.74 + {
1.75 + return SMINTERFACE_LIBRARYSYS_VERSION;
1.76 + }
1.77 + public:
1.78 + /**
1.79 + * @brief Opens a dynamic library file.
1.80 + *
1.81 + * @param path Path to library file (.dll/.so).
1.82 + * @param error Buffer for any error message (may be NULL).
1.83 + * @param err_max Maximum length of error buffer.
1.84 + * @return Pointer to an ILibrary, NULL if failed.
1.85 + */
1.86 + virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max) =0;
1.87 +
1.88 + /**
1.89 + * @brief Opens a directory for reading.
1.90 + *
1.91 + * @param path Path to directory.
1.92 + * @param error Buffer for any error message (may be NULL).
1.93 + * @param err_max Maximum length of error buffer.
1.94 + * @return Pointer to an IDirectory, NULL if failed.
1.95 + */
1.96 + virtual IDirectory *OpenDirectory(const char *path, char *error, size_t err_max) =0;
1.97 +
1.98 + /**
1.99 + * @brief Closes a directory and frees its handle.
1.100 + *
1.101 + * @param dir Pointer to IDirectory.
1.102 + */
1.103 + virtual void CloseDirectory(IDirectory *dir) =0;
1.104 +
1.105 + /**
1.106 + * @brief Returns true if the path is a normal file.
1.107 + */
1.108 + virtual bool IsPathFile(const char *path) =0;
1.109 +
1.110 + /**
1.111 + * @brief Returns true if the path is a normal directory.
1.112 + */
1.113 + virtual bool IsPathDirectory(const char *path) =0;
1.114 + };
1.115 +};
1.116 +
1.117 +#endif //_INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/core/interfaces/IModuleSys.h Sun Nov 05 00:29:44 2006 +0000
2.3 @@ -0,0 +1,92 @@
2.4 +#ifndef _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
2.5 +#define _INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
2.6 +
2.7 +#include <IShareSys.h>
2.8 +#include <ILibrarySys.h>
2.9 +
2.10 +namespace SourceMod
2.11 +{
2.12 + class IModuleInterface;
2.13 +
2.14 + class IModule : public IUnloadableParent
2.15 + {
2.16 + public:
2.17 + virtual UnloadableParentType GetParentType()
2.18 + {
2.19 + return ParentType_Module;
2.20 + }
2.21 + public:
2.22 + virtual IModuleInterface *GetModuleInfo() =0;
2.23 + virtual const char *GetFilename() =0;
2.24 + };
2.25 +
2.26 + class IModuleInterface
2.27 + {
2.28 + public:
2.29 + /**
2.30 + * @brief Called when the module is loaded.
2.31 + *
2.32 + * @param me Pointer back to module.
2.33 + * @param sys Pointer to interface sharing system of SourceMod.
2.34 + * @param error Error buffer to print back to, if any.
2.35 + * @param err_max Maximum size of error buffer.
2.36 + * @param late If this module was loaded "late" (i.e. manually).
2.37 + * @return True if load should continue, false otherwise.
2.38 + */
2.39 + virtual bool OnModuleLoad(IModule *me, IShareSys *sys, char *error, size_t err_max, bool late) =0;
2.40 +
2.41 + /**
2.42 + * @brief Called when the module is unloaded.
2.43 + *
2.44 + * @param force True if this unload will be forced.
2.45 + * @param error Error message buffer.
2.46 + * @param err_max Maximum siez of error buffer.
2.47 + * @return True on success, false to request no unload.
2.48 + */
2.49 + virtual bool OnModuleUnload(bool force, char *error, size_t err_max) =0;
2.50 +
2.51 + /**
2.52 + * @brief Called when your pause state is about to change.
2.53 + *
2.54 + * @param pause True if pausing, false if unpausing.
2.55 + */
2.56 + virtual void OnPauseChange(bool pause) =0;
2.57 +
2.58 + public:
2.59 + virtual const char *GetModuleName() =0;
2.60 + virtual const char *GetModuleVersion() =0;
2.61 + virtual const char *GetModuleURL() =0;
2.62 + virtual const char *GetModuleTags() =0;
2.63 + virtual const char *GetModuleAuthor() =0;
2.64 + };
2.65 +
2.66 + #define SMINTERFACE_MODULEMANAGER_NAME "IModuleManager"
2.67 + #define SMINTERFACE_MODULEMANAGER_VERSION 1
2.68 +
2.69 + enum ModuleLifetime
2.70 + {
2.71 + ModuleLifetime_Forever, //Module will never be unloaded automatically
2.72 + ModuleLifetime_Map, //Module will be unloaded at the end of the map
2.73 + ModuleLifetime_Dependent, //Module will be unloaded once its dependencies are gone
2.74 + };
2.75 +
2.76 + class IModuleManager : public SMInterface
2.77 + {
2.78 + public:
2.79 + /**
2.80 + * @brief Loads a module into the module system.
2.81 + *
2.82 + * @param path Path to module file, relative to the modules folder.
2.83 + * @param lifetime Lifetime of the module.
2.84 + * @param error Error buffer.
2.85 + * @param err_max Maximum error buffer length.
2.86 + * @return New IModule on success, NULL on failure.
2.87 + */
2.88 + virtual IModule *LoadModule(const char *path,
2.89 + ModuleLifetime lifetime,
2.90 + char *error,
2.91 + size_t err_max);
2.92 + };
2.93 +};
2.94 +
2.95 +#endif //_INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/core/interfaces/IPluginSys.h Sun Nov 05 00:29:44 2006 +0000
3.3 @@ -0,0 +1,59 @@
3.4 +#ifndef _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
3.5 +#define _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
3.6 +
3.7 +#include <IShareSys.h>
3.8 +
3.9 +#define SMINTERFACE_PLUGINMANAGER_NAME "IPluginManager"
3.10 +#define SMINTERFACE_PLUGINMANAGER_VERSION 1
3.11 +
3.12 +namespace SourceMod
3.13 +{
3.14 + class IPlugin : public IUnloadableParent
3.15 + {
3.16 + public:
3.17 + UnloadableParentType GetParentType()
3.18 + {
3.19 + return ParentType_Module;
3.20 + }
3.21 + };
3.22 +
3.23 + enum PluginLifetime
3.24 + {
3.25 + PluginLifetime_Forever,
3.26 + PluginLifetime_Map
3.27 + };
3.28 +
3.29 + class IPluginManager : public SMInterface
3.30 + {
3.31 + public:
3.32 + virtual const char *GetInterfaceName()
3.33 + {
3.34 + return SMINTERFACE_PLUGINMANAGER_NAME;
3.35 + }
3.36 +
3.37 + virtual unsigned int GetInterfaceVersion()
3.38 + {
3.39 + return SMINTERFACE_PLUGINMANAGER_VERSION;
3.40 + }
3.41 + public:
3.42 + /**
3.43 + * @brief Attempts to load a plugin.
3.44 + *
3.45 + * @param path Path and filename of plugin, relative to plugins folder.
3.46 + * @param extended Whether or not the plugin is a static plugin or optional plugin.
3.47 + * @param debug Whether or not to default the plugin into debug mode.
3.48 + * @param lifetime Lifetime of the plugin.
3.49 + * @param error Buffer to hold any error message.
3.50 + * @param err_max Maximum length of error message buffer.
3.51 + * @return A new plugin pointer on success, false otherwise.
3.52 + */
3.53 + virtual IPlugin *LoadPlugin(const char *path,
3.54 + bool extended,
3.55 + bool debug,
3.56 + PluginLifetime lifetime,
3.57 + char error[],
3.58 + size_t err_max) =0;
3.59 + };
3.60 +};
3.61 +
3.62 +#endif //_INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/core/interfaces/IShareSys.h Sun Nov 05 00:29:44 2006 +0000
4.3 @@ -0,0 +1,135 @@
4.4 +#ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
4.5 +#define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
4.6 +
4.7 +namespace SourceMod
4.8 +{
4.9 + /**
4.10 + * @brief Defines the base functionality required by a shared interface.
4.11 + */
4.12 + class SMInterface
4.13 + {
4.14 + public:
4.15 + /**
4.16 + * @brief Must return an integer defining the interface's version.
4.17 + */
4.18 + virtual unsigned int GetInterfaceVersion() =0;
4.19 +
4.20 + /**
4.21 + * @brief Must return a string defining the interface's unique name.
4.22 + */
4.23 + virtual const char *GetInterfaceName() =0;
4.24 +
4.25 + /**
4.26 + * @brief Must return whether the requested version number is backwards comaptible.
4.27 + * Note: This can be overridden for breaking changes or custom versioning.
4.28 + *
4.29 + * @param version Version number to compare against.
4.30 + * @return True if compatible, false otherwise.
4.31 + */
4.32 + virtual bool IsVersionCompatible(unsigned int version)
4.33 + {
4.34 + if (version > GetInterfaceVersion())
4.35 + {
4.36 + return false;
4.37 + }
4.38 +
4.39 + return true;
4.40 + }
4.41 + };
4.42 +
4.43 + enum UnloadableParentType
4.44 + {
4.45 + ParentType_Module,
4.46 + ParentType_Plugin
4.47 + };
4.48 +
4.49 + /**
4.50 + * @brief Denotes a top-level unloadable object.
4.51 + */
4.52 + class IUnloadableParent
4.53 + {
4.54 + public:
4.55 + virtual UnloadableParentType GetParentType() =0;
4.56 +
4.57 + virtual void *GetParentToken() =0;
4.58 +
4.59 + /**
4.60 + * @brief Called when an interface this object has requested is removed.
4.61 + *
4.62 + * @param pIface Interface being removed.
4.63 + */
4.64 + virtual void OnInterfaceUnlink(SMInterface *pIface) =0;
4.65 + protected:
4.66 + void *m_parent_token;
4.67 + };
4.68 +
4.69 + /**
4.70 + * @brief Listens for unlinked objects.
4.71 + */
4.72 + class IUnlinkListener
4.73 + {
4.74 + public:
4.75 + /**
4.76 + * @brief Called when a parent object is unloaded.
4.77 + *
4.78 + * @param parent The parent object which is dying.
4.79 + */
4.80 + virtual void OnParentUnlink(IUnloadableParent *parent)
4.81 + {
4.82 + }
4.83 + };
4.84 +
4.85 + /**
4.86 + * @brief Tracks dependencies and fires dependency listeners.
4.87 + */
4.88 + class IShareSys
4.89 + {
4.90 + public:
4.91 + /**
4.92 + * @brief Adds an interface to the global interface system
4.93 + *
4.94 + * @param iface Interface pointer (must be unique).
4.95 + * @param parent Parent unloadable token given to the module/interface.
4.96 + */
4.97 + virtual bool AddInterface(SMInterface *iface, IUnloadableParent *parent) =0;
4.98 +
4.99 + /**
4.100 + * @brief Requests an interface from the global interface system.
4.101 + * If found, the interface's internal reference count will be increased.
4.102 + *
4.103 + * @param iface_name Interface name.
4.104 + * @param iface_vers Interface version to attempt to match.
4.105 + * @param me Object requesting this interface, in order to track dependencies.
4.106 + * @param pIface Pointer to store the return value in.
4.107 + */
4.108 + virtual bool RequestInterface(const char *iface_name,
4.109 + unsigned int iface_vers,
4.110 + IUnloadableParent *me,
4.111 + void **pIface) =0;
4.112 +
4.113 + /**
4.114 + * @brief Unloads an interface.
4.115 + *
4.116 + * @param iface Interface pointer.
4.117 + * @param parent Security token, trivial measure to prevent accidental unloads.
4.118 + * This token must match the one used with AddInterface().
4.119 + */
4.120 + virtual void RemoveInterface(SMInterface *iface, IUnloadableParent *parent) =0;
4.121 +
4.122 + /**
4.123 + * @brief Adds an unlink listener.
4.124 + *
4.125 + * @param pListener Listener pointer.
4.126 + */
4.127 + virtual void AddUnlinkListener(IUnlinkListener *pListener) =0;
4.128 +
4.129 + /**
4.130 + * @brief Removes an unlink listener.
4.131 + *
4.132 + * @param pListener Listener pointer.
4.133 + */
4.134 + virtual void RemoveUnlinkListener(IUnlinkListener *pListener) =0;
4.135 + };
4.136 +};
4.137 +
4.138 +#endif //_INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
5.1 --- a/core/mm_api.cpp Sat Nov 04 20:01:12 2006 +0000
5.2 +++ b/core/mm_api.cpp Sun Nov 05 00:29:44 2006 +0000
5.3 @@ -2,72 +2,72 @@
5.4 #include "mm_api.h"
5.5 #include "sm_version.h"
5.6
5.7 -SourceMod g_SourceMod;
5.8 +SourceMod_Core g_SourceMod;
5.9
5.10 PLUGIN_EXPOSE(SourceMod, g_SourceMod);
5.11
5.12 -bool SourceMod::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
5.13 +bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
5.14 {
5.15 PLUGIN_SAVEVARS();
5.16
5.17 return true;
5.18 }
5.19
5.20 -bool SourceMod::Unload(char *error, size_t maxlen)
5.21 +bool SourceMod_Core::Unload(char *error, size_t maxlen)
5.22 {
5.23 return true;
5.24 }
5.25
5.26 -bool SourceMod::Pause(char *error, size_t maxlen)
5.27 +bool SourceMod_Core::Pause(char *error, size_t maxlen)
5.28 {
5.29 return true;
5.30 }
5.31
5.32 -bool SourceMod::Unpause(char *error, size_t maxlen)
5.33 +bool SourceMod_Core::Unpause(char *error, size_t maxlen)
5.34 {
5.35 return true;
5.36 }
5.37
5.38 -void SourceMod::AllPluginsLoaded()
5.39 +void SourceMod_Core::AllPluginsLoaded()
5.40 {
5.41 }
5.42
5.43 -const char *SourceMod::GetAuthor()
5.44 +const char *SourceMod_Core::GetAuthor()
5.45 {
5.46 return "AlliedModders, LLC";
5.47 }
5.48
5.49 -const char *SourceMod::GetName()
5.50 +const char *SourceMod_Core::GetName()
5.51 {
5.52 return "SourceMod";
5.53 }
5.54
5.55 -const char *SourceMod::GetDescription()
5.56 +const char *SourceMod_Core::GetDescription()
5.57 {
5.58 return "Extensible administration and scripting system";
5.59 }
5.60
5.61 -const char *SourceMod::GetURL()
5.62 +const char *SourceMod_Core::GetURL()
5.63 {
5.64 return "http://www.sourcemod.net/";
5.65 }
5.66
5.67 -const char *SourceMod::GetLicense()
5.68 +const char *SourceMod_Core::GetLicense()
5.69 {
5.70 return "See LICENSE.txt";
5.71 }
5.72
5.73 -const char *SourceMod::GetVersion()
5.74 +const char *SourceMod_Core::GetVersion()
5.75 {
5.76 return SOURCEMOD_VERSION;
5.77 }
5.78
5.79 -const char *SourceMod::GetDate()
5.80 +const char *SourceMod_Core::GetDate()
5.81 {
5.82 return __DATE__;
5.83 }
5.84
5.85 -const char *SourceMod::GetLogTag()
5.86 +const char *SourceMod_Core::GetLogTag()
5.87 {
5.88 return "SRCMOD";
5.89 }
6.1 --- a/core/mm_api.h Sat Nov 04 20:01:12 2006 +0000
6.2 +++ b/core/mm_api.h Sun Nov 05 00:29:44 2006 +0000
6.3 @@ -3,7 +3,7 @@
6.4
6.5 #include <ISmmPlugin.h>
6.6
6.7 -class SourceMod : public ISmmPlugin
6.8 +class SourceMod_Core : public ISmmPlugin
6.9 {
6.10 public:
6.11 bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
6.12 @@ -22,7 +22,7 @@
6.13 const char *GetLogTag();
6.14 };
6.15
6.16 -extern SourceMod g_SourceMod;
6.17 +extern SourceMod_Core g_SourceMod;
6.18
6.19 PLUGIN_GLOBALVARS();
6.20
7.1 --- a/core/msvc8/sourcemod_mm.vcproj Sat Nov 04 20:01:12 2006 +0000
7.2 +++ b/core/msvc8/sourcemod_mm.vcproj Sun Nov 05 00:29:44 2006 +0000
7.3 @@ -40,6 +40,7 @@
7.4 <Tool
7.5 Name="VCCLCompilerTool"
7.6 Optimization="0"
7.7 + AdditionalIncludeDirectories="..\interfaces"
7.8 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS"
7.9 MinimalRebuild="true"
7.10 BasicRuntimeChecks="3"
7.11 @@ -116,6 +117,7 @@
7.12 />
7.13 <Tool
7.14 Name="VCCLCompilerTool"
7.15 + AdditionalIncludeDirectories="..\interfaces"
7.16 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SOURCEMOD_MM_EXPORTS"
7.17 RuntimeLibrary="0"
7.18 UsePrecompiledHeader="0"
7.19 @@ -204,6 +206,22 @@
7.20 <Filter
7.21 Name="Interfaces"
7.22 >
7.23 + <File
7.24 + RelativePath="..\interfaces\ILibrarySys.h"
7.25 + >
7.26 + </File>
7.27 + <File
7.28 + RelativePath="..\interfaces\IModuleSys.h"
7.29 + >
7.30 + </File>
7.31 + <File
7.32 + RelativePath="..\interfaces\IPluginMngr.h"
7.33 + >
7.34 + </File>
7.35 + <File
7.36 + RelativePath="..\interfaces\IShareSys.h"
7.37 + >
7.38 + </File>
7.39 </Filter>
7.40 </Files>
7.41 <Globals>
8.1 --- a/core/sm_version.h Sat Nov 04 20:01:12 2006 +0000
8.2 +++ b/core/sm_version.h Sun Nov 05 00:29:44 2006 +0000
8.3 @@ -1,8 +1,8 @@
8.4 #ifndef _INCLUDE_SOURCEMOD_VERSION_H_
8.5 #define _INCLUDE_SOURCEMOD_VERSION_H_
8.6
8.7 -#define SOURCEMOD_VERSION "1.0.0.0"
8.8 -#define SOURCEMOD_V_MAJOR 1
8.9 +#define SOURCEMOD_VERSION "0.0.0.0"
8.10 +#define SOURCEMOD_V_MAJOR 0
8.11 #define SOURCEMOD_V_MINOR 0
8.12 #define SOURCEMOD_V_REV 0
8.13 #define SOURCEMOD_V_BUILD 0