MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ConvertBooleanCallback

Function ConvertBooleanCallback

src/newgrf_commons.cpp:543–551  ·  view source on GitHub ↗

* Converts a callback result into a boolean. * For grf version < 8 the result is checked for zero or non-zero. * For grf version >= 8 the callback result must be 0 or 1. * @param grffile NewGRF returning the value. * @param cbid Callback returning the value. * @param cb_res Callback result. * @return Boolean value. True if cb_res != 0. */

Source from the content-addressed store, hash-verified

541 * @return Boolean value. True if cb_res != 0.
542 */
543bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
544{
545 assert(cb_res != CALLBACK_FAILED); // We do not know what to return
546
547 if (grffile->grf_version < 8) return cb_res != 0;
548
549 if (cb_res > 1) ErrorUnknownCallbackResult(grffile->grfid, cbid, cb_res);
550 return cb_res != 0;
551}
552
553/**
554 * Converts a callback result into a boolean.

Callers 11

GetFoundation_IndustryFunction · 0.85
ProduceIndustryGoodsFunction · 0.85
TerraformTile_IndustryFunction · 0.85
DrawNewHouseTileFunction · 0.85
CanDeleteHouseFunction · 0.85
DrawNewAirportTileFunction · 0.85
TerraformTile_ObjectFunction · 0.85
DrawNewIndustryTileFunction · 0.85
GetFoundation_TownFunction · 0.85
TerraformTile_TownFunction · 0.85

Calls 1

Tested by

no test coverage detected