diff options
author | darkvater <darkvater@openttd.org> | 2004-11-12 19:03:37 +0000 |
---|---|---|
committer | darkvater <darkvater@openttd.org> | 2004-11-12 19:03:37 +0000 |
commit | 2aae43a848a6d5f7336955fcf7bf3bfcd07f0023 (patch) | |
tree | 713234145035c4966aab46b76667e7acf6a6113e /grfspecial.c | |
parent | c53cf38ffdf56d79e9de36182a146c90c38c1edb (diff) | |
download | openttd-2aae43a848a6d5f7336955fcf7bf3bfcd07f0023.tar.xz |
(svn r551) -newgrf: Preliminary support for TTDPatch flags checking (we just pretend that a bunch of things are on and the rest is off and that's it). Patch by octo, small cleanup by pasky.
Diffstat (limited to 'grfspecial.c')
-rw-r--r-- | grfspecial.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/grfspecial.c b/grfspecial.c index ae915ae4c..1ce3e734f 100644 --- a/grfspecial.c +++ b/grfspecial.c @@ -26,6 +26,10 @@ static int _cur_spriteid; static int32 _paramlist[0x7f]; static int _param_max; +/* 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */ +static uint32 _ttdpatch_flags[8]; + + typedef void (*SpecialSpriteHandler)(byte *buf, int len); static const int _vehshifts[4] = { @@ -898,6 +902,10 @@ static void SkipIf(byte *buf, int len) /* XXX: This should be always true (at least until we get multiple loading stages?). */ param_val = 1; break; + case 0x85: + param_val = _ttdpatch_flags[cond_val / 0x20]; + cond_val %= 0x20; + break; case 0x86: param_val = _opt.road_side << 4; break; @@ -1176,6 +1184,26 @@ static void GRFInhibit(byte *buf, int len) /* TODO */ } + +static void InitializeGRFSpecial(void) +{ + /* FIXME: We should rather reflect reality in _ttdpatch_flags[]. */ + + _ttdpatch_flags[1] = (1 << 0x08) /* mammothtrains */ + | (1 << 0x0B) /* subsidiaries */ + | (1 << 0x14) /* bridgespeedlimits */ + | (1 << 0x16) /* eternalgame */ + | (1 << 0x17) /* newtrains */ + | (1 << 0x18) /* newrvs */ + | (1 << 0x19) /* newships */ + | (1 << 0x1A); /* newplanes */ + + _ttdpatch_flags[2] = (1 << 0x0D) /* signalsontrafficside */ + | (1 << 0x16) /* canals */ + | (1 << 0x17); /* newstartyear */ +} + + /* Here we perform initial decoding of some special sprites (as are they * described at http://www.ttdpatch.net/src/newgrf.txt, but this is only a very * partial implementation yet; also, we ignore the stages stuff). */ @@ -1203,12 +1231,18 @@ void DecodeSpecialSprite(const char *filename, int num, int spriteid) /* 0xd */ ParamSet, /* 0xe */ GRFInhibit, }; + static int initialized; byte action; byte *buf = malloc(num); int i; if (buf == NULL) error("DecodeSpecialSprite: Could not allocate memory"); + if (!initialized) { + InitializeGRFSpecial(); + initialized = 1; + } + _cur_grffile = filename; _cur_spriteid = spriteid; |