summaryrefslogtreecommitdiff
path: root/src/articulated_vehicles.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-04-29 21:31:29 +0000
committerpeter1138 <peter1138@openttd.org>2008-04-29 21:31:29 +0000
commita00371c8db9d3b944d901ea0468eb58fe51418a7 (patch)
tree82b8c0d69acb1c38843e4fcf0b11f46a057ef270 /src/articulated_vehicles.cpp
parent1d01390fa6d6ca83cd0cb148137d2a81749b380d (diff)
downloadopenttd-a00371c8db9d3b944d901ea0468eb58fe51418a7.tar.xz
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
Diffstat (limited to 'src/articulated_vehicles.cpp')
-rw-r--r--src/articulated_vehicles.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index ef63e71b5..d6e1a97d2 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -11,6 +11,19 @@
#include "newgrf_engine.h"
#include "vehicle_func.h"
+static EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id)
+{
+ const Engine *e = NULL;
+ FOR_ALL_ENGINES(e) {
+ if (e->grffile != file) continue;
+ if (e->type != type) continue;
+ if (e->internal_id != internal_id) continue;
+
+ return e->index;
+ }
+
+ return INVALID_ENGINE;
+}
uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
{
@@ -54,7 +67,7 @@ uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
- EngineID artic_engine = GetFirstEngineOfType(type) + GB(callback, 0, 7);
+ EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
if (type == VEH_TRAIN) {
const RailVehicleInfo *rvi = RailVehInfo(artic_engine);
@@ -88,7 +101,7 @@ void AddArticulatedParts(Vehicle **vl, VehicleType type)
Vehicle *previous = u;
u = u->Next();
- EngineID engine_type = GetFirstEngineOfType(type) + GB(callback, 0, 7);
+ EngineID engine_type = GetNewEngineID(GetEngineGRF(v->engine_type), type, GB(callback, 0, 7));
bool flip_image = HasBit(callback, 7);
/* get common values from first engine */