Merge pull request #12354 from pchote/fix-smudge-out-of-bounds

Add map bounds checks to TerrainSpriteLayer and SmudgeLayer.
This commit is contained in:
reaperrr
2016-11-13 13:08:51 +01:00
committed by GitHub
2 changed files with 10 additions and 0 deletions

View File

@@ -87,6 +87,10 @@ namespace OpenRA.Graphics
else
sprite = emptySprite;
// The vertex buffer does not have geometry for cells outside the map
if (!map.Contains(uv))
return;
var offset = rowStride * uv.V + 6 * uv.U;
Util.FastCreateQuad(vertices, pos, sprite, palette.TextureIndex, offset, sprite.Size);

View File

@@ -139,6 +139,9 @@ namespace OpenRA.Mods.Common.Traits
public void AddSmudge(CPos loc)
{
if (!world.Map.Contains(loc))
return;
if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage)
world.AddFrameEndTask(w => w.Add(new SpriteEffect(world.Map.CenterOfCell(loc), w, Info.SmokeType, Info.SmokeSequence, Info.SmokePalette)));
@@ -167,6 +170,9 @@ namespace OpenRA.Mods.Common.Traits
public void RemoveSmudge(CPos loc)
{
if (!world.Map.Contains(loc))
return;
var tile = dirty.ContainsKey(loc) ? dirty[loc] : new Smudge();
// Setting Sprite to null to indicate a deleted smudge.