New auto-module system

This commit is contained in:
David Anderson 2005-07-15 19:05:31 +00:00
parent b312da8c63
commit 74ec2e75b8
17 changed files with 56 additions and 6 deletions

View File

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

View File

@ -32,7 +32,7 @@
// ***** AMXX stuff *****
// module interface version is 1
#define AMXX_INTERFACE_VERSION 1
#define AMXX_INTERFACE_VERSION 2
// amxx module info
struct amxx_module_info_s
@ -41,6 +41,7 @@ struct amxx_module_info_s
const char *author;
const char *version;
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);
#endif // FN_AMXX_PLUGINSLOADED
// *** Types ***
typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/);
// ***** Module funcs stuff *****
enum ForwardExecType
{
@ -1906,6 +1910,7 @@ enum ForwardParam
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
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 void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...);
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_MERGEDEFINITION_FILE) (const char * /*filename*/);
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_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole;
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_FORMAT g_fn_Format;
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
// Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
void MF_PrintSrvConsole (char * format, ...) { }
const char * MF_GetModname (void) { }
@ -2089,10 +2099,13 @@ void MF_UnregisterSPForward (int id) { }
int MF_GetPlayerFlags (int id) { }
edict_t* MF_GetPlayerEdict (int id) { }
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
#define MF_AddNatives g_fn_AddNatives
#define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString
#define MF_GetAmxAddr g_fn_GetAmxAddr
#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_GetPlayerEdict g_fn_GetPlayerEdict
#define MF_Format g_fn_Format
#define MF_RegisterFunction g_fn_RegisterFunction
#define MF_RequestFunction g_fn_RequestFunction;
/*** Memory ***/
void *operator new(size_t reportedSize);

View File

@ -10,6 +10,8 @@
#endif
#define _cstrike_included
#pragma library cstrike
/* Returns player deaths.
*/
native cs_get_user_deaths(index);

View File

@ -11,6 +11,8 @@
#include <csstats>
#pragma library csx
/*
* Forwards
*/

View File

@ -17,6 +17,8 @@
#endif
#define _dbi_included
#pragma library dbi
enum Sql
{
SQL_FAILED=0,

View File

@ -11,6 +11,8 @@
#include <dodconst>
#pragma library dodfun
/* Function is called after grenade throw */
forward grenade_throw(index,greindex,wId);

View File

@ -12,6 +12,8 @@
#include <dodconst>
#include <dodstats>
#pragma library dodx
/************* Shared Natives Start ********************************/
/* Forward types */

View File

@ -13,6 +13,8 @@
#include <engine_const>
#pragma library engine
native traceresult(type,{Float,Sql,Result,_}:...);
/* Registers a client impulse to a function. Function is passed the ID of the user. */

View File

@ -20,6 +20,8 @@
#include <esf_const>
#pragma library esfmod
/**************************
* Main functions *********
**************************/

View File

@ -9,6 +9,8 @@
#include <fakemeta_const>
#pragma library fakemeta
/* Returns entvar data from an entity Use the pev_* enum to specify which form of data you want returned. */
native pev(_index,_value,{Float,Sql,Result,_}:...)

View File

@ -10,6 +10,8 @@
#endif
#define _fun_included
#pragma library fun
/* Returns 1 if receiver hears sender via voice communication. */
native get_client_listen(receiver, sender);

View File

@ -8,6 +8,7 @@
#endif
#define _geoip_included
#pragma library geoip
//IP address can contain ports, the ports will be stripped out

View File

@ -9,6 +9,8 @@
#endif
#define NS_INC
#pragma library ns
#include <ns_const>

View File

@ -9,6 +9,8 @@
#endif
#define _regex_included
#pragma library regex
enum Regex
{
REGEX_MATCH_FAIL = -2,

View File

@ -13,6 +13,8 @@
#endif
#define _socket_included
#pragma library socket
// Use SOCKET_TCP for TCP Socket connections
#define SOCKET_TCP 1

View File

@ -12,6 +12,7 @@
#include <tfcconst>
#include <tfcstats>
#pragma library tfcx
/************* Shared Natives Start ********************************/

View File

@ -12,6 +12,8 @@
#include <tsconst>
#include <tsstats>
#pragma library tsx
/************* Shared Natives Start ********************************/
/* Forward types */