- improved ending scene of EP1. The lights on Window are now seen
- improved key stacking code - reduced more lines of the source code git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@216 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
Commander Genius Pre-Release v0.3 (CloneKeenPlus):
|
||||
--------------------------------------------------
|
||||
|
||||
08-08-2009
|
||||
- Better source-code. At least a little bit :-)
|
||||
- Special key items can only be taken once. Even replaying the levels
|
||||
- Now levels can be exited without doing something before through the exit door. Be careful ;-)
|
||||
- Vorticon Commander in Ep1 now dies with 105 shots.
|
||||
- Improved consistency of the program
|
||||
- Improved memory management when decompressing graphics
|
||||
- Improved Enemys AI
|
||||
|
||||
05-08-2009
|
||||
|
||||
@@ -111,6 +111,7 @@ short CGame::runCycle(stCloneKeenPlus *pCKP)
|
||||
initgamefirsttime(pCKP, EGAGraphics->getNumSprites());
|
||||
loadinggame = 0;
|
||||
playgame_levelmanager(pCKP);
|
||||
|
||||
break;
|
||||
case MAINMNU_2PLAYER:
|
||||
defaultopt = 0;
|
||||
@@ -167,34 +168,34 @@ short CGame::runCycle(stCloneKeenPlus *pCKP)
|
||||
|
||||
case MAINMNU_TIMEOUT:
|
||||
case MAINMNU_DEMO:
|
||||
retval = play_demo(current_demo, pCKP, EGAGraphics->getNumSprites());
|
||||
|
||||
if (retval==DEMO_RESULT_FILE_BAD)
|
||||
{
|
||||
// we tried to play a demo that did not exist--assume we
|
||||
// reached the last demo and go back to the intro
|
||||
//intro(pCKP);
|
||||
CIntro *pIntro;
|
||||
pIntro = new CIntro();
|
||||
delete pIntro;
|
||||
pIntro = NULL;
|
||||
current_demo = 0;
|
||||
}
|
||||
else if (retval==DEMO_RESULT_CANCELED)
|
||||
{ // user hit a key to cancel demo
|
||||
IntroCanceled = 1; // pop up menu
|
||||
}
|
||||
retval = play_demo(current_demo, pCKP, EGAGraphics->getNumSprites());
|
||||
|
||||
if (IntroCanceled)
|
||||
{ // user canceled out of demo (or intro if at end of demos)
|
||||
// if user selected "demo" have it selected when he comes back
|
||||
if (opt==MAINMNU_DEMO)
|
||||
{
|
||||
defaultopt = MAINMNU_DEMO;
|
||||
}
|
||||
}
|
||||
if (retval==DEMO_RESULT_FILE_BAD)
|
||||
{
|
||||
// we tried to play a demo that did not exist--assume we
|
||||
// reached the last demo and go back to the intro
|
||||
//intro(pCKP);
|
||||
CIntro *pIntro;
|
||||
pIntro = new CIntro();
|
||||
delete pIntro;
|
||||
pIntro = NULL;
|
||||
current_demo = 0;
|
||||
}
|
||||
else if (retval==DEMO_RESULT_CANCELED)
|
||||
{ // user hit a key to cancel demo
|
||||
IntroCanceled = 1; // pop up menu
|
||||
}
|
||||
|
||||
current_demo++;
|
||||
if (IntroCanceled)
|
||||
{ // user canceled out of demo (or intro if at end of demos)
|
||||
// if user selected "demo" have it selected when he comes back
|
||||
if (opt==MAINMNU_DEMO)
|
||||
{
|
||||
defaultopt = MAINMNU_DEMO;
|
||||
}
|
||||
}
|
||||
current_demo++;
|
||||
break;
|
||||
case RESTART_GAME:
|
||||
g_pLogFile->ftextOut("********************<br>");
|
||||
|
||||
@@ -100,13 +100,13 @@ typedef struct stTankData
|
||||
{
|
||||
char state;
|
||||
|
||||
uint timer,animtimer;
|
||||
unsigned int timer,animtimer;
|
||||
unsigned char frame;
|
||||
uint dist_traveled;
|
||||
unsigned int dist_traveled;
|
||||
|
||||
unsigned char movedir;
|
||||
|
||||
uint ponsameleveltime;
|
||||
unsigned int ponsameleveltime;
|
||||
unsigned char alreadyfiredcauseonsamelevel;
|
||||
unsigned char fireafterlook;
|
||||
|
||||
@@ -114,11 +114,11 @@ typedef struct stTankData
|
||||
unsigned char detectedPlayerIndex; // index of player that was detected
|
||||
|
||||
// for tank2
|
||||
uint timetillnextshot;
|
||||
uint firetimes;
|
||||
uint timetillcanfire;
|
||||
uint timetillcanfirecauseonsamelevel;
|
||||
uint turnaroundtimer;
|
||||
unsigned int timetillnextshot;
|
||||
unsigned int firetimes;
|
||||
unsigned int timetillcanfire;
|
||||
unsigned int timetillcanfirecauseonsamelevel;
|
||||
unsigned int turnaroundtimer;
|
||||
int pausetime;
|
||||
} stTankData;
|
||||
|
||||
|
||||
@@ -280,17 +280,17 @@ int scrollingon;
|
||||
|
||||
int eseq1_BackAtHome(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
/*int draw;*/
|
||||
int i;
|
||||
int i;
|
||||
std::string text[10];
|
||||
std::string strname;
|
||||
std::string tempbuf;
|
||||
short textline, showtimer;
|
||||
unsigned short amountshown;
|
||||
signed int waittimer;
|
||||
int state;
|
||||
int enter, lastenterstate;
|
||||
int dlgX, dlgY, dlgW, dlgH;
|
||||
short textline, showtimer;
|
||||
unsigned short amountshown;
|
||||
signed int waittimer;
|
||||
int state;
|
||||
int enter, lastenterstate;
|
||||
int dlgX, dlgY, dlgW, dlgH;
|
||||
int bmnum_window;
|
||||
|
||||
#define STATE_TEXTAPPEARING 0
|
||||
#define STATE_WAITASEC 1
|
||||
@@ -323,6 +323,7 @@ int dlgX, dlgY, dlgW, dlgH;
|
||||
dlgY = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "TOP");
|
||||
dlgW = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "WIDTH");
|
||||
dlgH = GetStringAttribute("EP1_ESEQ_PART2_PAGE1", "HEIGHT");
|
||||
bmnum_window = g_pGraphics->getBitmapNumberFromName("WINDOFF"); // window lights off
|
||||
|
||||
fade.mode = FADE_GO;
|
||||
fade.rate = FADE_NORM;
|
||||
@@ -331,81 +332,87 @@ int dlgX, dlgY, dlgW, dlgH;
|
||||
fade.fadetimer = 0;
|
||||
do
|
||||
{
|
||||
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
|
||||
enter = ( g_pInput->getPressedKey(KENTER) || g_pInput->getPressedKey(KCTRL) || g_pInput->getPressedKey(KALT) );
|
||||
|
||||
sb_dialogbox(dlgX, dlgY, dlgW, dlgH);
|
||||
// Show the window (lights on or off)
|
||||
g_pGraphics->drawBitmap(80, 0, bmnum_window);
|
||||
|
||||
// draw the current text line up to the amount currently shown
|
||||
sb_dialogbox(dlgX, dlgY, dlgW, dlgH);
|
||||
|
||||
// draw the current text line up to the amount currently shown
|
||||
tempbuf = text[textline];
|
||||
if(amountshown < tempbuf.size())
|
||||
tempbuf.erase(amountshown);
|
||||
g_pGraphics->sb_font_draw( tempbuf, (dlgX+1)*8, (dlgY+1)*8);
|
||||
g_pGraphics->sb_font_draw( tempbuf, (dlgX+1)*8, (dlgY+1)*8);
|
||||
|
||||
if (state==STATE_TEXTAPPEARING)
|
||||
{
|
||||
if (enter) goto fullshow;
|
||||
if (showtimer > LETTER_SHOW_SPD)
|
||||
{ // it's time to show a new letter
|
||||
amountshown++;
|
||||
if (amountshown > text[textline].size())
|
||||
{ // reached end of line
|
||||
state = STATE_WAITASEC;
|
||||
// if (textline==8)
|
||||
// waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
|
||||
// else
|
||||
waittimer = -BACKHOME_SHORT_WAIT_TIME*2;
|
||||
}
|
||||
// if the last letter shown is a dash/cr ('Billy...are you a-'),
|
||||
// show the rest of the text immediately
|
||||
// (for when the mom shouts "WHAT IS THIS ONE-EYED GREEN THING..."
|
||||
if (text[textline][amountshown]==13 && \
|
||||
text[textline][amountshown-1]=='-')
|
||||
{
|
||||
fullshow: ;
|
||||
amountshown = text[textline].size();
|
||||
state = STATE_WAITASEC;
|
||||
waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
|
||||
}
|
||||
showtimer = 0;
|
||||
} else showtimer++;
|
||||
if (state==STATE_TEXTAPPEARING)
|
||||
{
|
||||
if (enter) goto fullshow;
|
||||
if (showtimer > LETTER_SHOW_SPD)
|
||||
{ // it's time to show a new letter
|
||||
amountshown++;
|
||||
if (amountshown > text[textline].size())
|
||||
{ // reached end of line
|
||||
state = STATE_WAITASEC;
|
||||
waittimer = -BACKHOME_SHORT_WAIT_TIME*2;
|
||||
}
|
||||
// if the last letter shown is a dash/cr ('Billy...are you a-'),
|
||||
// show the rest of the text immediately
|
||||
// (for when the mom shouts "WHAT IS THIS ONE-EYED GREEN THING..."
|
||||
if (text[textline][amountshown]==13 && \
|
||||
text[textline][amountshown-1]=='-')
|
||||
{
|
||||
fullshow: ;
|
||||
amountshown = text[textline].size();
|
||||
state = STATE_WAITASEC;
|
||||
waittimer = -BACKHOME_SHORT_WAIT_TIME*3;
|
||||
}
|
||||
showtimer = 0;
|
||||
} else showtimer++;
|
||||
|
||||
// user pressed enter
|
||||
if (enter)
|
||||
{ // show all text immediately
|
||||
// user pressed enter
|
||||
if (enter)
|
||||
{ // show all text immediately
|
||||
|
||||
}
|
||||
}
|
||||
else if (state==STATE_WAITASEC)
|
||||
{
|
||||
if (enter) goto nextline;
|
||||
if (waittimer<BACKHOME_SHORT_WAIT_TIME)
|
||||
{
|
||||
waittimer++;
|
||||
if (waittimer==BACKHOME_SHORT_WAIT_TIME)
|
||||
{
|
||||
nextline: ;
|
||||
textline++;
|
||||
state = STATE_TEXTAPPEARING;
|
||||
amountshown = 0;
|
||||
if (textline>7)
|
||||
{ // end of text
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state==STATE_WAITASEC)
|
||||
{
|
||||
if (enter) goto nextline;
|
||||
if (waittimer<BACKHOME_SHORT_WAIT_TIME)
|
||||
{
|
||||
waittimer++;
|
||||
if (waittimer==BACKHOME_SHORT_WAIT_TIME)
|
||||
{
|
||||
nextline: ;
|
||||
|
||||
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE)
|
||||
return 0;
|
||||
if( (textline > 0 && textline < 5) || textline == 6)
|
||||
bmnum_window = g_pGraphics->getBitmapNumberFromName("WINDON"); // lights on
|
||||
else
|
||||
bmnum_window = g_pGraphics->getBitmapNumberFromName("WINDOFF"); // lights off
|
||||
|
||||
gamedo_fades();
|
||||
gamedo_frameskipping_blitonly();
|
||||
textline++;
|
||||
state = STATE_TEXTAPPEARING;
|
||||
amountshown = 0;
|
||||
if (textline>7)
|
||||
{ // end of text
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastenterstate = enter;
|
||||
if (fade.dir==FADE_OUT && fade.mode==FADE_COMPLETE)
|
||||
return 0;
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
if (g_pInput->getPressedKey(KQUIT)) return 1;
|
||||
gamedo_fades();
|
||||
gamedo_frameskipping_blitonly();
|
||||
|
||||
lastenterstate = enter;
|
||||
|
||||
g_pInput->pollEvents();
|
||||
g_pTimer->SpeedThrottle();
|
||||
if (g_pInput->getPressedKey(KQUIT)) return 1;
|
||||
} while(1);
|
||||
|
||||
finale_draw("finale.ck1", pCKP->GameData[pCKP->Resources.GameSelected-1].DataDirectory);
|
||||
|
||||
@@ -12,5 +12,4 @@ void eseq_ToBeContinued();
|
||||
void eseq_showmsg(const std::string& text, int boxleft, int boxtop,
|
||||
int boxwidth, int boxheight, bool autodismiss);
|
||||
|
||||
|
||||
#endif /* ENDINGSEQUENCEEP1_H_ */
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define DEMOBOX_WIDTH 48
|
||||
#define DEMOBOX_HEIGHT 16
|
||||
|
||||
unsigned char demobox_image[768] = { \
|
||||
/*unsigned char demobox_image[768] = { \
|
||||
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
|
||||
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
|
||||
15,15,15,12,12,12,12,12,12,15,15,15,15,12,12,12,12,12,12,12,15,15,12,15,15,15,15,15,15,15,12,15,15,15,15,12,12,12,12,15,15,15,15,15,15,15,15,15,15, \
|
||||
@@ -27,6 +27,25 @@ unsigned char demobox_image[768] = { \
|
||||
4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
|
||||
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
|
||||
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
|
||||
};*/
|
||||
|
||||
unsigned char demobox_image[768] = { \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0,12,12,12,12,12,12, 0, 0, 0, 0,12,12,12,12,12,12,12, 0, 0,12, 0, 0, 0, 0, 0, 0, 0,12, 0, 0, 0, 0,12,12,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0,12,12, 0, 0, 0,12,12, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0,12,12, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0,12,12, 0, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12,12, 0, 0, 0,12,12,12, 0, 0,12,12, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
12,12, 0, 0, 0, 0,12,12, 0, 0,12,12,12,12,12,12, 0, 0, 0,12,12, 0,12, 0,12, 0,12,12, 0, 0,12,12, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12, \
|
||||
12, 0, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0,12, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12, \
|
||||
0, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0,12, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12, 0, \
|
||||
0, 0,12,12, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0,12,12, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12,12,12, \
|
||||
12,12, 0, 0, 0, 0,12,12,12,12,12,12,12, 0, 0,12,12, 0, 0, 0, 0, 0,12,12, 0, 0, 0, 0,12,12,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4, \
|
||||
4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 , 0,4 ,4 ,12,12,12,12,12,12,12,12,12,12, \
|
||||
12,12,12,12,12,12,15,12,12,15,15,15,15,15,15,12,12,15,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,4 ,4 , 0,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4, \
|
||||
4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
|
||||
};
|
||||
|
||||
char demobox_mask[768] = { \
|
||||
@@ -47,4 +66,3 @@ char demobox_mask[768] = { \
|
||||
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , \
|
||||
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , \
|
||||
};
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#include "sdl/sound/CSound.h"
|
||||
#include "hqp/CMusic.h"
|
||||
#include "include/fileio.h"
|
||||
#include <vector>
|
||||
#include "include/fileio/rle.h"
|
||||
#include "CLogFile.h"
|
||||
#include "CGraphics.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include "StringUtils.h"
|
||||
#include "Debug.h"
|
||||
#include "FindFile.h"
|
||||
@@ -473,7 +473,6 @@ unsigned int temp1, temp2, temp3, temp4;
|
||||
unsigned int loadmap(const std::string& filename, const std::string& path,
|
||||
int lvlnum,stLevelControl* p_levelcontrol)
|
||||
{
|
||||
|
||||
// TODO: Tie that one up in converting stuff into C++
|
||||
|
||||
FILE *fp;
|
||||
@@ -495,37 +494,29 @@ unsigned int loadmap(const std::string& filename, const std::string& path,
|
||||
fp = OpenGameFile(fname.c_str(), "rb");
|
||||
if (!fp)
|
||||
{
|
||||
// only record this error message on build platforms that log errors
|
||||
// to a file and not to the screen.
|
||||
// only record this error message on build platforms that log errors
|
||||
// to a file and not to the screen.
|
||||
g_pLogFile->ftextOut("loadmap(): unable to open file %s<br>", fname.c_str());
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
g_pLogFile->ftextOut("loadmap(): file %s opened. Loading...<br>", fname.c_str());
|
||||
|
||||
// decompress map RLEW data
|
||||
curmapx = curmapy = mapdone = 0;
|
||||
|
||||
unsigned int *filebuf; // big File Buffer for the uncompression
|
||||
filebuf = (unsigned int*) malloc(1000000*sizeof(int));
|
||||
std::vector<unsigned int> filebuf;
|
||||
unsigned long finsize; // Final size
|
||||
|
||||
if(filebuf == NULL)
|
||||
{
|
||||
g_pLogFile->ftextOut("loadmap(): unable to allocate memory for unpacking the level file<br>", fname.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int finsize; // Final size
|
||||
|
||||
finsize = unRLEW(fp, filebuf);
|
||||
finsize = unRLEW(fp, filebuf);
|
||||
|
||||
c=0;
|
||||
|
||||
if(finsize == -1)
|
||||
if(!finsize)
|
||||
{
|
||||
rewind(fp);
|
||||
while(!feof(fp))
|
||||
{
|
||||
filebuf[c] = fgeti(fp);
|
||||
filebuf.push_back( fgeti(fp) );
|
||||
c++;
|
||||
}
|
||||
}
|
||||
@@ -569,8 +560,7 @@ unsigned int loadmap(const std::string& filename, const std::string& path,
|
||||
c++;
|
||||
}
|
||||
|
||||
free(filebuf);
|
||||
|
||||
filebuf.clear();
|
||||
fclose(fp);
|
||||
|
||||
// HQ Sounds. Load Music for a level if you have HQP
|
||||
|
||||
@@ -5,14 +5,16 @@
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include "../funcdefs.h"
|
||||
|
||||
// Reference to ../fileio.cpp
|
||||
unsigned int fgeti(FILE *fp);
|
||||
|
||||
int unRLEW(FILE *fp, unsigned int *filebuf)
|
||||
unsigned long unRLEW(FILE *fp, std::vector<unsigned int>& filebuf)
|
||||
{
|
||||
|
||||
int t,i, howmany, cursize, finsize;
|
||||
int t,i, howmany, cursize;
|
||||
unsigned int finsize;
|
||||
/*
|
||||
1.) If implemented, get the first dword in the file, [Final Length]
|
||||
2.) If [Length of data so far] < [Final Length] then:
|
||||
@@ -31,28 +33,26 @@ int unRLEW(FILE *fp, unsigned int *filebuf)
|
||||
|
||||
rewind(fp);
|
||||
|
||||
|
||||
while(!feof(fp)) // Detect, if the file is really RLEW compressed!
|
||||
{
|
||||
t = fgeti(fp);
|
||||
if(t == 0xFEFE)
|
||||
{
|
||||
cursize = 1;
|
||||
filebuf.push_back(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(cursize == 0)
|
||||
{
|
||||
return -1; // This file is not RLEW compressed!
|
||||
}
|
||||
return 0; // This file is not RLEW compressed!
|
||||
|
||||
rewind(fp);
|
||||
|
||||
finsize = fgeti(fp);
|
||||
|
||||
|
||||
while( cursize < finsize )
|
||||
while( filebuf.size() < finsize )
|
||||
{
|
||||
t = fgeti(fp);
|
||||
if (t == 0xFEFE)
|
||||
@@ -61,16 +61,19 @@ int unRLEW(FILE *fp, unsigned int *filebuf)
|
||||
t = fgeti(fp);
|
||||
for(i=0;i<howmany;i++)
|
||||
{
|
||||
filebuf[cursize] = t;
|
||||
cursize++;
|
||||
//filebuf[cursize] = t;
|
||||
filebuf.push_back(t);
|
||||
//cursize++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filebuf[cursize] = t;
|
||||
cursize++;
|
||||
//filebuf[cursize] = t;
|
||||
filebuf.push_back(t);
|
||||
//cursize++;
|
||||
}
|
||||
}
|
||||
|
||||
return cursize;
|
||||
//return cursize;
|
||||
return filebuf.size();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
// gamedo.c
|
||||
int gamedo_ScrollTriggers(int theplayer);
|
||||
void gamedo_AnimatedTiles(bool animate_hinttiles = false);
|
||||
|
||||
void gamedo_render_eraseobjects(void);
|
||||
void gamedo_render_drawdebug(void);
|
||||
void gamedo_render_erasedebug(void);
|
||||
@@ -63,7 +62,6 @@ void sound_resume(void);
|
||||
char sound_extraction_of_exe_files(char *inputpath, int episode);
|
||||
|
||||
// graphics.c
|
||||
void DrawBitmap(int xa, int ya, int b);
|
||||
void freemem(void);
|
||||
void Graphics_Stop(void);
|
||||
void /*inline*/ sb_setpixel(int x, int y, unsigned char c);
|
||||
|
||||
35
src/game.cpp
35
src/game.cpp
@@ -15,7 +15,6 @@
|
||||
#include "sdl/CTimer.h"
|
||||
#include "sdl/CInput.h"
|
||||
#include "sdl/sound/CSound.h"
|
||||
//#include "include/enemyai.h"
|
||||
#include "hqp/CMusic.h"
|
||||
#include "vorticon/CHighScores.h"
|
||||
#include "hqp/CHQBitmap.h"
|
||||
@@ -275,33 +274,35 @@ void gameloop(stCloneKeenPlus *pCKP)
|
||||
// gives keycard for door doortile to player p
|
||||
void give_keycard(int doortile, int p)
|
||||
{
|
||||
bool keystack = options[OPT_KEYCARDSTACK].value; // True if set
|
||||
g_pSound->playSound(SOUND_GET_CARD, PLAY_NOW);
|
||||
|
||||
if (doortile==DOOR_YELLOW) player[p].inventory.HasCardYellow = keystack ? player[p].inventory.HasCardYellow + 1 : 1;
|
||||
else if (doortile==DOOR_RED) player[p].inventory.HasCardRed = keystack ? player[p].inventory.HasCardRed + 1 : 1;
|
||||
else if (doortile==DOOR_GREEN) player[p].inventory.HasCardGreen = keystack ? player[p].inventory.HasCardGreen + 1 : 1;
|
||||
else if (doortile==DOOR_BLUE) player[p].inventory.HasCardBlue = keystack ? player[p].inventory.HasCardBlue + 1 : 1;
|
||||
if (doortile==DOOR_YELLOW && player[p].inventory.HasCardYellow < 9)
|
||||
player[p].inventory.HasCardYellow++;
|
||||
else if (doortile==DOOR_RED && player[p].inventory.HasCardRed < 9)
|
||||
player[p].inventory.HasCardRed++;
|
||||
else if (doortile==DOOR_GREEN && player[p].inventory.HasCardGreen < 9)
|
||||
player[p].inventory.HasCardGreen++;
|
||||
else if (doortile==DOOR_BLUE && player[p].inventory.HasCardBlue < 9)
|
||||
player[p].inventory.HasCardBlue++;
|
||||
else
|
||||
{
|
||||
crashflag = 1;
|
||||
crashflag = 0;
|
||||
crashflag2 = doortile;
|
||||
why_term_ptr = "give_keycard(): invalid value for doortile parameter.";
|
||||
g_pLogFile->textOut("give_keycard(): invalid value for doortile parameter.<br>");
|
||||
}
|
||||
}
|
||||
|
||||
// take away the specified keycard from player p
|
||||
void take_keycard(int doortile, int p)
|
||||
{
|
||||
if (doortile==DOOR_YELLOW) player[p].inventory.HasCardYellow--;
|
||||
else if (doortile==DOOR_RED) player[p].inventory.HasCardRed--;
|
||||
else if (doortile==DOOR_GREEN) player[p].inventory.HasCardGreen--;
|
||||
else if (doortile==DOOR_BLUE) player[p].inventory.HasCardBlue--;
|
||||
|
||||
if(player[p].inventory.HasCardYellow > 9) player[p].inventory.HasCardYellow = 0;
|
||||
if(player[p].inventory.HasCardRed > 9) player[p].inventory.HasCardRed = 0;
|
||||
if(player[p].inventory.HasCardGreen > 9) player[p].inventory.HasCardGreen = 0;
|
||||
if(player[p].inventory.HasCardBlue > 9) player[p].inventory.HasCardBlue = 0;
|
||||
if (doortile==DOOR_YELLOW && player[p].inventory.HasCardYellow > 0)
|
||||
player[p].inventory.HasCardYellow--;
|
||||
else if (doortile==DOOR_RED && player[p].inventory.HasCardRed > 0)
|
||||
player[p].inventory.HasCardRed--;
|
||||
else if (doortile==DOOR_GREEN && player[p].inventory.HasCardGreen > 0)
|
||||
player[p].inventory.HasCardGreen--;
|
||||
else if (doortile==DOOR_BLUE && player[p].inventory.HasCardBlue > 0)
|
||||
player[p].inventory.HasCardBlue--;
|
||||
}
|
||||
|
||||
// unregisters all animated tiles with baseframe tile
|
||||
|
||||
@@ -243,7 +243,7 @@ int i, topobj;
|
||||
|
||||
if (objects[i].hasbeenonscreen || objects[i].zapped ||
|
||||
objects[i].type==OBJ_RAY || \
|
||||
objects[i].type==OBJ_ICECHUNK || objects[i].type==OBJ_PLATFORM ||\
|
||||
objects[i].type==OBJ_ICECHUNK || objects[i].type==OBJ_PLATFORM ||
|
||||
objects[i].type==OBJ_PLATVERT || objects[i].type==OBJ_YORP ||
|
||||
objects[i].type==OBJ_FOOB || objects[i].type==OBJ_WALKER)
|
||||
|
||||
@@ -291,13 +291,14 @@ int i, topobj;
|
||||
//case OBJ_GOTPOINTS: gotpoints_ai(i); break;
|
||||
|
||||
case OBJ_DEMOMSG: break;
|
||||
|
||||
default:
|
||||
g_pLogFile->ftextOut("gamedo_enemy_ai: Object %d is of invalid type %d\n", i, objects[i].type);
|
||||
break;
|
||||
}
|
||||
|
||||
objects[i].scrx = (objects[i].x>>CSF)-scroll_x;
|
||||
objects[i].scry = (objects[i].y>>CSF)-scroll_y;
|
||||
objects[i].scrx = (objects[i].x>>CSF)-scroll_x;
|
||||
objects[i].scry = (objects[i].y>>CSF)-scroll_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -486,33 +487,26 @@ int xa,ya;
|
||||
|
||||
}
|
||||
|
||||
// if we're playing a demo keep the "DEMO" message on the screen
|
||||
// as an object
|
||||
// TODO: It would be better to add this demo message as on object, like the other stuff that is shown
|
||||
// This still must be done...
|
||||
/*if (show_demo_title)
|
||||
{
|
||||
#define DEMO_X_POS 137
|
||||
#define DEMO_Y_POS 6
|
||||
objects[DemoObjectHandle].exists = 1;
|
||||
objects[DemoObjectHandle].onscreen = 1;
|
||||
objects[DemoObjectHandle].type = OBJ_DEMOMSG;
|
||||
objects[DemoObjectHandle].sprite = DemoSprite;
|
||||
objects[DemoObjectHandle].x = (DEMO_X_POS+scroll_x)<<CSF;
|
||||
objects[DemoObjectHandle].y = (DEMO_Y_POS+scroll_y)<<CSF;
|
||||
objects[DemoObjectHandle].honorPriority = 0;
|
||||
}
|
||||
else objects[DemoObjectHandle].exists = 0;*/
|
||||
|
||||
// draw all objects. drawn in reverse order because the player sprites
|
||||
// are in the first few indexes and we want them to come out on top.
|
||||
for(i=highest_objslot;;i--)
|
||||
for( i=highest_objslot ;; i-- )
|
||||
{
|
||||
if (objects[i].exists && objects[i].onscreen)
|
||||
{
|
||||
objects[i].scrx = ((objects[i].x>>CSF)-scroll_x);
|
||||
objects[i].scry = ((objects[i].y>>CSF)-scroll_y);
|
||||
g_pGraphics->drawSprite(objects[i].scrx, objects[i].scry, objects[i].sprite, i);
|
||||
// Draw the Demo-Bar if it must be shown
|
||||
if(objects[i].type == OBJ_DEMOMSG)
|
||||
{
|
||||
#define DEMO_X_POS 137
|
||||
#define DEMO_Y_POS 6
|
||||
objects[i].scrx = DEMO_X_POS;
|
||||
objects[i].scry = DEMO_Y_POS;
|
||||
}
|
||||
else
|
||||
{
|
||||
objects[i].scrx = ((objects[i].x>>CSF)-scroll_x);
|
||||
objects[i].scry = ((objects[i].y>>CSF)-scroll_y);
|
||||
}
|
||||
g_pGraphics->drawSprite(objects[i].scrx, objects[i].scry, objects[i].sprite, i);
|
||||
|
||||
if (objects[i].honorPriority)
|
||||
{
|
||||
@@ -552,9 +546,8 @@ int xa,ya;
|
||||
}
|
||||
|
||||
}
|
||||
if(i==0) break;
|
||||
if(i==0) break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void gamedo_render_drawdebug(void)
|
||||
|
||||
@@ -49,14 +49,14 @@ void gamepdo_wm_HandlePlayer(int cp, stCloneKeenPlus *pCKP)
|
||||
AllowMountUnmountNessie(cp);
|
||||
}
|
||||
|
||||
gamepdo_wm_SelectFrame(cp);
|
||||
gamepdo_wm_SelectFrame(cp, pCKP->Control.levelcontrol.episode);
|
||||
|
||||
// copy player's keytable to lastkeytable
|
||||
memcpy(&player[cp].lastkeytable, &player[cp].keytable, sizeof(player[cp].lastkeytable));
|
||||
}
|
||||
|
||||
// select the appropriate player frame based on what he's doing
|
||||
void gamepdo_wm_SelectFrame(int cp)
|
||||
void gamepdo_wm_SelectFrame(int cp, int episode)
|
||||
{
|
||||
// select base frame for current direction
|
||||
if (player[cp].pshowdir==RIGHT) player[cp].playframe = PMAPRIGHTFRAME;
|
||||
@@ -64,6 +64,9 @@ void gamepdo_wm_SelectFrame(int cp)
|
||||
else if (player[cp].pshowdir==UP) player[cp].playframe = PMAPUPFRAME;
|
||||
else if (player[cp].pshowdir==DOWN) player[cp].playframe = PMAPDOWNFRAME;
|
||||
|
||||
// episode 3 map frames start at 31, ep1&2 at 32
|
||||
if (episode==3) player[cp].playframe--;
|
||||
|
||||
// no walking animation if we're fading
|
||||
if (fade.mode != NO_FADE) return;
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
* Author: gerstrong
|
||||
*/
|
||||
|
||||
int unRLEW(FILE *fp, unsigned int *filebuf);
|
||||
unsigned long unRLEW(FILE *fp, std::vector<unsigned int>& filebuf);
|
||||
|
||||
@@ -3,7 +3,7 @@ void gamepdo_wm_HandlePlayer(int cp, stCloneKeenPlus *pCKP);
|
||||
void gamepdo_InertiaAndFriction_Y(int cp, stCloneKeenPlus *pCKP);
|
||||
void gamepdo_InertiaAndFriction_X(unsigned int cp, stCloneKeenPlus *pCKP);
|
||||
void gamepdo_wm_AllowEnterLevel(int cp, stCloneKeenPlus *pCKP);
|
||||
void gamepdo_wm_SelectFrame(int cp);
|
||||
void gamepdo_wm_SelectFrame(int cp, int episode);
|
||||
void gamepdo_wm_setblockedlrud(int cp, stCloneKeenPlus *pCKP);
|
||||
void gamepdo_wm_setdir(int cp, stCloneKeenPlus *pCKP);
|
||||
|
||||
|
||||
27
src/main.cpp
27
src/main.cpp
@@ -109,6 +109,7 @@ unsigned int numplayers;
|
||||
int crashflag,crashflag2,crashflag3;
|
||||
const char *why_term_ptr = "No reason given.";
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
banner(); // Intro on the text-console.
|
||||
@@ -172,11 +173,7 @@ int main(int argc, char *argv[])
|
||||
if(!CKP.Control.skipstarting)
|
||||
{
|
||||
while(!loadStartMenu(&CKP))
|
||||
{
|
||||
g_pLogFile->textOut(PURPLE,"Error! You have chosen a Game that doesn't exist. Please correct the \"games.cfg\" File under \"data\" and choose another game.<br>");
|
||||
//cleanupResources(&CKP);
|
||||
//return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(!g_pInput->getExitEvent())
|
||||
@@ -194,17 +191,14 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if(CKP.shutdown != SHUTDOWN_NEW_GAME) {
|
||||
CKP.shutdown = SHUTDOWN_NONE; // Game is runnning
|
||||
|
||||
Game.runCycle(&CKP);
|
||||
}
|
||||
|
||||
if(CKP.shutdown == SHUTDOWN_NEW_GAME)
|
||||
{
|
||||
while(!loadStartMenu(&CKP))
|
||||
{
|
||||
g_pLogFile->textOut(PURPLE,"Error! You have chosen a Game that doesn't exist. Please correct the \"games.cfg\" File under \"data\" and choose another game.<br>");
|
||||
//cleanupResources(&CKP);
|
||||
//return 0;
|
||||
}
|
||||
|
||||
//loadResourcesforGame(pCKP);
|
||||
if(Game.loadResources(CKP.Control.levelcontrol.episode, CKP.GameData[CKP.Resources.GameSelected-1].DataDirectory))
|
||||
@@ -291,7 +285,6 @@ short closeCKP(stCloneKeenPlus *pCKP)
|
||||
int eseq2_TantalusRay(stCloneKeenPlus *pCKP);
|
||||
void eseq2_vibrate();
|
||||
|
||||
|
||||
void playgame_levelmanager(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
int i, o, wm, firsttime = 1;
|
||||
@@ -357,7 +350,7 @@ void playgame_levelmanager(stCloneKeenPlus *pCKP)
|
||||
|
||||
p_levelcontrol->command = LVLC_NOCOMMAND;
|
||||
|
||||
p_levelcontrol->dark = 0;
|
||||
p_levelcontrol->dark = false;
|
||||
p_levelcontrol->usedhintmb = false;
|
||||
if (loadinggame)
|
||||
{
|
||||
@@ -378,6 +371,20 @@ void playgame_levelmanager(stCloneKeenPlus *pCKP)
|
||||
|
||||
g_pInput->flushAll();
|
||||
|
||||
// Check if we are in Demo-mode. If yes, add the upper logo to the objects
|
||||
if(pCKP->Control.levelcontrol.demomode)
|
||||
{
|
||||
objects[DemoObjectHandle].exists = 1;
|
||||
objects[DemoObjectHandle].onscreen = 1;
|
||||
objects[DemoObjectHandle].type = OBJ_DEMOMSG;
|
||||
objects[DemoObjectHandle].sprite = DemoSprite;
|
||||
objects[DemoObjectHandle].x = 0;
|
||||
objects[DemoObjectHandle].y = 0;
|
||||
objects[DemoObjectHandle].honorPriority = 0;
|
||||
}
|
||||
else
|
||||
objects[DemoObjectHandle].exists = 0;
|
||||
|
||||
if (wm)
|
||||
{ // entering map from normal level, or first time around
|
||||
if (!p_levelcontrol->tobonuslevel)
|
||||
|
||||
20
src/map.cpp
20
src/map.cpp
@@ -178,32 +178,21 @@ int ya = y>>4;
|
||||
|
||||
if (xa<=255 && ya<=255)
|
||||
{
|
||||
return map.mapdata[xa][ya];
|
||||
return map.mapdata[xa][ya];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(xa > 255)
|
||||
{
|
||||
xa = 255;
|
||||
//player[cp].xa = 255;
|
||||
}
|
||||
|
||||
if(ya > 254)
|
||||
{
|
||||
ya = 255;
|
||||
//player[cp].ya = 255;
|
||||
}
|
||||
|
||||
return map.mapdata[xa][ya];
|
||||
//crashflag = 1;
|
||||
//crashflag2 = x;
|
||||
//crashflag3 = y;
|
||||
//why_term_ptr = "getmaptileat(): OOB reading from mapdata.";
|
||||
//return 0;
|
||||
}
|
||||
}
|
||||
unsigned int getlevelat(unsigned int x, unsigned int y)
|
||||
{
|
||||
|
||||
return map.objectlayer[x>>4][y>>4];
|
||||
}
|
||||
|
||||
@@ -212,11 +201,10 @@ unsigned int getlevelat(unsigned int x, unsigned int y)
|
||||
// in stripes as it scrolls around.
|
||||
void drawmap(void)
|
||||
{
|
||||
int y;
|
||||
int y;
|
||||
|
||||
for(y=0;y<SCROLLBUF_NUMTILESY;y++)
|
||||
{
|
||||
map_draw_hstripe(y<<4, y);
|
||||
}
|
||||
}
|
||||
|
||||
// changes the tile at (x,y) in real time
|
||||
|
||||
@@ -1382,7 +1382,7 @@ int boxtimer;
|
||||
{
|
||||
if (player[i].isPlaying)
|
||||
{
|
||||
gamepdo_wm_SelectFrame(i);
|
||||
gamepdo_wm_SelectFrame(i, episode);
|
||||
player[i].hideplayer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
24
src/misc.cpp
24
src/misc.cpp
@@ -532,30 +532,6 @@ void showinventory(int p, stCloneKeenPlus *pCKP)
|
||||
}
|
||||
}
|
||||
|
||||
/*void sshot(char *visiblefile, char *scrollfile)
|
||||
{
|
||||
FILE *fp;
|
||||
int x,y;
|
||||
|
||||
fp = OpenGameFile(visiblefile, "wb");
|
||||
if (!fp) return;<
|
||||
|
||||
for(y=0;y<200;y++)
|
||||
for(x=0;x<320;x++)
|
||||
fputc(getpixel(x,y), fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
fp = OpenGameFile(scrollfile, "wb");
|
||||
if (!fp) return;
|
||||
|
||||
for(y=0;y<512;y++)
|
||||
for(x=0;x<512;x++)
|
||||
fputc(sb_getpixel(x,y), fp);
|
||||
|
||||
fclose(fp);
|
||||
}*/
|
||||
|
||||
void YourShipNeedsTheseParts(stCloneKeenPlus *pCKP)
|
||||
{
|
||||
int cp = 0;
|
||||
|
||||
@@ -130,7 +130,6 @@ void CSettings::loadDefaultGameCfg(stOption *Option)
|
||||
setOption(Option,OPT_ALLOWPKING, "pking", 1);
|
||||
setOption(Option,OPT_CHEATS, "allcheats", 0);
|
||||
setOption(Option,OPT_TWOBUTTON, "two-button-firing", 0);
|
||||
setOption(Option,OPT_KEYCARDSTACK, "keycard-stacking", 0);
|
||||
setOption(Option,OPT_ANALOGJOYSTICK, "analog-joystick", 1);
|
||||
setOption(Option,OPT_LVLREPLAYABILITY, "level replayability", 0);
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ extern std::string CONFIGFILENAME;
|
||||
enum e_OptionKeywords
|
||||
{ OPT_FULLYAUTOMATIC, OPT_SUPERPOGO,
|
||||
OPT_ALLOWPKING, OPT_CHEATS,
|
||||
OPT_TWOBUTTON, OPT_KEYCARDSTACK,
|
||||
OPT_ANALOGJOYSTICK, OPT_LVLREPLAYABILITY };
|
||||
OPT_TWOBUTTON, OPT_ANALOGJOYSTICK,
|
||||
OPT_LVLREPLAYABILITY };
|
||||
|
||||
#define NUM_OPTIONS 8
|
||||
#define NUM_OPTIONS 7
|
||||
|
||||
typedef struct stOption
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user