Stabilize taxi/state sync and creature spawn handling

This commit is contained in:
Kelsi 2026-02-11 21:14:35 -08:00
parent 38cef8d9c6
commit 40b50454ce
18 changed files with 818 additions and 127 deletions

View file

@ -163,14 +163,23 @@ std::vector<uint8_t> AssetManager::readFile(const std::string& path) const {
fileCacheHits++;
return it->second.data;
}
fileCacheMisses++;
}
// Cache miss - decompress from MPQ.
// Keep MPQ reads serialized, but do not block cache-hit readers on this mutex.
// Cache miss path: serialize MPQ reads. Before reading, re-check cache while holding
// readMutex so only one thread performs decompression per hot path at a time.
std::vector<uint8_t> data;
{
std::lock_guard<std::mutex> readLock(readMutex);
{
std::lock_guard<std::mutex> cacheLock(cacheMutex);
auto it = fileCache.find(normalized);
if (it != fileCache.end()) {
it->second.lastAccessTime = ++fileCacheAccessCounter;
fileCacheHits++;
return it->second.data;
}
fileCacheMisses++;
}
data = mpqManager.readFile(normalized);
}
if (data.empty()) {