IsEntityRefd now checks the entity pointer as well (avoids null pointer dereference in some cases - encountered during MP game).
Simulation.cpp: hoist retrieval of simulation pointer out of loop This was SVN commit r6482.
This commit is contained in:
parent
cb257dd020
commit
6267e13760
@ -308,7 +308,7 @@ void CEntityManager::GetExtant( std::vector<CEntity*>& results )
|
||||
{
|
||||
results.clear();
|
||||
for( size_t i = 0; i < MAX_HANDLES; i++ )
|
||||
if( IsEntityRefd(i) && m_entities[i].m_entity->m_extant )
|
||||
if( IsEntityRefd(i) )
|
||||
results.push_back( m_entities[i].m_entity );
|
||||
}
|
||||
|
||||
@ -432,7 +432,7 @@ void CEntityManager::InterpolateAll( float relativeoffset )
|
||||
for( size_t i = 0; i < MAX_HANDLES; i++ )
|
||||
// This needs to handle all entities, including destroyed/non-extant ones
|
||||
// (mainly dead bodies), so it can't use IsEntityRefd
|
||||
if( m_entities[i].m_refcount )
|
||||
if( m_entities[i].m_refcount && m_entities[i].m_entity )
|
||||
m_entities[i].m_entity->Interpolate( relativeoffset );
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,8 @@ friend class CHandle;
|
||||
|
||||
inline bool IsEntityRefd( size_t index )
|
||||
{
|
||||
if(!m_entities[index].m_entity)
|
||||
return false;
|
||||
return m_refd[index];
|
||||
//return m_entities[index].m_refcount && !m_entities[index].m_entity->entf_get(ENTF_DESTROYED);
|
||||
}
|
||||
|
@ -198,12 +198,13 @@ void RandomizeLocations(const CEntityOrder& order, const std::vector<HEntity> &e
|
||||
std::vector<HEntity>::const_iterator it;
|
||||
float radius = 2.0f * sqrt( (float)entities.size() - 1 );
|
||||
|
||||
CSimulation* sim = g_Game->GetSimulation();
|
||||
|
||||
for (it = entities.begin(); it < entities.end(); it++)
|
||||
{
|
||||
float _x, _y;
|
||||
CEntityOrder randomizedOrder = order;
|
||||
|
||||
CSimulation* sim = g_Game->GetSimulation();
|
||||
do
|
||||
{
|
||||
_x = sim->RandFloat() * 2.0f - 1.0f;
|
||||
|
Loading…
Reference in New Issue
Block a user