diff --git a/source/game/gameslot.cpp b/source/game/gameslot.cpp index 391112bd3..06322cff3 100644 --- a/source/game/gameslot.cpp +++ b/source/game/gameslot.cpp @@ -88,10 +88,10 @@ void CGameSlotManager::setActiveSlot(unsigned int _slot) Params: Returns: ---------------------------------------------------------------------- */ -CGameSlotManager::GameSlot CGameSlotManager::getSlotData() +CGameSlotManager::GameSlot *CGameSlotManager::getSlotData() { ASSERT(s_currentGameSlot!=0); - return *s_currentGameSlot; + return s_currentGameSlot; } @@ -119,6 +119,7 @@ void CGameSlotManager::eraseGameSlot(unsigned int _slot) ASSERT(_slot<=NUM_GAME_SLOTS); GameSlot *slot; + int i,j; slot=&s_gameSlots[_slot]; @@ -126,6 +127,13 @@ void CGameSlotManager::eraseGameSlot(unsigned int _slot) slot->m_lives=INITIAL_LIVES; slot->m_continues=INITIAL_CONTINUES; slot->m_maxLevelCompleted=0; + for(i=0;im_spatulaCollectedFlags[i][j]=0; + } + } } diff --git a/source/game/gameslot.h b/source/game/gameslot.h index a1d4c0801..a55fcc401 100644 --- a/source/game/gameslot.h +++ b/source/game/gameslot.h @@ -38,34 +38,62 @@ public: INITIAL_CONTINUES=3, NUM_GAME_SLOTS=4, + + NUM_CHAPTERS=5, + NUM_LEVELS=6, }; + typedef struct { - int m_isInUse; - int m_lives; - int m_continues; - int m_maxLevelCompleted; + unsigned char m_isInUse; + unsigned char m_lives; + unsigned char m_continues; + unsigned char m_maxLevelCompleted; + unsigned char m_spatulaCollectedFlags[NUM_CHAPTERS*NUM_LEVELS][8]; // Enuf space for 64 spats per level + + int getSpatulaCollectedCount(int _chapter,int _level) + { + int i,j,count; + count=0; + for(i=0;i<8;i++) + { + unsigned char flags=m_spatulaCollectedFlags[(_chapter*NUM_LEVELS)+_level][i]; + for(j=0;j<8;j++) + { + if(flags&1)count++; + flags>>=1; + } + } + return count; + } + void collectSpatula(int _chapter,int _level,int _spat) + { + m_spatulaCollectedFlags[(_chapter*NUM_LEVELS)+_level][_spat>>3]|=1<<(_spat&7); + } + int isSpatulaUncollected(int _chapter,int _level,int _spat) + { + return (m_spatulaCollectedFlags[(_chapter*NUM_LEVELS)+_level][_spat>>3]>>(_spat&7))&1?false:true; + } } GameSlot; + static void init(); - static void init(); + static void setActiveSlot(unsigned int _slot); + static GameSlot *getSlotData(); + static void setSlotData(GameSlot *_data); - static void setActiveSlot(unsigned int _slot); - static GameSlot getSlotData(); - static void setSlotData(GameSlot *_data); - - static void eraseGameSlot(unsigned int _slot); - static void copyGameSlot(unsigned int _src,unsigned int _dest); + static void eraseGameSlot(unsigned int _slot); + static void copyGameSlot(unsigned int _src,unsigned int _dest); private: - static GameSlot s_gameSlots[NUM_GAME_SLOTS]; - static GameSlot *s_currentGameSlot; + static GameSlot s_gameSlots[NUM_GAME_SLOTS]; + static GameSlot *s_currentGameSlot; // These allow the CSaveLoadDatabase total access to the game slots - static void setSlotData(int _slot,GameSlot *_data); - static GameSlot getSlotData(int _slot); + static void setSlotData(int _slot,GameSlot *_data); + static GameSlot getSlotData(int _slot); friend class CSaveLoadDatabase; diff --git a/source/level/level.cpp b/source/level/level.cpp index 415959bcb..e20c31135 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -43,6 +43,10 @@ #include "pickups\pickup.h" #endif +#ifndef __PICKUPS_PSPATULA_H__ +#include "pickups\pspatula.h" +#endif + #ifndef __SOUND_SOUND_H__ #include "sound\sound.h" #endif @@ -73,6 +77,10 @@ #include "projectl\projectl.h" #endif +#ifndef __GAME_GAMESLOT_H__ +#include "game\gameslot.h" +#endif + /*****************************************************************************/ extern int s_globalLevelSelectThing; @@ -421,13 +429,24 @@ void CLevel::initThings(int _respawningLevel) ItemCount=Hdr->Count; ItemList=(sThingItem*)MakePtr(Hdr,sizeof(sThingHdr)); DVECTOR pos; + int spatNumber=0; for(int i=0;iType==PICKUP__SPATULA)) + int isSpat=(PICKUP_TYPE)ItemList->Type==PICKUP__SPATULA; + CBasePickup *newPickup; + if(!isSpat||CGameSlotManager::getSlotData()->isSpatulaUncollected(0,0,spatNumber)) { pos.vx=ItemList->Pos.X<<4; pos.vy=ItemList->Pos.Y<<4; - createPickup((PICKUP_TYPE)ItemList->Type,&pos); + newPickup=createPickup((PICKUP_TYPE)ItemList->Type,&pos); + if(isSpat) + { + ((CSpatulaPickup*)newPickup)->setSpatulaNumber(spatNumber); + } + } + if(isSpat) + { + spatNumber++; } ItemList++; } diff --git a/source/map/map.cpp b/source/map/map.cpp index 9d9c72ffa..7891fa018 100644 --- a/source/map/map.cpp +++ b/source/map/map.cpp @@ -50,6 +50,10 @@ #include "utils\mathtab.h" #endif +#ifndef __GAME_GAMESLOT_H__ +#include "game\gameslot.h" +#endif + /* Std Lib ------- */ @@ -417,12 +421,12 @@ int CMapScene::isLevelOpen(int _chapter,int _level) int CMapScene::getSpatulaCollectedCount(int _chapter,int _level) { - return 0; + return CGameSlotManager::getSlotData()->getSpatulaCollectedCount(_chapter,_level); } int CMapScene::getSpatulaAvailableCount(int _chapter,int _level) { - return 30; + return 99; } int CMapScene::hasQuestItemBeenCollected(int _chapter,int _level) diff --git a/source/pickups/pspatula.cpp b/source/pickups/pspatula.cpp index 4740ef6a6..73013208a 100644 --- a/source/pickups/pspatula.cpp +++ b/source/pickups/pspatula.cpp @@ -29,6 +29,10 @@ #include "utils\mathtab.h" #endif +#ifndef __GAME_GAMESLOT_H__ +#include "game\gameslot.h" +#endif + /* Std Lib ------- */ @@ -101,6 +105,7 @@ DVECTOR CSpatulaPickup::getSizeForPlacement() void CSpatulaPickup::collect(class CPlayer *_player) { CBasePickup::collect(_player); + CGameSlotManager::getSlotData()->collectSpatula(0,0,m_spatulaNumber); } /*---------------------------------------------------------------------- diff --git a/source/pickups/pspatula.h b/source/pickups/pspatula.h index ecc01ad03..841cbf2f2 100644 --- a/source/pickups/pspatula.h +++ b/source/pickups/pspatula.h @@ -46,6 +46,8 @@ public: virtual DVECTOR getSizeForPlacement(); virtual void collect(class CPlayer *_player); + void setSpatulaNumber(int _number) {m_spatulaNumber=_number;} + protected: virtual void thinkPickup(int _frames); virtual void renderPickup(DVECTOR *_pos); @@ -53,6 +55,7 @@ protected: private: int m_glint; int m_glintRot; + int m_spatulaNumber; }; class CBalloonAndSpatulaPickup : public CSpatulaPickup diff --git a/source/player/player.cpp b/source/player/player.cpp index 0dfe92250..d0a474094 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -477,7 +477,7 @@ m_animFrame=0; setFacing(FACING_RIGHT); respawn(); - m_lives=CGameSlotManager::getSlotData().m_lives; + m_lives=CGameSlotManager::getSlotData()->m_lives; m_lastPadInput=m_padInput=PI_NONE;