Ticket #3238: trigger-STmode.patch

File trigger-STmode.patch, 2.4 KB (added by Itms, 9 years ago)
  • source/simulation2/Simulation2.cpp

     
    103103
    104104    static bool LoadDefaultScripts(CComponentManager& componentManager, std::set<VfsPath>* loadedScripts);
    105105    static bool LoadScripts(CComponentManager& componentManager, std::set<VfsPath>* loadedScripts, const VfsPath& path);
    106     static bool LoadTriggerScripts(CComponentManager& componentManager, JS::HandleValue mapSettings, std::set<VfsPath>* loadedScripts);
     106    static bool LoadTriggerScripts(CComponentManager& componentManager, JS::HandleValue mapSettings, std::set<VfsPath>* loadedScripts, bool acceptMultipleLoad = false);
    107107    Status ReloadChangedFile(const VfsPath& path);
    108108
    109109    static Status ReloadChangedFileCB(void* param, const VfsPath& path)
     
    199199    return ok;
    200200}
    201201
    202 bool CSimulation2Impl::LoadTriggerScripts(CComponentManager& componentManager, JS::HandleValue mapSettings, std::set<VfsPath>* loadedScripts)
     202bool CSimulation2Impl::LoadTriggerScripts(CComponentManager& componentManager, JS::HandleValue mapSettings, std::set<VfsPath>* loadedScripts, bool acceptMultipleLoad)
    203203{
    204204    bool ok = true;
    205205    if (componentManager.GetScriptInterface().HasProperty(mapSettings, "TriggerScripts"))
     
    211211            std::string scriptName = "maps/" + scriptNames[i];
    212212            if (loadedScripts)
    213213            {
    214                 if (loadedScripts->find(scriptName) != loadedScripts->end())
     214                if (!acceptMultipleLoad && loadedScripts->find(scriptName) != loadedScripts->end())
    215215                    return true;
    216216                loadedScripts->insert(scriptName);
    217217            }
     
    371371        ResetComponentState(secondaryComponentManager, false, false);
    372372
    373373        // Load the trigger scripts after we have loaded the simulation.
     374        // Make sure scripts are not discarded because already loaded in the first simulation.
    374375        {
    375376            JSContext* cx2 = secondaryComponentManager.GetScriptInterface().GetContext();
    376377            JSAutoRequest rq2(cx2);
     
    377378            JS::RootedValue mapSettingsCloned(cx2,
    378379                secondaryComponentManager.GetScriptInterface().CloneValueFromOtherContext(
    379380                    scriptInterface, m_MapSettings));
    380             ENSURE(LoadTriggerScripts(secondaryComponentManager, mapSettingsCloned, &m_LoadedScripts));
     381            ENSURE(LoadTriggerScripts(secondaryComponentManager, mapSettingsCloned, &m_LoadedScripts, true));
    381382        }
    382383
    383384        // Load the map into the secondary simulation