mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-10 20:16:53 +00:00
Maybe fixed nasty memory corruption bug.
This was SVN commit r2254.
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
void TickAll();
|
||||
void renderAll();
|
||||
|
||||
void deleteAll();
|
||||
|
||||
// Predicate functions
|
||||
typedef bool (*EntityPredicate)( CEntity* target, void* userdata );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user