Skip to content

Commit

Permalink
- save SW's User array as JSON.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Apr 21, 2021
1 parent 3295562 commit 8fee2b3
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 118 deletions.
2 changes: 1 addition & 1 deletion source/common/engine/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TArray<T, TT> &value,
return arc;
}

template<class T, class TT>
template<class T>
FSerializer& Serialize(FSerializer& arc, const char* key, TPointer<T>& value, TPointer<T>* def)
{
if (arc.isWriting())
Expand Down
25 changes: 25 additions & 0 deletions source/core/savegamehelp.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,28 @@ void M_Autosave();

#define SAVEGAME_EXT ".dsave"


inline FSerializer& Serialize(FSerializer& arc, const char* keyname, spritetype*& w, spritetype** def)
{
int ndx = w ? int(w - sprite) : -1;
arc(keyname, ndx);
w = ndx == -1 ? nullptr : sprite + ndx;
return arc;
}

inline FSerializer& Serialize(FSerializer& arc, const char* keyname, sectortype*& w, sectortype** def)
{
int ndx = w ? int(w - sector) : -1;
arc(keyname, ndx);
w = ndx == -1 ? nullptr : sector + ndx;
return arc;
}

inline FSerializer& Serialize(FSerializer& arc, const char* keyname, walltype*& w, walltype** def)
{
int ndx = w ? int(w - wall) : -1;
arc(keyname, ndx);
w = ndx == -1 ? nullptr : wall + ndx;
return arc;
}

3 changes: 2 additions & 1 deletion source/games/sw/src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,8 @@ struct GameInterface : ::GameInterface
bool CanSave() override;
bool StartGame(FNewGameStartup& gs) override;
FSavegameInfo GetSaveSig() override;
bool LoadGame() override;
void SerializeGameState(FSerializer& arc);
bool LoadGame() override;
bool SaveGame() override;
void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); }
FString GetCoordString() override;
Expand Down
Loading

0 comments on commit 8fee2b3

Please sign in to comment.