SBSPSS/source/game/gameslot.h

250 lines
6.6 KiB
C
Raw Normal View History

2001-01-10 22:43:17 +01:00
/*=========================================================================
gameslot.h
Author: PKG
Created:
Project: Spongebob
Purpose:
2001-01-10 23:03:20 +01:00
Copyright (c) 2001 Climax Development Ltd
2001-01-10 22:43:17 +01:00
===========================================================================*/
#ifndef __GAME_GAMESLOT_H__
#define __GAME_GAMESLOT_H__
/*----------------------------------------------------------------------
Includes
-------- */
2001-06-06 04:11:50 +02:00
#ifndef __SHOP_SHOP_H__
#include "shop\shop.h"
#endif
2001-05-30 16:58:29 +02:00
// Just for ASSERT()..
#ifndef __SYSTEM_DBG_H__
#include "system\dbg.h"
#endif
2001-01-10 22:43:17 +01:00
/* Std Lib
------- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
class CGameSlotManager
{
public:
enum
{
2001-06-13 16:48:33 +02:00
INITIAL_LIVES=5,
2001-01-10 22:43:17 +01:00
INITIAL_CONTINUES=3,
NUM_GAME_SLOTS=4,
2001-05-09 22:15:01 +02:00
2001-05-31 23:17:33 +02:00
NUM_CHAPTERS=5,
2001-05-30 16:58:29 +02:00
NUM_LEVELS_WITH_SPATULAS=4,
2001-06-12 20:56:40 +02:00
NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS=4,
NUM_BONUS_LEVELS_PER_CHAPTER=1,
};
enum
{
LEVELCOMPETESTATE_NOT_OPEN, // Level is not available to play
LEVELCOMPETESTATE_OPEN, // Level is available to play
LEVELCOMPETESTATE_COMPLETED, // Level has been completed
2001-01-10 22:43:17 +01:00
};
2001-05-09 22:15:01 +02:00
2001-01-10 22:43:17 +01:00
typedef struct
{
2001-05-09 22:15:01 +02:00
unsigned char m_isInUse;
unsigned char m_lives;
unsigned char m_continues;
2001-06-22 22:06:39 +02:00
unsigned char m_hasSeenOpeningFMA;
2001-06-14 17:19:57 +02:00
unsigned char m_spatulaCollectedCounts[NUM_CHAPTERS*NUM_LEVELS_WITH_SPATULAS];
unsigned char m_kelpTokenCollectedFlags[NUM_CHAPTERS][16]; // Enuf space for 128 tokens per level
2001-06-06 04:11:50 +02:00
unsigned char m_kelpTokensHeld;
unsigned char m_partyItemsHeld[CShopScene::NUM_SHOP_ITEM_IDS];
2001-06-12 20:56:40 +02:00
unsigned char m_levelCompletionState[NUM_CHAPTERS*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER)];
2001-05-30 16:58:29 +02:00
// Spat functions..
int getSpatulaCollectedCount(unsigned int _chapter,unsigned int _level)
{
2001-05-31 23:17:33 +02:00
ASSERT(_chapter<=NUM_CHAPTERS);
2001-05-30 16:58:29 +02:00
ASSERT(_level<=NUM_LEVELS_WITH_SPATULAS);
2001-06-14 17:19:57 +02:00
return m_spatulaCollectedCounts[(_chapter*NUM_LEVELS_WITH_SPATULAS)+_level];
2001-05-30 16:58:29 +02:00
}
2001-06-14 17:19:57 +02:00
void setSpatulaCollectedCount(unsigned int _chapter,unsigned int _level,unsigned char _count,unsigned char _totalCount)
2001-05-30 16:58:29 +02:00
{
2001-05-31 23:17:33 +02:00
ASSERT(_chapter<=NUM_CHAPTERS);
2001-05-30 16:58:29 +02:00
ASSERT(_level<=NUM_LEVELS_WITH_SPATULAS);
2001-06-14 17:19:57 +02:00
m_spatulaCollectedCounts[(_chapter*NUM_LEVELS_WITH_SPATULAS)+_level]=_count;
// Does this open up a bonus level?
int percentRequired,percentAchieved;
percentRequired=(_chapter*10)+60; // 60% on chapter 1 ... to ... 100% on chapter 5
percentAchieved=(_count*100)/_totalCount;
if(percentAchieved>=percentRequired)
{
levelIsNowOpen(_chapter,4);
}
2001-05-30 16:58:29 +02:00
}
2001-05-09 22:15:01 +02:00
2001-05-30 16:58:29 +02:00
// Kelp Token functions..
int getKelpTokenCollectedCount(unsigned int _chapter,unsigned int _level)
2001-05-09 22:15:01 +02:00
{
2001-06-01 20:59:33 +02:00
ASSERT(_chapter<=NUM_CHAPTERS);
ASSERT(_level==NUM_LEVELS_WITH_SPATULAS);
2001-05-09 22:15:01 +02:00
int i,j,count;
count=0;
for(i=0;i<8;i++)
{
2001-06-04 20:09:47 +02:00
unsigned char flags=m_kelpTokenCollectedFlags[_chapter][i];
2001-05-09 22:15:01 +02:00
for(j=0;j<8;j++)
{
if(flags&1)count++;
flags>>=1;
}
}
return count;
}
2001-05-30 16:58:29 +02:00
void collectKelpToken(unsigned int _chapter,unsigned int _level,unsigned int _token)
2001-05-09 22:15:01 +02:00
{
2001-06-01 20:59:33 +02:00
ASSERT(_chapter<=NUM_CHAPTERS);
ASSERT(_level==NUM_LEVELS_WITH_SPATULAS);
2001-05-30 16:58:29 +02:00
ASSERT(_token<=128);
2001-06-04 20:09:47 +02:00
m_kelpTokenCollectedFlags[_chapter][_token>>3]|=1<<(_token&7);
2001-06-19 18:46:36 +02:00
m_kelpTokensHeld++;
2001-05-09 22:15:01 +02:00
}
2001-05-30 16:58:29 +02:00
int isKelpTokenUncollected(unsigned int _chapter,unsigned int _level,unsigned int _token)
2001-05-09 22:15:01 +02:00
{
2001-06-01 20:59:33 +02:00
ASSERT(_chapter<=NUM_CHAPTERS);
2001-06-04 20:09:47 +02:00
ASSERT(_level==NUM_LEVELS_WITH_SPATULAS);
2001-05-30 16:58:29 +02:00
ASSERT(_token<=128);
2001-06-04 20:09:47 +02:00
return (m_kelpTokenCollectedFlags[_chapter][_token>>3]>>(_token&7))&1?false:true;
2001-05-09 22:15:01 +02:00
}
2001-06-06 04:11:50 +02:00
// Shop
int getNumberOfKelpTokensHeld()
{
return m_kelpTokensHeld;
}
void useKelpTokens(int _count)
{
ASSERT(((int)m_kelpTokensHeld-_count)>=0);
m_kelpTokensHeld-=_count;
}
int isPartyItemHeld(int _itemNumber)
{
return m_partyItemsHeld[_itemNumber];
}
void buyPartyItem(int _itemNumber)
{
ASSERT(!m_partyItemsHeld[_itemNumber]);
m_partyItemsHeld[_itemNumber]=true;
}
2001-06-12 20:56:40 +02:00
// Levels
int isLevelOpen(unsigned int _chapter,unsigned int _level)
{
int index;
index=(_chapter*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER))+_level;
return m_levelCompletionState[index]!=(int)LEVELCOMPETESTATE_NOT_OPEN;
}
int hasQustItemBeenCollected(unsigned int _chapter,unsigned int _level)
{
int index;
index=(_chapter*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER))+_level;
return m_levelCompletionState[index]==(int)LEVELCOMPETESTATE_COMPLETED;
}
void levelIsNowOpen(unsigned int _chapter,unsigned int _level)
{
int index;
index=(_chapter*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER))+_level;
if(m_levelCompletionState[index]==LEVELCOMPETESTATE_NOT_OPEN)
{
m_levelCompletionState[index]=LEVELCOMPETESTATE_OPEN;
}
}
void levelHasBeenCompleted(unsigned int _chapter,unsigned int _level)
{
int index;
index=(_chapter*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER))+_level;
m_levelCompletionState[index]=LEVELCOMPETESTATE_COMPLETED;
}
2001-06-13 16:48:33 +02:00
void getHighestLevelOpen(int *_chapter,int *_level)
{
int chapter,level;
for(chapter=0;chapter<NUM_CHAPTERS;chapter++)
{
for(level=0;level<NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS;level++)
{
if(isLevelOpen(chapter,level))
{
*_chapter=chapter;
*_level=level;
}
}
}
}
2001-06-12 20:56:40 +02:00
#ifdef __VERSION_DEBUG__
void debugCheatOpenAllLevels()
{
for(int i=1;i<NUM_CHAPTERS*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER);i++)
{
m_levelCompletionState[i]=LEVELCOMPETESTATE_OPEN;
}
}
#endif
2001-01-10 22:43:17 +01:00
} GameSlot;
2001-05-09 22:15:01 +02:00
static void init();
2001-01-10 22:43:17 +01:00
2001-05-09 22:15:01 +02:00
static void setActiveSlot(unsigned int _slot);
static GameSlot *getSlotData();
static void setSlotData(GameSlot *_data);
2001-01-10 22:43:17 +01:00
2001-05-09 22:15:01 +02:00
static void eraseGameSlot(unsigned int _slot);
static void copyGameSlot(unsigned int _src,unsigned int _dest);
2001-01-10 22:43:17 +01:00
2001-06-20 00:14:00 +02:00
static int getNumberOfFrontendScreenToUse();
2001-01-10 22:43:17 +01:00
private:
2001-05-09 22:15:01 +02:00
static GameSlot s_gameSlots[NUM_GAME_SLOTS];
static GameSlot *s_currentGameSlot;
2001-01-10 22:43:17 +01:00
// These allow the CSaveLoadDatabase total access to the game slots
2001-05-09 22:15:01 +02:00
static void setSlotData(int _slot,GameSlot *_data);
static GameSlot getSlotData(int _slot);
2001-01-10 22:43:17 +01:00
friend class CSaveLoadDatabase;
};
/*----------------------------------------------------------------------
Globals
------- */
/*----------------------------------------------------------------------
Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* __GAME_GAMESLOT_H__ */
/*===========================================================================
end */