- 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;
}
class EndGameLoadSave : public LoadSave {
public:
virtual void Load(void);
virtual void Save(void);
};
void EndGameLoadSave::Load(void)
void SerializeGameStats(FSerializer& arc)
{
Read(&gSecretMgr.Total, 4);
Read(&gSecretMgr.Founds, 4);
Read(&gSecretMgr.Super, 4);
Read(&gKillMgr.TotalKills, 4);
Read(&gKillMgr.Kills, 4);
if (arc.BeginObject("gamestats"))
{
arc("secrets", gSecretMgr.Total)
("secretsfound", gSecretMgr.Founds)
("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;
CKillMgr gKillMgr;
void EndGameLoadSaveConstruct(void)
{
new EndGameLoadSave();
}
class DBloodLoadScreen : public DScreenJob
{
const char* pzLoadingScreenText1;

View file

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