Codechange: Make TownRatingCheckType an enum class. (#14652)
This commit is contained in:
@@ -282,7 +282,7 @@ CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, R
|
||||
|
||||
/* check if you're allowed to remove the street owned by a town
|
||||
* removal allowance depends on difficulty setting */
|
||||
CommandCost ret = CheckforTownRating(flags, t, ROAD_REMOVE);
|
||||
CommandCost ret = CheckforTownRating(flags, t, TownRatingCheckType::RoadRemove);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
/* Get a bitmask of which neighbouring roads has a tile */
|
||||
@@ -2492,7 +2492,7 @@ CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_
|
||||
* acceptance of destructive actions. */
|
||||
if (owner == OWNER_TOWN) {
|
||||
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
||||
CommandCost ret = CheckforTownRating({}, t, tt == MP_TUNNELBRIDGE ? TUNNELBRIDGE_REMOVE : ROAD_REMOVE);
|
||||
CommandCost ret = CheckforTownRating({}, t, tt == MP_TUNNELBRIDGE ? TownRatingCheckType::TunnelBridgeRemove : TownRatingCheckType::RoadRemove);
|
||||
if (ret.Failed()) {
|
||||
error = std::move(ret);
|
||||
continue;
|
||||
|
||||
@@ -245,10 +245,10 @@ enum TownCouncilAttitudes {
|
||||
* Action types that a company must ask permission for to a town authority.
|
||||
* @see CheckforTownRating
|
||||
*/
|
||||
enum TownRatingCheckType {
|
||||
ROAD_REMOVE = 0, ///< Removal of a road owned by the town.
|
||||
TUNNELBRIDGE_REMOVE = 1, ///< Removal of a tunnel or bridge owned by the town.
|
||||
TOWN_RATING_CHECK_TYPE_COUNT, ///< Number of town checking action types.
|
||||
enum class TownRatingCheckType : uint8_t {
|
||||
RoadRemove, ///< Removal of a road owned by the town.
|
||||
TunnelBridgeRemove, ///< Removal of a tunnel or bridge owned by the town.
|
||||
End,
|
||||
};
|
||||
|
||||
/** Special values for town list window for the data parameter of #InvalidateWindowData. */
|
||||
|
||||
@@ -4388,8 +4388,8 @@ CommandCost CheckforTownRating(DoCommandFlags flags, Town *t, TownRatingCheckTyp
|
||||
}
|
||||
|
||||
/* minimum rating needed to be allowed to remove stuff */
|
||||
static const int needed_rating[][TOWN_RATING_CHECK_TYPE_COUNT] = {
|
||||
/* ROAD_REMOVE, TUNNELBRIDGE_REMOVE */
|
||||
static const int needed_rating[][to_underlying(TownRatingCheckType::End)] = {
|
||||
/* RoadRemove, TunnelBridgeRemove */
|
||||
{ RATING_ROAD_NEEDED_LENIENT, RATING_TUNNEL_BRIDGE_NEEDED_LENIENT}, // Lenient
|
||||
{ RATING_ROAD_NEEDED_NEUTRAL, RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL}, // Neutral
|
||||
{ RATING_ROAD_NEEDED_HOSTILE, RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE}, // Hostile
|
||||
@@ -4400,7 +4400,7 @@ CommandCost CheckforTownRating(DoCommandFlags flags, Town *t, TownRatingCheckTyp
|
||||
* owned by a town no removal if rating is lower than ... depends now on
|
||||
* difficulty setting. Minimum town rating selected by difficulty level
|
||||
*/
|
||||
int needed = needed_rating[_settings_game.difficulty.town_council_tolerance][type];
|
||||
int needed = needed_rating[_settings_game.difficulty.town_council_tolerance][to_underlying(type)];
|
||||
|
||||
if (GetRating(t) < needed) {
|
||||
return CommandCostWithParam(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS, t->index);
|
||||
|
||||
@@ -866,7 +866,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlags flags)
|
||||
|
||||
/* Check if you are allowed to remove the tunnel owned by a town
|
||||
* Removal depends on difficulty settings */
|
||||
ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
|
||||
ret = CheckforTownRating(flags, t, TownRatingCheckType::TunnelBridgeRemove);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
@@ -947,7 +947,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlags flags)
|
||||
|
||||
/* Check if you are allowed to remove the bridge owned by a town
|
||||
* Removal depends on difficulty settings */
|
||||
ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
|
||||
ret = CheckforTownRating(flags, t, TownRatingCheckType::TunnelBridgeRemove);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user