From 35cd7eb2be6011bff8b4ace2992def332abde941 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Tue, 19 Mar 2013 11:25:04 -0400 Subject: [PATCH] Add alternative lookup method for EntityFactoryDictionary (bug 5658, r=asherkin). --- extensions/sdktools/vhelpers.cpp | 59 ++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/extensions/sdktools/vhelpers.cpp b/extensions/sdktools/vhelpers.cpp index 39b53642..2956d699 100644 --- a/extensions/sdktools/vhelpers.cpp +++ b/extensions/sdktools/vhelpers.cpp @@ -708,41 +708,56 @@ CON_COMMAND(sm_dump_datamaps, "Dumps the data map list as a text file") return; } - ICallWrapper *pWrapper = NULL; - - if (!pWrapper) + static CEntityFactoryDictionary *dict = NULL; + if (dict == NULL) { + void *addr; + if (g_pGameConf->GetMemSig("EntityFactoryFinder", (void **)&addr) && addr) + { + int offset; + if (!g_pGameConf->GetOffset("EntityFactoryOffset", &offset) || !offset) + { + return; + } + dict = *reinterpret_cast((intptr_t)addr + offset); + } + } + + if (dict == NULL) + { + ICallWrapper *pWrapper = NULL; + PassInfo retData; retData.flags = PASSFLAG_BYVAL; retData.size = sizeof(void *); retData.type = PassType_Basic; void *addr; - if (!g_pGameConf->GetMemSig("EntityFactory", &addr) || addr == NULL) + if (g_pGameConf->GetMemSig("EntityFactory", &addr) && addr != NULL) { - META_CONPRINT("Failed to locate function\n"); - return; + pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0); } - pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0); + if (pWrapper) + { + void *returnData = NULL; + + pWrapper->Execute(NULL, &returnData); + + pWrapper->Destroy(); + + if (returnData == NULL) + { + return; + } + + dict = ( CEntityFactoryDictionary * )returnData; + } } - - void *returnData = NULL; - - pWrapper->Execute(NULL, &returnData); - - pWrapper->Destroy(); - - if (returnData == NULL) - { - return; - } - - CEntityFactoryDictionary *dict = ( CEntityFactoryDictionary * )returnData; - - if ( !dict ) + if ( dict == NULL ) { + META_CONPRINT("Failed to locate function\n"); return; }