1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

fix: cannot open saved games with extra dots in the name

This commit is contained in:
Mircea TheHonestCTO
2025-09-21 17:45:42 +02:00
parent 80b1170669
commit 5c19f0aa7a
2 changed files with 7 additions and 5 deletions

View File

@@ -64,9 +64,9 @@ void CMapInfo::saveInit(const ResourcePath & file)
else else
lf.load(scenarioOptionsOfSave); lf.load(scenarioOptionsOfSave);
fileURI = file.getName(); fileURI = file.getName(); // Name without file extension
originalFileURI = file.getOriginalName(); originalFileURI = file.getOriginalName(); // Same as file.getName()
fullFileURI = CResourceHandler::get()->getFullFileURI(file); fullFileURI = CResourceHandler::get()->getFullFileURI(file); // Includes absolute path + extension
countPlayers(); countPlayers();
lastWrite = CResourceHandler::get()->getLastWriteTime(file); lastWrite = CResourceHandler::get()->getLastWriteTime(file);
date = TextOperations::getFormattedDateTimeLocal(lastWrite); date = TextOperations::getFormattedDateTimeLocal(lastWrite);

View File

@@ -1607,11 +1607,13 @@ void CGameHandler::save(const std::string & filename)
void CGameHandler::load(const StartInfo &info) void CGameHandler::load(const StartInfo &info)
{ {
logGlobal->info("Loading from %s", info.mapname); logGlobal->info("Loading from %s", info.mapname);
const auto stem = FileInfo::GetPathStem(info.mapname); // No need to use the stem because info.mapname doesn't come with the file extension included
// const auto stem = FileInfo::GetPathStem(info.mapname);
reinitScripting(); reinitScripting();
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(stem.to_string(), EResType::SAVEGAME)), gs.get()); // CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(stem.to_string(), EResType::SAVEGAME)), gs.get());
CLoadFile lf(*CResourceHandler::get()->getResourceName(ResourcePath(info.mapname, EResType::SAVEGAME)), gs.get());
gs = std::make_shared<CGameState>(); gs = std::make_shared<CGameState>();
randomizer = std::make_unique<GameRandomizer>(*gs); randomizer = std::make_unique<GameRandomizer>(*gs);
gs->loadGame(lf); gs->loadGame(lf);