diff --git a/src/Utilities/NetVars.h b/src/Utilities/NetVars.h index e91a1c1..4d9c1c1 100644 --- a/src/Utilities/NetVars.h +++ b/src/Utilities/NetVars.h @@ -2,6 +2,11 @@ #include +typedef std::unordered_map PropertyCache; +typedef std::unordered_map 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 PropertyCache; - typedef std::unordered_map ClassCache; - static ClassCache classCache; - - 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; - } - } + ClassCache::iterator class_cache_itr = class_cache.find(class_name); + + 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; } }