mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-08 23:34:15 +00:00
Codechange: do not make a string valid in place, to then copy it
This commit is contained in:
parent
b958a343fe
commit
18a31cca7c
@ -2651,12 +2651,9 @@ static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader
|
||||
*/
|
||||
static std::string ReadDWordAsString(ByteReader *reader)
|
||||
{
|
||||
char output[5];
|
||||
for (int i = 0; i < 4; i++) output[i] = reader->ReadByte();
|
||||
output[4] = '\0';
|
||||
StrMakeValidInPlace(output, lastof(output));
|
||||
|
||||
return std::string(output);
|
||||
std::string output;
|
||||
for (int i = 0; i < 4; i++) output.push_back(reader->ReadByte());
|
||||
return StrMakeValid(output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,8 +68,7 @@ public:
|
||||
SlObject(lc, this->GetLoadDescription());
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_STRING_GAMELOG)) {
|
||||
StrMakeValidInPlace(SlGamelogRevision::revision_text, lastof(SlGamelogRevision::revision_text));
|
||||
static_cast<LoggedChangeRevision *>(lc)->text = SlGamelogRevision::revision_text;
|
||||
static_cast<LoggedChangeRevision *>(lc)->text = StrMakeValid(std::string_view(SlGamelogRevision::revision_text, lengthof(SlGamelogRevision::revision_text)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -573,8 +573,7 @@ bool ScriptInstance::IsPaused()
|
||||
SlObject(nullptr, _script_byte);
|
||||
static char buf[std::numeric_limits<decltype(_script_sl_byte)>::max()];
|
||||
SlCopy(buf, _script_sl_byte, SLE_CHAR);
|
||||
StrMakeValidInPlace(buf, buf + _script_sl_byte);
|
||||
if (data != nullptr) data->push_back(std::string(buf));
|
||||
if (data != nullptr) data->push_back(StrMakeValid(std::string_view(buf, _script_sl_byte)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user