1
0
Fork 0

(svn r8110) -Codechange: direct Vehicle::current_order.type changes (to OT_LOADING and OT_LEAVESTATION) replaced by v->BeginLoading() and v->LeaveStation() calls. This should allow easy hooking of those state transitions in order to maintain vehicle loading queue.

release/0.6
KUDr 2007-01-13 18:55:54 +00:00
parent 1f0206f62d
commit 9bfb3f08d9
6 changed files with 25 additions and 12 deletions

View File

@ -1370,7 +1370,7 @@ static void AircraftEntersTerminal(Vehicle *v)
} }
old_order = v->current_order; old_order = v->current_order;
v->current_order.type = OT_LOADING; v->BeginLoading();
v->current_order.flags = 0; v->current_order.flags = 0;
if (old_order.type == OT_GOTO_STATION && if (old_order.type == OT_GOTO_STATION &&

View File

@ -750,8 +750,7 @@ static void HandleRoadVehLoading(Vehicle *v)
} }
b = v->current_order; b = v->current_order;
v->current_order.type = OT_LEAVESTATION; v->LeaveStation();
v->current_order.flags = 0;
if (!(b.flags & OF_NON_STOP)) return; if (!(b.flags & OF_NON_STOP)) return;
break; break;
} }
@ -1508,7 +1507,7 @@ again:
RoadVehArrivesAt(v, st); RoadVehArrivesAt(v, st);
old_order = v->current_order; old_order = v->current_order;
v->current_order.type = OT_LOADING; v->BeginLoading();
v->current_order.flags = 0; v->current_order.flags = 0;
if (old_order.type == OT_GOTO_STATION && if (old_order.type == OT_GOTO_STATION &&

View File

@ -292,8 +292,7 @@ static void HandleShipLoading(Vehicle *v)
{ {
Order b = v->current_order; Order b = v->current_order;
v->current_order.type = OT_LEAVESTATION; v->LeaveStation();
v->current_order.flags = 0;
if (!(b.flags & OF_NON_STOP)) return; if (!(b.flags & OF_NON_STOP)) return;
} }
} }
@ -704,7 +703,7 @@ static void ShipController(Vehicle *v)
/* Process station in the orderlist. */ /* Process station in the orderlist. */
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->current_order.type = OT_LOADING; v->BeginLoading();
v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER; v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
v->current_order.flags |= OF_NON_STOP; v->current_order.flags |= OF_NON_STOP;
ShipArrivesAt(v, st); ShipArrivesAt(v, st);
@ -717,7 +716,6 @@ static void ShipController(Vehicle *v)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
} else { /* leave stations without docks right aways */ } else { /* leave stations without docks right aways */
v->current_order.type = OT_LEAVESTATION; v->current_order.type = OT_LEAVESTATION;
v->current_order.flags = 0;
v->cur_order_index++; v->cur_order_index++;
InvalidateVehicleOrder(v); InvalidateVehicleOrder(v);
} }

View File

@ -2647,8 +2647,7 @@ static void HandleTrainLoading(Vehicle *v, bool mode)
{ {
Order b = v->current_order; Order b = v->current_order;
v->current_order.type = OT_LEAVESTATION; v->LeaveStation();
v->current_order.flags = 0;
// If this was not the final order, don't remove it from the list. // If this was not the final order, don't remove it from the list.
if (!(b.flags & OF_NON_STOP)) return; if (!(b.flags & OF_NON_STOP)) return;
@ -2721,12 +2720,12 @@ static void TrainEnterStation(Vehicle *v, StationID station)
v->current_order.dest == station) { v->current_order.dest == station) {
// Yeah, keep the load/unload flags // Yeah, keep the load/unload flags
// Non Stop now means if the order should be increased. // Non Stop now means if the order should be increased.
v->current_order.type = OT_LOADING; v->BeginLoading();
v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER; v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
v->current_order.flags |= OF_NON_STOP; v->current_order.flags |= OF_NON_STOP;
} else { } else {
// No, just do a simple load // No, just do a simple load
v->current_order.type = OT_LOADING; v->BeginLoading();
v->current_order.flags = 0; v->current_order.flags = 0;
} }
v->current_order.dest = 0; v->current_order.dest = 0;

View File

@ -3227,3 +3227,17 @@ static void Load_VEHS(void)
extern const ChunkHandler _veh_chunk_handlers[] = { extern const ChunkHandler _veh_chunk_handlers[] = {
{ 'VEHS', Save_VEHS, Load_VEHS, CH_SPARSE_ARRAY | CH_LAST}, { 'VEHS', Save_VEHS, Load_VEHS, CH_SPARSE_ARRAY | CH_LAST},
}; };
void Vehicle::BeginLoading()
{
assert(IsTileType(tile, MP_STATION) || type == VEH_Ship);
current_order.type = OT_LOADING;
}
void Vehicle::LeaveStation()
{
assert(IsTileType(tile, MP_STATION) || type == VEH_Ship);
assert(current_order.type == OT_LOADING);
current_order.type = OT_LEAVESTATION;
current_order.flags = 0;
}

View File

@ -251,6 +251,9 @@ struct Vehicle {
VehicleDisaster disaster; VehicleDisaster disaster;
VehicleShip ship; VehicleShip ship;
} u; } u;
void BeginLoading();
void LeaveStation();
}; };
#define is_custom_sprite(x) (x >= 0xFD) #define is_custom_sprite(x) (x >= 0xFD)