1
0
Fork 0

Compare commits

...

5 Commits

Author SHA1 Message Date
SamuXarick 61b1c5a1b9
Merge f0382c37ee into 67e56391c7 2025-07-14 22:23:23 +00:00
Peter Nelson 67e56391c7
Fix #8167: No error sub-message when trying to clear protected buildings. (#14444) 2025-07-14 23:23:15 +01:00
Peter Nelson e015e3ecc3
Codefix 3fde611012: AirportMovingDataFlag should be `enum class` (#14435)
`AirportMovingDataFlag` was changed to use `enum class` naming style, but wasn't actually changed to be `enum class`.
2025-07-14 23:22:51 +01:00
Henry Wilson 8330957a4d Codechange: Remove manual memory management from IcuStringIterator 2025-07-14 23:55:24 +02:00
SamuXarick f0382c37ee Fix #12193: [YAPF] Don't use the entire docking area when computing closest station tile
Don't use CalcClosestStationTile for ships. Instead, use a specialized GetShipDestinationTiles which creates a list of possible destination tiles. For docks, it only takes into consideration the tiles that pass both IsDockingTile and IsShipDestinationTile tests. For the other cases it just takes the ship's current dest_tile.

Modified CYapfDestinationTileWaterT class to accept multiple destinations. In this manner, the estimate cost is calculated for each of the destination tiles and the shortest estimate is returned. Some adaptation was necessary to make this possible to work for both the high- and low-level pathfinders and the existing functions. ChooseShipTrack and its FindWaterRegionPath brother both will take the same destination tiles which are calculated at either YapfShipChooseTrack or YapfShipCheckReverse.
2025-02-16 20:54:32 +00:00
8 changed files with 96 additions and 62 deletions

View File

@ -44,7 +44,7 @@ enum AirportTypes : uint8_t {
}; };
/** Flags for airport movement data. */ /** Flags for airport movement data. */
enum AirportMovingDataFlag : uint8_t { enum class AirportMovingDataFlag : uint8_t {
NoSpeedClamp, ///< No speed restrictions. NoSpeedClamp, ///< No speed restrictions.
Takeoff, ///< Takeoff movement. Takeoff, ///< Takeoff movement.
SlowTurn, ///< Turn slowly (mostly used in the air). SlowTurn, ///< Turn slowly (mostly used in the air).

View File

@ -5001,6 +5001,7 @@ STR_ERROR_FLAT_LAND_REQUIRED :{WHITE}Flat lan
STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION :{WHITE}Land sloped in wrong direction STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION :{WHITE}Land sloped in wrong direction
STR_ERROR_CAN_T_DO_THIS :{WHITE}Can't do this... STR_ERROR_CAN_T_DO_THIS :{WHITE}Can't do this...
STR_ERROR_BUILDING_MUST_BE_DEMOLISHED :{WHITE}Building must be demolished first STR_ERROR_BUILDING_MUST_BE_DEMOLISHED :{WHITE}Building must be demolished first
STR_ERROR_BUILDING_IS_PROTECTED :{WHITE}... building is protected
STR_ERROR_CAN_T_CLEAR_THIS_AREA :{WHITE}Can't clear this area... STR_ERROR_CAN_T_CLEAR_THIS_AREA :{WHITE}Can't clear this area...
STR_ERROR_SITE_UNSUITABLE :{WHITE}... site unsuitable STR_ERROR_SITE_UNSUITABLE :{WHITE}... site unsuitable
STR_ERROR_ALREADY_BUILT :{WHITE}... already built STR_ERROR_ALREADY_BUILT :{WHITE}... already built

View File

@ -12,6 +12,40 @@
#include "../tile_cmd.h" #include "../tile_cmd.h"
#include "../waypoint_base.h" #include "../waypoint_base.h"
#include "../ship.h"
/**
* Creates a list containing possible destination tiles for a ship.
* @param v The ship
* return Vector of tiles filled with all possible destinations.
*/
inline std::vector<TileIndex> GetShipDestinationTiles(const Ship *v)
{
std::vector<TileIndex> dest_tiles;
if (v->current_order.IsType(OT_GOTO_STATION)) {
const StationID station = v->current_order.GetDestination().ToStationID();
const BaseStation *st = BaseStation::Get(station);
TileArea ta;
st->GetTileArea(&ta, StationType::Dock);
/* If the dock station is (temporarily) not present, use the station sign to drive near the station. */
if (ta.tile == INVALID_TILE) {
dest_tiles.push_back(st->xy);
} else {
for (const TileIndex &docking_tile : ta) {
if (!IsDockingTile(docking_tile) || !IsShipDestinationTile(docking_tile, station)) continue;
dest_tiles.push_back(docking_tile);
}
}
} else {
dest_tiles.push_back(v->dest_tile);
}
assert(!dest_tiles.empty());
return dest_tiles;
}
/** /**
* Calculates the tile of given station that is closest to a given tile * Calculates the tile of given station that is closest to a given tile

View File

@ -33,8 +33,7 @@ public:
typedef typename Node::Key Key; ///< key to hash tables. typedef typename Node::Key Key; ///< key to hash tables.
protected: protected:
TileIndex dest_tile; std::span<TileIndex> dest_tiles;
TrackdirBits dest_trackdirs;
StationID dest_station; StationID dest_station;
bool has_intermediate_dest = false; bool has_intermediate_dest = false;
@ -42,16 +41,13 @@ protected:
WaterRegionPatchDesc intermediate_dest_region_patch; WaterRegionPatchDesc intermediate_dest_region_patch;
public: public:
void SetDestination(const Ship *v) void SetDestination(const Ship *v, const std::span<TileIndex> destination_tiles)
{ {
this->dest_tiles = destination_tiles;
if (v->current_order.IsType(OT_GOTO_STATION)) { if (v->current_order.IsType(OT_GOTO_STATION)) {
this->dest_station = v->current_order.GetDestination().ToStationID(); this->dest_station = v->current_order.GetDestination().ToStationID();
this->dest_tile = CalcClosestStationTile(this->dest_station, v->tile, StationType::Dock);
this->dest_trackdirs = INVALID_TRACKDIR_BIT;
} else { } else {
this->dest_station = StationID::Invalid(); this->dest_station = StationID::Invalid();
this->dest_tile = v->dest_tile;
this->dest_trackdirs = TrackStatusToTrackdirBits(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER, 0));
} }
} }
@ -73,11 +69,8 @@ public:
/** Called by YAPF to detect if node ends in the desired destination. */ /** Called by YAPF to detect if node ends in the desired destination. */
inline bool PfDetectDestination(Node &n) inline bool PfDetectDestination(Node &n)
{ {
return this->PfDetectDestinationTile(n.segment_last_tile, n.segment_last_td); const TileIndex tile = n.segment_last_tile;
}
inline bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
{
if (this->has_intermediate_dest) { if (this->has_intermediate_dest) {
/* GetWaterRegionInfo is much faster than GetWaterRegionPatchInfo so we try that first. */ /* GetWaterRegionInfo is much faster than GetWaterRegionPatchInfo so we try that first. */
if (GetWaterRegionInfo(tile) != this->intermediate_dest_region_patch) return false; if (GetWaterRegionInfo(tile) != this->intermediate_dest_region_patch) return false;
@ -86,23 +79,14 @@ public:
if (this->dest_station != StationID::Invalid()) return IsDockingTile(tile) && IsShipDestinationTile(tile, this->dest_station); if (this->dest_station != StationID::Invalid()) return IsDockingTile(tile) && IsShipDestinationTile(tile, this->dest_station);
return tile == this->dest_tile && ((this->dest_trackdirs & TrackdirToTrackdirBits(trackdir)) != TRACKDIR_BIT_NONE); assert(this->dest_tiles.size() == 1);
return tile == this->dest_tiles.front();
} }
/** static inline int CalcEstimate(Node &n, TileIndex destination_tile)
* Called by YAPF to calculate cost estimate. Calculates distance to the destination
* adds it to the actual cost from origin and stores the sum to the Node::estimate.
*/
inline bool PfCalcEstimate(Node &n)
{ {
const TileIndex destination_tile = this->has_intermediate_dest ? this->intermediate_dest_tile : this->dest_tile;
static const int dg_dir_to_x_offs[] = { -1, 0, 1, 0 }; static const int dg_dir_to_x_offs[] = { -1, 0, 1, 0 };
static const int dg_dir_to_y_offs[] = { 0, 1, 0, -1 }; static const int dg_dir_to_y_offs[] = { 0, 1, 0, -1 };
if (this->PfDetectDestination(n)) {
n.estimate = n.cost;
return true;
}
TileIndex tile = n.segment_last_tile; TileIndex tile = n.segment_last_tile;
DiagDirection exitdir = TrackdirToExitdir(n.segment_last_td); DiagDirection exitdir = TrackdirToExitdir(n.segment_last_td);
@ -115,8 +99,33 @@ public:
int dmin = std::min(dx, dy); int dmin = std::min(dx, dy);
int dxy = abs(dx - dy); int dxy = abs(dx - dy);
int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2); int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
n.estimate = n.cost + d; int estimate = n.cost + d;
assert(n.estimate >= n.parent->estimate); assert(estimate >= n.parent->estimate);
return estimate;
}
/**
* Called by YAPF to calculate cost estimate. Calculates distance to the destination
* adds it to the actual cost from origin and stores the sum to the Node::estimate.
*/
inline bool PfCalcEstimate(Node &n)
{
if (this->PfDetectDestination(n)) {
n.estimate = n.cost;
return true;
}
int shortest_estimate = std::numeric_limits<int>::max();
if (this->has_intermediate_dest) {
shortest_estimate = this->CalcEstimate(n, this->intermediate_dest_tile);
} else {
for (const TileIndex &destination_tile : this->dest_tiles) {
int estimate = this->CalcEstimate(n, destination_tile);
if (estimate < shortest_estimate) shortest_estimate = estimate;
}
}
n.estimate = shortest_estimate;
return true; return true;
} }
}; };
@ -211,10 +220,10 @@ public:
return result; return result;
} }
static Trackdir ChooseShipTrack(const Ship *v, TileIndex tile, TrackdirBits forward_dirs, TrackdirBits reverse_dirs, static Trackdir ChooseShipTrack(const Ship *v, TileIndex tile, TrackdirBits forward_dirs, TrackdirBits reverse_dirs, const std::span<TileIndex> dest_tiles,
bool &path_found, ShipPathCache &path_cache, Trackdir &best_origin_dir) bool &path_found, ShipPathCache &path_cache, Trackdir &best_origin_dir)
{ {
const std::vector<WaterRegionPatchDesc> high_level_path = YapfShipFindWaterRegionPath(v, tile, NUMBER_OR_WATER_REGIONS_LOOKAHEAD + 1); const std::vector<WaterRegionPatchDesc> high_level_path = YapfShipFindWaterRegionPath(v, tile, NUMBER_OR_WATER_REGIONS_LOOKAHEAD + 1, dest_tiles);
if (high_level_path.empty()) { if (high_level_path.empty()) {
path_found = false; path_found = false;
/* Make the ship move around aimlessly. This prevents repeated pathfinder calls and clearly indicates that the ship is lost. */ /* Make the ship move around aimlessly. This prevents repeated pathfinder calls and clearly indicates that the ship is lost. */
@ -229,7 +238,7 @@ public:
/* Set origin and destination nodes */ /* Set origin and destination nodes */
pf.SetOrigin(v->tile, forward_dirs | reverse_dirs); pf.SetOrigin(v->tile, forward_dirs | reverse_dirs);
pf.SetDestination(v); pf.SetDestination(v, dest_tiles);
const bool is_intermediate_destination = static_cast<int>(high_level_path.size()) >= NUMBER_OR_WATER_REGIONS_LOOKAHEAD + 1; const bool is_intermediate_destination = static_cast<int>(high_level_path.size()) >= NUMBER_OR_WATER_REGIONS_LOOKAHEAD + 1;
if (is_intermediate_destination) pf.SetIntermediateDestination(high_level_path.back()); if (is_intermediate_destination) pf.SetIntermediateDestination(high_level_path.back());
@ -297,9 +306,10 @@ public:
* Called when leaving depot. * Called when leaving depot.
* @param v Ship. * @param v Ship.
* @param trackdir [out] the best of all possible reversed trackdirs. * @param trackdir [out] the best of all possible reversed trackdirs.
* @param dest_tiles list of destination tiles.
* @return true if the reverse direction is better. * @return true if the reverse direction is better.
*/ */
static bool CheckShipReverse(const Ship *v, Trackdir *trackdir) static bool CheckShipReverse(const Ship *v, Trackdir *trackdir, const std::span<TileIndex> dest_tiles)
{ {
bool path_found = false; bool path_found = false;
ShipPathCache dummy_cache; ShipPathCache dummy_cache;
@ -310,13 +320,13 @@ public:
const Trackdir reverse_dir = ReverseTrackdir(v->GetVehicleTrackdir()); const Trackdir reverse_dir = ReverseTrackdir(v->GetVehicleTrackdir());
const TrackdirBits forward_dirs = TrackdirToTrackdirBits(v->GetVehicleTrackdir()); const TrackdirBits forward_dirs = TrackdirToTrackdirBits(v->GetVehicleTrackdir());
const TrackdirBits reverse_dirs = TrackdirToTrackdirBits(reverse_dir); const TrackdirBits reverse_dirs = TrackdirToTrackdirBits(reverse_dir);
(void)ChooseShipTrack(v, v->tile, forward_dirs, reverse_dirs, path_found, dummy_cache, best_origin_dir); (void)ChooseShipTrack(v, v->tile, forward_dirs, reverse_dirs, dest_tiles, path_found, dummy_cache, best_origin_dir);
return path_found && best_origin_dir == reverse_dir; return path_found && best_origin_dir == reverse_dir;
} else { } else {
/* This gets called when a ship suddenly can't move forward, e.g. due to terraforming. */ /* This gets called when a ship suddenly can't move forward, e.g. due to terraforming. */
const DiagDirection entry = ReverseDiagDir(VehicleExitDir(v->direction, v->state)); const DiagDirection entry = ReverseDiagDir(VehicleExitDir(v->direction, v->state));
const TrackdirBits reverse_dirs = DiagdirReachesTrackdirs(entry) & TrackStatusToTrackdirBits(GetTileTrackStatus(v->tile, TRANSPORT_WATER, 0, entry)); const TrackdirBits reverse_dirs = DiagdirReachesTrackdirs(entry) & TrackStatusToTrackdirBits(GetTileTrackStatus(v->tile, TRANSPORT_WATER, 0, entry));
(void)ChooseShipTrack(v, v->tile, TRACKDIR_BIT_NONE, reverse_dirs, path_found, dummy_cache, best_origin_dir); (void)ChooseShipTrack(v, v->tile, TRACKDIR_BIT_NONE, reverse_dirs, dest_tiles, path_found, dummy_cache, best_origin_dir);
*trackdir = path_found && best_origin_dir != INVALID_TRACKDIR ? best_origin_dir : GetRandomTrackdir(reverse_dirs); *trackdir = path_found && best_origin_dir != INVALID_TRACKDIR ? best_origin_dir : GetRandomTrackdir(reverse_dirs);
return true; return true;
} }
@ -420,13 +430,15 @@ struct CYapfShip : CYapfT<CYapfShip_TypesT<CYapfShip, CFollowTrackWater, CShipNo
/** Ship controller helper - path finder invoker. */ /** Ship controller helper - path finder invoker. */
Track YapfShipChooseTrack(const Ship *v, TileIndex tile, bool &path_found, ShipPathCache &path_cache) Track YapfShipChooseTrack(const Ship *v, TileIndex tile, bool &path_found, ShipPathCache &path_cache)
{ {
std::vector<TileIndex> dest_tiles = GetShipDestinationTiles(v);
Trackdir best_origin_dir = INVALID_TRACKDIR; Trackdir best_origin_dir = INVALID_TRACKDIR;
const TrackdirBits origin_dirs = TrackdirToTrackdirBits(v->GetVehicleTrackdir()); const TrackdirBits origin_dirs = TrackdirToTrackdirBits(v->GetVehicleTrackdir());
const Trackdir td_ret = CYapfShip::ChooseShipTrack(v, tile, origin_dirs, TRACKDIR_BIT_NONE, path_found, path_cache, best_origin_dir); const Trackdir td_ret = CYapfShip::ChooseShipTrack(v, tile, origin_dirs, TRACKDIR_BIT_NONE, dest_tiles, path_found, path_cache, best_origin_dir);
return (td_ret != INVALID_TRACKDIR) ? TrackdirToTrack(td_ret) : INVALID_TRACK; return (td_ret != INVALID_TRACKDIR) ? TrackdirToTrack(td_ret) : INVALID_TRACK;
} }
bool YapfShipCheckReverse(const Ship *v, Trackdir *trackdir) bool YapfShipCheckReverse(const Ship *v, Trackdir *trackdir)
{ {
return CYapfShip::CheckShipReverse(v, trackdir); std::vector<TileIndex> dest_tiles = GetShipDestinationTiles(v);
return CYapfShip::CheckShipReverse(v, trackdir, dest_tiles);
} }

View File

@ -175,7 +175,7 @@ public:
inline char TransportTypeChar() const { return '^'; } inline char TransportTypeChar() const { return '^'; }
static std::vector<WaterRegionPatchDesc> FindWaterRegionPath(const Ship *v, TileIndex start_tile, int max_returned_path_length) static std::vector<WaterRegionPatchDesc> FindWaterRegionPath(const Ship *v, TileIndex start_tile, int max_returned_path_length, const std::span<TileIndex> dest_tiles)
{ {
const WaterRegionPatchDesc start_water_region_patch = GetWaterRegionPatchInfo(start_tile); const WaterRegionPatchDesc start_water_region_patch = GetWaterRegionPatchInfo(start_tile);
@ -184,18 +184,7 @@ public:
Tpf pf(std::min(static_cast<int>(Map::Size() * NODES_PER_REGION) / WATER_REGION_NUMBER_OF_TILES, MAX_NUMBER_OF_NODES)); Tpf pf(std::min(static_cast<int>(Map::Size() * NODES_PER_REGION) / WATER_REGION_NUMBER_OF_TILES, MAX_NUMBER_OF_NODES));
pf.SetDestination(start_water_region_patch); pf.SetDestination(start_water_region_patch);
if (v->current_order.IsType(OT_GOTO_STATION)) { for (const TileIndex &tile : dest_tiles) {
StationID station_id = v->current_order.GetDestination().ToStationID();
const BaseStation *station = BaseStation::Get(station_id);
TileArea tile_area;
station->GetTileArea(&tile_area, StationType::Dock);
for (const auto &tile : tile_area) {
if (IsDockingTile(tile) && IsShipDestinationTile(tile, station_id)) {
pf.AddOrigin(GetWaterRegionPatchInfo(tile));
}
}
} else {
TileIndex tile = v->dest_tile;
pf.AddOrigin(GetWaterRegionPatchInfo(tile)); pf.AddOrigin(GetWaterRegionPatchInfo(tile));
} }
@ -292,9 +281,10 @@ struct CYapfRegionWater : CYapfT<CYapfRegion_TypesT<CYapfRegionWater, CRegionNod
* @param v The ship to find a path for. * @param v The ship to find a path for.
* @param start_tile The tile to start searching from. * @param start_tile The tile to start searching from.
* @param max_returned_path_length The maximum length of the path that will be returned. * @param max_returned_path_length The maximum length of the path that will be returned.
* @param dest_tiles List of destination tiles.
* @returns A path of water region patches, or an empty vector if no path was found. * @returns A path of water region patches, or an empty vector if no path was found.
*/ */
std::vector<WaterRegionPatchDesc> YapfShipFindWaterRegionPath(const Ship *v, TileIndex start_tile, int max_returned_path_length) std::vector<WaterRegionPatchDesc> YapfShipFindWaterRegionPath(const Ship *v, TileIndex start_tile, int max_returned_path_length, const std::span<TileIndex> dest_tiles)
{ {
return CYapfRegionWater::FindWaterRegionPath(v, start_tile, max_returned_path_length); return CYapfRegionWater::FindWaterRegionPath(v, start_tile, max_returned_path_length, dest_tiles);
} }

View File

@ -15,6 +15,6 @@
struct Ship; struct Ship;
std::vector<WaterRegionPatchDesc> YapfShipFindWaterRegionPath(const Ship *v, TileIndex start_tile, int max_returned_path_length); std::vector<WaterRegionPatchDesc> YapfShipFindWaterRegionPath(const Ship *v, TileIndex start_tile, int max_returned_path_length, const std::span<TileIndex> dest_tiles);
#endif /* YAPF_SHIP_REGIONS_H */ #endif /* YAPF_SHIP_REGIONS_H */

View File

@ -607,28 +607,25 @@ bool ConvertHexToBytes(std::string_view hex, std::span<uint8_t> bytes)
/** String iterator using ICU as a backend. */ /** String iterator using ICU as a backend. */
class IcuStringIterator : public StringIterator class IcuStringIterator : public StringIterator
{ {
icu::BreakIterator *char_itr; ///< ICU iterator for characters. std::unique_ptr<icu::BreakIterator> char_itr; ///< ICU iterator for characters.
icu::BreakIterator *word_itr; ///< ICU iterator for words. std::unique_ptr<icu::BreakIterator> word_itr; ///< ICU iterator for words.
std::vector<UChar> utf16_str; ///< UTF-16 copy of the string. std::vector<UChar> utf16_str; ///< UTF-16 copy of the string.
std::vector<size_t> utf16_to_utf8; ///< Mapping from UTF-16 code point position to index in the UTF-8 source string. std::vector<size_t> utf16_to_utf8; ///< Mapping from UTF-16 code point position to index in the UTF-8 source string.
public: public:
IcuStringIterator() : char_itr(nullptr), word_itr(nullptr) IcuStringIterator()
{ {
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
this->char_itr = icu::BreakIterator::createCharacterInstance(icu::Locale(_current_language != nullptr ? _current_language->isocode : "en"), status); auto locale = icu::Locale(_current_language != nullptr ? _current_language->isocode : "en");
this->word_itr = icu::BreakIterator::createWordInstance(icu::Locale(_current_language != nullptr ? _current_language->isocode : "en"), status); this->char_itr.reset(icu::BreakIterator::createCharacterInstance(locale, status));
this->word_itr.reset(icu::BreakIterator::createWordInstance(locale, status));
this->utf16_str.push_back('\0'); this->utf16_str.push_back('\0');
this->utf16_to_utf8.push_back(0); this->utf16_to_utf8.push_back(0);
} }
~IcuStringIterator() override ~IcuStringIterator() override = default;
{
delete this->char_itr;
delete this->word_itr;
}
void SetString(std::string_view s) override void SetString(std::string_view s) override
{ {

View File

@ -710,7 +710,7 @@ static void TileLoop_Town(TileIndex tile)
static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlags flags) static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlags flags)
{ {
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED); if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
if (!CanDeleteHouse(tile)) return CMD_ERROR; if (!CanDeleteHouse(tile)) return CommandCost(STR_ERROR_BUILDING_IS_PROTECTED);
const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile)); const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile));
@ -724,7 +724,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlags flags)
if (!_cheats.magic_bulldozer.value && !flags.Test(DoCommandFlag::NoTestTownRating)) { if (!_cheats.magic_bulldozer.value && !flags.Test(DoCommandFlag::NoTestTownRating)) {
/* NewGRFs can add indestructible houses. */ /* NewGRFs can add indestructible houses. */
if (rating > RATING_MAXIMUM) { if (rating > RATING_MAXIMUM) {
return CommandCost(CMD_ERROR); return CommandCost(STR_ERROR_BUILDING_IS_PROTECTED);
} }
/* If town authority controls removal, check the company's rating. */ /* If town authority controls removal, check the company's rating. */
if (rating > t->ratings[_current_company] && _settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) { if (rating > t->ratings[_current_company] && _settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) {