[Scummvm-cvs-logs] CVS: scummvm/sword2 console.cpp,1.37,1.38 logic.h,1.22,1.23 speech.cpp,1.51,1.52 sword2.cpp,1.87,1.88

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sun Nov 30 23:48:04 CET 2003


Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1:/tmp/cvs-serv6737

Modified Files:
	console.cpp logic.h speech.cpp sword2.cpp 
Log Message:
Removed some unnecessary / commented out code, and initialized the debug
console a bit earlier so that error messages about missing files will be
more obvious to the user. (If an error happens that early, some of the
debugger commands will cause ScummVM to crash. I might look into that
later.)


Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/console.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- console.cpp	27 Nov 2003 07:34:19 -0000	1.37
+++ console.cpp	1 Dec 2003 07:47:54 -0000	1.38
@@ -123,19 +123,25 @@
 
 void Debugger::preEnter() {
 	// Pause sound output
-	_vm->_sound->pauseFx();
-	_vm->_sound->pauseSpeech();
-	_vm->_sound->pauseMusic();
+	if (_vm->_sound) {
+		_vm->_sound->pauseFx();
+		_vm->_sound->pauseSpeech();
+		_vm->_sound->pauseMusic();
+	}
 }
 
 void Debugger::postEnter() {
-	// Resume previous sound state
-	_vm->_sound->unpauseFx();
-	_vm->_sound->unpauseSpeech();
-	_vm->_sound->unpauseMusic();
+	if (_vm->_sound) {
+		// Resume previous sound state
+		_vm->_sound->unpauseFx();
+		_vm->_sound->unpauseSpeech();
+		_vm->_sound->unpauseMusic();
+	}
 
-	// Restore old mouse cursor
-	_vm->_graphics->drawMouse();
+	if (_vm->_graphics) {
+		// Restore old mouse cursor
+		_vm->_graphics->drawMouse();
+	}
 }
 
 ///////////////////////////////////////////////////

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/logic.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- logic.h	24 Nov 2003 07:34:07 -0000	1.22
+++ logic.h	1 Dec 2003 07:47:54 -0000	1.23
@@ -141,11 +141,6 @@
 	void formText(int32 *params);
 	bool wantSpeechForLine(uint32 wavId);
 
-#ifdef _SWORD2_DEBUG
-	// for testing speech & text
-	void getCorrectCdForSpeech(int32 wavId);
-#endif
-
 	uint32 _totalStartups;
 	uint32 _totalScreenManagers;
 	uint32 _startRes;
@@ -156,7 +151,7 @@
 		// id of screen manager object
 		uint32 start_res_id;
 
-		//tell the manager which startup you want (if there are more
+		// tell the manager which startup you want (if there are more
 		// than 1) (i.e more than 1 entrance to a screen and/or
 		// separate game boots)
 		uint32 key;

Index: speech.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/speech.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- speech.cpp	23 Nov 2003 13:40:24 -0000	1.51
+++ speech.cpp	1 Dec 2003 07:47:54 -0000	1.52
@@ -871,8 +871,6 @@
 
 	// for text/speech testing & checking for correct file type
 	_standardHeader	*head;
-	// for text/speech testing - keeping track of text resource currently being tested
-	static uint32 currentTextResource = 0;
 
 	// set up the pointers which we know we'll always need
 
@@ -1081,21 +1079,6 @@
 			else if (speech_pan > 16)
 				speech_pan = 16;
 
-			// if we're testing text & speech
-			if (SYSTEM_TESTING_TEXT) {
-				// if we've moved onto a new text resource,
-				// we will want to check if the CD needs
-				// changing again - can only know which CD to
-				// get if the wavID is non-zero
-
-				if (text_res != currentTextResource && params[S_WAV]) {
-					// ensure correct CD is in for this
-					// wavId
-					// getCorrectCdForSpeech(params[S_WAV]);
-					currentTextResource = text_res;
-				}
-			}
-
 			// set up path to speech cluster
 			// first checking if we have speech1.clu or
 			// speech2.clu in current directory (for translators
@@ -1467,28 +1450,6 @@
 		debug(5, "no text line for speech wav %d", params[S_WAV]);
 	}
 }
-
-#ifdef _SWORD2_DEBUG
-void Logic::getCorrectCdForSpeech(int32 wavId) {
-	File fp;
-
-	// 1, 2 or 0 (if speech on both cd's, ie. no need to change)
-	uint8 cd;
-
-	if (!fp.open("cd.bin"))
-		error("Need cd.bin file for testing speech!");
-
-	fp.seek(wavId, SEEK_SET);
-	fp.read(&cd, 1);
-
-	fp.close();
-
-	// if we specifically need CD1 or CD2 (ie. it's not on both)
-	// then check it's there (& ask for it if it's not there)
-	if (cd == 1 || cd == 2)
-		_vm->_resman->getCd(cd);
-}
-#endif
 
 // For preventing sfx subtitles from trying to load speech samples
 // - since the sfx are implemented as normal sfx, so we don't want them as

Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- sword2.cpp	25 Nov 2003 09:05:09 -0000	1.87
+++ sword2.cpp	1 Dec 2003 07:47:54 -0000	1.88
@@ -51,9 +51,9 @@
 	GameList detectedGames;
 	const GameSettings *g;
 	
