summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index e740e26f9..13ec454e0 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -216,6 +216,8 @@ void RoadVehUpdateCache(RoadVehicle *v, bool same_length)
v->gcache.cached_total_length = 0;
+ uint32 cargo_mask = 0;
+
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
/* Check the v->first cache. */
assert(u->First() == v);
@@ -237,12 +239,15 @@ void RoadVehUpdateCache(RoadVehicle *v, bool same_length)
/* Invalidate the vehicle colour map */
u->colourmap = PAL_NONE;
+ /* Update carried cargo. */
+ if (u->cargo_type != INVALID_CARGO && u->cargo_cap > 0) SetBit(cargo_mask, u->cargo_type);
/* Update cargo aging period. */
u->vcache.cached_cargo_age_period = GetVehicleProperty(u, PROP_ROADVEH_CARGO_AGE_PERIOD, EngInfo(u->engine_type)->cargo_age_period);
}
uint max_speed = GetVehicleProperty(v, PROP_ROADVEH_SPEED, 0);
v->vcache.cached_max_speed = (max_speed != 0) ? max_speed * 4 : RoadVehInfo(v->engine_type)->max_speed;
+ v->vcache.cached_cargo_mask = cargo_mask;
}
/**
@@ -1392,9 +1397,8 @@ again:
v->owner == GetTileOwner(v->tile) && !v->current_order.IsType(OT_LEAVESTATION) &&
GetRoadStopType(v->tile) == (v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK)) {
Station *st = Station::GetByTile(v->tile);
- v->last_station_visited = st->index;
RoadVehArrivesAt(v, st);
- v->BeginLoading();
+ v->BeginLoading(st->index);
}
return false;
}
@@ -1453,13 +1457,13 @@ again:
rs->SetEntranceBusy(false);
SetBit(v->state, RVS_ENTERED_STOP);
- v->last_station_visited = st->index;
-
if (IsDriveThroughStopTile(v->tile) || (v->current_order.IsType(OT_GOTO_STATION) && v->current_order.GetDestination() == st->index)) {
RoadVehArrivesAt(v, st);
- v->BeginLoading();
+ v->BeginLoading(st->index);
return false;
}
+
+ v->last_station_visited = st->index;
} else {
/* Vehicle is ready to leave a bay in a road stop */
if (rs->IsEntranceBusy()) {