1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

show random maps

This commit is contained in:
Laserlicht
2023-10-21 02:12:34 +02:00
committed by GitHub
parent f3acc939b9
commit 0eba0ee686
6 changed files with 33 additions and 5 deletions

View File

@@ -566,17 +566,20 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan
{
try
{
auto path = VCMIDirs::get().userCachePath() / "RandomMaps";
auto path = VCMIDirs::get().userDataPath() / "Maps" / "RandomMaps";
boost::filesystem::create_directories(path);
std::shared_ptr<CMapGenOptions> options = scenarioOps->mapGenOptions;
const std::string templateName = options->getMapTemplate()->getName();
const ui32 seed = scenarioOps->seedToBeUsed;
const std::string dt = vstd::getDateTimeISO8601Basic(std::time(0));
const std::string fileName = boost::str(boost::format("%s_%d.vmap") % templateName % seed );
const std::string fileName = boost::str(boost::format("%s_%s_%d.vmap") % dt % templateName % seed );
const auto fullPath = path / fileName;
randomMap->name.appendRawString(boost::str(boost::format(" %s") % dt));
mapService->saveMap(randomMap, fullPath);
logGlobal->info("Random map has been saved to:");