int handle()
        {
            CExeFile &ExeFile = gKeenFiles.exeFile;
            int version = ExeFile.getEXEVersion();
            unsigned char *p_exedata = ExeFile.getRawData();

            if( mEp == 1 && version == 134)
            {
                gLogging.ftextOut("This version of the game is not supported!<br>");
                return 0;
            }

            // Patch the EXE-File-Data directly in the memory.
            CPatcher Patcher(ExeFile, gpBehaviorEngine->mPatchFname);
            Patcher.process();

            mLoader.setPermilage(100);

            gTimer.setLPS(DEFAULT_LPS_VORTICON);

            gpBehaviorEngine->readTeleporterTable(p_exedata);

            if( (mFlags & LOADGFX) == LOADGFX )
            {
                // Decode the entire graphics for the game (EGALATCH, EGASPRIT, etc.)
                // This will also read the Tile-Properties
                CEGAGraphicsVort graphics(mEp, mDataPath);
                graphics.loadData(version, p_exedata);
                mLoader.setPermilage(400);
                mLoader.setStyle(PROGRESS_STYLE_BITMAP);
            }

            if( (mFlags & LOADSTR) == LOADSTR )
            {
                // load the strings.
                CMessages Messages(p_exedata, mEp, version);
                Messages.extractGlobalStrings();
                mLoader.setPermilage(500);
            }

            if( (mFlags & LOADSND) == LOADSND )
            {
                // Load the sound data
                setupAudio();
                mLoader.setPermilage(800);
            }

            gpBehaviorEngine->getPhysicsSettings().loadGameConstants(mEp, p_exedata);
            mLoader.setPermilage(900);

            // If there are patches left that must be apllied later, do it here!
            Patcher.postProcess();

            mLoader.setPermilage(1000);

            gEventManager.add(new FinishedLoadingResources());
            return 1;
        }
        int handle()
        {
            CExeFile &ExeFile = gKeenFiles.exeFile;

            mLoader.setPermilage(10);

            // Patch the EXE-File-Data directly in the memory.
            CPatcher Patcher(ExeFile, gpBehaviorEngine->mPatchFname);
            Patcher.process();

            mLoader.setPermilage(50);

            extractEmbeddedFilesIntoMemory(g_be_gamever_kdreamse113);

            gEventManager.add(new FinishedLoadingResources());

            return 1;
        }
Exemple #3
0
bool DreamsEngine::start()
{
    CExeFile &ExeFile = gKeenFiles.exeFile;

    //mLoader.setPermilage(10);

    // Patch the EXE-File-Data directly in the memory.
    CPatcher Patcher(ExeFile, gBehaviorEngine.mPatchFname);
    Patcher.process();

    //mLoader.setPermilage(50);

    extractEmbeddedFilesIntoMemory(g_be_gamever_kdreamse113);

    // Global for the legacy refkeen code.
    gDreamsEngine = this;    
    //gpRenderLock = SDL_CreateSemaphore(1);

    gKeenFiles.setupFilenames(7);

    setScreenMode(3);

    dreamsengine_datapath = const_cast<char*>(mDataPath.c_str());

    // This function extracts the embedded files. TODO: We should integrate that to our existing system
    // Load the Resources
    loadResources();

    //RefKeen_Patch_id_ca();
    //RefKeen_Patch_id_us();
    RefKeen_Patch_id_rf();
    setupObjOffset();

    mpScene.reset( new DreamsDosIntro );

    gGameStateChange = GSS_INTRO_TEXT;

    mpScene->start();

    return true;
}
///
// This is used for loading all the resources of the game the use has chosen.
// It loads graphics, sound and text into the memory
///
bool CGameLauncherMenu::loadResources( const std::string& DataDirectory, const int& Episode, const Uint8 flags )
{
	int version;
	unsigned char *p_exedata;
	unsigned char *p_exeheader;

	CExeFile &ExeFile = g_pBehaviorEngine->m_ExeFile;

    version = ExeFile.getEXEVersion();
	p_exedata = ExeFile.getRawData();
	p_exeheader = ExeFile.getHeaderData();

	g_pLogFile->ftextOut("Commander Keen Episode %d (Version %d.%d) was detected.<br>", Episode, version/100, version%100);
	if( Episode == 1 && version == 134) g_pLogFile->ftextOut("This version of the game is not supported!<br>");

	if(p_exeheader == NULL) {
		g_pLogFile->textOut(RED, "CGameControl::loadResources: Could not load data from the EXE File<br>");
		return false;
	}

	// Patch the EXE-File-Data directly in the memory.
	CPatcher Patcher(ExeFile, g_pBehaviorEngine->m_is_a_mod);
	Patcher.patchMemory();

	g_pBehaviorEngine->setEpisode(Episode);

	if( Episode == 1 || Episode == 2 || Episode == 3 ) // Vorticon resources
	{
		g_pBehaviorEngine->readTeleporterTable(p_exedata);

		if( (flags & LOADGFX) == LOADGFX )
		{
			// Decode the entire graphics for the game (EGALATCH, EGASPRIT, etc.)
			// This will also read the Tile-Properties
			mp_EGAGraphics.tryDeleteData(); // except for the first start of a game this always happens
			mp_EGAGraphics = new vorticon::CEGAGraphicsVort(Episode, DataDirectory);
			if(!mp_EGAGraphics.get())
				return false;

			mp_EGAGraphics->loadData( version, p_exedata );
		}

		if( (flags & LOADSTR) == LOADSTR )
		{
			// load the strings.
			CMessages Messages(p_exedata, Episode, version);
			Messages.extractGlobalStrings();
		}

		if( (flags & LOADSND) == LOADSND )
		{
			// Load the sound data
			g_pSound->loadSoundData(ExeFile);
		}

		g_pBehaviorEngine->getPhysicsSettings().loadGameConstants(Episode, p_exedata);

		return true;
	}
	else if( Episode == 4 || Episode == 5 || Episode == 6 ) // Galaxy resources
	{
		// TODO: Lots of coding
		if( (flags & LOADGFX) == LOADGFX )
		{
			// Decode the entire graphics for the game (Only EGAGRAPH.CK?)
			mp_EGAGraphics.tryDeleteData();

			mp_EGAGraphics = new galaxy::CEGAGraphicsGalaxy(ExeFile); // Path is relative to the data directory
			if(!mp_EGAGraphics.get())
				return false;

			mp_EGAGraphics->loadData();
		}

		if( (flags & LOADSTR) == LOADSTR )
		{
			// load the strings.
			CMessages Messages(p_exedata, Episode, version);
			Messages.extractGlobalStrings();
		}

		if( (flags & LOADSND) == LOADSND )
		{
			// Load the sound data
			g_pSound->loadSoundData(ExeFile);
		}
	}
	return true;
}