Mercurial > hg > openttd
changeset 11106:ada4c4d48050 draft
(svn r15452) -Codechange: Add DC_NO_MODIFY_TOWN_RATING.
author | frosch <frosch@openttd.org> |
---|---|
date | Wed, 11 Feb 2009 18:50:47 +0000 |
parents | e62b4d827027 |
children | 60439e4cdc0a |
files | src/command_type.h src/road_cmd.cpp src/town.h src/town_cmd.cpp src/tree_cmd.cpp src/tunnelbridge_cmd.cpp |
diffstat | 6 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/command_type.h +++ b/src/command_type.h @@ -304,6 +304,7 @@ DC_BANKRUPT = 0x040, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases DC_AUTOREPLACE = 0x080, ///< autoreplace/autorenew is in progress, this shall disable vehicle limits when building, and ignore certain restrictions when undoing things (like vehicle attach callback) DC_ALL_TILES = 0x100, ///< allow this command also on MP_VOID tiles + DC_NO_MODIFY_TOWN_RATING = 0x200, ///< do not change town rating }; DECLARE_ENUM_AS_BIT_SET(DoCommandFlag);
--- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -157,7 +157,7 @@ } rating_decrease = RATING_ROAD_DOWN_STEP_INNER; } - ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM); + ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM, flags); return true; }
--- a/src/town.h +++ b/src/town.h @@ -355,7 +355,7 @@ void UpdateTownRadius(Town *t); bool CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags); Town *ClosestTownFromTile(TileIndex tile, uint threshold); -void ChangeTownRating(Town *t, int add, int max); +void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags); HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile); void SetTownRatingTestMode(bool mode); uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t);
--- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -537,7 +537,7 @@ } } - ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM); + ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM, flags); if (flags & DC_EXEC) { ClearTownHouse(t, tile); } @@ -2278,7 +2278,7 @@ InvalidateWindow(WC_TOWN_AUTHORITY, t->index); } } else { - ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM); + ChangeTownRating(t, RATING_BRIBE_UP_STEP, RATING_BRIBE_MAXIMUM, DC_EXEC); } } @@ -2591,10 +2591,17 @@ return t->ratings[_current_company]; } -void ChangeTownRating(Town *t, int add, int max) +/** + * Changes town rating of the current company + * @param t Town to affect + * @param add Value to add + * @param max Minimum (add < 0) resp. maximum (add > 0) rating that should be archievable with this change + * @param flags Command flags, especially DC_NO_MODIFY_TOWN_RATING is tested + */ +void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags) { /* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */ - if (t == NULL || + if (t == NULL || (flags & DC_NO_MODIFY_TOWN_RATING) || !IsValidCompanyID(_current_company) || (_cheats.magic_bulldozer.value && add < 0)) { return;
--- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -389,7 +389,7 @@ if (_game_mode != GM_EDITOR && IsValidCompanyID(_current_company)) { Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); - if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM); + if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM, flags); } if (flags & DC_EXEC) { @@ -532,7 +532,7 @@ if (IsValidCompanyID(_current_company)) { Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); - if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM); + if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM, flags); } num = GetTreeCount(tile);
--- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -617,7 +617,7 @@ /* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until * you have a "Poor" (0) town rating */ if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { - ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); + ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags); } if (flags & DC_EXEC) { @@ -683,7 +683,7 @@ /* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until * you have a "Poor" (0) town rating */ if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { - ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); + ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags); } if (flags & DC_EXEC) {