Core/Players: Fixed CharacterCache by-name storage holding data for deleted characters

Port From (https://github.com/TrinityCore/TrinityCore/commit/d03e0d69353852636e12911a7f7149cb0bca40ef)
This commit is contained in:
hondacrx
2024-02-06 16:05:00 -05:00
parent 3ec159ebe1
commit 1fc1153f67
2 changed files with 12 additions and 7 deletions
+9 -4
View File
@@ -51,6 +51,7 @@ namespace Game.Cache
data.IsDeleted = isDeleted;
// Fill Name to Guid Store
if (!isDeleted)
_characterCacheByNameStore[name] = data;
_characterCacheStore[guid] = data;
}
@@ -125,14 +126,18 @@ namespace Game.Cache
_characterCacheStore[guid].ArenaTeamId[slot] = arenaTeamId;
}
public void UpdateCharacterInfoDeleted(ObjectGuid guid, bool deleted, string name = null)
public void UpdateCharacterInfoDeleted(ObjectGuid guid, bool deleted, string name)
{
if (!_characterCacheStore.ContainsKey(guid))
if (!_characterCacheStore.TryGetValue(guid, out var cacheEntry))
return;
_characterCacheStore[guid].IsDeleted = deleted;
if (!name.IsEmpty())
if (deleted)
_characterCacheByNameStore.Remove(cacheEntry.Name);
else
_characterCacheByNameStore[name] = cacheEntry;
_characterCacheStore[guid].Name = name;
_characterCacheStore[guid].IsDeleted = deleted;
}
public bool HasCharacterCacheEntry(ObjectGuid guid)
+1 -1
View File
@@ -4521,7 +4521,7 @@ namespace Game.Entities
stmt.AddValue(0, guid);
trans.Append(stmt);
Global.CharacterCacheStorage.UpdateCharacterInfoDeleted(playerGuid, true);
Global.CharacterCacheStorage.UpdateCharacterInfoDeleted(playerGuid, true, "");
break;
}
default: