HE demos sometimes call music tracks that don't exist.

svn-id: r18080
This commit is contained in:
Travis Howell 2005-05-13 08:45:42 +00:00
parent d987a58529
commit 739e0640ad
3 changed files with 12 additions and 6 deletions

View File

@ -1760,7 +1760,10 @@ int ScummEngine_v72he::getSoundResourceSize(int id) {
int offs, size;
if (id > _numSounds) {
_sound->getHEMusicDetails(id, offs, size);
if (!_sound->getHEMusicDetails(id, offs, size)) {
debug(0, "getSoundResourceSize: musicID %d not found", id);
return 0;
}
} else {
ptr = getResourceAddress(rtSound, id);
if (!ptr)

View File

@ -202,18 +202,18 @@ void Sound::setupHEMusicFile() {
musicFile.close();
}
void Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
bool Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
int i;
for (i = 0; i < _heMusicTracks; i++) {
if (_heMusic[i].id == id) {
musicOffs = _heMusic[i].offset;
musicSize = _heMusic[i].size;
return;
return 1;
}
}
error("getHEMusicDetails: musicID %d not found", id);
return 0;
}
void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
@ -250,8 +250,11 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
warning("playSound: Can't open music file %s", buf);
return;
}
if (!getHEMusicDetails(soundID, music_offs, size)) {
debug(0, "playSound: musicID %d not found", soundID);
return;
}
getHEMusicDetails(soundID, music_offs, size);
musicFile.seek(music_offs, SEEK_SET);
ptr = (byte *)malloc(size);
musicFile.read(ptr, size);

View File

@ -133,7 +133,7 @@ public:
int getCurrentCDSound() const { return _currentCDSound; }
void setupHEMusicFile();
void getHEMusicDetails(int id, int &musicOffs, int &musicSize);
bool getHEMusicDetails(int id, int &musicOffs, int &musicSize);
// Used by the save/load system:
const SaveLoadEntry *getSaveLoadEntries();