diff --git a/src/fileio/CExeFile.cpp b/src/fileio/CExeFile.cpp
index 4404ccbdf..b9e8c325e 100644
--- a/src/fileio/CExeFile.cpp
+++ b/src/fileio/CExeFile.cpp
@@ -17,7 +17,7 @@ using namespace std;
CExeFile::CExeFile(int episode, const std::string& datadirectory) {
m_episode = episode;
m_datadirectory = datadirectory;
- if(m_datadirectory != "") m_datadirectory += "/";
+ if( m_datadirectory != "" && *(m_datadirectory.end()) != '/') m_datadirectory += "/";
m_data = NULL;
}
diff --git a/src/menu.cpp b/src/menu.cpp
index 6bd427931..ed50b0bca 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -193,7 +193,7 @@ bool loadStartMenu(stCloneKeenPlus *pCKP)
fade.rate = FADE_NORM;
fade.mode = FADE_GO;
- if( GamesMenu->getSelection()+1 < pCKP->numGames )
+ if( GamesMenu->getSelection() < pCKP->numGames )
{
ret = true;
pCKP->Resources.GameSelected = GamesMenu->getSelection()+1;
diff --git a/src/sdl/sound/CSound.cpp b/src/sdl/sound/CSound.cpp
index 76b7ee196..2aad47373 100644
--- a/src/sdl/sound/CSound.cpp
+++ b/src/sdl/sound/CSound.cpp
@@ -328,7 +328,7 @@ bool CSound::loadSoundData(unsigned short Episode, const std::string& DataDirect
buf = "keen" + itoa(Episode) + ".exe";
g_pLogFile->ftextOut("sound_load_all(): \"%s\" was not found in the data directory. Looking for \"%s\" in \"%s\" and trying to extract this file
", soundfile.c_str(), buf.c_str(), formatPathString(path).c_str());
- extractOfExeFile(formatPathString(path), Episode);
+ extractOfExeFile(path, Episode);
}
else
fclose(p_file);
@@ -411,7 +411,6 @@ char CSound::extractOfExeFile(const std::string& inputpath, int episode)
int bit_count;
int pos, sounds_start, sounds_end, ret = 0;
std::string buffer;
- std::string inputfname;
pos = 0;
bit_count = 0;
@@ -431,19 +430,25 @@ char CSound::extractOfExeFile(const std::string& inputpath, int episode)
}
else
{
- g_pLogFile->ftextOut("Error: Unknown keen executable name: %s
", inputfname.c_str());
+ g_pLogFile->ftextOut("Error: Unknown episode: %d
", episode);
return 1;
}
- CExeFile *ExeFile = new CExeFile(episode, inputfname);
+ CExeFile *ExeFile = new CExeFile(episode, inputpath);
if(!ExeFile->readData()) ret = 1;
else
{
FILE *fout;
- if(!(fout = fopen(outputfname.c_str(),"wb"))) ret = 1;
+
+ buffer = "data/" + inputpath;
+ if( *(buffer.end()) != '/') buffer += "/";
+ buffer += outputfname;
+
+ if(!(fout = fopen(buffer.c_str(),"wb"))) ret = 1;
else
{
fwrite( ExeFile->getData()+sounds_start, 1, (sounds_end-sounds_start), fout);
+ g_pLogFile->ftextOut(GREEN,"Sounds extraction completed successfully
");
fclose(fout);
}
}