* 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. */
| 541 | * @return Boolean value. True if cb_res != 0. |
| 542 | */ |
| 543 | bool 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. |
no test coverage detected