Add: [NewGRF] All callbacks returning D0xx strings, have now the option to return any string id via register 0x100.

This commit is contained in:
frosch
2025-05-06 17:28:51 +02:00
committed by frosch
parent 84bc78fd8f
commit c6fa5022cb
11 changed files with 114 additions and 54 deletions

View File

@@ -862,15 +862,19 @@ static void GetTileDesc_Town(TileIndex tile, TileDesc &td)
td.str = hs->building_name;
td.town_can_upgrade = !IsHouseProtected(tile);
uint16_t callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, Town::GetByTile(tile), tile);
std::array<int32_t, 1> regs100;
uint16_t callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, Town::GetByTile(tile), tile, regs100);
if (callback_res != CALLBACK_FAILED && callback_res != 0x400) {
if (callback_res > 0x400) {
StringID new_name = STR_NULL;
if (callback_res == 0x40F) {
new_name = GetGRFStringID(hs->grf_prop.grfid, static_cast<GRFStringID>(regs100[0]));
} else if (callback_res > 0x400) {
ErrorUnknownCallbackResult(hs->grf_prop.grfid, CBID_HOUSE_CUSTOM_NAME, callback_res);
} else {
StringID new_name = GetGRFStringID(hs->grf_prop.grfid, GRFSTR_MISC_GRF_TEXT + callback_res);
if (new_name != STR_NULL && new_name != STR_UNDEFINED) {
td.str = new_name;
}
new_name = GetGRFStringID(hs->grf_prop.grfid, GRFSTR_MISC_GRF_TEXT + callback_res);
}
if (new_name != STR_NULL && new_name != STR_UNDEFINED) {
td.str = new_name;
}
}