(svn r12019) -Codechange: Add support for passenger engine designation for AI-use, NewGRF property 0x08 for trains.
--- a/src/ai/default/default.cpp Wed Jan 30 03:34:24 2008 +0000
+++ b/src/ai/default/default.cpp Wed Jan 30 10:27:45 2008 +0000
@@ -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 Wed Jan 30 03:34:24 2008 +0000
+++ b/src/engine.h Wed Jan 30 10:27:45 2008 +0000
@@ -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 Wed Jan 30 03:34:24 2008 +0000
+++ b/src/newgrf.cpp Wed Jan 30 10:27:45 2008 +0000
@@ -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 Wed Jan 30 03:34:24 2008 +0000
+++ b/src/table/engines.h Wed Jan 30 10:27:45 2008 +0000
@@ -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