Changeset - r20790:1c40c83d41c6
[Not reviewed]
master
0 2 0
frosch - 11 years ago 2013-10-12 16:31:31
frosch@openttd.org
(svn r25834) -Codechange: Use NUM_OBJECTS_PER_GRF instead of NUM_OBJECTS to properly distinguish limits per NewGRF and limits of the pool.
-Change: [NewGRF] Lower the limit of object types per NewGRF from 256 to 255 to prevent usage of ID 0xFF in Action3, and thus allowing it to become an extended byte somewhen.
2 files changed with 8 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -3770,20 +3770,20 @@ static ChangeInfoResult IgnoreObjectProp
 
 * @return ChangeInfoResult.
 
 */
 
static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteReader *buf)
 
{
 
	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++) {
 
		ObjectSpec *spec = _cur.grffile->objectspec[id + i];
 

	
 
		if (prop != 0x08 && spec == NULL) {
 
@@ -7879,13 +7879,13 @@ static void ResetCustomIndustries()
 
static void ResetCustomObjects()
 
{
 
	const GRFFile * const *end = _grf_files.End();
 
	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]);
 
		}
 

	
 
		free(objectspec);
 
		objectspec = NULL;
 
	}
 
@@ -8549,13 +8549,13 @@ static void FinaliseIndustriesArray()
 
static void FinaliseObjectsArray()
 
{
 
	const GRFFile * const *end = _grf_files.End();
 
	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]);
 
				}
 
			}
 
		}
 
	}
src/object_type.h
Show inline comments
 
@@ -18,14 +18,16 @@ typedef uint16 ObjectType;
 
static const ObjectType OBJECT_TRANSMITTER  =   0;    ///< The large antenna
 
static const ObjectType OBJECT_LIGHTHOUSE   =   1;    ///< The nice lighthouse
 
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. */
 
typedef uint16 ObjectID;
 

	
 
struct Object;
0 comments (0 inline, 0 general)