Commit 54ba75f2 authored by Gerhard Stein's avatar Gerhard Stein

Music load fixes

parent a703fc06
Subproject commit a00c5b5ee25e6282de98cce24bd574c9531deeeb
Subproject commit 56b1530f51d3a739fbdbf172bcddffd7ff8d6b38
......@@ -90,7 +90,6 @@ bool CGameLauncher::setupMenu()
mLauncherDialog.initEmptyBackground();
mSelection = -1;
bool gamesDetected = false;
// TODO: Put that scanning into a separate so we can show a loading menu
// Scan for games...
......@@ -102,12 +101,16 @@ bool CGameLauncher::setupMenu()
// Process any custom labels
getLabels();
bool gamesDetected = false;
// Scan VFS DIR_ROOT for exe's
gamesDetected |= scanExecutables(DIR_ROOT);
mGameScanner.setPermilage(100);
// Recursivly scan into DIR_GAMES subdir's for exe's
gamesDetected |= scanSubDirectories(DIR_GAMES, DEPTH_MAX_GAMES, 200, 900);
gamesDetected |= scanSubDirectories(DIR_GAMES,
DEPTH_MAX_GAMES,
200, 900);
mpGameSelecList = new CGUITextSelectionList();
......@@ -263,7 +266,8 @@ bool CGameLauncher::scanSubDirectories(const std::string& path,
std::set<std::string> dirs;
FileListAdder fileListAdder;
GetFileList(dirs, fileListAdder, path, false, FM_DIR);
GetFileList(dirs, fileListAdder,
path, false, FM_DIR);
size_t interval = dirs.size();
......@@ -278,9 +282,9 @@ bool CGameLauncher::scanSubDirectories(const std::string& path,
mGameScanner.setPermilage(startPermil);
for(std::set<std::string>::iterator i = dirs.begin(); i != dirs.end(); ++i)
for( const auto &subdir : dirs )
{
std::string newpath = path + '/' + *i;
std::string newpath = JoinPaths(path , subdir);
gamesDetected |= scanExecutables(newpath);
......@@ -289,7 +293,9 @@ bool CGameLauncher::scanSubDirectories(const std::string& path,
lastPermil = endPermil;
if(maxdepth > 1 && scanSubDirectories(newpath, maxdepth - 1, permil, lastPermil))
{
gamesDetected = true;
}
permil = lastPermil;
mGameScanner.setPermilage(permil);
......@@ -397,6 +403,9 @@ bool CGameLauncher::scanExecutables(const std::string& path)
bool CGameLauncher::start()
{
// CRC init when Launcher starts.
crc32_init();
// Here it always makes sense to have the mouse cursor active
SDL_ShowCursor(SDL_ENABLE);
......
......@@ -81,7 +81,7 @@ bool loadLevelMusic(const int level)
int track = gMusicPlayer.readTrackNofromMusicTable(path, levelname);
// Does the file provide some number as track number to use.
if(track < -1)
if(track <= -1)
{
track = 0;
byte* rawDataPtr = ExeFile.getRawData();
......
......@@ -83,13 +83,10 @@ void CExeFile::dumpDataFile(const std::string& filename)
bool CExeFile::readData(const unsigned int episode,
const std::string& datadirectory)
{
// TODO: It would be nice to gather a list of executables and by scanning it decide which episode will be played.
crc32_init();
bool demo = false;
std::string filename = datadirectory + "/keen" + itoa(episode) + ".exe";
std::string filename = JoinPaths(datadirectory,
"keen" + itoa(episode) + ".exe" );
std::ifstream File;
OpenGameFileR(File, filename, std::ios::binary);
......@@ -98,7 +95,8 @@ bool CExeFile::readData(const unsigned int episode,
if(!File)
{
// try another filename (Used in Episode 4-6)
filename = datadirectory + "/keen" + itoa(episode) + "e.exe";
filename = JoinPaths(datadirectory,
"keen" + itoa(episode) + "e.exe");
OpenGameFileR(File, filename, std::ios::binary);
}
......@@ -106,7 +104,8 @@ bool CExeFile::readData(const unsigned int episode,
if(!File)
{
// try another filename (Used in Episode 4-6) for demo versions
filename = datadirectory + "/k" + itoa(episode) + "demo.exe";
filename = JoinPaths(datadirectory,
"k" + itoa(episode) + "demo.exe");
OpenGameFileR(File, filename, std::ios::binary);
if(File)
demo = true;
......@@ -117,17 +116,21 @@ bool CExeFile::readData(const unsigned int episode,
if(!File)
{
// try another filename (Used in Episode 4-6) for demo versions
filename = datadirectory + "/kdreams.exe";
filename = JoinPaths(datadirectory, "kdreams.exe");
OpenGameFileR(File, filename, std::ios::binary);
// This is only for Keen Dreams so it has to be 7!
if(episode != 7)
{
return false;
}
}
// If we still have no file found, the directory with the game cannot be used at all.
if(!File)
{
return false;
}
m_filename = filename;
m_episode = episode;
......@@ -584,7 +587,8 @@ bool CExeFile::readMusicHedInternal(RingBuffer<IMFChunkType> &imfData,
for( size_t i=0 ; i<number_of_audiorecs-music_start ; i++ )
{
musiched.push_back(*audiohedptr);
const uint32_t record = *audiohedptr;
musiched.push_back(record);
audiohedptr++;
}
......@@ -701,6 +705,8 @@ bool CExeFile::loadMusicTrack(RingBuffer<IMFChunkType> &imfData,
std::vector<uint8_t> AudioCompFileData;
std::vector<uint32_t> musiched;
assert(track >= 0);
if( readCompressedAudiointoMemory(imfData, musiched, AudioCompFileData) )
{
unpackAudioInterval(imfData,
......
......@@ -10,23 +10,25 @@
#endif
#define QUOTIENT 0x04C11DB7
unsigned int crctab[256];
static unsigned int crctab[256];
void crc32_init(void)
void crc32_init()
{
int i,j;
unsigned int crc;
for (i = 0; i < 256; i++)
for (unsigned int i = 0; i < 256; i++)
{
crc = i << 24;
for (j = 0; j < 8; j++)
for (unsigned int j = 0; j < 8; j++)
{
if (crc & 0x80000000)
{
crc = (crc << 1) ^ QUOTIENT;
}
else
{
crc = crc << 1;
}
}
crctab[i] = crc; // may need to account for big endian
}
......
void crc32_init(void);
void crc32_init();
unsigned int getcrc32(unsigned char *data, int len);
......@@ -21,9 +21,16 @@
bool CMusic::loadTrack(const int track)
{
gLogging.textOut("Load track number " + itoa(track) + "");
if(track < 0)
{
gLogging.textOut("The requested Track-Number does not make sense. Music will not be loaded here!");
return false;
}
gSound.pauseAudio();
gLogging.textOut("Load track number " + itoa(track) + "");
if(loadIMFTrack(track))
{
......
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