Skip to content

Commit a7dd12c

Browse files
authored
Minor cleanup and logic update to delete map events when maps are removed from the db (#1849)
1 parent a86bfe3 commit a7dd12c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Intersect.Server/Database/DbInterface.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,15 @@ public static void DeleteGameObject(IDatabaseObject gameObject)
10491049

10501050
break;
10511051
case GameObjectType.Map:
1052+
//Delete all map events first
1053+
foreach (var evtId in ((MapController)gameObject).EventIds)
1054+
{
1055+
var evt = EventBase.Get(evtId);
1056+
if (evt != null)
1057+
{
1058+
DeleteGameObject(evt);
1059+
}
1060+
}
10521061
context.Maps.Remove((MapController)gameObject);
10531062
MapController.Lookup.Delete(gameObject);
10541063

Intersect.Server/Networking/PacketHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,11 +3349,12 @@ public void HandlePacket(Client client, Network.Packets.Editor.MapListUpdatePack
33493349

33503350
lock (ServerContext.Instance.LogicService.LogicLock)
33513351
{
3352+
var map = MapController.Get(mapId);
33523353
ServerContext.Instance.LogicService.LogicPool.WaitForIdle();
33533354
mapId = packet.TargetId;
3354-
var players = MapController.Get(mapId).GetPlayersOnAllInstances();
3355+
var players = map.GetPlayersOnAllInstances();
33553356
MapList.List.DeleteMap(mapId);
3356-
DbInterface.DeleteGameObject(MapController.Get(mapId));
3357+
DbInterface.DeleteGameObject(map);
33573358
DbInterface.GenerateMapGrids();
33583359
PacketSender.SendMapListToAll();
33593360
foreach (var plyr in players)

0 commit comments

Comments
 (0)