mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
support for the new module interface
This commit is contained in:
parent
97bf30cb2a
commit
32b0c93539
@ -37,26 +37,48 @@
|
|||||||
#define CMODULE_H
|
#define CMODULE_H
|
||||||
|
|
||||||
enum MODULE_STATUS {
|
enum MODULE_STATUS {
|
||||||
MODULE_NONE,
|
MODULE_NONE, // No module loaded
|
||||||
MODULE_QUERY,
|
MODULE_QUERY, // Query failed
|
||||||
MODULE_BADLOAD,
|
MODULE_BADLOAD, // Bad file or the module writer messed something up ;]
|
||||||
MODULE_LOADED,
|
MODULE_LOADED, // Loaded
|
||||||
MODULE_NOINFO,
|
MODULE_NOINFO, // No info
|
||||||
MODULE_NOQUERY,
|
MODULE_NOQUERY, // No query function present
|
||||||
MODULE_NOATTACH,
|
MODULE_NOATTACH, // No attach function present
|
||||||
MODULE_OLD
|
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
|
class CModule
|
||||||
{
|
{
|
||||||
String filename;
|
String m_Filename; // Filename
|
||||||
bool metamod;
|
bool m_Metamod; // Using metamod?
|
||||||
module_info_s* info;
|
bool m_Amxx; // Using new module interface?
|
||||||
DLHANDLE module;
|
module_info_s* m_InfoOld; // module info (old module interface)
|
||||||
MODULE_STATUS status;
|
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:
|
public:
|
||||||
|
|
||||||
CModule(const char* fname);
|
CModule(const char* fname);
|
||||||
~CModule();
|
~CModule();
|
||||||
|
|
||||||
@ -65,15 +87,20 @@ public:
|
|||||||
bool queryModule();
|
bool queryModule();
|
||||||
bool detachModule();
|
bool detachModule();
|
||||||
const char* getStatus() const;
|
const char* getStatus() const;
|
||||||
inline const char* getType() const { return metamod ? "amx&mm" : "amx"; }
|
inline const char* getType() const { return m_Amxx ? (m_Metamod ? "amxx&mm" : "amxx") : (m_Metamod ? "amx&mm" : "amx"); }
|
||||||
inline const char* getAuthor() const { return info ? info->author : "unknown"; }
|
inline const char* getAuthor() const { return m_Amxx ? (m_InfoNew.author) : (m_InfoOld ? m_InfoOld->author : "unknown"); }
|
||||||
inline const char* getVersion() const { return info ? info->version : "unknown"; }
|
inline const char* getVersion() const { return m_Amxx ? (m_InfoNew.version) : (m_InfoOld ? m_InfoOld->version : "unknown"); }
|
||||||
inline const char* getName() const { return info ? info->name : "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 info; }
|
inline module_info_s* getInfo() const { return m_InfoOld; } // old
|
||||||
inline int getStatusValue() { return status; }
|
inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new
|
||||||
inline bool operator==( void* fname ) { return !strcmp( filename.str() , (char*)fname ); }
|
inline int getStatusValue() { return m_Status; }
|
||||||
inline bool isReloadable() { return ( (status==MODULE_LOADED) && (info->type==RELOAD_MODULE)); }
|
inline bool operator==( void* fname ) { return !strcmp( m_Filename.str() , (char*)fname ); }
|
||||||
CList<AMX_NATIVE_INFO*> natives;
|
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<AMX_NATIVE_INFO*> m_Natives;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user