1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 07:09:42 +00:00

Filter saves by the first esm/omwgame rather than by the first content file (that can be a universal omwaddon/omwscripts)

This commit is contained in:
Petr Mikheev 2021-10-17 10:29:10 +02:00
parent 47c89567fb
commit 19a0fde278
7 changed files with 19 additions and 9 deletions

View file

@ -669,7 +669,7 @@ void OMW::Engine::setWindowIcon()
void OMW::Engine::prepareEngine (Settings::Manager & settings)
{
mEnvironment.setStateManager (
new MWState::StateManager (mCfgMgr.getUserDataPath() / "saves", mContentFiles.at (0)));
new MWState::StateManager (mCfgMgr.getUserDataPath() / "saves", mContentFiles));
createWindow(settings);

View file

@ -13,6 +13,15 @@ bool MWState::operator< (const Slot& left, const Slot& right)
return left.mTimeStamp<right.mTimeStamp;
}
std::string MWState::getFirstGameFile(const std::vector<std::string>& contentFiles)
{
for (const std::string& c : contentFiles)
{
if (Misc::StringUtils::ciEndsWith(c, ".esm") || Misc::StringUtils::ciEndsWith(c, ".omwgame"))
return c;
}
return "";
}
void MWState::Character::addSlot (const boost::filesystem::path& path, const std::string& game)
{
@ -30,8 +39,7 @@ void MWState::Character::addSlot (const boost::filesystem::path& path, const std
slot.mProfile.load (reader);
if (Misc::StringUtils::lowerCase (slot.mProfile.mContentFiles.at (0))!=
Misc::StringUtils::lowerCase (game))
if (!Misc::StringUtils::ciEqual(getFirstGameFile(slot.mProfile.mContentFiles), game))
return; // this file is for a different game -> ignore
mSlots.push_back (slot);

View file

@ -16,6 +16,8 @@ namespace MWState
bool operator< (const Slot& left, const Slot& right);
std::string getFirstGameFile(const std::vector<std::string>& contentFiles);
class Character
{
public:

View file

@ -6,8 +6,8 @@
#include <boost/filesystem.hpp>
MWState::CharacterManager::CharacterManager (const boost::filesystem::path& saves,
const std::string& game)
: mPath (saves), mCurrent (nullptr), mGame (game)
const std::vector<std::string>& contentFiles)
: mPath (saves), mCurrent (nullptr), mGame (getFirstGameFile(contentFiles))
{
if (!boost::filesystem::is_directory (mPath))
{

View file

@ -29,7 +29,7 @@ namespace MWState
public:
CharacterManager (const boost::filesystem::path& saves, const std::string& game);
CharacterManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles);
Character *getCurrentCharacter ();
///< @note May return null

View file

@ -88,8 +88,8 @@ std::map<int, int> MWState::StateManager::buildContentFileIndexMap (const ESM::E
return map;
}
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::string& game)
: mQuitRequest (false), mAskLoadRecent(false), mState (State_NoGame), mCharacterManager (saves, game), mTimePlayed (0)
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles)
: mQuitRequest (false), mAskLoadRecent(false), mState (State_NoGame), mCharacterManager (saves, contentFiles), mTimePlayed (0)
{
}

View file

@ -31,7 +31,7 @@ namespace MWState
public:
StateManager (const boost::filesystem::path& saves, const std::string& game);
StateManager (const boost::filesystem::path& saves, const std::vector<std::string>& contentFiles);
void requestQuit() override;