(svn r12905) [0.6] -Backport from trunk r12904, r12876: 0.6
authorrubidium
Fri, 25 Apr 2008 19:27:27 +0000
branch0.6
changeset 10364 40889da45fc9
parent 10352 da787f26b8b6
child 10366 960aae8c20e2
(svn r12905) [0.6] -Backport from trunk r12904, r12876:
- Fix: Remove trams from savegames saved in OTTD without tram support, it is better than to simply crash [FS#1953] (r12904)
- Fix: GCC on FreeBSD does not support -dumpmachine causing configure to fail. Use g++ instead [FS#1928] (r12876)
config.lib
src/lang/brazilian_portuguese.txt
src/lang/english.txt
src/openttd.cpp
src/vehicle.cpp
--- a/config.lib	Fri Apr 25 06:53:50 2008 +0000
+++ b/config.lib	Fri Apr 25 19:27:27 2008 +0000
@@ -419,11 +419,11 @@
 
 	detect_awk
 
+	detect_os
+
 	check_build
 	check_host
 
-	detect_os
-
 # We might enable universal builds always on OSX targets.. but currently we don't
 #	if [ "$enable_universal" = "1" ]  && [ "$os" != "OSX" ]; then
 	if [ "$enable_universal" = "1" ]; then
@@ -1347,13 +1347,26 @@
 }
 
 check_build() {
-	check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CC" "gcc" "cc" "0" "-dumpmachine"
+	if [ "$os" = "FREEBSD" ]; then
+		# FreeBSD's C compiler does not support dump machine.
+		# However, removing C support is not possible because PSP must be linked with the C compiler.
+		check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CXX" "g++" "c++" "0" "-dumpmachine"
+	else
+		check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CC" "gcc" "cc" "0" "-dumpmachine"
+	fi
 }
 
 check_host() {
 	# By default the host is the build
 	if [ -z "$host" ]; then host="$build"; fi
-	check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CC" "gcc" "cc" "0" "-dumpmachine"
+
+	if [ "$os" = "FREEBSD" ]; then
+		# FreeBSD's C compiler does not support dump machine.
+		# However, removing C support is not possible because PSP must be linked with the C compiler.
+		check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CXX" "g++" "c++" "0" "-dumpmachine"
+	else
+		check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CC" "gcc" "cc" "0" "-dumpmachine"
+	fi
 }
 
 check_cxx_build() {
--- a/src/lang/brazilian_portuguese.txt	Fri Apr 25 06:53:50 2008 +0000
+++ b/src/lang/brazilian_portuguese.txt	Fri Apr 25 19:27:27 2008 +0000
@@ -1809,8 +1809,6 @@
 STR_INDUSTRY                                                    :{INDUSTRY}
 STR_TOWN                                                        :{TOWN}
 STR_INDUSTRY_FORMAT                                             :{1:STRING} de {0:TOWN}
-STR_INDUSTRY_FORMAT.f                                           :{G=f}{1:STRING} de {0:TOWN}
-STR_INDUSTRY_FORMAT.m                                           :{G=m}{1:STRING} de {0:TOWN}
 STR_STATION                                                     :{STATION}
 
 ##id 0x2800
--- a/src/lang/english.txt	Fri Apr 25 06:53:50 2008 +0000
+++ b/src/lang/english.txt	Fri Apr 25 19:27:27 2008 +0000
@@ -3129,6 +3129,8 @@
 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:
--- a/src/openttd.cpp	Fri Apr 25 06:53:50 2008 +0000
+++ b/src/openttd.cpp	Fri Apr 25 19:27:27 2008 +0000
@@ -2440,6 +2440,21 @@
 		}
 	}
 
+	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();
 }
 
--- a/src/vehicle.cpp	Fri Apr 25 06:53:50 2008 +0000
+++ b/src/vehicle.cpp	Fri Apr 25 19:27:27 2008 +0000
@@ -583,7 +583,7 @@
 	}
 
 	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;
 	}