@@ -682,7 +682,7 @@ bool CCollisionSet::Contains(void *pObject)
682
682
return m_pSet.find (pObject) != m_pSet.end ();
683
683
}
684
684
685
- void CCollisionSet::Clear (void *pObject )
685
+ void CCollisionSet::Clear ()
686
686
{
687
687
m_pSet.clear ();
688
688
}
@@ -726,21 +726,13 @@ bool CCollisionSet::ShouldHitEntity(CBaseEntity *pEntity, CBaseEntity *pOther)
726
726
// -----------------------------------------------------------------------------
727
727
boost::shared_ptr<CCollisionSet> CCollisionMap::Find (CBaseEntityWrapper *pEntity)
728
728
{
729
- boost::shared_ptr<CCollisionSet> spSet;
730
- spSet = m_mapSets[pEntity];
731
-
732
- if (!get_pointer (spSet)) {
733
- if (!pEntity->IsNetworked ()) {
734
- BOOST_RAISE_EXCEPTION (
735
- PyExc_ValueError,
736
- " Given entity is not networked."
737
- )
738
- }
739
-
740
- spSet = boost::shared_ptr<CCollisionSet>(new CCollisionSet (false ));
741
- m_mapSets[pEntity] = spSet;
729
+ CollisionMap_t::const_iterator it = m_mapSets.find (pEntity);
730
+ if (it != m_mapSets.end ()) {
731
+ return it->second ;
742
732
}
743
733
734
+ boost::shared_ptr<CCollisionSet> spSet = boost::shared_ptr<CCollisionSet>(new CCollisionSet (false ));
735
+ m_mapSets[pEntity] = spSet;
744
736
return spSet;
745
737
}
746
738
@@ -774,8 +766,7 @@ object CCollisionMap::Iterate()
774
766
list oElements;
775
767
776
768
if (HasElements ()) {
777
- for (boost::unordered_map<void *, boost::shared_ptr<CCollisionSet> >::const_iterator it = m_mapSets.begin ();
778
- it != m_mapSets.end (); it++) {
769
+ for (CollisionMap_t::const_iterator it = m_mapSets.begin (); it != m_mapSets.end (); it++) {
779
770
oElements.append (make_tuple (object (it->first ), object (it->second )));
780
771
}
781
772
}
@@ -785,8 +776,7 @@ object CCollisionMap::Iterate()
785
776
786
777
void CCollisionMap::OnEntityDeleted (CBaseEntity *pEntity)
787
778
{
788
- for (boost::unordered_map<void *, boost::shared_ptr<CCollisionSet> >::const_iterator it = m_mapSets.begin ();
789
- it != m_mapSets.end (); it++) {
779
+ for (CollisionMap_t::const_iterator it = m_mapSets.begin (); it != m_mapSets.end (); it++) {
790
780
it->second ->OnEntityDeleted (pEntity);
791
781
}
792
782
@@ -795,8 +785,14 @@ void CCollisionMap::OnEntityDeleted(CBaseEntity *pEntity)
795
785
796
786
bool CCollisionMap::ShouldHitEntity (CBaseEntity *pEntity, CBaseEntity *pOther)
797
787
{
798
- CCollisionSet *pSet = get_pointer (m_mapSets[pEntity]);
788
+ CollisionMap_t::const_iterator it = m_mapSets.find (pEntity);
789
+ if (it == m_mapSets.end ()) {
790
+ return true ;
791
+ }
792
+
793
+ CCollisionSet *pSet = get_pointer (it->second );
799
794
if (!pSet) {
795
+ m_mapSets.erase (it);
800
796
return true ;
801
797
}
802
798
0 commit comments