From 32b0c93539d18c4803c0a3094f1bb6703de2d988 Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Wed, 31 Mar 2004 18:03:06 +0000 Subject: [PATCH] support for the new module interface --- amxmodx/CModule.h | 73 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/amxmodx/CModule.h b/amxmodx/CModule.h index a7b13b26..d237ebd8 100755 --- a/amxmodx/CModule.h +++ b/amxmodx/CModule.h @@ -37,26 +37,48 @@ #define CMODULE_H enum MODULE_STATUS { - MODULE_NONE, - MODULE_QUERY, - MODULE_BADLOAD, - MODULE_LOADED, - MODULE_NOINFO, - MODULE_NOQUERY, - MODULE_NOATTACH, - MODULE_OLD + MODULE_NONE, // No module loaded + MODULE_QUERY, // Query failed + MODULE_BADLOAD, // Bad file or the module writer messed something up ;] + MODULE_LOADED, // Loaded + MODULE_NOINFO, // No info + MODULE_NOQUERY, // No query function present + MODULE_NOATTACH, // No attach function present + MODULE_OLD, // Old interface + MODULE_NEWER, // newer interface + MODULE_INTERROR, // Internal error + MODULE_FUNCNOTPRESENT // Function not present }; +struct amxx_module_info_s +{ + const char *name; + const char *author; + const char *version; + int reload; // reload on mapchange when nonzero +}; + + +#define AMXX_OK 0 /* no error */ +#define AMXX_IFVERS 1 /* interface version */ +#define AMXX_PARAM 2 /* Invalid parameter */ +#define AMXX_FUNC_NOT_PRESENT 3 /* Function not present */ + +#define AMXX_INTERFACE_VERSION 1 + class CModule { - String filename; - bool metamod; - module_info_s* info; - DLHANDLE module; - MODULE_STATUS status; + String m_Filename; // Filename + bool m_Metamod; // Using metamod? + bool m_Amxx; // Using new module interface? + module_info_s* m_InfoOld; // module info (old module interface) + amxx_module_info_s m_InfoNew; // module info (new module interface) + DLHANDLE m_Handle; // handle + MODULE_STATUS m_Status; // status + const char *m_MissingFunc; // missing function; only set on MODULE_FUNCNOTPRESENT status + void clear(bool clearFilename = true); public: - CModule(const char* fname); ~CModule(); @@ -65,15 +87,20 @@ public: bool queryModule(); bool detachModule(); const char* getStatus() const; - inline const char* getType() const { return metamod ? "amx&mm" : "amx"; } - inline const char* getAuthor() const { return info ? info->author : "unknown"; } - inline const char* getVersion() const { return info ? info->version : "unknown"; } - inline const char* getName() const { return info ? info->name : "unknown"; } - inline module_info_s* getInfo() const { return info; } - inline int getStatusValue() { return status; } - inline bool operator==( void* fname ) { return !strcmp( filename.str() , (char*)fname ); } - inline bool isReloadable() { return ( (status==MODULE_LOADED) && (info->type==RELOAD_MODULE)); } - CList natives; + inline const char* getType() const { return m_Amxx ? (m_Metamod ? "amxx&mm" : "amxx") : (m_Metamod ? "amx&mm" : "amx"); } + inline const char* getAuthor() const { return m_Amxx ? (m_InfoNew.author) : (m_InfoOld ? m_InfoOld->author : "unknown"); } + inline const char* getVersion() const { return m_Amxx ? (m_InfoNew.version) : (m_InfoOld ? m_InfoOld->version : "unknown"); } + inline const char* getName() const { return m_Amxx ? (m_InfoNew.name) : (m_InfoOld ? m_InfoOld->name : "unknown"); } + inline module_info_s* getInfo() const { return m_InfoOld; } // old + inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new + inline int getStatusValue() { return m_Status; } + inline bool operator==( void* fname ) { return !strcmp( m_Filename.str() , (char*)fname ); } + inline bool isReloadable() { return m_Amxx ? ((m_Status == MODULE_LOADED) && (m_InfoNew.reload != 0)) : ( (m_Status==MODULE_LOADED) && (m_InfoOld->type==RELOAD_MODULE)); } + inline bool isAmxx() const { return m_Amxx; } + inline const char *getMissingFunc() const { return m_MissingFunc; } + inline const char *getFilename() const { return m_Filename.str(); } + + CList m_Natives; };