From d3c7a35d22de9e72de039d57d5c1ee480d983e61 Mon Sep 17 00:00:00 2001 From: frosch Date: Mon, 28 Jan 2008 15:55:59 +0000 Subject: [PATCH] (svn r12001) -Fix: When skipping Action 11 or 12, also skip belonging sprites. --- src/newgrf.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index c2d17c616c..119def0d5d 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4560,6 +4560,20 @@ static void GRFSound(byte *buf, int len) if (_cur_grffile->sound_offset == 0) _cur_grffile->sound_offset = GetNumSounds(); } +/* Action 0x11 (SKIP) */ +static void SkipAct11(byte *buf, int len) +{ + /* <11> + * + * W num Number of sound files that follow */ + + if (!check_length(len, 1, "SkipAct11")) return; + buf++; + _skip_sprites = grf_load_word(&buf); + + grfmsg(3, "SkipAct11: Skipping %d sprites", _skip_sprites); +} + static void ImportGRFSound(byte *buf, int len) { const GRFFile *file; @@ -4704,6 +4718,36 @@ static void LoadFontGlyph(byte *buf, int len) } } +/* Action 0x12 (SKIP) */ +static void SkipAct12(byte *buf, int len) +{ + /* <12> + * + * B num_def Number of definitions + * B font_size Size of font (0 = normal, 1 = small, 2 = large) + * B num_char Number of consecutive glyphs + * W base_char First character index */ + + buf++; len--; + if (!check_length(len, 1, "SkipAct12")) return; + uint8 num_def = grf_load_byte(&buf); + + if (!check_length(len, 1 + num_def * 4, "SkipAct12")) return; + + for (uint i = 0; i < num_def; i++) { + /* Ignore 'size' byte */ + grf_load_byte(&buf); + + /* Sum up number of characters */ + _skip_sprites += grf_load_byte(&buf); + + /* Ignore 'base_char' word */ + grf_load_word(&buf); + } + + grfmsg(3, "SkipAct12: Skipping %d sprites", _skip_sprites); +} + /* Action 0x13 */ static void TranslateGRFStrings(byte *buf, int len) { @@ -5461,8 +5505,8 @@ static void DecodeSpecialSprite(uint num, GrfLoadingStage stage) /* 0x0E */ { NULL, SafeGRFInhibit, NULL, GRFInhibit, GRFInhibit, GRFInhibit, }, /* 0x0F */ { NULL, GRFUnsafe, NULL, FeatureTownName, NULL, NULL, }, /* 0x10 */ { NULL, NULL, DefineGotoLabel, NULL, NULL, NULL, }, - /* 0x11 */ { NULL, GRFUnsafe, NULL, NULL, NULL, GRFSound, }, - /* 0x12 */ { NULL, NULL, NULL, NULL, NULL, LoadFontGlyph, }, + /* 0x11 */ { SkipAct11,GRFUnsafe, SkipAct11, SkipAct11, SkipAct11, GRFSound, }, + /* 0x12 */ { SkipAct12, SkipAct12, SkipAct12, SkipAct12, SkipAct12, LoadFontGlyph, }, /* 0x13 */ { NULL, NULL, NULL, NULL, NULL, TranslateGRFStrings, }, };