Fix targeted scripts losing their targets when rearranging your load order

pull/593/head
Evil Eye 4 years ago
parent 30cba854da
commit 44f2cb0923

@ -235,13 +235,20 @@ namespace MWScript
}
}
bool GlobalScripts::readRecord (ESM::ESMReader& reader, uint32_t type)
bool GlobalScripts::readRecord (ESM::ESMReader& reader, uint32_t type, const std::map<int, int>& contentFileMap)
{
if (type==ESM::REC_GSCR)
{
ESM::GlobalScript script;
script.load (reader);
if (script.mTargetRef.hasContentFile())
{
auto iter = contentFileMap.find(script.mTargetRef.mContentFile);
if (iter != contentFileMap.end())
script.mTargetRef.mContentFile = iter->second;
}
auto iter = mScripts.find (script.mId);
if (iter==mScripts.end())

@ -73,7 +73,7 @@ namespace MWScript
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
bool readRecord (ESM::ESMReader& reader, uint32_t type);
bool readRecord (ESM::ESMReader& reader, uint32_t type, const std::map<int, int>& contentFileMap);
///< Records for variables that do not exist are dropped silently.
///
/// \return Known type?

@ -461,7 +461,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
case ESM::REC_GSCR:
MWBase::Environment::get().getScriptManager()->getGlobalScripts().readRecord (reader, n.intval);
MWBase::Environment::get().getScriptManager()->getGlobalScripts().readRecord (reader, n.intval, contentFileMap);
break;
case ESM::REC_GMAP:

Loading…
Cancel
Save