コード例 #1
0
ファイル: globalscripts.cpp プロジェクト: Chiur/openmw
    bool GlobalScripts::readRecord (ESM::ESMReader& reader, int32_t type)
    {
        if (type==ESM::REC_GSCR)
        {
            ESM::GlobalScript script;
            script.load (reader);

            std::map<std::string, std::pair<bool, Locals> >::iterator iter =
                mScripts.find (script.mId);

            if (iter==mScripts.end())
            {
                if (const ESM::Script *scriptRecord = mStore.get<ESM::Script>().search (script.mId))
                {
                    std::pair<bool, Locals> data (false, Locals());

                    data.second.configure (*scriptRecord);

                    iter = mScripts.insert (std::make_pair (script.mId, data)).first;
                }
                else // script does not exist anymore
                    return true;
            }

            iter->second.first = script.mRunning!=0;
            iter->second.second.read (script.mLocals, script.mId);

            return true;
        }

        return false;
    }
コード例 #2
0
ファイル: globalscripts.cpp プロジェクト: A1-Triard/openmw
    bool GlobalScripts::readRecord (ESM::ESMReader& reader, uint32_t type)
    {
        if (type==ESM::REC_GSCR)
        {
            ESM::GlobalScript script;
            script.load (reader);

            std::map<std::string, GlobalScriptDesc>::iterator iter =
                mScripts.find (script.mId);

            if (iter==mScripts.end())
            {
                if (const ESM::Script *scriptRecord = mStore.get<ESM::Script>().search (script.mId))
                {
                    try
                    {
                        GlobalScriptDesc desc;
                        desc.mLocals.configure (*scriptRecord);

                        iter = mScripts.insert (std::make_pair (script.mId, desc)).first;
                    }
                    catch (const std::exception& exception)
                    {
                        std::cerr
                            << "Failed to add start script " << script.mId
                            << " because an exception has been thrown: " << exception.what()
                            << std::endl;

                        return true;
                    }
                }
                else // script does not exist anymore
                    return true;
            }

            iter->second.mRunning = script.mRunning!=0;
            iter->second.mLocals.read (script.mLocals, script.mId);
            iter->second.mId = script.mTargetId;

            return true;
        }

        return false;
    }