summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-07-08 15:10:23 +0000
committerrubidium <rubidium@openttd.org>2008-07-08 15:10:23 +0000
commitd974acac8986accbbbc8c4512ca8e413c9a591f9 (patch)
tree1cb8248688de6895f87895cd745183a1db2c6f56 /src
parent03d32e12fba1a4568aee7734d37e7e7195b72e8d (diff)
downloadopenttd-d974acac8986accbbbc8c4512ca8e413c9a591f9.tar.xz
(svn r13681) -Revert (r13678, r13677): the fixes didn't work in all cases (assertions on savegame loads).
-Fix [FS#2102]: but now in a hopefully beter way.
Diffstat (limited to 'src')
-rw-r--r--src/elrail.cpp9
-rw-r--r--src/openttd.cpp2
-rw-r--r--src/vehicle.cpp24
-rw-r--r--src/vehicle_base.h1
4 files changed, 16 insertions, 20 deletions
diff --git a/src/elrail.cpp b/src/elrail.cpp
index 11c6f8953..435675b15 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -495,10 +495,13 @@ int32 SettingsDisableElrail(int32 p1)
}
}
- /* setup total power for trains */
+ /* Fix the total power and acceleration for trains */
FOR_ALL_VEHICLES(v) {
- /* power is cached only for front engines */
- if (v->type == VEH_TRAIN && IsFrontEngine(v)) TrainPowerChanged(v);
+ /* power and acceleration is cached only for front engines */
+ if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
+ TrainPowerChanged(v);
+ UpdateTrainAcceleration(v);
+ }
}
FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index);
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 3c33f571b..817aace13 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1265,8 +1265,6 @@ static bool InitializeWindowsAndCaches()
}
}
- InitializeVehicleCaches();
-
SetCachedEngineCounts();
/* Towns have a noise controlled number of airports system
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index b0ad68113..e8b1e4093 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -275,8 +275,17 @@ void AfterLoadVehicles(bool clear_te_id)
}
FOR_ALL_VEHICLES(v) {
- assert(v->First() != NULL);
+ assert(v->first != NULL);
+ if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) {
+ if (IsFrontEngine(v)) v->u.rail.last_speed = v->cur_speed; // update displayed train speed
+ TrainConsistChanged(v);
+ } else if (v->type == VEH_ROAD && IsRoadVehFront(v)) {
+ RoadVehUpdateCache(v);
+ }
+ }
+
+ FOR_ALL_VEHICLES(v) {
switch (v->type) {
case VEH_ROAD:
v->u.road.roadtype = HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
@@ -312,19 +321,6 @@ void AfterLoadVehicles(bool clear_te_id)
}
}
-void InitializeVehicleCaches()
-{
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_TRAIN && (IsFrontEngine(v) || IsFreeWagon(v))) {
- if (IsFrontEngine(v)) v->u.rail.last_speed = v->cur_speed; // update displayed train speed
- TrainConsistChanged(v);
- } else if (v->type == VEH_ROAD && IsRoadVehFront(v)) {
- RoadVehUpdateCache(v);
- }
- }
-}
-
Vehicle::Vehicle()
{
this->type = VEH_INVALID;
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index c7b09b88b..0defc9566 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -191,7 +191,6 @@ DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125)
struct SaveLoad;
extern const SaveLoad *GetVehicleDescription(VehicleType vt);
extern void AfterLoadVehicles(bool clear_te_id);
-extern void InitializeVehicleCaches();
struct LoadgameState;
extern bool LoadOldVehicle(LoadgameState *ls, int num);