mirror of
https://github.com/rehlds/metamod-r.git
synced 2024-12-26 14:45:34 +03:00
Recognize some gamedll Closes #14
Added platform toolset selector for VS2013/VS2015/VS2017 Added lookup gamedll with postfix, е.g _i386.so
This commit is contained in:
parent
0e59dfe7f7
commit
5cf552dc8c
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,9 +8,12 @@
|
||||
**/msvc/*.opensdf
|
||||
**/msvc/*.user
|
||||
**/msvc/*.suo
|
||||
**/msvc/*.db
|
||||
**/msvc/*.opendb
|
||||
**/msvc/*.aps
|
||||
**/msvc/*.pch
|
||||
**/msvc/*.txt
|
||||
**/msvc/.vs
|
||||
**/msvc/start*.bat
|
||||
**/msvc/ipch
|
||||
**/PublishPath*.txt
|
||||
|
@ -14,16 +14,21 @@
|
||||
<ProjectGuid>{02832A39-E902-46B7-8D47-911C37CF41B0}</ProjectGuid>
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@ -110,6 +115,8 @@
|
||||
</CustomBuildStep>
|
||||
<CustomBuildStep>
|
||||
<Message>Force build to run Pre-Build event</Message>
|
||||
<Outputs>build.always.run</Outputs>
|
||||
<Inputs>build.always.run</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@ -182,6 +189,8 @@
|
||||
</CustomBuildStep>
|
||||
<CustomBuildStep>
|
||||
<Message>Force build to run Pre-Build event</Message>
|
||||
<Outputs>build.always.run</Outputs>
|
||||
<Inputs>build.always.run</Inputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
@ -105,8 +105,11 @@ bool MConfig::load(const char* fn)
|
||||
}
|
||||
|
||||
META_DEBUG(2, "Loading from config file: %s", loadfile);
|
||||
for (int ln = 1; !feof(fp) && fgets(line, sizeof line, fp); ln++) {
|
||||
if (line[0] == '#' || line[0] == ';' || !Q_strncmp(line, "//", 2))
|
||||
for (int ln = 1; !feof(fp) && fgets(line, sizeof line, fp); ln++)
|
||||
{
|
||||
trimbuf(line);
|
||||
|
||||
if (line[0] == '\0' || line[0] == '#' || line[0] == ';' || !Q_strncmp(line, "//", 2))
|
||||
continue;
|
||||
|
||||
char* optname = strtok(line, " \t\r\n");
|
||||
|
@ -5,14 +5,24 @@
|
||||
//! To add support for another mod add an entry here, and add all the
|
||||
//! exported entities to link_func.cpp
|
||||
const game_modinfo_t g_known_games[] = {
|
||||
// name/gamedir linux_so win_dll desc
|
||||
// name/gamedir linux_so win_dll desc
|
||||
//
|
||||
// Previously enumerated in this sourcefile, the list is now kept in a
|
||||
// separate file, generated based on game information stored in a
|
||||
// convenient db.
|
||||
{ "valve", "hl.so", "hl.dll", "Half-Life" },
|
||||
{ "bshift", "bshift.so", "hl.dll", "Half-Life: Blue Shift" },
|
||||
{ "ag", "ag.so", "ag.dll", "Adrenaline Gamer" },
|
||||
{ "cstrike", "cs.so", "mp.dll", "Counter-Strike" },
|
||||
{ "czero", "cs.so", "mp.dll", "Counter-Strike:Condition Zero" },
|
||||
{ "czeror", "cz.so", "cz.dll", "Counter-Strike:Condition Zero Deleted Scenes" },
|
||||
{ "ricochet", "ricochet.so", "mp.dll", "Ricochet" },
|
||||
{ "dmc", "dmc.so", "dmc.dll", "Deathmatch Classic" },
|
||||
{ "dod", "dod.so", "dod.dll", "Day of Defeat" },
|
||||
{ "tfc", "tfc.so", "tfc.dll", "Team Fortress Classic" },
|
||||
{ "gearbox", "opfor.so", "opfor.dll", "Opposing Force" },
|
||||
{ "ns", "ns.so", "ns.dll", "Natural Selection" },
|
||||
{ "nsp", "ns.so", "ns.dll", "Natural Selection Beta" },
|
||||
|
||||
// End of list terminator:
|
||||
{ nullptr, nullptr, nullptr, nullptr }
|
||||
@ -30,6 +40,37 @@ static const game_modinfo_t *lookup_game(const char *name)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool lookup_game_postfixes(gamedll_t *gamedll)
|
||||
{
|
||||
char pathname[PATH_MAX];
|
||||
static char postfix_path[PATH_MAX] = "";
|
||||
|
||||
strlcpy(pathname, gamedll->pathname);
|
||||
|
||||
// find extensions and skip
|
||||
char *pos = strrchr(pathname, '.');
|
||||
if (pos) {
|
||||
*pos = '\0';
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < arraysize(g_platform_postfixes); i++)
|
||||
{
|
||||
postfix_path[0] = '\0';
|
||||
strlcat(postfix_path, pathname);
|
||||
strlcat(postfix_path, g_platform_postfixes[i]);
|
||||
|
||||
if (is_file_exists_in_gamedir(postfix_path)) {
|
||||
strlcpy(gamedll->pathname, postfix_path);
|
||||
strlcpy(gamedll->real_pathname, postfix_path);
|
||||
gamedll->file = postfix_path;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Installs gamedll from Steam cache
|
||||
bool install_gamedll(char *from, const char *to)
|
||||
{
|
||||
@ -103,8 +144,7 @@ bool setup_gamedll(gamedll_t *gamedll)
|
||||
|
||||
// Use override-dll if specified.
|
||||
if (g_config->m_gamedll) {
|
||||
Q_strncpy(gamedll->pathname, g_config->m_gamedll, sizeof gamedll->pathname - 1);
|
||||
gamedll->pathname[sizeof gamedll->pathname - 1] = '\0';
|
||||
strlcpy(gamedll->pathname, g_config->m_gamedll);
|
||||
|
||||
// If the path is relative, the gamedll file will be missing and
|
||||
// it might be found in the cache file.
|
||||
@ -115,7 +155,7 @@ bool setup_gamedll(gamedll_t *gamedll)
|
||||
// If we could successfully install the gamedll from the cache we
|
||||
// rectify the pathname to be a full pathname.
|
||||
if (install_gamedll(gamedll->pathname, szInstallPath)) {
|
||||
Q_strncpy(gamedll->pathname, szInstallPath, sizeof(gamedll->pathname));
|
||||
strlcpy(gamedll->pathname, szInstallPath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,8 +185,7 @@ bool setup_gamedll(gamedll_t *gamedll)
|
||||
Q_snprintf(gamedll->real_pathname, sizeof(gamedll->real_pathname), "%s/dlls/%s", gamedll->gamedir, knownfn);
|
||||
}
|
||||
else {
|
||||
Q_strncpy(gamedll->real_pathname, gamedll->pathname, sizeof gamedll->real_pathname - 1);
|
||||
gamedll->real_pathname[sizeof gamedll->real_pathname - 1] = '\0';
|
||||
strlcpy(gamedll->real_pathname, gamedll->pathname);
|
||||
}
|
||||
|
||||
if (override) {
|
||||
@ -157,8 +196,17 @@ bool setup_gamedll(gamedll_t *gamedll)
|
||||
META_LOG("Overriding game '%s' with dllfile '%s'", gamedll->name, gamedll->file);
|
||||
}
|
||||
else if (known) {
|
||||
Q_strncpy(gamedll->desc, known->desc, sizeof gamedll->desc - 1);
|
||||
gamedll->desc[sizeof gamedll->desc - 1] = '\0';
|
||||
strlcpy(gamedll->desc, known->desc);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
if (!is_file_exists_in_gamedir(gamedll->pathname))
|
||||
{
|
||||
// trying lookup gamedll with postfixes ie _i386.so
|
||||
if (lookup_game_postfixes(gamedll)) {
|
||||
META_DEBUG(3, "dll: Trying lookup to gamedll with postfixes was a success. Game '%s'", gamedll->pathname);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
META_LOG("Recognized game '%s'; using dllfile '%s'", gamedll->name, gamedll->file);
|
||||
}
|
||||
|
@ -120,12 +120,6 @@ void metamod_startup()
|
||||
g_config->set("gamedll", cp);
|
||||
}
|
||||
|
||||
cp = LOCALINFO("mm_pluginsfile");
|
||||
if (cp && *cp != '\0') {
|
||||
META_LOG("Pluginsfile specified via localinfo: %s", cp);
|
||||
g_config->set("plugins_file", cp);
|
||||
}
|
||||
|
||||
cp = LOCALINFO("mm_execcfg");
|
||||
if (cp && *cp != '\0') {
|
||||
META_LOG("Execcfg specified via localinfo: %s", cp);
|
||||
|
@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "meta_api.h" // META_RES, etc
|
||||
#include "mlist.h" // MPluginList, etc
|
||||
#include "mreg.h" // MRegCmdList, etc
|
||||
#include "conf_meta.h" // MConfig
|
||||
#include "osdep.h" // NAME_MAX, etc
|
||||
#include "mplayer.h" // MPlayerList
|
||||
#include "engine_t.h" // engine_t, Engine
|
||||
#include "meta_api.h" // META_RES, etc
|
||||
#include "mlist.h" // MPluginList, etc
|
||||
#include "mreg.h" // MRegCmdList, etc
|
||||
#include "conf_meta.h" // MConfig
|
||||
#include "osdep.h" // NAME_MAX, etc
|
||||
#include "mplayer.h" // MPlayerList
|
||||
#include "engine_t.h" // engine_t, Engine
|
||||
|
||||
#define PLUGINS_INI "plugins.ini" // file that lists plugins to load at startup
|
||||
#define EXEC_CFG "exec.cfg" // file that contains commands to metamod plugins at startup
|
||||
#define CONFIG_INI "config.ini" // generic config file
|
||||
#define PLUGINS_INI "plugins.ini" // file that lists plugins to load at startup
|
||||
#define EXEC_CFG "exec.cfg" // file that contains commands to metamod plugins at startup
|
||||
#define CONFIG_INI "config.ini" // generic config file
|
||||
|
||||
// cvar to contain version
|
||||
extern cvar_t g_meta_version;
|
||||
@ -18,14 +18,14 @@ extern cvar_t g_meta_version;
|
||||
// Info about the game dll/mod.
|
||||
struct gamedll_t
|
||||
{
|
||||
char name[NAME_MAX]; // ie "cstrike" (from gamedir)
|
||||
char desc[NAME_MAX]; // ie "Counter-Strike"
|
||||
char gamedir[PATH_MAX]; // ie "/home/willday/half-life/cstrike"
|
||||
char pathname[PATH_MAX]; // ie "/home/willday/half-life/cstrike/dlls/cs_i386.so"
|
||||
char const* file; // ie "cs_i386.so"
|
||||
char real_pathname[PATH_MAX]; // in case pathname overridden by bot, etc
|
||||
char name[NAME_MAX]; // ie "cstrike" (from gamedir)
|
||||
char desc[NAME_MAX]; // ie "Counter-Strike"
|
||||
char gamedir[PATH_MAX]; // ie "/home/willday/half-life/cstrike"
|
||||
char pathname[PATH_MAX]; // ie "/home/willday/half-life/cstrike/dlls/cs_i386.so"
|
||||
char const* file; // ie "cs_i386.so"
|
||||
char real_pathname[PATH_MAX]; // in case pathname overridden by bot, etc
|
||||
CSysModule sys_module;
|
||||
gamedll_funcs_t funcs; // dllapi_table, newapi_table
|
||||
gamedll_funcs_t funcs; // dllapi_table, newapi_table
|
||||
};
|
||||
|
||||
extern gamedll_t g_GameDLL;
|
||||
|
@ -64,6 +64,40 @@ bool is_no(const char* str);
|
||||
|
||||
const char* LOCALINFO(char* key);
|
||||
|
||||
template <size_t N>
|
||||
char *strlcpy(char (&dest)[N], const char *src) {
|
||||
Q_strncpy(dest, src, N - 1);
|
||||
dest[N - 1] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
inline char *strnlcpy(char *dest, const char *src, size_t n) {
|
||||
Q_strncpy(dest, src, n - 1);
|
||||
dest[n - 1] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
size_t strlcat(char (&dest)[N], const char *src)
|
||||
{
|
||||
size_t dstlen = Q_strlen(dest);
|
||||
size_t size = N - dstlen + 1;
|
||||
|
||||
if (!size) {
|
||||
return dstlen;
|
||||
}
|
||||
|
||||
size_t srclen = Q_strlen(src);
|
||||
if (srclen > size) {
|
||||
srclen = size;
|
||||
}
|
||||
|
||||
Q_memcpy(dest + dstlen, src, srclen);
|
||||
dest[dstlen + srclen] = '\0';
|
||||
|
||||
return dstlen + srclen;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
char *mm_strtok_r(char *s, const char *delim, char **ptrptr);
|
||||
char *realpath(const char *file_name, char *resolved_name);
|
||||
|
Loading…
Reference in New Issue
Block a user