Fixed some gamedata lookups requiring symbols on linux/mac (bug 4832, r=fyren).
This commit is contained in:
parent
a5c4739804
commit
ef082d855c
@ -133,40 +133,57 @@ void CHalfLife2::OnSourceModAllInitialized()
|
|||||||
void CHalfLife2::OnSourceModAllInitialized_Post()
|
void CHalfLife2::OnSourceModAllInitialized_Post()
|
||||||
{
|
{
|
||||||
char *addr = NULL;
|
char *addr = NULL;
|
||||||
#ifdef PLATFORM_WINDOWS
|
|
||||||
int offset;
|
|
||||||
|
|
||||||
/* gEntList and/or g_pEntityList */
|
/*
|
||||||
|
* gEntList and/or g_pEntityList
|
||||||
|
*
|
||||||
|
* First try to lookup pointer directly for platforms with symbols.
|
||||||
|
* If symbols aren't present (Windows or stripped Linux/Mac),
|
||||||
|
* attempt find via LevelShutdown + offset
|
||||||
|
*/
|
||||||
|
if (g_pGameConf->GetMemSig("gEntList", (void **)&addr))
|
||||||
|
{
|
||||||
|
if (!addr)
|
||||||
|
{
|
||||||
|
// Key exists so notify if lookup fails, but try other method.
|
||||||
|
g_Logger.LogError("Failed lookup of gEntList directly - Reverting to lookup via LevelShutdown");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_EntList = reinterpret_cast<void *>(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!g_EntList)
|
||||||
|
{
|
||||||
if (!g_pGameConf->GetMemSig("LevelShutdown", (void **)&addr))
|
if (!g_pGameConf->GetMemSig("LevelShutdown", (void **)&addr))
|
||||||
{
|
{
|
||||||
g_Logger.LogError("Logical Entities not supported by this mod (LevelShutdown) - Reverting to networkable entities only");
|
g_Logger.LogError("Logical Entities not supported by this mod (LevelShutdown) - Reverting to networkable entities only");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
{
|
{
|
||||||
g_Logger.LogError("Failed lookup of LevelShutdown - Reverting to networkable entities only");
|
g_Logger.LogError("Failed lookup of LevelShutdown - Reverting to networkable entities only");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int offset;
|
||||||
if (!g_pGameConf->GetOffset("gEntList", &offset))
|
if (!g_pGameConf->GetOffset("gEntList", &offset))
|
||||||
{
|
{
|
||||||
g_Logger.LogError("Logical Entities not supported by this mod (gEntList) - Reverting to networkable entities only");
|
g_Logger.LogError("Logical Entities not supported by this mod (gEntList) - Reverting to networkable entities only");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_EntList = *reinterpret_cast<void **>(addr + offset);
|
g_EntList = *reinterpret_cast<void **>(addr + offset);
|
||||||
#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE
|
|
||||||
/* gEntList and/or g_pEntityList */
|
|
||||||
if (!g_pGameConf->GetMemSig("gEntList", (void **)&addr))
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Logical Entities not supported by this mod (gEntList) - Reverting to networkable entities only");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!addr)
|
|
||||||
|
if (!g_EntList)
|
||||||
{
|
{
|
||||||
g_Logger.LogError("Failed lookup of gEntList - Reverting to networkable entities only");
|
g_Logger.LogError("Failed lookup of gEntList - Reverting to networkable entities only");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g_EntList = reinterpret_cast<void *>(addr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!g_pGameConf->GetOffset("EntInfo", &entInfoOffset))
|
if (!g_pGameConf->GetOffset("EntInfo", &entInfoOffset))
|
||||||
{
|
{
|
||||||
|
@ -285,26 +285,33 @@ void TempEntityManager::Initialize()
|
|||||||
int offset;
|
int offset;
|
||||||
m_Loaded = false;
|
m_Loaded = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First try to lookup s_pTempEntities directly for platforms with symbols.
|
||||||
|
* If symbols aren't present (Windows or stripped Linux/Mac),
|
||||||
|
* attempt find via CBaseTempEntity ctor + offset
|
||||||
|
*/
|
||||||
|
|
||||||
/* Read our sigs and offsets from the config file */
|
/* Read our sigs and offsets from the config file */
|
||||||
#if defined PLATFORM_WINDOWS
|
if (g_pGameConf->GetMemSig("s_pTempEntities", &addr) && addr)
|
||||||
if (!g_pGameConf->GetMemSig("CBaseTempEntity", &addr) || !addr)
|
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
|
/* Store the head of the TE linked list */
|
||||||
|
m_ListHead = *(void **)addr;
|
||||||
}
|
}
|
||||||
|
else if (g_pGameConf->GetMemSig("CBaseTempEntity", &addr) && addr)
|
||||||
|
{
|
||||||
if (!g_pGameConf->GetOffset("s_pTempEntities", &offset))
|
if (!g_pGameConf->GetOffset("s_pTempEntities", &offset))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Store the head of the TE linked list */
|
/* Store the head of the TE linked list */
|
||||||
m_ListHead = **(void ***)((unsigned char *)addr + offset);
|
m_ListHead = **(void ***)((unsigned char *)addr + offset);
|
||||||
#else
|
}
|
||||||
if (!g_pGameConf->GetMemSig("s_pTempEntities", &addr) || !addr)
|
else
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Store the head of the TE linked list */
|
|
||||||
m_ListHead = *(void **)addr;
|
|
||||||
#endif
|
|
||||||
if (!g_pGameConf->GetOffset("GetTEName", &m_NameOffs))
|
if (!g_pGameConf->GetOffset("GetTEName", &m_NameOffs))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -39,29 +39,28 @@ void InitializeValveGlobals()
|
|||||||
{
|
{
|
||||||
g_EntList = gamehelpers->GetGlobalEntityList();
|
g_EntList = gamehelpers->GetGlobalEntityList();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* g_pGameRules
|
||||||
|
*
|
||||||
|
* First try to lookup pointer directly for platforms with symbols.
|
||||||
|
* If symbols aren't present (Windows or stripped Linux/Mac),
|
||||||
|
* attempt find via CreateGameRulesObject + offset
|
||||||
|
*/
|
||||||
|
|
||||||
char *addr;
|
char *addr;
|
||||||
|
if (g_pGameConf->GetMemSig("g_pGameRules", (void **)&addr) && addr)
|
||||||
#ifdef PLATFORM_WINDOWS
|
|
||||||
/* g_pGameRules */
|
|
||||||
if (!g_pGameConf->GetMemSig("CreateGameRulesObject", (void **)&addr) || !addr)
|
|
||||||
{
|
{
|
||||||
return;
|
g_pGameRules = reinterpret_cast<void **>(addr);
|
||||||
}
|
}
|
||||||
|
else if (g_pGameConf->GetMemSig("CreateGameRulesObject", (void **)&addr) && addr)
|
||||||
|
{
|
||||||
int offset;
|
int offset;
|
||||||
if (!g_pGameConf->GetOffset("g_pGameRules", &offset) || !offset)
|
if (!g_pGameConf->GetOffset("g_pGameRules", &offset) || !offset)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g_pGameRules = *reinterpret_cast<void ***>(addr + offset);
|
g_pGameRules = *reinterpret_cast<void ***>(addr + offset);
|
||||||
#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE
|
|
||||||
/* g_pGameRules */
|
|
||||||
if (!g_pGameConf->GetMemSig("g_pGameRules", (void **)&addr) || !addr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
g_pGameRules = reinterpret_cast<void **>(addr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t UTIL_StringToSignature(const char *str, char buffer[], size_t maxlength)
|
size_t UTIL_StringToSignature(const char *str, char buffer[], size_t maxlength)
|
||||||
|
Loading…
Reference in New Issue
Block a user