summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-05-11 11:55:41 +0000
committersmatz <smatz@openttd.org>2009-05-11 11:55:41 +0000
commite1e6687bfd2e8e41ecafa3e4b9d5ff7d38aebcb6 (patch)
tree8d588eadde2aed571ec6d103ee296dfdf9791bf7
parentd9e1de0281152f30a2df04ccad9b6cda4d34f51d (diff)
downloadopenttd-e1e6687bfd2e8e41ecafa3e4b9d5ff7d38aebcb6.tar.xz
(svn r16277) -Codechange: enumerize values and remove unneeded values used for testing town rating
-rw-r--r--src/town.h7
-rw-r--r--src/town_cmd.cpp28
-rw-r--r--src/town_type.h17
3 files changed, 30 insertions, 22 deletions
diff --git a/src/town.h b/src/town.h
index 384ff9b3a..fe50fd17a 100644
--- a/src/town.h
+++ b/src/town.h
@@ -258,11 +258,10 @@ void ShowTownViewWindow(TownID town);
void ExpandTown(Town *t);
Town *CreateRandomTown(uint attempts, TownSize size, bool city, TownLayout layout);
-enum {
+enum TownRatingCheckType {
ROAD_REMOVE = 0,
- UNMOVEABLE_REMOVE = 1,
TUNNELBRIDGE_REMOVE = 1,
- INDUSTRY_REMOVE = 2
+ TOWN_RATING_CHECK_TYPE_COUNT,
};
/** This is the number of ticks between towns being processed for building new
@@ -286,7 +285,7 @@ enum {
TOWN_HAS_STADIUM = 2 ///< There can be only one stadium by town.
};
-bool CheckforTownRating(DoCommandFlag flags, Town *t, byte type);
+bool CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type);
static inline HouseSpec *GetHouseSpecs(HouseID house_id)
{
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 200f650a7..dc53528c8 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -2810,27 +2810,29 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
}
}
-/* penalty for removing town-owned stuff */
-static const int _default_rating_settings [3][3] = {
- /* ROAD_REMOVE, TUNNELBRIDGE_REMOVE, INDUSTRY_REMOVE */
- { 0, 128, 384}, // Permissive
- { 48, 192, 480}, // Neutral
- { 96, 384, 768}, // Hostile
-};
-
-bool CheckforTownRating(DoCommandFlag flags, Town *t, byte type)
+bool CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
{
/* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
- if (t == NULL || !IsValidCompanyID(_current_company) || _cheats.magic_bulldozer.value)
+ if (t == NULL || !IsValidCompanyID(_current_company) ||
+ _cheats.magic_bulldozer.value || (flags & DC_NO_TEST_TOWN_RATING)) {
return true;
+ }
+
+ /* minimum rating needed to be allowed to remove stuff */
+ static const int needed_rating[][TOWN_RATING_CHECK_TYPE_COUNT] = {
+ /* ROAD_REMOVE, TUNNELBRIDGE_REMOVE */
+ { RATING_ROAD_NEEDED_PERMISSIVE, RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE}, // Permissive
+ { RATING_ROAD_NEEDED_NEUTRAL, RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL}, // Neutral
+ { RATING_ROAD_NEEDED_HOSTILE, RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE}, // Hostile
+ };
- /* check if you're allowed to remove the street/bridge/tunnel/industry
+ /* check if you're allowed to remove the road/bridge/tunnel
* owned by a town no removal if rating is lower than ... depends now on
* difficulty setting. Minimum town rating selected by difficulty level
*/
- int modemod = _default_rating_settings[_settings_game.difficulty.town_council_tolerance][type];
+ int needed = needed_rating[_settings_game.difficulty.town_council_tolerance][type];
- if (GetRating(t) < 16 + modemod && !(flags & DC_NO_TEST_TOWN_RATING)) {
+ if (GetRating(t) < needed) {
SetDParam(0, t->index);
_error_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS;
return false;
diff --git a/src/town_type.h b/src/town_type.h
index 179254b73..a032c8bea 100644
--- a/src/town_type.h
+++ b/src/town_type.h
@@ -50,12 +50,19 @@ enum {
RATING_STATION_UP_STEP = 12, ///< when a town grows, company gains reputation for all well serviced stations ...
RATING_STATION_DOWN_STEP = -15, ///< ... but loses for bad serviced stations
- RATING_TUNNEL_BRIDGE_DOWN_STEP = -250,
- RATING_TUNNEL_BRIDGE_MINIMUM = 0,
+ RATING_TUNNEL_BRIDGE_DOWN_STEP = -250, ///< penalty for removing town owned tunnel or bridge
+ RATING_TUNNEL_BRIDGE_MINIMUM = 0, ///< minimum rating after removing tunnel or bridge
+ RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE = 144, ///< rating needed, "Permissive" difficulty settings
+ RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL = 208, ///< "Neutral"
+ RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE = 400, ///< "Hostile"
+
+ RATING_ROAD_DOWN_STEP_INNER = -50, ///< removing a roadpiece in the middle
+ RATING_ROAD_DOWN_STEP_EDGE = -18, ///< removing a roadpiece at the edge
+ RATING_ROAD_MINIMUM = -100, ///< minimum rating after removing town owned road
+ RATING_ROAD_NEEDED_PERMISSIVE = 16, ///< rating needed, "Permissive" difficulty settings
+ RATING_ROAD_NEEDED_NEUTRAL = 64, ///< "Neutral"
+ RATING_ROAD_NEEDED_HOSTILE = 112, ///< "Hostile"
- RATING_ROAD_DOWN_STEP_INNER = -50, ///< removing a roadpiece in the middle
- RATING_ROAD_DOWN_STEP_EDGE = -18, ///< removing a roadpiece at the edge
- RATING_ROAD_MINIMUM = -100,
RATING_HOUSE_MINIMUM = RATING_MINIMUM,
RATING_BRIBE_UP_STEP = 200,