From bd3a188cf9944bfd6ac11809308f08e1ab9d959e Mon Sep 17 00:00:00 2001 From: Matei Date: Wed, 12 Jul 2006 19:31:27 +0000 Subject: [PATCH] m_sectorValues should be per-entity, not a property of BaseEntity. This was SVN commit r4084. --- source/simulation/BaseEntity.cpp | 3 --- source/simulation/BaseEntity.h | 1 - source/simulation/Entity.cpp | 11 ++++++++--- source/simulation/Entity.h | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/simulation/BaseEntity.cpp b/source/simulation/BaseEntity.cpp index 3fce2a3e90..84a6c8e46d 100644 --- a/source/simulation/BaseEntity.cpp +++ b/source/simulation/BaseEntity.cpp @@ -84,9 +84,6 @@ CBaseEntity::CBaseEntity( CPlayer* player ) m_socket = CStrW(); m_passThroughAllies = false; m_sectorDivs = 4; - m_sectorValues.resize(m_sectorDivs); - for ( int i=0; i m_sectorValues; int m_sectorDivs; int m_pitchDivs; float m_anchorConformX; diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index 4847106e10..1f120087b7 100644 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -251,6 +251,11 @@ void CEntity::loadBase() { (*it)->Remove( this ); } + + // Resize sectors array + m_sectorValues.resize(m_base->m_sectorDivs); + for ( int i=0; im_sectorDivs; ++i ) + m_sectorValues[i] = false; } void CEntity::initAttributes(const CEntity* _this) @@ -2183,7 +2188,7 @@ jsval CEntity::RegisterDamage( JSContext* cx, uintN argc, jsval* argv ) float angle = acosf( up.dot(posDelta) ); //Find what section it is between and "activate" it int sector = findSector(m_base->m_sectorDivs, angle, DEGTORAD(360.0f))-1; - m_base->m_sectorValues[sector]=true; + m_sectorValues[sector]=true; return JS_TRUE; } jsval CEntity::RegisterOrderChange( JSContext* cx, uintN argc, jsval* argv ) @@ -2202,14 +2207,14 @@ jsval CEntity::RegisterOrderChange( JSContext* cx, uintN argc, jsval* argv ) float angle = acosf( up.dot(posDelta) ); //Find what section it is between and "deactivate" it int sector = MAX( 0.0, findSector(m_base->m_sectorDivs, angle, DEGTORAD(360.0f)) ); - m_base->m_sectorValues[sector]=false; + m_sectorValues[sector]=false; return JS_TRUE; } jsval CEntity::GetAttackDirections( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(argv) ) { int directions=0; - for ( std::vector::iterator it=m_base->m_sectorValues.begin(); it != m_base->m_sectorValues.end(); it++ ) + for ( std::vector::iterator it=m_sectorValues.begin(); it != m_sectorValues.end(); it++ ) { if ( *it ) ++directions; diff --git a/source/simulation/Entity.h b/source/simulation/Entity.h index cd1a2f86a3..aa014abe66 100644 --- a/source/simulation/Entity.h +++ b/source/simulation/Entity.h @@ -234,9 +234,10 @@ public: int m_currentNotification; //Current order in the form of a notification code int m_currentRequest; //Notification we our notifiers are sending + std::vector m_sectorValues; + /* JW: these have all been 'moved' (1) into BaseEntity: 1: were already present there, just removed from here - std::vector m_sectorValues; int m_sectorDivs; int m_pitchDivs;