summaryrefslogtreecommitdiff
path: root/src/newgrf_industrytiles.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-02-27 10:21:59 +0000
committeralberth <alberth@openttd.org>2010-02-27 10:21:59 +0000
commitb33264f30f598244f24fae9ed2aca7adc037f831 (patch)
treec275bc0fa5b83c7c459dd5973adc8d7b4bed8d53 /src/newgrf_industrytiles.cpp
parent1c66ce9ea3affb6c33389dd0ac3b3c2a832fa335 (diff)
downloadopenttd-b33264f30f598244f24fae9ed2aca7adc037f831.tar.xz
(svn r19269) -Codechange: PerformIndustryTileSlopeCheck() returns a succeeded or failed command.
Diffstat (limited to 'src/newgrf_industrytiles.cpp')
-rw-r--r--src/newgrf_industrytiles.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index 63e8b7524..26905c004 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -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));
}
}