1.1 --- a/extensions/sdktools/vhelpers.cpp Tue Mar 19 11:24:01 2013 -0400
1.2 +++ b/extensions/sdktools/vhelpers.cpp Tue Mar 19 11:25:04 2013 -0400
1.3 @@ -708,41 +708,56 @@
1.4 return;
1.5 }
1.6
1.7 - ICallWrapper *pWrapper = NULL;
1.8 + static CEntityFactoryDictionary *dict = NULL;
1.9 + if (dict == NULL)
1.10 + {
1.11 + void *addr;
1.12 + if (g_pGameConf->GetMemSig("EntityFactoryFinder", (void **)&addr) && addr)
1.13 + {
1.14 + int offset;
1.15 + if (!g_pGameConf->GetOffset("EntityFactoryOffset", &offset) || !offset)
1.16 + {
1.17 + return;
1.18 + }
1.19 + dict = *reinterpret_cast<CEntityFactoryDictionary **>((intptr_t)addr + offset);
1.20 + }
1.21 + }
1.22
1.23 - if (!pWrapper)
1.24 + if (dict == NULL)
1.25 {
1.26 + ICallWrapper *pWrapper = NULL;
1.27 +
1.28 PassInfo retData;
1.29 retData.flags = PASSFLAG_BYVAL;
1.30 retData.size = sizeof(void *);
1.31 retData.type = PassType_Basic;
1.32
1.33 void *addr;
1.34 - if (!g_pGameConf->GetMemSig("EntityFactory", &addr) || addr == NULL)
1.35 + if (g_pGameConf->GetMemSig("EntityFactory", &addr) && addr != NULL)
1.36 {
1.37 - META_CONPRINT("Failed to locate function\n");
1.38 - return;
1.39 + pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0);
1.40 }
1.41
1.42 - pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0);
1.43 + if (pWrapper)
1.44 + {
1.45 + void *returnData = NULL;
1.46 +
1.47 + pWrapper->Execute(NULL, &returnData);
1.48 +
1.49 + pWrapper->Destroy();
1.50 +
1.51 + if (returnData == NULL)
1.52 + {
1.53 + return;
1.54 + }
1.55 +
1.56 + dict = ( CEntityFactoryDictionary * )returnData;
1.57 + }
1.58 }
1.59
1.60 -
1.61 - void *returnData = NULL;
1.62 -
1.63 - pWrapper->Execute(NULL, &returnData);
1.64 -
1.65 - pWrapper->Destroy();
1.66 -
1.67 - if (returnData == NULL)
1.68 + if ( dict == NULL )
1.69 {
1.70 - return;
1.71 - }
1.72 -
1.73 - CEntityFactoryDictionary *dict = ( CEntityFactoryDictionary * )returnData;
1.74 -
1.75 - if ( !dict )
1.76 - {
1.77 + META_CONPRINT("Failed to locate function\n");
1.78 return;
1.79 }
1.80