Skip to content

Commit

Permalink
use new1 .0 reservation # calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
alextd committed Jun 19, 2018
1 parent 530d221 commit 5dd5bab
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Source/Utilities/ReservationUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ public static int ReserveAsMuchAsPossible(this Pawn p, LocalTargetInfo target, J

if (!target.HasThing) return p.Reserve(target, job, maxPawns, stackCount, layer) ? 1 : 0;

int canDo = p.Map.reservationManager.CanReserveStack(p, target.Thing, maxPawns, layer);

Thing thing = target.Thing;
int desired = stackCount == ReservationManager.StackCount_All ? thing.stackCount : stackCount;
for (int tryCount = desired; tryCount > 0; tryCount --)
{
if (p.CanReserve(target, maxPawns, tryCount, layer)
&& p.Reserve(target, job, maxPawns, tryCount, layer))
return tryCount;
}
canDo = Math.Min(canDo, desired);

p.Reserve(target, job, maxPawns, stackCount, layer);

return 0;
return canDo;
}
}
}

0 comments on commit 5dd5bab

Please sign in to comment.