소스 검색

change datetime format

Laserlicht 11 달 전
부모
커밋
452762cd78
4개의 변경된 파일19개의 추가작업 그리고 8개의 파일을 삭제
  1. 2 2
      client/CPlayerInterface.cpp
  2. 13 3
      lib/StartInfo.h
  3. 2 1
      lib/serializer/ESerializationVersion.h
  4. 2 2
      server/CVCMIServer.cpp

+ 2 - 2
client/CPlayerInterface.cpp

@@ -238,7 +238,7 @@ void CPlayerInterface::performAutosave()
 				std::string name = cb->getMapHeader()->name.toString();
 				int txtlen = TextOperations::getUnicodeCharactersCount(name);
 
-				TextOperations::trimRightUnicode(name, std::max(0, txtlen - 15));
+				TextOperations::trimRightUnicode(name, std::max(0, txtlen - 14));
 				auto const & isSymbolIllegal = [&](char c) {
 					static const std::string forbiddenChars("\\/:*?\"<>| ");
 
@@ -249,7 +249,7 @@ void CPlayerInterface::performAutosave()
 				};
 				std::replace_if(name.begin(), name.end(), isSymbolIllegal, '_' );
 
-				prefix = cb->getStartInfo()->startTimeIso8601 + "_" + name + "/";
+				prefix = vstd::getFormattedDateTime(cb->getStartInfo()->startTime, "%Y-%m-%d_%H-%M") + "_" + name + "/";
 			}
 		}
 

+ 13 - 3
lib/StartInfo.h

@@ -146,7 +146,7 @@ struct DLL_LINKAGE StartInfo : public Serializeable
 	using TPlayerInfos = std::map<PlayerColor, PlayerSettings>;
 	TPlayerInfos playerInfos; //color indexed
 
-	std::string startTimeIso8601;
+	time_t startTime;
 	std::string fileURI;
 	SimturnsInfo simturnsInfo;
 	TurnTimerInfo turnTimerInfo;
@@ -180,7 +180,17 @@ struct DLL_LINKAGE StartInfo : public Serializeable
 			h & oldSeeds;
 			h & oldSeeds;
 		}
-		h & startTimeIso8601;
+		if (h.version < Handler::Version::FOLDER_NAME_REWORK)
+		{
+			std::string startTimeLegacy;
+			h & startTimeLegacy;
+			struct std::tm tm;
+			std::istringstream ss(startTimeLegacy);
+			ss >> std::get_time(&tm, "%Y%m%dT%H%M%S");
+			startTime = mktime(&tm);
+		}
+		else
+			h & startTime;
 		h & fileURI;
 		h & simturnsInfo;
 		h & turnTimerInfo;
@@ -193,7 +203,7 @@ struct DLL_LINKAGE StartInfo : public Serializeable
 	StartInfo()
 		: mode(EStartMode::INVALID)
 		, difficulty(1)
-		, startTimeIso8601(vstd::getDateTimeISO8601Basic(std::time(nullptr)))
+		, startTime(std::time(nullptr))
 	{
 
 	}

+ 2 - 1
lib/serializer/ESerializationVersion.h

@@ -65,6 +65,7 @@ enum class ESerializationVersion : int32_t
 	LOCAL_PLAYER_STATE_DATA, // 866 - player state contains arbitrary client-side data
 	REMOVE_TOWN_PTR, // 867 - removed pointer to CTown from CGTownInstance
 	REMOVE_OBJECT_TYPENAME, // 868 - remove typename from CGObjectInstance
+	FOLDER_NAME_REWORK, // 869 - rework foldername
 
-	CURRENT = REMOVE_OBJECT_TYPENAME
+	CURRENT = FOLDER_NAME_REWORK
 };

+ 2 - 2
server/CVCMIServer.cpp

@@ -245,7 +245,7 @@ bool CVCMIServer::prepareToStartGame()
 	{
 	case EStartMode::CAMPAIGN:
 		logNetwork->info("Preparing to start new campaign");
-		si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(nullptr));
+		si->startTime = std::time(nullptr);
 		si->fileURI = mi->fileURI;
 		si->campState->setCurrentMap(campaignMap);
 		si->campState->setCurrentMapBonus(campaignBonus);
@@ -254,7 +254,7 @@ bool CVCMIServer::prepareToStartGame()
 
 	case EStartMode::NEW_GAME:
 		logNetwork->info("Preparing to start new game");
-		si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(nullptr));
+		si->startTime = std::time(nullptr);
 		si->fileURI = mi->fileURI;
 		gh->init(si.get(), progressTracking);
 		break;