mirror of https://github.com/OpenTTD/OpenTTD
Fix: Handle \t when loading GS strings from savegame (#14180)
parent
6f4994329c
commit
1f212e6f2a
|
@ -121,7 +121,7 @@ static uint32_t _game_saveload_strings;
|
||||||
class SlGameLanguageString : public DefaultSaveLoadHandler<SlGameLanguageString, LanguageStrings> {
|
class SlGameLanguageString : public DefaultSaveLoadHandler<SlGameLanguageString, LanguageStrings> {
|
||||||
public:
|
public:
|
||||||
inline static const SaveLoad description[] = {
|
inline static const SaveLoad description[] = {
|
||||||
SLEG_SSTR("string", _game_saveload_string, SLE_STR | SLF_ALLOW_CONTROL),
|
SLEG_SSTR("string", _game_saveload_string, SLE_STR | SLF_ALLOW_CONTROL | SLF_REPLACE_TABCRLF),
|
||||||
};
|
};
|
||||||
inline const static SaveLoadCompatTable compat_description = _game_language_string_sl_compat;
|
inline const static SaveLoadCompatTable compat_description = _game_language_string_sl_compat;
|
||||||
|
|
||||||
|
|
|
@ -1066,6 +1066,9 @@ static void SlStdString(void *ptr, VarType conv)
|
||||||
if ((conv & SLF_ALLOW_NEWLINE) != 0) {
|
if ((conv & SLF_ALLOW_NEWLINE) != 0) {
|
||||||
settings.Set(StringValidationSetting::AllowNewline);
|
settings.Set(StringValidationSetting::AllowNewline);
|
||||||
}
|
}
|
||||||
|
if ((conv & SLF_REPLACE_TABCRLF) != 0) {
|
||||||
|
settings.Set(StringValidationSetting::ReplaceTabCrNlWithSpace);
|
||||||
|
}
|
||||||
StrMakeValidInPlace(*str, settings);
|
StrMakeValidInPlace(*str, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -691,6 +691,7 @@ enum VarTypes : uint16_t {
|
||||||
* Flags directing saving/loading of a variable */
|
* Flags directing saving/loading of a variable */
|
||||||
SLF_ALLOW_CONTROL = 1 << 8, ///< Allow control codes in the strings.
|
SLF_ALLOW_CONTROL = 1 << 8, ///< Allow control codes in the strings.
|
||||||
SLF_ALLOW_NEWLINE = 1 << 9, ///< Allow new lines in the strings.
|
SLF_ALLOW_NEWLINE = 1 << 9, ///< Allow new lines in the strings.
|
||||||
|
SLF_REPLACE_TABCRLF = 1 << 10, ///< Replace tabs, cr and lf in the string with spaces.
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint32_t VarType;
|
typedef uint32_t VarType;
|
||||||
|
|
Loading…
Reference in New Issue