This commit is contained in:
parent
154c1a0ac5
commit
89f269ae72
@ -208,7 +208,8 @@ void CBasePickup::setPos(const DVECTOR *_pos)
|
|||||||
void CBasePickup::collect(class CPlayer *_player)
|
void CBasePickup::collect(class CPlayer *_player)
|
||||||
{
|
{
|
||||||
shutdown();
|
shutdown();
|
||||||
delete this;
|
CThingManager::DeleteThing(this);
|
||||||
|
// delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
===========================================================================*/
|
===========================================================================*/
|
||||||
|
|
||||||
//#define USE_FREE_LIST
|
#define USE_FREE_LIST
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Includes
|
Includes
|
||||||
-------- */
|
-------- */
|
||||||
@ -96,6 +96,8 @@ sBBox CThingManager::m_ThinkBBox;
|
|||||||
#ifdef USE_FREE_LIST
|
#ifdef USE_FREE_LIST
|
||||||
CThing **CThingManager::s_FreeList[CThing::MAX_TYPE];
|
CThing **CThingManager::s_FreeList[CThing::MAX_TYPE];
|
||||||
CThing *DuffList;
|
CThing *DuffList;
|
||||||
|
int FreeListCount=0;
|
||||||
|
int DuffListCount=0;
|
||||||
|
|
||||||
|
|
||||||
struct sFreeListTable
|
struct sFreeListTable
|
||||||
@ -349,16 +351,15 @@ DVECTOR const &CamPos=CLevel::getCameraPos();
|
|||||||
{
|
{
|
||||||
// Check If in Thinkable range
|
// Check If in Thinkable range
|
||||||
CRECT const *ThingRect= thing->getThinkBBox();
|
CRECT const *ThingRect= thing->getThinkBBox();
|
||||||
bool Flag=true;
|
int lastFlag=thing->getThinkFlag()<<1;
|
||||||
|
int Flag=1;
|
||||||
// Will speed this up
|
// Will speed this up
|
||||||
|
|
||||||
if (!thing->alwaysThink())
|
if (!thing->alwaysThink())
|
||||||
{
|
{
|
||||||
if (ThingRect->x2<m_ThinkBBox.XMin || ThingRect->x1>m_ThinkBBox.XMax) Flag=false;
|
if (ThingRect->x2<m_ThinkBBox.XMin || ThingRect->x1>m_ThinkBBox.XMax) Flag=0;
|
||||||
if (ThingRect->y2<m_ThinkBBox.YMin || ThingRect->y1>m_ThinkBBox.YMax) Flag=false;
|
if (ThingRect->y2<m_ThinkBBox.YMin || ThingRect->y1>m_ThinkBBox.YMax) Flag=0;
|
||||||
}
|
}
|
||||||
thing->setThinkFlag(Flag);
|
thing->setThinkFlag(Flag);
|
||||||
|
|
||||||
if (Flag)
|
if (Flag)
|
||||||
{
|
{
|
||||||
thing->think(_frames);
|
thing->think(_frames);
|
||||||
@ -368,6 +369,25 @@ DVECTOR const &CamPos=CLevel::getCameraPos();
|
|||||||
CThingManager::addToCollisionList(thing);
|
CThingManager::addToCollisionList(thing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Flag|=lastFlag;
|
||||||
|
switch (Flag)
|
||||||
|
{ // Last This
|
||||||
|
case 0: // 0 0
|
||||||
|
break;
|
||||||
|
case 1: // 0 1
|
||||||
|
thing->enterThingZone(_frames);
|
||||||
|
break;
|
||||||
|
case 2: // 1 0
|
||||||
|
thing->leftThingZone(_frames);
|
||||||
|
break;
|
||||||
|
case 3: // 1 1
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT("Invalid Think State");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* THIS WILL NOT STAY HERE, THINGS MUST BE INITIALISED CORRECTLY */
|
/* THIS WILL NOT STAY HERE, THINGS MUST BE INITIALISED CORRECTLY */
|
||||||
thing->updateCollisionArea();
|
thing->updateCollisionArea();
|
||||||
|
|
||||||
@ -387,7 +407,6 @@ DVECTOR const &CamPos=CLevel::getCameraPos();
|
|||||||
if (player && playerThing)
|
if (player && playerThing)
|
||||||
{
|
{
|
||||||
playerThing->setHasPlatformCollided( false );
|
playerThing->setHasPlatformCollided( false );
|
||||||
//!Dave! playerThing->setNewCollidedPos( playerThing->getPos() );
|
|
||||||
|
|
||||||
// Player -> Platform collision
|
// Player -> Platform collision
|
||||||
thing1=s_CollisionLists[CThing::TYPE_PLATFORM];
|
thing1=s_CollisionLists[CThing::TYPE_PLATFORM];
|
||||||
@ -781,6 +800,7 @@ void CThingManager::resetFreeList()
|
|||||||
{
|
{
|
||||||
CThing *Next=ThisThing->NextFreeThing;
|
CThing *Next=ThisThing->NextFreeThing;
|
||||||
delete ThisThing;
|
delete ThisThing;
|
||||||
|
FreeListCount--;
|
||||||
ThisThing=Next;
|
ThisThing=Next;
|
||||||
}
|
}
|
||||||
List[t]=0;
|
List[t]=0;
|
||||||
@ -791,6 +811,7 @@ void CThingManager::resetFreeList()
|
|||||||
{
|
{
|
||||||
CThing *next=Duff->NextFreeThing;
|
CThing *next=Duff->NextFreeThing;
|
||||||
delete Duff;
|
delete Duff;
|
||||||
|
DuffListCount--;
|
||||||
Duff=next;
|
Duff=next;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -816,12 +837,12 @@ CThing *CThingManager::GetThing(int Type,int SubType)
|
|||||||
CThing **List=s_FreeList[Type];
|
CThing **List=s_FreeList[Type];
|
||||||
CThing *Thing=List[SubType];
|
CThing *Thing=List[SubType];
|
||||||
|
|
||||||
|
|
||||||
if (Thing)
|
if (Thing)
|
||||||
{
|
{
|
||||||
List[SubType]=Thing->NextFreeThing;
|
List[SubType]=Thing->NextFreeThing;
|
||||||
Thing->initDef();
|
Thing->initDef();
|
||||||
Thing->NextFreeThing=0;
|
Thing->NextFreeThing=0;
|
||||||
|
FreeListCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(Thing);
|
return(Thing);
|
||||||
@ -840,18 +861,19 @@ CThing **List=s_FreeList[Type];
|
|||||||
|
|
||||||
// Check its been aquired/set correctly
|
// Check its been aquired/set correctly
|
||||||
// Temp workaround
|
// Temp workaround
|
||||||
// ASSERT(SubType!=1234);
|
ASSERT(SubType!=1234);
|
||||||
if (SubType!=1234)
|
if (SubType!=1234)
|
||||||
{
|
{
|
||||||
Thing->NextFreeThing=List[SubType];
|
Thing->NextFreeThing=List[SubType];
|
||||||
List[SubType]=Thing;
|
List[SubType]=Thing;
|
||||||
|
FreeListCount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// delete Thing;
|
// delete Thing;
|
||||||
Thing->NextFreeThing=DuffList;
|
Thing->NextFreeThing=DuffList;
|
||||||
DuffList=Thing;
|
DuffList=Thing;
|
||||||
|
DuffListCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -872,10 +894,8 @@ CThing **List=s_FreeList[Type];
|
|||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
int DaveDbg=1;
|
|
||||||
void CThing::init()
|
void CThing::init()
|
||||||
{
|
{
|
||||||
ASSERT(DaveDbg);
|
|
||||||
ParentThing=NULL;
|
ParentThing=NULL;
|
||||||
NextThing=NULL;
|
NextThing=NULL;
|
||||||
m_numChildren = 0;
|
m_numChildren = 0;
|
||||||
@ -884,7 +904,6 @@ void CThing::init()
|
|||||||
// These need to stay for init
|
// These need to stay for init
|
||||||
setCollisionSize(20,20); // Some temporary defaults.. (pkg)
|
setCollisionSize(20,20); // Some temporary defaults.. (pkg)
|
||||||
setCollisionCentreOffset(0,0);
|
setCollisionCentreOffset(0,0);
|
||||||
//!Dave! setCollisionAngle(0);
|
|
||||||
|
|
||||||
// Add to thing list
|
// Add to thing list
|
||||||
CThingManager::addToThingList(this);
|
CThingManager::addToThingList(this);
|
||||||
@ -898,6 +917,7 @@ void CThing::init()
|
|||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
void CThing::shutdown()
|
void CThing::shutdown()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ParentThing)
|
if (ParentThing)
|
||||||
{ // Is child
|
{ // Is child
|
||||||
ParentThing->removeChild(this);
|
ParentThing->removeChild(this);
|
||||||
@ -922,8 +942,6 @@ void CThing::think(int _frames)
|
|||||||
PosDelta.vx=Pos.vx-PosLast.vx;
|
PosDelta.vx=Pos.vx-PosLast.vx;
|
||||||
PosDelta.vy=Pos.vy-PosLast.vy;
|
PosDelta.vy=Pos.vy-PosLast.vy;
|
||||||
PosLast=Pos;
|
PosLast=Pos;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
@ -182,14 +182,14 @@ 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;}
|
||||||
virtual bool alwaysThink() {return(false);}
|
virtual bool alwaysThink() {return(false);}
|
||||||
|
virtual void leftThingZone(int _frames) {}
|
||||||
|
virtual void enterThingZone(int _frames) {}
|
||||||
|
|
||||||
void ShowBBox();
|
void ShowBBox();
|
||||||
DVECTOR const &getCollisionCentre() {return m_collisionCentre;}
|
DVECTOR const &getCollisionCentre() {return m_collisionCentre;}
|
||||||
DVECTOR const &getCollisionCentreOffset() {return m_collisionCentreOffset;}
|
DVECTOR const &getCollisionCentreOffset() {return m_collisionCentreOffset;}
|
||||||
int getCollisionRadius() {return m_collisionRadius;}
|
int getCollisionRadius() {return m_collisionRadius;}
|
||||||
virtual CRECT const &getCollisionArea() {return m_collisionArea;}
|
virtual CRECT const &getCollisionArea() {return m_collisionArea;}
|
||||||
//!Dave! s16 getCollisionAngle() {return m_collisionAngle;} // pkg - move to CNpcPlatform?
|
|
||||||
//!Dave! DVECTOR const &getNewCollidedPos() {return m_newCollidedPos;} // pkg - to be removed?
|
|
||||||
DVECTOR const &getCollisionSize() {return m_collisionSize;}
|
DVECTOR const &getCollisionSize() {return m_collisionSize;}
|
||||||
|
|
||||||
virtual int canCollide() {return true;}
|
virtual int canCollide() {return true;}
|
||||||
@ -200,12 +200,12 @@ virtual void collidedWith(CThing *_thisThing) {;}
|
|||||||
virtual void setHasPlatformCollided( bool newVal ) {;}
|
virtual void setHasPlatformCollided( bool newVal ) {;}
|
||||||
virtual bool getHasPlatformCollided() {return false;}
|
virtual bool getHasPlatformCollided() {return false;}
|
||||||
virtual s32 getNewYPos( CThing *_thisThing );
|
virtual s32 getNewYPos( CThing *_thisThing );
|
||||||
//!Dave! void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed?
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Thing states
|
// 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 getThinkFlag() {return(m_thinkFlag);}
|
||||||
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);}
|
||||||
@ -219,15 +219,13 @@ protected:
|
|||||||
virtual void setCollisionSize(int _w,int _h);
|
virtual void setCollisionSize(int _w,int _h);
|
||||||
virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
|
virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
|
||||||
virtual void setCollisionCentreOffset(DVECTOR xy) {m_collisionCentreOffset=xy;}
|
virtual void setCollisionCentreOffset(DVECTOR xy) {m_collisionCentreOffset=xy;}
|
||||||
//!Dave!virtual void setCollisionAngle(int newAngle) {m_collisionAngle = newAngle;} // pkg - move to CNpcPlatform?
|
|
||||||
private:
|
private:
|
||||||
DVECTOR m_collisionSize;
|
DVECTOR m_collisionSize;
|
||||||
DVECTOR m_collisionCentreOffset;
|
DVECTOR m_collisionCentreOffset;
|
||||||
int m_collisionRadius;
|
int m_collisionRadius;
|
||||||
CRECT m_collisionArea;
|
CRECT m_collisionArea;
|
||||||
DVECTOR m_collisionCentre;
|
DVECTOR m_collisionCentre;
|
||||||
//!Dave! s16 m_collisionAngle; // pkg - move to CNpcPlatform?
|
|
||||||
//!Dave! DVECTOR m_newCollidedPos; // pkg - to be removed?
|
|
||||||
|
|
||||||
// Free List Stuff
|
// Free List Stuff
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user