mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fixed bug when reading text files using internal file system
Small oversight causing defect, but found during extensive tests and code inspection.
This commit is contained in:
parent
41fda3a8ac
commit
d946f9d1a1
@ -340,16 +340,18 @@ void MOD_PreloadPakFile(const string& svLevelName)
|
|||||||
ostringstream ostream;
|
ostringstream ostream;
|
||||||
ostream << "scripts/levels/settings/" << svLevelName << ".json";
|
ostream << "scripts/levels/settings/" << svLevelName << ".json";
|
||||||
|
|
||||||
FileHandle_t pFile = FileSystem()->Open(ostream.str().c_str(), "rb");
|
FileHandle_t pFile = FileSystem()->Open(ostream.str().c_str(), "rt");
|
||||||
if (!pFile)
|
if (!pFile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t nLen = FileSystem()->Size(pFile);
|
uint32_t nLen = FileSystem()->Size(pFile);
|
||||||
uint8_t* pBuf = MemAllocSingleton()->Alloc<uint8_t>(nLen);
|
uint8_t* pBuf = MemAllocSingleton()->Alloc<uint8_t>(nLen);
|
||||||
|
|
||||||
FileSystem()->Read(pBuf, nLen, pFile);
|
int nRead = FileSystem()->Read(pBuf, nLen, pFile);
|
||||||
FileSystem()->Close(pFile);
|
FileSystem()->Close(pFile);
|
||||||
|
|
||||||
|
pBuf[nRead] = '\0';
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nlohmann::json jsIn = nlohmann::json::parse(pBuf);
|
nlohmann::json jsIn = nlohmann::json::parse(pBuf);
|
||||||
|
@ -19,15 +19,17 @@ void StreamDB_Init(const char* pszLevelName)
|
|||||||
ostringstream ostream;
|
ostringstream ostream;
|
||||||
ostream << "scripts/levels/settings/" << pszLevelName << ".json";
|
ostream << "scripts/levels/settings/" << pszLevelName << ".json";
|
||||||
|
|
||||||
FileHandle_t pFile = FileSystem()->Open(ostream.str().c_str(), "rb");
|
FileHandle_t pFile = FileSystem()->Open(ostream.str().c_str(), "rt");
|
||||||
if (pFile)
|
if (pFile)
|
||||||
{
|
{
|
||||||
uint32_t nLen = FileSystem()->Size(pFile);
|
uint32_t nLen = FileSystem()->Size(pFile);
|
||||||
uint8_t* pBuf = MemAllocSingleton()->Alloc<uint8_t>(nLen);
|
uint8_t* pBuf = MemAllocSingleton()->Alloc<uint8_t>(nLen);
|
||||||
|
|
||||||
FileSystem()->Read(pBuf, nLen, pFile);
|
int nRead = FileSystem()->Read(pBuf, nLen, pFile);
|
||||||
FileSystem()->Close(pFile);
|
FileSystem()->Close(pFile);
|
||||||
|
|
||||||
|
pBuf[nRead] = '\0';
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nlohmann::json jsIn = nlohmann::json::parse(pBuf);
|
nlohmann::json jsIn = nlohmann::json::parse(pBuf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user