(svn r19269) -Codechange: PerformIndustryTileSlopeCheck() returns a succeeded or failed command.
This commit is contained in:
@@ -238,7 +238,16 @@ bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const Indus
|
||||
|
||||
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(TileIndex ind_base_tile, TileIndex ind_tile,
|
||||
|
||||
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(TileIndex ind_base_tile, TileIndex ind_tile,
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user