diff options
-rw-r--r-- | src/newgrf.cpp | 10 | ||||
-rw-r--r-- | src/object_type.h | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index e32ba1a15..6a5e41330 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -3773,14 +3773,14 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea { ChangeInfoResult ret = CIR_SUCCESS; - if (id + numinfo > NUM_OBJECTS) { - grfmsg(1, "ObjectChangeInfo: Too many objects loaded (%u), max (%u). Ignoring.", id + numinfo, NUM_OBJECTS); + if (id + numinfo > NUM_OBJECTS_PER_GRF) { + grfmsg(1, "ObjectChangeInfo: Too many objects loaded (%u), max (%u). Ignoring.", id + numinfo, NUM_OBJECTS_PER_GRF); return CIR_INVALID_ID; } /* Allocate object specs if they haven't been allocated already. */ if (_cur.grffile->objectspec == NULL) { - _cur.grffile->objectspec = CallocT<ObjectSpec*>(NUM_OBJECTS); + _cur.grffile->objectspec = CallocT<ObjectSpec*>(NUM_OBJECTS_PER_GRF); } for (int i = 0; i < numinfo; i++) { @@ -7882,7 +7882,7 @@ static void ResetCustomObjects() for (GRFFile **file = _grf_files.Begin(); file != end; file++) { ObjectSpec **&objectspec = (*file)->objectspec; if (objectspec == NULL) continue; - for (uint i = 0; i < NUM_OBJECTS; i++) { + for (uint i = 0; i < NUM_OBJECTS_PER_GRF; i++) { free(objectspec[i]); } @@ -8552,7 +8552,7 @@ static void FinaliseObjectsArray() for (GRFFile **file = _grf_files.Begin(); file != end; file++) { ObjectSpec **&objectspec = (*file)->objectspec; if (objectspec != NULL) { - for (int i = 0; i < NUM_OBJECTS; i++) { + for (int i = 0; i < NUM_OBJECTS_PER_GRF; i++) { if (objectspec[i] != NULL && objectspec[i]->grf_prop.grffile != NULL && objectspec[i]->enabled) { _object_mngr.SetEntitySpec(objectspec[i]); } diff --git a/src/object_type.h b/src/object_type.h index 7987c6481..9716b360e 100644 --- a/src/object_type.h +++ b/src/object_type.h @@ -21,8 +21,10 @@ static const ObjectType OBJECT_STATUE = 2; ///< Statue in towns static const ObjectType OBJECT_OWNED_LAND = 3; ///< Owned land 'flag' static const ObjectType OBJECT_HQ = 4; ///< HeadQuarter of a player +static const ObjectType NUM_OBJECTS_PER_GRF = 255; ///< Number of supported objects per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on. + static const ObjectType NEW_OBJECT_OFFSET = 5; ///< Offset for new objects -static const ObjectType NUM_OBJECTS = 256; ///< Number of supported objects +static const ObjectType NUM_OBJECTS = 256; ///< Number of supported objects overall static const ObjectType INVALID_OBJECT_TYPE = 0xFFFF; ///< An invalid object /** Unique identifier for an object. */ |