Changeset - r15256:e22f3389fd3a
[Not reviewed]
master
0 5 0
frosch - 14 years ago 2010-05-29 13:08:50
frosch@openttd.org
(svn r19901) -Add: [NewGRF] Access to industry founder (var A7) during callbacks 28 and 2F. (yexo)
5 files changed with 14 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1321,10 +1321,11 @@ bool IsSlopeRefused(Slope current, Slope
 
 * @param itspec_index             The index of the itsepc to build/fund
 
 * @param type                     Type of the industry.
 
 * @param initial_random_bits      The random bits the industry is going to have after construction.
 
 * @param founder Industry founder
 
 * @param [out] custom_shape_check Perform custom check for the site.
 
 * @return Failed or succeeded command.
 
 */
 
static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, uint16 initial_random_bits, bool *custom_shape_check = NULL)
 
static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, uint16 initial_random_bits, Owner founder, bool *custom_shape_check = NULL)
 
{
 
	bool refused_slope = false;
 
	bool custom_shape = false;
 
@@ -1356,7 +1357,7 @@ static CommandCost CheckIfIndustryTilesA
 

	
 
			if (HasBit(its->callback_mask, CBM_INDT_SHAPE_CHECK)) {
 
				custom_shape = true;
 
				CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index, initial_random_bits);
 
				CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index, initial_random_bits, founder);
 
				if (ret.Failed()) return ret;
 
			} else {
 
				Slope tileh = GetTileSlope(cur_tile, NULL);
 
@@ -1708,11 +1709,11 @@ static CommandCost CreateNewIndustryHelp
 

	
 
	*ip = NULL;
 

	
 
	CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, &custom_shape_check);
 
	CommandCost ret = CheckIfIndustryTilesAreFree(tile, it, itspec_index, type, random_initial_bits, founder, &custom_shape_check);
 
	if (ret.Failed()) return ret;
 

	
 
	if (HasBit(GetIndustrySpec(type)->callback_mask, CBM_IND_LOCATION)) {
 
		ret = CheckIfCallBackAllowsCreation(tile, type, itspec_index, random_var8f, random_initial_bits);
 
		ret = CheckIfCallBackAllowsCreation(tile, type, itspec_index, random_var8f, random_initial_bits, founder);
 
	} else {
 
		ret = _check_new_industry_procs[indspec->check_proc](tile);
 
	}
 
@@ -1811,7 +1812,7 @@ CommandCost CmdBuildIndustry(TileIndex t
 
		do {
 
			if (--count < 0) return ret;
 
			if (--num < 0) num = indspec->num_table - 1;
 
			ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it, random_initial_bits);
 
			ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it, random_initial_bits, _current_company);
 
		} while (ret.Failed());
 

	
 
		ret = CreateNewIndustryHelper(tile, it, flags, indspec, num, random_var8f, random_initial_bits, _current_company, &ind);
src/newgrf_industries.cpp
Show inline comments
 
@@ -453,9 +453,10 @@ uint32 IndustryLocationGetVariable(const
 
 * @param layout Layout number.
 
 * @param seed Seed for the random generator.
 
 * @param initial_random_bits The random bits the industry is going to have after construction.
 
 * @param founder Industry founder
 
 * @return Succeeded or failed command.
 
 */
 
CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits)
 
CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder)
 
{
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 

	
 
@@ -470,6 +471,7 @@ CommandCost CheckIfCallBackAllowsCreatio
 
	ind.selected_layout = layout;
 
	ind.town = ClosestTownFromTile(tile, UINT_MAX);
 
	ind.random = initial_random_bits;
 
	ind.founder = founder;
 

	
 
	NewIndustryResolver(&object, tile, &ind, type);
 
	object.GetVariable = IndustryLocationGetVariable;
src/newgrf_industries.h
Show inline comments
 
@@ -37,7 +37,7 @@ uint32 IndustryGetVariable(const Resolve
 
uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile);
 
uint32 GetIndustryIDAtOffset(TileIndex new_tile, const Industry *i, uint32 cur_grfid);
 
void IndustryProductionCallback(Industry *ind, int reason);
 
CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits);
 
CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint layout, uint32 seed, uint16 initial_random_bits, Owner founder);
 
bool CheckIfCallBackAllowsAvailability(IndustryType type, IndustryAvailabilityCallType creation_type);
 

	
 
IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id);
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -258,9 +258,10 @@ extern bool IsSlopeRefused(Slope current
 
 * @param gfx           Gfx of the tile.
 
 * @param itspec_index  Layout.
 
 * @param initial_random_bits Random bits of industry after construction
 
 * @param founder       Industry founder
 
 * @return Suceeded or failed command.
 
 */
 
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits)
 
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder)
 
{
 
	Industry ind;
 
	ind.index = INVALID_INDUSTRY;
 
@@ -268,6 +269,7 @@ CommandCost PerformIndustryTileSlopeChec
 
	ind.location.w = 0;
 
	ind.type = type;
 
	ind.random = initial_random_bits;
 
	ind.founder = founder;
 

	
 
	uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, itspec_index, gfx, &ind, ind_tile);
 
	if (callback_res == CALLBACK_FAILED) {
src/newgrf_industrytiles.h
Show inline comments
 
@@ -27,7 +27,7 @@ enum IndustryAnimationTrigger {
 

	
 
bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
 
uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile);
 
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits);
 
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index, uint16 initial_random_bits, Owner founder);
 

	
 
void AnimateNewIndustryTile(TileIndex tile);
 
bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random = Random());
0 comments (0 inline, 0 general)