mirror of https://github.com/OpenTTD/OpenTTD
Cleanup: remove str_strip_colours; StrMakeValid also removes the colours
Essentially str_strip_colours followed by StrMakeValid makes the calling of str_strip_colours useless, as StrMakeValid would have removed them too.pull/10972/head
parent
35ef6c1723
commit
e762855201
|
@ -107,7 +107,6 @@ void IConsolePrint(TextColour colour_code, const std::string &string)
|
|||
/* Create a copy of the string, strip if of colours and invalid
|
||||
* characters and (when applicable) assign it to the console buffer */
|
||||
char *str = stredup(string.c_str());
|
||||
str_strip_colours(str);
|
||||
StrMakeValidInPlace(str);
|
||||
|
||||
if (_network_dedicated) {
|
||||
|
|
|
@ -423,29 +423,6 @@ bool StrEqualsIgnoreCase(const std::string_view str1, const std::string_view str
|
|||
return StrCompareIgnoreCase(str1, str2) == 0;
|
||||
}
|
||||
|
||||
/** Scans the string for colour codes and strips them */
|
||||
void str_strip_colours(char *str)
|
||||
{
|
||||
char *dst = str;
|
||||
WChar c;
|
||||
size_t len;
|
||||
|
||||
for (len = Utf8Decode(&c, str); c != '\0'; len = Utf8Decode(&c, str)) {
|
||||
if (c < SCC_BLUE || c > SCC_BLACK) {
|
||||
/* Copy the character back. Even if dst is current the same as str
|
||||
* (i.e. no characters have been changed) this is quicker than
|
||||
* moving the pointers ahead by len */
|
||||
do {
|
||||
*dst++ = *str++;
|
||||
} while (--len != 0);
|
||||
} else {
|
||||
/* Just skip (strip) the colour codes */
|
||||
str += len;
|
||||
}
|
||||
}
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of an UTF-8 encoded string in number of characters
|
||||
* and thus not the number of bytes that the encoded string contains.
|
||||
|
|
|
@ -42,7 +42,6 @@ void StrMakeValidInPlace(char *str, const char *last, StringValidationSettings s
|
|||
void StrMakeValidInPlace(char *str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
|
||||
|
||||
void str_fix_scc_encoded(char *str, const char *last) NOACCESS(2);
|
||||
void str_strip_colours(char *str);
|
||||
bool strtolower(std::string &str, std::string::size_type offs = 0);
|
||||
|
||||
[[nodiscard]] bool StrValid(const char *str, const char *last) NOACCESS(2);
|
||||
|
|
Loading…
Reference in New Issue