1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

autosave folders

This commit is contained in:
Michael 2023-08-22 20:43:44 +02:00 committed by GitHub
parent ec4da06b56
commit 68a1b883eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 6 deletions

View File

@ -121,6 +121,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
#include <optional> #include <optional>
#include <queue> #include <queue>
#include <random> #include <random>
#include <regex>
#include <set> #include <set>
#include <sstream> #include <sstream>
#include <string> #include <string>
@ -166,6 +167,9 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
#include <boost/range/adaptor/reversed.hpp> #include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm.hpp> #include <boost/range/algorithm.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#ifndef M_PI #ifndef M_PI
# define M_PI 3.14159265358979323846 # define M_PI 3.14159265358979323846

View File

@ -193,6 +193,8 @@ void CPlayerInterface::playerStartsTurn(PlayerColor player)
void CPlayerInterface::performAutosave() void CPlayerInterface::performAutosave()
{ {
std::string id = cb->getStartInfo()->uuid.substr(0, 8);
int frequency = static_cast<int>(settings["general"]["saveFrequency"].Integer()); int frequency = static_cast<int>(settings["general"]["saveFrequency"].Integer());
if(frequency > 0 && cb->getDate() % frequency == 0) if(frequency > 0 && cb->getDate() % frequency == 0)
{ {
@ -204,7 +206,7 @@ void CPlayerInterface::performAutosave()
prefix = settings["general"]["savePrefix"].String(); prefix = settings["general"]["savePrefix"].String();
if(prefix.empty()) if(prefix.empty())
{ {
prefix = cb->getMapHeader()->name.substr(0, 5) + "_"; prefix = cb->getMapHeader()->name.substr(0, 18) + "_" + id + "/";
} }
} }
@ -213,7 +215,7 @@ void CPlayerInterface::performAutosave()
int autosaveCountLimit = settings["general"]["autosaveCountLimit"].Integer(); int autosaveCountLimit = settings["general"]["autosaveCountLimit"].Integer();
if(autosaveCountLimit > 0) if(autosaveCountLimit > 0)
{ {
cb->save("Saves/" + prefix + "Autosave_" + std::to_string(autosaveCount)); cb->save("Saves/Autosave/" + prefix + "Autosave_" + std::to_string(autosaveCount));
autosaveCount %= autosaveCountLimit; autosaveCount %= autosaveCountLimit;
} }
else else
@ -222,7 +224,7 @@ void CPlayerInterface::performAutosave()
+ std::to_string(cb->getDate(Date::WEEK)) + std::to_string(cb->getDate(Date::WEEK))
+ std::to_string(cb->getDate(Date::DAY_OF_WEEK)); + std::to_string(cb->getDate(Date::DAY_OF_WEEK));
cb->save("Saves/" + prefix + "Autosave_" + stringifiedDate); cb->save("Saves/Autosave/" + prefix + "Autosave_" + stringifiedDate);
} }
} }
} }

View File

@ -80,6 +80,7 @@ struct DLL_LINKAGE StartInfo
ui32 seedToBeUsed; //0 if not sure (client requests server to decide, will be send in reply pack) ui32 seedToBeUsed; //0 if not sure (client requests server to decide, will be send in reply pack)
ui32 seedPostInit; //so we know that game is correctly synced at the start; 0 if not known yet ui32 seedPostInit; //so we know that game is correctly synced at the start; 0 if not known yet
ui32 mapfileChecksum; //0 if not relevant ui32 mapfileChecksum; //0 if not relevant
std::string uuid;
ui8 turnTime; //in minutes, 0=unlimited ui8 turnTime; //in minutes, 0=unlimited
std::string mapname; // empty for random map, otherwise name of the map or savegame std::string mapname; // empty for random map, otherwise name of the map or savegame
bool createRandomMap() const { return mapGenOptions != nullptr; } bool createRandomMap() const { return mapGenOptions != nullptr; }
@ -103,6 +104,7 @@ struct DLL_LINKAGE StartInfo
h & seedToBeUsed; h & seedToBeUsed;
h & seedPostInit; h & seedPostInit;
h & mapfileChecksum; h & mapfileChecksum;
h & uuid;
h & turnTime; h & turnTime;
h & mapname; h & mapname;
h & mapGenOptions; h & mapGenOptions;
@ -110,7 +112,7 @@ struct DLL_LINKAGE StartInfo
} }
StartInfo() : mode(INVALID), difficulty(1), seedToBeUsed(0), seedPostInit(0), StartInfo() : mode(INVALID), difficulty(1), seedToBeUsed(0), seedPostInit(0),
mapfileChecksum(0), turnTime(0) mapfileChecksum(0), turnTime(0), uuid(boost::uuids::to_string(boost::uuids::random_generator()()))
{ {
} }

View File

@ -14,8 +14,8 @@
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
const ui32 SERIALIZATION_VERSION = 825; const ui32 SERIALIZATION_VERSION = 826;
const ui32 MINIMAL_SERIALIZATION_VERSION = 824; const ui32 MINIMAL_SERIALIZATION_VERSION = 826;
const std::string SAVEGAME_MAGIC = "VCMISVG"; const std::string SAVEGAME_MAGIC = "VCMISVG";
class CHero; class CHero;