Modified semantics of HEntity's validity check to count handles to units that are destroyed but not deleted as still valid handles. This fixes some previous code that assumed these semantics, such as code for dealing with exhausted gather targets. It looks like the meaning was changed long ago when the entity flags were added. Also added an IsAlive method in HEntity for the old check, in case any code needs to be switched over to that.
Also removed some debug output from entity_functions.js. This was SVN commit r5074.
This commit is contained in:
parent
dcf253714f
commit
2e5c530c03
@ -1963,7 +1963,6 @@ function InfidelityAura( source, time )
|
||||
{
|
||||
if( this.count[i] > 0 )
|
||||
{
|
||||
console.write( "Starting convert timer" );
|
||||
this.convertTimer = setTimeout( this.convert, parseInt( this.time * 1000 ), this );
|
||||
return;
|
||||
}
|
||||
@ -1974,7 +1973,6 @@ function InfidelityAura( source, time )
|
||||
// If we had started a convert timer before, cancel it (either we have units from our owner in range, or there are no units from anyone in range)
|
||||
if( this.convertTimer )
|
||||
{
|
||||
console.write( "Cancelling convert timer" );
|
||||
cancelTimer( this.convertTimer );
|
||||
this.convertTimer = 0;
|
||||
}
|
||||
@ -1982,8 +1980,6 @@ function InfidelityAura( source, time )
|
||||
|
||||
this.convert = function()
|
||||
{
|
||||
console.write( "Conversion time!" );
|
||||
|
||||
// Switch ownership to whichever non-gaia player has the most units near us
|
||||
bestPlayer = 0;
|
||||
bestCount = 0;
|
||||
|
@ -47,22 +47,19 @@ bool HEntity::operator ==( const HEntity& test ) const
|
||||
return( m_handle == test.m_handle );
|
||||
}
|
||||
|
||||
HEntity::operator bool() const
|
||||
bool HEntity::IsValid() const
|
||||
{
|
||||
if( m_handle == INVALID_HANDLE )
|
||||
return( false );
|
||||
|
||||
debug_assert( g_EntityManager.m_entities[m_handle].m_refcount );
|
||||
return( !g_EntityManager.m_entities[m_handle].m_entity->entf_get(ENTF_DESTROYED) );
|
||||
//return( !g_EntityManager.m_entities[m_handle].m_entity->entf_get(ENTF_DESTROYED) );
|
||||
return( true );
|
||||
}
|
||||
|
||||
bool HEntity::operator!() const
|
||||
{
|
||||
if( m_handle == INVALID_HANDLE )
|
||||
return( true );
|
||||
|
||||
debug_assert( g_EntityManager.m_entities[m_handle].m_refcount );
|
||||
return( g_EntityManager.m_entities[m_handle].m_entity->entf_get(ENTF_DESTROYED) );
|
||||
bool HEntity::IsAlive() const
|
||||
{
|
||||
return( IsValid() && !g_EntityManager.m_entities[m_handle].m_entity->entf_get(ENTF_DESTROYED) );
|
||||
}
|
||||
|
||||
void HEntity::AddRef()
|
||||
|
@ -50,19 +50,31 @@ private:
|
||||
void DecRef();
|
||||
HEntity( u16 index );
|
||||
public:
|
||||
CEntity& operator*() const;
|
||||
CEntity* operator->() const;
|
||||
HEntity();
|
||||
HEntity( const HEntity& copy );
|
||||
~HEntity();
|
||||
|
||||
void operator=( const HEntity& copy );
|
||||
|
||||
CEntity& operator*() const;
|
||||
CEntity* operator->() const;
|
||||
|
||||
bool operator==( const HEntity& test ) const;
|
||||
bool operator!=( const HEntity& test ) const { return( !operator==( test ) ); }
|
||||
operator bool() const;
|
||||
bool operator!() const;
|
||||
|
||||
operator CEntity*() const;
|
||||
// Visual C++ 2003 can't handle (bool && HEntity) expressions, so provide another alias for operator bool()
|
||||
bool IsValid() const {return this->operator bool();}
|
||||
~HEntity();
|
||||
|
||||
// Returns true iff we are a valid handle, i.e. one to a non-deleted (but possibly destroyed) entity
|
||||
bool IsValid() const;
|
||||
|
||||
// Returns true iff we are a valid handle to an entity that is not destroyed
|
||||
bool IsAlive() const;
|
||||
|
||||
// Same as IsValid(); maybe this should be removed altogether to prevent confusion?
|
||||
operator bool() const { return IsValid(); }
|
||||
|
||||
// Same as !IsValid()
|
||||
bool operator!() const { return !IsValid(); };
|
||||
|
||||
uint GetSerializedLength() const;
|
||||
u8 *Serialize(u8 *buffer) const;
|
||||
|
Loading…
Reference in New Issue
Block a user