Changeset - r14677:2cb23a1debe3
[Not reviewed]
master
0 3 0
alberth - 14 years ago 2010-02-27 10:21:59
alberth@openttd.org
(svn r19269) -Codechange: PerformIndustryTileSlopeCheck() returns a succeeded or failed command.
3 files changed with 23 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1349,7 +1349,9 @@ static CommandCost CheckIfIndustryTilesA
 

	
 
			if (HasBit(its->callback_mask, CBM_INDT_SHAPE_CHECK)) {
 
				custom_shape = true;
 
				if (!PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index)) return_cmd_error(_error_message);
 
				CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index);
 
				ret.SetGlobalErrorMessage();
 
				if (ret.Failed()) return ret;
 
			} else {
 
				Slope tileh = GetTileSlope(cur_tile, NULL);
 
				refused_slope |= IsSlopeRefused(tileh, its->slopes_refused);
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -238,7 +238,16 @@ bool DrawNewIndustryTile(TileInfo *ti, I
 

	
 
extern bool IsSlopeRefused(Slope current, Slope refused);
 

	
 
bool PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index)
 
/** Check the slope of a tile of a new industry.
 
 * @param ind_base_tile Base tile of the industry.
 
 * @param ind_tile      Tile to check.
 
 * @param its           Tile specification.
 
 * @param type          Industry type.
 
 * @param gfx           Gfx of the tile.
 
 * @param itspec_index  Layout.
 
 * @return Suceeded or failed command.
 
 */
 
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index)
 
{
 
	Industry ind;
 
	ind.index = INVALID_INDUSTRY;
 
@@ -248,12 +257,14 @@ bool PerformIndustryTileSlopeCheck(TileI
 

	
 
	uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, itspec_index, gfx, &ind, ind_tile);
 
	if (callback_res == CALLBACK_FAILED) {
 
		return !IsSlopeRefused(GetTileSlope(ind_tile, NULL), its->slopes_refused);
 
		if (!IsSlopeRefused(GetTileSlope(ind_tile, NULL), its->slopes_refused)) return CommandCost();
 
		return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	}
 
	if (its->grf_prop.grffile->grf_version < 7) {
 
		return callback_res != 0;
 
		if (callback_res != 0) return CommandCost();
 
		return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	}
 
	if (callback_res == 0x400) return true;
 
	if (callback_res == 0x400) return CommandCost();
 

	
 
	/* Copy some parameters from the registers to the error message text ref. stack */
 
	SwitchToErrorRefStack();
 
@@ -261,10 +272,10 @@ bool PerformIndustryTileSlopeCheck(TileI
 
	SwitchToNormalRefStack();
 

	
 
	switch (callback_res) {
 
		case 0x401: _error_message = STR_ERROR_SITE_UNSUITABLE;                 return false;
 
		case 0x402: _error_message = STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST; return false;
 
		case 0x403: _error_message = STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT;     return false;
 
		default: _error_message = GetGRFStringID(its->grf_prop.grffile->grfid, 0xD000 + callback_res); return false;
 
		case 0x401: return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
		case 0x402: return_cmd_error(STR_ERROR_CAN_ONLY_BE_BUILT_IN_RAINFOREST);
 
		case 0x403: return_cmd_error(STR_ERROR_CAN_ONLY_BE_BUILT_IN_DESERT);
 
		default:    return_cmd_error(GetGRFStringID(its->grf_prop.grffile->grfid, 0xD000 + callback_res));
 
	}
 
}
 

	
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);
 
bool PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index);
 
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, uint itspec_index);
 

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