Fixed some potential sources of errors.

This was SVN commit r4539.
This commit is contained in:
Matei
2006-10-10 05:21:41 +00:00
parent e1c888eca0
commit 78382c14c9
4 changed files with 8 additions and 4 deletions
+1
View File
@@ -1686,6 +1686,7 @@ Handle snd_open(const char* snd_fn, bool is_stream)
*/
LibError snd_free(Handle& hvs)
{
if(!hvs) return INFO::OK;
return h_free(hvs, H_VSrc);
}
+4 -3
View File
@@ -757,8 +757,9 @@ int CEntity::DestroyNotifier( CEntity* target )
std::vector<CEntity*>::iterator newEnd2 = std::remove_if(
m_notifiers.begin(), m_notifiers.end(),
bind2nd(std::equal_to<CEntity*>(), target));
int removed = std::distance(newEnd2, m_notifiers.end());
m_notifiers.erase(newEnd2, m_notifiers.end());
int removed = m_notifiers.end() - newEnd2;
//m_notifiers.erase(newEnd2, m_notifiers.end());
m_notifiers.resize(m_notifiers.size() - removed);
return removed;
}
void CEntity::DestroyAllNotifiers()
@@ -766,7 +767,7 @@ void CEntity::DestroyAllNotifiers()
debug_assert(entf_get(ENTF_DESTROY_NOTIFIERS));
//Make them stop listening to us
while ( ! m_notifiers.empty() )
DestroyNotifier( m_notifiers[0] );
DestroyNotifier( m_notifiers[m_notifiers.size()-1] );
}
CEntityFormation* CEntity::GetFormation()
{
+1
View File
@@ -191,6 +191,7 @@ void CEntityManager::GetInRange( float x, float z, float radius, std::vector<CEn
for( size_t i=0; i<vec.size(); i++ )
{
CEntity* e = vec[i];
debug_assert(e != 0);
float dx = x - e->m_position.X;
float dz = z - e->m_position.Z;
if( dx*dx + dz*dz <= radiusSq )
+2 -1
View File
@@ -118,7 +118,8 @@ bool JSI_Sound::Loop( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(a
// sounds are freed automatically when done playing.
bool JSI_Sound::Free( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) )
{
snd_free(m_Handle); // resets it to 0
if(m_Handle)
snd_free(m_Handle); // resets it to 0
return true;
}