mirror of
https://github.com/rehlds/metamod-r.git
synced 2025-02-04 17:50:52 +03:00
Fixed all places where meta_errno was used
Removed most of crazy defines
This commit is contained in:
parent
ca8d4e0bcf
commit
6e1a6f8a02
@ -19,6 +19,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
@ -114,8 +115,8 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\;$(ProjectDir)\..\src;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\common;$(ProjectDir)\..\include\dlls;$(ProjectDir)\..\include\engine;$(ProjectDir)\..\include\game_shared;$(ProjectDir)\..\include\pm_shared;$(ProjectDir)\..\include\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>METAMOD_CORE;WIN32;NDEBUG;_WINDOWS;_USRDLL;METAMOD_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
@ -132,6 +133,11 @@
|
||||
<CompileAs>Default</CompileAs>
|
||||
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>.\release/metamod.dll</OutputFile>
|
||||
@ -143,6 +149,8 @@
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Midl>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -117,7 +117,7 @@ void CForwardCallbackJIT::naked_main()
|
||||
CUniqueLabel go_next_plugin("go_next_plugin");
|
||||
|
||||
// check status and handler set
|
||||
cmp(byte_ptr[size_t(&plug->status)], PL_RUNNING);
|
||||
cmp(byte_ptr[size_t(&plug->m_status)], PL_RUNNING);
|
||||
mov(ecx, dword_ptr[fn_table + m_jitdata->pfn_offset]);
|
||||
jnz(go_next_plugin);
|
||||
jecxz(go_next_plugin);
|
||||
@ -194,7 +194,7 @@ void CForwardCallbackJIT::naked_main()
|
||||
CUniqueLabel go_next_plugin("go_next_plugin");
|
||||
|
||||
// check status and handler set
|
||||
cmp(byte_ptr[size_t(&plug->status)], PL_RUNNING);
|
||||
cmp(byte_ptr[size_t(&plug->m_status)], PL_RUNNING);
|
||||
mov(ecx, dword_ptr[fn_table + m_jitdata->pfn_offset]);
|
||||
jnz(go_next_plugin);
|
||||
jecxz(go_next_plugin);
|
||||
|
@ -335,13 +335,14 @@ void cmd_doplug(PLUG_CMD pcmd)
|
||||
|
||||
// try to match plugin id first
|
||||
int pindex = strtol(arg, &endptr, 10);
|
||||
bool unique = true;
|
||||
|
||||
if (*arg && !*endptr)
|
||||
findp = g_plugins->find(pindex);
|
||||
|
||||
// else try to match some string (prefix)
|
||||
else
|
||||
findp = g_plugins->find_match(arg);
|
||||
findp = g_plugins->find_match(arg, unique);
|
||||
|
||||
// Require that:
|
||||
// - specified plugin was found in the list of current plugins
|
||||
@ -349,14 +350,14 @@ void cmd_doplug(PLUG_CMD pcmd)
|
||||
// Otherwise, print error and exit.
|
||||
if (pcmd == PC_REQUIRE)
|
||||
{
|
||||
if (findp && findp->status >= PL_RUNNING)
|
||||
if (findp && findp->m_status >= PL_RUNNING && unique)
|
||||
{
|
||||
META_DEBUG(3, "Required plugin '%s' found loaded and running.", arg);
|
||||
return;
|
||||
}
|
||||
// Output to both places, because we don't want the admin
|
||||
// to miss this..
|
||||
if (!findp /*&& meta_errno == ME_NOTUNIQ*/) // TODO
|
||||
if (findp && !unique)
|
||||
{
|
||||
META_ERROR("Unique match for required plugin '%s' was not found! Exiting.", arg);
|
||||
META_CONS("\nERROR: Unique match for required plugin '%s' was not found! Exiting.\n", arg);
|
||||
@ -376,12 +377,12 @@ void cmd_doplug(PLUG_CMD pcmd)
|
||||
do_exit(1);
|
||||
}
|
||||
|
||||
if (!findp)
|
||||
{
|
||||
if (false /*meta_errno == ME_NOTUNIQ*/) // TODO
|
||||
META_CONS("Couldn't find unique plugin matching '%s'", arg);
|
||||
else
|
||||
META_CONS("Couldn't find plugin matching '%s'", arg);
|
||||
if (findp && !unique) {
|
||||
META_CONS("Couldn't find unique plugin matching '%s'", arg);
|
||||
return;
|
||||
}
|
||||
if (!findp) {
|
||||
META_CONS("Couldn't find plugin matching '%s'", arg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -389,69 +390,69 @@ void cmd_doplug(PLUG_CMD pcmd)
|
||||
{
|
||||
case PC_PAUSE:
|
||||
if (findp->pause())
|
||||
META_CONS("Paused plugin '%s'", findp->desc);
|
||||
META_CONS("Paused plugin '%s'", findp->m_desc);
|
||||
else
|
||||
META_CONS("Pause failed for plugin '%s'", findp->desc);
|
||||
META_CONS("Pause failed for plugin '%s'", findp->m_desc);
|
||||
break;
|
||||
case PC_UNPAUSE:
|
||||
if (findp->unpause())
|
||||
META_CONS("Unpaused plugin '%s'", findp->desc);
|
||||
META_CONS("Unpaused plugin '%s'", findp->m_desc);
|
||||
else
|
||||
META_CONS("Unpause failed for plugin '%s'", findp->desc);
|
||||
META_CONS("Unpause failed for plugin '%s'", findp->m_desc);
|
||||
break;
|
||||
case PC_UNLOAD:
|
||||
{
|
||||
findp->action = PA_UNLOAD;
|
||||
findp->m_action = PA_UNLOAD;
|
||||
if (findp->unload(PT_ANYTIME, PNL_COMMAND, PNL_COMMAND))
|
||||
{
|
||||
META_CONS("Unloaded plugin '%s'", findp->desc);
|
||||
META_CONS("Unloaded plugin '%s'", findp->m_desc);
|
||||
g_plugins->show();
|
||||
}
|
||||
else if (false /*meta_errno == ME_DELAYED*/) // TODO
|
||||
META_CONS("Unload delayed for plugin '%s'", findp->desc);
|
||||
META_CONS("Unload delayed for plugin '%s'", findp->m_desc);
|
||||
else
|
||||
META_CONS("Unload failed for plugin '%s'", findp->desc);
|
||||
META_CONS("Unload failed for plugin '%s'", findp->m_desc);
|
||||
break;
|
||||
}
|
||||
case PC_FORCE_UNLOAD:
|
||||
{
|
||||
findp->action = PA_UNLOAD;
|
||||
findp->m_action = PA_UNLOAD;
|
||||
if (findp->unload(PT_ANYTIME, PNL_CMD_FORCED, PNL_CMD_FORCED))
|
||||
{
|
||||
META_CONS("Forced unload plugin '%s'", findp->desc);
|
||||
META_CONS("Forced unload plugin '%s'", findp->m_desc);
|
||||
g_plugins->show();
|
||||
}
|
||||
else
|
||||
META_CONS("Forced unload failed for plugin '%s'", findp->desc);
|
||||
META_CONS("Forced unload failed for plugin '%s'", findp->m_desc);
|
||||
break;
|
||||
}
|
||||
case PC_RELOAD:
|
||||
{
|
||||
findp->action = PA_RELOAD;
|
||||
findp->m_action = PA_RELOAD;
|
||||
if (findp->reload(PT_ANYTIME, PNL_COMMAND))
|
||||
META_CONS("Reloaded plugin '%s'", findp->desc);
|
||||
META_CONS("Reloaded plugin '%s'", findp->m_desc);
|
||||
else if (0/*meta_errno == ME_DELAYED*/)
|
||||
META_CONS("Reload delayed for plugin '%s'", findp->desc);
|
||||
META_CONS("Reload delayed for plugin '%s'", findp->m_desc);
|
||||
else if (0/*meta_errno == ME_NOTALLOWED*/)
|
||||
META_CONS("Reload not allowed for plugin '%s' now, only allowed %s", findp->desc, findp->str_loadable(SL_ALLOWED));
|
||||
META_CONS("Reload not allowed for plugin '%s' now, only allowed %s", findp->m_desc, findp->str_loadable(SL_ALLOWED));
|
||||
else
|
||||
META_CONS("Reload failed for plugin '%s'", findp->desc);
|
||||
META_CONS("Reload failed for plugin '%s'", findp->m_desc);
|
||||
break;
|
||||
}
|
||||
case PC_RETRY:
|
||||
if (findp->retry(PT_ANYTIME, PNL_COMMAND))
|
||||
META_CONS("Retry succeeded for plugin '%s'", findp->desc);
|
||||
META_CONS("Retry succeeded for plugin '%s'", findp->m_desc);
|
||||
else
|
||||
META_CONS("Retry failed for plugin '%s'", findp->desc);
|
||||
META_CONS("Retry failed for plugin '%s'", findp->m_desc);
|
||||
break;
|
||||
case PC_CLEAR:
|
||||
if (!findp->clear())
|
||||
{
|
||||
META_CONS("Clear failed for plugin '%s'", findp->desc);
|
||||
META_CONS("Clear failed for plugin '%s'", findp->m_desc);
|
||||
return;
|
||||
}
|
||||
|
||||
META_CONS("Cleared failed plugin '%s' from list", findp->desc);
|
||||
META_CONS("Cleared failed plugin '%s' from list", findp->m_desc);
|
||||
g_plugins->show();
|
||||
break;
|
||||
case PC_INFO:
|
||||
|
@ -215,10 +215,10 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *in
|
||||
void compile_dllfunc_callbacks()
|
||||
{
|
||||
jitdata_t jitdata;
|
||||
jitdata.plugins = g_plugins ? g_plugins->plist : nullptr;
|
||||
jitdata.plugins_count = g_plugins ? g_plugins->max_loaded_count : 0;
|
||||
jitdata.table_offset = offsetof(MPlugin, dllapi_table);
|
||||
jitdata.post_table_offset = offsetof(MPlugin, dllapi_post_table);
|
||||
jitdata.plugins = g_plugins ? g_plugins->getlist() : nullptr;
|
||||
jitdata.plugins_count = g_plugins ? g_plugins->getmaxcount() : 0;
|
||||
jitdata.table_offset = offsetof(MPlugin, m_dllapi_table);
|
||||
jitdata.post_table_offset = offsetof(MPlugin, m_dllapi_post_table);
|
||||
|
||||
for (auto& cd : g_dllfunc_cdata) {
|
||||
jitdata.pfn_original = *(size_t *)(size_t(GameDLL.funcs.dllapi_table) + cd.offset);
|
||||
@ -236,10 +236,10 @@ void compile_dllfunc_callbacks()
|
||||
void compile_newdllfunc_callbacks()
|
||||
{
|
||||
jitdata_t jitdata;
|
||||
jitdata.plugins = g_plugins ? g_plugins->plist : nullptr;
|
||||
jitdata.plugins_count = g_plugins ? g_plugins->max_loaded_count : 0;
|
||||
jitdata.table_offset = offsetof(MPlugin, newapi_table);
|
||||
jitdata.post_table_offset = offsetof(MPlugin, newapi_post_table);
|
||||
jitdata.plugins = g_plugins ? g_plugins->getlist() : nullptr;
|
||||
jitdata.plugins_count = g_plugins ? g_plugins->getmaxcount() : 0;
|
||||
jitdata.table_offset = offsetof(MPlugin, m_newapi_table);
|
||||
jitdata.post_table_offset = offsetof(MPlugin, m_newapi_post_table);
|
||||
|
||||
for (auto& cd : g_newdllfunc_cdata) {
|
||||
jitdata.pfn_original = *(size_t *)(size_t(GameDLL.funcs.newapi_table) + cd.offset);
|
||||
|
@ -239,10 +239,10 @@ compile_data_t g_engfuncs_cdata[] =
|
||||
void compile_engfuncs_callbacks()
|
||||
{
|
||||
jitdata_t jitdata;
|
||||
jitdata.plugins = g_plugins ? g_plugins->plist : nullptr;
|
||||
jitdata.plugins_count = g_plugins ? g_plugins->max_loaded_count : 0;
|
||||
jitdata.table_offset = offsetof(MPlugin, engine_table);
|
||||
jitdata.post_table_offset = offsetof(MPlugin, engine_post_table);
|
||||
jitdata.plugins = g_plugins ? g_plugins->getlist() : nullptr;
|
||||
jitdata.plugins_count = g_plugins ? g_plugins->getmaxcount() : 0;
|
||||
jitdata.table_offset = offsetof(MPlugin, m_engine_table);
|
||||
jitdata.post_table_offset = offsetof(MPlugin, m_engine_post_table);
|
||||
|
||||
for (auto& cd : g_engfuncs_cdata) {
|
||||
jitdata.pfn_original = *(size_t *)(size_t(&g_engfuncs) + cd.offset);
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Function to perform common code of LINK_ENTITY_TO_GAME, rather than
|
||||
// duplicating the code in ~2000 expanded macros. Based on code from Jussi
|
||||
// Kivilinna <kijuhe00@students.oamk.fi>.
|
||||
void do_link_ent(ENTITY_FN *pfnEntity, int *missing, const char *entStr, entvars_t *pev)
|
||||
void NOINLINE do_link_ent(ENTITY_FN *pfnEntity, int *missing, const char *entStr, entvars_t *pev)
|
||||
{
|
||||
if (*missing)
|
||||
{
|
||||
|
@ -12,9 +12,8 @@ typedef void (*ENTITY_FN)(entvars_t *);
|
||||
void do_link_ent(ENTITY_FN *pfnEntity, int *missing, const char *entStr, entvars_t *pev);
|
||||
|
||||
#define LINK_ENTITY_TO_GAME(entityName) \
|
||||
C_DLLEXPORT void entityName(entvars_t *pev); \
|
||||
void entityName(entvars_t *pev) { \
|
||||
static ENTITY_FN pfnEntity = NULL; \
|
||||
C_DLLEXPORT void entityName(entvars_t *pev) { \
|
||||
static ENTITY_FN pfnEntity = nullptr; \
|
||||
static int missing = 0; \
|
||||
do_link_ent(&pfnEntity, &missing, STRINGIZE(entityName, 0), pev); \
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void buffered_ALERT(MLOG_SERVICE service, ALERT_TYPE atype, const char *prefix,
|
||||
|
||||
if (g_engfuncs.pfnAlertMessage)
|
||||
{
|
||||
Q_vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
Q_vsnprintf(buf, sizeof buf, fmt, ap);
|
||||
ALERT(atype, "%s %s\n", prefix, buf);
|
||||
return;
|
||||
}
|
||||
@ -133,7 +133,7 @@ void buffered_ALERT(MLOG_SERVICE service, ALERT_TYPE atype, const char *prefix,
|
||||
msg->service = service;
|
||||
msg->atype = atype;
|
||||
msg->prefix = prefix;
|
||||
Q_vsnprintf(msg->buf, sizeof(buf), fmt, ap);
|
||||
Q_vsnprintf(msg->buf, sizeof buf, fmt, ap);
|
||||
msg->next = nullptr;
|
||||
|
||||
if (!messageQueueEnd)
|
||||
|
@ -252,14 +252,14 @@ bool meta_init_gamedll(void)
|
||||
// New style; GET_GAME_DIR returned game name. Copy this into our
|
||||
// game name, and prepend the current working directory.
|
||||
char buf[PATH_MAX];
|
||||
if (!_getcwd(buf, sizeof(buf)))
|
||||
if (!_getcwd(buf, sizeof buf))
|
||||
{
|
||||
META_WARNING("dll: Couldn't get cwd; %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_snprintf(GameDLL.gamedir, sizeof(GameDLL.gamedir), "%s/%s", buf, gamedir);
|
||||
Q_strncpy(GameDLL.name, gamedir, sizeof(GameDLL.name) - 1);
|
||||
Q_snprintf(GameDLL.gamedir, sizeof GameDLL.gamedir, "%s/%s", buf, gamedir);
|
||||
Q_strncpy(GameDLL.name, gamedir, sizeof GameDLL.name - 1);
|
||||
GameDLL.name[sizeof(GameDLL.name) - 1] = '\0';
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ bool meta_init_gamedll(void)
|
||||
template<typename ifvers_t, typename table_t>
|
||||
bool get_function_table(const char* ifname, int ifvers_mm, table_t*& table, size_t table_size = sizeof(table_t))
|
||||
{
|
||||
typedef int (*getfunc_t)(table_t *pFunctionTable, ifvers_t interfaceVersion);
|
||||
typedef int(*getfunc_t)(table_t *pFunctionTable, ifvers_t interfaceVersion);
|
||||
|
||||
auto pfnGetFuncs = (getfunc_t)GameDLL.sys_module.getsym(ifname);
|
||||
|
||||
@ -309,6 +309,33 @@ bool get_function_table(const char* ifname, int ifvers_mm, table_t*& table, size
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename table_t>
|
||||
bool get_function_table_old(const char* ifname, int ifvers_mm, table_t*& table, size_t table_size = sizeof(table_t))
|
||||
{
|
||||
typedef int (*getfunc_t)(table_t *pFunctionTable, int interfaceVersion);
|
||||
|
||||
auto pfnGetFuncs = (getfunc_t)GameDLL.sys_module.getsym(ifname);
|
||||
|
||||
if (pfnGetFuncs) {
|
||||
table = (table_t *)Q_calloc(1, table_size);
|
||||
|
||||
if (pfnGetFuncs(table, ifvers_mm)) {
|
||||
META_DEBUG(3, "dll: Game '%s': Found %s", GameDLL.name, ifname);
|
||||
return true;
|
||||
}
|
||||
|
||||
META_ERROR("dll: Failure calling %s in game '%s'", ifname, GameDLL.name);
|
||||
Q_free(table);
|
||||
table = nullptr;
|
||||
}
|
||||
else {
|
||||
META_DEBUG(5, "dll: Game '%s': No %s", GameDLL.name, ifname);
|
||||
table = nullptr;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load game DLL.
|
||||
// meta_errno values:
|
||||
// - ME_DLOPEN couldn't dlopen game dll file
|
||||
@ -359,7 +386,7 @@ bool meta_load_gamedll(void)
|
||||
|
||||
// Look for API-1 in plugin, if API2 interface wasn't found.
|
||||
if (!found) {
|
||||
found = get_function_table<int>("GetEntityAPI", INTERFACE_VERSION, GameDLL.funcs.dllapi_table);
|
||||
found = get_function_table_old("GetEntityAPI", INTERFACE_VERSION, GameDLL.funcs.dllapi_table);
|
||||
}
|
||||
|
||||
// If didn't find either, return failure.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -17,11 +17,14 @@ class MPluginList {
|
||||
public:
|
||||
MPluginList(const char *ifile);
|
||||
|
||||
MPlugin *getlist();
|
||||
int getmaxcount() const;
|
||||
|
||||
MPlugin *find(int pindex); // find by index
|
||||
MPlugin *find(const char *findpath); // find by pathname
|
||||
MPlugin *find(plid_t id); // find by plid_t
|
||||
MPlugin *find_memloc(void *memptr); // find by memory location
|
||||
MPlugin *find_match(const char *prefix); // find by partial prefix match
|
||||
MPlugin *find_match(const char *prefix, bool& unique); // find by partial prefix match
|
||||
MPlugin *find_match(MPlugin *pmatch); // find by platform_match()
|
||||
MPlugin *find(module_handle_t handle); // find by handle
|
||||
MPlugin *find_empty_slot();
|
||||
@ -42,8 +45,8 @@ public:
|
||||
void show_client(edict_t *pEntity); // list plugins to player client
|
||||
void clear_source_plugin_index(int source_index);
|
||||
|
||||
public:
|
||||
int max_loaded_count; // index of last used entry
|
||||
char inifile[PATH_MAX]; // full pathname
|
||||
MPlugin plist[MAX_PLUGINS]; // array of plugins
|
||||
private:
|
||||
int m_max_loaded_count; // index of last used entry
|
||||
MPlugin m_plist[MAX_PLUGINS]; // array of plugins
|
||||
char m_inifile[PATH_MAX]; // full pathname
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -69,32 +69,32 @@ enum STR_SOURCE : uint8
|
||||
// An individual plugin.
|
||||
class MPlugin {
|
||||
public:
|
||||
PLUG_STATUS status; // current status of plugin (loaded, etc)
|
||||
PLUG_ACTION action; // what to do with plugin (load, unload, etc)
|
||||
PLOAD_SOURCE source; // source of the request to load the plugin
|
||||
int index; // 1-based
|
||||
plugin_info_t *info; // information plugin provides about itself
|
||||
CSysModule sys_module;
|
||||
time_t time_loaded; // when plugin was loaded
|
||||
int source_plugin_index; // who loaded this plugin
|
||||
int unloader_index;
|
||||
bool is_unloader; // fix to prevent other plugins unload active unloader.
|
||||
PLUG_STATUS m_status; // current status of plugin (loaded, etc)
|
||||
PLUG_ACTION m_action; // what to do with plugin (load, unload, etc)
|
||||
PLOAD_SOURCE m_source; // source of the request to load the plugin
|
||||
int m_index; // 1-based
|
||||
plugin_info_t *m_info; // information plugin provides about itself
|
||||
CSysModule m_sys_module;
|
||||
time_t m_time_loaded; // when plugin was loaded
|
||||
int m_source_plugin_index; // who loaded this plugin
|
||||
int m_unloader_index;
|
||||
bool m_is_unloader; // fix to prevent other plugins unload active unloader.
|
||||
|
||||
DLL_FUNCTIONS *dllapi_table;
|
||||
DLL_FUNCTIONS *dllapi_post_table;
|
||||
NEW_DLL_FUNCTIONS *newapi_table;
|
||||
NEW_DLL_FUNCTIONS *newapi_post_table;
|
||||
enginefuncs_t *engine_table;
|
||||
enginefuncs_t *engine_post_table;
|
||||
DLL_FUNCTIONS *m_dllapi_table;
|
||||
DLL_FUNCTIONS *m_dllapi_post_table;
|
||||
NEW_DLL_FUNCTIONS *m_newapi_table;
|
||||
NEW_DLL_FUNCTIONS *m_newapi_post_table;
|
||||
enginefuncs_t *m_engine_table;
|
||||
enginefuncs_t *m_engine_post_table;
|
||||
|
||||
gamedll_funcs_t gamedll_funcs;
|
||||
mutil_funcs_t mutil_funcs;
|
||||
gamedll_funcs_t m_gamedll_funcs;
|
||||
mutil_funcs_t m_mutil_funcs;
|
||||
|
||||
char filename[PATH_MAX]; // ie "dlls/mm_test_i386.so", from inifile
|
||||
char *file; // ie "mm_test_i386.so", ptr from filename
|
||||
char desc[MAX_DESC_LEN]; // ie "Test metamod plugin", from inifile
|
||||
char pathname[PATH_MAX]; // UNIQUE, ie "/home/willday/half-life/cstrike/dlls/mm_test_i386.so", built with GameDLL.gamedir
|
||||
int pfspecific; // level of specific platform affinity, used during load time
|
||||
char m_filename[PATH_MAX]; // ie "dlls/mm_test_i386.so", from inifile
|
||||
char *m_file; // ie "mm_test_i386.so", ptr from filename
|
||||
char m_desc[MAX_DESC_LEN]; // ie "Test metamod plugin", from inifile
|
||||
char m_pathname[PATH_MAX]; // UNIQUE, ie "/home/willday/half-life/cstrike/dlls/mm_test_i386.so", built with GameDLL.gamedir
|
||||
int m_pfspecific; // level of specific platform affinity, used during load time
|
||||
|
||||
bool ini_parseline(char *line); // parse line from inifile
|
||||
bool cmd_parseline(const char *line); // parse from console command
|
||||
@ -102,11 +102,11 @@ public:
|
||||
bool check_input();
|
||||
|
||||
bool resolve(); // find a matching file on disk
|
||||
char *resolve_dirs(char *path);
|
||||
char *resolve_dirs(char *path) const;
|
||||
char *resolve_prefix(char *path) const;
|
||||
char *resolve_suffix(char *path) const;
|
||||
|
||||
bool platform_match(MPlugin* plugin);
|
||||
bool platform_match(MPlugin* plugin) const;
|
||||
|
||||
bool load(PLUG_LOADTIME now);
|
||||
bool unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, PL_UNLOAD_REASON real_reason);
|
||||
@ -118,33 +118,33 @@ public:
|
||||
bool plugin_unload(plid_t plid, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); // other plugin unloading
|
||||
void show(); // print info about plugin to console
|
||||
|
||||
bool newer_file(); // check for newer file on disk
|
||||
bool newer_file() const; // check for newer file on disk
|
||||
|
||||
const char *str_status(STR_STATUS fmt);
|
||||
const char *str_action(STR_ACTION fmt);
|
||||
const char *str_source(STR_SOURCE fmt);
|
||||
const char *str_status(STR_STATUS fmt) const;
|
||||
const char *str_action(STR_ACTION fmt) const;
|
||||
const char *str_source(STR_SOURCE fmt) const;
|
||||
|
||||
const char *str_reason(PL_UNLOAD_REASON preason, PL_UNLOAD_REASON preal_reason);
|
||||
const char *str_loadtime(PLUG_LOADTIME pallow, STR_LOADTIME fmt);
|
||||
const char *str_reason(PL_UNLOAD_REASON preason, PL_UNLOAD_REASON preal_reason) const;
|
||||
static const char *str_loadtime(PLUG_LOADTIME pallow, STR_LOADTIME fmt);
|
||||
|
||||
const char *str_status() { return str_status(ST_SIMPLE); };
|
||||
const char *str_action() { return str_action(SA_SIMPLE); };
|
||||
const char *str_source() { return str_source(SO_SIMPLE); };
|
||||
|
||||
const char *str_loadable() {
|
||||
if (info) return str_loadtime(info->loadable, SL_SIMPLE);
|
||||
if (m_info) return str_loadtime(m_info->loadable, SL_SIMPLE);
|
||||
else return " -";
|
||||
};
|
||||
const char *str_unloadable() {
|
||||
if (info) return str_loadtime(info->unloadable, SL_SIMPLE);
|
||||
if (m_info) return str_loadtime(m_info->unloadable, SL_SIMPLE);
|
||||
else return " -";
|
||||
};
|
||||
const char *str_loadable(STR_LOADTIME fmt) {
|
||||
if (info) return str_loadtime(info->loadable, fmt);
|
||||
if (m_info) return str_loadtime(m_info->loadable, fmt);
|
||||
else return " -";
|
||||
};
|
||||
const char *str_unloadable(STR_LOADTIME fmt) {
|
||||
if (info) return str_loadtime(info->unloadable, fmt);
|
||||
if (m_info) return str_loadtime(m_info->unloadable, fmt);
|
||||
else return " -";
|
||||
};
|
||||
|
||||
@ -153,228 +153,3 @@ private:
|
||||
bool attach(PLUG_LOADTIME now);
|
||||
bool detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
|
||||
};
|
||||
|
||||
// Macros used by MPlugin::show(), to list the functions that the plugin
|
||||
// catches.
|
||||
#define SHOW_IFDEF(api_table, info_table, pfnName, pre_str, post_str) \
|
||||
if (api_table->pfnName) { META_CONS("%s%s%s", pre_str, info_table.pfnName.name, post_str); n++;}
|
||||
|
||||
#define SHOW_DEF_DLLAPI(api_table, pre_str, post_str) \
|
||||
n = 0; \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnGameInit, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSpawn, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnThink, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnUse, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnTouch, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnBlocked, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnKeyValue, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSave, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnRestore, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSetAbsBox, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSaveWriteFields, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSaveReadFields, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSaveGlobalState, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnRestoreGlobalState, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnResetGlobalState, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnClientConnect, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnClientDisconnect, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnClientKill, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnClientPutInServer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnClientCommand, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnClientUserInfoChanged, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnServerActivate, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnServerDeactivate, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnPlayerPreThink, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnPlayerPostThink, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnStartFrame, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnParmsNewLevel, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnParmsChangeLevel, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnGetGameDescription, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnPlayerCustomization, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSpectatorConnect, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSpectatorDisconnect, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSpectatorThink, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSys_Error, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnPM_Move, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnPM_Init, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnPM_FindTextureType, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnSetupVisibility, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnUpdateClientData, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnAddToFullPack, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnCreateBaseline, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnRegisterEncoders, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnGetWeaponData, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnCmdStart, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnCmdEnd, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnConnectionlessPacket, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnGetHullBounds, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnCreateInstancedBaselines, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnInconsistentFile, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, dllapi_info, pfnAllowLagCompensation, pre_str, post_str);
|
||||
|
||||
#define SHOW_DEF_NEWAPI(api_table, pre_str, post_str) \
|
||||
n = 0; \
|
||||
SHOW_IFDEF(api_table, newapi_info, pfnOnFreeEntPrivateData, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, newapi_info, pfnGameShutdown, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, newapi_info, pfnShouldCollide, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, newapi_info, pfnCvarValue, pre_str, post_str);
|
||||
|
||||
#define SHOW_DEF_ENGINE(api_table, pre_str, post_str) \
|
||||
n = 0; \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPrecacheModel, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPrecacheSound, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetModel, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnModelIndex, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnModelFrames, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetSize, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnChangeLevel, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetSpawnParms, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSaveSpawnParms, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnVecToYaw, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnVecToAngles, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnMoveToOrigin, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnChangeYaw, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnChangePitch, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnFindEntityByString, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetEntityIllum, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnFindEntityInSphere, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnFindClientInPVS, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnEntitiesInPVS, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnMakeVectors, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnAngleVectors, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCreateEntity, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnRemoveEntity, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCreateNamedEntity, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnMakeStatic, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnEntIsOnFloor, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnDropToFloor, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWalkMove, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetOrigin, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnEmitSound, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnEmitAmbientSound, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnTraceLine, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnTraceToss, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnTraceMonsterHull, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnTraceHull, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnTraceModel, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnTraceTexture, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnTraceSphere, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetAimVector, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnServerCommand, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnServerExecute, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnClientCommand, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnParticleEffect, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnLightStyle, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnDecalIndex, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPointContents, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnMessageBegin, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnMessageEnd, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWriteByte, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWriteChar, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWriteShort, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWriteLong, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWriteAngle, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWriteCoord, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWriteString, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnWriteEntity, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCVarRegister, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCVarGetFloat, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCVarGetString, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCVarSetFloat, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCVarSetString, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnAlertMessage, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnEngineFprintf, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPvAllocEntPrivateData, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPvEntPrivateData, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnFreeEntPrivateData, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSzFromIndex, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnAllocString, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetVarsOfEnt, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPEntityOfEntOffset, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnEntOffsetOfPEntity, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnIndexOfEdict, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPEntityOfEntIndex, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnFindEntityByVars, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetModelPtr, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnRegUserMsg, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnAnimationAutomove, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetBonePosition, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnFunctionFromName, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnNameForFunction, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnClientPrintf, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnServerPrint, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCmd_Args, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCmd_Argv, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCmd_Argc, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetAttachment, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCRC32_Init, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCRC32_ProcessBuffer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCRC32_ProcessByte, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCRC32_Final, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnRandomLong, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnRandomFloat, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetView, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnTime, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCrosshairAngle, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnLoadFileForMe, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnFreeFile, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnEndSection, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCompareFileTime, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetGameDir, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCvar_RegisterVariable, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnFadeClientVolume, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetClientMaxspeed, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCreateFakeClient, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnRunPlayerMove, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnNumberOfEntities, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetInfoKeyBuffer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnInfoKeyValue, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetKeyValue, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetClientKeyValue, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnIsMapValid, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnStaticDecal, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPrecacheGeneric, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetPlayerUserId, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnBuildSoundMsg, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnIsDedicatedServer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCVarGetPointer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetPlayerWONId, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnInfo_RemoveKey, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetPhysicsKeyValue, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetPhysicsKeyValue, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetPhysicsInfoString, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPrecacheEvent, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnPlaybackEvent, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetFatPVS, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetFatPAS, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCheckVisibility, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnDeltaSetField, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnDeltaUnsetField, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnDeltaAddEncoder, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetCurrentPlayer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCanSkipPlayer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnDeltaFindField, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnDeltaSetFieldByIndex, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnDeltaUnsetFieldByIndex, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSetGroupMask, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCreateInstancedBaseline, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnCvar_DirectSet, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnForceUnmodified, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetPlayerStats, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnAddServerCommand, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnVoice_GetClientListening, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnVoice_SetClientListening, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetPlayerAuthId, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSequenceGet, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnSequencePickSentence, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetFileSize, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetApproxWavePlayLen, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnIsCareerMatch, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetLocalizedStringLength, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnRegisterTutorMessageShown, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnGetTimesTutorMessageShown, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnProcessTutorMessageDecayBuffer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnConstructTutorMessageDecayBuffer, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnResetTutorMessageDecayData, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnQueryClientCvarValue, pre_str, post_str); \
|
||||
SHOW_IFDEF(api_table, engine_info, pfnEngCheckParm, pre_str, post_str);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
MRegCmd::MRegCmd(char* cmd_name, REG_CMD_FN cmd_handler, MPlugin* cmd_plugin) : m_pfunction(cmd_handler), m_plugid(cmd_plugin->index), m_status(RG_VALID)
|
||||
MRegCmd::MRegCmd(char* cmd_name, REG_CMD_FN cmd_handler, MPlugin* cmd_plugin) : m_pfunction(cmd_handler), m_plugid(cmd_plugin->m_index), m_status(RG_VALID)
|
||||
{
|
||||
m_name = _strdup(cmd_name);
|
||||
}
|
||||
@ -100,7 +100,7 @@ void MRegCmdList::show() const
|
||||
{
|
||||
auto iplug = g_plugins->find(reg->m_plugid);
|
||||
|
||||
Q_strncpy(bplug, iplug ? iplug->desc : "(unknown)", sizeof bplug - 1);
|
||||
Q_strncpy(bplug, iplug ? iplug->m_desc : "(unknown)", sizeof bplug - 1);
|
||||
bplug[sizeof bplug - 1] = '\0';
|
||||
}
|
||||
else
|
||||
@ -137,7 +137,7 @@ void MRegCmdList::show(int plugin_id) const
|
||||
META_CONS("%d commands", total_count);
|
||||
}
|
||||
|
||||
MRegCvar::MRegCvar(cvar_t* cv_ptr, MPlugin* cv_plugin) : m_cvar(cv_ptr), m_plugid(cv_plugin->index), m_status(RG_VALID)
|
||||
MRegCvar::MRegCvar(cvar_t* cv_ptr, MPlugin* cv_plugin) : m_cvar(cv_ptr), m_plugid(cv_plugin->m_index), m_status(RG_VALID)
|
||||
{
|
||||
m_cvar = g_static_allocator.allocate<cvar_t>();
|
||||
m_cvar->name = _strdup(cv_ptr->name);
|
||||
@ -202,7 +202,7 @@ void MRegCvarList::show() const
|
||||
if (reg->m_status == RG_VALID)
|
||||
{
|
||||
auto plug = g_plugins->find(reg->m_plugid);
|
||||
Q_strncpy(bplug, plug ? plug->desc : "(unknown)", sizeof bplug - 1);
|
||||
Q_strncpy(bplug, plug ? plug->m_desc : "(unknown)", sizeof bplug - 1);
|
||||
bplug[sizeof bplug - 1] = '\0';
|
||||
}
|
||||
else
|
||||
|
@ -252,7 +252,7 @@ const char* EXT_FUNC mutil_GetPluginPath(plid_t plid)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Q_strncpy(buf, plug->pathname, sizeof buf - 1);
|
||||
Q_strncpy(buf, plug->m_pathname, sizeof buf - 1);
|
||||
buf[sizeof buf - 1] = '\0';
|
||||
return buf;
|
||||
}
|
||||
@ -312,7 +312,7 @@ int EXT_FUNC mutil_LoadMetaPlugin(plid_t plid, const char* fname, PLUG_LOADTIME
|
||||
else
|
||||
{
|
||||
if (plugin_handle)
|
||||
*plugin_handle = (void *)pl_loaded->sys_module.gethandle();
|
||||
*plugin_handle = (void *)pl_loaded->m_sys_module.gethandle();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -329,13 +329,14 @@ int EXT_FUNC mutil_UnloadMetaPlugin(plid_t plid, const char *fname, PLUG_LOADTIM
|
||||
|
||||
char *endptr;
|
||||
int pindex = strtol(fname, &endptr, 10);
|
||||
bool unique = true;
|
||||
|
||||
if (*fname != '\0' && *endptr == '\0')
|
||||
findp = g_plugins->find(pindex);
|
||||
else
|
||||
findp = g_plugins->find_match(fname);
|
||||
findp = g_plugins->find_match(fname, unique);
|
||||
|
||||
if (!findp)
|
||||
if (!findp || !unique)
|
||||
return 1;
|
||||
|
||||
if (findp->plugin_unload(plid, now, reason))
|
||||
|
@ -66,7 +66,7 @@ module_handle_t CSysModule::load(const char* filepath)
|
||||
|
||||
FILE* fp = fopen(buf, "r");
|
||||
|
||||
while (fgets(buf, sizeof(buf), fp)) {
|
||||
while (fgets(buf, sizeof buf, fp)) {
|
||||
uintptr_t start, end;
|
||||
|
||||
int args = sscanf(buf, "%x-%x %128s %128s %128s %128s %255s", &start, &end, dummy, dummy, dummy, dummy, path);
|
||||
@ -136,6 +136,7 @@ const char *str_GetLastError()
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, MAX_STRBUF_LEN - 1, NULL);
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* str_os_error()
|
||||
{
|
||||
@ -145,4 +146,3 @@ const char* str_os_error()
|
||||
return strerror(errno);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@ void EXT_FUNC meta_AddServerCommand(char *cmd_name, void (*function)())
|
||||
{
|
||||
MPlugin *plug = g_plugins->find_memloc(function);
|
||||
|
||||
META_DEBUG(4, "called: meta_AddServerCommand; cmd_name=%s, function=%d, plugin=%s", cmd_name, function, plug ? plug->file : "unknown");
|
||||
META_DEBUG(4, "called: meta_AddServerCommand; cmd_name=%s, function=%d, plugin=%s", cmd_name, function, plug ? plug->m_file : "unknown");
|
||||
|
||||
if (!plug) {
|
||||
META_ERROR("Failed to find memloc for regcmd '%s'", cmd_name);
|
||||
@ -46,7 +46,6 @@ void EXT_FUNC meta_AddServerCommand(char *cmd_name, void (*function)())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Replacement for engine routine CVarRegister; called by plugins. Rather
|
||||
// then handing the engine the plugin's cvar structure (which is allocated
|
||||
// in the plugin DLL), this hands the engine a cvar structure allocated
|
||||
|
@ -27,7 +27,7 @@ int valid_gamedir_file(const char* path)
|
||||
|
||||
if (is_absolute_path(path))
|
||||
{
|
||||
Q_strncpy(buf, path, sizeof(buf));
|
||||
Q_strncpy(buf, path, sizeof buf);
|
||||
buf[sizeof buf - 1] = '\0';
|
||||
}
|
||||
else
|
||||
@ -47,17 +47,16 @@ int valid_gamedir_file(const char* path)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int size = st.st_size;
|
||||
if (!size)
|
||||
if (!st.st_size)
|
||||
{
|
||||
META_DEBUG(5, "Empty file: %s", buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ret == 0 && reg && size)
|
||||
if (ret == 0 && reg)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Turns path into a full path:
|
||||
@ -77,7 +76,7 @@ char* full_gamedir_path(const char* path, char* fullpath)
|
||||
Q_strncpy(buf, path, sizeof buf - 1);
|
||||
buf[sizeof buf - 1] = '\0';
|
||||
}
|
||||
else snprintf(buf, sizeof(buf), "%s/%s", GameDLL.gamedir, path);
|
||||
else snprintf(buf, sizeof buf, "%s/%s", GameDLL.gamedir, path);
|
||||
|
||||
// Remove relative path components, if possible.
|
||||
if (!realpath(buf, fullpath))
|
||||
|
@ -101,6 +101,26 @@ char *mm_strtok_r(char *s, const char *delim, char **ptrptr)
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
char* trimbuf(char *str)
|
||||
{
|
||||
char *ibuf;
|
||||
|
||||
if (str == NULL) return NULL;
|
||||
for (ibuf = str; *ibuf && (byte)(*ibuf) < (byte)0x80 && isspace(*ibuf); ++ibuf)
|
||||
;
|
||||
|
||||
int i = strlen(ibuf);
|
||||
if (str != ibuf)
|
||||
memmove(str, ibuf, i);
|
||||
|
||||
while (--i >= 0) {
|
||||
if (!isspace(str[i]))
|
||||
break;
|
||||
}
|
||||
str[i + 1] = '\0';
|
||||
return str;
|
||||
}
|
||||
|
||||
void normalize_pathname(char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -54,6 +54,7 @@ const char* LOCALINFO(char* key);
|
||||
char *mm_strtok_r(char *s, const char *delim, char **ptrptr);
|
||||
#endif
|
||||
|
||||
char* trimbuf(char *str);
|
||||
void normalize_pathname(char *path);
|
||||
bool is_absolute_path(const char *path);
|
||||
char *realpath(const char *file_name, char *resolved_name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user