1
0
Fork 0

Compare commits

...

6 Commits

Author SHA1 Message Date
Peter Nelson 706313df6d
Merge b96da4d7a0 into 67e56391c7 2025-07-14 22:25:02 +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
Peter Nelson b96da4d7a0
Change: Automatically push/pop colours when formatting a sub-string.
Reverts 226a44bf86.

This universally prevents the sub-string from changing colours in the outer string.
2025-04-15 19:31:09 +01:00
Peter Nelson ffed3c7f1c
Change: Don't replace stripped control codes with '?' for scripts. 2025-04-15 19:31:08 +01:00
5 changed files with 25 additions and 22 deletions

View File

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

View File

@ -1231,7 +1231,7 @@ STR_CONFIG_SETTING_EXPAND_ALL :Expand all
STR_CONFIG_SETTING_COLLAPSE_ALL :Collapse all
STR_CONFIG_SETTING_RESET_ALL :Reset all values
STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT :(no explanation available)
STR_CONFIG_SETTING_VALUE :{PUSH_COLOUR}{ORANGE}{STRING1}{POP_COLOUR}
STR_CONFIG_SETTING_VALUE :{ORANGE}{STRING1}
STR_CONFIG_SETTING_DEFAULT_VALUE :{LTBLUE}Default value: {ORANGE}{STRING1}
STR_CONFIG_SETTING_TYPE :{LTBLUE}Setting type: {ORANGE}{STRING}
STR_CONFIG_SETTING_TYPE_CLIENT :Client setting (not stored in saves; affects all games)
@ -3624,17 +3624,17 @@ STR_NEWGRF_LIST_COMPATIBLE :{YELLOW}Found c
STR_NEWGRF_LIST_MISSING :{RED}Missing files
# NewGRF 'it's broken' warnings
STR_NEWGRF_BROKEN :{WHITE}Behaviour of NewGRF '{PUSH_COLOUR}{0:RAW_STRING}{POP_COLOUR}' is likely to cause desyncs and/or crashes
STR_NEWGRF_BROKEN_POWERED_WAGON :{WHITE}It changed powered-wagon state for '{PUSH_COLOUR}{1:ENGINE}{POP_COLOUR}' when not inside a depot
STR_NEWGRF_BROKEN_VEHICLE_LENGTH :{WHITE}It changed vehicle length for '{PUSH_COLOUR}{1:ENGINE}{POP_COLOUR}' when not inside a depot
STR_NEWGRF_BROKEN_CAPACITY :{WHITE}It changed vehicle capacity for '{PUSH_COLOUR}{1:ENGINE}{POP_COLOUR}' when not inside a depot or refitting
STR_NEWGRF_BROKEN :{WHITE}Behaviour of NewGRF '{0:RAW_STRING}' is likely to cause desyncs and/or crashes
STR_NEWGRF_BROKEN_POWERED_WAGON :{WHITE}It changed powered-wagon state for '{1:ENGINE}' when not inside a depot
STR_NEWGRF_BROKEN_VEHICLE_LENGTH :{WHITE}It changed vehicle length for '{1:ENGINE}' when not inside a depot
STR_NEWGRF_BROKEN_CAPACITY :{WHITE}It changed vehicle capacity for '{1:ENGINE}' when not inside a depot or refitting
STR_BROKEN_VEHICLE_LENGTH :{WHITE}Train '{VEHICLE}' belonging to '{COMPANY}' has invalid length. It is probably caused by problems with NewGRFs. Game may desync or crash
STR_NEWGRF_BUGGY :{WHITE}NewGRF '{PUSH_COLOUR}{0:RAW_STRING}{POP_COLOUR}' provides incorrect information
STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Cargo/refit information for '{PUSH_COLOUR}{1:ENGINE}{POP_COLOUR}' differs from purchase list after construction. This might cause autorenew/-replace to fail refitting correctly
STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{PUSH_COLOUR}{1:STRING}{POP_COLOUR}' caused an endless loop in the production callback
STR_NEWGRF_BUGGY :{WHITE}NewGRF '{0:RAW_STRING}' provides incorrect information
STR_NEWGRF_BUGGY_ARTICULATED_CARGO :{WHITE}Cargo/refit information for '{1:ENGINE}' differs from purchase list after construction. This might cause autorenew/-replace to fail refitting correctly
STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' caused an endless loop in the production callback
STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT :{WHITE}Callback {1:HEX} returned unknown/invalid result {2:HEX}
STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{PUSH_COLOUR}{1:STRING}{POP_COLOUR}' returned invalid cargo type in the production callback at {2:HEX}
STR_NEWGRF_BUGGY_INVALID_CARGO_PRODUCTION_CALLBACK :{WHITE}'{1:STRING}' returned invalid cargo type in the production callback at {2:HEX}
# 'User removed essential NewGRFs'-placeholders for stuff without specs
STR_NEWGRF_INVALID_CARGO :<invalid cargo>
@ -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_CAN_T_DO_THIS :{WHITE}Can't do this...
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_SITE_UNSUITABLE :{WHITE}... site unsuitable
STR_ERROR_ALREADY_BUILT :{WHITE}... already built

