- Blood: save level stats as JSON.

This commit is contained in:
Christoph Oelckers 2020-11-22 13:05:17 +01:00
parent c6c9b26af2
commit 63d71c120a
2 changed files with 12 additions and 28 deletions

View file

@ -265,39 +265,23 @@ void CSecretMgr::Clear(void)
Total = Founds = Super = 0; Total = Founds = Super = 0;
} }
class EndGameLoadSave : public LoadSave { void SerializeGameStats(FSerializer& arc)
public:
virtual void Load(void);
virtual void Save(void);
};
void EndGameLoadSave::Load(void)
{ {
Read(&gSecretMgr.Total, 4); if (arc.BeginObject("gamestats"))
Read(&gSecretMgr.Founds, 4); {
Read(&gSecretMgr.Super, 4); arc("secrets", gSecretMgr.Total)
Read(&gKillMgr.TotalKills, 4); ("secretsfound", gSecretMgr.Founds)
Read(&gKillMgr.Kills, 4); ("super", gSecretMgr.Super)
("totalkills", gKillMgr.TotalKills)
("kills", gKillMgr.Kills)
.EndObject();
}
} }
void EndGameLoadSave::Save(void)
{
Write(&gSecretMgr.Total, 4);
Write(&gSecretMgr.Founds, 4);
Write(&gSecretMgr.Super, 4);
Write(&gKillMgr.TotalKills, 4);
Write(&gKillMgr.Kills, 4);
}
CSecretMgr gSecretMgr; CSecretMgr gSecretMgr;
CKillMgr gKillMgr; CKillMgr gKillMgr;
void EndGameLoadSaveConstruct(void)
{
new EndGameLoadSave();
}
class DBloodLoadScreen : public DScreenJob class DBloodLoadScreen : public DScreenJob
{ {
const char* pzLoadingScreenText1; const char* pzLoadingScreenText1;

View file

@ -728,7 +728,6 @@ void MyLoadSave::Save(void)
Write(&gGameOptions, sizeof(gGameOptions)); Write(&gGameOptions, sizeof(gGameOptions));
} }
void EndGameLoadSaveConstruct(void);
void MirrorLoadSaveConstruct(void); void MirrorLoadSaveConstruct(void);
void PlayerLoadSaveConstruct(void); void PlayerLoadSaveConstruct(void);
void ViewLoadSaveConstruct(void); void ViewLoadSaveConstruct(void);
@ -740,7 +739,6 @@ void LoadSaveSetup(void)
{ {
new MyLoadSave(); new MyLoadSave();
EndGameLoadSaveConstruct();
MirrorLoadSaveConstruct(); MirrorLoadSaveConstruct();
PlayerLoadSaveConstruct(); PlayerLoadSaveConstruct();
ViewLoadSaveConstruct(); ViewLoadSaveConstruct();
@ -756,6 +754,7 @@ void SerializeWarp(FSerializer& arc);
void SerializeTriggers(FSerializer& arc); void SerializeTriggers(FSerializer& arc);
void SerializeActor(FSerializer& arc); void SerializeActor(FSerializer& arc);
void SerializeAI(FSerializer& arc); void SerializeAI(FSerializer& arc);
void SerializeGameStats(FSerializer& arc);
void GameInterface::SerializeGameState(FSerializer& arc) void GameInterface::SerializeGameState(FSerializer& arc)
{ {
@ -783,6 +782,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
SerializeActor(arc); SerializeActor(arc);
SerializeAI(arc); SerializeAI(arc);
SerializeEvents(arc); SerializeEvents(arc);
SerializeGameStats(arc);
SerializeSequences(arc); SerializeSequences(arc);
SerializeWarp(arc); SerializeWarp(arc);
SerializeTriggers(arc); SerializeTriggers(arc);