Maybe fixed nasty memory corruption bug.

This was SVN commit r2254.
This commit is contained in:
Ykkrosh
2005-05-09 02:29:33 +00:00
parent f6e864c9f6
commit bcc4aea8dc
3 changed files with 17 additions and 3 deletions
+2 -3
View File
@@ -182,9 +182,8 @@ int CMapReader::ApplyData()
}
}
// remove all existing entities (by recreating the entity manager)
delete &g_EntityManager;
new CEntityManager();
// delete all existing entities
g_EntityManager.deleteAll();
// delete all remaining non-entity units
pUnitMan->DeleteAll();
+13
View File
@@ -28,6 +28,19 @@ CEntityManager::~CEntityManager()
delete( m_entities[i].m_entity );
}
void CEntityManager::deleteAll()
{
m_extant = false;
for( int i = 0; i < MAX_HANDLES; i++ )
if( m_entities[i].m_refcount )
{
delete( m_entities[i].m_entity );
m_entities[i].m_refcount = 0;
}
m_nextalloc = 0;
m_extant = true;
}
HEntity CEntityManager::create( CBaseEntity* base, CVector3D position, float orientation )
{
assert( base );
+2
View File
@@ -54,6 +54,8 @@ public:
void TickAll();
void renderAll();
void deleteAll();
// Predicate functions
typedef bool (*EntityPredicate)( CEntity* target, void* userdata );