[Scummvm-git-logs] scummvm master -> 54e16ae6dd6601902c214c7a42d54f78a5cbf9da

dreammaster paulfgilbert at gmail.com
Wed Jun 3 02:09:52 UTC 2020


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

Summary:
99dffa8609 GLK: COMPREHEND: Fix naming of game virtual methods
54e16ae6dd GLK: COMPREHEND: Cleanup of game classes


Commit: 99dffa860931e45e13da64205ea4a12b6d7e1a8b
    https://github.com/scummvm/scummvm/commit/99dffa860931e45e13da64205ea4a12b6d7e1a8b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-02T18:40:33-07:00

Commit Message:
GLK: COMPREHEND: Fix naming of game virtual methods

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


diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index 06b04fb4a9..8fb88b9a34 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -333,7 +333,7 @@ static void update_graphics(ComprehendGame *game) {
 	if (!g_comprehend->_graphicsEnabled)
 		return;
 
-	type = game->room_is_special(game->_currentRoom, NULL);
+	type = game->roomIsSpecial(game->_currentRoom, NULL);
 
 	switch (type) {
 	case ROOM_IS_DARK:
@@ -400,7 +400,7 @@ static void update(ComprehendGame *game) {
 
 	/* Check if the room is special (dark, too bright, etc) */
 	room_desc_string = room->string_desc;
-	room_type = game->room_is_special(game->_currentRoom,
+	room_type = game->roomIsSpecial(game->_currentRoom,
 	                                  &room_desc_string);
 
 	if (game->_updateFlags & UPDATE_ROOM_DESC)
@@ -1011,7 +1011,7 @@ static void eval_instruction(ComprehendGame *game,
 
 	case OPCODE_SPECIAL:
 		/* Game specific opcode */
-		game->handle_special_opcode(instr->operand[0]);
+		game->handleSpecialOpcode(instr->operand[0]);
 		break;
 
 	default:
@@ -1176,9 +1176,9 @@ static void read_sentence(ComprehendGame *game, char **line,
 	*line = p;
 }
 
-static void before_turn(ComprehendGame *game) {
+static void beforeTurn(ComprehendGame *game) {
 	// Run the game specific before turn bits
-	game->before_turn();
+	game->beforeTurn();
 
 	// Run the each turn functions
 	eval_function(game, &game->_functions[0], NULL, NULL);
@@ -1188,7 +1188,7 @@ static void before_turn(ComprehendGame *game) {
 
 static void after_turn(ComprehendGame *game) {
 	// Do post turn game specific bits
-	game->after_turn();
+	game->afterTurn();
 }
 
 static void read_input(ComprehendGame *game) {
@@ -1196,8 +1196,8 @@ static void read_input(ComprehendGame *game) {
 	char *line = NULL, buffer[1024];
 	bool handled;
 
-	game->before_prompt();
-	before_turn(game);
+	game->beforePrompt();
+	beforeTurn(game);
 
 	do {
 		g_comprehend->print("> ");
@@ -1221,14 +1221,14 @@ static void read_input(ComprehendGame *game) {
 		line++;
 
 		if (handled)
-			before_turn(game);
+			beforeTurn(game);
 	}
 }
 
 void comprehend_play_game(ComprehendGame *game) {
 	console_init();
 
-	game->before_game();
+	game->beforeGame();
 
 	game->_updateFlags = (uint)UPDATE_ALL;
 	while (!g_comprehend->shouldQuit())
diff --git a/engines/glk/comprehend/game.h b/engines/glk/comprehend/game.h
index 8e82a44dd0..6c9fcb8f00 100644
--- a/engines/glk/comprehend/game.h
+++ b/engines/glk/comprehend/game.h
@@ -50,19 +50,18 @@ public:
 	ComprehendGame();
 	virtual ~ComprehendGame();
 
-	virtual void before_game() {}
-	virtual void before_prompt() {}
-	virtual bool before_turn() {
+	virtual void beforeGame() {}
+	virtual void beforePrompt() {}
+	virtual bool beforeTurn() {
 		return false;
 	}
-	virtual bool after_turn() {
+	virtual bool afterTurn() {
 		return false;
 	}
-	virtual int room_is_special(unsigned room_index,
-		unsigned *room_desc_string) {
+	virtual int roomIsSpecial(unsigned room_index, unsigned *room_desc_string) {
 		return ROOM_IS_NORMAL;
 	}
-	virtual void handle_special_opcode(uint8 operand) {}
+	virtual void handleSpecialOpcode(uint8 operand) {}
 
 	void synchronizeSave(Common::Serializer &s);
 
diff --git a/engines/glk/comprehend/game_cc.cpp b/engines/glk/comprehend/game_cc.cpp
index 401cf420db..a0d8da8602 100644
--- a/engines/glk/comprehend/game_cc.cpp
+++ b/engines/glk/comprehend/game_cc.cpp
@@ -50,7 +50,7 @@ void CrimsonCrownGame::setupDisk(uint diskNum) {
 		_gameStrings = nullptr;
 }
 
-void CrimsonCrownGame::handle_special_opcode(uint8 operand) {
+void CrimsonCrownGame::handleSpecialOpcode(uint8 operand) {
 	switch (operand) {
 	case 0x01:
 		// Enter the Vampire's throne room
@@ -92,7 +92,7 @@ void CrimsonCrownGame::handle_special_opcode(uint8 operand) {
 	}
 }
 
-void CrimsonCrownGame::before_prompt() {
+void CrimsonCrownGame::beforePrompt() {
 	// Clear the Sabrina/Erik action flags
 	_flags[0xa] = 0;
 	_flags[0xb] = 0;
diff --git a/engines/glk/comprehend/game_cc.h b/engines/glk/comprehend/game_cc.h
index d69eab2b66..cadca2f93e 100644
--- a/engines/glk/comprehend/game_cc.h
+++ b/engines/glk/comprehend/game_cc.h
@@ -36,8 +36,8 @@ public:
 	CrimsonCrownGame();
 	~CrimsonCrownGame() override {}
 
-	void before_prompt() override;
-	void handle_special_opcode(uint8 operand) override;
+	void beforePrompt() override;
+	void handleSpecialOpcode(uint8 operand) override;
 
 	void setupDisk(uint diskNum);
 };
diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index bba0a7fc89..4e246425db 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -56,7 +56,7 @@ OOToposGame::OOToposGame() : ComprehendGame() {
 	_colorTable = 1;
 }
 
-int OOToposGame::room_is_special(unsigned room_index,
+int OOToposGame::roomIsSpecial(unsigned room_index,
                               unsigned *room_desc_string) {
 	Room *room = &_rooms[room_index];
 
@@ -79,7 +79,7 @@ int OOToposGame::room_is_special(unsigned room_index,
 	return ROOM_IS_NORMAL;
 }
 
-bool OOToposGame::before_turn() {
+bool OOToposGame::beforeTurn() {
 	/* FIXME - probably doesn't work correctly with restored games */
 	static bool flashlight_was_on = false, googles_were_worn = false;
 	Room *room = &_rooms[_currentRoom];
@@ -107,7 +107,7 @@ bool OOToposGame::before_turn() {
 	return false;
 }
 
-void OOToposGame::handle_special_opcode(uint8 operand) {
+void OOToposGame::handleSpecialOpcode(uint8 operand) {
 	switch (operand) {
 	case 0x03:
 		/* Game over - failure */
diff --git a/engines/glk/comprehend/game_oo.h b/engines/glk/comprehend/game_oo.h
index bfac91ec9b..c24efb4149 100644
--- a/engines/glk/comprehend/game_oo.h
+++ b/engines/glk/comprehend/game_oo.h
@@ -33,9 +33,9 @@ public:
 	OOToposGame();
 	~OOToposGame() override {}
 
-	bool before_turn() override;
-	int room_is_special(unsigned room_index, unsigned *room_desc_string) override;
-	void handle_special_opcode(uint8 operand) override;
+	bool beforeTurn() override;
+	int roomIsSpecial(unsigned room_index, unsigned *room_desc_string) override;
+	void handleSpecialOpcode(uint8 operand) override;
 };
 
 } // namespace Comprehend
diff --git a/engines/glk/comprehend/game_tr.cpp b/engines/glk/comprehend/game_tr.cpp
index ea2209198a..5bf981e75b 100644
--- a/engines/glk/comprehend/game_tr.cpp
+++ b/engines/glk/comprehend/game_tr.cpp
@@ -93,7 +93,7 @@ void TransylvaniaGame::update_monster(const TransylvaniaMonster *monster_info) {
 	}
 }
 
-int TransylvaniaGame::room_is_special(unsigned room_index,
+int TransylvaniaGame::roomIsSpecial(unsigned room_index,
 			      unsigned *room_desc_string)
 {
 	Room *room = &_rooms[room_index];
@@ -107,13 +107,13 @@ int TransylvaniaGame::room_is_special(unsigned room_index,
 	return ROOM_IS_NORMAL;
 }
 
-bool TransylvaniaGame::before_turn() {
+bool TransylvaniaGame::beforeTurn() {
 	update_monster(&WEREWOLF);
 	update_monster(&VAMPIRE);
 	return false;
 }
 
-void TransylvaniaGame::handle_special_opcode(uint8 operand)
+void TransylvaniaGame::handleSpecialOpcode(uint8 operand)
 {
 	switch (operand) {
 	case 0x01:
@@ -156,7 +156,7 @@ void TransylvaniaGame::handle_special_opcode(uint8 operand)
 	}
 }
 
-void TransylvaniaGame::before_game() {
+void TransylvaniaGame::beforeGame() {
 	char buffer[128];
 
 	// Draw the title
diff --git a/engines/glk/comprehend/game_tr.h b/engines/glk/comprehend/game_tr.h
index ef20981efb..12e23d4950 100644
--- a/engines/glk/comprehend/game_tr.h
+++ b/engines/glk/comprehend/game_tr.h
@@ -47,10 +47,10 @@ public:
 	TransylvaniaGame();
 	~TransylvaniaGame() override {}
 
-	void before_game() override;
-	bool before_turn() override;
-	int room_is_special(unsigned room_index, unsigned *room_desc_string) override;
-	void handle_special_opcode(uint8 operand) override;
+	void beforeGame() override;
+	bool beforeTurn() override;
+	int roomIsSpecial(unsigned room_index, unsigned *room_desc_string) override;
+	void handleSpecialOpcode(uint8 operand) override;
 };
 
 } // namespace Comprehend


Commit: 54e16ae6dd6601902c214c7a42d54f78a5cbf9da
    https://github.com/scummvm/scummvm/commit/54e16ae6dd6601902c214c7a42d54f78a5cbf9da
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-02T19:09:39-07:00

Commit Message:
GLK: COMPREHEND: Cleanup of game classes

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


diff --git a/engines/glk/comprehend/game.h b/engines/glk/comprehend/game.h
index 6c9fcb8f00..6fa667a314 100644
--- a/engines/glk/comprehend/game.h
+++ b/engines/glk/comprehend/game.h
@@ -35,6 +35,8 @@ namespace Comprehend {
 #define ROOM_IS_DARK 1
 #define ROOM_IS_TOO_BRIGHT 2
 
+struct GameStrings;
+
 class ComprehendGame : public GameInfo, public OpcodeMap {
 public:
 	Common::String _gameDataFile;
@@ -44,7 +46,7 @@ public:
 	Common::String _titleGraphicFile;
 	unsigned _colorTable;
 
-	struct GameStrings *_gameStrings;
+	const GameStrings *_gameStrings;
 
 public:
 	ComprehendGame();
diff --git a/engines/glk/comprehend/game_cc.cpp b/engines/glk/comprehend/game_cc.cpp
index a0d8da8602..fe1c2c1f85 100644
--- a/engines/glk/comprehend/game_cc.cpp
+++ b/engines/glk/comprehend/game_cc.cpp
@@ -26,7 +26,7 @@
 namespace Glk {
 namespace Comprehend {
 
-static GameStrings CC1_STRINGS = {0x9};
+static const GameStrings CC1_STRINGS = {0x9};
 
 CrimsonCrownGame::CrimsonCrownGame() : ComprehendGame() {
 	setupDisk(1);
@@ -59,12 +59,8 @@ void CrimsonCrownGame::handleSpecialOpcode(uint8 operand) {
 		break;
 
 	case 0x03:
-		/*
-		 * Game over - failure.
-		 *
-		 * FIXME - If playing the second disk this should restart
-		 *         from the beginning of the first disk.
-		 */
+		// Game over - failure
+		setupDisk(1);
 		game_restart(this);
 		break;
 
diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index 420888e1fd..6f887135aa 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -255,7 +255,7 @@ struct StringFile {
 	uint32 base_offset;
 	uint32 end_offset;
 
-	StringFile() : filename(nullptr), base_offset(0), end_offset(0) {}
+	StringFile() : base_offset(0), end_offset(0) {}
 	StringFile(const Common::String &fname, uint32 baseOfs, uint32 endO = 0) : filename(fname), base_offset(baseOfs), end_offset(endO) {
 	}
 };
diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index 4e246425db..4283488203 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -57,22 +57,22 @@ OOToposGame::OOToposGame() : ComprehendGame() {
 }
 
 int OOToposGame::roomIsSpecial(unsigned room_index,
-                              unsigned *room_desc_string) {
+                              unsigned *roomDescString) {
 	Room *room = &_rooms[room_index];
 
-	/* Is the room dark */
+	// Is the room dark
 	if ((room->flags & OO_ROOM_FLAG_DARK) &&
 	    !(_flags[OO_FLAG_FLASHLIGHT_ON])) {
-		if (room_desc_string)
-			*room_desc_string = 0xb3;
+		if (roomDescString)
+			*roomDescString = 0xb3;
 		return ROOM_IS_DARK;
 	}
 
-	/* Is the room too bright */
+	// Is the room too bright
 	if (room_index == OO_BRIGHT_ROOM &&
 	    !_flags[OO_FLAG_WEARING_GOGGLES]) {
-		if (room_desc_string)
-			*room_desc_string = 0x1c;
+		if (roomDescString)
+			*roomDescString = 0x1c;
 		return ROOM_IS_TOO_BRIGHT;
 	}
 
@@ -80,7 +80,7 @@ int OOToposGame::roomIsSpecial(unsigned room_index,
 }
 
 bool OOToposGame::beforeTurn() {
-	/* FIXME - probably doesn't work correctly with restored games */
+	// FIXME: Probably doesn't work correctly with restored games
 	static bool flashlight_was_on = false, googles_were_worn = false;
 	Room *room = &_rooms[_currentRoom];
 
@@ -110,21 +110,23 @@ bool OOToposGame::beforeTurn() {
 void OOToposGame::handleSpecialOpcode(uint8 operand) {
 	switch (operand) {
 	case 0x03:
-		/* Game over - failure */
+		// Game over - failure
+		// fall through
 	case 0x05:
-		/* Won the game */
+		// Won the game
+		// fall through
 	case 0x04:
-		/* Restart game */
+		// Restart game
 		game_restart(this);
 		break;
 
 	case 0x06:
-		/* Save game */
+		// Save game
 		game_save(this);
 		break;
 
 	case 0x07:
-		/* Restore game */
+		// Restore game
 		game_restore(this);
 		break;
 	}
diff --git a/engines/glk/comprehend/game_tr.cpp b/engines/glk/comprehend/game_tr.cpp
index 5bf981e75b..06953dc3de 100644
--- a/engines/glk/comprehend/game_tr.cpp
+++ b/engines/glk/comprehend/game_tr.cpp
@@ -36,7 +36,7 @@ const TransylvaniaMonster TransylvaniaGame::VAMPIRE = {
 	0x26, 5, (1 << 7), 0, 5
 };
 
-static GameStrings TR_STRINGS = {
+static const GameStrings TR_STRINGS = {
     EXTRA_STRING_TABLE(0x8a)
 };
 
@@ -62,7 +62,7 @@ TransylvaniaGame::TransylvaniaGame() : ComprehendGame() {
 	_gameStrings = &TR_STRINGS;
 }
 
-void TransylvaniaGame::update_monster(const TransylvaniaMonster *monster_info) {
+void TransylvaniaGame::updateMonster(const TransylvaniaMonster *monsterInfo) {
 	Item *monster;
 	Room *room;
 	uint16 turn_count;
@@ -70,21 +70,21 @@ void TransylvaniaGame::update_monster(const TransylvaniaMonster *monster_info) {
 	room = &_rooms[_currentRoom];
 	turn_count = _variables[VAR_TURN_COUNT];
 
-	monster = get_item(this, monster_info->object);
+	monster = get_item(this, monsterInfo->object);
 	if (monster->room == _currentRoom) {
-		/* The monster is in the current room - leave it there */
+		// The monster is in the current room - leave it there
 		return;
 	}
 
-	if ((room->flags & monster_info->room_allow_flag) &&
-	    !_flags[monster_info->dead_flag] &&
-	    turn_count > monster_info->min_turns_before) {
+	if ((room->flags & monsterInfo->room_allow_flag) &&
+	    !_flags[monsterInfo->dead_flag] &&
+	    turn_count > monsterInfo->min_turns_before) {
 		/*
 		 * The monster is alive and allowed to move to the current
 		 * room. Randomly decide whether on not to. If not, move
 		 * it back to limbo.
 		 */
-		if ((g_comprehend->getRandomNumber(0x7fffffff) % monster_info->randomness) == 0) {
+		if ((g_comprehend->getRandomNumber(0x7fffffff) % monsterInfo->randomness) == 0) {
 			move_object(this, monster, _currentRoom);
 			_variables[0xf] = turn_count + 1;
 		} else {
@@ -94,13 +94,13 @@ void TransylvaniaGame::update_monster(const TransylvaniaMonster *monster_info) {
 }
 
 int TransylvaniaGame::roomIsSpecial(unsigned room_index,
-			      unsigned *room_desc_string)
+			      unsigned *roomDescString)
 {
 	Room *room = &_rooms[room_index];
 
 	if (room_index == 0x28) {
-		if (room_desc_string)
-			*room_desc_string = room->string_desc;
+		if (roomDescString)
+			*roomDescString = room->string_desc;
 		return ROOM_IS_DARK;
 	}
 
@@ -108,8 +108,8 @@ int TransylvaniaGame::roomIsSpecial(unsigned room_index,
 }
 
 bool TransylvaniaGame::beforeTurn() {
-	update_monster(&WEREWOLF);
-	update_monster(&VAMPIRE);
+	updateMonster(&WEREWOLF);
+	updateMonster(&VAMPIRE);
 	return false;
 }
 
@@ -117,14 +117,11 @@ void TransylvaniaGame::handleSpecialOpcode(uint8 operand)
 {
 	switch (operand) {
 	case 0x01:
-		/*
-		 * FIXME - Called when the mice are dropped and the cat chases
-		 *         them.
-		 */
+		// FIXME: Called when the mice are dropped and the cat chases them.
 		break;
 
 	case 0x02:
-		/* FIXME - Called when the gun is fired */
+		// FIXME: Called when the gun is fired
 		break;
 
 	case 0x06:
@@ -136,11 +133,13 @@ void TransylvaniaGame::handleSpecialOpcode(uint8 operand)
 		break;
 
 	case 0x03:
-		/* Game over - failure */
+		// Game over - failure
+		// fall through
 	case 0x05:
-		/* Won the game */
+		// Won the game
+		// fall through
 	case 0x08:
-		/* Restart game */
+		// Restart game
 		game_restart(this);
 		break;
 
diff --git a/engines/glk/comprehend/game_tr.h b/engines/glk/comprehend/game_tr.h
index 12e23d4950..1de67d729e 100644
--- a/engines/glk/comprehend/game_tr.h
+++ b/engines/glk/comprehend/game_tr.h
@@ -41,7 +41,7 @@ private:
 	static const TransylvaniaMonster WEREWOLF;
 	static const TransylvaniaMonster VAMPIRE;
 
-	void update_monster(const TransylvaniaMonster *monster_info);
+	void updateMonster(const TransylvaniaMonster *monsterInfo);
 
 public:
 	TransylvaniaGame();
@@ -49,7 +49,7 @@ public:
 
 	void beforeGame() override;
 	bool beforeTurn() override;
-	int roomIsSpecial(unsigned room_index, unsigned *room_desc_string) override;
+	int roomIsSpecial(unsigned room_index, unsigned *roomDescString) override;
 	void handleSpecialOpcode(uint8 operand) override;
 };
 




More information about the Scummvm-git-logs mailing list