1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

starttime in foldername

This commit is contained in:
Michael 2023-08-23 01:47:55 +02:00 committed by GitHub
parent 538acfe3c0
commit d2bbe0f35a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 6 deletions

View File

@ -169,7 +169,7 @@ void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std::
void CPlayerInterface::playerStartsTurn(PlayerColor player)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
makingTurn = false;
stillMoveHero.setn(STOP_MOVE);
@ -180,7 +180,7 @@ void CPlayerInterface::playerStartsTurn(PlayerColor player)
GH.windows().pushWindow(adventureInt);
}
//close window from another player
//close window from another player
if(auto w = GH.windows().topWindow<CInfoWindow>())
if(w->ID == -1 && player != playerID)
w->close();
@ -201,7 +201,7 @@ void CPlayerInterface::playerStartsTurn(PlayerColor player)
void CPlayerInterface::performAutosave()
{
std::string id = cb->getStartInfo()->gameUuid.substr(0, 8);
std::string id = cb->getStartInfo()->gameUuid.substr(0, 4);
int frequency = static_cast<int>(settings["general"]["saveFrequency"].Integer());
if(frequency > 0 && cb->getDate() % frequency == 0)
@ -214,7 +214,7 @@ void CPlayerInterface::performAutosave()
prefix = settings["general"]["savePrefix"].String();
if(prefix.empty())
{
prefix = cb->getMapHeader()->name.substr(0, 18) + "_" + id + "/";
prefix = cb->getMapHeader()->name.substr(0, 15) + "_" + cb->getStartInfo()->startTimeIso8601 + "/";
}
}
@ -232,7 +232,7 @@ void CPlayerInterface::performAutosave()
+ std::to_string(cb->getDate(Date::WEEK))
+ std::to_string(cb->getDate(Date::DAY_OF_WEEK));
cb->save("Saves/Autosave/" + prefix + "Autosave_" + stringifiedDate);
cb->save("Saves/Autosave/" + prefix + "Autosave_" + id + "_" + stringifiedDate);
}
}
}

View File

@ -6,6 +6,7 @@ namespace vstd
{
DLL_LINKAGE std::string getFormattedDateTime(std::time_t dt);
DLL_LINKAGE std::string getDateTimeISO8601Basic(std::time_t dt);
}

View File

@ -9,6 +9,8 @@
*/
#pragma once
#include "vstd/DateUtils.h"
#include "GameConstants.h"
#include "TurnTimerInfo.h"
#include "campaign/CampaignConstants.h"
@ -82,6 +84,7 @@ struct DLL_LINKAGE StartInfo
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 gameUuid;
std::string startTimeIso8601;
TurnTimerInfo turnTimerInfo;
std::string mapname; // empty for random map, otherwise name of the map or savegame
bool createRandomMap() const { return mapGenOptions != nullptr; }
@ -106,6 +109,7 @@ struct DLL_LINKAGE StartInfo
h & seedPostInit;
h & mapfileChecksum;
h & gameUuid;
h & startTimeIso8601;
h & turnTimerInfo;
h & mapname;
h & mapGenOptions;
@ -113,7 +117,7 @@ struct DLL_LINKAGE StartInfo
}
StartInfo() : mode(INVALID), difficulty(1), seedToBeUsed(0), seedPostInit(0),
mapfileChecksum(0), gameUuid(boost::uuids::to_string(boost::uuids::random_generator()()))
mapfileChecksum(0), gameUuid(boost::uuids::to_string(boost::uuids::random_generator()())), startTimeIso8601(vstd::getDateTimeISO8601Basic(std::time(0)))
{
}

View File

@ -15,6 +15,15 @@ namespace vstd
return s.str();
}
DLL_LINKAGE std::string getDateTimeISO8601Basic(std::time_t dt)
{
std::tm tm = *std::localtime(&dt);
std::stringstream s;
s.imbue(std::locale(""));
s << std::put_time(&tm, "%Y%m%dT%H%M%S");
return s.str();
}
}
VCMI_LIB_NAMESPACE_END