Mercurial > hg > openttd
changeset 5651:28d6c9f90f62 draft
(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.
author | KUDr <KUDr@openttd.org> |
---|---|
date | Sat, 13 Jan 2007 18:55:54 +0000 |
parents | fcb1e4785a04 |
children | ce642f6d3e06 |
files | src/aircraft_cmd.cpp src/roadveh_cmd.cpp src/ship_cmd.cpp src/train_cmd.cpp src/vehicle.cpp src/vehicle.h |
diffstat | 6 files changed, 25 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1370,7 +1370,7 @@ } old_order = v->current_order; - v->current_order.type = OT_LOADING; + v->BeginLoading(); v->current_order.flags = 0; if (old_order.type == OT_GOTO_STATION &&
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -750,8 +750,7 @@ } b = v->current_order; - v->current_order.type = OT_LEAVESTATION; - v->current_order.flags = 0; + v->LeaveStation(); if (!(b.flags & OF_NON_STOP)) return; break; } @@ -1508,7 +1507,7 @@ RoadVehArrivesAt(v, st); old_order = v->current_order; - v->current_order.type = OT_LOADING; + v->BeginLoading(); v->current_order.flags = 0; if (old_order.type == OT_GOTO_STATION &&
--- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -292,8 +292,7 @@ { Order b = v->current_order; - v->current_order.type = OT_LEAVESTATION; - v->current_order.flags = 0; + v->LeaveStation(); if (!(b.flags & OF_NON_STOP)) return; } } @@ -704,7 +703,7 @@ /* Process station in the orderlist. */ 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 */ - v->current_order.type = OT_LOADING; + v->BeginLoading(); v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER; v->current_order.flags |= OF_NON_STOP; ShipArrivesAt(v, st); @@ -717,7 +716,6 @@ InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); } else { /* leave stations without docks right aways */ v->current_order.type = OT_LEAVESTATION; - v->current_order.flags = 0; v->cur_order_index++; InvalidateVehicleOrder(v); }
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2647,8 +2647,7 @@ { Order b = v->current_order; - v->current_order.type = OT_LEAVESTATION; - v->current_order.flags = 0; + v->LeaveStation(); // If this was not the final order, don't remove it from the list. if (!(b.flags & OF_NON_STOP)) return; @@ -2721,12 +2720,12 @@ v->current_order.dest == station) { // Yeah, keep the load/unload flags // 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_NON_STOP; } else { // No, just do a simple load - v->current_order.type = OT_LOADING; + v->BeginLoading(); v->current_order.flags = 0; } v->current_order.dest = 0;
--- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -3227,3 +3227,17 @@ extern const ChunkHandler _veh_chunk_handlers[] = { { '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; +}