Ticket #2756: fix.patch
File fix.patch, 2.0 KB (added by , 10 years ago) |
---|
-
source/simulation2/components/CCmpRangeManager.cpp
1512 1512 1513 1513 void UpdateVisibility(entity_id_t ent) 1514 1514 { 1515 // Warning: Code related to fogging (like posting VisibilityChanged messages) shouldn't be invoked while 1516 // keeping an iterator to an element of m_EntityData because, by deleting mirage entities and so on, 1517 // that code will change the indexes in the map, leading to segfaults. 1515 1518 EntityMap<EntityData>::iterator itEnts = m_EntityData.find(ent); 1516 1519 if (itEnts == m_EntityData.end()) 1517 1520 return; 1518 1521 1522 // So we just remember what visibilities to update and do that later. 1519 1523 std::vector<u8> oldVisibilities; 1520 1524 std::vector<u8> newVisibilities; 1521 1525 … … 1645 1649 */ 1646 1650 void SeeExploredEntities(player_id_t p) 1647 1651 { 1652 // Warning: Code related to fogging (like ForceMiraging) shouldn't be invoked while iterating 1653 // through m_EntityData because, by deleting mirage entities and so on, that code will change the 1654 // indexes in the map, leading to segfaults. So we just remember what entities to mirage and do that later. 1655 std::vector<entity_id_t> miragableEntities; 1656 1648 1657 for (EntityMap<EntityData>::iterator it = m_EntityData.begin(); it != m_EntityData.end(); ++it) 1649 1658 { 1650 1659 CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), it->first); … … 1661 1670 1662 1671 CmpPtr<ICmpFogging> cmpFogging(GetSimContext(), it->first); 1663 1672 if (cmpFogging) 1664 cmpFogging->ForceMiraging(p);1673 miragableEntities.push_back(it->first); 1665 1674 } 1675 1676 for (std::vector<entity_id_t>::iterator it = miragableEntities.begin(); it != miragableEntities.end(); ++it) 1677 { 1678 CmpPtr<ICmpFogging> cmpFogging(GetSimContext(), *it); 1679 ENSURE(cmpFogging && "Impossible to retrieve Fogging component, previously achieved"); 1680 cmpFogging->ForceMiraging(p); 1681 } 1666 1682 } 1667 1683 1668 1684 /**