Changeset - r26437:31785ae094bd
[Not reviewed]
master
0 2 0
Michael Lutz - 20 months ago 2022-10-16 15:05:50
michi@icosahedron.de
Codechange: [NewGRF] Replace magic number for default object size by a constant.
2 files changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -4083,7 +4083,7 @@ static ChangeInfoResult ObjectChangeInfo
 
				if (*ospec == nullptr) {
 
					*ospec = CallocT<ObjectSpec>(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
 
				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;
 

	
src/newgrf_object.h
Show inline comments
 
@@ -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. */
0 comments (0 inline, 0 general)