(svn r23147) -Change: [NewGRF v8] Unify the return values of boolean callbacks, and check the results for validity.

This commit is contained in:
frosch
2011-11-08 17:26:49 +00:00
parent b98c7763de
commit 30874b5e81
11 changed files with 90 additions and 28 deletions

View File

@@ -741,7 +741,7 @@ static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlag flags, int
if (HasBit(spec->callback_mask, CBM_OBJ_AUTOSLOPE)) {
/* If the callback fails, allow autoslope. */
uint16 res = GetObjectCallback(CBID_OBJECT_AUTOSLOPE, 0, 0, spec, Object::GetByTile(tile), tile);
if ((res == 0) || (res == CALLBACK_FAILED)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
if (res == CALLBACK_FAILED || !ConvertBooleanCallback(spec->grf_prop.grffile, CBID_OBJECT_AUTOSLOPE, res)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
} else if (spec->enabled) {
/* allow autoslope */
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);