diff options
author | Travis Howell | 2006-08-27 05:02:48 +0000 |
---|---|---|
committer | Travis Howell | 2006-08-27 05:02:48 +0000 |
commit | 57bdecb4c6dc6f35a69120201e0b0f2654ac4c65 (patch) | |
tree | c58f07364ae5ba3aa6b5a36d5c7b12eac3684752 /engines | |
parent | b964c889ed96fede5137fb065ef607126ca1d90a (diff) | |
download | scummvm-rg350-57bdecb4c6dc6f35a69120201e0b0f2654ac4c65.tar.gz scummvm-rg350-57bdecb4c6dc6f35a69120201e0b0f2654ac4c65.tar.bz2 scummvm-rg350-57bdecb4c6dc6f35a69120201e0b0f2654ac4c65.zip |
Update error messages and always report an error if data file load fails
svn-id: r23772
Diffstat (limited to 'engines')
-rw-r--r-- | engines/simon/midi.cpp | 23 | ||||
-rw-r--r-- | engines/simon/midiparser_s1d.cpp | 10 | ||||
-rw-r--r-- | engines/simon/res.cpp | 49 | ||||
-rw-r--r-- | engines/simon/simon.cpp | 27 | ||||
-rw-r--r-- | engines/simon/sound.cpp | 27 |
5 files changed, 58 insertions, 78 deletions
diff --git a/engines/simon/midi.cpp b/engines/simon/midi.cpp index f139f1fa2e..2d85983ad4 100644 --- a/engines/simon/midi.cpp +++ b/engines/simon/midi.cpp @@ -522,26 +522,21 @@ void MidiPlayer::loadXMIDI(Common::File *in, bool sfx) { in->read(&buf[2], 2); } if (memcmp(buf, "CAT ", 4)) { - warning("Could not find 'CAT ' tag to determine resource size"); - return; + error("Could not find 'CAT ' tag to determine resource size"); } size += 4 + in->readUint32BE(); in->seek(pos, 0); p->data = (byte *)calloc(size, 1); in->read(p->data, size); } else { - warning("Expected 'FORM' tag but found '%c%c%c%c' instead", buf[0], buf[1], buf[2], buf[3]); - return; + error("Expected 'FORM' tag but found '%c%c%c%c' instead", buf[0], buf[1], buf[2], buf[3]); } MidiParser *parser = MidiParser::createParser_XMIDI(); parser->setMidiDriver(this); parser->setTimerRate(_driver->getBaseTempo()); - if (!parser->loadMusic(p->data, size)) { - warning("Error reading track"); - delete parser; - parser = 0; - } + if (!parser->loadMusic(p->data, size)) + error("Error reading track"); if (!sfx) { _currentTrack = 255; @@ -557,8 +552,7 @@ void MidiPlayer::loadS1D(Common::File *in, bool sfx) { uint16 size = in->readUint16LE(); if (size != in->size() - 2) { - warning("Size mismatch in simon1demo MUS file (%ld versus reported %d)", (long)in->size() - 2, (int)size); - return; + error("Size mismatch in simon1demo MUS file (%ld versus reported %d)", (long)in->size() - 2, (int)size); } p->data = (byte *)calloc(size, 1); @@ -567,11 +561,8 @@ void MidiPlayer::loadS1D(Common::File *in, bool sfx) { MidiParser *parser = MidiParser_createS1D(); parser->setMidiDriver(this); parser->setTimerRate(_driver->getBaseTempo()); - if (!parser->loadMusic(p->data, size)) { - warning("Error reading track"); - delete parser; - parser = 0; - } + if (!parser->loadMusic(p->data, size)) + error("Error reading track"); if (!sfx) { _currentTrack = 255; diff --git a/engines/simon/midiparser_s1d.cpp b/engines/simon/midiparser_s1d.cpp index 95a8431a6a..92e4146a9b 100644 --- a/engines/simon/midiparser_s1d.cpp +++ b/engines/simon/midiparser_s1d.cpp @@ -115,9 +115,7 @@ void MidiParser_S1D::parseNextEvent(EventInfo &info) { // OTherwise fall through to default. default: - printf ("MidiParser_S1D: Warning! Unexpected byte 0x%02X found!\n", (int) info.event); - _abort_parse = true; - _position._play_pos = 0; + error("MidiParser_S1D: Unexpected byte 0x%02X found!\n", (int) info.event); } } @@ -125,10 +123,8 @@ bool MidiParser_S1D::loadMusic(byte *data, uint32 size) { unloadMusic(); byte *pos = data; - if (*(pos++) != 0xFC) { - printf ("Warning: Expected 0xFC header but found 0x%02X instead\n", (int) *pos); - return false; - } + if (*(pos++) != 0xFC) + error("Expected 0xFC header but found 0x%02X instead\n", (int) *pos); // The next 3 bytes MIGHT be tempo, but we skip them and use the default. // setTempo (*(pos++) | (*(pos++) << 8) | (*(pos++) << 16)); diff --git a/engines/simon/res.cpp b/engines/simon/res.cpp index 332a5e2676..914f62134d 100644 --- a/engines/simon/res.cpp +++ b/engines/simon/res.cpp @@ -151,23 +151,23 @@ void SimonEngine::decompressData(const char *srcName, byte *dst, uint32 offset, File in; in.open(srcName); if (in.isOpen() == false) - error("decompressData: can't open %s", srcName); + error("decompressData: Can't load %s", srcName); in.seek(offset, SEEK_SET); if (srcSize != dstSize) { byte *srcBuffer = (byte *)malloc(srcSize); if (in.read(srcBuffer, srcSize) != srcSize) - error("decompressData: read failed"); + error("decompressData: Read failed"); unsigned long decompressedSize = dstSize; int result = uncompress(dst, &decompressedSize, srcBuffer, srcSize); if (result != Z_OK) - error("decompressData() Zlib uncompress error"); + error("decompressData: Zlib uncompress error"); free(srcBuffer); } else { if (in.read(dst, dstSize) != dstSize) - error("decompressData: read failed"); + error("decompressData: Read failed"); } in.close(); #else @@ -183,7 +183,7 @@ void SimonEngine::loadOffsets(const char *filename, int number, uint32 &file, ui /* read offsets from index */ in.open(filename); if (in.isOpen() == false) { - error("Can't open index file '%s'", filename); + error("loadOffsets: Can't load index file '%s'", filename); } in.seek(number * offsSize, SEEK_SET); @@ -208,11 +208,11 @@ int SimonEngine::allocGamePcVars(File *in) { item_array_size += 2; if (version != 0x80) - error("Not a runtime database"); + error("allocGamePcVars: Not a runtime database"); _itemArrayPtr = (Item **)calloc(item_array_size, sizeof(Item *)); if (_itemArrayPtr == NULL) - error("Out of memory for Item array"); + error("allocGamePcVars: Out of memory for Item array"); _itemArraySize = item_array_size; _itemArrayInited = item_array_inited; @@ -236,7 +236,7 @@ void SimonEngine::loadGamePcFile() { /* read main gamepc file */ in.open(getFileName(GAME_BASEFILE)); if (in.isOpen() == false) { - error("Can't open gamepc file '%s'", getFileName(GAME_BASEFILE)); + error("loadGamePcFile: Can't load gamepc file '%s'", getFileName(GAME_BASEFILE)); } num_inited_objects = allocGamePcVars(&in); @@ -255,14 +255,14 @@ void SimonEngine::loadGamePcFile() { /* Read list of TABLE resources */ in.open(getFileName(GAME_TBLFILE)); if (in.isOpen() == false) { - error("Can't open table resources file '%s'", getFileName(GAME_TBLFILE)); + error("loadGamePcFile: Can't load table resources file '%s'", getFileName(GAME_TBLFILE)); } file_size = in.size(); _tblList = (byte *)malloc(file_size); if (_tblList == NULL) - error("Out of memory for strip table list"); + error("loadGamePcFile: Out of memory for strip table list"); in.read(_tblList, file_size); in.close(); @@ -277,12 +277,12 @@ void SimonEngine::loadGamePcFile() { /* Read list of TEXT resources */ in.open(getFileName(GAME_STRFILE)); if (in.isOpen() == false) - error("Can't open text resources file '%s'", getFileName(GAME_STRFILE)); + error("loadGamePcFile: Can't load text resources file '%s'", getFileName(GAME_STRFILE)); file_size = in.size(); _strippedTxtMem = (byte *)malloc(file_size); if (_strippedTxtMem == NULL) - error("Out of memory for strip text list"); + error("loadGamePcFile: Out of memory for strip text list"); in.read(_strippedTxtMem, file_size); in.close(); } @@ -291,7 +291,7 @@ void SimonEngine::readGamePcText(Common::File *in) { _textSize = in->readUint32BE(); _textMem = (byte *)malloc(_textSize); if (_textMem == NULL) - error("Out of text memory"); + error("readGamePcText: Out of text memory"); in->read(_textMem, _textSize); @@ -463,7 +463,7 @@ byte *SimonEngine::readSingleOpcode(Common::File *in, byte *ptr) { *ptr++ = val & 255; break; default: - error("Bad cmd table entry %c", l); + error("readSingleOpcode: Bad cmd table entry %c", l); } } } @@ -474,13 +474,13 @@ void SimonEngine::openGameFile() { _gameFile->open(getFileName(GAME_GMEFILE)); if (_gameFile->isOpen() == false) - error("Can't open game file '%s'", getFileName(GAME_GMEFILE)); + error("openGameFile: Can't load game file '%s'", getFileName(GAME_GMEFILE)); uint32 size = _gameFile->readUint32LE(); _gameOffsetsPtr = (uint32 *)malloc(size); if (_gameOffsetsPtr == NULL) - error("out of memory, game offsets"); + error("openGameFile: Out of memory, game offsets"); readGameFile(_gameOffsetsPtr, 0, size); #if defined(SCUMM_BIG_ENDIAN) @@ -493,7 +493,7 @@ void SimonEngine::openGameFile() { void SimonEngine::readGameFile(void *dst, uint32 offs, uint32 size) { _gameFile->seek(offs, SEEK_SET); if (_gameFile->read(dst, size) != size) - error("readGameFile(%d,%d) read failed", offs, size); + error("readGameFile: Read failed (%d,%d)", offs, size); } // Thanks to Stuart Caie for providing the original @@ -635,18 +635,18 @@ void SimonEngine::loadSimonVGAFile(uint vga_id) { in.open(filename); if (in.isOpen() == false) - error("loadSimonVGAFile: can't open %s", filename); + error("loadSimonVGAFile: Can't load %s", filename); size = in.size(); if (getFeatures() & GF_CRUNCHED) { byte *srcBuffer = (byte *)malloc(size); if (in.read(srcBuffer, size) != size) - error("loadSimonVGAFile: read failed"); + error("loadSimonVGAFile: Read failed"); decrunchFile(srcBuffer, _vgaBufferPointers[11].vgaFile2, size); free(srcBuffer); } else { if (in.read(_vgaBufferPointers[11].vgaFile2, size) != size) - error("loadSimonVGAFile: read failed"); + error("loadSimonVGAFile: Read failed"); } in.close(); } else { @@ -701,14 +701,14 @@ byte *SimonEngine::loadVGAFile(uint id, uint type, uint32 &dstSize) { if (type == 3) return NULL; else - error("loadVGAFile: can't open %s", filename); + error("loadVGAFile: Can't load %s", filename); } dstSize = srcSize = in.size(); if (getFeatures() & GF_CRUNCHED) { byte *srcBuffer = (byte *)malloc(srcSize); if (in.read(srcBuffer, srcSize) != srcSize) - error("loadVGAFile: read failed"); + error("loadVGAFile: Read failed"); dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4); dst = allocBlock (dstSize + extraBuffer); @@ -717,7 +717,7 @@ byte *SimonEngine::loadVGAFile(uint id, uint type, uint32 &dstSize) { } else { dst = allocBlock(dstSize + extraBuffer); if (in.read(dst, dstSize) != dstSize) - error("loadVGAFile: read failed"); + error("loadVGAFile: Read failed"); } in.close(); } else { @@ -753,6 +753,9 @@ void SimonEngine::loadSound(uint sound, int pan, int vol, uint type) { dst = (byte *)malloc(dstSize); decompressData(filename, dst, offset, srcSize, dstSize); } else { + if (!_curSfxFile) + error("loadSound: Can't load sound data file '%d3.VGA'", _zoneNumber); + dst = _curSfxFile + READ_LE_UINT32(_curSfxFile + sound * 4); } diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp index d54087b9ca..2e0c2712f3 100644 --- a/engines/simon/simon.cpp +++ b/engines/simon/simon.cpp @@ -657,7 +657,7 @@ byte *SimonEngine::allocateItem(uint size) { _itemHeapCurPos += size; if (_itemHeapCurPos > _itemHeapSize) - error("Itemheap overflow"); + error("allocateItem: Itemheap overflow"); return org; } @@ -683,7 +683,7 @@ void SimonEngine::createPlayer() { child = (Child *)allocateChildBlock(_currentPlayer, 3, sizeof(Child)); if (child == NULL) - error("player create failure"); + error("createPlayer: player create failure"); setUserFlag(_currentPlayer, 0, 0); } @@ -842,7 +842,7 @@ uint SimonEngine::getNextVarContents() { uint SimonEngine::readVariable(uint variable) { if (variable >= 255) - error("Variable %d out of range in read", variable); + error("readVariable: Variable %d out of range", variable); if (getGameType() == GType_FF) { if (getBitFlag(83)) @@ -860,7 +860,7 @@ void SimonEngine::writeNextVarContents(uint16 contents) { void SimonEngine::writeVariable(uint variable, uint16 contents) { if (variable >= 256) - error("Variable %d out of range in write", variable); + error("writeVariable: Variable %d out of range", variable); if (getGameType() == GType_FF && getBitFlag(83)) _variableArray2[variable] = contents; @@ -872,7 +872,7 @@ void SimonEngine::setItemParent(Item *item, Item *parent) { Item *old_parent = derefItem(item->parent); if (item == parent) - error("Trying to set item as its own parent"); + error("setItemParent: Trying to set item as its own parent"); // unlink it if it has a parent if (old_parent) @@ -1261,7 +1261,7 @@ TextLocation *SimonEngine::getTextLocation(uint a) { case 102: return &_textLocation4; default: - error("text, invalid value %d", a); + error("getTextLocation: Invalid text location %d", a); } return NULL; } @@ -2133,10 +2133,9 @@ void SimonEngine::loadMusic(uint music) { File f; sprintf(filename, "MOD%d.MUS", music); f.open(filename); - if (f.isOpen() == false) { - warning("Can't load music from '%s'", filename); - return; - } + if (f.isOpen() == false) + error("loadMusic: Can't load music from '%s'", filename); + if (getGameId() == GID_SIMON1DEMO) midi.loadS1D (&f); else @@ -2158,15 +2157,13 @@ void SimonEngine::playSting(uint a) { sprintf(filename, "STINGS%i.MUS", _soundFileId); mus_file.open(filename); - if (!mus_file.isOpen()) { - warning("Can't load sound effect from '%s'", filename); - return; - } + if (!mus_file.isOpen()) + error("playSting: Can't load sound effect from '%s'", filename); mus_file.seek(a * 2, SEEK_SET); mus_offset = mus_file.readUint16LE(); if (mus_file.ioFailed()) - error("Can't read sting %d offset", a); + error("playSting: Can't read sting %d offset", a); mus_file.seek(mus_offset, SEEK_SET); midi.loadSMF(&mus_file, a, true); diff --git a/engines/simon/sound.cpp b/engines/simon/sound.cpp index a49ac95433..80099aae9b 100644 --- a/engines/simon/sound.cpp +++ b/engines/simon/sound.cpp @@ -100,7 +100,7 @@ BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 base, bool bigendia _file->seek(base, SEEK_SET); if (_file->read(_offsets, size) != size) - error("Can't read offsets"); + error("BaseSound: Can't read offsets"); for (uint i = 0; i < res; i++) { #if defined(SCUMM_BIG_ENDIAN) @@ -137,9 +137,8 @@ void WavSound::playSound(uint sound, Audio::SoundHandle *handle, byte flags) { byte wavFlags; int size, rate; - if (!Audio::loadWAVFromStream(*_file, size, rate, wavFlags)) { + if (!Audio::loadWAVFromStream(*_file, size, rate, wavFlags)) error("playSound: Not a valid WAV file"); - } flags |= wavFlags; @@ -429,8 +428,7 @@ void Sound::readSfxFile(const char *filename) { if (file->isOpen() == false) { if (atoi(filename + 6) != 1 && atoi(filename + 6) != 30) - warning("readSfxFile: Can't load sfx file %s", filename); - return; + error("readSfxFile: Can't load sfx file %s", filename); } delete _effects; @@ -455,10 +453,8 @@ void Sound::readVoiceFile(const char *filename) { File *file = new File(); file->open(filename); - if (file->isOpen() == false) { - warning("readVoiceFile: Can't load voice file %s", filename); - return; - } + if (file->isOpen() == false) + error("readVoiceFile: Can't load voice file %s", filename); delete _voice; _voice = new RawSound(_mixer, file, 0, SOUND_BIG_ENDIAN); @@ -474,10 +470,9 @@ void Sound::playVoice(uint sound) { sprintf(filename, "voices%d.dat", _filenums[sound]); File *file = new File(); file->open(filename); - if (file->isOpen() == false) { - warning("playVoice: Can't load voice file %s", filename); - return; - } + if (file->isOpen() == false) + error("playVoice: Can't load voice file %s", filename); + delete _voice; _voice = new WavSound(_mixer, file, _offsets); } @@ -595,9 +590,8 @@ void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint soun int size = READ_LE_UINT32(soundData + 4); Common::MemoryReadStream stream(soundData, size); - if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) { + if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) error("playSoundData: Not a valid WAV data"); - } // The Feeble Files originally used DirectSound, which specifies volume // and panning differently than ScummVM does, using a logarithmic scale @@ -699,8 +693,7 @@ void Sound::switchVoiceFile(const GameSpecificSettings *gss, uint disc) { sprintf(filename, "%s%d.wav", gss->speech_filename, disc); file->open(filename); if (file->isOpen() == false) { - warning("switchVoiceFile: Can't load voice file %s", filename); - return; + error("switchVoiceFile: Can't load voice file %s", filename); } _hasVoiceFile = true; _voice = new WavSound(_mixer, file); |