summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2005-12-02 14:55:23 +0000
committerpeter1138 <peter1138@openttd.org>2005-12-02 14:55:23 +0000
commit7460ecd42a56c96277e7566cbe3750d890b2dded (patch)
treebfc55dc94af3e7e35618d464a7392a26935b38b0
parentea9cb3ee5bd7e36ee344c42d4bd697ab7f177134 (diff)
downloadopenttd-7460ecd42a56c96277e7566cbe3750d890b2dded.tar.xz
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
-rw-r--r--engine.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/engine.c b/engine.c
index ebbe04cf8..acb4558a1 100644
--- a/engine.c
+++ b/engine.c
@@ -17,6 +17,7 @@
#include "saveload.h"
#include "sprite.h"
#include "variables.h"
+#include "train.h"
enum {
ENGINE_AVAILABLE = 1,
@@ -363,6 +364,14 @@ void UnloadCustomEngineSprites(void)
}
}
+static int MapOldSubType(const Vehicle *v)
+{
+ if (v->type != VEH_Train) return v->subtype;
+ if (IsTrainEngine(v)) return 0;
+ if (IsFreeWagon(v)) return 4;
+ return 2;
+}
+
typedef SpriteGroup *(*resolve_callback)(const SpriteGroup *spritegroup,
const Vehicle *veh, uint16 callback_info, void *resolve_func); /* XXX data pointer used as function pointer */
@@ -442,7 +451,7 @@ static const SpriteGroup* ResolveVehicleSpriteGroup(const SpriteGroup *spritegro
switch (dsg->variable - 0x80) {
#define veh_prop(id_, value_) case (id_): value = (value_); break
veh_prop(0x00, veh->type);
- veh_prop(0x01, veh->subtype);
+ veh_prop(0x01, MapOldSubType(veh));
veh_prop(0x04, veh->index);
veh_prop(0x05, veh->index & 0xFF);
/* XXX? Is THIS right? */