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

Game no longer crashes if no ResourceLayer is used. #14088

Merged
merged 1 commit into from Oct 6, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs
Expand Up @@ -230,10 +230,10 @@ public IEnumerable<IRenderable> RenderAboveShroud(WorldRenderer wr, World world)
foreach (var r in previewRenderables)
yield return r;

var res = world.WorldActor.Trait<ResourceLayer>();
var res = world.WorldActor.TraitOrDefault<ResourceLayer>();
var isCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, building, topLeft);
foreach (var t in buildingInfo.Tiles(topLeft))
cells.Add(t, MakeCellType(isCloseEnough && world.IsCellBuildable(t, buildingInfo) && res.GetResource(t) == null));
cells.Add(t, MakeCellType(isCloseEnough && world.IsCellBuildable(t, buildingInfo) && (res == null || res.GetResource(t) == null)));
}

var cellPalette = wr.Palette(placeBuildingInfo.Palette);
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs
Expand Up @@ -43,9 +43,9 @@ public static bool CanPlaceBuilding(this World world, string name, BuildingInfo
if (building.AllowInvalidPlacement)
return true;

var res = world.WorldActor.Trait<ResourceLayer>();
var res = world.WorldActor.TraitOrDefault<ResourceLayer>();
return building.Tiles(topLeft).All(
t => world.Map.Contains(t) && res.GetResource(t) == null &&
t => world.Map.Contains(t) && (res == null || res.GetResource(t) == null) &&
world.IsCellBuildable(t, building, toIgnore));
}

Expand Down