[Scummvm-cvs-logs] scummvm master -> 3ef4222f33bc6e888ff7e4d25f7f8a3b3a7bd5bf

Strangerke Strangerke at scummvm.org
Wed Aug 21 08:39:39 CEST 2013


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
972cdf0e12 MORTEVIELLE: Avoid erroring out when the user tries to load a missing save game
a710bb5ca4 MORTEVIELLE: Remove second parameter of show()
3ef4222f33 MORTEVIELLE: Replace some big if statements by switch statements


Commit: 972cdf0e129759e109aa53876b72ed4df03c229b
    https://github.com/scummvm/scummvm/commit/972cdf0e129759e109aa53876b72ed4df03c229b
Author: Strangerke (strangerke at scummvm.org)
Date: 2013-08-20T23:37:55-07:00

Commit Message:
MORTEVIELLE: Avoid erroring out when the user tries to load a missing save game

Changed paths:
    engines/mortevielle/saveload.cpp
    engines/mortevielle/saveload.h



diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp
index 651ed07..c14a03c 100644
--- a/engines/mortevielle/saveload.cpp
+++ b/engines/mortevielle/saveload.cpp
@@ -72,15 +72,16 @@ void SavegameManager::sync_save(Common::Serializer &sz) {
  * Inner code for loading a saved game
  * @remarks	Originally called 'takesav'
  */
-void SavegameManager::loadSavegame(const Common::String &filename) {
+bool SavegameManager::loadSavegame(const Common::String &filename) {
 	// Try loading first from the save area
 	Common::SeekableReadStream *stream = g_system->getSavefileManager()->openForLoading(filename);
 
 	Common::File f;
 	if (stream == NULL) {
-		if (!f.open(filename))
-			error("Unable to open save file '%s'", filename.c_str());
-
+		if (!f.open(filename)) {
+			warning("Unable to open save file '%s'", filename.c_str());
+			return false;
+		}
 		stream = f.readStream(f.size());
 		f.close();
 	}
@@ -107,6 +108,8 @@ void SavegameManager::loadSavegame(const Common::String &filename) {
 
 	// Close the stream
 	delete stream;
+
+	return true;
 }
 
 /**
@@ -115,14 +118,15 @@ void SavegameManager::loadSavegame(const Common::String &filename) {
 Common::Error SavegameManager::loadGame(const Common::String &filename) {
 	g_vm->_mouse.hideMouse();
 	g_vm->displayEmptyHand();
-	loadSavegame(filename);
-
-	/* Initialization */
-	g_vm->charToHour();
-	g_vm->initGame();
-	g_vm->gameLoaded();
-	g_vm->_mouse.showMouse();
-	return Common::kNoError;
+	if (loadSavegame(filename)) {
+		/* Initialization */
+		g_vm->charToHour();
+		g_vm->initGame();
+		g_vm->gameLoaded();
+		g_vm->_mouse.showMouse();
+		return Common::kNoError;
+	} else 
+		return Common::kUnknownError;
 }
 
 /**
diff --git a/engines/mortevielle/saveload.h b/engines/mortevielle/saveload.h
index 0121a04..79747e6 100644
--- a/engines/mortevielle/saveload.h
+++ b/engines/mortevielle/saveload.h
@@ -57,7 +57,7 @@ private:
 	void sync_save(Common::Serializer &sz);
 public:
 	void setParent(MortevielleEngine *vm);
-	void loadSavegame(const Common::String &filename);
+	bool loadSavegame(const Common::String &filename);
 	Common::Error loadGame(const Common::String &filename);
 	Common::Error saveGame(int n, const Common::String &saveName);
 	Common::Error loadGame(int slot);


Commit: a710bb5ca435b246d7ac042fbb5575e0ab82c1fd
    https://github.com/scummvm/scummvm/commit/a710bb5ca435b246d7ac042fbb5575e0ab82c1fd
Author: Strangerke (strangerke at scummvm.org)
Date: 2013-08-20T23:37:56-07:00

Commit Message:
MORTEVIELLE: Remove second parameter of show()

Changed paths:
    engines/mortevielle/actions.cpp
    engines/mortevielle/dialogs.cpp
    engines/mortevielle/dialogs.h
    engines/mortevielle/utils.cpp



diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp
index d0ecd6c..e635189 100644
--- a/engines/mortevielle/actions.cpp
+++ b/engines/mortevielle/actions.cpp
@@ -702,10 +702,10 @@ void MortevielleEngine::fctPlace() {
 					_soundManager.startSpeech(6, -9, 1);
 
 					// Do you want to enter the hidden passage?
-					int answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
+					int answer = _dialogManager.show(getEngineString(S_YES_NO));
 					if (answer == 1) {
 						Common::String alertTxt = getString(582);
-						_dialogManager.show(alertTxt, 1);
+						_dialogManager.show(alertTxt);
 
 						bool enterPassageFl = _dialogManager.showKnowledgeCheck();
 						_mouse.hideMouse();
@@ -732,7 +732,7 @@ void MortevielleEngine::fctPlace() {
 							displayAnimFrame(1, 2);
 							displayAnimFrame(1, 1);
 							alertTxt = getString(577);
-							_dialogManager.show(alertTxt, 1);
+							_dialogManager.show(alertTxt);
 							displayAnimFrame(2, 1);
 							_crep = 166;
 						}
@@ -801,7 +801,7 @@ void MortevielleEngine::fctTurn() {
 		if ((_coreVar._currPlace == ATTIC) && (_coreVar._atticRodHoleObjectId == 159) && (_coreVar._atticBallHoleObjectId == 141)) {
 			handleDescriptionText(2, 167);
 			_soundManager.startSpeech(7, 9, 1);
-			int answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
+			int answer = _dialogManager.show(getEngineString(S_YES_NO));
 			if (answer == 1)
 				_endGame = true;
 			else
@@ -811,7 +811,7 @@ void MortevielleEngine::fctTurn() {
 			handleDescriptionText(2, 175);
 			clearVerbBar();
 			_soundManager.startSpeech(6, -9, 1);
-			int answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
+			int answer = _dialogManager.show(getEngineString(S_YES_NO));
 			if (answer == 1) {
 				_coreVar._currPlace = CRYPT;
 				prepareDisplayText();
@@ -914,7 +914,7 @@ void MortevielleEngine::fctKnock() {
 		displayTextInVerbBar(getEngineString(S_HIT));
 
 	if (_coreVar._currPlace == LANDING) {
-		_dialogManager.show(getEngineString(S_BEFORE_USE_DEP_MENU), 1);
+		_dialogManager.show(getEngineString(S_BEFORE_USE_DEP_MENU));
 		return;
 	}
 
@@ -1223,7 +1223,7 @@ void MortevielleEngine::fctSleep() {
 		if (hour > 23)
 			hour = 0;
 		prepareRoom();
-		answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
+		answer = _dialogManager.show(getEngineString(S_YES_NO));
 		_anyone = false;
 	} while (answer != 1);
 	_crep = 998;
@@ -1313,7 +1313,7 @@ void MortevielleEngine::fctWait() {
 			return;
 		}
 		handleDescriptionText(2, 102);
-		answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
+		answer = _dialogManager.show(getEngineString(S_YES_NO));
 	} while (answer != 2);
 	_crep = 998;
 	if (!_anyone)
@@ -1629,7 +1629,7 @@ void MortevielleEngine::askRestart() {
 	_day = 0;
 	handleDescriptionText(2, 180);
 
-	int answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
+	int answer = _dialogManager.show(getEngineString(S_YES_NO));
 	_quitGame = (answer != 1);
 }
 
diff --git a/engines/mortevielle/dialogs.cpp b/engines/mortevielle/dialogs.cpp
index a7bd381..9a2ade6 100644
--- a/engines/mortevielle/dialogs.cpp
+++ b/engines/mortevielle/dialogs.cpp
@@ -39,7 +39,7 @@ namespace Mortevielle {
  * Alert function - Show
  * @remarks	Originally called 'do_alert'
  */
-int DialogManager::show(const Common::String &msg, int n) {
+int DialogManager::show(const Common::String &msg) {
 	// Make a copy of the current screen surface for later restore
 	_vm->_backgroundSurface.copyFrom(_vm->_screenSurface);
 
@@ -164,10 +164,10 @@ int DialogManager::show(const Common::String &msg, int n) {
 	_vm->setMouseClick(false);
 	_vm->_mouse.hideMouse();
 	if (!test3)  {
-		id = n;
-		setPosition(n, coldep, esp);
+		id = 1;
+		setPosition(1, coldep, esp);
 		Common::String tmp4(" ");
-		tmp4 += buttonStr[n];
+		tmp4 += buttonStr[1];
 		tmp4 += " ";
 		_vm->_screenSurface.drawString(tmp4, 1);
 	}
diff --git a/engines/mortevielle/dialogs.h b/engines/mortevielle/dialogs.h
index ee210a6..3f30851 100644
--- a/engines/mortevielle/dialogs.h
+++ b/engines/mortevielle/dialogs.h
@@ -52,7 +52,7 @@ private:
 	void setButtonText(Common::String c, int coldep, int nbcase, Common::String *str, int esp);
 public:
 	void setParent(MortevielleEngine *vm);
-	int show(const Common::String &msg, int n);
+	int show(const Common::String &msg);
 	void drawF3F8();
 	void checkForF8(int SpeechNum, bool drawFrame2Fl);
 	int waitForF3F8();
diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp
index f8012b5..cb2c3c5 100644
--- a/engines/mortevielle/utils.cpp
+++ b/engines/mortevielle/utils.cpp
@@ -290,7 +290,7 @@ void MortevielleEngine::handleAction() {
 		if (_menu._menuSelected && (_currMenu == MENU_LOAD))
 			_savegameManager.loadGame((_currAction & 15) - 1);
 		if (inkey == '\103') {       /* F9 */
-			temps = _dialogManager.show(_hintPctMessage, 1);
+			temps = _dialogManager.show(_hintPctMessage);
 			return;
 		} else if (inkey == '\77') {
 			if ((_menuOpcode != OPCODE_NONE) && ((_currMenu == MENU_ACTION) || (_currMenu == MENU_SELF))) {
@@ -1712,7 +1712,7 @@ int MortevielleEngine::getRandomNumber(int minval, int maxval) {
  * @remarks	Originally called 'aldepl'
  */
 void MortevielleEngine::showMoveMenuAlert() {
-	_dialogManager.show(getEngineString(S_USE_DEP_MENU), 1);
+	_dialogManager.show(getEngineString(S_USE_DEP_MENU));
 }
 
 /**
@@ -3190,7 +3190,7 @@ void MortevielleEngine::displayStatusArrow() {
 		} while (!(qust || inRect || _anyone));
 
 		if (qust && (touch == '\103'))
-			_dialogManager.show(_hintPctMessage, 1);
+			_dialogManager.show(_hintPctMessage);
 	} while (!((touch == '\73') || ((touch == '\104') && (_x != 0) && (_y != 0)) || (_anyone) || (inRect)));
 
 	if (touch == '\73')


Commit: 3ef4222f33bc6e888ff7e4d25f7f8a3b3a7bd5bf
    https://github.com/scummvm/scummvm/commit/3ef4222f33bc6e888ff7e4d25f7f8a3b3a7bd5bf
Author: Strangerke (strangerke at scummvm.org)
Date: 2013-08-20T23:37:57-07:00

Commit Message:
MORTEVIELLE: Replace some big if statements by switch statements

Changed paths:
    engines/mortevielle/actions.cpp
    engines/mortevielle/utils.cpp



diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp
index e635189..b76b7e8 100644
--- a/engines/mortevielle/actions.cpp
+++ b/engines/mortevielle/actions.cpp
@@ -91,31 +91,41 @@ void MortevielleEngine::fctMove() {
 		oldMenu = (_menu._moveMenu[menuChoice]._menuId << 8) | _menu._moveMenu[menuChoice]._actionId;
 	}
 
-	if (_coreVar._currPlace == MOUNTAIN) {
+	switch (_coreVar._currPlace) {
+	case MOUNTAIN:
 		if (menuChoice == 1)
 			gotoManorFront();
 		else if (menuChoice == 2)
 			checkManorDistance();
 		_menu.setDestinationText(_coreVar._currPlace);
 		return;
-	} else if (_coreVar._currPlace == INSIDE_WELL) {
+	case INSIDE_WELL:
 		if (menuChoice == 1)
 			floodedInWell();
 		else if (menuChoice == 2)
 			gotoManorBack();
 		_menu.setDestinationText(_coreVar._currPlace);
 		return;
-	} else if ((_coreVar._currPlace == BUREAU) && (menuChoice == 1))
-		menuChoice = 6;
-	else if (_coreVar._currPlace == KITCHEN) {
+	case BUREAU:
+		if (menuChoice == 1)
+			menuChoice = 6;
+		break;
+	case KITCHEN:
 		if (menuChoice == 2)
 			menuChoice = 6;
 		else if (menuChoice == 5)
 			menuChoice = 16;
-	} else if ((_coreVar._currPlace == CELLAR) && (menuChoice == 3))
-		menuChoice = 6;
-	else if (((_coreVar._currPlace == LANDING) || (_coreVar._currPlace == ROOM26)) && (menuChoice == 4))
-		menuChoice = 6;
+		break;
+	case CELLAR:
+		if (menuChoice == 3)
+			menuChoice = 6;
+		break;
+	case LANDING:
+	case ROOM26:
+		if (menuChoice == 4)
+			menuChoice = 6;
+		break;
+	}
 
 	if ((_coreVar._currPlace > MOUNTAIN) && (_coreVar._currPlace != ROOM26))
 		menuChoice += 10;
@@ -132,32 +142,40 @@ void MortevielleEngine::fctMove() {
 	else if ((_coreVar._currPlace == WELL) && (menuChoice > 13) && (menuChoice != 17))
 		menuChoice = 15;
 
-	if (menuChoice == 1)
+	switch (menuChoice) {
+	case 1:
 		_coreVar._currPlace = BUREAU;
-	else if (menuChoice == 2)
+		break;
+	case 2:
 		_coreVar._currPlace = KITCHEN;
-	else if (menuChoice == 3)
+		break;
+	case 3:
 		_coreVar._currPlace = CELLAR;
-	else if (menuChoice == 4)
+		break;
+	case 4:
 		_coreVar._currPlace = LANDING;
-	else if (menuChoice == 5)
-		menuChoice = 12;
-	else if (menuChoice == 6)
-		menuChoice = 11;
-
-	if (menuChoice == 11)
-		gotoDiningRoom();
-	else if (menuChoice == 12)
+		break;
+	case 5:
+	case 12:
 		gotoManorFront();
-	else if (menuChoice == 13)
+		break;
+	case 6:
+	case 11:
+		gotoDiningRoom();
+		break;
+	case 13:
 		_coreVar._currPlace = CHAPEL;
-	else if (menuChoice == 14)
+		break;
+	case 14:
 		_coreVar._currPlace = WELL;
-	else if (menuChoice == 15)
+		break;
+	case 15:
 		checkManorDistance();
-	else if (menuChoice == 16)
+		break;
+	case 16:
 		gotoManorBack();
-	else if (menuChoice == 17) {
+		break;
+	case 17:
 		if ((_coreVar._wellObjectId != 120) && (_coreVar._wellObjectId != 140))
 			_crep = 997;
 		else if (_coreVar._wellObjectId == 120)
@@ -169,7 +187,9 @@ void MortevielleEngine::fctMove() {
 			_coreVar._currPlace = INSIDE_WELL;
 			prepareDisplayText();
 		}
+		break;
 	}
+
 	if ((menuChoice < 5) || (menuChoice == 13) || (menuChoice == 14))
 		prepareDisplayText();
 	resetRoomVariables(_coreVar._currPlace);
diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp
index cb2c3c5..92786b1 100644
--- a/engines/mortevielle/utils.cpp
+++ b/engines/mortevielle/utils.cpp
@@ -2498,7 +2498,7 @@ void MortevielleEngine::handleDescriptionText(int f, int mesgId) {
 			displayTextInDescriptionBar(8, 182, 103, mesgId);
 			if ((mesgId == 68) || (mesgId == 69))
 				_coreVar._availableQuestion[40] = '*';
-			if ((mesgId == 104) && (_caff == CELLAR)) {
+			else if ((mesgId == 104) && (_caff == CELLAR)) {
 				_coreVar._availableQuestion[36] = '*';
 				if (_coreVar._availableQuestion[39] == '*') {
 					_coreVar._pctHintFound[3] = '*';
@@ -2775,34 +2775,54 @@ int MortevielleEngine::getPresence(int roomId) {
 			displayAloneText();
 		else {
 			int h = 0;
-			if (roomId == DINING_ROOM)
+			switch (roomId) {
+			case DINING_ROOM:
 				pres = getPresenceStatsDiningRoom(h);
-			else if (roomId == BUREAU)
+				break;
+			case BUREAU:
 				pres = getPresenceStatsBureau(h);
-			else if (roomId == KITCHEN)
+				break;
+			case KITCHEN:
 				pres = getPresenceStatsKitchen();
-			else if ((roomId == ATTIC) || (roomId == CELLAR))
+				break;
+			case ATTIC:
+			case CELLAR:
 				pres = getPresenceStatsAttic();
-			else if ((roomId == LANDING) || (roomId == ROOM26))
+				break;
+			case LANDING:
+			case ROOM26:
 				pres = getPresenceStatsLanding();
-			else if (roomId == CHAPEL)
+				break;
+			case CHAPEL:
 				pres = getPresenceStatsChapel(h);
+				break;
+			}
 			pres += _coreVar._faithScore;
 			rand = getRandomNumber(1, 100);
 			if (rand > pres) {
 				displayAloneText();
 				retVal = 0;
 			} else {
-				if (roomId == DINING_ROOM)
+				switch (roomId) {
+				case DINING_ROOM:
 					pres = setPresenceDiningRoom(h);
-				else if (roomId == BUREAU)
+					break;
+				case BUREAU:
 					pres = setPresenceBureau(h);
-				else if ((roomId == KITCHEN) || (roomId == ATTIC) || (roomId == CELLAR))
+					break;
+				case KITCHEN:
+				case ATTIC:
+				case CELLAR:
 					pres = setPresenceKitchen();
-				else if ((roomId == LANDING) || (roomId == ROOM26))
+					break;
+				case LANDING:
+				case ROOM26:
 					pres = setPresenceLanding();
-				else if (roomId == CHAPEL)
+					break;
+				case CHAPEL:
 					pres = setPresenceChapel(h);
+					break;
+				}
 				retVal = pres;
 			}
 		}
@@ -2866,18 +2886,27 @@ void MortevielleEngine::drawPicture() {
 					displayAnimFrame(1, _openObjects[i]);
 			}
 
-			if (_caff == ATTIC) {
+			switch (_caff) {
+			case ATTIC:
 				if (_coreVar._atticBallHoleObjectId == 141)
 					displayAnimFrame(1, 7);
 
 				if (_coreVar._atticRodHoleObjectId == 159)
 					displayAnimFrame(1, 6);
-			} else if ((_caff == CELLAR) && (_coreVar._cellarObjectId == 151))
-				displayAnimFrame(1, 2);
-			else if ((_caff == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId == 143))
-				displayAnimFrame(1, 1);
-			else if ((_caff == WELL) && (_coreVar._wellObjectId != 0))
-				displayAnimFrame(1, 1);
+				break;
+			case CELLAR:
+				if (_coreVar._cellarObjectId == 151)
+					displayAnimFrame(1, 2);
+				break;
+			case SECRET_PASSAGE:
+				if (_coreVar._secretPassageObjectId == 143)
+					displayAnimFrame(1, 1);
+				break;
+			case WELL:
+				if (_coreVar._wellObjectId != 0)
+					displayAnimFrame(1, 1);
+				break;
+			}
 		}
 
 		if (_caff < ROOM26)






More information about the Scummvm-git-logs mailing list