From cfead5058ee2f02e7c627a0284ad2559fdcd2973 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 10 Jan 2001 21:43:17 +0000 Subject: [PATCH] --- source/game/gameslot.cpp | 172 +++++++++++++++++++++++++++++++++++++++ source/game/gameslot.h | 87 ++++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 source/game/gameslot.cpp create mode 100644 source/game/gameslot.h diff --git a/source/game/gameslot.cpp b/source/game/gameslot.cpp new file mode 100644 index 000000000..126400083 --- /dev/null +++ b/source/game/gameslot.cpp @@ -0,0 +1,172 @@ +/*========================================================================= + + gameslot.cpp + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#include "game\gameslot.h" + +#ifndef __SYSTEM_DBG_H__ +#include "system\dbg.h" +#endif + + +/* Std Lib + ------- */ + +/* Data + ---- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +/*---------------------------------------------------------------------- + Function Prototypes + ------------------- */ + +/*---------------------------------------------------------------------- + Vars + ---- */ + +CGameSlotManager::GameSlot CGameSlotManager::s_gameSlots[4]; +CGameSlotManager::GameSlot *CGameSlotManager::s_currentGameSlot=0; + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameSlotManager::init() +{ + int i; + + for(i=0;im_lives=INITIAL_LIVES; + slot->m_continues=INITIAL_CONTINUES; + slot->m_maxLevelCompleted=0; +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameSlotManager::copyGameSlot(unsigned int _src,unsigned int _dest) +{ + ASSERT(_src<=NUM_GAME_SLOTS); + ASSERT(_dest<=NUM_GAME_SLOTS); + + s_gameSlots[_dest]=s_gameSlots[_src]; +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CGameSlotManager::setSlotData(int _slot,GameSlot *_data) +{ + ASSERT(_slot<=NUM_GAME_SLOTS); + s_gameSlots[_slot]=*_data; +} + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +CGameSlotManager::GameSlot CGameSlotManager::getSlotData(int _slot) +{ + ASSERT(_slot<=NUM_GAME_SLOTS); + return s_gameSlots[_slot]; +} + + +/*=========================================================================== + end */ diff --git a/source/game/gameslot.h b/source/game/gameslot.h new file mode 100644 index 000000000..8672fcc1d --- /dev/null +++ b/source/game/gameslot.h @@ -0,0 +1,87 @@ +/*========================================================================= + + gameslot.h + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +#ifndef __GAME_GAMESLOT_H__ +#define __GAME_GAMESLOT_H__ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +/* Std Lib + ------- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +class CGameSlotManager +{ +public: + enum + { + INITIAL_LIVES=4, + INITIAL_CONTINUES=3, + + NUM_GAME_SLOTS=4, + }; + + typedef struct + { + int m_lives; + int m_continues; + int m_maxLevelCompleted; + } GameSlot; + + + static void init(); + + 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); + + +private: + 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); + friend class CSaveLoadDatabase; + + +}; + + +/*---------------------------------------------------------------------- + Globals + ------- */ + +/*---------------------------------------------------------------------- + Functions + --------- */ + +/*---------------------------------------------------------------------- */ + +#endif /* __GAME_GAMESLOT_H__ */ + +/*=========================================================================== + end */