Committed new SDK version

This commit is contained in:
David Anderson 2005-07-15 19:05:44 +00:00
parent 74ec2e75b8
commit 1a53b7bba7
34 changed files with 455 additions and 106 deletions

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2296,11 +2296,6 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs) C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs)
{ {
if ( gpGamedllFuncs ){
LOG_ERROR(PLID,"gpGamedllFuncs already set");
return(FALSE);
}
if(now > Plugin_info.loadable) { if(now > Plugin_info.loadable) {
LOG_ERROR(PLID, "Can't load module right now"); LOG_ERROR(PLID, "Can't load module right now");
return(FALSE); return(FALSE);
@ -2426,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2437,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2506,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2543,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2675,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2728,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2429,10 +2429,11 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif
@ -2757,8 +2764,8 @@ const char *Mem_MakeSourceFile(const char *sourceFile)
{ {
// init // init
buffer[0] = '['; buffer[0] = '[';
strcpy(buffer + 1, MODULE_LOGTAG); strcpy(buffer + 1, MODULE_NAME);
pos = strlen(MODULE_LOGTAG) + 1; pos = strlen(MODULE_NAME) + 1;
buffer[pos++] = ']'; buffer[pos++] = ']';
} }

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);

View File

@ -2421,9 +2421,6 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
/************* AMXX Stuff *************/ /************* AMXX Stuff *************/
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// *** Globals *** // *** Globals ***
// Module info // Module info
static amxx_module_info_s g_ModuleInfo = static amxx_module_info_s g_ModuleInfo =
@ -2432,15 +2429,17 @@ static amxx_module_info_s g_ModuleInfo =
MODULE_AUTHOR, MODULE_AUTHOR,
MODULE_VERSION, MODULE_VERSION,
#ifdef MODULE_RELOAD_ON_MAPCHANGE #ifdef MODULE_RELOAD_ON_MAPCHANGE
1 1,
#else // MODULE_RELOAD_ON_MAPCHANGE #else // MODULE_RELOAD_ON_MAPCHANGE
0 0,
#endif // MODULE_RELOAD_ON_MAPCHANGE #endif // MODULE_RELOAD_ON_MAPCHANGE
MODULE_LOGTAG
}; };
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
PFN_GET_MODNAME g_fn_GetModname; PFN_GET_MODNAME g_fn_GetModname;
@ -2501,6 +2500,8 @@ PFN_AMX_FINDNATIVE g_fn_AmxFindNative;
PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
PFN_FORMAT g_fn_Format; PFN_FORMAT g_fn_Format;
PFN_REGISTERFUNCTION g_fn_RegisterFunction;
PFN_REQ_FNPTR g_fn_RequestFunction;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2538,15 +2539,19 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
if (!reqFnptrFunc) if (!reqFnptrFunc)
return AMXX_PARAM; return AMXX_PARAM;
g_fn_RequestFunction = reqFnptrFunc;
// Req all known functions // Req all known functions
// Misc // Misc
REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME);
REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R);
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION);
// Amx scripts // Amx scripts
REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT);
@ -2670,6 +2675,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...)
void ValidateMacros_DontCallThis_Smiley() void ValidateMacros_DontCallThis_Smiley()
{ {
MF_BuildPathname("str", "str", 0); MF_BuildPathname("str", "str", 0);
MF_BuildPathnameR(NULL, 0, "%d", 0);
MF_FormatAmxString(NULL, 0, 0, NULL); MF_FormatAmxString(NULL, 0, 0, NULL);
MF_GetAmxAddr(NULL, 0); MF_GetAmxAddr(NULL, 0);
MF_PrintSrvConsole("str", "str", 0); MF_PrintSrvConsole("str", "str", 0);
@ -2723,6 +2729,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_GetPlayerFrags(0); MF_GetPlayerFrags(0);
MF_GetPlayerEdict(0); MF_GetPlayerEdict(0);
MF_Format("", 4, "str"); MF_Format("", 4, "str");
MF_RegisterFunction(NULL, "");
} }
#endif #endif

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff ***** // ***** AMXX stuff *****
// module interface version is 1 // module interface version is 1
#define AMXX_INTERFACE_VERSION 1 #define AMXX_INTERFACE_VERSION 2
// amxx module info // amxx module info
struct amxx_module_info_s struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author; const char *author;
const char *version; const char *version;
int reload; // reload on mapchange when nonzero int reload; // reload on mapchange when nonzero
const char *logtag; // added in version 2
}; };
@ -1883,6 +1884,9 @@ void FN_AMXX_DETACH(void);
void FN_AMXX_PLUGINSLOADED(void); void FN_AMXX_PLUGINSLOADED(void);
#endif // FN_AMXX_PLUGINSLOADED #endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff ***** // ***** Module funcs stuff *****
enum ForwardExecType enum ForwardExecType
{ {
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
typedef const char * (*PFN_GET_MODNAME) (void); typedef const char * (*PFN_GET_MODNAME) (void);
@ -1974,9 +1979,11 @@ typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*f
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/);
typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/);
typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
extern PFN_GET_MODNAME g_fn_GetModname; extern PFN_GET_MODNAME g_fn_GetModname;
@ -2034,12 +2041,15 @@ extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags;
extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict;
extern PFN_FORMAT g_fn_Format; extern PFN_FORMAT g_fn_Format;
extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam;
extern PFN_REGISTERFUNCTION g_fn_RegisterFunction;
extern PFN_REQ_FNPTR g_fn_RequestFunction;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { } void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { } const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { } int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { } edict_t* MF_GetPlayerEdict (int id) { }
const char * MF_Format (const char *fmt, ...) { } const char * MF_Format (const char *fmt, ...) { }
void MF_RegisterFunction (void *pfn, const char *description) { }
void * MF_RequestFunction (const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr #define MF_GetAmxAddr g_fn_GetAmxAddr
#define MF_PrintSrvConsole g_fn_PrintSrvConsole #define MF_PrintSrvConsole g_fn_PrintSrvConsole
@ -2150,6 +2163,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetPlayerFlags g_fn_GetPlayerFlags #define MF_GetPlayerFlags g_fn_GetPlayerFlags
#define MF_GetPlayerEdict g_fn_GetPlayerEdict #define MF_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format #define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);