mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r9752) -Codechange: remove some duplication related to BeginLoading.
This commit is contained in:
parent
bf04c88eca
commit
6440440f12
|
@ -1509,15 +1509,7 @@ static void AircraftEntersTerminal(Vehicle *v)
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Order old_order = v->current_order;
|
|
||||||
v->BeginLoading();
|
v->BeginLoading();
|
||||||
v->current_order.flags = 0;
|
|
||||||
|
|
||||||
if (old_order.type == OT_GOTO_STATION &&
|
|
||||||
v->current_order.dest == v->last_station_visited) {
|
|
||||||
v->current_order.flags =
|
|
||||||
(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC);
|
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_INC);
|
||||||
LoadUnloadVehicle(v, true);
|
LoadUnloadVehicle(v, true);
|
||||||
|
|
|
@ -1569,7 +1569,6 @@ again:
|
||||||
if (v->current_order.type != OT_LEAVESTATION &&
|
if (v->current_order.type != OT_LEAVESTATION &&
|
||||||
v->current_order.type != OT_GOTO_DEPOT) {
|
v->current_order.type != OT_GOTO_DEPOT) {
|
||||||
/* Vehicle has arrived at a bay in a road stop */
|
/* Vehicle has arrived at a bay in a road stop */
|
||||||
Order old_order;
|
|
||||||
|
|
||||||
if (IsDriveThroughStopTile(v->tile)) {
|
if (IsDriveThroughStopTile(v->tile)) {
|
||||||
TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction));
|
TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction));
|
||||||
|
@ -1600,15 +1599,7 @@ again:
|
||||||
|
|
||||||
RoadVehArrivesAt(v, st);
|
RoadVehArrivesAt(v, st);
|
||||||
|
|
||||||
old_order = v->current_order;
|
|
||||||
v->BeginLoading();
|
v->BeginLoading();
|
||||||
v->current_order.flags = 0;
|
|
||||||
|
|
||||||
if (old_order.type == OT_GOTO_STATION &&
|
|
||||||
v->current_order.dest == v->last_station_visited) {
|
|
||||||
v->current_order.flags =
|
|
||||||
(old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC);
|
SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC);
|
||||||
if (LoadUnloadVehicle(v, true)) {
|
if (LoadUnloadVehicle(v, true)) {
|
||||||
|
|
|
@ -304,7 +304,7 @@ static void HandleShipLoading(Vehicle *v)
|
||||||
{
|
{
|
||||||
switch (v->current_order.type) {
|
switch (v->current_order.type) {
|
||||||
case OT_LOADING: {
|
case OT_LOADING: {
|
||||||
if (--v->load_unload_time_rem) return;
|
if (--v->load_unload_time_rem != 0) return;
|
||||||
|
|
||||||
if (CanFillVehicle(v) && (
|
if (CanFillVehicle(v) && (
|
||||||
v->current_order.flags & OF_FULL_LOAD ||
|
v->current_order.flags & OF_FULL_LOAD ||
|
||||||
|
@ -736,8 +736,6 @@ static void ShipController(Vehicle *v)
|
||||||
st = GetStation(v->current_order.dest);
|
st = GetStation(v->current_order.dest);
|
||||||
if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
|
if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
|
||||||
v->BeginLoading();
|
v->BeginLoading();
|
||||||
v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
|
|
||||||
v->current_order.flags |= OF_NON_STOP;
|
|
||||||
ShipArrivesAt(v, st);
|
ShipArrivesAt(v, st);
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
|
SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
|
||||||
|
|
|
@ -2634,19 +2634,7 @@ static void TrainEnterStation(Vehicle *v, StationID station)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Did we reach the final destination? */
|
|
||||||
if (v->current_order.type == OT_GOTO_STATION &&
|
|
||||||
v->current_order.dest == station) {
|
|
||||||
/* Yeah, keep the load/unload flags
|
|
||||||
* Non Stop now means if the order should be increased. */
|
|
||||||
v->BeginLoading();
|
v->BeginLoading();
|
||||||
v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
|
|
||||||
v->current_order.flags |= OF_NON_STOP;
|
|
||||||
} else {
|
|
||||||
/* No, just do a simple load */
|
|
||||||
v->BeginLoading();
|
|
||||||
v->current_order.flags = 0;
|
|
||||||
}
|
|
||||||
v->current_order.dest = 0;
|
v->current_order.dest = 0;
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
|
SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
|
||||||
|
|
|
@ -2950,6 +2950,24 @@ extern const ChunkHandler _veh_chunk_handlers[] = {
|
||||||
void Vehicle::BeginLoading()
|
void Vehicle::BeginLoading()
|
||||||
{
|
{
|
||||||
assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
|
assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
|
||||||
|
|
||||||
|
if (this->current_order.type == OT_GOTO_STATION &&
|
||||||
|
this->current_order.dest == this->last_station_visited) {
|
||||||
|
/* Arriving at the ordered station.
|
||||||
|
* Keep the load/unload flags, as we (obviously) still need them. */
|
||||||
|
this->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
|
||||||
|
|
||||||
|
/* Furthermore add the Non Stop flag to mark that this station
|
||||||
|
* is the actual destination of the vehicle, which is (for example)
|
||||||
|
* necessary to be known for HandleTrainLoading to determine
|
||||||
|
* whether the train is lost or not; not marking a train lost
|
||||||
|
* that arrives at random stations is bad. */
|
||||||
|
this->current_order.flags |= OF_NON_STOP;
|
||||||
|
} else {
|
||||||
|
/* This is just an unordered intermediate stop */
|
||||||
|
this->current_order.flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
current_order.type = OT_LOADING;
|
current_order.type = OT_LOADING;
|
||||||
GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
|
GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue