- refactored all places which treated FileData as zero terminated.

This commit is contained in:
Christoph Oelckers 2023-08-20 01:49:22 +02:00
commit 2c2bf0265f
19 changed files with 63 additions and 47 deletions

View file

@ -36,6 +36,7 @@
#include "cmdlib.h"
#include "fs_findfile.h"
#include "filesystem.h"
#include "files.h"
#include "md5.h"
@ -1008,3 +1009,17 @@ void uppercopy(char* to, const char* from)
to[i] = 0;
}
//==========================================================================
//
// GetStringFromLump
//
// Loads a zero terminated string from a lump in the file system
//==========================================================================
FString GetStringFromLump(int lump)
{
FileData fd = fileSystem.ReadFile(lump);
FString ScriptBuffer(fd.GetString(), fd.GetSize());
ScriptBuffer.Truncate(strlen(ScriptBuffer.GetChars())); // this is necessary to properly truncate the generated string to not contain 0 bytes.
return ScriptBuffer;
}