Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cell-out-of-bounds crashes in BuildableTerrainLayer. #15924

Merged
merged 1 commit into from Dec 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion OpenRA.Mods.D2k/Traits/World/BuildableTerrainLayer.cs
Expand Up @@ -53,6 +53,9 @@ public void WorldLoaded(World w, WorldRenderer wr)

public void AddTile(CPos cell, TerrainTile tile)
{
if (!strength.Contains(cell))
return;

map.CustomTerrain[cell] = map.Rules.TileSet.GetTerrainIndex(tile);
strength[cell] = info.MaxStrength;

Expand All @@ -63,7 +66,7 @@ public void AddTile(CPos cell, TerrainTile tile)

public void HitTile(CPos cell, int damage)
{
if (strength[cell] == 0)
if (!strength.Contains(cell) || strength[cell] == 0)
return;

strength[cell] = strength[cell] - damage;
Expand All @@ -73,6 +76,9 @@ public void HitTile(CPos cell, int damage)

public void RemoveTile(CPos cell)
{
if (!strength.Contains(cell))
return;

map.CustomTerrain[cell] = byte.MaxValue;
strength[cell] = 0;
dirty[cell] = null;
Expand Down