diff options
author | Travis Howell | 2003-01-03 12:33:53 +0000 |
---|---|---|
committer | Travis Howell | 2003-01-03 12:33:53 +0000 |
commit | 5111eede5e768c9f0edde184c4bbc87ba3bc8463 (patch) | |
tree | d15f20521a96e4e47d8a8f19f5093f6884be0528 | |
parent | 3a4782f16656c180b48be4afa1270a7ec351ed72 (diff) | |
download | scummvm-rg350-5111eede5e768c9f0edde184c4bbc87ba3bc8463.tar.gz scummvm-rg350-5111eede5e768c9f0edde184c4bbc87ba3bc8463.tar.bz2 scummvm-rg350-5111eede5e768c9f0edde184c4bbc87ba3bc8463.zip |
Don't crash if sound effect file doesn't exist
svn-id: r6327
-rw-r--r-- | simon/res.cpp | 4 | ||||
-rw-r--r-- | simon/simon.cpp | 13 | ||||
-rw-r--r-- | simon/simon.h | 4 |
3 files changed, 12 insertions, 9 deletions
diff --git a/simon/res.cpp b/simon/res.cpp index 5499da7128..f6ccae921d 100644 --- a/simon/res.cpp +++ b/simon/res.cpp @@ -94,7 +94,7 @@ static const char *const opcode_arg_table_simon2dos[256] = { " ", " ", "BT ", " ", "B " }; -bool SimonState::loadGamePcFile(const char *filename) +void SimonState::loadGamePcFile(const char *filename) { File * in = new File(); int num_inited_objects; @@ -159,8 +159,6 @@ bool SimonState::loadGamePcFile(const char *filename) error("Out of memory for strip text list"); in->read(_stripped_txt_mem, file_size); in->close(); - - return true; } void SimonState::readGamePcText(File *in) diff --git a/simon/simon.cpp b/simon/simon.cpp index b91b907f0a..16ad0fb352 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -828,7 +828,7 @@ void SimonState::loadTablesIntoMem(uint subr_id) warning("loadTablesIntoMem: didn't find %d", subr_id); } -void SimonState::readSting(uint a) +bool SimonState::readSting(uint a) { char filename[11]; uint16 size; @@ -839,8 +839,10 @@ void SimonState::readSting(uint a) _mus_file->open(filename, _gameDataPath); - if (!_mus_file->isOpen()) - return; + if (!_mus_file->isOpen()) { + warning("Can't load sound effect from '%s'", filename); + return false; + } size = _mus_file->readUint16LE(); @@ -850,6 +852,8 @@ void SimonState::readSting(uint a) if (_mus_file->read(_mus_offsets, size) != size) error("Cannot read offsets"); + + return true; } void SimonState::playSting(uint a) @@ -857,7 +861,8 @@ void SimonState::playSting(uint a) if (!midi._midi_sfx_toggle) return; - readSting(_midi_sfx); + if (!readSting(_midi_sfx)) + return; midi.shutdown(); _mus_file->seek(_mus_offsets[a], SEEK_SET); diff --git a/simon/simon.h b/simon/simon.h index aa488a407d..1603a04475 100644 --- a/simon/simon.h +++ b/simon/simon.h @@ -103,7 +103,7 @@ public: File *_mus_file; uint16 *_mus_offsets; - void SimonState::readSting(uint a); + bool SimonState::readSting(uint a); void SimonState::playSting(uint a); byte *_vc_ptr; /* video code ptr */ @@ -363,7 +363,7 @@ public: void readGamePcText(File *in); void readItemChildren(File *in, Item *item, uint tmp); void readItemFromGamePc(File *in, Item *item); - bool loadGamePcFile(const char *filename); + void loadGamePcFile(const char *filename); byte *allocateItem(uint size); byte *allocateTable(uint size); |