Closed ubergarm closed 4 years ago
I have implemented a patch of one algorithm to fix this. It requires scanning all pawns capable of hauling and checking if a hauling job is already "in-flight" for a similar stack to the same destination stockpile.
At a minimum I want to optimize the existing implementation, as it could become CPU costly as the number of pawns and haulers grows etc...
There may be a better way to perhaps get a list of jobs already pointing at the slotgroup directly instead of scanning for everything explicitly like I'm doing... I'll sleep on it...
How to Recreate Issue
Similar Stack Limit
to 1 and everything else default.This is likely because the stockpile is not "full" until the first pawn drops off their stuff. If the map is small and not much is going on the second pawn will likely be updated and cancel their now unneeded job and drop the carried stack. However, if you are in a bigger game that notification may get delayed and the second pawn will successfully store a duplicate stack.
Proposed Solution
Add an additional check against all outstanding hauling jobs going to that stockpile already around here: https://github.com/ubergarm/RimWorld-KanbanStockpile/blob/master/Source/Patches.cs#L197
I need to research
JobGiver_Haul.cs
andPawn.carryTracker
etc to figure out most efficient way to get this info. May need to iterate over every pawn and check their job / carried item. May be able to get a list of all items currently being hauled to current stockpile too. brainstorming...