git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@142 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
albertzeyer
2009-07-24 14:02:05 +00:00
parent 3faa6b5bd6
commit a31d516ae0
7 changed files with 1594 additions and 1580 deletions

View File

@@ -291,8 +291,6 @@ void CGame::preallocateCKP(stCloneKeenPlus *pCKP)
demomode = DEMO_NODEMO; demomode = DEMO_NODEMO;
current_demo = 1; current_demo = 1;
memset(&pCKP->Control, 0, sizeof(stControl));
pCKP->Joystick = NULL; pCKP->Joystick = NULL;
acceleratemode = 0; acceleratemode = 0;

View File

@@ -48,7 +48,7 @@ bool CGraphics::allocScrollBufmem(void)
if (g_pVideoDriver->getZoomValue() > 1) if (g_pVideoDriver->getZoomValue() > 1)
{ {
g_pLogFile->ftextOut("allocmem(): allocating %d bytes for blit buffer...", blitbuf_memsize); g_pLogFile->ftextOut("allocmem(): allocating %d bytes for blit buffer...", blitbuf_memsize);
blitbuffer = (unsigned char*) malloc(blitbuf_memsize); blitbuffer = new unsigned char[blitbuf_memsize];
if (!blitbuffer) if (!blitbuffer)
{ {
g_pLogFile->ftextOut(RED,"Failure<br>"); g_pLogFile->ftextOut(RED,"Failure<br>");
@@ -63,12 +63,12 @@ void CGraphics::freemem(void)
{ {
if (scrollbuffer) if (scrollbuffer)
{ {
delete[] scrollbuffer; delete[] scrollbuffer; scrollbuffer = NULL;
g_pLogFile->ftextOut(BLACK,true," Scrollbuffer memory released to system.<br>"); g_pLogFile->ftextOut(BLACK,true," Scrollbuffer memory released to system.<br>");
} }
if (blitbuffer) if (blitbuffer)
{ {
free(blitbuffer); delete[] blitbuffer; blitbuffer = NULL;
g_pLogFile->ftextOut(BLACK,true," Blitbuffer memory released to system.<br>"); g_pLogFile->ftextOut(BLACK,true," Blitbuffer memory released to system.<br>");
} }
} }

View File

@@ -219,10 +219,9 @@ void gameloop(stCloneKeenPlus *pCKP)
HighScoreTable = new CHighScores(pCKP); HighScoreTable = new CHighScores(pCKP);
bool extras[4]; bool extras[4] = {false,false,false,false};
// check inventory or saved cities // check inventory or saved cities
memset(extras,false,4*sizeof(bool));
if(pCKP->Control.levelcontrol.episode == 1) if(pCKP->Control.levelcontrol.episode == 1)
{ {
if(player[0].inventory.HasJoystick) if(player[0].inventory.HasJoystick)
@@ -592,8 +591,6 @@ int initgamefirsttime(stCloneKeenPlus *pCKP, int s)
map.firsttime = 1; map.firsttime = 1;
memset(player, 0, sizeof(player));
for(i=0;i<MAX_LEVELS;i++) for(i=0;i<MAX_LEVELS;i++)
pCKP->Control.levelcontrol.levels_completed[i] = 0; pCKP->Control.levelcontrol.levels_completed[i] = 0;

View File

@@ -3,6 +3,7 @@
#include <string> #include <string>
#include <SDL.h> #include <SDL.h>
#include <cstdlib>
#define MAX_COMMANDS 8 #define MAX_COMMANDS 8
#define MAX_SOUND_LENGTH 1024 #define MAX_SOUND_LENGTH 1024
@@ -11,7 +12,7 @@
#define MAX_NUMBER_OF_FILES 100 #define MAX_NUMBER_OF_FILES 100
typedef struct stDisplay struct stDisplay
{ {
unsigned int Width; unsigned int Width;
unsigned int Height; unsigned int Height;
@@ -21,15 +22,18 @@ typedef struct stDisplay
short Filtermode; short Filtermode;
short Zoom; short Zoom;
unsigned short FrameSkip; unsigned short FrameSkip;
} stDisplay;
typedef struct stDevice // as long as we only have POD
stDisplay() { memset(this, 0, sizeof(stDisplay)); }
};
struct stDevice
{ {
SDL_Joystick *Joystick; SDL_Joystick *Joystick;
SDL_Event Event; SDL_Event Event;
} stDevice; };
typedef struct stLevelControl struct stLevelControl
{ {
// level control // level control
int command; // used to give a command to playgame_levelmanager() int command; // used to give a command to playgame_levelmanager()
@@ -57,18 +61,23 @@ typedef struct stLevelControl
unsigned int level_done, level_done_timer; unsigned int level_done, level_done_timer;
unsigned int level_finished_by; // index of player that finished level unsigned int level_finished_by; // index of player that finished level
unsigned int exitXpos; unsigned int exitXpos;
} stLevelControl;
// as long as we only have POD
stLevelControl() { memset(this, 0, sizeof(stLevelControl)); }
};
typedef struct stControl struct stControl
{ {
short eseq; // see only the ending sequence bool eseq; // see only the ending sequence
short dtm; // go direct to map. bool dtm; // go direct to map.
short storyboard; // go to storyboard bool storyboard; // go to storyboard
short skipstarting; // Skip Startmenu, Intro and Mainmenu. bool skipstarting; // Skip Startmenu, Intro and Mainmenu.
stLevelControl levelcontrol; stLevelControl levelcontrol;
} stControl;
stControl() : eseq(false), dtm(false), storyboard(false), skipstarting(false) {}
};
struct stGameData struct stGameData
{ {

View File

@@ -8,50 +8,52 @@
* Author: gerstrong * Author: gerstrong
*/ */
#ifndef __CG_DIALIG_H__
#define __CG_DIALIG_H__
#include <vector>
#include <string>
#define STARTER_SAVE 1 #define STARTER_SAVE 1
#define STARTER_ESCAPE 2 #define STARTER_ESCAPE 2
#define STARTER_SOUNDOPT 3 #define STARTER_SOUNDOPT 3
#define STARTER_DISPLAYOPT 4 #define STARTER_DISPLAYOPT 4
#define STARTER_GAMEOPT 5 #define STARTER_GAMEOPT 5
typedef struct stTextLine struct stTextLine
{ {
char *Text; std::string Text;
short ID; // items are orded by ID short ID; // items are orded by ID
} stTextLine; };
typedef struct stSeparator struct stSeparator
{ {
short ID; // items are orded by ID short ID; // items are orded by ID
} stSeparator; };
typedef struct stOptionSwitch struct stOptionSwitch
{ {
char *Name; char *Name;
char **Option; char **Option;
short selected; short selected;
short numSel; short numSel;
short ID; // items are orded by ID short ID; // items are orded by ID
} stOptionSwitch; };
typedef struct stStarterSwitch struct stStarterSwitch
{ {
char *Name; std::string Name;
int numFunctionToLaunch; int numFunctionToLaunch;
short ID; // items are sorted by IDs short ID; // items are sorted by IDs
} stStarterSwitch; };
typedef struct stDlgStruct // imagine every substructure as typical control struct stDlgStruct // imagine every substructure as typical control
{ {
stTextLine *TextLine; std::vector<std::string> TextLine;
stOptionSwitch *OptionSwitch; std::vector<stOptionSwitch> OptionSwitch;
stStarterSwitch *StarterSwitch; std::vector<stStarterSwitch> StarterSwitch;
stSeparator *Separator; std::vector<stSeparator> Separator;
};
short num_TextLines; #endif
short num_OptionSwitches;
short num_StarterSwitch;
short num_Separators;
} stDlgStruct;

View File

@@ -119,15 +119,15 @@ typedef struct stMap
#define BDOWN 4 #define BDOWN 4
#define BLEFT 5 #define BLEFT 5
typedef struct stBitmap struct stBitmap
{ {
int xsize; int xsize;
int ysize; int ysize;
unsigned char *bmptr; unsigned char *bmptr;
char name[9]; char name[9];
} stBitmap; };
typedef struct stSprite struct stSprite
{ {
char xsize, ysize; char xsize, ysize;
unsigned char imgdata[64][64]; unsigned char imgdata[64][64];
@@ -135,9 +135,9 @@ typedef struct stSprite
// bounding box for hit detection // bounding box for hit detection
unsigned int bboxX1, bboxY1; unsigned int bboxX1, bboxY1;
unsigned int bboxX2, bboxY2; unsigned int bboxX2, bboxY2;
} stSprite; };
typedef struct stInventory struct stInventory
{ {
unsigned long score; unsigned long score;
unsigned long extralifeat; unsigned long extralifeat;
@@ -153,7 +153,7 @@ typedef struct stInventory
unsigned char HasFuel; unsigned char HasFuel;
unsigned char HasBattery; unsigned char HasBattery;
unsigned char HasVacuum; unsigned char HasVacuum;
} stInventory; };
// for strings loaded from "strings.dat" // for strings loaded from "strings.dat"
#define MAX_STRINGS 100 #define MAX_STRINGS 100
@@ -169,7 +169,7 @@ struct stString
}; };
/* Structs used for different enemies data, these are in a union */ /* Structs used for different enemies data, these are in a union */
typedef struct stYorpData struct stYorpData
{ {
unsigned char state; unsigned char state;
@@ -180,8 +180,9 @@ typedef struct stYorpData
signed int yorpdie_inertia_y; signed int yorpdie_inertia_y;
unsigned char movedir; unsigned char movedir;
} stYorpData; };
typedef struct stGargData
struct stGargData
{ {
unsigned char state; unsigned char state;
@@ -194,8 +195,9 @@ typedef struct stGargData
unsigned char movedir; unsigned char movedir;
unsigned char detectedPlayer, detectedPlayerIndex; unsigned char detectedPlayer, detectedPlayerIndex;
} stGargData; };
typedef struct stVortData
struct stVortData
{ {
unsigned char state; unsigned char state;
@@ -218,8 +220,9 @@ typedef struct stVortData
int JumpLeftFrame; int JumpLeftFrame;
int DyingFrame; int DyingFrame;
int DeadFrame; int DeadFrame;
} stVortData; };
typedef struct stBearData
struct stBearData
{ {
unsigned char state; unsigned char state;
@@ -232,8 +235,9 @@ typedef struct stBearData
unsigned int running; unsigned int running;
int dist_traveled; int dist_traveled;
} stBearData; };
typedef struct stButlerData
struct stButlerData
{ {
unsigned char state; unsigned char state;
unsigned char timer,animtimer; unsigned char timer,animtimer;
@@ -241,8 +245,9 @@ typedef struct stButlerData
unsigned int dist_traveled; unsigned int dist_traveled;
unsigned char movedir; unsigned char movedir;
} stButlerData; };
typedef struct stTankData
struct stTankData
{ {
unsigned char state; unsigned char state;
@@ -264,8 +269,9 @@ typedef struct stTankData
unsigned int firetimes; unsigned int firetimes;
unsigned int timetillcanfire; unsigned int timetillcanfire;
unsigned int timetillcanfirecauseonsamelevel; unsigned int timetillcanfirecauseonsamelevel;
} stTankData; };
typedef struct stRayData
struct stRayData
{ {
char state; char state;
char direction; char direction;
@@ -280,20 +286,23 @@ typedef struct stRayData
// for earth chunks // for earth chunks
int baseframe; int baseframe;
} stRayData; };
typedef struct stDoorData
struct stDoorData
{ {
char timer; char timer;
char distance_traveled; char distance_traveled;
} stDoorData; };
typedef struct stIceChunk
struct stIceChunk
{ {
char movedir; char movedir;
char state; char state;
unsigned int originalX, originalY; unsigned int originalX, originalY;
int timer; int timer;
} stIceChunk; };
typedef struct stTeleportData
struct stTeleportData
{ {
char animtimer; char animtimer;
char animframe; char animframe;
@@ -312,17 +321,18 @@ typedef struct stTeleportData
char fadeamt; char fadeamt;
char fadetimer; char fadetimer;
} stTeleportData; };
typedef struct stRopeData
struct stRopeData
{ {
char state; char state;
int droptimer; int droptimer;
int droptimes; int droptimes;
int stoneX, stoneY; int stoneX, stoneY;
int vortboss; int vortboss;
} stRopeData; };
typedef struct stWalkerData struct stWalkerData
{ {
unsigned char state; unsigned char state;
@@ -333,9 +343,9 @@ typedef struct stWalkerData
unsigned char walkdir; unsigned char walkdir;
unsigned char kickedplayer[MAX_PLAYERS]; unsigned char kickedplayer[MAX_PLAYERS];
} stWalkerData; };
typedef struct stPlatformData struct stPlatformData
{ {
unsigned char state; unsigned char state;
unsigned char animframe; unsigned char animframe;
@@ -344,9 +354,9 @@ typedef struct stPlatformData
unsigned char movedir; unsigned char movedir;
unsigned char kickedplayer[MAX_PLAYERS]; unsigned char kickedplayer[MAX_PLAYERS];
} stPlatformData; };
typedef struct stSEData struct stSEData
{ {
unsigned int type; unsigned int type;
@@ -360,9 +370,9 @@ typedef struct stSEData
unsigned int frame; unsigned int frame;
int mx,my; int mx,my;
int blowx,blowy; int blowx,blowy;
} stSEData; };
typedef struct stBabyData struct stBabyData
{ {
char state; char state;
char dir; char dir;
@@ -373,9 +383,9 @@ typedef struct stBabyData
char walkframe; char walkframe;
int walktimer; int walktimer;
} stBabyData; };
typedef struct stFoobData struct stFoobData
{ {
char state; char state;
char dir; char dir;
@@ -385,9 +395,9 @@ typedef struct stFoobData
int OffOfSameLevelTime; int OffOfSameLevelTime;
int spooktimer; int spooktimer;
int SpookedByWho; int SpookedByWho;
} stFoobData; };
typedef struct stNinjaData struct stNinjaData
{ {
char state; char state;
char dir; char dir;
@@ -401,7 +411,7 @@ typedef struct stNinjaData
int KickMoveTimer; int KickMoveTimer;
int isdying; int isdying;
int dietimer; int dietimer;
} stNinjaData; };
typedef struct stMotherData typedef struct stMotherData
{ {
@@ -644,7 +654,7 @@ typedef struct stAnimTile
#define SCROLLTRIGGERDOWN 114 #define SCROLLTRIGGERDOWN 114
// this structure contains all the variables used by a player // this structure contains all the variables used by a player
typedef struct stPlayer struct stPlayer
{ {
// these coordinates are CSFed // these coordinates are CSFed
unsigned long x; unsigned long x;
@@ -726,7 +736,9 @@ typedef struct stPlayer
unsigned int ankhtime, ankhshieldobject; unsigned int ankhtime, ankhshieldobject;
stInventory inventory; stInventory inventory;
} stPlayer;
stPlayer() { memset(this, 0, sizeof(stPlayer)); }
};
typedef struct stShipQueue typedef struct stShipQueue
{ {
@@ -845,7 +857,7 @@ typedef struct stShipQueue
#include "keenext.h" #include "keenext.h"
#include "sdl/CSettings.h" #include "sdl/CSettings.h"
typedef struct stCloneKeenPlus struct stCloneKeenPlus
{ {
stCommand Command[MAX_COMMANDS]; stCommand Command[MAX_COMMANDS];
SDL_Joystick *Joystick; SDL_Joystick *Joystick;
@@ -857,7 +869,11 @@ typedef struct stCloneKeenPlus
stOption Option[NUM_OPTIONS]; stOption Option[NUM_OPTIONS];
unsigned short numGames; unsigned short numGames;
unsigned short shutdown; unsigned short shutdown;
}stCloneKeenPlus;
stCloneKeenPlus() : Joystick(NULL), GameData(NULL), numGames(0), shutdown(SHUTDOWN_NONE) {
memset(&Event, 0, sizeof(Event));
}
};
// keen.c // keen.c
void playgame_levelmanager(stCloneKeenPlus *pCKP); void playgame_levelmanager(stCloneKeenPlus *pCKP);

View File

@@ -360,14 +360,6 @@ int mainmenu(stCloneKeenPlus *pCKP,int defaultopt)
return selection; return selection;
} }
void initialiazeDlgStruct(stDlgStruct *pDlgStruct)
{
pDlgStruct->OptionSwitch = (stOptionSwitch*) malloc(pDlgStruct->num_OptionSwitches*sizeof(stOptionSwitch));
pDlgStruct->Separator = (stSeparator*) malloc(pDlgStruct->num_Separators*sizeof(stSeparator));
pDlgStruct->StarterSwitch = (stStarterSwitch*) malloc(pDlgStruct->num_StarterSwitch*sizeof(stStarterSwitch));
pDlgStruct->TextLine = (stTextLine*) malloc(pDlgStruct->num_TextLines*sizeof(stTextLine));
}
int getDifficulty(stCloneKeenPlus *pCKP) int getDifficulty(stCloneKeenPlus *pCKP)
{ {
CDialog *DifficultyMenu; CDialog *DifficultyMenu;