diff --git a/OpenRa.Game/PathSearch.cs b/OpenRa.Game/PathSearch.cs index b2a8ec43fc..e4db641604 100755 --- a/OpenRa.Game/PathSearch.cs +++ b/OpenRa.Game/PathSearch.cs @@ -51,11 +51,11 @@ namespace OpenRa continue; var custom = Game.world.customTerrain[newHere.X, newHere.Y]; - if (custom != null - && custom.GetCost(newHere, umt) == float.PositiveInfinity) - continue; - if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity) + var costHere = (custom != null) ? custom.GetCost(newHere, umt) : passableCost[(int)umt][newHere.X, newHere.Y]; + + if (costHere == float.PositiveInfinity) continue; + if (!Game.world.BuildingInfluence.CanMoveHere(newHere) && Game.world.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding) continue; @@ -73,10 +73,7 @@ namespace OpenRa if( est == float.PositiveInfinity ) continue; - float cellCost = ((d.X * d.Y != 0) ? 1.414213563f : 1.0f) * - (custom != null - ? custom.GetCost(newHere, umt) : - passableCost[(int)umt][newHere.X, newHere.Y]); + float cellCost = ((d.X * d.Y != 0) ? 1.414213563f : 1.0f) * costHere; float newCost = cellInfo[ p.Location.X, p.Location.Y ].MinCost + cellCost; if( newCost >= cellInfo[ newHere.X, newHere.Y ].MinCost ) diff --git a/OpenRa.Game/Traits/Bridge.cs b/OpenRa.Game/Traits/Bridge.cs index f00434601e..0ef1ff41f1 100644 --- a/OpenRa.Game/Traits/Bridge.cs +++ b/OpenRa.Game/Traits/Bridge.cs @@ -22,10 +22,8 @@ namespace OpenRa.Traits public Bridge(Actor self) { self.RemoveOnDeath = false; } - static Cache Sprites = - new Cache( - x => SheetBuilder.Add(Game.world.TileSet.GetBytes(x), - new Size(Game.CellSize, Game.CellSize))); + static string cachedTheater; + static Cache sprites; public IEnumerable Render(Actor self) { @@ -42,13 +40,22 @@ namespace OpenRa.Traits foreach (var t in replacedTiles.Keys) Game.world.customTerrain[t.X, t.Y] = this; + if (cachedTheater != Game.world.Map.Theater) + { + cachedTheater = Game.world.Map.Theater; + sprites = new Cache( + x => SheetBuilder.Add(Game.world.TileSet.GetBytes(x), + new Size(Game.CellSize, Game.CellSize))); + } + TileSprites = replacedTiles.ToDictionary( a => a.Key, - a => Sprites[new TileReference { tile = (ushort)template.Index, image = (byte)a.Value }]); + a => sprites[new TileReference { tile = (ushort)template.Index, image = (byte)a.Value }]); } public float GetCost(int2 p, UnitMovementType umt) { + throw new NotImplementedException(); var origTile = Tiles[p]; // if this explodes, then SetTiles did something horribly wrong. return float.PositiveInfinity; }