From 032346cf8a21d1af604db8aecf5f03d58997e418 Mon Sep 17 00:00:00 2001 From: frosch Date: Wed, 11 Feb 2009 18:50:47 +0000 Subject: (svn r15452) -Codechange: Add DC_NO_MODIFY_TOWN_RATING. --- src/command_type.h | 1 + src/road_cmd.cpp | 2 +- src/town.h | 2 +- src/town_cmd.cpp | 15 +++++++++++---- src/tree_cmd.cpp | 4 ++-- src/tunnelbridge_cmd.cpp | 4 ++-- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/command_type.h b/src/command_type.h index 883a0f7bd..c4ebde6d6 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -304,6 +304,7 @@ enum DoCommandFlag { 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); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 61b389540..1ff13d328 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -157,7 +157,7 @@ bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType } rating_decrease = RATING_ROAD_DOWN_STEP_INNER; } - ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM); + ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM, flags); return true; } diff --git a/src/town.h b/src/town.h index 2aac3bd4e..0f544de22 100644 --- a/src/town.h +++ b/src/town.h @@ -355,7 +355,7 @@ void UpdateTownMaxPass(Town *t); 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); diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index b16afa08c..d4e23ee99 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -537,7 +537,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlag flags) } } - ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM); + ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM, flags); if (flags & DC_EXEC) { ClearTownHouse(t, tile); } @@ -2278,7 +2278,7 @@ static void TownActionBribe(Town *t) 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 @@ static int GetRating(const Town *t) 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; diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 5dc5a00f1..763eeb3c7 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -389,7 +389,7 @@ CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 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 @@ static CommandCost ClearTile_Trees(TileIndex tile, DoCommandFlag flags) 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); diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 763213e01..585be6ed5 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -617,7 +617,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags) /* 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 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) /* 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) { -- cgit v1.2.3-54-g00ecf