1.1 --- a/metamod/mutil.cpp Fri Feb 18 20:52:34 2005 +0000
1.2 +++ b/metamod/mutil.cpp Tue Aug 23 20:31:28 2005 +0000
1.3 @@ -36,6 +36,7 @@
1.4
1.5 #include <stdio.h> // vsnprintf(), etc
1.6 #include <stdarg.h> // vs_start(), etc
1.7 +#include <stdlib.h> // strtol()
1.8
1.9 #include <extdll.h> // always
1.10
1.11 @@ -287,6 +288,82 @@
1.12 return(buf);
1.13 }
1.14
1.15 +int mutil_LoadMetaPlugin(plid_t plid, const char *fname, PLUG_LOADTIME now, void **plugin_handle)
1.16 +{
1.17 + MPlugin *pl_loaded;
1.18 +
1.19 + if (NULL == fname)
1.20 + {
1.21 + return ME_ARGUMENT;
1.22 + }
1.23 +
1.24 + meta_errno = ME_NOERROR;
1.25 + if (! (pl_loaded=Plugins->plugin_addload(plid, fname, now)) )
1.26 + {
1.27 + if (plugin_handle)
1.28 + *plugin_handle = NULL;
1.29 + return meta_errno;
1.30 + } else {
1.31 + if (plugin_handle)
1.32 + *plugin_handle = (void *)pl_loaded->handle;
1.33 + return 0;
1.34 + }
1.35 +}
1.36 +
1.37 +int mutil_UnloadMetaPlugin(plid_t plid, const char *fname, PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
1.38 +{
1.39 + MPlugin *findp = NULL;
1.40 + int pindex;
1.41 + char* endptr;
1.42 +
1.43 + if (NULL == fname)
1.44 + {
1.45 + return ME_ARGUMENT;
1.46 + }
1.47 +
1.48 + pindex = strtol(fname, &endptr, 10);
1.49 + if (*fname != '\0' && *endptr == '\0')
1.50 + findp = Plugins->find(pindex);
1.51 + else
1.52 + findp = Plugins->find_match(fname);
1.53 +
1.54 + if (!findp)
1.55 + return meta_errno;
1.56 +
1.57 + meta_errno = ME_NOERROR;
1.58 +
1.59 + if (findp->plugin_unload(plid, now, reason))
1.60 + return 0;
1.61 +
1.62 + return meta_errno;
1.63 +}
1.64 +
1.65 +int mutil_UnloadMetaPluginByHandle(plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
1.66 +{
1.67 + MPlugin *findp;
1.68 +
1.69 + if (NULL == plugin_handle)
1.70 + {
1.71 + return ME_ARGUMENT;
1.72 + }
1.73 +
1.74 + if (!(findp=Plugins->find((DLHANDLE)plugin_handle)))
1.75 + return ME_NOTFOUND;
1.76 +
1.77 + meta_errno = ME_NOERROR;
1.78 +
1.79 + if (findp->plugin_unload(plid, now, reason))
1.80 + return 0;
1.81 +
1.82 + return meta_errno;
1.83 +}
1.84 +
1.85 +const char *mutil_IsQueryingClientCvar(plid_t /*plid*/, const edict_t *pEdict)
1.86 +{
1.87 + return g_Players.is_querying_cvar(pEdict);
1.88 +}
1.89 +
1.90 +
1.91 #ifdef UNFINISHED
1.92 int mutil_HookGameEvent(plid_t plid, game_event_t event,
1.93 event_func_t pfnHandle)
1.94 @@ -338,6 +415,10 @@
1.95 mutil_GetUserMsgName, // pfnGetUserMsgName
1.96 mutil_GetPluginPath, // pfnGetPluginPath
1.97 mutil_GetGameInfo, // pfnGetGameInfo
1.98 + mutil_LoadMetaPlugin, // pfnLoadPlugin
1.99 + mutil_UnloadMetaPlugin, // pfnUnloadPlugin
1.100 + mutil_UnloadMetaPluginByHandle, //pfnUnloadPluginByHandle
1.101 + mutil_IsQueryingClientCvar, //pfnIsQueryingClientCvar
1.102 #ifdef UNFINISHED
1.103 mutil_HookGameEvent, // pfnGameEvent
1.104 mutil_HookLogTrigger, // pfnLogTrigger