2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2025-01-14 23:57:57 +03:00

Added missed EXT_FUNC

This commit is contained in:
asmodai 2017-01-06 22:33:36 +03:00
parent 87548b9af9
commit 8a996d4027
7 changed files with 34 additions and 80 deletions

View File

@ -41,7 +41,7 @@ void meta_register_cmdcvar()
} }
// Parse "meta" console command. // Parse "meta" console command.
void server_meta() void EXT_FUNC server_meta()
{ {
const char *cmd = CMD_ARGV(1); const char *cmd = CMD_ARGV(1);
@ -59,7 +59,7 @@ void server_meta()
} }
// Parse "meta" client command. // Parse "meta" client command.
void client_meta(edict_t* pEntity) void EXT_FUNC client_meta(edict_t* pEntity)
{ {
const char *cmd = CMD_ARGV(1); const char *cmd = CMD_ARGV(1);
META_LOG("ClientCommand 'meta %s' from player '%s'", CMD_ARGS(), STRING(pEntity->v.netname)); META_LOG("ClientCommand 'meta %s' from player '%s'", CMD_ARGS(), STRING(pEntity->v.netname));

View File

@ -29,7 +29,7 @@ void mm_ClientCommand(edict_t *pEntity)
} }
} }
void mm_ServerDeactivate(void) void EXT_FUNC mm_ServerDeactivate(void)
{ {
sFunctionTable_jit.pfnServerDeactivate(); sFunctionTable_jit.pfnServerDeactivate();
@ -46,11 +46,13 @@ void mm_ServerDeactivate(void)
// from the previous map. It's also called right before shutdown, // from the previous map. It's also called right before shutdown,
// which means whenever hlds quits, it'll reload the plugins just // which means whenever hlds quits, it'll reload the plugins just
// before it exits, which is rather silly, but oh well. // before it exits, which is rather silly, but oh well.
g_plugins->refresh(PT_CHANGELEVEL); g_plugins->refresh(PT_CHANGELEVEL); // <- callbacks rebuilded (!)
g_plugins->unpause_all(); g_plugins->unpause_all();
// g_plugins->retry_all(PT_CHANGELEVEL); // g_plugins->retry_all(PT_CHANGELEVEL);
g_players.clear_all_cvar_queries(); g_players.clear_all_cvar_queries();
requestid_counter = 0; requestid_counter = 0;
/* RETURN TO ENGINE */
} }
compile_data_t g_dllfunc_cdata[] = compile_data_t g_dllfunc_cdata[] =
@ -259,7 +261,7 @@ void compile_gamedll_tramps()
*(size_t *)(size_t(&sFunctionTable) + cd.offset) = g_jit.compile_tramp(size_t(&sFunctionTable_jit) + cd.offset); *(size_t *)(size_t(&sFunctionTable) + cd.offset) = g_jit.compile_tramp(size_t(&sFunctionTable_jit) + cd.offset);
} }
// use direct hook // use direct hook to prevent crash after callbacks rebuilding
sFunctionTable.pfnServerDeactivate = mm_ServerDeactivate; sFunctionTable.pfnServerDeactivate = mm_ServerDeactivate;
for (auto& cd : g_newdllfunc_cdata) { for (auto& cd : g_newdllfunc_cdata) {

View File

@ -8887,7 +8887,8 @@ struct function_cdecl<R, Derived, A1, detail::ArgNone, detail::ArgNone, detail::
typename detail::ResultTraits<R>::ResultPtr result_ptr; typename detail::ResultTraits<R>::ResultPtr result_ptr;
operator FuncPtr() { return (FuncPtr)GetCode(); } operator FuncPtr() { return (FuncPtr)GetCode(); }
void InternalMain() {static_cast<Derived *>(this)->naked_main();} void InternalMain() {static_cast<Derived *>(this)->naked_main();}
void naked_main() {
virtual void naked_main() {
using namespace detail::calling_convention_cdecl; using namespace detail::calling_convention_cdecl;
Prolog(); Prolog();
detail::ResultDest result_dst(*this, ResultInfo<R>()); detail::ResultDest result_dst(*this, ResultInfo<R>());

View File

@ -31,10 +31,6 @@ unsigned int CALL_API_count = 0;
int requestid_counter = 0; int requestid_counter = 0;
#ifdef UNFINISHED
MHookList *Hooks;
#endif // UNFINISHED
// Very first metamod function that's run. // Very first metamod function that's run.
// Do startup operations... // Do startup operations...
void metamod_startup() void metamod_startup()

View File

@ -10,7 +10,7 @@ hudtextparms_t default_csay_tparms = {
}; };
// Log to console; newline added. // Log to console; newline added.
void mutil_LogConsole(plid_t plid, const char *fmt, ...) void EXT_FUNC mutil_LogConsole(plid_t plid, const char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[MAX_LOGMSG_LEN]; char buf[MAX_LOGMSG_LEN];
@ -31,7 +31,7 @@ void mutil_LogConsole(plid_t plid, const char *fmt, ...)
} }
// Log regular message to logs; newline added. // Log regular message to logs; newline added.
void mutil_LogMessage(plid_t plid, const char *fmt, ...) void EXT_FUNC mutil_LogMessage(plid_t plid, const char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[MAX_LOGMSG_LEN]; char buf[MAX_LOGMSG_LEN];
@ -44,7 +44,7 @@ void mutil_LogMessage(plid_t plid, const char *fmt, ...)
} }
// Log an error message to logs; newline added. // Log an error message to logs; newline added.
void mutil_LogError(plid_t plid, const char *fmt, ...) void EXT_FUNC mutil_LogError(plid_t plid, const char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[MAX_LOGMSG_LEN]; char buf[MAX_LOGMSG_LEN];
@ -57,7 +57,7 @@ void mutil_LogError(plid_t plid, const char *fmt, ...)
} }
// Log a message only if cvar "developer" set; newline added. // Log a message only if cvar "developer" set; newline added.
void mutil_LogDeveloper(plid_t plid, const char* fmt, ...) void EXT_FUNC mutil_LogDeveloper(plid_t plid, const char* fmt, ...)
{ {
va_list ap; va_list ap;
char buf[MAX_LOGMSG_LEN]; char buf[MAX_LOGMSG_LEN];
@ -75,7 +75,7 @@ void mutil_LogDeveloper(plid_t plid, const char* fmt, ...)
// Print message on center of all player's screens. Uses default text // Print message on center of all player's screens. Uses default text
// parameters (color green, 10 second fade-in). // parameters (color green, 10 second fade-in).
void mutil_CenterSay(plid_t plid, const char* fmt, ...) void EXT_FUNC mutil_CenterSay(plid_t plid, const char* fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
@ -84,7 +84,7 @@ void mutil_CenterSay(plid_t plid, const char* fmt, ...)
} }
// Print a center-message, with given text parameters. // Print a center-message, with given text parameters.
void mutil_CenterSayParms(plid_t plid, hudtextparms_t tparms, const char* fmt, ...) void EXT_FUNC mutil_CenterSayParms(plid_t plid, hudtextparms_t tparms, const char* fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
@ -94,7 +94,7 @@ void mutil_CenterSayParms(plid_t plid, hudtextparms_t tparms, const char* fmt, .
// Print a center-message, with text parameters and varargs. Provides // Print a center-message, with text parameters and varargs. Provides
// functionality to the above center_say interfaces. // functionality to the above center_say interfaces.
void mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, const char* fmt, va_list ap) void EXT_FUNC mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, const char* fmt, va_list ap)
{ {
char buf[MAX_LOGMSG_LEN]; char buf[MAX_LOGMSG_LEN];
int n; int n;
@ -115,7 +115,7 @@ void mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, const char* fmt,
// Allow plugins to call the entity functions in the GameDLL. In // Allow plugins to call the entity functions in the GameDLL. In
// particular, calling "player()" as needed by most Bots. Suggested by // particular, calling "player()" as needed by most Bots. Suggested by
// Jussi Kivilinna. // Jussi Kivilinna.
qboolean mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev) qboolean EXT_FUNC mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev)
{ {
plugin_info_t *plinfo = (plugin_info_t *)plid; plugin_info_t *plinfo = (plugin_info_t *)plid;
META_DEBUG(8, ("Looking up game entity '%s' for plugin '%s'", entStr, plinfo->name)); META_DEBUG(8, ("Looking up game entity '%s' for plugin '%s'", entStr, plinfo->name));
@ -133,7 +133,7 @@ qboolean mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev)
// Find a usermsg, registered by the gamedll, with the corresponding // Find a usermsg, registered by the gamedll, with the corresponding
// msgname, and return remaining info about it (msgid, size). // msgname, and return remaining info about it (msgid, size).
int mutil_GetUserMsgID(plid_t plid, const char* msgname, int* size) int EXT_FUNC mutil_GetUserMsgID(plid_t plid, const char* msgname, int* size)
{ {
plugin_info_t *plinfo = (plugin_info_t *)plid; plugin_info_t *plinfo = (plugin_info_t *)plid;
META_DEBUG(8, ("Looking up usermsg name '%s' for plugin '%s'", msgname, plinfo->name)); META_DEBUG(8, ("Looking up usermsg name '%s' for plugin '%s'", msgname, plinfo->name));
@ -151,7 +151,7 @@ int mutil_GetUserMsgID(plid_t plid, const char* msgname, int* size)
// Find a usermsg, registered by the gamedll, with the corresponding // Find a usermsg, registered by the gamedll, with the corresponding
// msgid, and return remaining info about it (msgname, size). // msgid, and return remaining info about it (msgname, size).
const char* mutil_GetUserMsgName(plid_t plid, int msgid, int *size) const char* EXT_FUNC mutil_GetUserMsgName(plid_t plid, int msgid, int *size)
{ {
plugin_info_t *plinfo = (plugin_info_t *)plid; plugin_info_t *plinfo = (plugin_info_t *)plid;
META_DEBUG(8, ("Looking up usermsg id '%d' for plugin '%s'", msgid, plinfo->name)); META_DEBUG(8, ("Looking up usermsg id '%d' for plugin '%s'", msgid, plinfo->name));
@ -197,7 +197,7 @@ const char* mutil_GetUserMsgName(plid_t plid, int msgid, int *size)
} }
// Return the full path of the plugin's loaded dll/so file. // Return the full path of the plugin's loaded dll/so file.
const char* mutil_GetPluginPath(plid_t plid) const char* EXT_FUNC mutil_GetPluginPath(plid_t plid)
{ {
static char buf[PATH_MAX ]; static char buf[PATH_MAX ];
MPlugin *plug; MPlugin *plug;
@ -215,7 +215,7 @@ const char* mutil_GetPluginPath(plid_t plid)
} }
// Return various string-based info about the game/MOD/gamedll. // Return various string-based info about the game/MOD/gamedll.
const char* mutil_GetGameInfo(plid_t plid, ginfo_t type) const char* EXT_FUNC mutil_GetGameInfo(plid_t plid, ginfo_t type)
{ {
static char buf[MAX_STRBUF_LEN]; static char buf[MAX_STRBUF_LEN];
const char *cp; const char *cp;
@ -249,7 +249,7 @@ const char* mutil_GetGameInfo(plid_t plid, ginfo_t type)
return buf; return buf;
} }
int mutil_LoadMetaPlugin(plid_t plid, const char* fname, PLUG_LOADTIME now, void **plugin_handle) int EXT_FUNC mutil_LoadMetaPlugin(plid_t plid, const char* fname, PLUG_LOADTIME now, void **plugin_handle)
{ {
MPlugin *pl_loaded; MPlugin *pl_loaded;
if (!fname) if (!fname)
@ -273,7 +273,7 @@ int mutil_LoadMetaPlugin(plid_t plid, const char* fname, PLUG_LOADTIME now, void
} }
} }
int mutil_UnloadMetaPlugin(plid_t plid, const char *fname, PLUG_LOADTIME now, PL_UNLOAD_REASON reason) int EXT_FUNC mutil_UnloadMetaPlugin(plid_t plid, const char *fname, PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
{ {
MPlugin *findp = nullptr; MPlugin *findp = nullptr;
int pindex; int pindex;
@ -301,7 +301,7 @@ int mutil_UnloadMetaPlugin(plid_t plid, const char *fname, PLUG_LOADTIME now, PL
return meta_errno; return meta_errno;
} }
int mutil_UnloadMetaPluginByHandle(plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason) int EXT_FUNC mutil_UnloadMetaPluginByHandle(plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
{ {
MPlugin *findp; MPlugin *findp;
@ -321,18 +321,18 @@ int mutil_UnloadMetaPluginByHandle(plid_t plid, void *plugin_handle, PLUG_LOADTI
return meta_errno; return meta_errno;
} }
const char* mutil_IsQueryingClientCvar(plid_t plid, const edict_t* pEdict) const char* EXT_FUNC mutil_IsQueryingClientCvar(plid_t plid, const edict_t* pEdict)
{ {
return g_players.is_querying_cvar(pEdict); return g_players.is_querying_cvar(pEdict);
} }
int mutil_MakeRequestId(plid_t plid) int EXT_FUNC mutil_MakeRequestId(plid_t plid)
{ {
//the offset is to distinguish from gamedll requests, if any //the offset is to distinguish from gamedll requests, if any
return abs(0xbeef << 16) + (++requestid_counter); return abs(0xbeef << 16) + (++requestid_counter);
} }
void mutil_GetHookTables(plid_t plid, enginefuncs_t** peng, DLL_FUNCTIONS** pdll, NEW_DLL_FUNCTIONS** pnewdll) void EXT_FUNC mutil_GetHookTables(plid_t plid, enginefuncs_t** peng, DLL_FUNCTIONS** pdll, NEW_DLL_FUNCTIONS** pnewdll)
{ {
if (peng) if (peng)
*peng = &meta_engfuncs; *peng = &meta_engfuncs;
@ -344,43 +344,6 @@ void mutil_GetHookTables(plid_t plid, enginefuncs_t** peng, DLL_FUNCTIONS** pdll
*pnewdll = pHookedNewDllFunctions; *pnewdll = pHookedNewDllFunctions;
} }
#ifdef UNFINISHED
int mutil_HookGameEvent(plid_t plid, game_event_t event, event_func_t pfnHandle)
{
return Hooks->add(plid, event, pfnHandle);
}
int mutil_HookLogTrigger(plid_t plid, const char *trigger, logmatch_func_t pfnHandle)
{
return Hooks->add(plid, H_TRIGGER, trigger, pfnHandle);
}
int mutil_HookLogString(plid_t plid, const char *string, logmatch_func_t pfnHandle)
{
return Hooks->add(plid, H_STRING, string, pfnHandle);
}
int mutil_HookLogRegex(plid_t plid, const char *pattern, logmatch_func_t pfnHandle)
{
return Hooks->add(plid, H_STRING, pattern, pfnHandle);
}
qboolean mutil_RemoveHookID(plid_t plid, int hookid)
{
if (Hooks->remove(plid, hookid))
return true;
return false;
}
int mutil_RemoveHookAll(plid_t plid)
{
return Hooks->remove_all(plid);
}
#endif // UNFINISHED
// Meta Utility Function table. // Meta Utility Function table.
mutil_funcs_t MetaUtilFunctions = { mutil_funcs_t MetaUtilFunctions = {
mutil_LogConsole, // pfnLogConsole mutil_LogConsole, // pfnLogConsole
@ -401,12 +364,4 @@ mutil_funcs_t MetaUtilFunctions = {
mutil_IsQueryingClientCvar, // pfnIsQueryingClientCvar mutil_IsQueryingClientCvar, // pfnIsQueryingClientCvar
mutil_MakeRequestId, // pfnMakeRequestId mutil_MakeRequestId, // pfnMakeRequestId
mutil_GetHookTables, // pfnGetHookTables mutil_GetHookTables, // pfnGetHookTables
#ifdef UNFINISHED
mutil_HookGameEvent, // pfnGameEvent
mutil_HookLogTrigger, // pfnLogTrigger
mutil_HookLogString, // pfnLogString
mutil_HookLogRegex, // pfnLogRegex
mutil_RemoveHookID, // pfnRemoveHookID
mutil_RemoveHookAll, // pfnRemoveHookAll
#endif // UNFINISHED
}; };

View File

@ -45,7 +45,7 @@
// Generic command handler, passed to the engine for any AddServerCommand // Generic command handler, passed to the engine for any AddServerCommand
// calls made by the plugin. It finds the appropriate plugin function // calls made by the plugin. It finds the appropriate plugin function
// pointer to call based on CMD_ARGV(0). // pointer to call based on CMD_ARGV(0).
void meta_command_handler() void EXT_FUNC meta_command_handler()
{ {
META_DEBUG(5, ("called: meta_command_handler; arg0=%s args='%s'", CMD_ARGV(0), CMD_ARGS())); META_DEBUG(5, ("called: meta_command_handler; arg0=%s args='%s'", CMD_ARGV(0), CMD_ARGS()));
const char *cmd = CMD_ARGV(0); const char *cmd = CMD_ARGV(0);
@ -78,7 +78,7 @@ void meta_command_handler()
// The string handed to the engine is just a Q_strdup() of the plugin's // The string handed to the engine is just a Q_strdup() of the plugin's
// string. The function pointer handed to the engine is actually a pointer // string. The function pointer handed to the engine is actually a pointer
// to a generic command-handler function (see above). // to a generic command-handler function (see above).
void meta_AddServerCommand(char *cmd_name, void (*function)()) void EXT_FUNC meta_AddServerCommand(char *cmd_name, void (*function)())
{ {
MPlugin *iplug = NULL; MPlugin *iplug = NULL;
MRegCmd *icmd = NULL; MRegCmd *icmd = NULL;
@ -132,7 +132,7 @@ void meta_AddServerCommand(char *cmd_name, void (*function)())
// values via the engine functions, this will work fine. If the plugin // values via the engine functions, this will work fine. If the plugin
// code tries to _directly_ read/set the fields of its own cvar structures, // code tries to _directly_ read/set the fields of its own cvar structures,
// it will fail to work properly. // it will fail to work properly.
void meta_CVarRegister(cvar_t *pCvar) void EXT_FUNC meta_CVarRegister(cvar_t *pCvar)
{ {
MPlugin *iplug = nullptr; MPlugin *iplug = nullptr;
MRegCvar *icvar = nullptr; MRegCvar *icvar = nullptr;
@ -192,15 +192,15 @@ void meta_CVarRegister(cvar_t *pCvar)
// commands and cvars). This merely provides differently located storage // commands and cvars). This merely provides differently located storage
// for the string. // for the string.
int meta_RegUserMsg(const char *pszName, int iSize) int EXT_FUNC meta_RegUserMsg(const char *pszName, int iSize)
{ {
char *cp = Q_strdup(pszName); char *cp = Q_strdup(pszName);
return REG_USER_MSG(cp, iSize); return REG_USER_MSG(cp, iSize);
} }
// Intercept and record queries // Intercept and record queries
void meta_QueryClientCvarValue(const edict_t *player, const char *cvarName) void EXT_FUNC meta_QueryClientCvarValue(const edict_t *player, const char *cvarName)
{ {
g_players.set_player_cvar_query(player, cvarName); g_players.set_player_cvar_query(player, cvarName);
(*g_engfuncs.pfnQueryClientCvarValue)(player, cvarName); g_engfuncs.pfnQueryClientCvarValue(player, cvarName);
} }

View File

@ -17,7 +17,7 @@ char *UTIL_VarArgs(char *format, ...)
void UTIL_LogPrintf(char *fmt, ...) void UTIL_LogPrintf(char *fmt, ...)
{ {
va_list argptr; va_list argptr;
static char string[1024]; char string[1024];
va_start(argptr, fmt); va_start(argptr, fmt);
Q_vsnprintf(string, sizeof(string), fmt, argptr); Q_vsnprintf(string, sizeof(string), fmt, argptr);