Do autosaves
This commit is contained in:
@@ -35,6 +35,7 @@ std::vector<std::pair<fs::path, std::time_t>> sorted_file_mtimes(fs::path dir, s
|
||||
|
||||
bool load_party(fs::path file_to_load, cUniverse& univ);
|
||||
bool save_party(cUniverse& univ, bool save_as = false);
|
||||
bool save_party_force(cUniverse& univ, fs::path file);
|
||||
|
||||
void init_directories(const char* exec_path);
|
||||
|
||||
|
@@ -444,9 +444,12 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ){
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool save_party_const(const cUniverse& univ, bool save_as) {
|
||||
static bool save_party_const(const cUniverse& univ, bool save_as, fs::path dest_file = "") {
|
||||
// Make sure it has the proper file extension
|
||||
fs::path dest_file = univ.file;
|
||||
if(dest_file.empty()){
|
||||
dest_file = univ.file;
|
||||
}
|
||||
|
||||
if(dest_file.extension() != ".exg"){
|
||||
dest_file += ".exg";
|
||||
}
|
||||
@@ -555,6 +558,10 @@ bool save_party(cUniverse& univ, bool save_as) {
|
||||
return save_party_const(univ, save_as);
|
||||
}
|
||||
|
||||
bool save_party_force(cUniverse& univ, fs::path file) {
|
||||
return save_party_const(univ, false, file);
|
||||
}
|
||||
|
||||
static bool compare_mtime(std::pair<fs::path, std::time_t> a, std::pair<fs::path, std::time_t> b) {
|
||||
return std::difftime(a.second, b.second) > 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user