Adjust code style and fix unloading in NetVar scanner.
Signed-off-by: aixxe <me@aixxe.net>
This commit is contained in:
parent
ac03e2ead1
commit
d3ed74068a
|
@ -2,6 +2,11 @@
|
|||
|
||||
#include <unordered_map>
|
||||
|
||||
typedef std::unordered_map<const char*, uintptr_t> PropertyCache;
|
||||
typedef std::unordered_map<const char*, PropertyCache> ClassCache;
|
||||
|
||||
static ClassCache class_cache;
|
||||
|
||||
class NetVars {
|
||||
private:
|
||||
static uintptr_t FindOffset(RecvTable* recv_table, const char* property_name, RecvProp** property_ptr = nullptr) {
|
||||
|
@ -31,25 +36,21 @@ class NetVars {
|
|||
}
|
||||
public:
|
||||
static uintptr_t GetOffset(const char* class_name, const char* property_name, RecvProp** property_ptr = nullptr) {
|
||||
typedef std::unordered_map<const char *, uintptr_t> PropertyCache;
|
||||
typedef std::unordered_map<const char *, PropertyCache> ClassCache;
|
||||
static ClassCache classCache;
|
||||
ClassCache::iterator class_cache_itr = class_cache.find(class_name);
|
||||
|
||||
ClassCache::iterator itrClassCache = classCache.find(class_name);
|
||||
if(itrClassCache != classCache.end())
|
||||
{
|
||||
PropertyCache &propertyCache = itrClassCache->second;
|
||||
PropertyCache::iterator itrPropertyCache = propertyCache.find(property_name);
|
||||
if(itrPropertyCache != propertyCache.end())
|
||||
{
|
||||
return itrPropertyCache->second;
|
||||
if (class_cache_itr != class_cache.end()) {
|
||||
PropertyCache& property_cache = class_cache_itr->second;
|
||||
PropertyCache::iterator property_cache_itr = property_cache.find(property_name);
|
||||
|
||||
if (property_cache_itr != property_cache.end()) {
|
||||
return property_cache_itr->second;
|
||||
}
|
||||
}
|
||||
|
||||
for (ClientClass* class_ptr = clientdll->GetAllClasses(); class_ptr; class_ptr = class_ptr->m_pNext) {
|
||||
if (strcmp(class_ptr->m_pNetworkName, class_name) == 0) {
|
||||
uintptr_t result = FindOffset(class_ptr->m_pRecvTable, property_name, property_ptr);
|
||||
classCache[class_name][property_name] = result;
|
||||
class_cache[class_name][property_name] = result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue