From 90aeb38427c28f19400c86c3c245ab955ec8b09f Mon Sep 17 00:00:00 2001 From: Gustas Date: Sun, 20 Aug 2023 23:13:17 +0300 Subject: [PATCH] Fix potential crash if attempted to unload outside of the map --- OpenRA.Mods.Common/Traits/Cargo.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index 1044df878d..fc975eeb40 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -241,9 +241,10 @@ namespace OpenRA.Mods.Common.Traits if (checkTerrainType) { - var terrainType = self.World.Map.GetTerrainInfo(self.Location).Type; + if (!self.World.Map.Contains(self.Location)) + return false; - if (!Info.UnloadTerrainTypes.Contains(terrainType)) + if (!Info.UnloadTerrainTypes.Contains(self.World.Map.GetTerrainInfo(self.Location).Type)) return false; } @@ -409,6 +410,7 @@ namespace OpenRA.Mods.Common.Traits void INotifyKilled.Killed(Actor self, AttackInfo e) { + // IsAtGroundLevel contains Map.Contains(self.Location) check. if (Info.EjectOnDeath && self.IsAtGroundLevel() && (!checkTerrainType || Info.UnloadTerrainTypes.Contains(self.World.Map.GetTerrainInfo(self.Location).Type))) { while (!IsEmpty())