diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index f3ed92fe07..ae839b54af 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -43,14 +43,14 @@ namespace OpenRa.Game treeCache = new TreeCache(map); foreach( TreeReference treeReference in map.Trees ) - world.Add( new Actor( treeReference, treeCache, map.Offset ) ); - - pathFinder = new PathFinder(map, terrain.tileSet); - - network = new Network(); + world.Add( new Actor( treeReference, treeCache, map.Offset ) ); LocalPlayerBuildings = new BuildingInfluenceMap(world, LocalPlayer); + pathFinder = new PathFinder(map, terrain.tileSet, LocalPlayerBuildings); + + network = new Network(); + controller = new Controller(this); // CAREFUL THERES AN UGLY HIDDEN DEPENDENCY HERE STILL worldRenderer = new WorldRenderer(renderer, this); } diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs index abe8a81b2c..ae00256998 100644 --- a/OpenRa.Game/PathFinder.cs +++ b/OpenRa.Game/PathFinder.cs @@ -9,10 +9,12 @@ namespace OpenRa.Game { double[ , ] passableCost = new double[ 128, 128 ]; Map map; + BuildingInfluenceMap bim; - public PathFinder(Map map, TileSet tileSet) + public PathFinder(Map map, TileSet tileSet, BuildingInfluenceMap bim) { this.map = map; + this.bim = bim; for( int x = 0 ; x < 128 ; x++ ) for( int y = 0 ; y < 128 ; y++ ) @@ -59,6 +61,8 @@ namespace OpenRa.Game continue; if( passableCost[ newHere.X, newHere.Y ] == double.PositiveInfinity ) continue; + if (bim[newHere - offset] != null) + continue; double cellCost = ( ( d.X * d.Y != 0 ) ? 1.414213563 : 1.0 ) * passableCost[ newHere.X, newHere.Y ]; double newCost = cellInfo[ here.X, here.Y ].MinCost + cellCost;