diff options
author | rubidium <rubidium@openttd.org> | 2010-11-24 23:08:12 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-11-24 23:08:12 +0000 |
commit | 31a5f8f04388fbe5fccec5441e3acb2727cf3772 (patch) | |
tree | b4d0e10862a2b2dde2f93301ba95084e70d49535 | |
parent | 753b1ca0a7f6dec17be047680cd78023af27ced9 (diff) | |
download | openttd-31a5f8f04388fbe5fccec5441e3acb2727cf3772.tar.xz |
(svn r21314) -Fix [FS#4253]: [NewGRF] (Hopefully) make callback 157 behave more like TTDPatch does, i.e. fall back to the default check when the callback is not yielding a result for a tile instead of disallowing building the object
-rw-r--r-- | src/object_cmd.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index eab4ac075..8958a714a 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -202,18 +202,20 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 } /* So, now the surface is checked... check the slope of said surface. */ - if (HasBit(spec->callback_mask, CBM_OBJ_SLOPE_CHECK)) { - TILE_AREA_LOOP(t, ta) { + int allowed_z; + if (GetTileSlope(tile, (uint*)&allowed_z) != SLOPE_FLAT) allowed_z += TILE_HEIGHT; + + TILE_AREA_LOOP(t, ta) { + uint16 callback = CALLBACK_FAILED; + if (HasBit(spec->callback_mask, CBM_OBJ_SLOPE_CHECK)) { TileIndex diff = t - tile; - uint16 callback = GetObjectCallback(CBID_OBJECT_LAND_SLOPE_CHECK, GetTileSlope(t, NULL), TileY(diff) << 4 | TileX(diff), spec, NULL, t); - if (callback != 0) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); + callback = GetObjectCallback(CBID_OBJECT_LAND_SLOPE_CHECK, GetTileSlope(t, NULL), TileY(diff) << 4 | TileX(diff), spec, NULL, t); } - } else { - /* Check whether the ground is flat enough. */ - int allowed_z = -1; - TILE_AREA_LOOP(t, ta) { - /* We'll do the bridge test later; it's quite custom. */ + + if (callback == CALLBACK_FAILED) { cost.AddCost(CheckBuildableTile(t, 0, allowed_z, false)); + } else if (callback != 0) { + return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); } } } |