mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
5 Commits
16537ec0f9
...
911f9170a6
Author | SHA1 | Date |
---|---|---|
|
911f9170a6 | |
|
67e56391c7 | |
|
e015e3ecc3 | |
|
8330957a4d | |
|
bd9d785695 |
|
@ -36,3 +36,8 @@ AITown.FoundTown <- function(tile, size, city, layout, name) { return AITown.Fou
|
||||||
|
|
||||||
AIVehicle.SetNameCompat14 <- AIVehicle.SetName;
|
AIVehicle.SetNameCompat14 <- AIVehicle.SetName;
|
||||||
AIVehicle.SetName <- function(id, name) { return AIVehicle.SetNameCompat14(id, AICompat14.Text(name)); }
|
AIVehicle.SetName <- function(id, name) { return AIVehicle.SetNameCompat14(id, AICompat14.Text(name)); }
|
||||||
|
|
||||||
|
AIBaseStation.IsValidBaseStation <- function(station_id)
|
||||||
|
{
|
||||||
|
return AIStation.IsValidStation(station_id) || AIWaypoint.IsValidWaypoint(station_id);
|
||||||
|
}
|
||||||
|
|
|
@ -81,3 +81,8 @@ GSTown.FoundTown <- function(tile, size, city, layout, name) { return GSTown.Fou
|
||||||
|
|
||||||
GSVehicle.SetNameCompat14 <- GSVehicle.SetName;
|
GSVehicle.SetNameCompat14 <- GSVehicle.SetName;
|
||||||
GSVehicle.SetName <- function(id, name) { return GSVehicle.SetNameCompat14(id, GSCompat14.Text(name)); }
|
GSVehicle.SetName <- function(id, name) { return GSVehicle.SetNameCompat14(id, GSCompat14.Text(name)); }
|
||||||
|
|
||||||
|
GSBaseStation.IsValidBaseStation <- function(station_id)
|
||||||
|
{
|
||||||
|
return GSStation.IsValidStation(station_id) || GSWaypoint.IsValidWaypoint(station_id);
|
||||||
|
}
|
||||||
|
|
|
@ -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).
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
* \li AICargo::CC_NON_POTABLE
|
* \li AICargo::CC_NON_POTABLE
|
||||||
* \li AIVehicleList_Waypoint
|
* \li AIVehicleList_Waypoint
|
||||||
*
|
*
|
||||||
|
* API removals:
|
||||||
|
* \li AIBaseStation::IsValidBaseStation, use AIStation::IsValidStation or AIWaypoint::IsValidWaypoint instead
|
||||||
|
*
|
||||||
* Other changes:
|
* Other changes:
|
||||||
* \li AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType
|
* \li AIBridge::GetBridgeID renamed to AIBridge::GetBridgeType
|
||||||
* \li AIWaypoint::GetWaypointID now returns the StationID of any type of waypoint
|
* \li AIWaypoint::GetWaypointID now returns the StationID of any type of waypoint
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
* \li GSVehicleList_Waypoint
|
* \li GSVehicleList_Waypoint
|
||||||
* \li GSBaseStation::GetOwner
|
* \li GSBaseStation::GetOwner
|
||||||
*
|
*
|
||||||
|
* API removals:
|
||||||
|
* \li GSBaseStation::IsValidBaseStation, use GSStation::IsValidStation or GSWaypoint::IsValidWaypoint instead
|
||||||
|
*
|
||||||
* Other changes:
|
* Other changes:
|
||||||
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
||||||
* \li GSWaypoint::GetWaypointID now returns the StationID of any type of waypoint
|
* \li GSWaypoint::GetWaypointID now returns the StationID of any type of waypoint
|
||||||
|
|
|
@ -21,15 +21,16 @@
|
||||||
*/
|
*/
|
||||||
class ScriptBaseStation : public ScriptObject {
|
class ScriptBaseStation : public ScriptObject {
|
||||||
public:
|
public:
|
||||||
static constexpr StationID STATION_NEW = ::NEW_STATION; ///< Build a new station
|
static constexpr StationID STATION_NEW = ::NEW_STATION; ///< Build a new station or waypoint
|
||||||
static constexpr StationID STATION_JOIN_ADJACENT = ::ADJACENT_STATION; ///< Join an neighbouring station if one exists
|
static constexpr StationID STATION_JOIN_ADJACENT = ::ADJACENT_STATION; ///< Join a neighbouring station or waypoint if one exists
|
||||||
static constexpr StationID STATION_INVALID = ::StationID::Invalid(); ///< Invalid station id.
|
static constexpr StationID STATION_INVALID = ::StationID::Invalid(); ///< Invalid station or waypoint id.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the given basestation is valid and owned by you.
|
* Checks whether the given basestation is valid and owned by you.
|
||||||
* @param station_id The station to check.
|
* @param station_id The station to check.
|
||||||
* @return True if and only if the basestation is valid.
|
* @return True if and only if the basestation is valid.
|
||||||
* @note IsValidBaseStation == (IsValidStation || IsValidWaypoint).
|
* @note IsValidBaseStation == (IsValidStation || IsValidWaypoint).
|
||||||
|
* @api -all
|
||||||
*/
|
*/
|
||||||
static bool IsValidBaseStation(StationID station_id);
|
static bool IsValidBaseStation(StationID station_id);
|
||||||
|
|
||||||
|
@ -43,18 +44,18 @@ public:
|
||||||
static ScriptCompany::CompanyID GetOwner(StationID station_id);
|
static ScriptCompany::CompanyID GetOwner(StationID station_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of a basestation.
|
* Get the name of a station or waypoint.
|
||||||
* @param station_id The basestation to get the name of.
|
* @param station_id The station or waypoint to get the name of.
|
||||||
* @pre IsValidBaseStation(station_id).
|
* @pre IsValidStation(station_id) || IsValidWaypoint(station_id).
|
||||||
* @return The name of the station.
|
* @return The name of the station or waypoint.
|
||||||
*/
|
*/
|
||||||
static std::optional<std::string> GetName(StationID station_id);
|
static std::optional<std::string> GetName(StationID station_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name this basestation.
|
* Set the name of a station or waypoint.
|
||||||
* @param station_id The basestation to set the name of.
|
* @param station_id The station or waypoint to set the name of.
|
||||||
* @param name The new name of the station (can be either a raw string, or a ScriptText object).
|
* @param name The new name of the station or waypoint (can be either a raw string, or a ScriptText object).
|
||||||
* @pre IsValidBaseStation(station_id).
|
* @pre IsValidStation(station_id) || IsValidWaypoint(station_id).
|
||||||
* @pre name != null && len(name) != 0.
|
* @pre name != null && len(name) != 0.
|
||||||
* @game @pre ScriptCompanyMode::IsValid().
|
* @game @pre ScriptCompanyMode::IsValid().
|
||||||
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
||||||
|
@ -63,19 +64,19 @@ public:
|
||||||
static bool SetName(StationID station_id, Text *name);
|
static bool SetName(StationID station_id, Text *name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current location of a basestation.
|
* Get the current location of a station or waypoint.
|
||||||
* @param station_id The basestation to get the location of.
|
* @param station_id The station or waypoint to get the location of.
|
||||||
* @pre IsValidBaseStation(station_id).
|
* @pre IsValidStation(station_id) || IsValidWaypoint(station_id).
|
||||||
* @return The tile the basestation sign above it.
|
* @return The tile with the station or waypoint sign above it.
|
||||||
* @note The tile is not necessarily a station tile (and if it is, it could also belong to another station).
|
* @note The tile is not necessarily a station or waypoint tile (and if it is, it could also belong to another station or waypoint).
|
||||||
* @see ScriptTileList_StationType.
|
* @see ScriptTileList_StationType.
|
||||||
*/
|
*/
|
||||||
static TileIndex GetLocation(StationID station_id);
|
static TileIndex GetLocation(StationID station_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last calendar-date a station part was added to this station.
|
* Get the last calendar-date a station or waypoint part was added to this station or waypoint.
|
||||||
* @param station_id The station to look at.
|
* @param station_id The station or waypoint to look at.
|
||||||
* @return The last calendar-date some part of this station was build.
|
* @return The last calendar-date some part of this station or waypoint was built.
|
||||||
* @see \ref ScriptCalendarTime
|
* @see \ref ScriptCalendarTime
|
||||||
*/
|
*/
|
||||||
static ScriptDate::Date GetConstructionDate(StationID station_id);
|
static ScriptDate::Date GetConstructionDate(StationID station_id);
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue