summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-05-05 10:47:35 +0000
committerpeter1138 <peter1138@openttd.org>2007-05-05 10:47:35 +0000
commit9adf583122df5bf2b483df6cc621f8ade1dc3e26 (patch)
treeab6e8834a3b98e1746aeaaa84c1611c6e05d9363
parentd52b515de80ec8496cf183f2b7f6f4a67ea76cdb (diff)
downloadopenttd-9adf583122df5bf2b483df6cc621f8ade1dc3e26.tar.xz
(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.
-rw-r--r--src/newgrf.cpp38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index d7d4cbc57..2bc557106 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -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, },