From bd357656ba53b50c2f75b8a9da412d0d85cbd437 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 16 Oct 2022 17:05:50 +0200 Subject: [PATCH] Codechange: [NewGRF] Replace magic number for default object size by a constant. --- src/newgrf.cpp | 4 ++-- src/newgrf_object.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index f52e512a0b..0a3dff80bb 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4083,7 +4083,7 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea if (*ospec == nullptr) { *ospec = CallocT(1); (*ospec)->views = 1; // Default for NewGRFs that don't set it. - (*ospec)->size = 0x11; // Default for NewGRFs that manage to not set it (1x1) + (*ospec)->size = OBJECT_SIZE_1X1; // Default for NewGRFs that manage to not set it (1x1) } /* Swap classid because we read it in BE. */ @@ -4111,7 +4111,7 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea spec->size = buf->ReadByte(); if (GB(spec->size, 0, 4) == 0 || GB(spec->size, 4, 4) == 0) { grfmsg(0, "ObjectChangeInfo: Invalid object size requested (0x%x) for object id %u. Ignoring.", spec->size, id + i); - spec->size = 0x11; // 1x1 + spec->size = OBJECT_SIZE_1X1; } break; diff --git a/src/newgrf_object.h b/src/newgrf_object.h index 1776b760ab..fa48506ac2 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -40,6 +40,8 @@ enum ObjectFlags { }; DECLARE_ENUM_AS_BIT_SET(ObjectFlags) +static const uint8 OBJECT_SIZE_1X1 = 0x11; ///< The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X, high nibble for Y. + void ResetObjects(); /** Class IDs for objects. */