0
0
Fork 0
mirror of https://github.com/ZDoom/gzdoom-gles.git synced 2025-02-25 21:00:46 +00:00

- fixed some errors with parsing globals.json. It looks like this file is being processed correctly now.

This commit is contained in:
Christoph Oelckers 2016-09-22 19:36:23 +02:00
parent d9dbf26f63
commit c22e8c50af
4 changed files with 38 additions and 34 deletions

View file

@ -1926,11 +1926,11 @@ void G_DoLoadGame ()
// we are done with info.json. // we are done with info.json.
arc.Close(); arc.Close();
info = resfile->FindLump("global.json"); info = resfile->FindLump("globals.json");
if (info == nullptr) if (info == nullptr)
{ {
delete resfile; delete resfile;
Printf("'%s' is not a valid savegame: Missing 'global.json'.\n", savename.GetChars()); Printf("'%s' is not a valid savegame: Missing 'globals.json'.\n", savename.GetChars());
return; return;
} }
@ -1948,14 +1948,15 @@ void G_DoLoadGame ()
bglobal.RemoveAllBots (true); bglobal.RemoveAllBots (true);
arc("importantcvars", map); FString cvar;
if (!map.IsEmpty()) arc("importantcvars",cvar);
if (!cvar.IsEmpty())
{ {
BYTE *vars_p = (BYTE *)map.GetChars(); BYTE *vars_p = (BYTE *)cvar.GetChars();
C_ReadCVars (&vars_p); C_ReadCVars (&vars_p);
} }
DWORD time[2] = { 0,1 }; DWORD time[2] = { 1,0 };
arc("ticrate", time[0]) arc("ticrate", time[0])
("leveltime", time[1]); ("leveltime", time[1]);
@ -1970,7 +1971,6 @@ void G_DoLoadGame ()
bool demoplaybacksave = demoplayback; bool demoplaybacksave = demoplayback;
G_InitNew (map, false); G_InitNew (map, false);
demoplayback = demoplaybacksave; demoplayback = demoplaybacksave;
delete[] map;
savegamerestore = false; savegamerestore = false;
STAT_Serialize(arc); STAT_Serialize(arc);
@ -1981,7 +1981,8 @@ void G_DoLoadGame ()
NextSkill = -1; NextSkill = -1;
arc("nextskill", NextSkill); arc("nextskill", NextSkill);
level.info->Snapshot.Clean(); if (level.info != nullptr)
level.info->Snapshot.Clean();
BackupSaveName = savename; BackupSaveName = savename;

View file

@ -353,8 +353,8 @@ void FRandom::StaticReadRNGState(FSerializer &arc)
} }
arc.EndObject(); arc.EndObject();
} }
arc.EndArray();
} }
arc.EndArray();
} }
} }

View file

@ -725,36 +725,39 @@ void ACSStringPool::ReadStrings(FSerializer &file, const char *key)
{ {
Clear(); Clear();
int poolsize; if (file.BeginObject(key))
{
int poolsize = 0;
file("poolsize", poolsize); file("poolsize", poolsize);
Pool.Resize(poolsize); Pool.Resize(poolsize);
for (auto &p : Pool) for (auto &p : Pool)
{
p.Next = FREE_ENTRY;
p.LockCount = 0;
}
if (file.BeginArray("pool"))
{
int j = file.ArraySize();
for (int i = 0; i < j; i++)
{ {
if (file.BeginObject(nullptr)) p.Next = FREE_ENTRY;
p.LockCount = 0;
}
if (file.BeginArray("pool"))
{
int j = file.ArraySize();
for (int i = 0; i < j; i++)
{ {
unsigned ii = UINT_MAX; if (file.BeginObject(nullptr))
file("index", ii);
if (ii < Pool.Size())
{ {
file("string", Pool[ii].Str) unsigned ii = UINT_MAX;
("lockcount", Pool[ii].LockCount); file("index", ii);
if (ii < Pool.Size())
{
file("string", Pool[ii].Str)
("lockcount", Pool[ii].LockCount);
unsigned h = SuperFastHash(Pool[ii].Str, Pool[ii].Str.Len()); unsigned h = SuperFastHash(Pool[ii].Str, Pool[ii].Str.Len());
unsigned bucketnum = h % NUM_BUCKETS; unsigned bucketnum = h % NUM_BUCKETS;
Pool[ii].Hash = h; Pool[ii].Hash = h;
Pool[ii].Next = PoolBuckets[bucketnum]; Pool[ii].Next = PoolBuckets[bucketnum];
PoolBuckets[bucketnum] = i; PoolBuckets[bucketnum] = i;
}
file.EndObject();
} }
file.EndObject();
} }
} }
} }

View file

@ -51,7 +51,6 @@ struct FJSONObject
else if (v->IsArray()) else if (v->IsArray())
{ {
mIndex = 0; mIndex = 0;
mIterator = v->MemberEnd();
} }
} }
}; };
@ -717,6 +716,7 @@ unsigned FSerializer::GetSize(const char *group)
const char *FSerializer::GetKey() const char *FSerializer::GetKey()
{ {
if (isWriting()) return nullptr; // we do not know this when writing. if (isWriting()) return nullptr; // we do not know this when writing.
if (!r->mObjects.Last().mObject->IsObject()) return nullptr; // non-objects do not have keys.
auto &it = r->mObjects.Last().mIterator; auto &it = r->mObjects.Last().mIterator;
if (it == r->mObjects.Last().mObject->MemberEnd()) return nullptr; if (it == r->mObjects.Last().mObject->MemberEnd()) return nullptr;
return it->name.GetString(); return it->name.GetString();