summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/openttd.cpp15
-rw-r--r--src/vehicle.cpp2
3 files changed, 18 insertions, 1 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 165a3c618..972666cc3 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3182,6 +3182,8 @@ STR_NEWGRF_NOT_FOUND_WARNING :{WHITE}Missing
STR_NEWGRF_UNPAUSE_WARNING_TITLE :{YELLOW}Missing GRF file(s)
STR_NEWGRF_UNPAUSE_WARNING :{WHITE}Unpausing can crash OpenTTD. Do not file bug reports for subsequent crashes.{}Do you really want to unpause?
+STR_LOADGAME_REMOVED_TRAMS :{WHITE}Game was saved in version without tram support. All trams have been removed.
+
STR_CURRENCY_WINDOW :{WHITE}Custom currency
STR_CURRENCY_EXCHANGE_RATE :{LTBLUE}Exchange rate: {ORANGE}{CURRENCY} = £ {COMMA}
STR_CURRENCY_SEPARATOR :{LTBLUE}Separator:
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 2d32c04f6..50bf799c7 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -2501,6 +2501,21 @@ bool AfterLoadGame()
}
}
+ if (CheckSavegameVersion(62)) {
+ /* Remove all trams from savegames without tram support.
+ * There would be trams without tram track under causing crashes sooner or later. */
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if (v->type == VEH_ROAD && v->First() == v &&
+ HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM)) {
+ if (_switch_mode_errorstr == INVALID_STRING_ID || _switch_mode_errorstr == STR_NEWGRF_COMPATIBLE_LOAD_WARNING) {
+ _switch_mode_errorstr = STR_LOADGAME_REMOVED_TRAMS;
+ }
+ delete v;
+ }
+ }
+ }
+
return InitializeWindowsAndCaches();
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index d8acda4ab..ec4908669 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -591,7 +591,7 @@ void Vehicle::PreDestructor()
}
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
- if (WP(w, vp_d).follow_vehicle == this->index) {
+ if (w != NULL && WP(w, vp_d).follow_vehicle == this->index) {
ScrollMainWindowTo(this->x_pos, this->y_pos, true); // lock the main view on the vehicle's last position
WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
}