diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2662,20 +2662,19 @@ static void UpdateTownUnwanted(Town *t) * Checks whether the local authority allows construction of a new station (rail, road, airport, dock) on the given tile * @param tile The tile where the station shall be constructed. * @param flags Command flags. DC_NO_TEST_TOWN_RATING is tested. + * @return Succeeded or failed command. */ -bool CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags) +CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags) { - if (!Company::IsValidID(_current_company) || (flags & DC_NO_TEST_TOWN_RATING)) return true; + if (!Company::IsValidID(_current_company) || (flags & DC_NO_TEST_TOWN_RATING)) return CommandCost(); Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); - if (t == NULL) return true; - - if (t->ratings[_current_company] > RATING_VERYPOOR) return true; - - _error_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS; + if (t == NULL) return CommandCost(); + + if (t->ratings[_current_company] > RATING_VERYPOOR) return CommandCost(); + SetDParam(0, t->index); - - return false; + return_cmd_error(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS); }