Ver código fonte

autosave folders

Michael 2 anos atrás
pai
commit
68a1b883eb
4 arquivos alterados com 14 adições e 6 exclusões
  1. 4 0
      Global.h
  2. 5 3
      client/CPlayerInterface.cpp
  3. 3 1
      lib/StartInfo.h
  4. 2 2
      lib/serializer/CSerializer.h

+ 4 - 0
Global.h

@@ -121,6 +121,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #include <optional>
 #include <queue>
 #include <random>
+#include <regex>
 #include <set>
 #include <sstream>
 #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/algorithm.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
 #  define M_PI 3.14159265358979323846

+ 5 - 3
client/CPlayerInterface.cpp

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

+ 3 - 1
lib/StartInfo.h

@@ -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 seedPostInit; //so we know that game is correctly synced at the start; 0 if not known yet
 	ui32 mapfileChecksum; //0 if not relevant
+	std::string uuid;
 	ui8 turnTime; //in minutes, 0=unlimited
 	std::string mapname; // empty for random map, otherwise name of the map or savegame
 	bool createRandomMap() const { return mapGenOptions != nullptr; }
@@ -103,6 +104,7 @@ struct DLL_LINKAGE StartInfo
 		h & seedToBeUsed;
 		h & seedPostInit;
 		h & mapfileChecksum;
+		h & uuid;
 		h & turnTime;
 		h & mapname;
 		h & mapGenOptions;
@@ -110,7 +112,7 @@ struct DLL_LINKAGE StartInfo
 	}
 
 	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()()))
 	{
 
 	}

+ 2 - 2
lib/serializer/CSerializer.h

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