Untitled
unknown
plain_text
5 months ago
2.8 kB
3
Indexable
void CClientManager::PutGrowthPetCache(TGrowthPet* pNew, bool bSkipQuery) { CGrowthPetCache* c; c = GetGrowthPetCache(pNew->dwID); if (pNew->bState == STATE_SAFEBOX) { // Cache was not found, lets create a new one and immidiately flush it if (!c) { std::unique_ptr<CGrowthPetCache> tempCache = std::make_unique<CGrowthPetCache>(); tempCache->Put(pNew); tempCache->OnFlush(); return; } // Cache was found, remove it from owner's cache set auto it = m_map_pkGrowthPetCacheSetPtr.find(c->Get()->dwOwner); if (it != m_map_pkGrowthPetCacheSetPtr.end()) { if (g_log) sys_log(0, "GROWTH_PET_CACHE: delete owner %u id %u new owner %u", c->Get()->dwOwner, c->Get()->dwID, pNew->dwOwner); it->second->erase(c); } // Flush and remove it from global map as well c->Put(pNew); c->OnFlush(); m_map_growthPetCache.erase(pNew->dwID); } else { if (!c) { if (g_log) sys_log(0, "GROWTH_PET_CACHE: PutGrowthPetCache ==> New CGrowthPetCache id%d vnum%d new owner%d", pNew->dwID, pNew->dwVnum, pNew->dwOwner); c = new CGrowthPetCache; m_map_growthPetCache.insert(TGrowthPetCacheMap::value_type(pNew->dwID, c)); } else { if (g_log) sys_log(0, "GROWTH_PET_CACHE: PutGrowthPetCache ==> Have Cache"); if (pNew->dwOwner != c->Get()->dwOwner) { auto it = m_map_pkGrowthPetCacheSetPtr.find(c->Get()->dwOwner); if (it != m_map_pkGrowthPetCacheSetPtr.end()) { if (g_log) sys_log(0, "GROWTH_PET_CACHE: delete owner %u id %u new owner %u", c->Get()->dwOwner, c->Get()->dwID, pNew->dwOwner); it->second->erase(c); } } } c->Put(pNew, bSkipQuery); auto it = m_map_pkGrowthPetCacheSetPtr.find(c->Get()->dwOwner); if (it != m_map_pkGrowthPetCacheSetPtr.end()) { if (g_log) sys_log(0, "GROWTH_PET_CACHE: save %u id %u", c->Get()->dwOwner, c->Get()->dwID); else sys_log(1, "GROWTH_PET_CACHE: save %u id %u", c->Get()->dwOwner, c->Get()->dwID); it->second->insert(c); } else { if (g_log) sys_log(0, "GROWTH_PET_CACHE: direct save %u id %u", c->Get()->dwOwner, c->Get()->dwID); else sys_log(1, "GROWTH_PET_CACHE: direct save %u id %u", c->Get()->dwOwner, c->Get()->dwID); c->OnFlush(); } } }
Editor is loading...
Leave a Comment