Need to also track the not deleted to re-add after attempting a DeleteSpawns loop, need to also release the read lock if we continue
This commit is contained in:
parent
40e83f5e2d
commit
93b7620364
@ -1512,18 +1512,27 @@ void ZoneServer::DeleteSpawns(bool delete_all) {
|
||||
spawn_delete_list.clear();
|
||||
MSpawnDeleteList.releasewritelock(__FUNCTION__, __LINE__);
|
||||
|
||||
// Prepare a list of entries we’ll need to keep around
|
||||
std::vector<std::pair<Spawn*,int32>> to_keep;
|
||||
to_keep.reserve(to_process.size());
|
||||
|
||||
MSpawnList.writelock(__FUNCTION__, __LINE__);
|
||||
int32 current_time = Timer::GetCurrentTime2();
|
||||
for (auto &entry : to_process) {
|
||||
Spawn* spawn = entry.first;
|
||||
int32 when = entry.second;
|
||||
|
||||
if (!delete_all && current_time < when)
|
||||
if (!delete_all && current_time < when) {
|
||||
to_keep.emplace_back(entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
MPendingSpawnRemoval.readlock(__FUNCTION__, __LINE__);
|
||||
if(!delete_all && m_pendingSpawnRemove.count(spawn->GetID()))
|
||||
if(!delete_all && m_pendingSpawnRemove.count(spawn->GetID())) {
|
||||
to_keep.emplace_back(entry);
|
||||
MPendingSpawnRemoval.releasereadlock(__FUNCTION__, __LINE__);
|
||||
continue;
|
||||
}
|
||||
MPendingSpawnRemoval.releasereadlock(__FUNCTION__, __LINE__);
|
||||
|
||||
lua_interface->SetLuaUserDataStale(spawn);
|
||||
@ -1565,6 +1574,15 @@ void ZoneServer::DeleteSpawns(bool delete_all) {
|
||||
safe_delete(spawn);
|
||||
}
|
||||
MSpawnList.releasewritelock(__FUNCTION__, __LINE__);
|
||||
|
||||
// Add all the kept entries
|
||||
if (!to_keep.empty()) {
|
||||
MSpawnDeleteList.writelock(__FUNCTION__, __LINE__);
|
||||
for (auto &kv : to_keep) {
|
||||
spawn_delete_list.emplace(kv.first, kv.second);
|
||||
}
|
||||
MSpawnDeleteList.releasewritelock(__FUNCTION__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneServer::AddDamagedSpawn(Spawn* spawn){
|
||||
|
Loading…
x
Reference in New Issue
Block a user