mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 05:53:50 +00:00
Insert records that may not exist in vanilla MW
This commit is contained in:
parent
1420a2cb33
commit
40a0969055
6 changed files with 77 additions and 12 deletions
|
@ -137,8 +137,7 @@ namespace MWClass
|
||||||
fJumpAcrobaticsBase = gmst.find("fJumpAcrobaticsBase");
|
fJumpAcrobaticsBase = gmst.find("fJumpAcrobaticsBase");
|
||||||
fJumpAcroMultiplier = gmst.find("fJumpAcroMultiplier");
|
fJumpAcroMultiplier = gmst.find("fJumpAcroMultiplier");
|
||||||
fJumpRunMultiplier = gmst.find("fJumpRunMultiplier");
|
fJumpRunMultiplier = gmst.find("fJumpRunMultiplier");
|
||||||
// Added in Tribunal/Bloodmoon, may not exist
|
fWereWolfRunMult = gmst.find("fWereWolfRunMult");
|
||||||
fWereWolfRunMult = gmst.search("fWereWolfRunMult");
|
|
||||||
|
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,25 @@ namespace MWWorld
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
const T *insertStatic(const T &x) {
|
||||||
|
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
||||||
|
if (store.search(x.mId) != 0) {
|
||||||
|
std::ostringstream msg;
|
||||||
|
msg << "Try to override existing record '" << x.mId << "'";
|
||||||
|
throw std::runtime_error(msg.str());
|
||||||
|
}
|
||||||
|
T record = x;
|
||||||
|
|
||||||
|
T *ptr = store.insertStatic(record);
|
||||||
|
for (iterator it = mStores.begin(); it != mStores.end(); ++it) {
|
||||||
|
if (it->second == &store) {
|
||||||
|
mIds[ptr->mId] = it->first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
// This method must be called once, after loading all master/plugin files. This can only be done
|
// This method must be called once, after loading all master/plugin files. This can only be done
|
||||||
// from the outside, so it must be public.
|
// from the outside, so it must be public.
|
||||||
void setUp();
|
void setUp();
|
||||||
|
|
|
@ -74,15 +74,6 @@ namespace MWWorld
|
||||||
|
|
||||||
mVariables.insert (std::make_pair (iter->mId, std::make_pair (type, value)));
|
mVariables.insert (std::make_pair (iter->mId, std::make_pair (type, value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVariables.find ("dayspassed")==mVariables.end())
|
|
||||||
{
|
|
||||||
// vanilla Morrowind does not define dayspassed.
|
|
||||||
Data value;
|
|
||||||
value.mLong = 1; // but the addons start counting at 1 :(
|
|
||||||
|
|
||||||
mVariables.insert (std::make_pair ("dayspassed", std::make_pair ('l', value)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Globals::Data& Globals::operator[] (const std::string& name) const
|
const Globals::Data& Globals::operator[] (const std::string& name) const
|
||||||
|
|
|
@ -92,6 +92,7 @@ namespace MWWorld
|
||||||
std::map<std::string, T> mDynamic;
|
std::map<std::string, T> mDynamic;
|
||||||
|
|
||||||
typedef std::map<std::string, T> Dynamic;
|
typedef std::map<std::string, T> Dynamic;
|
||||||
|
typedef std::map<std::string, T> Static;
|
||||||
|
|
||||||
friend class ESMStore;
|
friend class ESMStore;
|
||||||
|
|
||||||
|
@ -183,6 +184,20 @@ namespace MWWorld
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
T *insertStatic(const T &item) {
|
||||||
|
std::string id = Misc::StringUtils::lowerCase(item.mId);
|
||||||
|
std::pair<typename Static::iterator, bool> result =
|
||||||
|
mStatic.insert(std::pair<std::string, T>(id, item));
|
||||||
|
T *ptr = &result.first->second;
|
||||||
|
if (result.second) {
|
||||||
|
mShared.push_back(ptr);
|
||||||
|
} else {
|
||||||
|
*ptr = item;
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool eraseStatic(const std::string &id) {
|
bool eraseStatic(const std::string &id) {
|
||||||
T item;
|
T item;
|
||||||
item.mId = Misc::StringUtils::lowerCase(id);
|
item.mId = Misc::StringUtils::lowerCase(id);
|
||||||
|
|
|
@ -211,6 +211,10 @@ namespace MWWorld
|
||||||
mStore.load (mEsm[idx]);
|
mStore.load (mEsm[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// insert records that may not be present in all versions of MW
|
||||||
|
if (mEsm[0].getFormat() == 0)
|
||||||
|
ensureNeededRecords();
|
||||||
|
|
||||||
mStore.setUp();
|
mStore.setUp();
|
||||||
|
|
||||||
// global variables
|
// global variables
|
||||||
|
@ -230,6 +234,41 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void World::ensureNeededRecords()
|
||||||
|
{
|
||||||
|
if (!mStore.get<ESM::GameSetting>().search("sCompanionShare"))
|
||||||
|
{
|
||||||
|
ESM::GameSetting sCompanionShare;
|
||||||
|
sCompanionShare.mId = "sCompanionShare";
|
||||||
|
ESM::Variant value;
|
||||||
|
value.setType(ESM::VT_String);
|
||||||
|
value.setString("Companion Share");
|
||||||
|
sCompanionShare.mValue = value;
|
||||||
|
mStore.insertStatic(sCompanionShare);
|
||||||
|
}
|
||||||
|
if (!mStore.get<ESM::Global>().search("dayspassed"))
|
||||||
|
{
|
||||||
|
// vanilla Morrowind does not define dayspassed.
|
||||||
|
ESM::Global dayspassed;
|
||||||
|
dayspassed.mId = "dayspassed";
|
||||||
|
ESM::Variant value;
|
||||||
|
value.setType(ESM::VT_Long);
|
||||||
|
value.setInteger(1); // but the addons start counting at 1 :(
|
||||||
|
dayspassed.mValue = value;
|
||||||
|
mStore.insertStatic(dayspassed);
|
||||||
|
}
|
||||||
|
if (!mStore.get<ESM::GameSetting>().search("fWereWolfRunMult"))
|
||||||
|
{
|
||||||
|
ESM::GameSetting fWereWolfRunMult;
|
||||||
|
fWereWolfRunMult.mId = "fWereWolfRunMult";
|
||||||
|
ESM::Variant value;
|
||||||
|
value.setType(ESM::VT_Float);
|
||||||
|
value.setFloat(1.f);
|
||||||
|
fWereWolfRunMult.mValue = value;
|
||||||
|
mStore.insertStatic(fWereWolfRunMult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
World::~World()
|
World::~World()
|
||||||
{
|
{
|
||||||
delete mWeatherManager;
|
delete mWeatherManager;
|
||||||
|
|
|
@ -115,9 +115,11 @@ namespace MWWorld
|
||||||
void addContainerScripts(const Ptr& reference, Ptr::CellStore* cell);
|
void addContainerScripts(const Ptr& reference, Ptr::CellStore* cell);
|
||||||
void PCDropped (const Ptr& item);
|
void PCDropped (const Ptr& item);
|
||||||
|
|
||||||
virtual void processDoors(float duration);
|
void processDoors(float duration);
|
||||||
///< Run physics simulation and modify \a world accordingly.
|
///< Run physics simulation and modify \a world accordingly.
|
||||||
|
|
||||||
|
void ensureNeededRecords();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
World (OEngine::Render::OgreRenderer& renderer,
|
World (OEngine::Render::OgreRenderer& renderer,
|
||||||
|
|
Loading…
Reference in a new issue