changeset 8449:b733d748fa67 draft

(svn r12019) -Codechange: Add support for passenger engine designation for AI-use, NewGRF property 0x08 for trains.
author peter1138 <peter1138@openttd.org>
date Wed, 30 Jan 2008 10:27:45 +0000
parents 5b5fdcb49728
children 4f8718f910d8
files src/ai/default/default.cpp src/engine.h src/newgrf.cpp src/table/engines.h
diffstat 4 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -154,6 +154,9 @@
 			continue;
 		}
 
+		/* Don't choose an engine designated for passenger use for freight. */
+		if (rvi->ai_passenger_only != 0 && flag == 1) continue;
+
 		CommandCost ret = DoCommand(tile, i, 0, 0, CMD_BUILD_RAIL_VEHICLE);
 		if (CmdSucceeded(ret) && ret.GetCost() <= money && rvi->ai_rank >= best_veh_score) {
 			best_veh_score = rvi->ai_rank;
--- a/src/engine.h
+++ b/src/engine.h
@@ -42,6 +42,7 @@
 	byte capacity;
 	CargoID cargo_type;
 	byte ai_rank;
+	byte ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only
 	uint16 pow_wag_power;
 	byte pow_wag_weight;
 	byte visual_effect; // NOTE: this is not 100% implemented yet, at the moment it is only used as a 'fallback' value
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -348,10 +348,9 @@
 			} break;
 
 			case 0x08: // AI passenger service
-				/** @todo Tells the AI that this engine is designed for
+				/* Tells the AI that this engine is designed for
 				 * passenger services and shouldn't be used for freight. */
-				grf_load_byte(&buf);
-				ret = true;
+				rvi->ai_passenger_only = grf_load_byte(&buf);
 				break;
 
 			case 0x09: { // Speed (1 unit is 1 kmh)
--- a/src/table/engines.h
+++ b/src/table/engines.h
@@ -345,7 +345,7 @@
  * @param m engclass
  * Tractive effort coefficient by default is the same as TTDPatch, 0.30*256=76
  */
-#define RVI(a, b, c, d, e, f, g, h, i, j, k, l, m) { a, b, c, {l}, d, e, f, g, h, m, i, j, k, 0, 0, 0, 0, 76, 0 }
+#define RVI(a, b, c, d, e, f, g, h, i, j, k, l, m) { a, b, c, {l}, d, e, f, g, h, m, i, j, k, 0, 0, 0, 0, 0, 76, 0 }
 #define M RAILVEH_MULTIHEAD
 #define W RAILVEH_WAGON
 #define G RAILVEH_SINGLEHEAD