mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r12904) -Fix [FS#1953]: remove trams from savegames saved in OTTD without tram support, it is better than to simply crash
This commit is contained in:
parent
4e80f3f3b1
commit
805e1db332
@ -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:
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user