(svn r23147) -Change: [NewGRF v8] Unify the return values of boolean callbacks, and check the results for validity.
This commit is contained in:
@@ -273,7 +273,7 @@ static Foundation GetFoundation_Town(TileIndex tile, Slope tileh)
|
||||
const HouseSpec *hs = HouseSpec::Get(hid);
|
||||
if (hs->grf_prop.spritegroup[0] != NULL && HasBit(hs->callback_mask, CBM_HOUSE_DRAW_FOUNDATIONS)) {
|
||||
uint32 callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, hid, Town::GetByTile(tile), tile);
|
||||
if (callback_res == 0) return FOUNDATION_NONE;
|
||||
if (callback_res != CALLBACK_FAILED && !ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DRAW_FOUNDATIONS, callback_res)) return FOUNDATION_NONE;
|
||||
}
|
||||
}
|
||||
return FlatteningFoundation(tileh);
|
||||
@@ -2207,7 +2207,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
||||
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) {
|
||||
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house, t, tile, true, random_bits);
|
||||
if (callback_res != CALLBACK_FAILED && GB(callback_res, 0, 8) == 0) continue;
|
||||
if (callback_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_ALLOW_CONSTRUCTION, callback_res)) continue;
|
||||
}
|
||||
|
||||
/* build the house */
|
||||
@@ -3068,7 +3068,7 @@ static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlag flags, int z
|
||||
if (HasBit(hs->callback_mask, CBM_HOUSE_AUTOSLOPE)) {
|
||||
/* If the callback fails, allow autoslope. */
|
||||
uint16 res = GetHouseCallback(CBID_HOUSE_AUTOSLOPE, 0, 0, house, Town::GetByTile(tile), tile);
|
||||
if ((res != 0) && (res != CALLBACK_FAILED)) allow_terraform = false;
|
||||
if (res != CALLBACK_FAILED && ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_AUTOSLOPE, res)) allow_terraform = false;
|
||||
}
|
||||
|
||||
if (allow_terraform) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
|
||||
|
Reference in New Issue
Block a user