mirror of
https://github.com/rehlds/metamod-r.git
synced 2025-01-14 15:47:54 +03:00
Removed some macros
This commit is contained in:
parent
ccea6516cb
commit
ca8d4e0bcf
@ -18,11 +18,11 @@
|
|||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120_xp</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>v120</PlatformToolset>
|
<PlatformToolset>v120_xp</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<TargetName>$(ProjectName)_mm</TargetName>
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<TargetName>$(ProjectName)</TargetName>
|
<TargetName>$(ProjectName)</TargetName>
|
||||||
@ -78,6 +78,7 @@
|
|||||||
<TargetMachine>MachineX86</TargetMachine>
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||||
<AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
<Midl>
|
<Midl>
|
||||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
@ -141,6 +142,7 @@
|
|||||||
<TargetMachine>MachineX86</TargetMachine>
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||||
<AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
<Midl>
|
<Midl>
|
||||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
@ -351,7 +351,7 @@ void cmd_doplug(PLUG_CMD pcmd)
|
|||||||
{
|
{
|
||||||
if (findp && findp->status >= PL_RUNNING)
|
if (findp && findp->status >= PL_RUNNING)
|
||||||
{
|
{
|
||||||
META_DEBUG(3, ("Required plugin '%s' found loaded and running.", arg));
|
META_DEBUG(3, "Required plugin '%s' found loaded and running.", arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Output to both places, because we don't want the admin
|
// Output to both places, because we don't want the admin
|
||||||
|
@ -71,20 +71,20 @@ bool MConfig::set(option_t* setp, const char* setstr)
|
|||||||
setstr);
|
setstr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
META_DEBUG(3, ("set config bool: %s = %s", setp->name, *optval ? "true" : "false"));
|
META_DEBUG(3, "set config bool: %s = %s", setp->name, *optval ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
case CF_STR:
|
case CF_STR:
|
||||||
if (*optstr)
|
if (*optstr)
|
||||||
Q_free(*optstr);
|
Q_free(*optstr);
|
||||||
*optstr = Q_strdup(setstr);
|
*optstr = Q_strdup(setstr);
|
||||||
META_DEBUG(3, ("set config string: %s = %s", setp->name, *optstr));
|
META_DEBUG(3, "set config string: %s = %s", setp->name, *optstr);
|
||||||
break;
|
break;
|
||||||
case CF_PATH:
|
case CF_PATH:
|
||||||
if (*optstr)
|
if (*optstr)
|
||||||
Q_free(*optstr);
|
Q_free(*optstr);
|
||||||
full_gamedir_path(setstr, pathbuf);
|
full_gamedir_path(setstr, pathbuf);
|
||||||
*optstr = Q_strdup(pathbuf);
|
*optstr = Q_strdup(pathbuf);
|
||||||
META_DEBUG(3, ("set config path: %s = %s", setp->name, *optstr));
|
META_DEBUG(3, "set config path: %s = %s", setp->name, *optstr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
META_ERROR("unrecognized config type '%d'", setp->type);
|
META_ERROR("unrecognized config type '%d'", setp->type);
|
||||||
@ -114,7 +114,7 @@ bool MConfig::load(const char* fn)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(2, ("Loading from config file: %s", loadfile));
|
META_DEBUG(2, "Loading from config file: %s", loadfile);
|
||||||
for (ln = 1; !feof(fp) && fgets(line, sizeof(line), fp); ln++)
|
for (ln = 1; !feof(fp) && fgets(line, sizeof(line), fp); ln++)
|
||||||
{
|
{
|
||||||
if (line[0] == '#' || line[0] == ';' || !Q_strncmp(line, "//", 2))
|
if (line[0] == '#' || line[0] == ';' || !Q_strncmp(line, "//", 2))
|
||||||
|
@ -50,7 +50,7 @@ bool install_gamedll(char *from, const char *to)
|
|||||||
int fd = open(to, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
|
int fd = open(to, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
META_DEBUG(3, ("Installing gamedll from cache: Failed to create file %s: %s", to, strerror(errno)) );
|
META_DEBUG(3, "Installing gamedll from cache: Failed to create file %s: %s", to, strerror(errno));
|
||||||
FREE_FILE(cachefile);
|
FREE_FILE(cachefile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ bool install_gamedll(char *from, const char *to)
|
|||||||
// Writing the file was not successfull
|
// Writing the file was not successfull
|
||||||
if (length_out != length_in)
|
if (length_out != length_in)
|
||||||
{
|
{
|
||||||
META_DEBUG(3, ("Installing gamedll from chache: Failed to write all %d bytes to file, only %d written: %s", length_in, length_out, strerror(errno)));
|
META_DEBUG(3, "Installing gamedll from chache: Failed to write all %d bytes to file, only %d written: %s", length_in, length_out, strerror(errno));
|
||||||
|
|
||||||
// Let's not leave a mess but clean up nicely.
|
// Let's not leave a mess but clean up nicely.
|
||||||
if (length_out >= 0)
|
if (length_out >= 0)
|
||||||
@ -75,7 +75,7 @@ bool install_gamedll(char *from, const char *to)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
META_DEBUG(3, ("Failed to install gamedll from cache: file %s not found in cache.", from));
|
META_DEBUG(3, "Failed to install gamedll from cache: file %s not found in cache.", from);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ bool setup_gamedll(gamedll_t *gamedll)
|
|||||||
knownfn = known->linux_so;
|
knownfn = known->linux_so;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
META_DEBUG(4, ("Checking for old version game DLL name '%s'.\n", knownfn));
|
META_DEBUG(4, "Checking for old version game DLL name '%s'.\n", knownfn);
|
||||||
Q_snprintf(gamedll->pathname, sizeof(gamedll->pathname), "dlls/%s", knownfn);
|
Q_snprintf(gamedll->pathname, sizeof(gamedll->pathname), "dlls/%s", knownfn);
|
||||||
|
|
||||||
// Check if the gamedll file exists. If not, try to install it from the cache.
|
// Check if the gamedll file exists. If not, try to install it from the cache.
|
||||||
|
@ -7,13 +7,13 @@ void do_link_ent(ENTITY_FN *pfnEntity, int *missing, const char *entStr, entvars
|
|||||||
{
|
{
|
||||||
if (*missing)
|
if (*missing)
|
||||||
{
|
{
|
||||||
META_DEBUG(9, ("Skipping entity '%s'; was previously found missing", entStr));
|
META_DEBUG(9, "Skipping entity '%s'; was previously found missing", entStr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*pfnEntity)
|
if (!*pfnEntity)
|
||||||
{
|
{
|
||||||
META_DEBUG(9, ("Looking up game entity '%s'", entStr));
|
META_DEBUG(9, "Looking up game entity '%s'", entStr);
|
||||||
*pfnEntity = (ENTITY_FN)GameDLL.sys_module.getsym(entStr);
|
*pfnEntity = (ENTITY_FN)GameDLL.sys_module.getsym(entStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +24,6 @@ void do_link_ent(ENTITY_FN *pfnEntity, int *missing, const char *entStr, entvars
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(8, ("Linking game entity '%s'", entStr));
|
META_DEBUG(8, "Linking game entity '%s'", entStr);
|
||||||
(*pfnEntity)(pev);
|
(*pfnEntity)(pev);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,18 @@ void META_LOG(const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NOINLINE META_DEBUG_(int level, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
char buf[MAX_LOGMSG_LEN];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
Q_vsnprintf(buf, sizeof buf, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
ALERT(at_logged, "[META] (debug:%i) %s\n", level, buf);
|
||||||
|
}
|
||||||
|
|
||||||
// Print to client.
|
// Print to client.
|
||||||
void META_CLIENT(edict_t *pEntity, const char *fmt, ...)
|
void META_CLIENT(edict_t *pEntity, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -13,9 +13,8 @@ extern cvar_t meta_debug;
|
|||||||
template<typename ...t_args>
|
template<typename ...t_args>
|
||||||
void META_DEBUG(int level, const char* fmt, t_args... args)
|
void META_DEBUG(int level, const char* fmt, t_args... args)
|
||||||
{
|
{
|
||||||
if (meta_debug.value < level)
|
if (unlikely(meta_debug.value >= level))
|
||||||
return;
|
META_DEBUG_(level, fmt, args...);
|
||||||
ALERT(at_logged, "[META] (debug:%i) %s\n", level, args...); // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void META_CONS(const char *fmt, ...);
|
void META_CONS(const char *fmt, ...);
|
||||||
@ -24,6 +23,7 @@ void META_INFO(const char *fmt, ...);
|
|||||||
void META_WARNING(const char *fmt, ...);
|
void META_WARNING(const char *fmt, ...);
|
||||||
void META_ERROR(const char *fmt, ...);
|
void META_ERROR(const char *fmt, ...);
|
||||||
void META_LOG(const char *fmt, ...);
|
void META_LOG(const char *fmt, ...);
|
||||||
|
void META_DEBUG_(int level, const char* fmt, ...);
|
||||||
void META_CLIENT(edict_t *pEntity, const char *fmt, ...);
|
void META_CLIENT(edict_t *pEntity, const char *fmt, ...);
|
||||||
|
|
||||||
void flush_ALERT_buffer(void);
|
void flush_ALERT_buffer(void);
|
||||||
|
@ -70,6 +70,7 @@ void metamod_startup()
|
|||||||
|
|
||||||
// Init default values
|
// Init default values
|
||||||
g_config->init(global_options);
|
g_config->init(global_options);
|
||||||
|
|
||||||
// Find config file
|
// Find config file
|
||||||
cfile = CONFIG_INI;
|
cfile = CONFIG_INI;
|
||||||
if ((cp = LOCALINFO("mm_configfile")) && *cp != '\0')
|
if ((cp = LOCALINFO("mm_configfile")) && *cp != '\0')
|
||||||
@ -84,7 +85,7 @@ void metamod_startup()
|
|||||||
if (valid_gamedir_file(cfile))
|
if (valid_gamedir_file(cfile))
|
||||||
g_config->load(cfile);
|
g_config->load(cfile);
|
||||||
else
|
else
|
||||||
META_DEBUG(2, ("No config.ini file found: %s", CONFIG_INI));
|
META_DEBUG(2, "No config.ini file found: %s", CONFIG_INI);
|
||||||
|
|
||||||
// Now, override config options with localinfo commandline options.
|
// Now, override config options with localinfo commandline options.
|
||||||
if ((cp = LOCALINFO("mm_debug")) && *cp != '\0')
|
if ((cp = LOCALINFO("mm_debug")) && *cp != '\0')
|
||||||
@ -180,10 +181,7 @@ void metamod_startup()
|
|||||||
// Exit on failure here? Dunno...
|
// Exit on failure here? Dunno...
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UNFINISHED
|
meta_init_rehlds_api();
|
||||||
// Start up the log parsing thread.
|
|
||||||
startup_logparse_thread();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Allow for commands to metamod plugins at startup. Autoexec.cfg is
|
// Allow for commands to metamod plugins at startup. Autoexec.cfg is
|
||||||
// read too early, and server.cfg is read too late.
|
// read too early, and server.cfg is read too late.
|
||||||
@ -207,7 +205,7 @@ void metamod_startup()
|
|||||||
{
|
{
|
||||||
char cmd[NAME_MAX];
|
char cmd[NAME_MAX];
|
||||||
META_LOG("Exec'ing metamod exec.cfg: %s...", mmfile);
|
META_LOG("Exec'ing metamod exec.cfg: %s...", mmfile);
|
||||||
Q_snprintf(cmd, sizeof(cmd), "exec %s\n", mmfile);
|
Q_snprintf(cmd, sizeof cmd, "exec %s\n", mmfile);
|
||||||
SERVER_COMMAND(cmd);
|
SERVER_COMMAND(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,13 +239,13 @@ bool meta_init_gamedll(void)
|
|||||||
// Old style; GET_GAME_DIR returned full pathname. Copy this into
|
// Old style; GET_GAME_DIR returned full pathname. Copy this into
|
||||||
// our gamedir, and truncate to get the game name.
|
// our gamedir, and truncate to get the game name.
|
||||||
// (note check for both linux and win32 full pathname.)
|
// (note check for both linux and win32 full pathname.)
|
||||||
Q_strncpy(GameDLL.gamedir, gamedir, sizeof(GameDLL.gamedir) - 1);
|
Q_strncpy(GameDLL.gamedir, gamedir, sizeof GameDLL.gamedir - 1);
|
||||||
GameDLL.gamedir[sizeof(GameDLL.gamedir) - 1] = '\0';
|
GameDLL.gamedir[sizeof GameDLL.gamedir - 1] = '\0';
|
||||||
|
|
||||||
cp = Q_strrchr(gamedir, '/') + 1;
|
cp = Q_strrchr(gamedir, '/') + 1;
|
||||||
|
|
||||||
Q_strncpy(GameDLL.name, cp, sizeof(GameDLL.name) - 1);
|
Q_strncpy(GameDLL.name, cp, sizeof GameDLL.name - 1);
|
||||||
GameDLL.name[sizeof(GameDLL.name) - 1] = '\0';
|
GameDLL.name[sizeof GameDLL.name - 1] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -265,10 +263,52 @@ bool meta_init_gamedll(void)
|
|||||||
GameDLL.name[sizeof(GameDLL.name) - 1] = '\0';
|
GameDLL.name[sizeof(GameDLL.name) - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(3, ("Game: %s", GameDLL.name));
|
META_DEBUG(3, "Game: %s", GameDLL.name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
auto pfnGetFuncs = (getfunc_t)GameDLL.sys_module.getsym(ifname);
|
||||||
|
|
||||||
|
if (pfnGetFuncs) {
|
||||||
|
table = (table_t *)Q_calloc(1, table_size);
|
||||||
|
|
||||||
|
int ifvers_gamedll = ifvers_mm;
|
||||||
|
|
||||||
|
if (pfnGetFuncs(table, ifvers_gamedll)) {
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (ifvers_gamedll != ifvers_mm) {
|
||||||
|
META_ERROR("dll: Interface version didn't match; we wanted %d, they had %d", ifvers_mm, ifvers_gamedll);
|
||||||
|
META_CONS("==================");
|
||||||
|
META_CONS("Game DLL version mismatch");
|
||||||
|
META_CONS("DLL version is %d, engine version is %d", ifvers_gamedll, ifvers_mm);
|
||||||
|
if (ifvers_gamedll > ifvers_mm)
|
||||||
|
META_CONS("g_engine appears to be outdated, check for updates");
|
||||||
|
else
|
||||||
|
META_CONS("The game DLL for %s appears to be outdated, check for updates", GameDLL.name);
|
||||||
|
META_CONS("==================");
|
||||||
|
ALERT(at_error, "Exiting...\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
META_DEBUG(5, "dll: Game '%s': No %s", GameDLL.name, ifname);
|
||||||
|
table = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Load game DLL.
|
// Load game DLL.
|
||||||
// meta_errno values:
|
// meta_errno values:
|
||||||
// - ME_DLOPEN couldn't dlopen game dll file
|
// - ME_DLOPEN couldn't dlopen game dll file
|
||||||
@ -276,14 +316,6 @@ bool meta_init_gamedll(void)
|
|||||||
// (GiveFnptrsToDll, GetEntityAPI, GetEntityAPI2)
|
// (GiveFnptrsToDll, GetEntityAPI, GetEntityAPI2)
|
||||||
bool meta_load_gamedll(void)
|
bool meta_load_gamedll(void)
|
||||||
{
|
{
|
||||||
int iface_vers;
|
|
||||||
int found = 0;
|
|
||||||
|
|
||||||
GIVE_ENGINE_FUNCTIONS_FN pfn_give_engfuncs;
|
|
||||||
GETNEWDLLFUNCTIONS_FN pfn_getapinew;
|
|
||||||
GETENTITYAPI2_FN pfn_getapi2;
|
|
||||||
GETENTITYAPI_FN pfn_getapi;
|
|
||||||
|
|
||||||
if (!setup_gamedll(&GameDLL))
|
if (!setup_gamedll(&GameDLL))
|
||||||
{
|
{
|
||||||
META_ERROR("dll: Unrecognized game: %s", GameDLL.name);
|
META_ERROR("dll: Unrecognized game: %s", GameDLL.name);
|
||||||
@ -305,10 +337,12 @@ bool meta_load_gamedll(void)
|
|||||||
// wanted to catch one of the functions, but now that plugins are
|
// wanted to catch one of the functions, but now that plugins are
|
||||||
// dynamically loadable at any time, we have to always pass our table,
|
// dynamically loadable at any time, we have to always pass our table,
|
||||||
// so that any plugin loaded later can catch what they need to.
|
// so that any plugin loaded later can catch what they need to.
|
||||||
if ((pfn_give_engfuncs = (GIVE_ENGINE_FUNCTIONS_FN)GameDLL.sys_module.getsym("GiveFnptrsToDll")))
|
auto pfn_give_engfuncs = (GIVE_ENGINE_FUNCTIONS_FN)GameDLL.sys_module.getsym("GiveFnptrsToDll");
|
||||||
|
|
||||||
|
if (pfn_give_engfuncs)
|
||||||
{
|
{
|
||||||
pfn_give_engfuncs(&meta_engfuncs, gpGlobals);
|
pfn_give_engfuncs(&meta_engfuncs, gpGlobals);
|
||||||
META_DEBUG(3, ("dll: Game '%s': Called GiveFnptrsToDll", GameDLL.name));
|
META_DEBUG(3, "dll: Game '%s': Called GiveFnptrsToDll", GameDLL.name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -316,62 +350,20 @@ bool meta_load_gamedll(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
// Yes...another macro.
|
|
||||||
#define GET_FUNC_TABLE_FROM_GAME(gamedll, pfnGetFuncs, STR_GetFuncs, struct_field, API_TYPE, TABLE_TYPE, vers_pass, vers_int, vers_want, gotit) \
|
|
||||||
if ((pfnGetFuncs = (API_TYPE)gamedll.sys_module.getsym(STR_GetFuncs))) { \
|
|
||||||
gamedll.funcs.struct_field = (TABLE_TYPE *)Q_calloc(1, sizeof(TABLE_TYPE)); \
|
|
||||||
if (!gamedll.funcs.struct_field) {\
|
|
||||||
META_ERROR("malloc failed for gamedll struct_field: %s", STR_GetFuncs); \
|
|
||||||
} \
|
|
||||||
else if (pfnGetFuncs(gamedll.funcs.struct_field, vers_pass)) { \
|
|
||||||
META_DEBUG(3, ("dll: Game '%s': Found %s", gamedll.name, STR_GetFuncs)); \
|
|
||||||
gotit = 1; \
|
|
||||||
} \
|
|
||||||
else { \
|
|
||||||
META_ERROR("dll: Failure calling %s in game '%s'", STR_GetFuncs, gamedll.name); \
|
|
||||||
Q_free(gamedll.funcs.struct_field); \
|
|
||||||
gamedll.funcs.struct_field = NULL; \
|
|
||||||
if (vers_int != vers_want) { \
|
|
||||||
META_ERROR("dll: Interface version didn't match; we wanted %d, they had %d", vers_want, vers_int); \
|
|
||||||
/* reproduce error from engine */ \
|
|
||||||
META_CONS("=================="); \
|
|
||||||
META_CONS("Game DLL version mismatch"); \
|
|
||||||
META_CONS("DLL version is %d, engine version is %d", vers_int, vers_want); \
|
|
||||||
if (vers_int > vers_want) \
|
|
||||||
META_CONS("g_engine appears to be outdated, check for updates"); \
|
|
||||||
else \
|
|
||||||
META_CONS("The game DLL for %s appears to be outdated, check for updates", GameDLL.name); \
|
|
||||||
META_CONS("=================="); \
|
|
||||||
ALERT(at_error, "Exiting...\n"); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
else { \
|
|
||||||
META_DEBUG(5, ("dll: Game '%s': No %s", gamedll.name, STR_GetFuncs)); \
|
|
||||||
gamedll.funcs.struct_field = NULL; \
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for API-NEW interface in Game dll. We do this before API2/API, because
|
// Look for API-NEW interface in Game dll. We do this before API2/API, because
|
||||||
// that's what the engine appears to do..
|
// that's what the engine appears to do..
|
||||||
iface_vers = NEW_DLL_FUNCTIONS_VERSION;
|
get_function_table<int&>("GetNewDLLFunctions", NEW_DLL_FUNCTIONS_VERSION, GameDLL.funcs.newapi_table);
|
||||||
GET_FUNC_TABLE_FROM_GAME(GameDLL, pfn_getapinew, "GetNewDLLFunctions", newapi_table, GETNEWDLLFUNCTIONS_FN, meta_new_dll_functions_t, &iface_vers, iface_vers, NEW_DLL_FUNCTIONS_VERSION, found);
|
|
||||||
|
|
||||||
// Look for API2 interface in plugin; preferred over API-1.
|
// Look for API2 interface in plugin; preferred over API-1.
|
||||||
found = 0;
|
bool found = get_function_table<int&>("GetEntityAPI2", INTERFACE_VERSION, GameDLL.funcs.dllapi_table);
|
||||||
iface_vers = INTERFACE_VERSION;
|
|
||||||
GET_FUNC_TABLE_FROM_GAME(GameDLL, pfn_getapi2, "GetEntityAPI2", dllapi_table, GETENTITYAPI2_FN, DLL_FUNCTIONS, &iface_vers, iface_vers, INTERFACE_VERSION, found);
|
|
||||||
|
|
||||||
// Look for API-1 in plugin, if API2 interface wasn't found.
|
// Look for API-1 in plugin, if API2 interface wasn't found.
|
||||||
if (!found)
|
if (!found) {
|
||||||
{
|
found = get_function_table<int>("GetEntityAPI", INTERFACE_VERSION, GameDLL.funcs.dllapi_table);
|
||||||
found = 0;
|
|
||||||
GET_FUNC_TABLE_FROM_GAME(GameDLL, pfn_getapi, "GetEntityAPI", dllapi_table, GETENTITYAPI_FN, DLL_FUNCTIONS, INTERFACE_VERSION, INTERFACE_VERSION, INTERFACE_VERSION, found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If didn't find either, return failure.
|
// If didn't find either, return failure.
|
||||||
if (!found)
|
if (!found) {
|
||||||
{
|
|
||||||
META_ERROR("dll: Couldn't find either GetEntityAPI nor GetEntityAPI2 in game DLL '%s'", GameDLL.name);
|
META_ERROR("dll: Couldn't find either GetEntityAPI nor GetEntityAPI2 in game DLL '%s'", GameDLL.name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -83,23 +83,23 @@ MPlugin *MPluginList::find(const char* findpath)
|
|||||||
if (!findpath)
|
if (!findpath)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
META_DEBUG(8, ("Looking for loaded plugin with dlfnamepath: %s", findpath));
|
META_DEBUG(8, "Looking for loaded plugin with dlfnamepath: %s", findpath);
|
||||||
|
|
||||||
for (int i = 0; i < max_loaded_count; i++)
|
for (int i = 0; i < max_loaded_count; i++)
|
||||||
{
|
{
|
||||||
META_DEBUG(9, ("Looking at: plugin %s loadedpath: %s", plist[i].file, plist[i].pathname));
|
META_DEBUG(9, "Looking at: plugin %s loadedpath: %s", plist[i].file, plist[i].pathname);
|
||||||
|
|
||||||
if (plist[i].status < PL_VALID)
|
if (plist[i].status < PL_VALID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!Q_strcmp(plist[i].pathname, findpath))
|
if (!Q_strcmp(plist[i].pathname, findpath))
|
||||||
{
|
{
|
||||||
META_DEBUG(8, ("Found loaded plugin %s", plist[i].file));
|
META_DEBUG(8, "Found loaded plugin %s", plist[i].file);
|
||||||
return &plist[i];
|
return &plist[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(8, ("No loaded plugin found with path: %s", findpath));
|
META_DEBUG(8, "No loaded plugin found with path: %s", findpath);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ MPlugin* MPluginList::plugin_addload(plid_t plid, const char* fname, PLUG_LOADTI
|
|||||||
|
|
||||||
if (!(pl_loader = find(plid)))
|
if (!(pl_loader = find(plid)))
|
||||||
{
|
{
|
||||||
META_DEBUG(1, ("Couldn't find plugin that gave this loading request!"));
|
META_DEBUG(1, "Couldn't find plugin that gave this loading request!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,20 +241,19 @@ MPlugin* MPluginList::plugin_addload(plid_t plid, const char* fname, PLUG_LOADTI
|
|||||||
|
|
||||||
if (pl_temp.resolve() != true)
|
if (pl_temp.resolve() != true)
|
||||||
{
|
{
|
||||||
META_DEBUG(1, ("Couldn't resolve given path into a file: %s", pl_temp.file));
|
META_DEBUG(1, "Couldn't resolve given path into a file: %s", pl_temp.file);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pl_found = find(pl_temp.pathname)))
|
if ((pl_found = find(pl_temp.pathname)))
|
||||||
{
|
{
|
||||||
META_DEBUG(1, ("Plugin '%s' already in current list; file=%s desc='%s'",
|
META_DEBUG(1, "Plugin '%s' already in current list; file=%s desc='%s'", pl_temp.file, pl_found->file, pl_found->desc);
|
||||||
pl_temp.file, pl_found->file, pl_found->desc));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pl_added = add(&pl_temp)))
|
if (!(pl_added = add(&pl_temp)))
|
||||||
{
|
{
|
||||||
META_DEBUG(1, ("Couldn't add plugin '%s' to list; see log", pl_temp.desc));
|
META_DEBUG(1, "Couldn't add plugin '%s' to list; see log", pl_temp.desc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,21 +262,21 @@ MPlugin* MPluginList::plugin_addload(plid_t plid, const char* fname, PLUG_LOADTI
|
|||||||
{
|
{
|
||||||
if (1/*meta_errno == ME_NOTALLOWED || meta_errno == ME_DELAYED*/)
|
if (1/*meta_errno == ME_NOTALLOWED || meta_errno == ME_DELAYED*/)
|
||||||
{
|
{
|
||||||
META_DEBUG(1, ("Plugin '%s' couldn't attach; only allowed %s", pl_added->desc, pl_added->str_loadable(SL_ALLOWED)));
|
META_DEBUG(1, "Plugin '%s' couldn't attach; only allowed %s", pl_added->desc, pl_added->str_loadable(SL_ALLOWED));
|
||||||
pl_added->clear();
|
pl_added->clear();
|
||||||
}
|
}
|
||||||
else if (pl_added->status == PL_OPENED)
|
else if (pl_added->status == PL_OPENED)
|
||||||
{
|
{
|
||||||
META_DEBUG(1, ("Opened plugin '%s', but failed to attach; see log", pl_added->desc));
|
META_DEBUG(1, "Opened plugin '%s', but failed to attach; see log", pl_added->desc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
META_DEBUG(1, ("Couldn't load plugin '%s'; see log", pl_added->desc));
|
META_DEBUG(1, "Couldn't load plugin '%s'; see log", pl_added->desc);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(1, ("Loaded plugin '%s' successfully", pl_added->desc));
|
META_DEBUG(1, "Loaded plugin '%s' successfully", pl_added->desc);
|
||||||
|
|
||||||
return pl_added;
|
return pl_added;
|
||||||
}
|
}
|
||||||
@ -518,7 +517,7 @@ bool MPluginList::ini_refresh()
|
|||||||
// Newer file on disk.
|
// Newer file on disk.
|
||||||
else if (pl_found->status >= PL_OPENED)
|
else if (pl_found->status >= PL_OPENED)
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("ini: Plugin '%s' has newer file on disk", pl_found->desc));
|
META_DEBUG(2, "ini: Plugin '%s' has newer file on disk", pl_found->desc);
|
||||||
pl_found->action = PA_RELOAD;
|
pl_found->action = PA_RELOAD;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -679,19 +678,19 @@ bool MPluginList::refresh(PLUG_LOADTIME now)
|
|||||||
switch (iplug->action)
|
switch (iplug->action)
|
||||||
{
|
{
|
||||||
case PA_KEEP:
|
case PA_KEEP:
|
||||||
META_DEBUG(1, ("Keeping plugin '%s'", iplug->desc));
|
META_DEBUG(1, "Keeping plugin '%s'", iplug->desc);
|
||||||
iplug->action = PA_NONE;
|
iplug->action = PA_NONE;
|
||||||
nkept++;
|
nkept++;
|
||||||
break;
|
break;
|
||||||
case PA_LOAD:
|
case PA_LOAD:
|
||||||
META_DEBUG(1, ("Loading plugin '%s'", iplug->desc));
|
META_DEBUG(1, "Loading plugin '%s'", iplug->desc);
|
||||||
if (iplug->load(now))
|
if (iplug->load(now))
|
||||||
nloaded++;
|
nloaded++;
|
||||||
else if (1/*meta_errno == ME_DELAYED*/)
|
else if (1/*meta_errno == ME_DELAYED*/)
|
||||||
ndelayed++;
|
ndelayed++;
|
||||||
break;
|
break;
|
||||||
case PA_RELOAD:
|
case PA_RELOAD:
|
||||||
META_DEBUG(1, ("Reloading plugin '%s'", iplug->desc));
|
META_DEBUG(1, "Reloading plugin '%s'", iplug->desc);
|
||||||
if (iplug->reload(now, PNL_FILE_NEWER))
|
if (iplug->reload(now, PNL_FILE_NEWER))
|
||||||
nreloaded++;
|
nreloaded++;
|
||||||
else if (1/*meta_errno == ME_DELAYED*/)
|
else if (1/*meta_errno == ME_DELAYED*/)
|
||||||
@ -701,7 +700,7 @@ bool MPluginList::refresh(PLUG_LOADTIME now)
|
|||||||
// If previously loaded from ini, but apparently removed from new ini.
|
// If previously loaded from ini, but apparently removed from new ini.
|
||||||
if (iplug->source == PS_INI && iplug->status >= PL_RUNNING)
|
if (iplug->source == PS_INI && iplug->status >= PL_RUNNING)
|
||||||
{
|
{
|
||||||
META_DEBUG(1, ("Unloading plugin '%s'", iplug->desc));
|
META_DEBUG(1, "Unloading plugin '%s'", iplug->desc);
|
||||||
iplug->action = PA_UNLOAD;
|
iplug->action = PA_UNLOAD;
|
||||||
if (iplug->unload(now, PNL_INI_DELETED, PNL_INI_DELETED))
|
if (iplug->unload(now, PNL_INI_DELETED, PNL_INI_DELETED))
|
||||||
nunloaded++;
|
nunloaded++;
|
||||||
@ -711,7 +710,7 @@ bool MPluginList::refresh(PLUG_LOADTIME now)
|
|||||||
break;
|
break;
|
||||||
case PA_ATTACH:
|
case PA_ATTACH:
|
||||||
// Previously requested attach, but was delayed?
|
// Previously requested attach, but was delayed?
|
||||||
META_DEBUG(1, ("Retrying attach plugin '%s'", iplug->desc));
|
META_DEBUG(1, "Retrying attach plugin '%s'", iplug->desc);
|
||||||
if (iplug->retry(now, PNL_DELAYED))
|
if (iplug->retry(now, PNL_DELAYED))
|
||||||
nloaded++;
|
nloaded++;
|
||||||
else if (1/*meta_errno == ME_DELAYED*/)
|
else if (1/*meta_errno == ME_DELAYED*/)
|
||||||
@ -719,7 +718,7 @@ bool MPluginList::refresh(PLUG_LOADTIME now)
|
|||||||
break;
|
break;
|
||||||
case PA_UNLOAD:
|
case PA_UNLOAD:
|
||||||
// Previously requested unload, but was delayed?
|
// Previously requested unload, but was delayed?
|
||||||
META_DEBUG(1, ("Retrying unload plugin '%s'", iplug->desc));
|
META_DEBUG(1, "Retrying unload plugin '%s'", iplug->desc);
|
||||||
if (iplug->retry(now, PNL_DELAYED))
|
if (iplug->retry(now, PNL_DELAYED))
|
||||||
nunloaded++;
|
nunloaded++;
|
||||||
else if (1/*meta_errno == ME_DELAYED*/)
|
else if (1/*meta_errno == ME_DELAYED*/)
|
||||||
|
@ -21,13 +21,13 @@ bool MPlugin::ini_parseline(char *line)
|
|||||||
// skip empty lines
|
// skip empty lines
|
||||||
if (line[0] == '\0')
|
if (line[0] == '\0')
|
||||||
{
|
{
|
||||||
META_DEBUG(7, ("ini: Ignoring empty line: %s", line));
|
META_DEBUG(7, "ini: Ignoring empty line: %s", line);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line[0] == '#' || line[0] == ';' || Q_strstr(line, "//") == line)
|
if (line[0] == '#' || line[0] == ';' || Q_strstr(line, "//") == line)
|
||||||
{
|
{
|
||||||
META_DEBUG(7, ("ini: Ignoring commented line: %s", line));
|
META_DEBUG(7, "ini: Ignoring commented line: %s", line);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ bool MPlugin::ini_parseline(char *line)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// plugin is not for this OS
|
// plugin is not for this OS
|
||||||
META_DEBUG(7, ("ini: Ignoring entry for %s", token));
|
META_DEBUG(7, "ini: Ignoring entry for %s", token);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ bool MPlugin::plugin_unload(plid_t plid, PLUG_LOADTIME now, PL_UNLOAD_REASON rea
|
|||||||
if (0/*meta_errno == ME_DELAYED*/)
|
if (0/*meta_errno == ME_DELAYED*/)
|
||||||
{
|
{
|
||||||
action = old_action;
|
action = old_action;
|
||||||
META_DEBUG(2, ("dll: Failed unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(PT_ANYTIME, SL_SIMPLE)));
|
META_DEBUG(2, "dll: Failed unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(PT_ANYTIME, SL_SIMPLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -306,11 +306,11 @@ bool MPlugin::resolve(void)
|
|||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("Couldn't resolve '%s' to file", filename));
|
META_DEBUG(2, "Couldn't resolve '%s' to file", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(2, ("Resolved '%s' to file '%s'", filename, found));
|
META_DEBUG(2, "Resolved '%s' to file '%s'", filename, found);
|
||||||
|
|
||||||
// store pathname: the resolved path (should be absolute)
|
// store pathname: the resolved path (should be absolute)
|
||||||
Q_strncpy(pathname, found, sizeof pathname - 1);
|
Q_strncpy(pathname, found, sizeof pathname - 1);
|
||||||
@ -610,12 +610,12 @@ bool MPlugin::load(PLUG_LOADTIME now)
|
|||||||
if (info->loadable > PT_STARTUP)
|
if (info->loadable > PT_STARTUP)
|
||||||
{
|
{
|
||||||
// will try to attach again at next opportunity
|
// will try to attach again at next opportunity
|
||||||
META_DEBUG(2, ("dll: Delaying load plugin '%s'; can't attach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE)));
|
META_DEBUG(2, "dll: Delaying load plugin '%s'; can't attach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("dll: Failed load plugin '%s'; can't attach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE)));
|
META_DEBUG(2, "dll: Failed load plugin '%s'; can't attach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
// don't try to attach again later
|
// don't try to attach again later
|
||||||
action = PA_NONE;
|
action = PA_NONE;
|
||||||
return false;
|
return false;
|
||||||
@ -718,11 +718,11 @@ bool MPlugin::query(void)
|
|||||||
if (pfn_init)
|
if (pfn_init)
|
||||||
{
|
{
|
||||||
pfn_init();
|
pfn_init();
|
||||||
META_DEBUG(6, ("dll: Plugin '%s': Called Meta_Init()", desc));
|
META_DEBUG(6, "dll: Plugin '%s': Called Meta_Init()", desc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
META_DEBUG(5, ("dll: no Meta_Init present in plugin '%s'", desc));
|
META_DEBUG(5, "dll: no Meta_Init present in plugin '%s'", desc);
|
||||||
// don't return; not an error
|
// don't return; not an error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,7 +735,7 @@ bool MPlugin::query(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pfn_give_engfuncs(g_engine.pl_funcs, g_engine.globals);
|
pfn_give_engfuncs(g_engine.pl_funcs, g_engine.globals);
|
||||||
META_DEBUG(6, ("dll: Plugin '%s': Called GiveFnptrsToDll()", desc));
|
META_DEBUG(6, "dll: Plugin '%s': Called GiveFnptrsToDll()", desc);
|
||||||
|
|
||||||
// Call plugin's Meta_Query(), to pass our meta interface version, and get
|
// Call plugin's Meta_Query(), to pass our meta interface version, and get
|
||||||
// plugin's info structure.
|
// plugin's info structure.
|
||||||
@ -752,8 +752,7 @@ bool MPlugin::query(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
META_DEBUG(6, ("dll: Plugin '%s': Called Meta_Query() successfully",
|
META_DEBUG(6, "dll: Plugin '%s': Called Meta_Query() successfully", desc);
|
||||||
desc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for interface differences... Generally, a difference in major
|
// Check for interface differences... Generally, a difference in major
|
||||||
@ -768,7 +767,7 @@ bool MPlugin::query(void)
|
|||||||
if (info && !FStrEq(info->ifvers, META_INTERFACE_VERSION))
|
if (info && !FStrEq(info->ifvers, META_INTERFACE_VERSION))
|
||||||
{
|
{
|
||||||
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
|
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
|
||||||
META_DEBUG(3, ("dll: Note: Plugin '%s' interface version didn't match; expected %s, found %s", desc, META_INTERFACE_VERSION, info->ifvers));
|
META_DEBUG(3, "dll: Note: Plugin '%s' interface version didn't match; expected %s, found %s", desc, META_INTERFACE_VERSION, info->ifvers);
|
||||||
sscanf(META_INTERFACE_VERSION, "%d:%d", &mmajor, &mminor);
|
sscanf(META_INTERFACE_VERSION, "%d:%d", &mmajor, &mminor);
|
||||||
sscanf(info->ifvers, "%d:%d", &pmajor, &pminor);
|
sscanf(info->ifvers, "%d:%d", &pmajor, &pminor);
|
||||||
// If plugin has later interface version, it's incompatible
|
// If plugin has later interface version, it's incompatible
|
||||||
@ -816,7 +815,7 @@ bool MPlugin::query(void)
|
|||||||
desc[sizeof desc - 1] = '\0';
|
desc[sizeof desc - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(6, ("dll: Plugin '%s': Query successful", desc));
|
META_DEBUG(6, "dll: Plugin '%s': Query successful", desc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -887,7 +886,7 @@ bool MPlugin::attach(PLUG_LOADTIME now)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(6, ("dll: Plugin '%s': Called Meta_Attach() successfully", desc));
|
META_DEBUG(6, "dll: Plugin '%s': Called Meta_Attach() successfully", desc);
|
||||||
|
|
||||||
// Rather than duplicate code, we use another ugly macro. Again,
|
// Rather than duplicate code, we use another ugly macro. Again,
|
||||||
// a function isn't an option since we have varying types.
|
// a function isn't an option since we have varying types.
|
||||||
@ -896,7 +895,7 @@ bool MPlugin::attach(PLUG_LOADTIME now)
|
|||||||
if (!struct_field) \
|
if (!struct_field) \
|
||||||
struct_field = (TABLE_TYPE *)Q_calloc(1, sizeof(TABLE_TYPE)); \
|
struct_field = (TABLE_TYPE *)Q_calloc(1, sizeof(TABLE_TYPE)); \
|
||||||
if (meta_table.pfnGetFuncs(struct_field, vers_pass)) { \
|
if (meta_table.pfnGetFuncs(struct_field, vers_pass)) { \
|
||||||
META_DEBUG(3, ("dll: Plugin '%s': Found %s", desc, STR_GetFuncs)); \
|
META_DEBUG(3, "dll: Plugin '%s': Found %s", desc, STR_GetFuncs); \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
META_ERROR("dll: Failure calling %s in plugin '%s'", STR_GetFuncs, desc); \
|
META_ERROR("dll: Failure calling %s in plugin '%s'", STR_GetFuncs, desc); \
|
||||||
@ -905,7 +904,7 @@ bool MPlugin::attach(PLUG_LOADTIME now)
|
|||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
META_DEBUG(5, ("dll: Plugin '%s': No %s", desc, STR_GetFuncs)); \
|
META_DEBUG(5, "dll: Plugin '%s': No %s", desc, STR_GetFuncs); \
|
||||||
if (struct_field) \
|
if (struct_field) \
|
||||||
Q_free(struct_field); \
|
Q_free(struct_field); \
|
||||||
struct_field = NULL; \
|
struct_field = NULL; \
|
||||||
@ -1011,20 +1010,20 @@ bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, PL_UNLOAD_REASO
|
|||||||
{
|
{
|
||||||
if (reason == PNL_CMD_FORCED)
|
if (reason == PNL_CMD_FORCED)
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("dll: Forced unload plugin '%s' overriding allowed times: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE)));
|
META_DEBUG(2, "dll: Forced unload plugin '%s' overriding allowed times: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (info->unloadable > PT_STARTUP)
|
if (info->unloadable > PT_STARTUP)
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("dll: Delaying unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE)));
|
META_DEBUG(2, "dll: Delaying unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
// caller should give message to user
|
// caller should give message to user
|
||||||
// try to unload again at next opportunity
|
// try to unload again at next opportunity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("dll: Failed unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE)));
|
META_DEBUG(2, "dll: Failed unload plugin '%s'; can't detach now: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
// don't try to unload again later
|
// don't try to unload again later
|
||||||
action = PA_NONE;
|
action = PA_NONE;
|
||||||
return false;
|
return false;
|
||||||
@ -1042,11 +1041,11 @@ bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, PL_UNLOAD_REASO
|
|||||||
{
|
{
|
||||||
if (reason == PNL_RELOAD)
|
if (reason == PNL_RELOAD)
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("dll: Reload plugin '%s' overriding failed detach", desc));
|
META_DEBUG(2, "dll: Reload plugin '%s' overriding failed detach", desc);
|
||||||
}
|
}
|
||||||
else if (reason == PNL_CMD_FORCED)
|
else if (reason == PNL_CMD_FORCED)
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("dll: Forced unload plugin '%s' overriding failed detach"));
|
META_DEBUG(2, "dll: Forced unload plugin '%s' overriding failed detach");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1124,7 +1123,7 @@ bool MPlugin::detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(6, ("dll: Plugin '%s': Called Meta_Detach() successfully", desc));
|
META_DEBUG(6, "dll: Plugin '%s': Called Meta_Detach() successfully", desc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,14 +1146,14 @@ bool MPlugin::reload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
|||||||
{
|
{
|
||||||
if (info->loadable > PT_STARTUP)
|
if (info->loadable > PT_STARTUP)
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("dll: Delaying reload plugin '%s'; would not be able to reattach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE)));
|
META_DEBUG(2, "dll: Delaying reload plugin '%s'; would not be able to reattach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
// caller should give message to user
|
// caller should give message to user
|
||||||
// try to reload again at next opportunity
|
// try to reload again at next opportunity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
META_DEBUG(2, ("dll: Failed reload plugin '%s'; would not be able to reattach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE)));
|
META_DEBUG(2, "dll: Failed reload plugin '%s'; would not be able to reattach now: allowed=%s; now=%s", desc, str_loadable(), str_loadtime(now, SL_SIMPLE));
|
||||||
// don't try to reload again later
|
// don't try to reload again later
|
||||||
action = PA_NONE;
|
action = PA_NONE;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
MRegCmd::MRegCmd(char* cmd_name, REG_CMD_FN cmd_handler, MPlugin* cmd_plugin) : m_pfunction(cmd_handler), m_status(RG_VALID), m_plugid(cmd_plugin->index)
|
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)
|
||||||
{
|
{
|
||||||
m_name = _strdup(m_name);
|
m_name = _strdup(cmd_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MRegCmd::call() const
|
bool MRegCmd::call() const
|
||||||
|
@ -174,7 +174,7 @@ void EXT_FUNC mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, const c
|
|||||||
// Jussi Kivilinna.
|
// Jussi Kivilinna.
|
||||||
qboolean EXT_FUNC 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)
|
||||||
{
|
{
|
||||||
META_DEBUG(8, ("Looking up game entity '%s' for plugin '%s'", entStr, plid->name));
|
META_DEBUG(8, "Looking up game entity '%s' for plugin '%s'", entStr, plid->name);
|
||||||
ENTITY_FN pfnEntity = (ENTITY_FN)GameDLL.sys_module.getsym(entStr);
|
ENTITY_FN pfnEntity = (ENTITY_FN)GameDLL.sys_module.getsym(entStr);
|
||||||
|
|
||||||
if (!pfnEntity)
|
if (!pfnEntity)
|
||||||
@ -183,7 +183,7 @@ qboolean EXT_FUNC mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(7, ("Calling game entity '%s' for plugin '%s'", entStr, plid->name));
|
META_DEBUG(7, "Calling game entity '%s' for plugin '%s'", entStr, plid->name);
|
||||||
(*pfnEntity)(pev);
|
(*pfnEntity)(pev);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,18 @@
|
|||||||
#define PLATFORM "mswin"
|
#define PLATFORM "mswin"
|
||||||
#define PLATFORM_SPC "win32"
|
#define PLATFORM_SPC "win32"
|
||||||
#define PLATFORM_DLEXT ".dll"
|
#define PLATFORM_DLEXT ".dll"
|
||||||
|
|
||||||
|
#define likely(x) (x)
|
||||||
|
#define unlikely(x) (x)
|
||||||
#else
|
#else
|
||||||
#define UNUSED __attribute__((unused))
|
#define UNUSED __attribute__((unused))
|
||||||
|
|
||||||
#define PLATFORM "linux"
|
#define PLATFORM "linux"
|
||||||
#define PLATFORM_SPC "lin32"
|
#define PLATFORM_SPC "lin32"
|
||||||
#define PLATFORM_DLEXT ".so"
|
#define PLATFORM_DLEXT ".so"
|
||||||
|
|
||||||
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mreg.h"
|
#include "mreg.h"
|
||||||
|
@ -30,7 +30,7 @@ void EXT_FUNC meta_AddServerCommand(char *cmd_name, void (*function)())
|
|||||||
{
|
{
|
||||||
MPlugin *plug = g_plugins->find_memloc(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->file : "unknown");
|
||||||
|
|
||||||
if (!plug) {
|
if (!plug) {
|
||||||
META_ERROR("Failed to find memloc for regcmd '%s'", cmd_name);
|
META_ERROR("Failed to find memloc for regcmd '%s'", cmd_name);
|
||||||
|
@ -16,9 +16,8 @@ void __declspec(noreturn) do_exit(int exitval)
|
|||||||
// Special-case-recognize "/dev/null" as a valid file.
|
// Special-case-recognize "/dev/null" as a valid file.
|
||||||
int valid_gamedir_file(const char* path)
|
int valid_gamedir_file(const char* path)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX ];
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int ret, reg, size;
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
if (!path)
|
if (!path)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -32,26 +31,26 @@ int valid_gamedir_file(const char* path)
|
|||||||
buf[sizeof buf - 1] = '\0';
|
buf[sizeof buf - 1] = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
snprintf(buf, sizeof(buf), "%s/%s", GameDLL.gamedir, path);
|
snprintf(buf, sizeof buf, "%s/%s", GameDLL.gamedir, path);
|
||||||
|
|
||||||
ret = stat(buf, &st);
|
int ret = stat(buf, &st);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
META_DEBUG(5, ("Unable to stat '%s': %s", buf, strerror(errno)));
|
META_DEBUG(5, "Unable to stat '%s': %s", buf, strerror(errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg = S_ISREG(st.st_mode);
|
int reg = S_ISREG(st.st_mode);
|
||||||
if (!reg)
|
if (!reg)
|
||||||
{
|
{
|
||||||
META_DEBUG(5, ("Not a regular file: %s", buf));
|
META_DEBUG(5, "Not a regular file: %s", buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = st.st_size;
|
int size = st.st_size;
|
||||||
if (!size)
|
if (!size)
|
||||||
{
|
{
|
||||||
META_DEBUG(5, ("Empty file: %s", buf));
|
META_DEBUG(5, "Empty file: %s", buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ char* full_gamedir_path(const char* path, char* fullpath)
|
|||||||
// Remove relative path components, if possible.
|
// Remove relative path components, if possible.
|
||||||
if (!realpath(buf, fullpath))
|
if (!realpath(buf, fullpath))
|
||||||
{
|
{
|
||||||
META_DEBUG(4, ("Unable to get realpath for '%s': %s", buf, str_os_error()));
|
META_DEBUG(4, "Unable to get realpath for '%s': %s", buf, str_os_error());
|
||||||
Q_strncpy(fullpath, path, sizeof(fullpath) - 1);
|
Q_strncpy(fullpath, path, sizeof(fullpath) - 1);
|
||||||
fullpath[sizeof(fullpath) - 1] = '\0';
|
fullpath[sizeof(fullpath) - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -106,13 +106,10 @@ void normalize_pathname(char *path)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
META_DEBUG(8, ("normalize: %s", path));
|
|
||||||
for (cp = path; *cp; cp++) {
|
for (cp = path; *cp; cp++) {
|
||||||
if (isupper(*cp)) *cp = tolower(*cp);
|
if (isupper(*cp)) *cp = tolower(*cp);
|
||||||
if (*cp == '\\') *cp = '/';
|
if (*cp == '\\') *cp = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
META_DEBUG(8, ("normalized: %s", path));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user