(svn r9790) -Codechange: [NewGRF] Skip action 1 sprites in all stages except activation. This also cleans up some special-case handling of the sprites. Actions 1 and 2 are now not considered unsafe, as an Action 3 (which is unsafe) is required for them.

This commit is contained in:
peter1138 2007-05-05 10:47:35 +00:00
parent 438d55d576
commit 74bf87dd82

View File

@ -1791,11 +1791,6 @@ static void FeatureChangeInfo(byte *buf, int len)
EngineInfo *ei = NULL;
if (len == 1) {
grfmsg(8, "Silently ignoring one-byte special sprite 0x00");
return;
}
if (!check_length(len, 6, "FeatureChangeInfo")) return;
buf++;
uint8 feature = grf_load_byte(&buf);
@ -1879,11 +1874,6 @@ static void FeatureChangeInfo(byte *buf, int len)
/* Action 0x00 (GLS_SAFETYSCAN) */
static void SafeChangeInfo(byte *buf, int len)
{
if (len == 1) {
grfmsg(8, "Silently ignoring one-byte special sprite 0x00");
return;
}
if (!check_length(len, 6, "SafeChangeInfo")) return;
buf++;
uint8 feature = grf_load_byte(&buf);
@ -1909,11 +1899,6 @@ static void InitChangeInfo(byte *buf, int len)
{
byte *bufend = buf + len;
if (len == 1) {
grfmsg(8, "Silently ignoring one-byte special sprite 0x00");
return;
}
if (!check_length(len, 6, "InitChangeInfo")) return;
buf++;
uint8 feature = grf_load_byte(&buf);
@ -1954,11 +1939,6 @@ static void ReserveChangeInfo(byte *buf, int len)
{
byte *bufend = buf + len;
if (len == 1) {
grfmsg(8, "Silently ignoring one-byte special sprite 0x00");
return;
}
if (!check_length(len, 6, "InitChangeInfo")) return;
buf++;
uint8 feature = grf_load_byte(&buf);
@ -2055,6 +2035,20 @@ static void NewSpriteSet(byte *buf, int len)
}
}
/* Action 0x01 (SKIP) */
static void SkipAct1(byte *buf, int len)
{
if (!check_length(len, 4, "SkipAct1")) return;
buf++;
grf_load_byte(&buf);
uint8 num_sets = grf_load_byte(&buf);
uint16 num_ents = grf_load_extended(&buf);
_skip_sprites = num_sets * num_ents;
grfmsg(3, "SkipAct1: Skipping %d sprites", _skip_sprites);
}
/* Helper function to either create a callback or link to a previously
* defined spritegroup. */
static const SpriteGroup* GetGroupFromGroupID(byte setid, byte type, uint16 groupid)
@ -4614,8 +4608,8 @@ static void DecodeSpecialSprite(uint num, GrfLoadingStage stage)
* In other stages we skip action 0x10 since it's already dealt with. */
static const SpecialSpriteHandler handlers[][GLS_END] = {
/* 0x00 */ { NULL, SafeChangeInfo, NULL, InitChangeInfo, ReserveChangeInfo, FeatureChangeInfo, },
/* 0x01 */ { NULL, GRFUnsafe, NULL, NULL, NULL, NewSpriteSet, },
/* 0x02 */ { NULL, GRFUnsafe, NULL, NULL, NULL, NewSpriteGroup, },
/* 0x01 */ { SkipAct1, SkipAct1, SkipAct1, SkipAct1, SkipAct1, NewSpriteSet, },
/* 0x02 */ { NULL, NULL, NULL, NULL, NULL, NewSpriteGroup, },
/* 0x03 */ { NULL, GRFUnsafe, NULL, NULL, NULL, FeatureMapSpriteGroup, },
/* 0x04 */ { NULL, NULL, NULL, NULL, NULL, FeatureNewName, },
/* 0x05 */ { SkipAct5, SkipAct5, SkipAct5, SkipAct5, SkipAct5, GraphicsNew, },