summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp56
-rw-r--r--src/saveload/vehicle_sl.cpp24
2 files changed, 32 insertions, 48 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index a298108aa..c4f9b9c81 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -921,16 +921,14 @@ bool AfterLoadGame()
/* Elrails got added in rev 24 */
if (CheckSavegameVersion(24)) {
- Vehicle *v;
RailType min_rail = RAILTYPE_ELECTRIC;
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_TRAIN) {
- RailType rt = RailVehInfo(v->engine_type)->railtype;
+ Train *v;
+ FOR_ALL_TRAINS(v) {
+ RailType rt = RailVehInfo(v->engine_type)->railtype;
- ((Train *)v)->railtype = rt;
- if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL;
- }
+ v->railtype = rt;
+ if (rt == RAILTYPE_ELECTRIC) min_rail = RAILTYPE_RAIL;
}
/* .. so we convert the entire map from normal to elrail (so maintain "fairness") */
@@ -963,8 +961,8 @@ bool AfterLoadGame()
}
}
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) TrainConsistChanged((Train *)v, true);
+ FOR_ALL_TRAINS(v) {
+ if (IsFrontEngine(v) || IsFreeWagon(v)) TrainConsistChanged(v, true);
}
}
@@ -1046,20 +1044,15 @@ bool AfterLoadGame()
}
if (CheckSavegameVersion(25)) {
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_ROAD) {
- RoadVehicle *rv = (RoadVehicle *)v;
- rv->vehstatus &= ~0x40;
- rv->slot = NULL;
- rv->slot_age = 0;
- }
+ RoadVehicle *rv;
+ FOR_ALL_ROADVEHICLES(rv) {
+ rv->vehstatus &= ~0x40;
+ rv->slot = NULL;
+ rv->slot_age = 0;
}
} else {
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
- if (v->type != VEH_ROAD) continue;
- RoadVehicle *rv = (RoadVehicle *)v;
+ RoadVehicle *rv;
+ FOR_ALL_ROADVEHICLES(rv) {
if (rv->slot != NULL) rv->slot->num_vehicles++;
}
}
@@ -1382,10 +1375,8 @@ bool AfterLoadGame()
if (CheckSavegameVersion(69)) {
/* In some old savegames a bit was cleared when it should not be cleared */
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
- if (v->type != VEH_ROAD) continue;
- RoadVehicle *rv = (RoadVehicle *)v;
+ RoadVehicle *rv;
+ FOR_ALL_ROADVEHICLES(rv) {
if (rv->state == 250 || rv->state == 251) {
SetBit(rv->state, RVS_IS_STOPPING);
}
@@ -1708,15 +1699,12 @@ bool AfterLoadGame()
/* Reserve all tracks trains are currently on. */
if (CheckSavegameVersion(101)) {
- Vehicle *u;
- FOR_ALL_VEHICLES(u) {
- if (u->type == VEH_TRAIN) {
- Train *v = (Train *)u;
- if ((v->track & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) {
- TryReserveRailTrack(v->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(v->tile)));
- } else if ((v->track & TRACK_BIT_MASK) != TRACK_BIT_NONE) {
- TryReserveRailTrack(v->tile, TrackBitsToTrack(v->track));
- }
+ Train *t;
+ FOR_ALL_TRAINS(t) {
+ if ((t->track & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) {
+ TryReserveRailTrack(t->tile, DiagDirToDiagTrack(GetTunnelBridgeDirection(t->tile)));
+ } else if ((t->track & TRACK_BIT_MASK) != TRACK_BIT_NONE) {
+ TryReserveRailTrack(t->tile, TrackBitsToTrack(t->track));
}
}
}
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 3170bb34a..65c1347d0 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -20,16 +20,14 @@
*/
void ConnectMultiheadedTrains()
{
- Vehicle *v;
+ Train *v;
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_TRAIN) {
- ((Train *)v)->other_multiheaded_part = NULL;
- }
+ FOR_ALL_TRAINS(v) {
+ v->other_multiheaded_part = NULL;
}
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) {
+ FOR_ALL_TRAINS(v) {
+ if (IsFrontEngine(v) || IsFreeWagon(v)) {
/* Two ways to associate multiheaded parts to each other:
* sequential-matching: Trains shall be arranged to look like <..>..<..>..<..>..
* bracket-matching: Free vehicle chains shall be arranged to look like ..<..<..>..<..>..>..
@@ -45,7 +43,7 @@ void ConnectMultiheadedTrains()
bool sequential_matching = IsFrontEngine(v);
- for (Train *u = (Train *)v; u != NULL; u = (Train *)GetNextVehicle(u)) {
+ for (Train *u = v; u != NULL; u = GetNextVehicle(u)) {
if (u->other_multiheaded_part != NULL) continue; // we already linked this one
if (IsMultiheaded(u)) {
@@ -167,13 +165,11 @@ void UpdateOldAircraft()
st->airport_flags = 0; // reset airport
}
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ Aircraft *a;
+ FOR_ALL_AIRCRAFT(a) {
/* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor)
* skip those */
- if (v->type == VEH_AIRCRAFT && IsNormalAircraft(v)) {
- Aircraft *v_oldstyle = (Aircraft *)v;
- Aircraft *a = (Aircraft *)v_oldstyle;
+ if (IsNormalAircraft(a)) {
/* airplane in terminal stopped doesn't hurt anyone, so goto next */
if (a->vehstatus & VS_STOPPED && a->state == 0) {
a->state = HANGAR;
@@ -182,7 +178,7 @@ void UpdateOldAircraft()
AircraftLeaveHangar(a); // make airplane visible if it was in a depot for example
a->vehstatus &= ~VS_STOPPED; // make airplane moving
- a->cur_speed = v_oldstyle->max_speed; // so aircraft don't have zero speed while in air
+ a->cur_speed = a->max_speed; // so aircraft don't have zero speed while in air
if (!a->current_order.IsType(OT_GOTO_STATION) && !a->current_order.IsType(OT_GOTO_DEPOT)) {
/* reset current order so aircraft doesn't have invalid "station-only" order */
a->current_order.MakeDummy();