2014-08-04 12:36:20 +04:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
2004-01-31 23:56:22 +03:00
|
|
|
|
|
|
|
// *****************************************************
|
|
|
|
// class CModule
|
|
|
|
// *****************************************************
|
|
|
|
|
|
|
|
#ifndef CMODULE_H
|
|
|
|
#define CMODULE_H
|
|
|
|
|
2005-09-10 04:38:42 +04:00
|
|
|
enum MODULE_STATUS
|
|
|
|
{
|
|
|
|
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
|
2008-04-27 04:07:06 +04:00
|
|
|
MODULE_NOT64BIT, // Not 64 bit compatible
|
|
|
|
MODULE_BADGAME, // Module cannot load on the current game mod
|
2004-01-31 23:56:22 +03:00
|
|
|
};
|
|
|
|
|
2004-03-31 22:03:06 +04:00
|
|
|
struct amxx_module_info_s
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *author;
|
|
|
|
const char *version;
|
|
|
|
int reload; // reload on mapchange when nonzero
|
2005-07-15 23:15:58 +04:00
|
|
|
const char *logtag; //added in version 2
|
2006-05-07 13:56:06 +04:00
|
|
|
const char *library; // added in version 4
|
|
|
|
const char *libclass; // added in version 4
|
2004-03-31 22:03:06 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#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 */
|
|
|
|
|
2008-04-27 04:07:06 +04:00
|
|
|
#define AMXX_GAME_OK 0 /* Module can load on this game. */
|
|
|
|
#define AMXX_GAME_BAD 1 /* Module cannot load on this game. */
|
|
|
|
|
2006-05-07 13:56:06 +04:00
|
|
|
#define AMXX_INTERFACE_VERSION 4
|
2004-03-31 22:03:06 +04:00
|
|
|
|
2004-01-31 23:56:22 +03:00
|
|
|
class CModule
|
|
|
|
{
|
2004-08-15 14:53:48 +04:00
|
|
|
String m_Filename; // Filename
|
2005-09-17 03:48:51 +04:00
|
|
|
|
2004-03-31 22:03:06 +04:00
|
|
|
bool m_Metamod; // Using metamod?
|
|
|
|
bool m_Amxx; // Using new module interface?
|
2005-09-17 03:48:51 +04:00
|
|
|
|
2004-03-31 22:03:06 +04:00
|
|
|
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
|
2004-01-31 23:56:22 +03:00
|
|
|
|
2004-03-31 22:03:06 +04:00
|
|
|
void clear(bool clearFilename = true);
|
2004-01-31 23:56:22 +03:00
|
|
|
public:
|
|
|
|
CModule(const char* fname);
|
|
|
|
~CModule();
|
|
|
|
|
|
|
|
// Interface
|
2005-09-10 04:38:42 +04:00
|
|
|
|
2004-01-31 23:56:22 +03:00
|
|
|
bool attachModule();
|
|
|
|
bool queryModule();
|
|
|
|
bool detachModule();
|
2006-05-10 15:23:08 +04:00
|
|
|
void rewriteNativeLists(AMX_NATIVE_INFO *list);
|
2005-09-10 04:38:42 +04:00
|
|
|
|
2005-07-22 23:32:16 +04:00
|
|
|
#ifndef FAKEMETA
|
|
|
|
bool attachMetamod(const char *mmfile, PLUG_LOADTIME now);
|
|
|
|
#endif
|
2005-09-10 04:38:42 +04:00
|
|
|
|
2004-01-31 23:56:22 +03:00
|
|
|
const char* getStatus() const;
|
2004-04-22 11:52:26 +04:00
|
|
|
inline const char* getType() const { return m_Amxx ? "amxx" : (m_Metamod ? "amx&mm" : "amx"); }
|
2005-07-25 10:03:43 +04:00
|
|
|
inline const char* getAuthor() const { return m_InfoNew.author; }
|
|
|
|
inline const char* getVersion() const { return m_InfoNew.version; }
|
|
|
|
inline const char* getName() const { return m_InfoNew.name; }
|
2004-03-31 22:03:06 +04:00
|
|
|
inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new
|
|
|
|
inline int getStatusValue() { return m_Status; }
|
2005-09-17 03:48:51 +04:00
|
|
|
inline bool operator==(const char* fname) { return !strcmp(m_Filename.c_str(), fname); }
|
2005-07-25 10:03:43 +04:00
|
|
|
inline bool isReloadable() { return ((m_Status == MODULE_LOADED) && (m_InfoNew.reload != 0)); }
|
2004-03-31 22:03:06 +04:00
|
|
|
inline bool isAmxx() const { return m_Amxx; }
|
|
|
|
inline const char *getMissingFunc() const { return m_MissingFunc; }
|
2004-08-13 12:46:04 +04:00
|
|
|
inline const char *getFilename() { return m_Filename.c_str(); }
|
2005-07-22 23:32:16 +04:00
|
|
|
inline bool IsMetamod() { return m_Metamod; }
|
2005-09-17 03:48:51 +04:00
|
|
|
|
2006-02-15 02:59:24 +03:00
|
|
|
void CallPluginsLoaded();
|
2006-05-07 13:56:06 +04:00
|
|
|
void CallPluginsUnloaded();
|
|
|
|
void CallPluginsUnloading();
|
2004-03-31 22:03:06 +04:00
|
|
|
|
2006-05-10 15:23:08 +04:00
|
|
|
CVector<AMX_NATIVE_INFO*> m_Natives;
|
2006-09-01 07:29:27 +04:00
|
|
|
CVector<AMX_NATIVE_INFO*> m_NewNatives; // Natives for new (AMXX, not AMX) plugins only
|
2006-05-10 15:23:08 +04:00
|
|
|
CVector<size_t> m_DestroyableIndexes;
|
2004-01-31 23:56:22 +03:00
|
|
|
};
|
|
|
|
|
2005-09-10 04:38:42 +04:00
|
|
|
#endif //CMODULE_H
|