[Scummvm-cvs-logs] CVS: scummvm/simon items.cpp,1.31,1.32 simon.cpp,1.107,1.108 simon.h,1.31,1.32

Oliver Kiehl olki at users.sourceforge.net
Wed Dec 4 14:41:04 CET 2002


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

Modified Files:
	items.cpp simon.cpp simon.h 
Log Message:
cleanup


Index: items.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/items.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- items.cpp	3 Dec 2002 05:39:30 -0000	1.31
+++ items.cpp	4 Dec 2002 22:39:56 -0000	1.32
@@ -386,20 +386,12 @@
 			break;
 
 		case 67:{									/* set array 3 and 4 */
-				if (_game & GAME_TALKIE) {
-					uint var = getVarOrByte();
-					uint string_id = getNextStringID();
-					uint value = getNextWord();
-					if (var < 20) {
-						_stringid_array_3[var] = string_id;
-						_array_4[var] = value;
-					}
-				} else {
-					uint var = getVarOrByte();
-					uint string_id = getNextStringID();
-					if (var < 20) {
-						_stringid_array_3[var] = string_id;
-					}
+				uint var = getVarOrByte();
+				uint string_id = getNextStringID();
+				if (var < 20) {
+					_stringid_array_3[var] = string_id;
+					if (_game & GAME_TALKIE)
+						_array_4[var] = getNextWord();
 				}
 			}
 			break;
@@ -743,13 +735,11 @@
 
 		case 130:{									/* set script cond */
 				uint a = getVarOrByte();
-				if (a == 1) {
-					getNextWord();
+				getNextWord();
+				if (a == 1)
 					_script_cond_b = getNextWord();
-				} else {
-					getNextWord();
+				else
 					_script_cond_c = getNextWord();
-				}
 			}
 			break;
 
@@ -930,24 +920,7 @@
 
 		case 161:{									/* setup text */
 				uint value = getVarOrByte();
-				ThreeValues *tv;
-
-				switch (value) {
-				case 1:
-					tv = &_threevalues_1;
-					break;
-				case 2:
-					tv = &_threevalues_2;
-					break;
-				case 101:
-					tv = &_threevalues_3;
-					break;
-				case 102:
-					tv = &_threevalues_4;
-					break;
-				default:
-					error("setup text, invalid value %d", value);
-				}
+				ThreeValues *tv = getThreeValues(value);
 
 				tv->a = getVarOrWord();
 				tv->b = getVarOrByte();
@@ -1039,24 +1012,7 @@
 					uint c = getVarOrByte();
 					uint a = getVarOrByte();
 					const char *s = (const char *)getStringPtrByID(_stringid_array_3[a]);
-					ThreeValues *tv;
-
-					switch (b) {
-					case 1:
-						tv = &_threevalues_1;
-						break;
-					case 2:
-						tv = &_threevalues_2;
-						break;
-					case 101:
-						tv = &_threevalues_3;
-						break;
-					case 102:
-						tv = &_threevalues_4;
-						break;
-					default:
-						error("setup text, invalid value %d", b);
-					}
+					ThreeValues *tv = getThreeValues(b);
 
 					talk_with_text(b, c, s, tv->a, tv->b, tv->c);
 				} else if (_game == GAME_SIMON2TALKIE || _game == GAME_SIMON2WIN) {
@@ -1065,24 +1021,7 @@
 					uint a = getVarOrByte();
 					uint d;
 					const char *s = (const char *)getStringPtrByID(_stringid_array_3[a]);
-					ThreeValues *tv;
-
-					switch (b) {
-					case 1:
-						tv = &_threevalues_1;
-						break;
-					case 2:
-						tv = &_threevalues_2;
-						break;
-					case 101:
-						tv = &_threevalues_3;
-						break;
-					case 102:
-						tv = &_threevalues_4;
-						break;
-					default:
-						error("setup text, invalid value %d", b);
-					}
+					ThreeValues *tv = getThreeValues(b);
 
 					d = _array_4[a];
 					if (d != 0 && !_vk_t_toggle)
@@ -1095,24 +1034,8 @@
 					uint c = getVarOrByte();
 					uint a = getVarOrByte();
 					const char *s = (const char *)getStringPtrByID(_stringid_array_3[a]);
-					ThreeValues *tv;
 
-					switch (b) {
-					case 1:
-						tv = &_threevalues_1;
-						break;
-					case 2:
-						tv = &_threevalues_2;
-						break;
-					case 101:
-						tv = &_threevalues_3;
-						break;
-					case 102:
-						tv = &_threevalues_4;
-						break;
-					default:
-						error("setup text, invalid value %d", b);
-					}
+					ThreeValues *tv = getThreeValues(b);
 
 					if (s != NULL)
 						talk_with_text(b, c, s, tv->a, tv->b, tv->c);
@@ -1361,24 +1284,9 @@
 		Child2 *child = (Child2 *)findChildOfType(getNextItemPtr(), 2);
 		if (child != NULL && child->avail_props & 1) {
 			const char *s = (const char *)getStringPtrByID(child->array[0]);
-			ThreeValues *tv;
 			char buf[256];
-			switch (a) {
-			case 1:
-				tv = &_threevalues_1;
-				break;
-			case 2:
-				tv = &_threevalues_2;
-				break;
-			case 101:
-				tv = &_threevalues_3;
-				break;
-			case 102:
-				tv = &_threevalues_4;
-				break;
-			default:
-				error("setup text, invalid value %d", a);
-			}
+
+			ThreeValues *tv = getThreeValues(a);
 
 			if (child->avail_props & 0x100) {
 				uint x = getOffsetOfChild2Param(child, 0x100);
@@ -1398,22 +1306,7 @@
 
 		if (child != NULL && child->avail_props & 1) {
 			s = (const char *)getStringPtrByID(child->array[0]);
-			switch (a) {
-			case 1:
-				tv = &_threevalues_1;
-				break;
-			case 2:
-				tv = &_threevalues_2;
-				break;
-			case 101:
-				tv = &_threevalues_3;
-				break;
-			case 102:
-				tv = &_threevalues_4;
-				break;
-			default:
-				error("setup text, invalid value %d", a);
-			}
+			tv = getThreeValues(a);
 		}
 
 		if (child != NULL && child->avail_props & 0x200) {
@@ -1489,22 +1382,7 @@
 
 		if (child != NULL && child->avail_props & 1) {
 			s = (const char *)getStringPtrByID(child->array[0]);
-			switch (a) {
-			case 1:
-				tv = &_threevalues_1;
-				break;
-			case 2:
-				tv = &_threevalues_2;
-				break;
-			case 101:
-				tv = &_threevalues_3;
-				break;
-			case 102:
-				tv = &_threevalues_4;
-				break;
-			default:
-				error("setup text, invalid value %d", a);
-			}
+			tv = getThreeValues(a);
 		}
 
 		if (child == NULL || !(child->avail_props & 1))

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- simon.cpp	1 Dec 2002 15:36:36 -0000	1.107
+++ simon.cpp	4 Dec 2002 22:40:00 -0000	1.108
@@ -1700,6 +1700,24 @@
 	startUp_helper_2();
 }
 
+ThreeValues *SimonState::getThreeValues(uint a)
+{
+	switch (a) {
+	case 1:
+		return &_threevalues_1;
+	case 2:
+		return &_threevalues_2;
+	case 101:
+		return &_threevalues_3;
+		break;
+	case 102:
+		return &_threevalues_4;
+		break;
+	default:
+		error("text, invalid value %d", a);
+	}
+}
+
 void SimonState::o_print_str()
 {
 	uint num_1 = getVarOrByte();
@@ -1709,54 +1727,16 @@
 	uint speech_id = 0;
 	ThreeValues *tv;
 
-
-	switch (_game) {
-	case GAME_SIMON1TALKIE:
-	case GAME_SIMON1WIN:
-		if (string_id != 0xFFFF)
-			string_ptr = getStringPtrByID(string_id);
-
-		speech_id = (uint16)getNextWord();
-		break;
-
-	case GAME_SIMON2TALKIE:
-	case GAME_SIMON2WIN:
+	if (_game & GAME_TALKIE) {
 		if (string_id != 0xFFFF)
 			string_ptr = getStringPtrByID(string_id);
 
 		speech_id = (uint16)getNextWord();
-		break;
-
-	case GAME_SIMON2DOS:
-		string_ptr = getStringPtrByID(string_id);
-		break;
-
-	case GAME_SIMON1DEMO:
-		string_ptr = getStringPtrByID(string_id);
-		break;
-
-	case GAME_SIMON1DOS:
+	} else {
 		string_ptr = getStringPtrByID(string_id);
-		break;
-	}
-
-	switch (num_1) {
-	case 1:
-		tv = &_threevalues_1;
-		break;
-	case 2:
-		tv = &_threevalues_2;
-		break;
-	case 101:
-		tv = &_threevalues_3;
-		break;
-	case 102:
-		tv = &_threevalues_4;
-		break;
-	default:
-		error("o_print_str, invalid value %d", num_1);
 	}
 
+	tv = getThreeValues(num_1);
 
 	switch (_game) {
 	case GAME_SIMON1TALKIE:

Index: simon.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- simon.h	3 Dec 2002 05:34:55 -0000	1.31
+++ simon.h	4 Dec 2002 22:40:16 -0000	1.32
@@ -474,6 +474,9 @@
 	void o_clear_vgapointer_entry(uint a);
 	void o_unk_186();
 	void o_fade_to_black();
+
+	
+	ThreeValues *getThreeValues(uint a);
 	void o_print_str();
 	void o_setup_cond_c();
 	void setup_cond_c_helper();





More information about the Scummvm-git-logs mailing list