diff options
author | rubidium <rubidium@openttd.org> | 2010-07-31 09:44:38 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-07-31 09:44:38 +0000 |
commit | 4a4f02dc81083b9de6665018ffb06d87b3bfd35e (patch) | |
tree | 5e5614bfdda7371550c1f53f908b327113b51b91 /src/newgrf.cpp | |
parent | e469a94a2df943c5595e91b2752782cfa4b2ff3f (diff) | |
download | openttd-4a4f02dc81083b9de6665018ffb06d87b3bfd35e.tar.xz |
(svn r20254) -Add: allow NewGRFs to specify their palette
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r-- | src/newgrf.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 3a2001b71..c5b91b723 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5931,6 +5931,27 @@ static bool ChangeGRFNumUsedParams(size_t len, ByteReader *buf) return true; } +/** Callback function for 'INFO'->'PALS' to set the number of valid parameters. */ +static bool ChangeGRFPalette(size_t len, ByteReader *buf) +{ + if (len != 1) { + grfmsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'PALS' but got " PRINTF_SIZE ", ignoring this field", len); + buf->Skip(len); + } else { + char data = buf->ReadByte(); + switch (data) { + case '*': + case 'A': _cur_grfconfig->palette |= GRFP_GRF_ANY; break; + case 'W': _cur_grfconfig->palette |= GRFP_GRF_WINDOWS; break; + case 'D': _cur_grfconfig->palette |= GRFP_GRF_DOS; break; + default: + grfmsg(2, "StaticGRFInfo: unexpected value '%02x' for 'INFO'->'PALS', ignoring this field", data); + break; + } + } + return true; +} + typedef bool (*DataHandler)(size_t, ByteReader *); ///< Type of callback function for binary nodes typedef bool (*TextHandler)(byte, const char *str); ///< Type of callback function for text nodes typedef bool (*BranchHandler)(ByteReader *); ///< Type of callback function for branch nodes @@ -6018,6 +6039,7 @@ AllowedSubtags _tags_info[] = { AllowedSubtags('NAME', ChangeGRFName), AllowedSubtags('DESC', ChangeGRFDescription), AllowedSubtags('NPAR', ChangeGRFNumUsedParams), + AllowedSubtags('PALS', ChangeGRFPalette), AllowedSubtags() }; |