[Scummvm-cvs-logs] CVS: scummvm/simon res.cpp,1.13,1.14 simon.cpp,1.131,1.132 simon.h,1.41,1.42

Travis Howell kirben at users.sourceforge.net
Fri Jan 3 04:34:17 CET 2003


Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv10696/simon

Modified Files:
	res.cpp simon.cpp simon.h 
Log Message:

Don't crash if sound effect file doesn't exist


Index: res.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/res.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- res.cpp	3 Jan 2003 10:36:13 -0000	1.13
+++ res.cpp	3 Jan 2003 12:33:52 -0000	1.14
@@ -94,7 +94,7 @@
 	" ", " ", "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 @@
 		error("Out of memory for strip text list");
 	in->read(_stripped_txt_mem, file_size);
 	in->close();
-
-	return true;
 }
 
 void SimonState::readGamePcText(File *in)

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- simon.cpp	3 Jan 2003 12:06:30 -0000	1.131
+++ simon.cpp	3 Jan 2003 12:33:53 -0000	1.132
@@ -828,7 +828,7 @@
 		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 @@
 
 	_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 @@
 
 	if (_mus_file->read(_mus_offsets, size) != size)
 		error("Cannot read offsets");
+
+	return true;
 }
 
 void SimonState::playSting(uint a)
@@ -857,7 +861,8 @@
 	if (!midi._midi_sfx_toggle)
 		return;
 
-	readSting(_midi_sfx);
+	if (!readSting(_midi_sfx))
+		return;
 	
 	midi.shutdown();
 	_mus_file->seek(_mus_offsets[a], SEEK_SET);

Index: simon.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- simon.h	3 Jan 2003 12:06:30 -0000	1.41
+++ simon.h	3 Jan 2003 12:33:53 -0000	1.42
@@ -103,7 +103,7 @@
 	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 @@
 	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);





More information about the Scummvm-git-logs mailing list