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

This commit is contained in:
Mircea TheHonestCTO committed 2025-09-21 17:48:46 +02:00
1 parent 80b1170669
commit 5c19f0aa7a
2 files changed
+7 -5

No files matched your search

+3 -3
View File
@@ -64,9 +64,9 @@ void CMapInfo::saveInit(const ResourcePath & file)
else
lf.load(scenarioOptionsOfSave);
fileURI = file.getName();
originalFileURI = file.getOriginalName();
fullFileURI = CResourceHandler::get()->getFullFileURI(file);
fileURI = file.getName(); // Name without file extension
originalFileURI = file.getOriginalName(); // Same as file.getName()
fullFileURI = CResourceHandler::get()->getFullFileURI(file); // Includes absolute path + extension
countPlayers();
lastWrite = CResourceHandler::get()->getLastWriteTime(file);
date = TextOperations::getFormattedDateTimeLocal(lastWrite);
+4 -2
View File
@@ -1607,11 +1607,13 @@ void CGameHandler::save(const std::string & filename)
void CGameHandler::load(const StartInfo &info)
{
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();
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>();
randomizer = std::make_unique<GameRandomizer>(*gs);
gs->loadGame(lf);