1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-21 11:41:33 +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) void OMW::Engine::prepareEngine (Settings::Manager & settings)
{ {
mEnvironment.setStateManager ( mEnvironment.setStateManager (
new MWState::StateManager (mCfgMgr.getUserDataPath() / "saves", mContentFiles.at (0))); new MWState::StateManager (mCfgMgr.getUserDataPath() / "saves", mContentFiles));
createWindow(settings); createWindow(settings);

View file

@ -13,6 +13,15 @@ bool MWState::operator< (const Slot& left, const Slot& right)
return left.mTimeStamp<right.mTimeStamp; 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) 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); slot.mProfile.load (reader);
if (Misc::StringUtils::lowerCase (slot.mProfile.mContentFiles.at (0))!= if (!Misc::StringUtils::ciEqual(getFirstGameFile(slot.mProfile.mContentFiles), game))
Misc::StringUtils::lowerCase (game))
return; // this file is for a different game -> ignore return; // this file is for a different game -> ignore
mSlots.push_back (slot); mSlots.push_back (slot);

View file

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

View file

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

View file

@ -29,7 +29,7 @@ namespace MWState
public: 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 (); Character *getCurrentCharacter ();
///< @note May return null ///< @note May return null

View file

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

View file

@ -31,7 +31,7 @@ namespace MWState
public: 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; void requestQuit() override;