diff --git a/source/fx/fx.cpp b/source/fx/fx.cpp index 6263a0fa1..3e98054ed 100644 --- a/source/fx/fx.cpp +++ b/source/fx/fx.cpp @@ -243,11 +243,13 @@ void TestFX(DVECTOR Pos) */ /*****************************************************************************/ int FXType=(CFX::FX_TYPE)CFX::FX_TYPE_THWACK; +#include "game\game.h" void TestFX(DVECTOR Pos,CThing *Parent) { -CFXAttachAnim *FX=(CFXAttachAnim*)CFX::Create((CFX::FX_TYPE)FXType,Pos); +//CFXAttachAnim *FX=(CFXAttachAnim*)CFX::Create((CFX::FX_TYPE)FXType,Pos); // Parent->addChild(FX); // TestFXPtr->setLife(32); + CGameScene::dropHealth(Pos,0,0); } /*****************************************************************************/ diff --git a/source/fx/fx.h b/source/fx/fx.h index b5ddcda36..5f2ed5f9e 100644 --- a/source/fx/fx.h +++ b/source/fx/fx.h @@ -69,6 +69,7 @@ static CFX *Create(const FX_TYPE Type); static CFX *Create(const FX_TYPE Type,CThing *Parent); static CFX *Create(const FX_TYPE Type,DVECTOR const &Pos); virtual bool alwaysThink() {return(!RelativeToMap);} +virtual void leftThinkZone(int _frames) {killFX();} virtual void init(); virtual void init(DVECTOR const &Pos); diff --git a/source/fx/fxbaseanim.cpp b/source/fx/fxbaseanim.cpp index e4f50ac80..6740c3725 100644 --- a/source/fx/fxbaseanim.cpp +++ b/source/fx/fxbaseanim.cpp @@ -39,12 +39,6 @@ void CFXBaseAnim::init(DVECTOR const &_Pos) renderFrame=DataPtr->StartFrame; } -/*****************************************************************************/ -void CFXBaseAnim::shutdown() -{ - CFX::shutdown(); -} - /*****************************************************************************/ /*** Think *******************************************************************/ /*****************************************************************************/ @@ -86,7 +80,7 @@ void CFXBaseAnim::killFX() { setToShutdown(); // If has follow on effect, create it now - if (DataPtr->EndFX) + if (DataPtr->EndFX || canThink()) { CFX::Create((CFX::FX_TYPE)DataPtr->EndFX,getPos()); } diff --git a/source/fx/fxbaseanim.h b/source/fx/fxbaseanim.h index 10157babf..9e8eecf44 100644 --- a/source/fx/fxbaseanim.h +++ b/source/fx/fxbaseanim.h @@ -32,7 +32,6 @@ public: }; virtual void init(DVECTOR const &Pos); -virtual void shutdown(); virtual void think(int _frames); virtual void render(); virtual void killFX(); diff --git a/source/fx/fxbasetrail.cpp b/source/fx/fxbasetrail.cpp index 84bfb7636..7b2b136b7 100644 --- a/source/fx/fxbasetrail.cpp +++ b/source/fx/fxbasetrail.cpp @@ -25,12 +25,6 @@ void CFXBaseTrail::init(DVECTOR const &_Pos) ListCount=0; } -/*****************************************************************************/ -void CFXBaseTrail::shutdown() -{ - CFX::shutdown(); -} - /*****************************************************************************/ /*** Think *******************************************************************/ /*****************************************************************************/ diff --git a/source/fx/fxbasetrail.h b/source/fx/fxbasetrail.h index d545536fe..885f4cf3f 100644 --- a/source/fx/fxbasetrail.h +++ b/source/fx/fxbasetrail.h @@ -32,7 +32,6 @@ public: }; virtual void init(DVECTOR const &Pos); -virtual void shutdown(); virtual void think(int _frames); virtual void render(); diff --git a/source/fx/fxfallingtile.cpp b/source/fx/fxfallingtile.cpp index 022032dfc..2a252fe55 100644 --- a/source/fx/fxfallingtile.cpp +++ b/source/fx/fxfallingtile.cpp @@ -36,12 +36,6 @@ sLevelHdr *LevelHdr=CLevel::getLevelHdr(); Life=FallingTile_DefLife; } -/*****************************************************************************/ -void CFXFallingTile::shutdown() -{ - CFX::shutdown(); -} - /*****************************************************************************/ /*** Think *******************************************************************/ /*****************************************************************************/ diff --git a/source/fx/fxfallingtile.h b/source/fx/fxfallingtile.h index 5a99aaff2..26ced7654 100644 --- a/source/fx/fxfallingtile.h +++ b/source/fx/fxfallingtile.h @@ -13,7 +13,6 @@ class CFXFallingTile : public CFX public: virtual void init(DVECTOR const &Pos); -virtual void shutdown(); virtual void think(int _frames); virtual void render(); void SetTile(int T) {Tile=T;} diff --git a/source/fx/fxjfish.cpp b/source/fx/fxjfish.cpp index 632f23dff..c16c53c74 100644 --- a/source/fx/fxjfish.cpp +++ b/source/fx/fxjfish.cpp @@ -32,12 +32,6 @@ void CFXJellyFishLegs::init(DVECTOR const &_Pos) Scale = ONE; } -/*****************************************************************************/ -void CFXJellyFishLegs::shutdown() -{ - CFX::shutdown(); -} - /*****************************************************************************/ void CFXJellyFishLegs::Setup(int XOfs,int YOfs,bool XFlip) { diff --git a/source/fx/fxjfish.h b/source/fx/fxjfish.h index cffbff9ec..6430f55ff 100644 --- a/source/fx/fxjfish.h +++ b/source/fx/fxjfish.h @@ -13,7 +13,6 @@ class CFXJellyFishLegs : public CFX public: virtual void init(DVECTOR const &Pos); -virtual void shutdown(); virtual void think(int _frames); virtual void render(); diff --git a/source/fx/fxnrgbar.cpp b/source/fx/fxnrgbar.cpp index 15cfd4a65..060862f0e 100644 --- a/source/fx/fxnrgbar.cpp +++ b/source/fx/fxnrgbar.cpp @@ -32,12 +32,6 @@ SpriteBank *SprBank=CGameScene::getSpriteBank(); DrawW=NRGW; } -/*****************************************************************************/ -void CFXNRGBar::shutdown() -{ - CFX::shutdown(); -} - /*****************************************************************************/ /*** Think *******************************************************************/ /*****************************************************************************/ diff --git a/source/fx/fxnrgbar.h b/source/fx/fxnrgbar.h index 89690499b..97dcc0a2c 100644 --- a/source/fx/fxnrgbar.h +++ b/source/fx/fxnrgbar.h @@ -13,7 +13,6 @@ class CFXNRGBar : public CFX public: virtual void init(DVECTOR const &Pos); -virtual void shutdown(); virtual void think(int _frames); virtual void render(); diff --git a/source/fx/fxsteam.cpp b/source/fx/fxsteam.cpp index 82e532912..f274ca198 100644 --- a/source/fx/fxsteam.cpp +++ b/source/fx/fxsteam.cpp @@ -33,12 +33,6 @@ void CFXSteam::init(DVECTOR const &_Pos) IsHorizontal=false; } -/*****************************************************************************/ -void CFXSteam::shutdown() -{ - CFX::shutdown(); -} - /*****************************************************************************/ void CFXSteam::SetSize(int Size) { diff --git a/source/fx/fxsteam.h b/source/fx/fxsteam.h index 04f9b5252..1bd09beb4 100644 --- a/source/fx/fxsteam.h +++ b/source/fx/fxsteam.h @@ -13,7 +13,7 @@ class CFXSteam : public CFXBaseTrail { public: virtual void init(DVECTOR const &Pos); -virtual void shutdown(); + virtual void think(int _frames); virtual void killFX(); diff --git a/source/gfx/actor.cpp b/source/gfx/actor.cpp index 45b2344c3..37e5e2773 100644 --- a/source/gfx/actor.cpp +++ b/source/gfx/actor.cpp @@ -6,7 +6,6 @@ #include "mem\memory.h" #include "fileio\fileio.h" #include "utils\utils.h" -//#include "utils\pak.h" #include "gfx\prim.h" #include "gfx\actor.h" #include "gfx\otpos.h" @@ -99,7 +98,7 @@ int Slot=0; SlotCount++; } } - SlotList[Slot].RefCount++; +// SlotList[Slot].RefCount++; return(Slot); } @@ -208,7 +207,7 @@ sPoolNode *DstTail=Dst->Tail; int CActorCache::ReserveSlot(int W,int H,int FrameCount) { int Slot=GetSlot(W,H); - SlotList[Slot].FrameCount+=FrameCount; +// SlotList[Slot].FrameCount+=FrameCount; return(Slot); } @@ -282,8 +281,8 @@ void CActorCache::Reset() SlotList[i].ListMem=0; SlotList[i].NodeList.Head=0; SlotList[i].NodeList.Tail=0; - SlotList[i].RefCount=0; - SlotList[i].FrameCount=0; +// SlotList[i].RefCount=0; +// SlotList[i].FrameCount=0; SlotList[i].Width=0; SlotList[i].Height=0; } @@ -524,12 +523,7 @@ sActorPool *Actor=ActorList; /*****************************************************************************/ CActorGfx::CActorGfx(sActorPool *ThisActor) { - PoolEntry=ThisActor; - ShadowXOfs=DEF_SHADOW_OFS; - ShadowYOfs=DEF_SHADOW_OFS; - ShadowFlag=false; - OtPos=OTPOS__ACTOR_POS; - + setActor(ThisActor); } /*****************************************************************************/ @@ -537,6 +531,17 @@ CActorGfx::~CActorGfx() { } +/*****************************************************************************/ +void CActorGfx::setActor(sActorPool *ThisActor) +{ + PoolEntry=ThisActor; +// ShadowXOfs=DEF_SHADOW_OFS; +// ShadowYOfs=DEF_SHADOW_OFS; +// ShadowFlag=false; + OtPos=OTPOS__ACTOR_POS; + +} + /*****************************************************************************/ POLY_FT4 *CActorGfx::Render(DVECTOR &Pos,int Anim,int Frame,bool XFlip,bool YFlip) @@ -622,7 +627,7 @@ sSpriteAnim *ThisAnim=SpriteBank->AnimList+Anim; Ft4->tpage=ThisNode->TPage; Ft4->clut=PoolEntry->ActorGfx->Clut; addPrim(OtPtr+OtPos,Ft4); - +/* if (ShadowFlag) { POLY_FT4 *sFt4=GetPrimFT4(); @@ -635,6 +640,7 @@ sSpriteAnim *ThisAnim=SpriteBank->AnimList+Anim; setRGB0(sFt4,0,0,0); addPrim(OtPtr+OtPos,sFt4); } +*/ // Set BBox //int HalfW=CurrentFrameGfx->W>>1; // Sizes now depend on aspect corrected sizes, so get sizes back from poly diff --git a/source/gfx/actor.h b/source/gfx/actor.h index bc60276c3..9c5ef91b7 100644 --- a/source/gfx/actor.h +++ b/source/gfx/actor.h @@ -31,19 +31,19 @@ struct sNodeList struct sPoolSlot { u16 Width,Height; - u16 RefCount; - u16 FrameCount; +// u16 RefCount; +// u16 FrameCount; sNodeList NodeList; u8 *ListMem; - int SlotCount; + u16 SlotCount; }; /*****************************************************************************/ struct sActorPool { FileEquate Filename; + s16 CacheSlot; sSpriteAnimBank *ActorGfx; - int CacheSlot; sNodeList *GlobalCache; sNodeList LocalCache; sNodeList LastCache; @@ -138,6 +138,8 @@ public: CActorGfx(sActorPool *ThisActor); virtual ~CActorGfx(); + void setActor(sActorPool *ThisActor); + POLY_FT4 *Render(DVECTOR &Pos,int Anim,int Frame,bool FlipX=false,bool FlipY=false); POLY_FT4 *RotateScale(POLY_FT4 *Ft4,DVECTOR &Pos,int Angle,int XScale,int YScale); @@ -146,8 +148,8 @@ virtual ~CActorGfx(); sBBox &GetBBox() {return(BBox);} - void SetShadow(bool f) {ShadowFlag=f;} - void SetShadowOfs(int X,int Y) {ShadowXOfs=X; ShadowYOfs=Y;} +// void SetShadow(bool f) {ShadowFlag=f;} +// void SetShadowOfs(int X,int Y) {ShadowXOfs=X; ShadowYOfs=Y;} void SetOtPos(int Ot) {OtPos=Ot;} protected: @@ -158,8 +160,8 @@ protected: sSpriteFrameGfx *CurrentFrameGfx; sBBox BBox; - bool ShadowFlag; - s16 ShadowXOfs,ShadowYOfs; +// bool ShadowFlag; +// s16 ShadowXOfs,ShadowYOfs; u32 OtPos; }; diff --git a/source/player/player.h b/source/player/player.h index e948688c8..78bb345ff 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -227,7 +227,7 @@ public: void setLedgeLookAhead(int _lookAhead) {m_ledgeLookAhead=_lookAhead;} void addLife(); - void addSpatula() {m_numSpatulasHeld++;} + void addSpatula(int Count=1) {m_numSpatulasHeld+=Count;} int getSpatulasHeld() {return m_numSpatulasHeld;} ATTACK_STATE getAttackState(); int isRecoveringFromHit() {return m_invincibleFrameCount!=0||m_currentMode==PLAYER_MODE_DEAD;} diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index 336ba1b13..6e0161423 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -418,6 +418,7 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); if (ThingRect->y2y1>m_ThinkBBox.YMax) Flag=0; } thing->setThinkFlag(Flag); +// Is in think zone if (Flag) { thing->think(_frames); @@ -428,15 +429,16 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); } } Flag|=lastFlag; +// Handle enter/leave states (not sure of viabilty now) switch (Flag) { // Last This case 0: // 0 0 break; case 1: // 0 1 - thing->enterThingZone(_frames); + thing->enterThinkZone(_frames); break; case 2: // 1 0 - thing->leftThingZone(_frames); + thing->leftThinkZone(_frames); break; case 3: // 1 1 break; @@ -444,11 +446,8 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); ASSERT("Invalid Think State"); } - - /* THIS WILL NOT STAY HERE, THINGS MUST BE INITIALISED CORRECTLY */ thing->updateCollisionArea(); - thing=thing->m_nextListThing; } } @@ -916,6 +915,7 @@ void CThingManager::resetFreeList() while (ThisThing) { CThing *Next=ThisThing->NextFreeThing; + ThisThing->destroy(); delete ThisThing; FreeListCount--; ThisThing=Next; @@ -979,21 +979,12 @@ int SubType=Thing->getThingSubType(); CThing **List=s_FreeList[Type]; // Check its been aquired/set correctly -// ASSERT(SubType!=1234); - if (SubType!=1234) - { - Thing->NextFreeThing=List[SubType]; - List[SubType]=Thing; - FreeListCount++; - } - else - { - printf("%i %i\n",Type,SubType); - ASSERT(!"Thing not Setup Correctly"); - Thing->NextFreeThing=DuffList; - DuffList=Thing; - DuffListCount++; - } + + ASSERT(SubType!=1234); + + Thing->NextFreeThing=List[SubType]; + List[SubType]=Thing; + FreeListCount++; #else delete Thing; @@ -1249,30 +1240,6 @@ CThing *List=NextThing; m_numChildren = 0; } -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -/* -bool CThing::hasChild(CThing *Child) -{ -CThing *nextChild = NextThing; - - while( nextChild ) - { - if ( nextChild == Child ) - { - return( true ); - } - - nextChild = nextChild->NextThing; - } - - return( false ); -} -*/ /*---------------------------------------------------------------------- Function: Purpose: @@ -1315,7 +1282,7 @@ void CThing::updateCollisionArea() Params: Returns: ---------------------------------------------------------------------- */ - +/* s32 CThing::getNewYPos(CThing *_thisThing) { CRECT thisRect; @@ -1330,7 +1297,7 @@ s32 CThing::getNewYPos(CThing *_thisThing) return( thisRect.y2 ); } } - +*/ /*---------------------------------------------------------------------- Function: Purpose: diff --git a/source/thing/thing.h b/source/thing/thing.h index 88e9c0d2d..192b21d72 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -140,8 +140,11 @@ virtual TYPE getThingType()=0; virtual void setThingSubType(int T) {m_SubType=T;} virtual int getThingSubType() {return(m_SubType);} -virtual void init(); -virtual void shutdown(); +virtual void create() {;} // Once only init (for mem alloc) +virtual void init(); // re-usable init +virtual void shutdown(); // re-usable shutdown +virtual void destroy() {;} // memory clean up when totally killing the poor things + virtual void think(int _frames); virtual void render(); void setToShutdown(bool f=true) {m_isShuttingDown = f;} @@ -153,10 +156,8 @@ virtual int dontKillDuringLevelRespawn() {return false;} void removeChild(CThing *Child); void removeAllChild(); void deleteAllChild(); -// bool hasChild(CThing *Child); int getNumChildren() {return( m_numChildren );} - DVECTOR const &getPos() {return Pos;} void setPos(DVECTOR newPos) {Pos=newPos;} DVECTOR getPosDelta() {return PosDelta;} @@ -186,8 +187,8 @@ 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) {} +virtual void leftThinkZone(int _frames) {} +virtual void enterThinkZone(int _frames) {} void ShowBBox(); DVECTOR const &getCollisionCentre() {return m_collisionCentre;} @@ -203,7 +204,7 @@ virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); virtual void collidedWith(CThing *_thisThing) {;} virtual void setHasPlatformCollided( bool newVal ) {;} virtual bool getHasPlatformCollided() {return false;} -virtual s32 getNewYPos( CThing *_thisThing ); +//virtual s32 getNewYPos( CThing *_thisThing ); public: // Thing states @@ -213,6 +214,7 @@ public: bool canRender() {return (m_renderFlag);} DVECTOR &getRenderPos() {return(m_RenderPos);} bool canThink() {return (m_thinkFlag);} + protected: bool m_renderFlag,m_thinkFlag; DVECTOR m_RenderPos;