Sanitize resource warheads

- Fix potential crash due to invalid target (no CenterPosition)
- Fix potential crash on multiple ResourceLayers
This commit is contained in:
reaperrr
2020-05-08 12:55:22 +02:00
committed by abcdefg30
parent 2bdefe0e9e
commit 2b3d99fac2
2 changed files with 27 additions and 16 deletions

View File

@@ -24,9 +24,13 @@ namespace OpenRA.Mods.Common.Warheads
// TODO: Allow maximum resource removal to be defined. (Per tile, and in total).
public override void DoImpact(Target target, WarheadArgs args)
{
if (target.Type == TargetType.Invalid)
return;
var firedBy = args.SourceActor;
var pos = target.CenterPosition;
var world = firedBy.World;
var targetTile = world.Map.CellContaining(target.CenterPosition);
var targetTile = world.Map.CellContaining(pos);
var resLayer = world.WorldActor.Trait<ResourceLayer>();
var minRange = (Size.Length > 1 && Size[1] > 0) ? Size[1] : 0;