(svn r9956) -Codechange: Add tram livery schemes
authorpeter1138
Sun, 27 May 2007 09:33:41 +0000
changeset 7220 a8d6abc0981f
parent 7219 e5b7a61ea70f
child 7221 d4e8d1ff84a0
(svn r9956) -Codechange: Add tram livery schemes
src/lang/english.txt
src/livery.h
src/player_gui.cpp
src/players.cpp
src/saveload.cpp
src/vehicle.cpp
--- a/src/lang/english.txt	Sun May 27 09:17:30 2007 +0000
+++ b/src/lang/english.txt	Sun May 27 09:33:41 2007 +0000
@@ -2271,6 +2271,8 @@
 STR_LIVERY_HELICOPTER                                           :Helicopter
 STR_LIVERY_SMALL_PLANE                                          :Small Aeroplane
 STR_LIVERY_LARGE_PLANE                                          :Large Aeroplane
+STR_LIVERY_PASSENGER_TRAM                                       :Passenger Tram
+STR_LIVERY_FREIGHT_TRAM                                         :Freight Tram
 
 STR_LIVERY_GENERAL_TIP                                          :{BLACK}Show general colour schemes
 STR_LIVERY_TRAIN_TIP                                            :{BLACK}Show train colour schemes
--- a/src/livery.h	Sun May 27 09:17:30 2007 +0000
+++ b/src/livery.h	Sun May 27 09:33:41 2007 +0000
@@ -38,6 +38,10 @@
 	LS_SMALL_PLANE,
 	LS_LARGE_PLANE,
 
+	/* Trams (appear on Road Vehicles tab) */
+	LS_PASSENGER_TRAM,
+	LS_FREIGHT_TRAM,
+
 	LS_END
 };
 
--- a/src/player_gui.cpp	Sun May 27 09:17:30 2007 +0000
+++ b/src/player_gui.cpp	Sun May 27 09:33:41 2007 +0000
@@ -277,13 +277,14 @@
 	LC_ROAD, LC_ROAD,
 	LC_SHIP, LC_SHIP,
 	LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
+	LC_ROAD, LC_ROAD,
 };
 
 /* Number of liveries in each class, used to determine the height of the livery window */
 static const byte livery_height[] = {
 	1,
 	11,
-	2,
+	4,
 	2,
 	3,
 };
--- a/src/players.cpp	Sun May 27 09:17:30 2007 +0000
+++ b/src/players.cpp	Sun May 27 09:33:41 2007 +0000
@@ -1279,9 +1279,16 @@
 	}
 
 	/* Write each livery entry. */
-	for (i = 0; i < LS_END; i++) {
+	int num_liveries = CheckSavegameVersion(63) ? LS_END - 2 : LS_END;
+	for (i = 0; i < num_liveries; i++) {
 		SlObject(&p->livery[i], _player_livery_desc);
 	}
+
+	if (num_liveries == LS_END - 2) {
+		/* Copy bus/truck liveries over to trams */
+		p->livery[LS_PASSENGER_TRAM] = p->livery[LS_BUS];
+		p->livery[LS_FREIGHT_TRAM]   = p->livery[LS_TRUCK];
+	}
 }
 
 static void Save_PLYR()
--- a/src/saveload.cpp	Sun May 27 09:17:30 2007 +0000
+++ b/src/saveload.cpp	Sun May 27 09:33:41 2007 +0000
@@ -29,7 +29,7 @@
 #include <setjmp.h>
 #include <list>
 
-extern const uint16 SAVEGAME_VERSION = 62;
+extern const uint16 SAVEGAME_VERSION = 63;
 uint16 _sl_version;       ///< the major savegame version identifier
 byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 
--- a/src/vehicle.cpp	Sun May 27 09:17:30 2007 +0000
+++ b/src/vehicle.cpp	Sun May 27 09:33:41 2007 +0000
@@ -2520,7 +2520,13 @@
 			case VEH_ROAD: {
 				const RoadVehicleInfo *rvi = RoadVehInfo(engine_type);
 				if (cargo_type == CT_INVALID) cargo_type = rvi->cargo_type;
-				scheme = IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_BUS : LS_TRUCK;
+				if (HASBIT(EngInfo(engine_type)->misc_flags, EF_ROAD_TRAM)) {
+					/* Tram */
+					scheme = IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_PASSENGER_TRAM : LS_FREIGHT_TRAM;
+				} else {
+					/* Bus or truck */
+					scheme = IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_BUS : LS_TRUCK;
+				}
 				break;
 			}