[Scummvm-cvs-logs] scummvm master -> ceaa86c1c45ab7f4d94b3bef64eed049af7144ab

Strangerke Strangerke at scummvm.org
Tue Dec 17 23:08:22 CET 2013


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

Summary:
ceaa86c1c4 AVALANCHE: Fix some coding convention issues, fix some warnings


Commit: ceaa86c1c45ab7f4d94b3bef64eed049af7144ab
    https://github.com/scummvm/scummvm/commit/ceaa86c1c45ab7f4d94b3bef64eed049af7144ab
Author: Strangerke (strangerke at scummvm.org)
Date: 2013-12-17T14:07:48-08:00

Commit Message:
AVALANCHE: Fix some coding convention issues, fix some warnings

Changed paths:
    engines/avalanche/dialogs.cpp
    engines/avalanche/nim.cpp



diff --git a/engines/avalanche/dialogs.cpp b/engines/avalanche/dialogs.cpp
index 0dcdb44..c68ad4b 100644
--- a/engines/avalanche/dialogs.cpp
+++ b/engines/avalanche/dialogs.cpp
@@ -356,6 +356,8 @@ void Dialogs::scrollModeMusic() {
 				case Common::KEYCODE_RIGHTBRACKET:
 					value = 11;
 					break;
+				default:
+					break;
 				}
 
 				lastOne = thisOne;
diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp
index 8f73fe6..2629b99 100644
--- a/engines/avalanche/nim.cpp
+++ b/engines/avalanche/nim.cpp
@@ -257,66 +257,63 @@ void Nim::dogFood() {
 		if (sr[0] > sr[1]) { // T > b
 			_row = _r[0];
 			_number = sr[0] - sr[1];
-			return;
-		}
-		else if (sr[0] < sr[1]) { // B > t
+		} else if (sr[0] < sr[1]) { // B > t
 			_row = _r[1];
 			_number = sr[1] - sr[0];
-			return;
-		}
-		else { // B = t... oh no, we've lost!
+		} else { // B = t... oh no, we've lost!
 			_row = _r[0];
 			_number = 1;
-			return;
 		}
-		break;
-	case 3: { // Ho hum... this'll be difficult!
-				// There are three possible courses of action when we have 3 lines left:
-				// 1) Look for 2 equal lines, then take the odd one out.
-				// 2) Look for A.P.s, and capitalise on them.
-				// 3) Go any old where.
-				const byte other[3][2] = { { 2, 3 }, { 1, 3 }, { 1, 2 } };
-
-				for (int i = 0; i < 3; i++) // Look for 2 equal lines.
-					if (_stones[other[i][0]] == _stones[other[i][1]]) {
-						_row = i; // This row.
-						_number = _stones[i]; // All of 'em.
-						return;
-					}
-
-				bool sorted;
-				do {
-					sorted = true;
-					for (int i = 0; i < 2; i++)
-						if (sr[i] > sr[i + 1]) {
-							byte temp = sr[i + 1];
-							sr[i + 1] = sr[i];
-							sr[i] = temp;
-
-							temp = _r[i + 1];
-							_r[i + 1] = _r[i];
-							_r[i] = temp;
-
-							sorted = false;
-						}
-				} while (sorted);
-				
-				// Now we look for A.P.s...
-				for (int i = 1; i <= 3; i++) {
-					findAp(i, 1); // There are 3 "1"s.
-					if (_lmo)
-						return; // Cut - out.
+		return;
+	case 3: { 
+		// Ho hum... this'll be difficult!
+		// There are three possible courses of action when we have 3 lines left:
+		// 1) Look for 2 equal lines, then take the odd one out.
+		// 2) Look for A.P.s, and capitalise on them.
+		// 3) Go any old where.
+		const byte other[3][2] = { { 2, 3 }, { 1, 3 }, { 1, 2 } };
+
+		for (int i = 0; i < 3; i++) { // Look for 2 equal lines.
+			if (_stones[other[i][0]] == _stones[other[i][1]]) {
+				_row = i; // This row.
+				_number = _stones[i]; // All of 'em.
+				return;
+			}
+		}
+
+		bool sorted;
+		do {
+			sorted = true;
+			for (int i = 0; i < 2; i++) {
+				if (sr[i] > sr[i + 1]) {
+					byte temp = sr[i + 1];
+					sr[i + 1] = sr[i];
+					sr[i] = temp;
+
+					temp = _r[i + 1];
+					_r[i + 1] = _r[i];
+					_r[i] = temp;
+
+					sorted = false;
 				}
-				findAp(1, 2); // Only "2" possible.
-				if (_lmo)
-					return;
+			}
+		} while (sorted);
+		
+		// Now we look for A.P.s...
+		for (int i = 1; i <= 3; i++) {
+			findAp(i, 1); // There are 3 "1"s.
+			if (_lmo)
+				return; // Cut - out.
+		}
+		findAp(1, 2); // Only "2" possible.
+		if (_lmo)
+			return;
 
-				// A.P.search must have failed - use the default move.
-				_row = _r[2];
-				_number = 1;
-				return;
+		// A.P.search must have failed - use the default move.
+		_row = _r[2];
+		_number = 1;
+		return;
 		}
-		break;
 	default:
 		break;
 	}
@@ -324,11 +321,12 @@ void Nim::dogFood() {
 
 bool Nim::find(byte x) {
 	bool ret = false;
-	for (int i = 0; i < 3; i++)
+	for (int i = 0; i < 3; i++) {
 		if (_stones[i] == x) {
 			ret = true;
 			_inAp[i] = true;
 		}
+	}
 	return ret;
 }
 
@@ -337,24 +335,26 @@ void Nim::findAp(byte start, byte stepSize) {
 	byte matches = 0;
 	for (int i = 0; i < 3; i++)
 		_inAp[i] = 0; // Blank 'em all!
-	for (int i = 0; i < 3; i++)
+	for (int i = 0; i < 3; i++) {
 		if (find(start + i * stepSize))
 			matches++;
 		else
 			thisOne = i;
+	}
 
 	// Now..Matches must be 0, 1, 2, or 3.
 	// 0 / 1 mean there are no A.P.s here, so we'll keep looking,
 	// 2 means there is a potential A.P.that we can create (ideal!), and
 	// 3 means that we're already in an A.P. (Trouble!)
 
-	byte ooo; // Odd one out.
+	byte ooo = 0; // Odd one out.
 
 	switch (matches) {
 	case 2:
-		for (int i = 0; i < 3; i++) // Find which one didn't fit the A.P.
+		for (int i = 0; i < 3; i++) { // Find which one didn't fit the A.P.
 			if (!_inAp[i])
 				ooo = i;
+		}
 
 		if (_stones[ooo] > (start + thisOne * stepSize)) { // Check if it's possible!
 			// Create an A.P.






More information about the Scummvm-git-logs mailing list