1
0
forked from 0ad/0ad

Fix hotloading of scripts with registered message handlers

This was SVN commit r7307.
This commit is contained in:
Ykkrosh 2010-02-05 21:40:08 +00:00
parent bd4cd244cf
commit 7770b414b7

View File

@ -165,6 +165,23 @@ void CComponentManager::Script_RegisterComponentType(void* cbdata, int iid, std:
// Clean up the old component type
componentManager->m_ScriptInterface.RemoveRoot(&componentManager->m_ComponentTypesById[cid].ctor);
// Remove its old message subscriptions
std::map<MessageTypeId, std::vector<ComponentTypeId> >::iterator it;
for (it = componentManager->m_LocalMessageSubscriptions.begin(); it != componentManager->m_LocalMessageSubscriptions.end(); ++it)
{
std::vector<ComponentTypeId>& types = it->second;
std::vector<ComponentTypeId>::iterator ctit = find(types.begin(), types.end(), cid);
if (ctit != types.end())
types.erase(ctit);
}
for (it = componentManager->m_GlobalMessageSubscriptions.begin(); it != componentManager->m_GlobalMessageSubscriptions.end(); ++it)
{
std::vector<ComponentTypeId>& types = it->second;
std::vector<ComponentTypeId>::iterator ctit = find(types.begin(), types.end(), cid);
if (ctit != types.end())
types.erase(ctit);
}
mustReloadComponents = true;
}