From d2fc3431a1baef1d7bbdfc02e80a02b5238f2741 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Wed, 10 May 2006 06:23:43 +0000 Subject: [PATCH] (svn r4811) - NewGRF: only check a sprite set's feature when assigning a sprite result sprite group. --- newgrf.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/newgrf.c b/newgrf.c index 023508e456..83493adbe1 100644 --- a/newgrf.c +++ b/newgrf.c @@ -1299,7 +1299,7 @@ static SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 groupid) } /* Helper function to either create a callback or a result sprite group. */ -static SpriteGroup* CreateGroupFromGroupID(byte setid, byte type, uint16 spriteid, uint16 num_sprites) +static SpriteGroup* CreateGroupFromGroupID(byte feature, byte setid, byte type, uint16 spriteid, uint16 num_sprites) { if (HASBIT(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid); @@ -1319,6 +1319,12 @@ static SpriteGroup* CreateGroupFromGroupID(byte setid, byte type, uint16 spritei return NULL; } + if (feature != _cur_grffile->spriteset_feature) { + grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Sprite set feature 0x%02X does not match action feature 0x%02X, skipping.", + _cur_grffile->spriteset_feature, feature); + return NULL; + } + return NewResultSpriteGroup(_cur_grffile->spriteset_start + spriteid * num_sprites, num_sprites); } @@ -1356,14 +1362,6 @@ static void NewSpriteGroup(byte *buf, int len) _cur_grffile->spritegroups[_cur_grffile->spritegroups_count] = NULL; } - if (feature != _cur_grffile->spriteset_feature) { - grfmsg(GMS_WARN, "NewSpriteGroup: sprite set feature 0x%02X does not match action feature 0x%02X, skipping.", - _cur_grffile->spriteset_feature, feature); - /* Clear this group's reference */ - _cur_grffile->spritegroups[setid] = NULL; - return; - } - switch (type) { /* Deterministic Sprite Group */ case 0x81: // Self scope, byte @@ -1475,6 +1473,8 @@ static void NewSpriteGroup(byte *buf, int len) /* Neither a variable or randomized sprite group... must be a real group */ default: { + + switch (feature) { case GSF_TRAIN: case GSF_ROAD: @@ -1507,13 +1507,13 @@ static void NewSpriteGroup(byte *buf, int len) for (i = 0; i < num_loaded; i++) { uint16 spriteid = grf_load_word(&buf); - group->g.real.loaded[i] = CreateGroupFromGroupID(setid, type, spriteid, sprites); + group->g.real.loaded[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); DEBUG(grf, 8) ("NewSpriteGroup: + rg->loaded[%i] = subset %u", i, spriteid); } for (i = 0; i < num_loading; i++) { uint16 spriteid = grf_load_word(&buf); - group->g.real.loading[i] = CreateGroupFromGroupID(setid, type, spriteid, sprites); + group->g.real.loading[i] = CreateGroupFromGroupID(feature, setid, type, spriteid, sprites); DEBUG(grf, 8) ("NewSpriteGroup: + rg->loading[%i] = subset %u", i, spriteid); }