[Scummvm-git-logs] scummvm master -> 5d2976f388f14d13b1a27924778749b2d6701045

neuromancer noreply at scummvm.org
Thu Apr 6 11:39:13 UTC 2023


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:
5d2976f388 FREESCAPE: fixed incorrect parsing of 8-bit conditions


Commit: 5d2976f388f14d13b1a27924778749b2d6701045
    https://github.com/scummvm/scummvm/commit/5d2976f388f14d13b1a27924778749b2d6701045
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-06T13:40:53+02:00

Commit Message:
FREESCAPE: fixed incorrect parsing of 8-bit conditions

Changed paths:
    engines/freescape/games/dark/dark.cpp
    engines/freescape/language/8bitDetokeniser.cpp
    engines/freescape/language/instruction.cpp


diff --git a/engines/freescape/games/dark/dark.cpp b/engines/freescape/games/dark/dark.cpp
index 1e17560ba1d..55484da32d3 100644
--- a/engines/freescape/games/dark/dark.cpp
+++ b/engines/freescape/games/dark/dark.cpp
@@ -95,9 +95,9 @@ void DarkEngine::addWalls(Area *area) {
 		if (target > 0) {
 			area->addObjectFromArea(id, _areaMap[255]);
 			GeometricObject *gobj = (GeometricObject *)area->objectWithID(id);
-			assert((*(gobj->_condition[1]._thenInstructions))[0].getType() == Token::Type::GOTO);
-			assert((*(gobj->_condition[1]._thenInstructions))[0]._destination == 0);
-			(*(gobj->_condition[1]._thenInstructions))[0].setSource(target);
+			assert((*(gobj->_condition[0]._thenInstructions))[0].getType() == Token::Type::GOTO);
+			assert((*(gobj->_condition[0]._thenInstructions))[0]._destination == 0);
+			(*(gobj->_condition[0]._thenInstructions))[0].setSource(target);
 		} else
 			area->addObjectFromArea(id + 1, _areaMap[255]);
 
diff --git a/engines/freescape/language/8bitDetokeniser.cpp b/engines/freescape/language/8bitDetokeniser.cpp
index 988182045d5..c4ac1c47621 100644
--- a/engines/freescape/language/8bitDetokeniser.cpp
+++ b/engines/freescape/language/8bitDetokeniser.cpp
@@ -80,8 +80,11 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
 			branch.setBranches(conditionalInstructions, nullptr);
 			instructions.push_back(branch);
 
-			if (bytePointer > 0)
+			if (bytePointer > 0) {
 				detokenisedStream += "ENDIF\n";
+				// Allocate the next vector of instructions
+				conditionalInstructions = new FCLInstructionVector();
+			}
 
 			if (oldConditional == Token::SHOTQ)
 				detokenisedStream += "IF SHOT? THEN\n";
@@ -91,9 +94,6 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
 				detokenisedStream += "IF COLLIDED? THEN\n";
 			else
 				error("Invalid conditional: %x", oldConditional);
-
-			// Allocate the next vector of instructions
-			conditionalInstructions = new FCLInstructionVector();
 		}
 
 		// get the actual operation
@@ -421,17 +421,6 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
 		detokenisedStream += "\n";
 	}
 
-	// if (!conditionalInstructions)
-	//	conditionalInstructions = new FCLInstructionVector();
-
-	// conditionalInstructions->push_back(currentInstruction);
-
-	FCLInstruction branch;
-	branch = FCLInstruction(oldConditional);
-
-	branch.setBranches(conditionalInstructions, nullptr);
-	instructions.push_back(branch);
-
 	return detokenisedStream;
 }
 
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 7b845bf28b1..509e060f142 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -94,7 +94,12 @@ void FreescapeEngine::executeObjectConditions(GeometricObject *obj, bool shot, b
 	if (!obj->_conditionSource.empty()) {
 		_firstSound = true;
 		_objExecutingCodeSize = obj->getSize();
-		debugC(1, kFreescapeDebugCode, "Executing with collision flag: %s", obj->_conditionSource.c_str());
+		if (collided)
+			debugC(1, kFreescapeDebugCode, "Executing with collision flag: %s", obj->_conditionSource.c_str());
+		else if (shot)
+			debugC(1, kFreescapeDebugCode, "Executing with shot flag: %s", obj->_conditionSource.c_str());
+		else
+			error("Neither shot or collided flag is set!");
 		executeCode(obj->_condition, shot, collided, false); // TODO: check this last parameter
 	}
 }
@@ -124,7 +129,7 @@ void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
 	int codeSize = code.size();
 	while (ip <= codeSize - 1) {
 		FCLInstruction &instruction = code[ip];
-		debugC(1, kFreescapeDebugCode, "Executing ip: %d in code with size: %d", ip, codeSize);
+		debugC(1, kFreescapeDebugCode, "Executing ip: %d with type %d in code with size: %d", ip, instruction.getType(), codeSize);
 		switch (instruction.getType()) {
 		default:
 			if (!isCastle())




More information about the Scummvm-git-logs mailing list