Skip to content

Commit

Permalink
Add PrepareSave() method for LDB, LMU, LSD
Browse files Browse the repository at this point in the history
- Should be called by Player and Editor before saving.
  • Loading branch information
fmatthew5876 committed Oct 29, 2018
1 parent 9d3be87 commit c98f726
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ldb_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#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()) {
Expand Down
5 changes: 5 additions & 0 deletions src/ldb_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
* LDB Reader namespace.
*/
namespace LDB_Reader {
/**
* Increment the database save_count.
*/
void PrepareSave(RPG::Database& db);

/**
* Loads Database.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/lmu_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#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()) {
Expand Down
5 changes: 5 additions & 0 deletions src/lmu_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
*/
namespace LMU_Reader {

/**
* Increment the map save count.
*/
void PrepareSave(RPG::Map& map);

/**
* Loads map.
*/
Expand Down
7 changes: 6 additions & 1 deletion src/lsd_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#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);
Expand All @@ -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()) {
Expand Down
5 changes: 5 additions & 0 deletions src/lsd_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit c98f726

Please sign in to comment.