(svn r19901) -Add: [NewGRF] Access to industry founder (var A7) during callbacks 28 and 2F. (yexo)

This commit is contained in:
frosch 2010-05-29 13:08:50 +00:00
parent 0c1add2d19
commit e296eeb20c
5 changed files with 14 additions and 9 deletions

View File

@ -1321,10 +1321,11 @@ bool IsSlopeRefused(Slope current, Slope refused)
* @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 CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
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 CreateNewIndustryHelper(TileIndex tile, IndustryType type, Do
*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 tile, DoCommandFlag flags, uint32 p1, uin
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);

View File

@ -453,9 +453,10 @@ uint32 IndustryLocationGetVariable(const ResolverObject *object, byte variable,
* @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 CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
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;

View File

@ -37,7 +37,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
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);

View File

@ -258,9 +258,10 @@ extern bool IsSlopeRefused(Slope current, Slope refused);
* @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 PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind
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) {

View File

@ -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());