diff options
Diffstat (limited to 'Source/Game/savefile.h')
-rw-r--r-- | Source/Game/savefile.h | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/Source/Game/savefile.h b/Source/Game/savefile.h index 7cb0e5e0..86afb549 100644 --- a/Source/Game/savefile.h +++ b/Source/Game/savefile.h @@ -34,30 +34,30 @@ struct uint128_holder { uint8_t val[16]; }; -typedef std::map<std::string,std::vector<std::string> > ArrayDataMap; +typedef std::map<std::string, std::vector<std::string> > ArrayDataMap; typedef std::map<std::string, std::string> DataMap; typedef std::map<std::string, uint32_t> Int32Map; class SavedLevel { -public: - void SetValue(const std::string &key, const std::string &val); - const std::string& GetValue(const std::string &key); - - void SetArrayValue(const std::string &key, const int32_t index, const std::string &val); - void DeleteArrayValue(const std::string &key, const int32_t index); - void AppendArrayValueIfUnique(const std::string &key, const std::string& val); - void AppendArrayValue(const std::string &key, const std::string& val); - bool ArrayContainsValue(const std::string &key, const std::string& val); - uint32_t GetArraySize(const std::string &key); - std::string GetArrayValue( const std::string &key, const int32_t index); - std::vector<std::string> GetArray(const std::string &key); - - void SetInt32Value(const std::string &key, const int32_t value); - int32_t GetInt32Value(const std::string &key); - bool HasInt32Value(const std::string &key); + public: + void SetValue(const std::string& key, const std::string& val); + const std::string& GetValue(const std::string& key); + + void SetArrayValue(const std::string& key, const int32_t index, const std::string& val); + void DeleteArrayValue(const std::string& key, const int32_t index); + void AppendArrayValueIfUnique(const std::string& key, const std::string& val); + void AppendArrayValue(const std::string& key, const std::string& val); + bool ArrayContainsValue(const std::string& key, const std::string& val); + uint32_t GetArraySize(const std::string& key); + std::string GetArrayValue(const std::string& key, const int32_t index); + std::vector<std::string> GetArray(const std::string& key); + + void SetInt32Value(const std::string& key, const int32_t value); + int32_t GetInt32Value(const std::string& key); + bool HasInt32Value(const std::string& key); void SetKey(const std::string& campaign_id, const std::string& save_category, const std::string& save_name); - bool SerializeToRAM( MemWriteFileDescriptor *file_ptr ); + bool SerializeToRAM(MemWriteFileDescriptor* file_ptr); void ClearData(); @@ -69,17 +69,16 @@ public: std::string save_category_; std::string save_name_; -private: - + private: DataMap data_; ArrayDataMap array_data_; - Int32Map data_int32_; + Int32Map data_int32_; uint128_holder md5_; }; class SaveFile { -public: + public: SavedLevel& GetSave(const std::string campaign_id, const std::string save_category, const std::string save_name); SavedLevel& GetSavedLevelDeprecated(const std::string& save_name); @@ -89,11 +88,11 @@ public: bool SaveExist(const std::string campaign_id, const std::string save_category, const std::string save_name); bool ReadFromFile(const std::string& filepath); - bool LoadFromRAM( void* mem ); + bool LoadFromRAM(void* mem); void Clear(); void SetWriteFile(const std::string& filepath); - bool WriteToFile( const std::string& filepath ); - bool SerializeToRAM( std::vector<uint8_t> *mem_ptr ); + bool WriteToFile(const std::string& filepath); + bool SerializeToRAM(std::vector<uint8_t>* mem_ptr); bool WriteInPlace(); void QueueWriteInPlace(); void ExecuteQueuedWrite(); @@ -101,10 +100,10 @@ public: static const char* kOvergrowthSaveMarker; static const uint16_t kCurrentVersion; -private: + + private: std::vector<SavedLevel> levels_; std::string filepath_; uint16_t loaded_version; bool queue_write_in_place_; }; - |