mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
Codechange: add method for reading a string from a savegame given a length
This commit is contained in:
parent
f90fa2a4d1
commit
83479a4e12
@ -928,6 +928,18 @@ static void FixSCCEncoded(std::string &str)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the given amount of bytes from the buffer into the string.
|
||||
* @param str The string to write to.
|
||||
* @param length The amount of bytes to read into the string.
|
||||
* @note Does not perform any validation on validity of the string.
|
||||
*/
|
||||
void SlReadString(std::string &str, size_t length)
|
||||
{
|
||||
str.resize(length);
|
||||
SlCopyBytes(str.data(), length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save/Load a \c std::string.
|
||||
* @param ptr the string being manipulated
|
||||
@ -953,8 +965,7 @@ static void SlStdString(void *ptr, VarType conv)
|
||||
return;
|
||||
}
|
||||
|
||||
str->resize(len);
|
||||
SlCopyBytes(str->data(), len);
|
||||
SlReadString(*str, len);
|
||||
|
||||
StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK;
|
||||
if ((conv & SLF_ALLOW_CONTROL) != 0) {
|
||||
|
@ -1328,6 +1328,7 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld);
|
||||
size_t SlCalcObjLength(const void *object, const SaveLoadTable &slt);
|
||||
|
||||
uint8_t SlReadByte();
|
||||
void SlReadString(std::string &str, size_t length);
|
||||
void SlWriteByte(uint8_t b);
|
||||
|
||||
void SlGlobList(const SaveLoadTable &slt);
|
||||
|
Loading…
Reference in New Issue
Block a user