View File

@ -607,28 +607,25 @@ bool ConvertHexToBytes(std::string_view hex, std::span<uint8_t> bytes)
/** String iterator using ICU as a backend. */
class IcuStringIterator : public StringIterator
{
icu::BreakIterator *char_itr; ///< ICU iterator for characters.
icu::BreakIterator *word_itr; ///< ICU iterator for words.
std::unique_ptr<icu::BreakIterator> char_itr; ///< ICU iterator for characters.
std::unique_ptr<icu::BreakIterator> word_itr; ///< ICU iterator for words.
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.
public:
IcuStringIterator() : char_itr(nullptr), word_itr(nullptr)
IcuStringIterator()
{
UErrorCode status = U_ZERO_ERROR;
this->char_itr = icu::BreakIterator::createCharacterInstance(icu::Locale(_current_language != nullptr ? _current_language->isocode : "en"), status);
this->word_itr = icu::BreakIterator::createWordInstance(icu::Locale(_current_language != nullptr ? _current_language->isocode : "en"), status);
auto locale = icu::Locale(_current_language != nullptr ? _current_language->isocode : "en");
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_to_utf8.push_back(0);
}
~IcuStringIterator() override
{
delete this->char_itr;
delete this->word_itr;
}
~IcuStringIterator() override = default;
void SetString(std::string_view s) override
{

View File

@ -1112,6 +1112,9 @@ static void FormatString(StringBuilder &builder, std::string_view str_arg, Strin
std::stack<StrStackItem, std::vector<StrStackItem>> str_stack;
str_stack.emplace(str_arg, orig_first_param_offset, orig_case_index);
bool appending = builder.AnyBytesWritten();
if (appending) builder.PutUtf8(SCC_PUSH_COLOUR);
for (;;) {
try {
while (!str_stack.empty() && !str_stack.top().consumer.AnyBytesLeft()) {
@ -1839,6 +1842,8 @@ static void FormatString(StringBuilder &builder, std::string_view str_arg, Strin
builder += "(invalid parameter)";
}
}
if (appending) builder.PutUtf8(SCC_POP_COLOUR);
}

View File

@ -710,7 +710,7 @@ static void TileLoop_Town(TileIndex tile)
static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlags flags)
{
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));
@ -724,7 +724,7 @@ static CommandCost ClearTile_Town(TileIndex tile, DoCommandFlags flags)
if (!_cheats.magic_bulldozer.value && !flags.Test(DoCommandFlag::NoTestTownRating)) {
/* NewGRFs can add indestructible houses. */
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 (rating > t->ratings[_current_company] && _settings_game.difficulty.town_council_tolerance != TOWN_COUNCIL_PERMISSIVE) {