forked from teamnwah/openmw-tes3coop
store content file list in saved games and reject saved games not matching the current game
This commit is contained in:
parent
1ecadccb28
commit
616e3aa32f
10 changed files with 38 additions and 16 deletions
|
@ -323,7 +323,8 @@ std::string OMW::Engine::loadSettings (Settings::Manager & settings)
|
||||||
|
|
||||||
void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
{
|
{
|
||||||
mEnvironment.setStateManager (new MWState::StateManager (mCfgMgr.getUserPath() / "saves"));
|
mEnvironment.setStateManager (
|
||||||
|
new MWState::StateManager (mCfgMgr.getUserPath() / "saves", mContentFiles.at (0)));
|
||||||
|
|
||||||
Nif::NIFFile::CacheLock cachelock;
|
Nif::NIFFile::CacheLock cachelock;
|
||||||
|
|
||||||
|
|
|
@ -416,6 +416,8 @@ namespace MWBase
|
||||||
|
|
||||||
virtual void launchProjectile (const std::string& id, const ESM::EffectList& effects,
|
virtual void launchProjectile (const std::string& id, const ESM::EffectList& effects,
|
||||||
const MWWorld::Ptr& actor, const std::string& sourceName) = 0;
|
const MWWorld::Ptr& actor, const std::string& sourceName) = 0;
|
||||||
|
|
||||||
|
virtual const std::vector<std::string>& getContentFiles() const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,18 @@
|
||||||
#include <components/esm/esmreader.hpp>
|
#include <components/esm/esmreader.hpp>
|
||||||
#include <components/esm/defs.hpp>
|
#include <components/esm/defs.hpp>
|
||||||
|
|
||||||
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
bool MWState::operator< (const Slot& left, const Slot& right)
|
bool MWState::operator< (const Slot& left, const Slot& right)
|
||||||
{
|
{
|
||||||
return left.mTimeStamp<right.mTimeStamp;
|
return left.mTimeStamp<right.mTimeStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MWState::Character::addSlot (const boost::filesystem::path& path)
|
void MWState::Character::addSlot (const boost::filesystem::path& path, const std::string& game)
|
||||||
{
|
{
|
||||||
Slot slot;
|
Slot slot;
|
||||||
slot.mPath = path;
|
slot.mPath = path;
|
||||||
|
@ -37,6 +42,9 @@ void MWState::Character::addSlot (const boost::filesystem::path& path)
|
||||||
|
|
||||||
slot.mProfile.load (reader);
|
slot.mProfile.load (reader);
|
||||||
|
|
||||||
|
if (Misc::StringUtils::lowerCase (slot.mProfile.mContentFiles.at (0))!=game)
|
||||||
|
return; // this file is for a different game -> ignore
|
||||||
|
|
||||||
mSlots.push_back (slot);
|
mSlots.push_back (slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +62,7 @@ void MWState::Character::addSlot (const ESM::SavedGame& profile)
|
||||||
mSlots.push_back (slot);
|
mSlots.push_back (slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWState::Character::Character (const boost::filesystem::path& saves)
|
MWState::Character::Character (const boost::filesystem::path& saves, const std::string& game)
|
||||||
: mPath (saves), mNext (0)
|
: mPath (saves), mNext (0)
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory (mPath))
|
if (!boost::filesystem::is_directory (mPath))
|
||||||
|
@ -70,7 +78,7 @@ MWState::Character::Character (const boost::filesystem::path& saves)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
addSlot (slotPath);
|
addSlot (slotPath, game);
|
||||||
}
|
}
|
||||||
catch (...) {} // ignoring bad saved game files for now
|
catch (...) {} // ignoring bad saved game files for now
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,13 @@ namespace MWState
|
||||||
std::vector<Slot> mSlots;
|
std::vector<Slot> mSlots;
|
||||||
int mNext;
|
int mNext;
|
||||||
|
|
||||||
void addSlot (const boost::filesystem::path& path);
|
void addSlot (const boost::filesystem::path& path, const std::string& game);
|
||||||
|
|
||||||
void addSlot (const ESM::SavedGame& profile);
|
void addSlot (const ESM::SavedGame& profile);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Character (const boost::filesystem::path& saves);
|
Character (const boost::filesystem::path& saves, const std::string& game);
|
||||||
|
|
||||||
const Slot *createSlot (const ESM::SavedGame& profile);
|
const Slot *createSlot (const ESM::SavedGame& profile);
|
||||||
///< Create new slot.
|
///< Create new slot.
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
MWState::CharacterManager::CharacterManager (const boost::filesystem::path& saves)
|
MWState::CharacterManager::CharacterManager (const boost::filesystem::path& saves,
|
||||||
: mPath (saves), mNext (0), mCurrent (0)
|
const std::string& game)
|
||||||
|
: mPath (saves), mNext (0), mCurrent (0), mGame (game)
|
||||||
{
|
{
|
||||||
if (!boost::filesystem::is_directory (mPath))
|
if (!boost::filesystem::is_directory (mPath))
|
||||||
{
|
{
|
||||||
|
@ -22,7 +23,7 @@ MWState::CharacterManager::CharacterManager (const boost::filesystem::path& save
|
||||||
|
|
||||||
if (boost::filesystem::is_directory (characterDir))
|
if (boost::filesystem::is_directory (characterDir))
|
||||||
{
|
{
|
||||||
Character character (characterDir);
|
Character character (characterDir, mGame);
|
||||||
|
|
||||||
if (character.begin()!=character.end())
|
if (character.begin()!=character.end())
|
||||||
mCharacters.push_back (character);
|
mCharacters.push_back (character);
|
||||||
|
@ -53,7 +54,7 @@ void MWState::CharacterManager::createCharacter()
|
||||||
|
|
||||||
boost::filesystem::path path = mPath / stream.str();
|
boost::filesystem::path path = mPath / stream.str();
|
||||||
|
|
||||||
mCharacters.push_back (Character (path));
|
mCharacters.push_back (Character (path, mGame));
|
||||||
|
|
||||||
mCurrent = &mCharacters.back();
|
mCurrent = &mCharacters.back();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace MWState
|
||||||
int mNext;
|
int mNext;
|
||||||
std::vector<Character> mCharacters;
|
std::vector<Character> mCharacters;
|
||||||
Character *mCurrent;
|
Character *mCurrent;
|
||||||
|
std::string mGame;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ namespace MWState
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CharacterManager (const boost::filesystem::path& saves);
|
CharacterManager (const boost::filesystem::path& saves, const std::string& game);
|
||||||
|
|
||||||
Character *getCurrentCharacter (bool create = true);
|
Character *getCurrentCharacter (bool create = true);
|
||||||
///< \param create Create a new character, if there is no current character.
|
///< \param create Create a new character, if there is no current character.
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
|
|
||||||
MWState::StateManager::StateManager (const boost::filesystem::path& saves)
|
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::string& game)
|
||||||
: mQuitRequest (false), mState (State_NoGame), mCharacterManager (saves)
|
: mQuitRequest (false), mState (State_NoGame), mCharacterManager (saves, game)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,8 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
||||||
|
|
||||||
MWWorld::Ptr player = world.getPlayer().getPlayer();
|
MWWorld::Ptr player = world.getPlayer().getPlayer();
|
||||||
|
|
||||||
/// \todo store content file list
|
profile.mContentFiles = world.getContentFiles();
|
||||||
|
|
||||||
profile.mPlayerName = player.getClass().getName (player);
|
profile.mPlayerName = player.getClass().getName (player);
|
||||||
profile.mPlayerLevel = player.getClass().getNpcStats (player).getLevel();
|
profile.mPlayerLevel = player.getClass().getNpcStats (player).getLevel();
|
||||||
profile.mPlayerClass = player.get<ESM::NPC>()->mBase->mClass;
|
profile.mPlayerClass = player.get<ESM::NPC>()->mBase->mClass;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace MWState
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
StateManager (const boost::filesystem::path& saves);
|
StateManager (const boost::filesystem::path& saves, const std::string& game);
|
||||||
|
|
||||||
virtual void requestQuit();
|
virtual void requestQuit();
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ namespace MWWorld
|
||||||
mSky (true), mCells (mStore, mEsm),
|
mSky (true), mCells (mStore, mEsm),
|
||||||
mActivationDistanceOverride (mActivationDistanceOverride),
|
mActivationDistanceOverride (mActivationDistanceOverride),
|
||||||
mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true),
|
mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true),
|
||||||
mFacedDistance(FLT_MAX), mGodMode(false)
|
mFacedDistance(FLT_MAX), mGodMode(false), mContentFiles (contentFiles)
|
||||||
{
|
{
|
||||||
mPhysics = new PhysicsSystem(renderer);
|
mPhysics = new PhysicsSystem(renderer);
|
||||||
mPhysEngine = mPhysics->getEngine();
|
mPhysEngine = mPhysics->getEngine();
|
||||||
|
@ -2246,4 +2246,9 @@ namespace MWWorld
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string>& World::getContentFiles() const
|
||||||
|
{
|
||||||
|
return mContentFiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ namespace MWWorld
|
||||||
OEngine::Physic::PhysicEngine* mPhysEngine;
|
OEngine::Physic::PhysicEngine* mPhysEngine;
|
||||||
|
|
||||||
bool mGodMode;
|
bool mGodMode;
|
||||||
|
std::vector<std::string> mContentFiles;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
World (const World&);
|
World (const World&);
|
||||||
|
@ -492,6 +493,8 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual void launchProjectile (const std::string& id, const ESM::EffectList& effects,
|
virtual void launchProjectile (const std::string& id, const ESM::EffectList& effects,
|
||||||
const MWWorld::Ptr& actor, const std::string& sourceName);
|
const MWWorld::Ptr& actor, const std::string& sourceName);
|
||||||
|
|
||||||
|
virtual const std::vector<std::string>& getContentFiles() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue