From 18fb1c386689f12d2a7e767d9372020c0a8d9fea Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 2 May 2021 00:34:17 +0100 Subject: 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. --- src/newgrf.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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())); } -- cgit v1.2.3-70-g09d2