fix: drones no longer freeze with a load after a slow trip or a fight
Plan() returned early for a delivery and kept the deadline of the job before it, so a delivery that started late timed out on its first tick, was planned again with the same stale deadline, and looped every frame. snakey's log shows 10790 deposit_station timeouts in a row: the drone hung by the kiln with the wood, and a fight mid-trip did the same. Every job now gets a fresh clock. A station that is in the penalty box is not asked again for a delivery; the Alfar drone takes the load back to the chest it came from, so fuel stays in the Eldividarkista. The Butler's servant had the same early return and gets the same fix.
This commit is contained in:
parent
9bd98c68c3
commit
85c7af6d05
2 changed files with 57 additions and 22 deletions
|
|
@ -363,8 +363,22 @@ namespace RacesOfValheim
|
|||
Scan(anchor.Value);
|
||||
ExpirePenalties();
|
||||
|
||||
if (m_payload.Count > 0) { m_job = PlanDelivery(anchor.Value); return; }
|
||||
// A delivery gets its own clock like any other job. Returning early here left it with the
|
||||
// load's deadline: a slow trip, or a fight on the way, made it late before it started, and
|
||||
// it timed out and was planned again on every tick, frozen with the goods in hand.
|
||||
Job job;
|
||||
if (m_payload.Count > 0) job = PlanDelivery(anchor.Value);
|
||||
else job = PlanWork();
|
||||
|
||||
if (job != null && (m_job == null || m_job.Kind != job.Kind || m_job.Target != job.Target))
|
||||
{
|
||||
m_jobDeadline = Time.time + JobTimeout;
|
||||
}
|
||||
m_job = job;
|
||||
}
|
||||
|
||||
private Job PlanWork()
|
||||
{
|
||||
// The forge has no clock: a smelter holds its ore indefinitely and puts its own output on
|
||||
// the floor, so PlanRescue would ask a question whose answer is always no. The smith is a
|
||||
// four-state machine and the cook is a five-state one, and that is the whole of the
|
||||
|
|
@ -376,13 +390,7 @@ namespace RacesOfValheim
|
|||
// in return, because FuelWanted is zero for a station with no work: an empty furnace asks
|
||||
// for no coal, gets filled, and only then becomes worth stoking.
|
||||
Job job = m_family == ButlerFamily.Kitchen ? PlanRescue() : null;
|
||||
job = job ?? PlanCollect() ?? PlanFuel() ?? PlanLoad();
|
||||
|
||||
if (job != null && (m_job == null || m_job.Kind != job.Kind || m_job.Target != job.Target))
|
||||
{
|
||||
m_jobDeadline = Time.time + JobTimeout;
|
||||
}
|
||||
m_job = job;
|
||||
return job ?? PlanCollect() ?? PlanFuel() ?? PlanLoad();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -634,8 +642,10 @@ namespace RacesOfValheim
|
|||
// coal, so gating the delivery on free slots sent the servant back to the chest with
|
||||
// the coal it had just fetched - and then PlanFuel sent it out for the same coal again,
|
||||
// forever. AcceptsAnything already asks the right question of both doors.
|
||||
// A station it could not reach is in the penalty box: asking it again straight away
|
||||
// is the same failed trip.
|
||||
ButlerStation station = StationById(target);
|
||||
if (station != null && station.Alive && station.Operable && AcceptsAnything(station))
|
||||
if (station != null && station.Alive && station.Operable && AcceptsAnything(station) && !IsPenalised(target))
|
||||
{
|
||||
return new Job
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue