File diff r21298:c09c5ce22fcd → r21299:8973364c4b52
src/newgrf_industries.cpp
Show inline comments
 
@@ -429,12 +429,13 @@ static const GRFFile *GetGrffile(Industr
 
IndustriesResolverObject::IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32 random_bits,
 
		CallbackID callback, uint32 callback_param1, uint32 callback_param2)
 
	: ResolverObject(GetGrffile(type), callback, callback_param1, callback_param2),
 
	industries_scope(*this, tile, indus, type, random_bits),
 
	town_scope(NULL)
 
{
 
	this->root_spritegroup = GetIndustrySpec(type)->grf_prop.spritegroup[0];
 
}
 

	
 
IndustriesResolverObject::~IndustriesResolverObject()
 
{
 
	delete this->town_scope;
 
}
 
@@ -487,16 +488,13 @@ IndustriesScopeResolver::IndustriesScope
 
 * @param tile The tile associated with the callback.
 
 * @return The callback result.
 
 */
 
uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile)
 
{
 
	IndustriesResolverObject object(tile, industry, type, 0, callback, param1, param2);
 
	const SpriteGroup *group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], object);
 
	if (group == NULL) return CALLBACK_FAILED;
 

	
 
	return group->GetCallbackResult();
 
	return object.ResolveCallback();
 
}
 

	
 
/**
 
 * Check that the industry callback allows creation of the industry.
 
 * @param tile %Tile to build the industry.
 
 * @param type Type of industry to build.
 
@@ -520,18 +518,16 @@ CommandCost CheckIfCallBackAllowsCreatio
 
	ind.town = ClosestTownFromTile(tile, UINT_MAX);
 
	ind.random = initial_random_bits;
 
	ind.founder = founder;
 
	ind.psa = NULL;
 

	
 
	IndustriesResolverObject object(tile, &ind, type, seed, CBID_INDUSTRY_LOCATION, 0, creation_type);
 
	const SpriteGroup *group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], object);
 
	uint16 result = object.ResolveCallback();
 

	
 
	/* Unlike the "normal" cases, not having a valid result means we allow
 
	 * the building of the industry, as that's how it's done in TTDP. */
 
	if (group == NULL) return CommandCost();
 
	uint16 result = group->GetCallbackResult();
 
	if (result == CALLBACK_FAILED) return CommandCost();
 

	
 
	return GetErrorMessageFromLocationCallbackResult(result, indspec->grf_prop.grffile, STR_ERROR_SITE_UNSUITABLE);
 
}
 

	
 
/**
 
@@ -593,13 +589,13 @@ void IndustryProductionCallback(Industry
 

	
 
			/* abort the function early, this error isn't critical and will allow the game to continue to run */
 
			break;
 
		}
 

	
 
		SB(object.callback_param2, 8, 16, loop);
 
		const SpriteGroup *tgroup = SpriteGroup::Resolve(spec->grf_prop.spritegroup[0], object);
 
		const SpriteGroup *tgroup = object.Resolve();
 
		if (tgroup == NULL || tgroup->type != SGT_INDUSTRY_PRODUCTION) break;
 
		const IndustryProductionSpriteGroup *group = (const IndustryProductionSpriteGroup *)tgroup;
 

	
 
		bool deref = (group->version == 1);
 

	
 
		for (uint i = 0; i < 3; i++) {