This commit is contained in:
Daveo 2001-05-29 16:38:09 +00:00
parent 154c1a0ac5
commit 89f269ae72
3 changed files with 39 additions and 22 deletions

View File

@ -208,7 +208,8 @@ void CBasePickup::setPos(const DVECTOR *_pos)
void CBasePickup::collect(class CPlayer *_player)
{
shutdown();
delete this;
CThingManager::DeleteThing(this);
// delete this;
}

View File

@ -11,7 +11,7 @@
===========================================================================*/
//#define USE_FREE_LIST
#define USE_FREE_LIST
/*----------------------------------------------------------------------
Includes
-------- */
@ -96,6 +96,8 @@ sBBox CThingManager::m_ThinkBBox;
#ifdef USE_FREE_LIST
CThing **CThingManager::s_FreeList[CThing::MAX_TYPE];
CThing *DuffList;
int FreeListCount=0;
int DuffListCount=0;
struct sFreeListTable
@ -349,16 +351,15 @@ DVECTOR const &CamPos=CLevel::getCameraPos();
{
// Check If in Thinkable range
CRECT const *ThingRect= thing->getThinkBBox();
bool Flag=true;
int lastFlag=thing->getThinkFlag()<<1;
int Flag=1;
// Will speed this up
if (!thing->alwaysThink())
{
if (ThingRect->x2<m_ThinkBBox.XMin || ThingRect->x1>m_ThinkBBox.XMax) Flag=false;
if (ThingRect->y2<m_ThinkBBox.YMin || ThingRect->y1>m_ThinkBBox.YMax) 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=0;
}
thing->setThinkFlag(Flag);
if (Flag)
{
thing->think(_frames);
@ -368,6 +369,25 @@ DVECTOR const &CamPos=CLevel::getCameraPos();
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 */
thing->updateCollisionArea();
@ -387,7 +407,6 @@ DVECTOR const &CamPos=CLevel::getCameraPos();
if (player && playerThing)
{
playerThing->setHasPlatformCollided( false );
//!Dave! playerThing->setNewCollidedPos( playerThing->getPos() );
// Player -> Platform collision
thing1=s_CollisionLists[CThing::TYPE_PLATFORM];
@ -781,6 +800,7 @@ void CThingManager::resetFreeList()
{
CThing *Next=ThisThing->NextFreeThing;
delete ThisThing;
FreeListCount--;
ThisThing=Next;
}
List[t]=0;
@ -791,6 +811,7 @@ void CThingManager::resetFreeList()
{
CThing *next=Duff->NextFreeThing;
delete Duff;
DuffListCount--;
Duff=next;
}
#endif
@ -816,12 +837,12 @@ CThing *CThingManager::GetThing(int Type,int SubType)
CThing **List=s_FreeList[Type];
CThing *Thing=List[SubType];
if (Thing)
{
List[SubType]=Thing->NextFreeThing;
Thing->initDef();
Thing->NextFreeThing=0;
FreeListCount--;
}
return(Thing);
@ -840,18 +861,19 @@ CThing **List=s_FreeList[Type];
// Check its been aquired/set correctly
// Temp workaround
// ASSERT(SubType!=1234);
ASSERT(SubType!=1234);
if (SubType!=1234)
{
Thing->NextFreeThing=List[SubType];
List[SubType]=Thing;
FreeListCount++;
}
else
{
// delete Thing;
Thing->NextFreeThing=DuffList;
DuffList=Thing;
DuffListCount++;
}
#else
@ -872,10 +894,8 @@ CThing **List=s_FreeList[Type];
Params:
Returns:
---------------------------------------------------------------------- */
int DaveDbg=1;
void CThing::init()
{
ASSERT(DaveDbg);
ParentThing=NULL;
NextThing=NULL;
m_numChildren = 0;
@ -884,7 +904,6 @@ void CThing::init()
// These need to stay for init
setCollisionSize(20,20); // Some temporary defaults.. (pkg)
setCollisionCentreOffset(0,0);
//!Dave! setCollisionAngle(0);
// Add to thing list
CThingManager::addToThingList(this);
@ -898,6 +917,7 @@ void CThing::init()
---------------------------------------------------------------------- */
void CThing::shutdown()
{
if (ParentThing)
{ // Is child
ParentThing->removeChild(this);
@ -922,8 +942,6 @@ void CThing::think(int _frames)
PosDelta.vx=Pos.vx-PosLast.vx;
PosDelta.vy=Pos.vy-PosLast.vy;
PosLast=Pos;
}
/*----------------------------------------------------------------------

View File

@ -182,14 +182,14 @@ public:
virtual CRECT const *getRenderBBox() {return &m_collisionArea;}
virtual CRECT const *getThinkBBox() {return &m_collisionArea;}
virtual bool alwaysThink() {return(false);}
virtual void leftThingZone(int _frames) {}
virtual void enterThingZone(int _frames) {}
void ShowBBox();
DVECTOR const &getCollisionCentre() {return m_collisionCentre;}
DVECTOR const &getCollisionCentreOffset() {return m_collisionCentreOffset;}
int getCollisionRadius() {return m_collisionRadius;}
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;}
virtual int canCollide() {return true;}
@ -200,12 +200,12 @@ virtual void collidedWith(CThing *_thisThing) {;}
virtual void setHasPlatformCollided( bool newVal ) {;}
virtual bool getHasPlatformCollided() {return false;}
virtual s32 getNewYPos( CThing *_thisThing );
//!Dave! void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed?
public:
// Thing states
void setRenderFlag(bool f) {m_renderFlag=f;}
void setThinkFlag(bool f) {m_thinkFlag=f;}
bool getThinkFlag() {return(m_thinkFlag);}
bool canRender() {return (m_renderFlag);}
DVECTOR &getRenderPos() {return(m_RenderPos);}
bool canThink() {return (m_thinkFlag);}
@ -219,15 +219,13 @@ protected:
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(DVECTOR xy) {m_collisionCentreOffset=xy;}
//!Dave!virtual void setCollisionAngle(int newAngle) {m_collisionAngle = newAngle;} // pkg - move to CNpcPlatform?
private:
DVECTOR m_collisionSize;
DVECTOR m_collisionCentreOffset;
int m_collisionRadius;
CRECT m_collisionArea;
DVECTOR m_collisionCentre;
//!Dave! s16 m_collisionAngle; // pkg - move to CNpcPlatform?
//!Dave! DVECTOR m_newCollidedPos; // pkg - to be removed?
// Free List Stuff
public: