Skip to content

Commit

Permalink
Minor cleanup and logic update to delete map events when maps are rem…
Browse files Browse the repository at this point in the history
…oved from the db (#1849)
  • Loading branch information
jcsnider authored Aug 24, 2023
1 parent a86bfe3 commit a7dd12c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Intersect.Server/Database/DbInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,15 @@ public static void DeleteGameObject(IDatabaseObject gameObject)

break;
case GameObjectType.Map:
//Delete all map events first
foreach (var evtId in ((MapController)gameObject).EventIds)
{
var evt = EventBase.Get(evtId);
if (evt != null)
{
DeleteGameObject(evt);
}
}
context.Maps.Remove((MapController)gameObject);
MapController.Lookup.Delete(gameObject);

Expand Down
5 changes: 3 additions & 2 deletions Intersect.Server/Networking/PacketHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3349,11 +3349,12 @@ public void HandlePacket(Client client, Network.Packets.Editor.MapListUpdatePack

lock (ServerContext.Instance.LogicService.LogicLock)
{
var map = MapController.Get(mapId);
ServerContext.Instance.LogicService.LogicPool.WaitForIdle();
mapId = packet.TargetId;
var players = MapController.Get(mapId).GetPlayersOnAllInstances();
var players = map.GetPlayersOnAllInstances();
MapList.List.DeleteMap(mapId);
DbInterface.DeleteGameObject(MapController.Get(mapId));
DbInterface.DeleteGameObject(map);
DbInterface.GenerateMapGrids();
PacketSender.SendMapListToAll();
foreach (var plyr in players)
Expand Down

0 comments on commit a7dd12c

Please sign in to comment.