Destroy components in reverse order of construction.

Components have some initialisation-order dependency. They could also
have destroy-order dependency, and from a RAII-like point of view, it
makes sense to do this.

Differential Revision: https://code.wildfiregames.com/D3843
This was SVN commit r25251.
This commit is contained in:
wraitii
2021-04-13 13:47:59 +00:00
parent 0a59489824
commit e36c8c3763
@@ -459,9 +459,9 @@ void CComponentManager::ResetState()
m_DynamicMessageSubscriptionsNonsync.clear();
m_DynamicMessageSubscriptionsNonsyncByComponent.clear();
// Delete all IComponents
std::map<ComponentTypeId, std::map<entity_id_t, IComponent*> >::iterator iit = m_ComponentsByTypeId.begin();
for (; iit != m_ComponentsByTypeId.end(); ++iit)
// Delete all IComponents in reverse order of creation.
std::map<ComponentTypeId, std::map<entity_id_t, IComponent*> >::reverse_iterator iit = m_ComponentsByTypeId.rbegin();
for (; iit != m_ComponentsByTypeId.rend(); ++iit)
{
std::map<entity_id_t, IComponent*>::iterator eit = iit->second.begin();
for (; eit != iit->second.end(); ++eit)