mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r16277) -Codechange: enumerize values and remove unneeded values used for testing town rating
This commit is contained in:
parent
d9e1de0281
commit
e1e6687bfd
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/* check if you're allowed to remove the street/bridge/tunnel/industry
|
||||
/* 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 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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue