Changeset - r20793:53ddcd7714d7
[Not reviewed]
master
0 2 0
frosch - 11 years ago 2013-10-12 16:32:59
frosch@openttd.org
(svn r25837) -Codechange: Use NUM_INDUSTRYTILES_PER_GRF instead of NUM_INDUSTRYTILES to properly distinguish limits per NewGRF and limits of the pool.
-Change: [NewGRF] Lower the limit of industry tile 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 7 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/industry_type.h
Show inline comments
 
@@ -25,12 +25,14 @@ static const IndustryID INVALID_INDUSTRY
 
static const IndustryType NUM_INDUSTRYTYPES_PER_GRF = 64;              ///< maximum number of industry types per NewGRF
 

	
 
static const IndustryType NEW_INDUSTRYOFFSET     = 37;                ///< original number of industry types
 
static const IndustryType NUM_INDUSTRYTYPES      = 64;                ///< total number of industry types, new and old
 
static const IndustryType INVALID_INDUSTRYTYPE   = NUM_INDUSTRYTYPES; ///< one above amount is considered invalid
 

	
 
static const IndustryGfx  NUM_INDUSTRYTILES_PER_GRF = 255;             ///< Maximum number of industry tiles per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.
 

	
 
static const IndustryGfx  INDUSTRYTILE_NOANIM    = 0xFF;              ///< flag to mark industry tiles as having no animation
 
static const IndustryGfx  NEW_INDUSTRYTILEOFFSET = 175;               ///< original number of tiles
 
static const IndustryGfx  NUM_INDUSTRYTILES      = 512;               ///< total number of industry tiles, new and old
 
static const IndustryGfx  INVALID_INDUSTRYTILE   = NUM_INDUSTRYTILES; ///< one above amount is considered invalid
 

	
 
static const int INDUSTRY_COMPLETED = 3; ///< final stage of industry construction.
src/newgrf.cpp
Show inline comments
 
@@ -2974,20 +2974,20 @@ static ChangeInfoResult IgnoreIndustryTi
 
 * @return ChangeInfoResult.
 
 */
 
static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int prop, ByteReader *buf)
 
{
 
	ChangeInfoResult ret = CIR_SUCCESS;
 

	
 
	if (indtid + numinfo > NUM_INDUSTRYTILES) {
 
		grfmsg(1, "IndustryTilesChangeInfo: Too many industry tiles loaded (%u), max (%u). Ignoring.", indtid + numinfo, NUM_INDUSTRYTILES);
 
	if (indtid + numinfo > NUM_INDUSTRYTILES_PER_GRF) {
 
		grfmsg(1, "IndustryTilesChangeInfo: Too many industry tiles loaded (%u), max (%u). Ignoring.", indtid + numinfo, NUM_INDUSTRYTILES_PER_GRF);
 
		return CIR_INVALID_ID;
 
	}
 

	
 
	/* Allocate industry tile specs if they haven't been allocated already. */
 
	if (_cur.grffile->indtspec == NULL) {
 
		_cur.grffile->indtspec = CallocT<IndustryTileSpec*>(NUM_INDUSTRYTILES);
 
		_cur.grffile->indtspec = CallocT<IndustryTileSpec*>(NUM_INDUSTRYTILES_PER_GRF);
 
	}
 

	
 
	for (int i = 0; i < numinfo; i++) {
 
		IndustryTileSpec *tsp = _cur.grffile->indtspec[indtid + i];
 

	
 
		if (prop != 0x08 && tsp == NULL) {
 
@@ -7863,13 +7863,13 @@ static void ResetCustomIndustries()
 

	
 
			free(industryspec);
 
			industryspec = NULL;
 
		}
 

	
 
		if (indtspec == NULL) continue;
 
		for (uint i = 0; i < NUM_INDUSTRYTILES; i++) {
 
		for (uint i = 0; i < NUM_INDUSTRYTILES_PER_GRF; i++) {
 
			free(indtspec[i]);
 
		}
 

	
 
		free(indtspec);
 
		indtspec = NULL;
 
	}
 
@@ -8516,13 +8516,13 @@ static void FinaliseIndustriesArray()
 
					_loaded_newgrf_features.has_newindustries = true;
 
				}
 
			}
 
		}
 

	
 
		if (indtspec != NULL) {
 
			for (int i = 0; i < NUM_INDUSTRYTILES; i++) {
 
			for (int i = 0; i < NUM_INDUSTRYTILES_PER_GRF; i++) {
 
				IndustryTileSpec *indtsp = indtspec[i];
 
				if (indtsp != NULL) {
 
					_industile_mngr.SetEntitySpec(indtsp);
 
				}
 
			}
 
		}
0 comments (0 inline, 0 general)