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