summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2021-05-02 00:34:17 +0100
committerPeterN <peter@fuzzle.org>2021-05-02 09:41:01 +0100
commit18fb1c386689f12d2a7e767d9372020c0a8d9fea (patch)
treeedeece09e6ec906ff1a8ab5f9f01c173516bff3e
parent6b0b1bb3de17c92881d5a570736103d22c403368 (diff)
downloadopenttd-18fb1c386689f12d2a7e767d9372020c0a8d9fea.tar.xz
Codechange: Warn if randomaction2 group count is not a power of 2.
Previously noted by a comment, this does not need to be guarded against as non-powers of 2 will not cause issues beyond the choice of results being reduced.
-rw-r--r--src/newgrf.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 0377c0bc5..a9727d38d 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -5130,6 +5130,10 @@ static void NewSpriteGroup(ByteReader *buf)
group->lowest_randbit = buf->ReadByte();
byte num_groups = buf->ReadByte();
+ if (!HasExactlyOneBit(num_groups)) {
+ grfmsg(1, "NewSpriteGroup: Random Action 2 nrand should be power of 2");
+ }
+
for (uint i = 0; i < num_groups; i++) {
group->groups.push_back(GetGroupFromGroupID(setid, type, buf->ReadWord()));
}