1
0
Fork 0

Fix: Handle \t when loading GS strings from savegame (#14180)

pull/13655/merge
Loïc Guilloux 2025-05-01 16:48:02 +02:00 committed by GitHub
parent 6f4994329c
commit 1f212e6f2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 1 deletions

View File

@ -121,7 +121,7 @@ static uint32_t _game_saveload_strings;
class SlGameLanguageString : public DefaultSaveLoadHandler<SlGameLanguageString, LanguageStrings> {
public:
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;

View File

@ -1066,6 +1066,9 @@ static void SlStdString(void *ptr, VarType conv)
if ((conv & SLF_ALLOW_NEWLINE) != 0) {
settings.Set(StringValidationSetting::AllowNewline);
}
if ((conv & SLF_REPLACE_TABCRLF) != 0) {
settings.Set(StringValidationSetting::ReplaceTabCrNlWithSpace);
}
StrMakeValidInPlace(*str, settings);
}

View File

@ -691,6 +691,7 @@ enum VarTypes : uint16_t {
* Flags directing saving/loading of a variable */
SLF_ALLOW_CONTROL = 1 << 8, ///< Allow control codes 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;