-	// TODO: It would be nice if we had code here which distinguishes between
-	// the 'sword2' and 'sword2demo' targets. The current code can't do that
-	// since they use the same detectname.
+	// TODO: It would be nice if we had code here which distinguishes
+	// between the 'sword2' and 'sword2demo' targets. The current code
+	// can't do that since they use the same detectname.
 
 	for (g = sword2_settings; g->gameName; ++g) {
 		// Iterate over all files in the given directory
@@ -85,6 +85,8 @@
 
 	g_sword2 = this;
 	_debugger = NULL;
+	_sound = NULL;
+	_graphics = NULL;
 	_features = detector->_game.features;
 	_targetName = strdup(detector->_targetName.c_str());
 	_bootParam = ConfMan.getInt("boot_param");
@@ -104,6 +106,15 @@
 	// get some falling RAM and put it in your pocket, never let it slip
 	// away
 
+	_graphics = new Graphics(this, 640, 480);
+
+	// Create the debugger as early as possible (but not before the
+	// graphics object!) so that errors can be displayed in it. In
+	// particular, we want errors about missing files to be clearly
+	// visible to the user.
+
+	_debugger = new Debugger(this);
+
 	_memory = new MemoryManager(this);
 	_resman = new ResourceManager(this);
 	_logic = new Logic(this);
@@ -111,8 +122,6 @@
 	_gui = new Gui(this);
 	_input = new Input(this);
 	_sound = new Sound(this);
-	_graphics = new Graphics(this, 640, 480);
-	_debugger = new Debugger(this);
 
 	_lastPaletteRes = 0;
 
@@ -185,10 +194,11 @@
 		return;
 #endif
 
-	// Unless an error -originated- within the debugger, spawn the debugger. Otherwise
-	// exit out normally.
+	// Unless an error -originated- within the debugger, spawn the
+	// debugger. Otherwise exit out normally.
 	if (_debugger && !_debugger->isAttached()) {
-		printf("%s\n", buf2);	// (Print it again in case debugger segfaults)
+		// (Print it again in case debugger segfaults)
+		printf("%s\n", buf2);
 		_debugger->attach(buf2);
 		_debugger->onFrame();
 	}
@@ -243,7 +253,7 @@
 
 	// got a screen to run?
 	if (_logic->getRunList()) {
-		//run the logic session UNTIL a full loop has been performed
+		// run the logic session UNTIL a full loop has been performed
 		do {
 			// reset the graphic 'buildit' list before a new
 			// logic list (see fnRegisterFrame)
@@ -275,14 +285,6 @@
 void Sword2Engine::go() {
 	_keyboardEvent ke;
 
-	// Call the application "Revolution" until the resource manager is
-	// ready to dig the name out of a text file. See initialiseGame()
-	// which calls InitialiseFontResourceFlags() in maketext.cpp
-	//
-	// Have to do it like this since we cannot really fire up the resource
-	// manager until a window has been created as any errors are displayed
-	// via a window, thus time becomes a loop.
-
 	debug(5, "CALLING: readOptionSettings");
 	_gui->readOptionSettings();
 
@@ -342,14 +344,9 @@
 
 			char c = toupper(ke.ascii);
 
-			if (ke.modifiers == OSystem::KBD_CTRL) {
-				if (ke.keycode == 'd') {
-					_debugger->attach();
-				}
-			}
-
-			if (c == '~' || c == '#')
+			if ((ke.modifiers == OSystem::KBD_CTRL && ke.keycode == 'd') || c == '~' || c == '#') {
 				_debugger->attach();
+			}
 
 			if (_gamePaused) {	// if currently paused
 				if (c == 'P') {
@@ -466,14 +463,6 @@
 }
 
 void Sword2Engine::pauseGame(void) {
-	// uint8 *text;
-
-	// open text file & get the line "PAUSED"
-	// text = fetchTextLine(_resman->openResource(3258), 449);
-	// pause_text_bloc_no = _fontRenderer->buildNewBloc(text + 2, 320, 210, 640, 184, RDSPR_TRANS | RDSPR_DISPLAYALIGN, SPEECH_FONT_ID, POSITION_AT_CENTRE_OF_BASE);
-	// now ok to close the text file
-	// _resman->closeResource(3258);
-
 	// don't allow Pause while screen fading or while black
 	if (_graphics->getFadeStatus() != RDFADE_NONE)
 		return;
@@ -483,8 +472,6 @@
 	// make a normal mouse
 	clearPointerText();
 
-	// mouse_mode=MOUSE_normal;
-
 	// this is the only place allowed to do it this way
 	_graphics->setLuggageAnim(NULL, 0);
 
@@ -512,9 +499,6 @@
 }
 
 void Sword2Engine::unpauseGame(void) {
-	// removed "PAUSED" from screen
-	// _fontRenderer->killTextBloc(pause_text_bloc_no);
-
 	if (OBJECT_HELD && _realLuggageItem)
 		setLuggage(_realLuggageItem);
 





More information about the Scummvm-git-logs mailing list