[Scummvm-git-logs] scummvm master -> a4f9516bad65f592afc9258bb2a13e567df6ec84

dreammaster paulfgilbert at gmail.com
Tue Oct 27 04:01:59 UTC 2020


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:
a4f9516bad GLK: COMPREHEND: Fleshing out OO-Topos handleSpecialOpcode


Commit: a4f9516bad65f592afc9258bb2a13e567df6ec84
    https://github.com/scummvm/scummvm/commit/a4f9516bad65f592afc9258bb2a13e567df6ec84
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-10-26T20:56:12-07:00

Commit Message:
GLK: COMPREHEND: Fleshing out OO-Topos handleSpecialOpcode

Changed paths:
    engines/glk/comprehend/game.cpp
    engines/glk/comprehend/game.h
    engines/glk/comprehend/game_oo.cpp
    engines/glk/comprehend/game_oo.h


diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index c10e597795..acded887a8 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -789,7 +789,8 @@ void ComprehendGame::doBeforeTurn() {
 	// Run the each turn functions
 	eval_function(0, nullptr);
 
-	update();
+	if (!_ended)
+		update();
 }
 
 void ComprehendGame::doAfterTurn() {
diff --git a/engines/glk/comprehend/game.h b/engines/glk/comprehend/game.h
index 153e1d3677..b117d4303e 100644
--- a/engines/glk/comprehend/game.h
+++ b/engines/glk/comprehend/game.h
@@ -62,7 +62,7 @@ struct Sentence {
 };
 
 class ComprehendGame : public GameData {
-private:
+protected:
 	bool _ended;
 public:
 	const GameStrings *_gameStrings;
diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index 6c565e7e86..2658acaaa3 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -34,7 +34,11 @@ namespace Comprehend {
 #define OO_FLAG_WEARING_GOGGLES 0x1b
 #define OO_FLAG_FLASHLIGHT_ON 0x27
 
-OOToposGame::OOToposGame() : ComprehendGameV2() {
+static const GameStrings OO_STRINGS = {
+	EXTRA_STRING_TABLE(154)
+};
+
+OOToposGame::OOToposGame() : ComprehendGameV2(), _restartMode(RESTART_IMMEDIATE) {
 	_gameDataFile = "g0";
 
 	// Extra strings are (annoyingly) stored in the game binary
@@ -54,6 +58,7 @@ OOToposGame::OOToposGame() : ComprehendGameV2() {
 	_itemGraphicFiles.push_back("OD");
 
 	_colorTable = 1;
+	_gameStrings = &OO_STRINGS;
 }
 
 int OOToposGame::roomIsSpecial(unsigned room_index,
@@ -107,27 +112,90 @@ void OOToposGame::beforeTurn() {
 
 void OOToposGame::handleSpecialOpcode(uint8 operand) {
 	switch (operand) {
-	case 0x03:
-	// Game over - failure
-	// fall through
-	case 0x05:
-	// Won the game
-	// fall through
-	case 0x04:
-		// Restart game
+	case 1:
+		// Update guard location
+		randomizeGuardLocation();
+		break;
+
+	case 2:
+		_restartMode = RESTART_IMMEDIATE;
+		game_restart();
+		break;
+
+	case 3:
+		_restartMode = RESTART_WITH_MSG;
 		game_restart();
 		break;
 
-	case 0x06:
+	case 4:
+		_restartMode = RESTART_WITHOUT_MSG;
+		game_restart();
+		break;
+
+	case 5:
+		// Won the game, or fall-through from case 3
+		game_restart();
+		break;
+
+	case 6:
 		// Save game
 		game_save();
 		break;
 
-	case 0x07:
+	case 7:
 		// Restore game
 		game_restore();
 		break;
+
+	case 8:
+		// Computer response
+		computerResponse();
+		randomizeGuardLocation();
+		break;
+
+	case 9:
+		error("TODO: Special 9");
+
+	case 10:
+		error("TODO: Special 10");
+
+	default:
+		break;
+	}
+}
+
+bool OOToposGame::handle_restart() {
+	_ended = false;
+
+	if (_restartMode != RESTART_IMMEDIATE) {
+		if (_restartMode == RESTART_WITH_MSG)
+			console_println(stringLookup(_gameStrings->game_restart).c_str());
+
+		if (tolower(console_get_key()) != 'r') {
+			g_comprehend->quitGame();
+			return false;
+		}
 	}
+
+	loadGame();
+	_updateFlags = UPDATE_ALL;
+	return true;
+}
+
+void OOToposGame::randomizeGuardLocation() {
+	Item *item = get_item(22);
+	if (_flags[13] && item->_room != _currentRoom) {
+		if (getRandomNumber(255) > 128 && (_currentRoom == 3 || _currentRoom == 6))
+			item->_room = _currentRoom;
+	}
+}
+
+void OOToposGame::computerResponse() {
+	console_println(_strings2[145].c_str());
+	if (_flags[43])
+		console_println(_strings2[144].c_str());
+	else
+		console_println(_strings2[152].c_str());
 }
 
 } // namespace Comprehend
diff --git a/engines/glk/comprehend/game_oo.h b/engines/glk/comprehend/game_oo.h
index 7d37651f64..373c67d20d 100644
--- a/engines/glk/comprehend/game_oo.h
+++ b/engines/glk/comprehend/game_oo.h
@@ -28,7 +28,14 @@
 namespace Glk {
 namespace Comprehend {
 
+enum RestartMode { RESTART_IMMEDIATE, RESTART_WITH_MSG, RESTART_WITHOUT_MSG };
+
 class OOToposGame : public ComprehendGameV2 {
+private:
+	RestartMode _restartMode;
+
+	void randomizeGuardLocation();
+	void computerResponse();
 public:
 	OOToposGame();
 	~OOToposGame() override {}
@@ -36,6 +43,7 @@ public:
 	void beforeTurn() override;
 	int roomIsSpecial(unsigned room_index, unsigned *room_desc_string) override;
 	void handleSpecialOpcode(uint8 operand) override;
+	bool handle_restart() override;
 };
 
 } // namespace Comprehend




More information about the Scummvm-git-logs mailing list