Commit cbc15b84 authored by Gerhard Stein's avatar Gerhard Stein

New code for python

parent b4301098
Subproject commit ddb78481b822c0d8f4eab47fa0b197a24643573b
Subproject commit d6fd2b5407e9abcc5a8e4ed1d9c754d9b2d4338d
......@@ -36,25 +36,36 @@ bool KeenEngine::start()
CExeFile &ExeFile = gKeenFiles.exeFile;
version = ExeFile.getEXEVersion();
if(!ExeFile.isPythonScript())
{
version = ExeFile.getEXEVersion();
gLogging.ftextOut("Commander Keen Episode %d (Version %d.%d) was detected.<br>", mEp, version/100, version%100);
gLogging.ftextOut("Commander Keen Episode %d (Version %d.%d) was detected.<br>", mEp, version/100, version%100);
if( ExeFile.getHeaderData() == nullptr)
{
gLogging.textOut(FONTCOLORS::RED, "KeenEngine::loadResources: Could not load data from the EXE File<br>");
gEventManager.add(new GMSwitchToGameLauncher() );
return false;
}
if( ExeFile.getHeaderData() == nullptr)
gBehaviorEngine.setDemo(ExeFile.isDemo());
}
else
{
gLogging.textOut(FONTCOLORS::RED, "KeenEngine::loadResources: Could not load data from the EXE File<br>");
gEventManager.add(new GMSwitchToGameLauncher() );
return false;
gLogging << "Commander Keen python based executable detected!<br>";
}
gKeenFiles.setupFilenames(mEp);
gBehaviorEngine.setEpisode(mEp);
gBehaviorEngine.setDemo(ExeFile.isDemo());
// Load the Resources
loadResources( LOADALL );
if( !loadResources( LOADALL ) )
{
return false;
}
return true;
}
......
......@@ -174,7 +174,7 @@ bool GalaxyEngine::loadResources( const Uint8 flags )
mFlags(flags),
mLoader(loader) {}
int handle()
int handleExeFile()
{
CExeFile &ExeFile = gKeenFiles.exeFile;
int version = ExeFile.getEXEVersion();
......@@ -216,7 +216,7 @@ bool GalaxyEngine::loadResources( const Uint8 flags )
{
gLogging.ftextOut("Loading audio... <br>");
// Load the sound data
// Load the sound data
setupAudio();
mLoader.setPermilage(900);
......@@ -240,6 +240,74 @@ bool GalaxyEngine::loadResources( const Uint8 flags )
return 1;
}
int handlePythonFile()
{
CExeFile &ExeFile = gKeenFiles.exeFile;
const int Episode = ExeFile.getEpisode();
mLoader.setPermilage(50);
if( (mFlags & LOADGFX) == LOADGFX )
{
// Decode the entire graphics for the game (Only EGAGRAPH.CK?)
CEGAGraphicsGalaxy graphics(ExeFile);
if( !graphics.loadData() )
{
gLogging << "Sorry, this graphics file is invalid! Quitting...";
gEventManager.add( new GMQuit() );
return 0;
}
mLoader.setPermilage(400);
}
if( (mFlags & LOADSTR) == LOADSTR )
{
// load the strings.
/*CMessages Messages(p_exedata, Episode, ExeFile.isDemo(), version);
Messages.extractGlobalStrings();
mLoader.setPermilage(450);*/
}
if( (mFlags & LOADSND) == LOADSND )
{
gLogging.ftextOut("Loading audio... <br>");
// Load the sound data
setupAudio();
mLoader.setPermilage(900);
gLogging.ftextOut("Done loading audio.<br>");
}
gLogging.ftextOut("Loading game constants...<br>");
/*
gBehaviorEngine.getPhysicsSettings().loadGameConstants(Episode, p_exedata);
*/
gLogging.ftextOut("Done loading the resources...<br>");
mLoader.setPermilage(1000);
gEventManager.add(new FinishedLoadingResources());
return 1;
}
int handle()
{
if(gKeenFiles.exeFile.isPythonScript())
{
return handlePythonFile();
}
else
{
return handleExeFile();
}
}
};
mEngineLoader.RunLoadActionBackground(new GalaxyDataLoad(flags, mEngineLoader));
......
......@@ -630,9 +630,13 @@ bool CEGAGraphicsGalaxy::begin()
byte *dataPtr = reinterpret_cast<byte*>(mExefile.getHeaderData());
//if(m_episode == 7) exeheaderlen = HEADERLEN_KDREAMS;
if(!mExefile.readExeImageSize( dataPtr, &exeimglen, &exeheaderlen))
return false;
if( !mExefile.isPythonScript() )
{
//if(m_episode == 7) exeheaderlen = HEADERLEN_KDREAMS;
if(!mExefile.readExeImageSize( dataPtr, &exeimglen, &exeheaderlen))
return false;
}
std::string filename;
......
......@@ -82,6 +82,10 @@ class CExeFile {
bool loadMusicTrack(RingBuffer<IMFChunkType> &imfData, const int track) const;
bool isPythonScript() const
{ return mIsPythonScript; }
private:
......@@ -103,6 +107,7 @@ private:
std::vector<uint8_t> &AudioCompFileData) const;
struct EXE_HEADER
{
unsigned short mzid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment