[Scummvm-git-logs] scummvm master -> 053672bd885eecbbc6b8b14efa4097973b57a2b8

dreammaster paulfgilbert at gmail.com
Thu Jun 18 01:48:16 UTC 2020


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

Summary:
5de4ec7fcd GLK: COMPREHEND: Adding const qualifier to script methods
4f318995dd GLK: COMPREHEND: Change Function to an Array
1e30aab78a GLK: COMPREHEND: Added dump function debugger action
053672bd88 ULTIMA8: Fix compiler warning


Commit: 5de4ec7fcd1fce7af4af09e6bfc7bd8f1bf73dee
    https://github.com/scummvm/scummvm/commit/5de4ec7fcd1fce7af4af09e6bfc7bd8f1bf73dee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-17T18:43:17-07:00

Commit Message:
GLK: COMPREHEND: Adding const qualifier to script methods

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


diff --git a/engines/glk/comprehend/debugger_dumper.cpp b/engines/glk/comprehend/debugger_dumper.cpp
index c234bb2af9..fb0c18e7d5 100644
--- a/engines/glk/comprehend/debugger_dumper.cpp
+++ b/engines/glk/comprehend/debugger_dumper.cpp
@@ -104,7 +104,7 @@ DebuggerDumper::DebuggerDumper() : _game(nullptr) {
 }
 
 Common::String DebuggerDumper::dumpInstruction(ComprehendGame *game,
-        FunctionState *func_state, Instruction *instr) {
+        const FunctionState *func_state, const Instruction *instr) {
 	uint i;
 	int str_index, str_table;
 	uint8 *opcode_map, opcode;
diff --git a/engines/glk/comprehend/debugger_dumper.h b/engines/glk/comprehend/debugger_dumper.h
index 89eda38936..42d2cd62f4 100644
--- a/engines/glk/comprehend/debugger_dumper.h
+++ b/engines/glk/comprehend/debugger_dumper.h
@@ -64,7 +64,7 @@ public:
 	virtual ~DebuggerDumper() {}
 
 	Common::String dumpInstruction(ComprehendGame *game,
-	                               FunctionState *func_state, Instruction *instr);
+		const FunctionState *func_state, const Instruction *instr);
 
 	bool dumpGameData(ComprehendGame *game, const Common::String &type);
 };
diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index 22421a8d48..10eed196af 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -289,7 +289,7 @@ bool ComprehendGame::handle_restart() {
 	}
 }
 
