|
@@ -1420,25 +1420,25 @@ void VehiclePayment(Vehicle *front_v)
|
|
|
if (!v->cargo.UnpaidCargo()) {
|
|
|
SETBIT(v->vehicle_flags, VF_CARGO_UNLOADING);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
GoodsEntry *ge = &st->goods[v->cargo_type];
|
|
|
const CargoList::List *cargos = v->cargo.Packets();
|
|
|
|
|
|
for (CargoList::List::const_iterator it = cargos->begin(); it != cargos->end(); it++) {
|
|
|
CargoPacket *cp = *it;
|
|
|
if (!cp->paid_for &&
|
|
|
cp->source != last_visited &&
|
|
|
ge->acceptance &&
|
|
|
HASBIT(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) &&
|
|
|
(front_v->current_order.flags & OF_TRANSFER) == 0) {
|
|
|
/* Deliver goods to the station */
|
|
|
st->time_since_unload = 0;
|
|
|
|
|
|
/* handle end of route payment */
|
|
|
Money profit = DeliverGoods(cp->count, v->cargo_type, cp->source, last_visited, cp->source_xy, cp->days_in_transit);
|
|
|
cp->paid_for = true;
|
|
|
route_profit += profit; // display amount paid for final route delivery, A-D of a chain A-B-C-D
|
|
|
vehicle_profit += profit - cp->feeder_share; // whole vehicle is not payed for transfers picked up earlier
|
|
|
|
|
|
result |= 1;
|
|
|
|
|
@@ -1536,31 +1536,32 @@ static void LoadUnloadVehicle(Vehicle *v
|
|
|
if (_patches.gradual_loading && HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_LOAD_AMOUNT)) {
|
|
|
uint16 cb_load_amount = GetVehicleCallback(CBID_VEHICLE_LOAD_AMOUNT, 0, 0, v->engine_type, v);
|
|
|
if (cb_load_amount != CALLBACK_FAILED) load_amount = cb_load_amount & 0xFF;
|
|
|
}
|
|
|
|
|
|
GoodsEntry *ge = &st->goods[v->cargo_type];
|
|
|
|
|
|
if (HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING)) {
|
|
|
uint cargo_count = v->cargo.Count();
|
|
|
uint amount_unloaded = _patches.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
|
|
|
bool remaining; // Are there cargo entities in this vehicle that can still be unloaded here?
|
|
|
|
|
|
if (ge->acceptance && !(u->current_order.flags & OF_TRANSFER)) {
|
|
|
if (HASBIT(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && !(u->current_order.flags & OF_TRANSFER)) {
|
|
|
/* The cargo has reached it's final destination, the packets may now be destroyed */
|
|
|
remaining = v->cargo.MoveTo(NULL, amount_unloaded, CargoList::MTA_FINAL_DELIVERY, last_visited);
|
|
|
|
|
|
result |= 1;
|
|
|
} else if (u->current_order.flags & (OF_UNLOAD | OF_TRANSFER)) {
|
|
|
remaining = v->cargo.MoveTo(&ge->cargo, amount_unloaded);
|
|
|
SETBIT(ge->acceptance_pickup, GoodsEntry::PICKUP);
|
|
|
|
|
|
result |= 2;
|
|
|
} else {
|
|
|
/* The order changed while unloading (unset unload/transfer) or the
|
|
|
* station does not accept goods anymore. */
|
|
|
CLRBIT(v->vehicle_flags, VF_CARGO_UNLOADING);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
/* Deliver goods to the station */
|
|
|
st->time_since_unload = 0;
|
|
|
|
|
@@ -1619,28 +1620,30 @@ static void LoadUnloadVehicle(Vehicle *v
|
|
|
/* TODO: Regarding this, when we do gradual loading, we
|
|
|
* should first unload all vehicles and then start
|
|
|
* loading them. Since this will cause
|
|
|
* VEHICLE_TRIGGER_EMPTY to be called at the time when
|
|
|
* the whole vehicle chain is really totally empty, the
|
|
|
* completely_empty assignment can then be safely
|
|
|
* removed; that's how TTDPatch behaves too. --pasky */
|
|
|
completely_empty = false;
|
|
|
anything_loaded = true;
|
|
|
|
|
|
ge->cargo.MoveTo(&v->cargo, cap, CargoList::MTA_CARGO_LOAD, st->xy);
|
|
|
|
|
|
unloading_time += cap;
|
|
|
SETBIT(ge->acceptance_pickup, GoodsEntry::PICKUP);
|
|
|
st->time_since_load = 0;
|
|
|
st->last_vehicle_type = v->type;
|
|
|
|
|
|
unloading_time += cap;
|
|
|
|
|
|
result |= 2;
|
|
|
}
|
|
|
|
|
|
if (v->cargo.Count() == v->cargo_cap) {
|
|
|
SETBIT(cargo_full, v->cargo_type);
|
|
|
} else {
|
|
|
SETBIT(cargo_not_full, v->cargo_type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* We update these variables here, so gradual loading still fills
|
|
|
* all wagons at the same time instead of using the same 'improved'
|