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

Function Convert8bitBooleanCallback

src/newgrf_commons.cpp:562–570  ·  view source on GitHub ↗

* Converts a callback result into a boolean. * For grf version < 8 the first 8 bit of the result are 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

560 * @return Boolean value. True if cb_res != 0.
561 */
562bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
563{
564 assert(cb_res != CALLBACK_FAILED); // We do not know what to return
565
566 if (grffile->grf_version < 8) return GB(cb_res, 0, 8) != 0;
567
568 if (cb_res > 1) ErrorUnknownCallbackResult(grffile->grfid, cbid, cb_res);
569 return cb_res != 0;
570}
571
572/**
573 * Allocate a spritelayout for \a num_sprites building sprites.

Callers 6

NewHouseTileLoopFunction · 0.85
CmdBuildRailStationFunction · 0.85
CmdBuildRoadStopFunction · 0.85
IsStationAvailableFunction · 0.85
TryBuildTownHouseFunction · 0.85
IsRoadStopAvailableFunction · 0.85

Calls 2

GBFunction · 0.85

Tested by

no test coverage detected