-WordIndex *ComprehendGame::is_word_pair(Word *word1, Word *word2) {
+WordIndex *ComprehendGame::is_word_pair(const Word *word1, const Word *word2) {
 	WordMap *map;
 	uint i;
 
@@ -307,7 +307,7 @@ WordIndex *ComprehendGame::is_word_pair(Word *word1, Word *word2) {
 	return nullptr;
 }
 
-Item *ComprehendGame::get_item_by_noun(Word *noun) {
+Item *ComprehendGame::get_item_by_noun(const Word *noun) {
 	uint i;
 
 	if (!noun || !(noun->_type & WORD_TYPE_NOUN_MASK))
@@ -482,8 +482,7 @@ void ComprehendGame::move_object(Item *item, int new_room) {
 }
 
 void ComprehendGame::eval_instruction(FunctionState *func_state,
-                             Instruction *instr,
-                             Word *verb, Word *noun) {
+		const Instruction *instr, const Word *verb, const Word *noun) {
 	const byte *opcode_map = _opcodeMap;
 	Room *room;
 	Item *item;
@@ -943,7 +942,7 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
 			      index, _functions.size());
 
 		debugC(kDebugScripts, "Calling subfunction %.4x", index);
-		eval_function(&_functions[index], verb, noun);
+		eval_function(_functions[index], verb, noun);
 		break;
 
 	case OPCODE_TEST_FALSE:
@@ -1020,16 +1019,16 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
 	}
 }
 
-void ComprehendGame::eval_function(Function *func,
-                   Word *verb, Word *noun) {
+void ComprehendGame::eval_function(const Function &func,
+		const Word *verb, const Word *noun) {
 	FunctionState func_state;
 	uint i;
 
 	func_state._elseResult = true;
 	func_state._executed = false;
 
-	for (i = 0; i < func->_nr_instructions; i++) {
-		if (func_state._executed && !func->_instructions[i]._isCommand) {
+	for (i = 0; i < func._nr_instructions; i++) {
+		if (func_state._executed && !func._instructions[i]._isCommand) {
 			/*
 			 * At least one command has been executed and the
 			 * current instruction is a test. Exit the function.
@@ -1037,7 +1036,7 @@ void ComprehendGame::eval_function(Function *func,
 			break;
 		}
 
-		eval_instruction(&func_state, &func->_instructions[i],
+		eval_instruction(&func_state, &func._instructions[i],
 		                 verb, noun);
 	}
 }
@@ -1053,7 +1052,6 @@ void ComprehendGame::skip_non_whitespace(char **p) {
 }
 
 bool ComprehendGame::handle_sentence(Sentence *sentence) {
-	Function *func;
 	Action *action;
 	uint i, j;
 
@@ -1090,9 +1088,8 @@ bool ComprehendGame::handle_sentence(Sentence *sentence) {
 		}
 		if (j == action->_nr_words) {
 			/* Match */
-			func = &_functions[action->_function];
-			eval_function(func,
-			              &sentence->_words[0], &sentence->_words[1]);
+			const Function &func = _functions[action->_function];
+			eval_function(func, &sentence->_words[0], &sentence->_words[1]);
 			return true;
 		}
 	}
@@ -1164,7 +1161,7 @@ void ComprehendGame::doBeforeTurn() {
 	beforeTurn();
 
 	// Run the each turn functions
-	eval_function(&_functions[0], NULL, NULL);
+	eval_function(_functions[0], nullptr, nullptr);
 
 	update();
 }
diff --git a/engines/glk/comprehend/game.h b/engines/glk/comprehend/game.h
index 5fac93782a..e077adb23f 100644
--- a/engines/glk/comprehend/game.h
+++ b/engines/glk/comprehend/game.h
@@ -45,14 +45,14 @@ public:
 	const GameStrings *_gameStrings;
 
 private:
-	WordIndex *is_word_pair(Word *word1, Word *word2);
-	Item *get_item_by_noun(Word *noun);
+	WordIndex *is_word_pair(const Word *word1, const Word *word2);
+	Item *get_item_by_noun(const Word *noun);
 	void describe_objects_in_current_room();
 	void update();
 	void func_set_test_result(FunctionState *func_state, bool value);
 	size_t num_objects_in_room(int room);
-	void eval_instruction(FunctionState *func_state, Instruction *instr,
-		Word *verb, Word *noun);
+	void eval_instruction(FunctionState *func_state, const Instruction *instr,
+		const Word *verb, const Word *noun);
 	void skip_whitespace(char **p);
 	void skip_non_whitespace(char **p);
 	bool handle_sentence(Sentence *sentence);
@@ -81,7 +81,7 @@ protected:
 	 * is reached. Otherwise the commands instructions are skipped over and the
 	 * next test sequence (if there is one) is tried.
 	 */
-	void eval_function(Function *func, Word *verb, Word *noun);
+	void eval_function(const Function &func, const Word *verb, const Word *noun);
 
 	void parse_header(FileBuffer *fb) override {
 		GameData::parse_header(fb);


Commit: 4f318995dd8855a469648369a6a18fb99b3f7791
    https://github.com/scummvm/scummvm/commit/4f318995dd8855a469648369a6a18fb99b3f7791
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-17T18:43:17-07:00

Commit Message:
GLK: COMPREHEND: Change Function to an Array

Changed paths:
    engines/glk/comprehend/debugger_dumper.cpp
    engines/glk/comprehend/game.cpp
    engines/glk/comprehend/game_data.cpp
    engines/glk/comprehend/game_data.h


diff --git a/engines/glk/comprehend/debugger_dumper.cpp b/engines/glk/comprehend/debugger_dumper.cpp
index fb0c18e7d5..ff69f6147a 100644
--- a/engines/glk/comprehend/debugger_dumper.cpp
+++ b/engines/glk/comprehend/debugger_dumper.cpp
@@ -159,16 +159,15 @@ Common::String DebuggerDumper::dumpInstruction(ComprehendGame *game,
 }
 
 void DebuggerDumper::dumpFunctions() {
-	Function *func;
 	uint i, j;
 
 	print("Functions (%u entries)\n", _game->_functions.size());
 	for (i = 0; i < _game->_functions.size(); i++) {
-		func = &_game->_functions[i];
+		const Function &func = _game->_functions[i];
 
-		print("[%.4x] (%u instructions)\n", i, (uint)func->_nr_instructions);
-		for (j = 0; j < func->_nr_instructions; j++) {
-			Common::String line = dumpInstruction(_game, NULL, &func->_instructions[j]);
+		print("[%.4x] (%u instructions)\n", i, func.size());
+		for (j = 0; j < func.size(); j++) {
+			Common::String line = dumpInstruction(_game, NULL, &func[j]);
 			print("%s", line.c_str());
 		}
 		print("\n");
diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index 10eed196af..c626252e1b 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -1027,8 +1027,8 @@ void ComprehendGame::eval_function(const Function &func,
 	func_state._elseResult = true;
 	func_state._executed = false;
 
-	for (i = 0; i < func._nr_instructions; i++) {
-		if (func_state._executed && !func._instructions[i]._isCommand) {
+	for (i = 0; i < func.size(); i++) {
+		if (func_state._executed && !func[i]._isCommand) {
 			/*
 			 * At least one command has been executed and the
 			 * current instruction is a test. Exit the function.
@@ -1036,7 +1036,7 @@ void ComprehendGame::eval_function(const Function &func,
 			break;
 		}
 
-		eval_instruction(&func_state, &func._instructions[i],
+		eval_instruction(&func_state, &func[i],
 		                 verb, noun);
 	}
 }
diff --git a/engines/glk/comprehend/game_data.cpp b/engines/glk/comprehend/game_data.cpp
index 73fb3b595b..192c9a1595 100644
--- a/engines/glk/comprehend/game_data.cpp
+++ b/engines/glk/comprehend/game_data.cpp
@@ -121,14 +121,6 @@ void Instruction::clear() {
 
 /*-------------------------------------------------------*/
 
-void Function::clear() {
-	_nr_instructions = 0;
-	for (int idx = 0; idx < 0x100; ++idx)
-		_instructions[idx].clear();
-}
-
-/*-------------------------------------------------------*/
-
 void GameHeader::clear() {
 	magic = 0;
 	room_desc_table = 0;
@@ -205,8 +197,9 @@ uint8 GameData::parse_vm_instruction(FileBuffer *fb,
 	return instr->_opcode;
 }
 
+#define MAX_FUNCTION_SIZE 0x100
+
 void GameData::parse_function(FileBuffer *fb, Function *func) {
-	Instruction *instruction;
 	const uint8 *p;
 	uint8 opcode;
 
@@ -214,17 +207,18 @@ void GameData::parse_function(FileBuffer *fb, Function *func) {
 	if (!p)
 		error("bad function @ %.4x", fb->pos());
 
-	while (1) {
-		instruction = &func->_instructions[func->_nr_instructions];
+	for (;;) {
+		Instruction instruction;
 
-		opcode = parse_vm_instruction(fb, instruction);
+		opcode = parse_vm_instruction(fb, &instruction);
 		if (opcode == 0)
 			break;
 
-		func->_nr_instructions++;
-		if (func->_nr_instructions >= ARRAY_SIZE(func->_instructions))
-			error("Function has too many instructions");
+		func->push_back(instruction);
+		assert(func->size() <= MAX_FUNCTION_SIZE);
 	}
+
+	assert(fb->dataPtr() == (p + 1));
 }
 
 void GameData::parse_vm(FileBuffer *fb) {
@@ -234,7 +228,7 @@ void GameData::parse_vm(FileBuffer *fb) {
 		Function func;
 
 		parse_function(fb, &func);
-		if (func._nr_instructions == 0)
+		if (func.empty())
 			break;
 
 		_functions.push_back(func);
diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index 1c4bb37275..be1af9ea9e 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -287,16 +287,7 @@ struct Instruction {
 	void clear();
 };
 
-struct Function {
-	Instruction _instructions[0x100];
-	size_t _nr_instructions;
-
-	Function() {
-		clear();
-	}
-
-	void clear();
-};
+typedef Common::Array<Instruction> Function;
 
 typedef Common::StringArray StringTable;
 


Commit: 1e30aab78acf9b90896583c50342b77d1d5b0b43
    https://github.com/scummvm/scummvm/commit/1e30aab78acf9b90896583c50342b77d1d5b0b43
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-17T18:43:17-07:00

Commit Message:
GLK: COMPREHEND: Added dump function debugger action

Changed paths:
    engines/glk/comprehend/debugger.cpp
    engines/glk/comprehend/debugger_dumper.cpp
    engines/glk/comprehend/debugger_dumper.h


diff --git a/engines/glk/comprehend/debugger.cpp b/engines/glk/comprehend/debugger.cpp
index 8950abc861..000a2b237e 100644
--- a/engines/glk/comprehend/debugger.cpp
+++ b/engines/glk/comprehend/debugger.cpp
@@ -52,10 +52,11 @@ void Debugger::print(const char *fmt, ...) {
 }
 
 bool Debugger::cmdDump(int argc, const char **argv) {
-	Common::String param = (argc == 2) ? argv[1] : "";
+	Common::String type = (argc >= 2) ? argv[1] : "";
+	uint param = (argc == 3) ? strToInt(argv[2]) : 0;
 	ComprehendGame *game = g_comprehend->_game;
 
-	if (!dumpGameData(game, param))
+	if (!dumpGameData(game, type, param))
 		debugPrintf("Unknown dump option\n");
 
 	return true;
diff --git a/engines/glk/comprehend/debugger_dumper.cpp b/engines/glk/comprehend/debugger_dumper.cpp
index ff69f6147a..53f3bd504f 100644
--- a/engines/glk/comprehend/debugger_dumper.cpp
+++ b/engines/glk/comprehend/debugger_dumper.cpp
@@ -159,19 +159,23 @@ Common::String DebuggerDumper::dumpInstruction(ComprehendGame *game,
 }
 
 void DebuggerDumper::dumpFunctions() {
-	uint i, j;
+	uint i;
 
 	print("Functions (%u entries)\n", _game->_functions.size());
-	for (i = 0; i < _game->_functions.size(); i++) {
-		const Function &func = _game->_functions[i];
+	for (i = 0; i < _game->_functions.size(); i++)
+		dumpFunction(i);
+}
 
-		print("[%.4x] (%u instructions)\n", i, func.size());
-		for (j = 0; j < func.size(); j++) {
-			Common::String line = dumpInstruction(_game, NULL, &func[j]);
-			print("%s", line.c_str());
-		}
-		print("\n");
+void DebuggerDumper::dumpFunction(uint functionNum) {
+	const Function &func = _game->_functions[functionNum];
+
+	print("[%.4x] (%u instructions)\n", functionNum, func.size());
+	for (uint i = 0; i < func.size(); i++) {
+		Common::String line = dumpInstruction(_game, NULL, &func[i]);
+		print("%s", line.c_str());
 	}
+
+	print("\n");
 }
 
 void DebuggerDumper::dumpActionTable() {
@@ -424,7 +428,7 @@ void DebuggerDumper::dumpState() {
 	print("\n");
 }
 
-bool DebuggerDumper::dumpGameData(ComprehendGame *game, const Common::String &type) {
+bool DebuggerDumper::dumpGameData(ComprehendGame *game, const Common::String &type, int param) {
 	_game = game;
 
 	if (type == "header")
@@ -445,6 +449,8 @@ bool DebuggerDumper::dumpGameData(ComprehendGame *game, const Common::String &ty
 		dumpActionTable();
 	else if (type == "functions")
 		dumpFunctions();
+	else if (type == "function")
+		dumpFunction(param);
 	else if (type == "replace_words")
 		dumpReplaceWords();
 	else if (type == "state")
diff --git a/engines/glk/comprehend/debugger_dumper.h b/engines/glk/comprehend/debugger_dumper.h
index 42d2cd62f4..5a952f22ad 100644
--- a/engines/glk/comprehend/debugger_dumper.h
+++ b/engines/glk/comprehend/debugger_dumper.h
@@ -40,6 +40,7 @@ private:
 
 private:
 	void dumpFunctions();
+	void dumpFunction(uint functionNum);
 	void dumpActionTable();
 	static int wordIndexCompare(const void *a, const void *b);
 	void dumpDictionary();
@@ -66,7 +67,8 @@ public:
 	Common::String dumpInstruction(ComprehendGame *game,
 		const FunctionState *func_state, const Instruction *instr);
 
-	bool dumpGameData(ComprehendGame *game, const Common::String &type);
+	bool dumpGameData(ComprehendGame *game, const Common::String &type,
+		int param = 0);
 };
 
 } // namespace Comprehend


Commit: 053672bd885eecbbc6b8b14efa4097973b57a2b8
    https://github.com/scummvm/scummvm/commit/053672bd885eecbbc6b8b14efa4097973b57a2b8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-17T18:48:01-07:00

Commit Message:
ULTIMA8: Fix compiler warning

Changed paths:
    engines/ultima/ultima8/audio/audio_process.cpp


diff --git a/engines/ultima/ultima8/audio/audio_process.cpp b/engines/ultima/ultima8/audio/audio_process.cpp
index 00408a563c..c1b1e44e0f 100644
--- a/engines/ultima/ultima8/audio/audio_process.cpp
+++ b/engines/ultima/ultima8/audio/audio_process.cpp
@@ -636,7 +636,7 @@ uint32 AudioProcess::I_stopSFXCru(const uint8 *args, unsigned int argsize) {
 	return 0;
 }
 
-uint32 AudioProcess::I_stopAllSFX(const uint8 */*args*/, unsigned int /*argsize*/) {
+uint32 AudioProcess::I_stopAllSFX(const uint8 * /*args*/, unsigned int /*argsize*/) {
 	AudioProcess *ap = AudioProcess::get_instance();
 	// Not *exactly* the same, but close enough for this intrinsic.
 	if (ap) ap->stopAllExceptSpeech();




More information about the Scummvm-git-logs mailing list