changeset 15266:cc26e230b04a draft

(svn r19901) -Add: [NewGRF] Access to industry founder (var A7) during callbacks 28 and 2F. (yexo)
author frosch <frosch@openttd.org>
date Sat, 29 May 2010 13:08:50 +0000
parents eb88c3f4b864
children dc16deee558a
files src/industry_cmd.cpp src/newgrf_industries.cpp src/newgrf_industries.h src/newgrf_industrytiles.cpp src/newgrf_industrytiles.h
diffstat 5 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1321,10 +1321,11 @@
  * @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 @@
 
 			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 @@
 
 	*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 @@
 		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);
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -453,9 +453,10 @@
  * @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 @@
 	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;
--- a/src/newgrf_industries.h
+++ b/src/newgrf_industries.h
@@ -37,7 +37,7 @@
 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);
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -258,9 +258,10 @@
  * @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 @@
 	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) {
--- a/src/newgrf_industrytiles.h
+++ b/src/newgrf_industrytiles.h
@@ -27,7 +27,7 @@
 
 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());