Waypoint reads the ship's own zone first

A leg whose orbit lies in the hauler's zone needs no search of the region (and a galaxy whose entrance Contents a test never set
made the search find no zone, leaving the on-screen hauler idle: TheLegIsTheHold and AHaulerCarriesSiloOreToTheRefinery).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-29 19:28:14 +01:00
commit 5ca76f266a

View file

@ -71,10 +71,11 @@ public static class HaulRun
{
var orbit = Leg(ship, order);
var zone = ship.Zone;
if (zone.Galaxy == null || zone.GalaxyZone == null) return zone.Orbits.ContainsKey(orbit) ? (orbit, null) : ((CultRecordKey, GalaxyZone)?) null;
// The ship's own zone first: the leg's orbit there is the common case and needs no search of the region.
if (zone.Orbits.ContainsKey(orbit)) return (orbit, null);
if (zone.Galaxy == null || zone.GalaxyZone == null) return null;
var target = ZoneOf(zone.Galaxy, orbit);
if (target == null) return null;
if (target == zone.GalaxyZone) return (orbit, null);
if (target == null || target == zone.GalaxyZone) return null;
var path = zone.Galaxy.FindPath(zone.GalaxyZone, target);
return path != null && path.Length > 1 ? (orbit, path[1]) : ((CultRecordKey, GalaxyZone)?) null;
}