diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -211,6 +211,26 @@ void Town::FillCachedName() const } /** + * Updates the town label of the town after changes in rating. The colour scheme is: + * Red: Appalling and Very poor ratings. + * Orange: Poor and mediocre ratings. + * Yellow: Good rating. + * White: Very good rating (standard). + * Green: Excellent and outstanding ratings. + */ +void Town::UpdateLabel() +{ + if (!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) { + int r = this->ratings[_local_company]; + (this->town_label = 0, r <= RATING_VERYPOOR) || // Appalling and Very Poor + (this->town_label++, r <= RATING_MEDIOCRE) || // Poor and Mediocre + (this->town_label++, r <= RATING_GOOD) || // Good + (this->town_label++, r <= RATING_VERYGOOD) || // Very Good + (this->town_label++, true); // Excellent and Outstanding + } +} + +/** * Get the cost for removing this house * @return the cost (inflation corrected etc) */ @@ -400,15 +420,14 @@ static bool IsCloseToTown(TileIndex tile */ void Town::UpdateVirtCoord() { + this->UpdateLabel(); Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE); if (this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index)); SetDParam(0, this->index); SetDParam(1, this->cache.population); - this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE, - _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN, - STR_VIEWPORT_TOWN); + this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE, this->Label(), STR_VIEWPORT_TOWN); _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(this->index)); @@ -668,7 +687,7 @@ static CommandCost ClearTile_Town(TileIn const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile)); - CommandCost cost(EXPENSES_CONSTRUCTION); + CommandCost cost(EXPENSES_T_DEMOLITION); cost.AddCost(hs->GetRemovalCost()); int rating = hs->remove_rating_decrease; @@ -1905,7 +1924,7 @@ static CommandCost TownCanBePlacedHere(T return_cmd_error(STR_ERROR_SITE_UNSUITABLE); } - return CommandCost(EXPENSES_OTHER); + return CommandCost(EXPENSES_CONSTRUCTION); } /** @@ -1975,7 +1994,7 @@ std::tuple C /* multidimensional arrays have to have defined length of non-first dimension */ static_assert(lengthof(price_mult[0]) == 4); - CommandCost cost(EXPENSES_OTHER, _price[PR_BUILD_TOWN]); + CommandCost cost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_TOWN]); byte mult = price_mult[city][size]; cost.MultiplyCost(mult); @@ -1984,7 +2003,7 @@ std::tuple C TownID new_town = INVALID_TOWN; if (flags & DC_EXEC) { if (cost.GetCost() > GetAvailableMoneyForCommand()) { - return { CommandCost(EXPENSES_OTHER), cost.GetCost(), INVALID_TOWN }; + return { CommandCost(EXPENSES_CONSTRUCTION), cost.GetCost(), INVALID_TOWN }; } Backup old_generating_world(_generating_world, true, FILE_LINE); @@ -3221,7 +3240,7 @@ static CommandCost TownActionBuyRights(T static CommandCost TownActionBribe(Town *t, DoCommandFlag flags) { if (flags & DC_EXEC) { - if (Chance16(1, 14)) { + if (_settings_game.economy.bribe_risky && Chance16(1, 14)) { /* set as unwanted for 6 months */ t->unwanted[_current_company] = 6; @@ -3242,6 +3261,7 @@ static CommandCost TownActionBribe(Town */ if (t->ratings[_current_company] > RATING_BRIBE_DOWN_TO) { t->ratings[_current_company] = RATING_BRIBE_DOWN_TO; + t->UpdateVirtCoord(); SetWindowDirty(WC_TOWN_AUTHORITY, t->index); } } else { @@ -3383,6 +3403,7 @@ static void UpdateTownRating(Town *t) t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM); } + t->UpdateVirtCoord(); SetWindowDirty(WC_TOWN_AUTHORITY, t->index); } @@ -3669,6 +3690,7 @@ void ChangeTownRating(Town *t, int add, } else { SetBit(t->have_ratings, _current_company); t->ratings[_current_company] = rating; + t->UpdateVirtCoord(); SetWindowDirty(WC_TOWN_AUTHORITY, t->index); } }