Fix: only count distance traveled in vehicles for cargo payment (#11283)

No longer you can utilize the free (and instant) labour of station
workers, transporting your cargo from one part of the station to
the other. No more!

Based on patch by dP.

(cherry picked from commit df400ef84a)
This commit is contained in:
Patric Stout
2023-09-19 22:16:31 +02:00
committed by Jonathan G Rennison
parent 05c35c8e31
commit 4280c413a6
11 changed files with 144 additions and 21 deletions

View File

@@ -120,7 +120,7 @@ bool CargoLoad::operator()(CargoPacket *cp)
{
CargoPacket *cp_new = this->Preprocess(cp);
if (cp_new == nullptr) return false;
cp_new->SetSourceXY(this->current_tile);
cp_new->UpdateLoadingTile(this->current_tile);
this->source->RemoveFromCache(cp_new, cp_new->Count());
this->destination->Append(cp_new, VehicleCargoList::MTA_KEEP);
return cp_new == cp;
@@ -135,7 +135,7 @@ bool CargoReservation::operator()(CargoPacket *cp)
{
CargoPacket *cp_new = this->Preprocess(cp);
if (cp_new == nullptr) return false;
cp_new->SetSourceXY(this->current_tile);
cp_new->UpdateLoadingTile(this->current_tile);
this->source->reserved_count += cp_new->Count();
this->source->RemoveFromCache(cp_new, cp_new->Count());
this->destination->Append(cp_new, VehicleCargoList::MTA_LOAD);
@@ -152,6 +152,7 @@ bool CargoReturn::operator()(CargoPacket *cp)
CargoPacket *cp_new = this->Preprocess(cp);
if (cp_new == nullptr) cp_new = cp;
assert(cp_new->Count() <= this->destination->reserved_count);
cp_new->UpdateUnloadingTile(this->current_tile);
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_LOAD, cp_new->Count());
this->destination->reserved_count -= cp_new->Count();
this->destination->Append(cp_new, this->next);
@@ -167,6 +168,7 @@ bool CargoTransfer::operator()(CargoPacket *cp)
{
CargoPacket *cp_new = this->Preprocess(cp);
if (cp_new == nullptr) return false;
cp_new->UpdateUnloadingTile(this->current_tile);
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_TRANSFER, cp_new->Count());
/* No transfer credits here as they were already granted during Stage(). */
this->destination->Append(cp_new, cp_new->GetNextHop());