Issue description
What I have is :
A Logistic Zone called Island Connections.
In there a MineTower which allowes dumping of rock, slag and dirt.
What I see is trucks from the default zone dumping rock into the dumping area of that minetower.
I expected that only trucks from the Island Connections zone to be dumping there.
Edit : I know my code analyses below is wrong, the symptons of wrong zone behavior is as reported.
As my save is using mods, I tried to investigate the root cause.
I made a Harmony Patch which checks when Dumping jobs are intanciated.
[HarmonyPostfix]
[HarmonyPatch(typeof(BalancingJobSpec), MethodType.Constructor,
new Type[] { typeof(Truck),
typeof(TerrainDesignation),
typeof(Lyst<TerrainDesignation>),
typeof(RegisteredOutputBuffer),
typeof(ProductQuantity)
})]
static void pf1(BalancingJobSpec __instance)
{
string az = __instance.Truck.AssignedZone.HasValue ? __instance.Truck.AssignedZone.Value.Name.ToString() : "Default";
string dt;
if (!__instance.DumpDesignation.Value.m_tower.HasValue)
{
dt = "No Tower";
}
else
{
if (!(__instance.DumpDesignation.Value.m_tower.Value is MineTower mt))
{
dt = "No MineTower";
}
else
{
dt = $"twr {mt.Id.ToString()} " + printZoneMask(" ", mt.ZoneMask);
LogWrite.Info($"BJ " + printZoneMask("opb", __instance.OutputBuffer.Value.ZoneMask) +
printZoneMask(" trc", __instance.Truck.ZoneMask) + " " + dt + " " + __instance.ProductQuantity.ToString() + __instance.OutputBuffer.Value.Entity.GetType().Name);
}
}
}
From that I see that there are DumpingJobs, which include MineTowers that have different ZoneMasks than the OutputBuffer.
I 12:38:48,076 S9992588 ~Sim: VehicleJobMod : ===> 134 296576 BJ opb zm 2 IslandC trc zm 2 IslandC twr 41038 zm 4 LeftExt 180 of Product_Rock (loose)OreSortingPlant
From that I came to : in
BalancingJobSpec? balanceBuffersForProduct(
VehicleBuffersRegistry.RegisteredBuffers buffers,
out bool hadEligibleTruck)
foreach (VehicleBuffersRegistry.TruckData truckData in this.m_allTrucksPerProductCache)
{
if (((long) zoneMask & (long) truckData.ZoneMask) != 0L && !(outputBuffer.OptimalQuantityOrMaxCached.Min(truckData.Capacity) > outputBuffer.AvailableQuantityCached) && outputBuffer.CanBeServedBy((Vehicle) truckData.Truck, true) && (!truckData.AssignedBuilding.HasValue || truckData.AssignedBuilding.Value == outputBuffer.Entity) && !truckData.UnreachableEntities.Contains((IEntity) outputBuffer.Entity))
{
this.m_terrainDesignationsCache.Clear();
TerrainDesignation bestDesignation;
if (this.m_dumpingManager.Value.TryFindClosestReadyToDump(outputBuffer.Entity.CenterTile.Tile2i, outputBuffer, (Option<LooseProductProto>) dumpableProduct.Value, truckData.Truck, out bestDesignation, this.m_terrainDesignationsCache))
{
Quantity quantity3 = truckData.Capacity.Min(outputBuffer.AvailableQuantityCached);
return new BalancingJobSpec?(new BalancingJobSpec(truckData.Truck, bestDesignation, new Lyst<TerrainDesignation>((IEnumerable<TerrainDesignation>) this.m_terrainDesignationsCache), outputBuffer, new ProductQuantity((ProductProto) dumpableProduct.Value, quantity3)));
}
}
Then in TerrainDumpingManager
public bool TryFindClosestReadyToDump(Tile2i position, Option<LooseProductProto> product, Truck servicingVehicle, ulong? zoneMask, out TerrainDesignation bestDesignation, IIndexable<MineTower> towersToEnforce = null, bool tryIgnoreReservations = false, Lyst<TerrainDesignation> additionalNearbyDesignations = null)
Which includes
IndexableEnumerator<MineTower> enumerator3 = m_towersManager.Towers.GetEnumerator();
while (enumerator3.MoveNext())
{
MineTower current3 = enumerator3.Current;
if (current3.IsEnabled && (current3.AllowNonAssignedOutput || !current3.HasOutputStorageOrTowerAssigned) && doesTowerAllowDumpOfAll(current3, m_cargoCache))
{
m_towersThatCanDumpTmp.Add(current3);
}
}
That doesn't check for the returned MineTower having the correct ZoneMask.
Maybe I am completely on the wrong track, then sorry for the wrong analysis.
Reproduction steps
Use output buffer ouside Logistic zone.
Game version and build number
v0.79 b495
Operating system
Windows
Attachments
I can supply a save together with the very limited mods needed to run.

