Skip to content

Instantly share code, notes, and snippets.

@glx22

glx22/saveload.h Secret

Last active June 6, 2021 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glx22/02493484b52570a10b360d5dcd92fc65 to your computer and use it in GitHub Desktop.
Save glx22/02493484b52570a10b360d5dcd92fc65 to your computer and use it in GitHub Desktop.
/** Handlers and description of chunk. */
struct ChunkHandler {
uint32 id; ///< Unique ID (4 letters).
ChunkSaveLoadProc *save_proc; ///< Save procedure of the chunk.
ChunkSaveLoadProc *load_proc; ///< Load procedure of the chunk.
ChunkSaveLoadProc *ptrs_proc; ///< Manipulate pointers in the chunk.
ChunkSaveLoadProc *load_check_proc; ///< Load procedure for game preview.
ChunkType type; ///< Type of the chunk. @see ChunkType
ChunkHandler(uint32 id, ChunkSaveLoadProc *save_proc, ChunkSaveLoadProc *load_proc, ChunkSaveLoadProc *ptrs_proc, ChunkSaveLoadProc *load_check_proc, ChunkType type)
: id(id), save_proc(save_proc), load_proc(load_proc), ptrs_proc(ptrs_proc), load_check_proc(load_check_proc), type(type)
{}
virtual ~ChunkHandler() {}
virtual void Save() { if (this->save_proc != nullptr) this->save_proc(); }
virtual void Load() { if (this->load_proc != nullptr) this->load_proc(); }
virtual void Pointers() { if (this->ptrs_proc != nullptr) this->ptrs_proc(); }
virtual void LoadCheck() { if (this->load_check_proc != nullptr) this->load_check_proc(); }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment