Use Linux game data for offsets and signatures/symbols on OS X if Mac-specific data is not available (bug 6056, r=dvander).
Although unlikely, OS X game data can also be used on Linux if Linux-specfic data is missing.
This commit is contained in:
parent
e95c2ba0b9
commit
ce6b993954
@ -77,10 +77,12 @@ static const char *g_pParseEngine = NULL;
|
|||||||
#define PLATFORM_SERVER_BINARY "server.dll"
|
#define PLATFORM_SERVER_BINARY "server.dll"
|
||||||
#elif defined PLATFORM_LINUX
|
#elif defined PLATFORM_LINUX
|
||||||
#define PLATFORM_NAME "linux"
|
#define PLATFORM_NAME "linux"
|
||||||
|
#define PLATFORM_COMPAT_ALT "mac" /* Alternate platform name if game data is missing for primary one */
|
||||||
#define PLATFORM_SERVER_BINARY "server_i486.so"
|
#define PLATFORM_SERVER_BINARY "server_i486.so"
|
||||||
#elif defined PLATFORM_APPLE
|
#elif defined PLATFORM_APPLE
|
||||||
#define PLATFORM_NAME "mac"
|
#define PLATFORM_NAME "mac"
|
||||||
#define PLATFORM_SERVER_BINARY "server.dylib"
|
#define PLATFORM_COMPAT_ALT "linux"
|
||||||
|
#define PLATFORM_SERVER_BINARY "server.dylib"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct TempSigInfo
|
struct TempSigInfo
|
||||||
@ -116,6 +118,30 @@ static bool DoesEngineMatch(const char *value)
|
|||||||
return strcmp(value, g_pParseEngine) == 0;
|
return strcmp(value, g_pParseEngine) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool DoesPlatformMatch(const char *platform)
|
||||||
|
{
|
||||||
|
return strcmp(platform, PLATFORM_NAME) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool IsPlatformCompatible(const char *platform, bool *hadPrimaryMatch)
|
||||||
|
{
|
||||||
|
if (DoesPlatformMatch(platform))
|
||||||
|
{
|
||||||
|
#if defined PLATFORM_COMPAT_ALT
|
||||||
|
*hadPrimaryMatch = true;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined PLATFORM_COMPAT_ALT
|
||||||
|
/* If entry hasn't been found for the primary platform name, check for compatible alternate */
|
||||||
|
if (!*hadPrimaryMatch)
|
||||||
|
return strcmp(platform, PLATFORM_COMPAT_ALT) == 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
CGameConfig::CGameConfig(const char *file, const char *engine)
|
CGameConfig::CGameConfig(const char *file, const char *engine)
|
||||||
{
|
{
|
||||||
strncopy(m_File, file, sizeof(m_File));
|
strncopy(m_File, file, sizeof(m_File));
|
||||||
@ -228,6 +254,7 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
m_Class[0] = '\0';
|
m_Class[0] = '\0';
|
||||||
strncopy(m_offset, name, sizeof(m_offset));
|
strncopy(m_offset, name, sizeof(m_offset));
|
||||||
m_ParseState = PSTATE_GAMEDEFS_OFFSETS_OFFSET;
|
m_ParseState = PSTATE_GAMEDEFS_OFFSETS_OFFSET;
|
||||||
|
matched_platform = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PSTATE_GAMEDEFS_SIGNATURES:
|
case PSTATE_GAMEDEFS_SIGNATURES:
|
||||||
@ -235,6 +262,7 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
strncopy(m_offset, name, sizeof(m_offset));
|
strncopy(m_offset, name, sizeof(m_offset));
|
||||||
s_TempSig.Reset();
|
s_TempSig.Reset();
|
||||||
m_ParseState = PSTATE_GAMEDEFS_SIGNATURES_SIG;
|
m_ParseState = PSTATE_GAMEDEFS_SIGNATURES_SIG;
|
||||||
|
matched_platform = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PSTATE_GAMEDEFS_CRC:
|
case PSTATE_GAMEDEFS_CRC:
|
||||||
@ -299,7 +327,7 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
}
|
}
|
||||||
case PSTATE_GAMEDEFS_ADDRESSES_ADDRESS:
|
case PSTATE_GAMEDEFS_ADDRESSES_ADDRESS:
|
||||||
{
|
{
|
||||||
if (strcmp(name, PLATFORM_NAME) == 0)
|
if (DoesPlatformMatch(name))
|
||||||
{
|
{
|
||||||
m_ParseState = PSTATE_GAMEDEFS_ADDRESSES_ADDRESS_READ;
|
m_ParseState = PSTATE_GAMEDEFS_ADDRESSES_ADDRESS_READ;
|
||||||
}
|
}
|
||||||
@ -347,7 +375,7 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
|
|||||||
strncopy(m_Class, value, sizeof(m_Class));
|
strncopy(m_Class, value, sizeof(m_Class));
|
||||||
} else if (strcmp(key, "prop") == 0) {
|
} else if (strcmp(key, "prop") == 0) {
|
||||||
strncopy(m_Prop, value, sizeof(m_Prop));
|
strncopy(m_Prop, value, sizeof(m_Prop));
|
||||||
} else if (strcmp(key, PLATFORM_NAME) == 0) {
|
} else if (IsPlatformCompatible(key, &matched_platform)) {
|
||||||
m_Offsets.replace(m_offset, atoi(value));
|
m_Offsets.replace(m_offset, atoi(value));
|
||||||
}
|
}
|
||||||
} else if (m_ParseState == PSTATE_GAMEDEFS_KEYS) {
|
} else if (m_ParseState == PSTATE_GAMEDEFS_KEYS) {
|
||||||
@ -379,14 +407,14 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (m_ParseState == PSTATE_GAMEDEFS_SIGNATURES_SIG) {
|
} else if (m_ParseState == PSTATE_GAMEDEFS_SIGNATURES_SIG) {
|
||||||
if (strcmp(key, PLATFORM_NAME) == 0)
|
if (IsPlatformCompatible(key, &matched_platform))
|
||||||
{
|
{
|
||||||
strncopy(s_TempSig.sig, value, sizeof(s_TempSig.sig));
|
strncopy(s_TempSig.sig, value, sizeof(s_TempSig.sig));
|
||||||
} else if (strcmp(key, "library") == 0) {
|
} else if (strcmp(key, "library") == 0) {
|
||||||
strncopy(s_TempSig.library, value, sizeof(s_TempSig.library));
|
strncopy(s_TempSig.library, value, sizeof(s_TempSig.library));
|
||||||
}
|
}
|
||||||
} else if (m_ParseState == PSTATE_GAMEDEFS_CRC_BINARY) {
|
} else if (m_ParseState == PSTATE_GAMEDEFS_CRC_BINARY) {
|
||||||
if (strcmp(key, PLATFORM_NAME) == 0
|
if (DoesPlatformMatch(key)
|
||||||
&& s_ServerBinCRC_Ok
|
&& s_ServerBinCRC_Ok
|
||||||
&& !bShouldBeReadingDefault)
|
&& !bShouldBeReadingDefault)
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,7 @@ private:
|
|||||||
bool matched_game;
|
bool matched_game;
|
||||||
bool had_engine;
|
bool had_engine;
|
||||||
bool matched_engine;
|
bool matched_engine;
|
||||||
|
bool matched_platform;
|
||||||
|
|
||||||
/* Custom Sections */
|
/* Custom Sections */
|
||||||
unsigned int m_CustomLevel;
|
unsigned int m_CustomLevel;
|
||||||
|
Loading…
Reference in New Issue
Block a user