This commit is contained in:
Daveo 2001-05-21 15:19:18 +00:00
parent 4258538252
commit f423ae5fad
2 changed files with 58 additions and 44 deletions

View File

@ -559,8 +559,8 @@ int Type=thing->getThingType();
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CThing::init() void CThing::init()
{ {
Parent=NULL; ParentThing=NULL;
Next=NULL; NextThing=NULL;
m_numChildren = 0; m_numChildren = 0;
Pos.vx=Pos.vy=10; Pos.vx=Pos.vy=10;
@ -582,9 +582,9 @@ void CThing::init()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CThing::shutdown() void CThing::shutdown()
{ {
if (Parent) if (ParentThing)
{ // Is child { // Is child
Parent->removeChild(this); ParentThing->removeChild(this);
} }
else else
{ // Is Parent { // Is Parent
@ -762,24 +762,24 @@ void CThing::ShowBBox()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CThing::addChild(CThing *Child) void CThing::addChild(CThing *Child)
{ {
CThing *List=Next; CThing *List=NextThing;
if ( List ) if ( List )
{ {
// Find end of list // Find end of list
while (List->Next) while (List->NextThing)
{ {
List=List->Next; List=List->NextThing;
} }
List->Next=Child; List->NextThing=Child;
Child->Parent=this; Child->ParentThing=this;
m_numChildren++; m_numChildren++;
} }
else else
{ {
// List does not exist, create // List does not exist, create
Next = Child; NextThing = Child;
Child->Parent=this; Child->ParentThing=this;
m_numChildren++; m_numChildren++;
} }
} }
@ -792,14 +792,14 @@ CThing *List=Next;
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CThing::removeChild(CThing *Child) void CThing::removeChild(CThing *Child)
{ {
CThing *List=Next; CThing *List=NextThing;
CThing *Last=NULL; CThing *Last=NULL;
// Find Child // Find Child
while ( List != Child && List->Next ) while ( List != Child && List->NextThing )
{ {
Last = List; Last = List;
List = List->Next; List = List->NextThing;
} }
// if there are no more links to continue down, the current 'List' must either be the correct item, or the item does not // if there are no more links to continue down, the current 'List' must either be the correct item, or the item does not
@ -809,16 +809,16 @@ CThing *Last=NULL;
if ( Last ) if ( Last )
{ {
Last->Next = List->Next; Last->NextThing = List->NextThing;
} }
else else
{ {
this->Next = List->Next; this->NextThing = List->NextThing;
} }
m_numChildren--; m_numChildren--;
Child->Parent=NULL; Child->ParentThing=NULL;
} }
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -829,16 +829,16 @@ CThing *Last=NULL;
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CThing::removeAllChild() void CThing::removeAllChild()
{ {
CThing *List=Next; CThing *List=NextThing;
while (List) while (List)
{ {
CThing *Next=List->Next; CThing *NextThing=List->NextThing;
List->Parent=NULL; List->ParentThing=NULL;
List->Next=NULL; List->NextThing=NULL;
List=Next; List=NextThing;
} }
Next=NULL; NextThing=NULL;
m_numChildren = 0; m_numChildren = 0;
} }
@ -851,18 +851,18 @@ CThing *List=Next;
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CThing::deleteAllChild() void CThing::deleteAllChild()
{ {
CThing *List=Next; CThing *List=NextThing;
while (List) while (List)
{ {
CThing *Next=List->Next; CThing *NextThing=List->NextThing;
List->Parent=NULL; List->ParentThing=NULL;
List->Next=NULL; List->NextThing=NULL;
List->shutdown(); List->shutdown();
delete List; delete List;
List=Next; List=NextThing;
} }
Next=NULL; NextThing=NULL;
m_numChildren = 0; m_numChildren = 0;
} }
@ -886,7 +886,7 @@ int CThing::getNumChildren()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
bool CThing::hasChild(CThing *Child) bool CThing::hasChild(CThing *Child)
{ {
CThing *nextChild = Next; CThing *nextChild = NextThing;
while( nextChild ) while( nextChild )
{ {
@ -895,7 +895,7 @@ bool CThing::hasChild(CThing *Child)
return( true ); return( true );
} }
nextChild = nextChild->Next; nextChild = nextChild->NextThing;
} }
return( false ); return( false );

View File

@ -82,6 +82,9 @@ private:
static CThing *s_CollisionLists[]; static CThing *s_CollisionLists[];
static sBBox m_RenderBBox; static sBBox m_RenderBBox;
static sBBox m_ThinkBBox; static sBBox m_ThinkBBox;
// static CThing *s_FreeList[];
}; };
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
@ -130,24 +133,28 @@ virtual int dontKillDuringLevelRespawn() {return false;}
DVECTOR const &getPos() {return Pos;} DVECTOR const &getPos() {return Pos;}
void setPos(DVECTOR newPos) {Pos=newPos;} void setPos(DVECTOR newPos) {Pos=newPos;}
DVECTOR getPosDelta() {return PosDelta;} DVECTOR getPosDelta() {return PosDelta;}
CThing *getNext() {return Next;} CThing *getParent() {return ParentThing;}
CThing *getNext() {return NextThing;}
virtual void processEvent(GAME_EVENT _event,CThing *_sourceThing); virtual void processEvent(GAME_EVENT _event,CThing *_sourceThing);
protected: protected:
// Parent Child Linkage
CThing *Parent,*Next;
// Count
int m_numChildren;
// Pos // Pos
DVECTOR Pos, PosLast, PosDelta; DVECTOR Pos, PosLast, PosDelta;
public: // Parent Child Linkage
CThing *m_nextListThing; CThing *ParentThing,*NextThing;
CThing *m_nextCollisionThing; int m_numChildren;
// -- Collision -- public:
// Collision/List Link List
CThing *m_nextCollisionThing;
CThing *m_nextListThing;
public:
CThing *m_NextFreeThing;
// -- Collision --
public: public:
virtual CRECT const *getRenderBBox() {return &m_collisionArea;} virtual CRECT const *getRenderBBox() {return &m_collisionArea;}
virtual CRECT const *getThinkBBox() {return &m_collisionArea;} virtual CRECT const *getThinkBBox() {return &m_collisionArea;}
@ -172,11 +179,18 @@ virtual bool getHasPlatformCollided() {return false;}
virtual s32 getNewYPos( CThing *_thisThing ); virtual s32 getNewYPos( CThing *_thisThing );
void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed? void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed?
public:
// Thing states
void setRenderFlag(bool f) {m_renderFlag=f;} void setRenderFlag(bool f) {m_renderFlag=f;}
void setThinkFlag(bool f) {m_thinkFlag=f;} void setThinkFlag(bool f) {m_thinkFlag=f;}
bool canRender() {return (m_renderFlag);} bool canRender() {return (m_renderFlag);}
DVECTOR &getRenderPos() {return(m_RenderPos);} DVECTOR &getRenderPos() {return(m_RenderPos);}
bool canThink() {return (m_thinkFlag);} bool canThink() {return (m_thinkFlag);}
protected:
bool m_renderFlag,m_thinkFlag;
DVECTOR m_RenderPos;
bool m_isShuttingDown;
protected: protected:
virtual void setCollisionSize(int _w,int _h); virtual void setCollisionSize(int _w,int _h);
@ -192,9 +206,9 @@ private:
s16 m_collisionAngle; // pkg - move to CNpcPlatform? s16 m_collisionAngle; // pkg - move to CNpcPlatform?
DVECTOR m_newCollidedPos; // pkg - to be removed? DVECTOR m_newCollidedPos; // pkg - to be removed?
bool m_renderFlag,m_thinkFlag; // Free List Stuff
DVECTOR m_RenderPos; public:
bool m_isShuttingDown; //virtual int getMaxType()=0;
}; };
/*---------------------------------------------------------------------- */ /*---------------------------------------------------------------------- */