Add PrepareSave() method for LDB, LMU, LSD
Should be called by Player and Editor before saving.
MODIFY
src/ldb_reader.cpp
src/ldb_reader.cpp
#include "reader_util.h"
#include "reader_struct.h"
+void LDB_Reader::PrepareSave(RPG::Database& db) {
+ ++db.system.save_count;
+}
+
bool LDB_Reader::Load(const std::string& filename, const std::string& encoding) {
std::ifstream stream(filename.c_str(), std::ios::binary);
if (!stream.is_open()) {

MODIFY
src/ldb_reader.h
src/ldb_reader.h
* LDB Reader namespace.
*/
namespace LDB_Reader {
+ /**
+ * Increment the database save_count.
+ */
+ void PrepareSave(RPG::Database& db);
+
/**
* Loads Database.
*/

MODIFY
src/lmu_reader.cpp
src/lmu_reader.cpp
#include "reader_util.h"
#include "reader_struct.h"
+void LMU_Reader::PrepareSave(RPG::Map& map) {
+ ++map.save_count;
+}
+
std::unique_ptr<RPG::Map> LMU_Reader::Load(const std::string& filename, const std::string& encoding) {
std::ifstream stream(filename.c_str(), std::ios::binary);
if (!stream.is_open()) {

MODIFY
src/lmu_reader.h
src/lmu_reader.h
*/
namespace LMU_Reader {
+ /**
+ * Increment the map save count.
+ */
+ void PrepareSave(RPG::Map& map);
+
/**
* Loads map.
*/

MODIFY
src/lsd_reader.cpp
src/lsd_reader.cpp
#include "reader_util.h"
#include "reader_struct.h"
-
double LSD_Reader::ToTDateTime(std::time_t const t) {
// 25569 is UnixDateDelta: number of days between 1970-01-01 and 1900-01-01
return(t / 86400.0 + 25569.0);
@@ -33,6 +32,12 @@ double LSD_Reader::GenerateTimestamp(std::time_t const t) {
return ToTDateTime(t);
}
+void LSD_Reader::PrepareSave(RPG::Save& save) {
+ ++save.system.save_count;
+ save.title.timestamp = LSD_Reader::GenerateTimestamp();
+}
+
+
std::unique_ptr<RPG::Save> LSD_Reader::Load(const std::string& filename, const std::string& encoding) {
std::ifstream stream(filename.c_str(), std::ios::binary);
if (!stream.is_open()) {

MODIFY
src/lsd_reader.h
src/lsd_reader.h
@@ -36,6 +36,11 @@ namespace LSD_Reader {
*/
double GenerateTimestamp(std::time_t const t = std::time(NULL));
+ /**
+ * Increment the save save_count and update the timestamp.
+ */
+ void PrepareSave(RPG::Save& save);
+
/**
* Loads Savegame.
*/

Add PrepareSave() method for LDB, LMU, LSD

- Should be called by Player and Editor before saving.