Mercurial > hg > openttd
diff src/town_cmd.cpp @ 14696:d10e739d1e4c draft
(svn r19279) -Codechange: CheckIfAuthorityAllowsNewStation() returns CommandCost.
author | alberth <alberth@openttd.org> |
---|---|
date | Sat, 27 Feb 2010 17:42:55 +0000 (2010-02-27) |
parents | 6cc90e733c5d |
children | 74b0a8a64ff5 |
line wrap: on
line diff
--- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2662,20 +2662,19 @@ * 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); }