[Scummvm-cvs-logs] scummvm master -> 9dcb5594888797143e8ec3eaee213d3c42f2c558

Strangerke Strangerke at scummvm.org
Sat Mar 22 11:44:35 CET 2014


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:
9dcb559488 CINE: Add a safeguard, split makeCommandLine() per game type


Commit: 9dcb5594888797143e8ec3eaee213d3c42f2c558
    https://github.com/scummvm/scummvm/commit/9dcb5594888797143e8ec3eaee213d3c42f2c558
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T11:42:06+01:00

Commit Message:
CINE: Add a safeguard, split makeCommandLine() per game type

Changed paths:
    engines/cine/various.cpp
    engines/cine/various.h



diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index aa1c22c..8687699 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -557,12 +557,20 @@ int16 selectSubObject(int16 x, int16 y, int16 param) {
 		}
 	}
 
+	if (selectedObject >= 20)
+		error("Invalid value for selectedObject: %d", selectedObject);
 	return objListTab[selectedObject];
 }
 
-// TODO: Make separate functions for Future Wars's and Operation Stealth's version of this function, this is getting too messy
-// TODO: Add support for using the different prepositions for different verbs (Doesn't work currently)
 void makeCommandLine() {
+	if (g_cine->getGameType() == Cine::GType_FW)
+		makeFWCommandLine();
+	else
+		makeOSCommandLine();
+}
+
+// TODO: Add support for using the different prepositions for different verbs (Doesn't work currently)
+void makeOSCommandLine() {
 	uint16 x, y;
 
 	commandVar1 = 0;
@@ -578,28 +586,16 @@ void makeCommandLine() {
 		int16 si;
 
 		getMouseData(mouseUpdateStatus, &dummyU16, &x, &y);
-
-		if (g_cine->getGameType() == Cine::GType_FW) {
-			si = selectSubObject(x, y + 8, -2);
-		} else {
-			si = selectSubObject(x, y + 8, -subObjectUseTable[playerCommand]);
-		}
+		si = selectSubObject(x, y + 8, -subObjectUseTable[playerCommand]);
 
 		if (si < 0) {
-			if (g_cine->getGameType() == Cine::GType_OS) {
-				canUseOnObject = 0;
-			} else { // Future Wars
-				playerCommand = -1;
-				g_cine->_commandBuffer = "";
-			}
+			canUseOnObject = 0;
 		} else {
-			if (g_cine->getGameType() == Cine::GType_OS) {
-				if (si >= 8000) {
-					si -= 8000;
-					canUseOnObject = canUseOnItemTable[playerCommand];
-				} else {
-					canUseOnObject = 0;
-				}
+			if (si >= 8000) {
+				si -= 8000;
+				canUseOnObject = canUseOnItemTable[playerCommand];
+			} else {
+				canUseOnObject = 0;
 			}
 
 			commandVar3[0] = si;
@@ -607,27 +603,21 @@ void makeCommandLine() {
 			g_cine->_commandBuffer += " ";
 			g_cine->_commandBuffer += g_cine->_objectTable[commandVar3[0]].name;
 			g_cine->_commandBuffer += " ";
-			if (g_cine->getGameType() == Cine::GType_OS) {
-				g_cine->_commandBuffer += commandPrepositionTable[playerCommand];
-			} else { // Future Wars
-				g_cine->_commandBuffer += defaultCommandPreposition;
-			}
+			g_cine->_commandBuffer += commandPrepositionTable[playerCommand];
 		}
 	}
 
-	if (g_cine->getGameType() == Cine::GType_OS || !(playerCommand != -1 && choiceResultTable[playerCommand] == 2)) {
-		if (playerCommand == 2) {
-			getMouseData(mouseUpdateStatus, &dummyU16, &x, &y);
-			CursorMan.showMouse(false);
-			processInventory(x, y + 8);
-			playerCommand = -1;
-			commandVar1 = 0;
-			g_cine->_commandBuffer = "";
-			CursorMan.showMouse(true);
-		}
+	if (playerCommand == 2) {
+		getMouseData(mouseUpdateStatus, &dummyU16, &x, &y);
+		CursorMan.showMouse(false);
+		processInventory(x, y + 8);
+		playerCommand = -1;
+		commandVar1 = 0;
+		g_cine->_commandBuffer = "";
+		CursorMan.showMouse(true);
 	}
 
-	if (g_cine->getGameType() == Cine::GType_OS && playerCommand != 2) {
+	if (playerCommand != 2) {
 		if (playerCommand != -1 && canUseOnObject != 0) { // call use on sub object
 			int16 si;
 
@@ -665,7 +655,55 @@ void makeCommandLine() {
 		}
 	}
 
-	if (g_cine->getGameType() == Cine::GType_OS || !disableSystemMenu) {
+	isDrawCommandEnabled = 1;
+	renderer->setCommand(g_cine->_commandBuffer);
+}
+
+// TODO: Add support for using the different prepositions for different verbs (Doesn't work currently)
+void makeFWCommandLine() {
+	uint16 x, y;
+
+	commandVar1 = 0;
+	commandVar2 = -10;
+
+	if (playerCommand != -1) {
+		g_cine->_commandBuffer = defaultActionCommand[playerCommand];
+	} else {
+		g_cine->_commandBuffer = "";
+	}
+
+	if ((playerCommand != -1) && (choiceResultTable[playerCommand] == 2)) { // need object selection?
+		int16 si;
+
+		getMouseData(mouseUpdateStatus, &dummyU16, &x, &y);
+		si = selectSubObject(x, y + 8, -2);
+
+		if (si < 0) {
+			playerCommand = -1;
+			g_cine->_commandBuffer = "";
+		} else {
+			commandVar3[0] = si;
+			commandVar1 = 1;
+			g_cine->_commandBuffer += " ";
+			g_cine->_commandBuffer += g_cine->_objectTable[commandVar3[0]].name;
+			g_cine->_commandBuffer += " ";
+			g_cine->_commandBuffer += defaultCommandPreposition;
+		}
+	}
+
+	if (!(playerCommand != -1 && choiceResultTable[playerCommand] == 2)) {
+		if (playerCommand == 2) {
+			getMouseData(mouseUpdateStatus, &dummyU16, &x, &y);
+			CursorMan.showMouse(false);
+			processInventory(x, y + 8);
+			playerCommand = -1;
+			commandVar1 = 0;
+			g_cine->_commandBuffer = "";
+			CursorMan.showMouse(true);
+		}
+	}
+
+	if (!disableSystemMenu) {
 		isDrawCommandEnabled = 1;
 		renderer->setCommand(g_cine->_commandBuffer);
 	}
diff --git a/engines/cine/various.h b/engines/cine/various.h
index 04f2d47..eb63129 100644
--- a/engines/cine/various.h
+++ b/engines/cine/various.h
@@ -37,6 +37,8 @@ void initLanguage(Common::Language lang);
 
 int16 makeMenuChoice(const CommandeType commandList[], uint16 height, uint16 X, uint16 Y, uint16 width, bool recheckValue = false);
 void makeCommandLine();
+void makeFWCommandLine();
+void makeOSCommandLine();
 void makeActionMenu();
 void waitPlayerInput();
 void setTextWindow(uint16 param1, uint16 param2, uint16 param3, uint16 param4);






More information about the Scummvm-git-logs mailing list