|
@@ -519,14 +519,14 @@ static CommandCost ClearTile_Town(TileIn
|
|
|
if (rating > t->ratings[_current_player] && !(flags & DC_NO_TOWN_RATING) && !_cheats.magic_bulldozer.value) {
|
|
|
SetDParam(0, t->index);
|
|
|
return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM);
|
|
|
if (flags & DC_EXEC) {
|
|
|
ChangeTownRating(t, -rating, RATING_HOUSE_MINIMUM);
|
|
|
ClearTownHouse(t, tile);
|
|
|
}
|
|
|
|
|
|
return cost;
|
|
|
}
|
|
|
|
|
@@ -2258,29 +2258,12 @@ Town *ClosestTownFromTile(TileIndex tile
|
|
|
return GetTownByTile(tile);
|
|
|
} else {
|
|
|
return CalcClosestTownFromTile(tile, threshold);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static bool _town_rating_test = false;
|
|
|
|
|
|
void SetTownRatingTestMode(bool mode)
|
|
|
{
|
|
|
static int ref_count = 0;
|
|
|
if (mode) {
|
|
|
if (ref_count == 0) {
|
|
|
Town *t;
|
|
|
FOR_ALL_TOWNS(t) t->test_rating = t->ratings[_current_player];
|
|
|
}
|
|
|
ref_count++;
|
|
|
} else {
|
|
|
assert(ref_count > 0);
|
|
|
ref_count--;
|
|
|
}
|
|
|
_town_rating_test = !(ref_count == 0);
|
|
|
}
|
|
|
|
|
|
void ChangeTownRating(Town *t, int add, int max)
|
|
|
{
|
|
|
int rating;
|
|
|
|
|
|
/* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */
|
|
@@ -2289,30 +2272,26 @@ void ChangeTownRating(Town *t, int add,
|
|
|
(_cheats.magic_bulldozer.value && add < 0)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
SetBit(t->have_ratings, _current_player);
|
|
|
|
|
|
rating = _town_rating_test ? t->test_rating : t->ratings[_current_player];
|
|
|
rating = t->ratings[_current_player];
|
|
|
|
|
|
if (add < 0) {
|
|
|
if (rating > max) {
|
|
|
rating += add;
|
|
|
if (rating < max) rating = max;
|
|
|
}
|
|
|
} else {
|
|
|
if (rating < max) {
|
|
|
rating += add;
|
|
|
if (rating > max) rating = max;
|
|
|
}
|
|
|
}
|
|
|
if (_town_rating_test) {
|
|
|
t->test_rating = rating;
|
|
|
} else {
|
|
|
t->ratings[_current_player] = rating;
|
|
|
}
|
|
|
t->ratings[_current_player] = rating;
|
|
|
}
|
|
|
|
|
|
/* penalty for removing town-owned stuff */
|
|
|
static const int _default_rating_settings [3][3] = {
|
|
|
/* ROAD_REMOVE, TUNNELBRIDGE_REMOVE, INDUSTRY_REMOVE */
|
|
|
{ 0, 128, 384}, // Permissive
|
|
@@ -2331,13 +2310,13 @@ bool CheckforTownRating(uint32 flags, To
|
|
|
/* check if you're allowed to remove the street/bridge/tunnel/industry
|
|
|
* owned by a town no removal if rating is lower than ... depends now on
|
|
|
* difficulty setting. Minimum town rating selected by difficulty level
|
|
|
*/
|
|
|
modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type];
|
|
|
|
|
|
if ((_town_rating_test ? t->test_rating : t->ratings[_current_player]) < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
|
|
|
if (t->ratings[_current_player] < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
|
|
|
SetDParam(0, t->index);
|
|
|
_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return true;
|