summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-04-30 17:42:08 +0000
committerpeter1138 <peter1138@openttd.org>2008-04-30 17:42:08 +0000
commit3e0b6199c4f68d9ff289a8ebbb7507e922f089b0 (patch)
treea5b7ee155f80b9091151ce09090aef647420805f /src
parent4097d81323214a711f48b1ce93e744bfed3b53e4 (diff)
downloadopenttd-3e0b6199c4f68d9ff289a8ebbb7507e922f089b0.tar.xz
(svn r12932) -Fix [FS#1970]: Articulated engines ignored GRF engine overrides.
Diffstat (limited to 'src')
-rw-r--r--src/articulated_vehicles.cpp14
-rw-r--r--src/newgrf.cpp22
-rw-r--r--src/newgrf_engine.h2
3 files changed, 24 insertions, 14 deletions
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index d6e1a97d2..1f949722c 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -11,20 +11,6 @@
#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)
{
if (!HasBit(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 0ef3e81d4..82746ad21 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -359,6 +359,28 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
return e;
}
+EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id)
+{
+ extern uint32 GetNewGRFOverride(uint32 grfid);
+
+ const GRFFile *grf_match = NULL;
+ if (_patches.dynamic_engines) {
+ uint32 override = _grf_id_overrides[file->grfid];
+ if (override != 0) grf_match = GetFileByGRFID(override);
+ }
+
+ const Engine *e = NULL;
+ FOR_ALL_ENGINES(e) {
+ if (_patches.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue;
+ if (e->type != type) continue;
+ if (e->internal_id != internal_id) continue;
+
+ return e->index;
+ }
+
+ return INVALID_ENGINE;
+}
+
/** Map the colour modifiers of TTDPatch to those that Open is using.
* @param grf_sprite pointer to the structure been modified
*/
diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h
index 48dde7608..80c299230 100644
--- a/src/newgrf_engine.h
+++ b/src/newgrf_engine.h
@@ -59,4 +59,6 @@ uint ListPositionOfEngine(EngineID engine);
void AlterRailVehListOrder(EngineID engine, EngineID target);
void CommitRailVehListOrderChanges();
+EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id);
+
#endif /* NEWGRF_ENGINE_H */