diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs index eab8afde53..e03c6b93db 100644 --- a/OpenRa.Game/PathFinder.cs +++ b/OpenRa.Game/PathFinder.cs @@ -43,18 +43,24 @@ namespace OpenRa.Game public List FindUnitPath( int2 from, int2 target, UnitMovementType umt ) { - using( new PerfSample( "find_unit_path" ) ) - return FindPath( PathSearch.FromPoint( from, target, umt, false ) ); + using (new PerfSample("find_unit_path")) + { + var pb = FindBidiPath( + PathSearch.FromPoint(target, from, umt, false), + PathSearch.FromPoint(from, target, umt, false)); + + return pb; + } } public List FindUnitPathToRange( int2 src, int2 target, UnitMovementType umt, int range ) { using( new PerfSample( "find_unit_path_multiple_src" ) ) { - var tilesInRange = Game.FindTilesInCircle( src, range ) + var tilesInRange = Game.FindTilesInCircle(target, range) .Where( t => Game.IsCellBuildable( t, umt ) ); - var path = FindPath( PathSearch.FromPoints( tilesInRange, target, umt, false )); + var path = FindPath( PathSearch.FromPoints( tilesInRange, src, umt, false )); path.Reverse(); return path; } @@ -124,7 +130,7 @@ namespace OpenRa.Game /* make some progress on the first search */ var p = fromSrc.Expand( passableCost ); - if (fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity) + if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity) return MakeBidiPath(fromSrc, fromDest, p); /* make some progress on the second search */ diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index 6d3418d21d..801e37606f 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -34,25 +34,16 @@ namespace OpenRa.Game public bool TakeCash( int num ) { - if (Cash >= num) - { - Cash -= num; - return true; - } - - return false; - // TODO: decrease cash. - // returns: if enough cash was available, true - //return true; + if (Cash < num) return false; + Cash -= num; + return true; } public void Tick() { foreach( var p in production ) - { if( p.Value != null ) p.Value.Tick( this ); - } } // Key: Production category. Categories are: Building, Infantry, Vehicle, Ship, Plane (and one per super, if they're done in here) diff --git a/OpenRa.Game/UnitOrders.cs b/OpenRa.Game/UnitOrders.cs index fd244856a9..95ea9bdf6b 100755 --- a/OpenRa.Game/UnitOrders.cs +++ b/OpenRa.Game/UnitOrders.cs @@ -96,10 +96,17 @@ namespace OpenRa.Game time = .05f * time; /* temporary hax so we can build stuff fast for test */ - Action complete = null; - if( group != "Building" ) complete = () => Game.world.AddFrameEndTask( _ => Game.BuildUnit( order.Player, order.TargetString ) ); - - order.Player.BeginProduction( group, new ProductionItem( order.TargetString, (int)time, ui.Cost, complete ) ); + order.Player.BeginProduction(group, + new ProductionItem(order.TargetString, (int)time, ui.Cost, + () => Game.world.AddFrameEndTask( + _ => + { + if (order.Player == Game.LocalPlayer) + Game.PlaySound(group == "Building" + ? "conscmp1.aud" : "unitrdy1.aud", false); + if (group != "Building") + Game.BuildUnit(order.Player, order.TargetString); + }))); break; } case "PauseProduction":