diff options
author | Peter Nelson <peter1138@openttd.org> | 2021-05-02 00:34:17 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2021-05-02 09:41:01 +0100 |
commit | 18fb1c386689f12d2a7e767d9372020c0a8d9fea (patch) | |
tree | edeece09e6ec906ff1a8ab5f9f01c173516bff3e /src | |
parent | 6b0b1bb3de17c92881d5a570736103d22c403368 (diff) | |
download | openttd-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.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf.cpp | 4 |
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())); } |