diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index e6596ac5f7..fd685c4a8a 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -80,6 +80,9 @@ namespace OpenRa.Game if (Owner != Game.LocalPlayer) return null; + if (!Rules.Map.IsInMap(xy.X, xy.Y)) + return null; + var underCursor = Game.UnitInfluence.GetUnitAt( xy ) ?? Game.BuildingInfluence.GetBuildingAt( xy ); return traits.WithInterface() diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index bc99ea7c7d..bae9ae9e39 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -36,7 +36,11 @@ namespace OpenRa.Game public static Player LocalPlayer { get { return players[localPlayerIndex]; } - set { localPlayerIndex = value.Index; } + set + { + localPlayerIndex = value.Index; + viewport.GoToStartLocation(); + } } public static BuildingInfluenceMap BuildingInfluence; public static UnitInfluenceMap UnitInfluence; @@ -313,7 +317,7 @@ namespace OpenRa.Game public static bool CanPlaceBuilding(BuildingInfo building, int2 xy, Actor toIgnore, bool adjust) { return !Footprint.Tiles(building, xy, adjust).Any( - t => Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t, + t => !Rules.Map.IsInMap(t.X, t.Y) || Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t, building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, toIgnore)); } diff --git a/OpenRa.Game/Graphics/Viewport.cs b/OpenRa.Game/Graphics/Viewport.cs index 0f74cb84b1..aac2312273 100644 --- a/OpenRa.Game/Graphics/Viewport.cs +++ b/OpenRa.Game/Graphics/Viewport.cs @@ -84,5 +84,16 @@ namespace OpenRa.Game.Graphics { return (1 / 24.0f) * (new float2(mi.Location.X, mi.Location.Y) + Location); } + + public void GoToStartLocation() + { + var unit = Game.world.Actors + .FirstOrDefault(a => a.Owner == Game.LocalPlayer); + + if (unit == null) + return; + + scrollPosition = unit.CenterLocation - .5f * new float2(Width, Height); + } } } diff --git a/OpenRa.Game/PathSearch.cs b/OpenRa.Game/PathSearch.cs index 77bbec69be..103670d7e9 100755 --- a/OpenRa.Game/PathSearch.cs +++ b/OpenRa.Game/PathSearch.cs @@ -38,13 +38,11 @@ namespace OpenRa.Game { int2 newHere = p.Location + d; + if (!Rules.Map.IsInMap(newHere.X, newHere.Y)) continue; if( cellInfo[ newHere.X, newHere.Y ].Seen ) continue; - if (ignoreTerrain) - { - if (!Rules.Map.IsInMap(newHere.X, newHere.Y)) continue; - } - else + + if (!ignoreTerrain) { if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity) continue; @@ -53,6 +51,7 @@ namespace OpenRa.Game if (Rules.Map.IsOverlaySolid(newHere)) continue; } + if( checkForBlocked && Game.UnitInfluence.GetUnitAt( newHere ) != null ) continue; if (customBlock != null && customBlock(newHere)) @@ -80,16 +79,13 @@ namespace OpenRa.Game public void AddInitialCell( int2 location ) { + if (!Rules.Map.IsInMap(location.X, location.Y)) + return; + cellInfo[ location.X, location.Y ] = new CellInfo( 0, location, false ); queue.Add( new PathDistance( heuristic( location ), location ) ); } - - - - - - public static PathSearch FromPoint( int2 from, int2 target, UnitMovementType umt, bool checkForBlocked ) { var search = new PathSearch { diff --git a/session.ini b/session.ini index afbb66a0ab..6e7bfd0aca 100644 --- a/session.ini +++ b/session.ini @@ -4,13 +4,8 @@ ; and then copy it to all the clients. [UNITS] -s0=Multi1,mcv,600,2580,0,Guard,None -s1=Multi2,mcv,600,2582,0,Guard,None -s2=Multi0,mcv,600,2584,0,Guard,None -s3=Multi1,jeep,150,3736,0,Guard,None -s4=Multi1,3tnk,400,2843,0,Guard,None -s5=Multi1,apc,200,2844,0,Guard,None -s6=Multi1,ca,700,2871,0,Guard,None -s7=Multi1,e1,50,3608,0,Guard,None -s8=Multi1,arty,75,3609,0,Guard,None -s9=Multi1,heli,225,3482,0,Guard,None +s0=Multi0,mcv,600,2580,0,Guard,None +s1=Multi1,mcv,600,10900,0,Guard,None +s2=Multi2,mcv,600,2662,0,Guard,None +s3=Multi3,mcv,600,10980,0,Guard,None +