[Scummvm-cvs-logs] SF.net SVN: scummvm: [23772] scummvm/trunk/engines/simon
kirben at users.sourceforge.net
kirben at users.sourceforge.net
Sun Aug 27 07:02:57 CEST 2006
Revision: 23772
Author: kirben
Date: 2006-08-26 22:02:48 -0700 (Sat, 26 Aug 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=23772&view=rev
Log Message:
-----------
Update error messages and always report an error if data file load fails
Modified Paths:
--------------
scummvm/trunk/engines/simon/midi.cpp
scummvm/trunk/engines/simon/midiparser_s1d.cpp
scummvm/trunk/engines/simon/res.cpp
scummvm/trunk/engines/simon/simon.cpp
scummvm/trunk/engines/simon/sound.cpp
Modified: scummvm/trunk/engines/simon/midi.cpp
===================================================================
--- scummvm/trunk/engines/simon/midi.cpp 2006-08-27 01:45:47 UTC (rev 23771)
+++ scummvm/trunk/engines/simon/midi.cpp 2006-08-27 05:02:48 UTC (rev 23772)
@@ -522,26 +522,21 @@
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 @@
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 @@
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;
Modified: scummvm/trunk/engines/simon/midiparser_s1d.cpp
===================================================================
--- scummvm/trunk/engines/simon/midiparser_s1d.cpp 2006-08-27 01:45:47 UTC (rev 23771)
+++ scummvm/trunk/engines/simon/midiparser_s1d.cpp 2006-08-27 05:02:48 UTC (rev 23772)
@@ -115,9 +115,7 @@
// 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 @@
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));
Modified: scummvm/trunk/engines/simon/res.cpp
===================================================================
--- scummvm/trunk/engines/simon/res.cpp 2006-08-27 01:45:47 UTC (rev 23771)
+++ scummvm/trunk/engines/simon/res.cpp 2006-08-27 05:02:48 UTC (rev 23772)
@@ -151,23 +151,23 @@
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 @@
/* 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 @@
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 @@
/* 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 @@
/* 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 @@
/* 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 @@
_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 @@
*ptr++ = val & 255;
break;
default:
- error("Bad cmd table entry %c", l);
+ error("readSingleOpcode: Bad cmd table entry %c", l);
}
}
}
@@ -474,13 +474,13 @@
_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::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 @@
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 @@
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 @@
} 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 @@
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);
}
Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp 2006-08-27 01:45:47 UTC (rev 23771)
+++ scummvm/trunk/engines/simon/simon.cpp 2006-08-27 05:02:48 UTC (rev 23772)
@@ -657,7 +657,7 @@
_itemHeapCurPos += size;
if (_itemHeapCurPos > _itemHeapSize)
- error("Itemheap overflow");
+ error("allocateItem: Itemheap overflow");
return org;
}
@@ -683,7 +683,7 @@
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::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::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 @@
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 @@
case 102:
return &_textLocation4;
default:
- error("text, invalid value %d", a);
+ error("getTextLocation: Invalid text location %d", a);
}
return NULL;
}
@@ -2133,10 +2133,9 @@
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 @@
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);
Modified: scummvm/trunk/engines/simon/sound.cpp
===================================================================
--- scummvm/trunk/engines/simon/sound.cpp 2006-08-27 01:45:47 UTC (rev 23771)
+++ scummvm/trunk/engines/simon/sound.cpp 2006-08-27 05:02:48 UTC (rev 23772)
@@ -100,7 +100,7 @@
_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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list