BVB Source Codes

CRYENGINE Show CheckPointSystem.h Source code

Return Download CRYENGINE: download CheckPointSystem.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: Checkpoint Save/Load system for Game04
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 10:07:2008 : Created By Jan M眉ller
  12.    - 05:02:2009 : Refactored and moved By Kevin Kirst
  13.  
  14. *************************************************************************/
  15.  
  16. #ifndef __CHECKPOINT_SYSTEM_H__
  17. #define __CHECKPOINT_SYSTEM_H__
  18.  
  19. #include "ICheckPointSystem.h"
  20.  
  21. class CCheckpointSystem : public ICheckpointSystem
  22. {
  23. public:
  24.         virtual ~CCheckpointSystem();
  25.  
  26.         //get save/load system
  27.         static CCheckpointSystem* GetInstance();
  28.  
  29.         //retrieve metaData for a checkpoint file
  30.         bool GetMetaData(const char* fileName, SCheckpointData& metaData, bool bRepairId = true);
  31.  
  32.         //load last (during this session) saved checkpoint
  33.         virtual bool LoadLastCheckpoint();
  34.  
  35.         //load a game checkpoint from the specified filename
  36.         virtual bool LoadGame(const char* fileName);
  37.  
  38.         //save a game checkpoint with the specified filename
  39.         virtual bool SaveGame(EntityId checkpointId, const char* fileName);
  40.  
  41.         //set game handler
  42.         virtual void SetGameHandler(ICheckpointGameHandler* pHandler);
  43.  
  44.         //clear game handler
  45.         virtual void ClearGameHandler();
  46.  
  47.         //add checkpoint system listener
  48.         virtual void RegisterListener(ICheckpointListener* pListener);
  49.  
  50.         //remove checkpoint system listener
  51.         virtual void RemoveListener(ICheckpointListener* pListener);
  52.  
  53.         //return a list of savegame names for the current level
  54.         void GetCurrentLevelCheckpoints(std::vector<string>& saveNames);
  55.  
  56.         //save/load worldMatrix for an Entity
  57.         virtual void SerializeWorldTM(IEntity* pEntity, XmlNodeRef data, bool writing);
  58.  
  59.         // use this to save XMLNodes during OnSave
  60.         bool SaveXMLNode(XmlNodeRef node, const char* identifier);
  61.  
  62.         // use this to load XMLNodes during OnLoad
  63.         XmlNodeRef LoadXMLNode(const char* identifier);
  64.  
  65.         // save a single, external entity position/orientation/status during "OnSave"
  66.         // the entity is loaded automatically with the checkpoint
  67.         virtual bool SaveExternalEntity(EntityId id);
  68.  
  69. private:
  70.         //this is a singleton
  71.         CCheckpointSystem();
  72.  
  73.         //SAVING *********************************
  74.  
  75.         //actor data : mainly flags
  76.         void WriteActorData(XmlNodeRef parentNode);
  77.  
  78.         //vehicle data
  79.         void WriteVehicleData(XmlNodeRef parentNode);
  80.  
  81.         //checkpoint data
  82.         void WriteMetaData(EntityId checkpointId, XmlNodeRef parentNode, SCheckpointData& outMetaData);
  83.  
  84.         //save the game token system
  85.         void WriteGameTokens(XmlNodeRef parentNode);
  86.  
  87.         //write xml node to file
  88.         void WriteXML(XmlNodeRef data, const char* fileName);
  89.  
  90.         //LOADING ********************************
  91.  
  92.         //delete all dynamic entities
  93.         void DeleteDynamicEntities();
  94.  
  95.         //trigger flowgraph node etc.
  96.         void OnCheckpointLoaded(SCheckpointData metaData);
  97.  
  98.         //loads the map a checkpoint was saved in, if it's not matching the current level
  99.         bool LoadCheckpointMap(const SCheckpointData& metaData, CryFixedStringT<32>& curLevelName);
  100.  
  101.         //loads entities which were saved by external calls (flowgraph)
  102.         void LoadExternalEntities(XmlNodeRef parentNode);
  103.  
  104.         //read checkpoint from XML
  105.         XmlNodeRef ReadXML(const char* fileName);
  106.  
  107.         //load the game token system
  108.         void ReadGameTokens(XmlNodeRef parentNode);
  109.  
  110.         //resetting dynamic parts of the engine
  111.         void ResetEngine();
  112.  
  113.         //respawn AI's and read actor flags
  114.         void RespawnAI(XmlNodeRef data);
  115.  
  116.         //reads meta data
  117.         bool ReadMetaData(XmlNodeRef parentNode, SCheckpointData& metaData, bool bRepairId = true);
  118.  
  119.         //finish up loading and start game
  120.         void RestartGameplay();
  121.  
  122.         //SHARED DATA ***************************
  123.  
  124.         //scan the savegame directory and return savegame names in a vector
  125.         static void ParseSavedFiles(std::vector<string>& saveNames, const char* pLevelName = NULL);
  126.  
  127.         //test/fix the entity id of a saved entity by checking for it's name
  128.         //returns true if the id is fixed, false if it's (still) broken
  129.         bool RepairEntityId(EntityId& id, const char* pEntityName);
  130.  
  131.         //this removes sub-directories from a level name
  132.         void RepairLevelName(CryFixedStringT<32>& levelName);
  133.  
  134.         //set or fix filename extension
  135.         static void SetFilenameExtension(FixedCheckpointString& fileName);
  136.  
  137.         //sends onSave/onLoad to all listeners
  138.         static void UpdateListener(SCheckpointData data, bool wasSaving);
  139.  
  140.         //VARIABLES ***************************
  141.  
  142.         //save last checkpoint for "quickload"
  143.         static FixedCheckpointString g_lastSavedCheckpoint;
  144.  
  145.         //list of CheckpointSystem listeners
  146.         static std::list<ICheckpointListener*> g_vCheckpointSystemListeners;
  147.  
  148.         //game handler
  149.         ICheckpointGameHandler* m_pGameHandler;
  150. };
  151.  
  152. #endif //__CHECKPOINT_SYSTEM_H__
  153.  
downloadCheckPointSystem.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top