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

scemino noreply at scummvm.org
Tue May 28 20:37:03 UTC 2024


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

Summary:
192a253322 DIRECTOR: Fix crash in byte code view
71a24ac475 DIRECTOR: Fix invalid indentation with case statement
f9aaf083ff DIRECTOR: Fix code viewer with D5


Commit: 192a25332220ef031bc0fcd1150b9ed06474ec21
    https://github.com/scummvm/scummvm/commit/192a25332220ef031bc0fcd1150b9ed06474ec21
Author: scemino (scemino74 at gmail.com)
Date: 2024-05-28T22:36:53+02:00

Commit Message:
DIRECTOR: Fix crash in byte code view

Changed paths:
    engines/director/debugtools.cpp


diff --git a/engines/director/debugtools.cpp b/engines/director/debugtools.cpp
index ad9c41d9642..9353006802a 100644
--- a/engines/director/debugtools.cpp
+++ b/engines/director/debugtools.cpp
@@ -1466,31 +1466,29 @@ private:
 	}
 
 	void byteCode(const LingoDec::HandlerNode &node) {
-		LingoDec::Handler *handler = node.handler;
-		bool isMethod = handler->script->isFactory();
-
-		if (!handler->isGenericEvent) {
+		bool isMethod = _script.isMethod;
+		if (!_script.isGenericEvent) {
 			Common::String code;
 			if (isMethod) {
 				code += "method ";
 			} else {
 				code += "on ";
 			}
-			code += handler->name;
-			if (handler->argumentNames.size() > 0) {
+			code += _script.handlerId;
+			if (_script.argumentNames.size() > 0) {
 				code += " ";
-				for (size_t i = 0; i < handler->argumentNames.size(); i++) {
+				for (size_t i = 0; i < _script.argumentNames.size(); i++) {
 					if (i > 0)
 						code += ", ";
-					code += handler->argumentNames[i];
+					code += _script.argumentNames[i];
 				}
 			}
 			writeByteCode(0, code);
 		}
-		for (uint i = 0; i < handler->bytecodeArray.size(); i++) {
+		for (uint i = 0; i < _script.bytecodeArray.size(); i++) {
 			LingoDec::CodeWriterVisitor code(_dot, true);
 			code.indent();
-			auto &bytecode = handler->bytecodeArray[i];
+			auto &bytecode = _script.bytecodeArray[i];
 			code.write(LingoDec::StandardNames::getOpcodeName(bytecode.opID));
 			switch (bytecode.opcode) {
 			case LingoDec::kOpJmp:
@@ -1529,7 +1527,7 @@ private:
 			}
 			writeByteCode(bytecode.pos, code._str);
 		}
-		if (!handler->isGenericEvent) {
+		if (!_script.isGenericEvent) {
 			if (!isMethod) {
 				writeByteCode(node._endOffset, "end");
 			}


Commit: 71a24ac4752a8cb00cb75f80da1c55be8356aaaa
    https://github.com/scummvm/scummvm/commit/71a24ac4752a8cb00cb75f80da1c55be8356aaaa
Author: scemino (scemino74 at gmail.com)
Date: 2024-05-28T22:36:53+02:00

Commit Message:
DIRECTOR: Fix invalid indentation with case statement

Changed paths:
    engines/director/debugtools.cpp


diff --git a/engines/director/debugtools.cpp b/engines/director/debugtools.cpp
index 9353006802a..67893b6cf20 100644
--- a/engines/director/debugtools.cpp
+++ b/engines/director/debugtools.cpp
@@ -565,6 +565,7 @@ public:
 
 		const ImVec4 color = (ImVec4)ImColor(g_lingo->_builtinCmds.contains(node.name) ? _state->_colors._builtin_color : _state->_colors._call_color);
 		ImGui::TextColored(color, "%s", node.name.c_str());
+		// TODO: we should test Director::builtins too (but inaccessible)
 		if (!g_lingo->_builtinCmds.contains(node.name) && ImGui::IsItemHovered() && ImGui::BeginTooltip()) {
 			ImGui::Text("Go to definition");
 			ImGui::EndTooltip();
@@ -705,6 +706,8 @@ public:
 	}
 
 	virtual void visit(const LingoDec::CaseLabelNode &node) override {
+		renderLine(node._startOffset);
+		renderIndentation();
 		bool parenValue = node.value->hasSpaces(_dot);
 		if (parenValue) {
 			ImGui::Text("(");
@@ -763,6 +766,7 @@ public:
 
 	virtual void visit(const LingoDec::CaseStmtNode &node) override {
 		write(node._startOffset, "case ", _state->_colors._keyword_color);
+		ImGui::SameLine();
 		node.value->accept(*this);
 		ImGui::TextColored(ImColor(_state->_colors._keyword_color), " of ");
 		indent();
@@ -773,7 +777,7 @@ public:
 			node.otherwise->accept(*this);
 		}
 		unindent();
-		ImGui::TextColored(ImColor(_state->_colors._keyword_color), "end case");
+		write(node._endOffset, "end case", _state->_colors._keyword_color);
 	}
 
 	virtual void visit(const LingoDec::ObjCallNode &node) override {


Commit: f9aaf083ffd2276c2d665cc07c7b2334ebdffbc4
    https://github.com/scummvm/scummvm/commit/f9aaf083ffd2276c2d665cc07c7b2334ebdffbc4
Author: scemino (scemino74 at gmail.com)
Date: 2024-05-28T22:36:53+02:00

Commit Message:
DIRECTOR: Fix code viewer with D5

Changed paths:
    engines/director/debugtools.cpp


diff --git a/engines/director/debugtools.cpp b/engines/director/debugtools.cpp
index 67893b6cf20..6de3030bc5a 100644
--- a/engines/director/debugtools.cpp
+++ b/engines/director/debugtools.cpp
@@ -429,29 +429,36 @@ typedef struct ImGuiState {
 
 ImGuiState *_state = nullptr;
 
-const LingoDec::Handler *getHandler(CastMemberID id, const Common::String &handlerId) {
-	const Director::Movie *movie = g_director->getCurrentMovie();
-	const Cast *targets[2] = {movie->getCast(), movie->getSharedCast()};
-	for (int i = 0; i < 2; i++) {
-		const Cast *cast = targets[i];
-		if (!cast)
-			continue;
-		const ScriptContext *ctx = cast->_lingoArchive->findScriptContext(id.member);
-		if (!ctx || !ctx->_functionHandlers.contains(handlerId))
+const LingoDec::Handler *getHandler(const Cast *cast, CastMemberID id, const Common::String &handlerId) {
+	if (!cast)
+		return nullptr;
+	const ScriptContext *ctx = cast->_lingoArchive->findScriptContext(id.member);
+	if (!ctx || !ctx->_functionHandlers.contains(handlerId))
+		return nullptr;
+	for (auto p : cast->_lingodec->scripts) {
+		if ((p.second->castID & 0xFFFF) != id.member)
 			continue;
-		for (auto p : cast->_lingodec->scripts) {
-			if (p.second->castID != id.member)
-				continue;
-			for (const LingoDec::Handler &handler : p.second->handlers) {
-				if (handler.name == handlerId) {
-					return &handler;
-				}
+		;
+		for (const LingoDec::Handler &handler : p.second->handlers) {
+			if (handler.name == handlerId) {
+				return &handler;
 			}
 		}
 	}
 	return nullptr;
 }
 
+const LingoDec::Handler *getHandler(CastMemberID id, const Common::String &handlerId) {
+	const Director::Movie *movie = g_director->getCurrentMovie();
+	for (const auto it : *movie->getCasts()) {
+		const Cast *cast = it._value;
+		const LingoDec::Handler *handler = getHandler(cast, id, handlerId);
+		if (handler)
+			return handler;
+	}
+	return getHandler(movie->getSharedCast(), id, handlerId);
+}
+
 ImGuiScript toImGuiScript(CastMemberID id, const Common::String &handlerId) {
 	ImGuiScript result;
 	result.id = id;




More information about the Scummvm-git-logs mailing list