1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-02-03 18:08:14 +01:00

Codechange: Use EncodedString for error messages. (#13569)

This commit is contained in:
Peter Nelson
2025-02-16 10:04:32 +00:00
committed by GitHub
parent 43c7865ca2
commit 2d7d085e8e
55 changed files with 426 additions and 390 deletions

View File

@@ -731,13 +731,11 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlags flags)
if (!_cheats.magic_bulldozer.value && !flags.Test(DoCommandFlag::NoTestTownRating)) {
/* NewGRFs can add indestructible houses. */
if (rating > RATING_MAXIMUM) {
SetDParam(0, t->index);
return CommandCost(CMD_ERROR);
}
/* If town authority controls removal, check the company's rating. */
if (rating > t->ratings[_current_company] && _settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) {
SetDParam(0, t->index);
return CommandCost(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS);
return CommandCostWithParam(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS, t->index);
}
}
}
@@ -1020,10 +1018,14 @@ bool CheckTownRoadTypes()
if (min_date <= TimerGameCalendar::date) return true;
if (min_date < INT32_MAX) {
SetDParam(0, min_date);
ShowErrorMessage(STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_YET, STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_YET_EXPLANATION, WL_CRITICAL);
ShowErrorMessage(
GetEncodedString(STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_YET),
GetEncodedString(STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_YET_EXPLANATION, min_date),
WL_CRITICAL);
} else {
ShowErrorMessage(STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_AT_ALL, STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_AT_ALL_EXPLANATION, WL_CRITICAL);
ShowErrorMessage(
GetEncodedString(STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_AT_ALL),
GetEncodedString(STR_ERROR_NO_TOWN_ROADTYPES_AVAILABLE_AT_ALL_EXPLANATION), WL_CRITICAL);
}
return false;
}
@@ -2468,7 +2470,7 @@ bool GenerateTowns(TownLayout layout)
/* If there are no towns at all and we are generating new game, bail out */
if (Town::GetNumItems() == 0 && _game_mode != GM_EDITOR) {
ShowErrorMessage(STR_ERROR_COULD_NOT_CREATE_TOWN, INVALID_STRING_ID, WL_CRITICAL);
ShowErrorMessage(GetEncodedString(STR_ERROR_COULD_NOT_CREATE_TOWN), {}, WL_CRITICAL);
}
return false; // we are still without a town? we failed, simply
@@ -3598,7 +3600,7 @@ static CommandCost TownActionBribe(Town *t, DoCommandFlags flags)
/* only show error message to the executing player. All errors are handled command.c
* but this is special, because it can only 'fail' on a DoCommandFlag::Execute */
if (IsLocalCompany()) ShowErrorMessage(STR_ERROR_BRIBE_FAILED, INVALID_STRING_ID, WL_INFO);
if (IsLocalCompany()) ShowErrorMessage(GetEncodedString(STR_ERROR_BRIBE_FAILED), {}, WL_INFO);
/* decrease by a lot!
* ChangeTownRating is only for stuff in demolishing. Bribe failure should
@@ -3898,8 +3900,7 @@ CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlags flag
if (t->ratings[_current_company] > RATING_VERYPOOR) return CommandCost();
SetDParam(0, t->index);
return CommandCost(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS);
return CommandCostWithParam(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS, t->index);
}
/**
@@ -4068,8 +4069,7 @@ CommandCost CheckforTownRating(DoCommandFlags flags, Town *t, TownRatingCheckTyp
int needed = needed_rating[_settings_game.difficulty.town_council_tolerance][type];
if (GetRating(t) < needed) {
SetDParam(0, t->index);
return CommandCost(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS);
return CommandCostWithParam(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS, t->index);
}
return CommandCost();