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

mgerhardy noreply at scummvm.org
Thu Sep 3 18:38:23 UTC 2026


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

Summary:
c561d207fa MACS2: removed wrapper methods for pathfinding
c1d3617cf5 MACS2: removed unused members
d33053a6e2 MACS2: fixed debug pathfinding rendering
eb6150842f MACS2: fixed panther speed in scene 6 jump


Commit: c561d207fa908a4f9757e647d0f3298a994685e0
    https://github.com/scummvm/scummvm/commit/c561d207fa908a4f9757e647d0f3298a994685e0
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-09-03T20:10:18+02:00

Commit Message:
MACS2: removed wrapper methods for pathfinding

Changed paths:
    engines/macs2/character.cpp
    engines/macs2/debugtools.cpp
    engines/macs2/macs2.cpp
    engines/macs2/macs2.h
    engines/macs2/pathfinding.h
    engines/macs2/scriptexecutor.cpp
    engines/macs2/view1.cpp


diff --git a/engines/macs2/character.cpp b/engines/macs2/character.cpp
index 5d88f38e15a..7976cd0b08d 100644
--- a/engines/macs2/character.cpp
+++ b/engines/macs2/character.cpp
@@ -143,11 +143,11 @@ bool Character::handleWalkability(Character *c) {
 }
 
 uint16 Character::lookupWalkability(const Common::Point &p) const {
-	return g_engine->getWalkabilityAt((int16)p.y, (int16)p.x);
+	return g_engine->_pathfinding.walkabilityAt(p);
 }
 
 bool Character::isWalkable(const Common::Point &p) const {
-	return Macs2Engine::isWalkabilityWalkable(lookupWalkability(p));
+	return Pathfinding::isWalkabilityWalkable(lookupWalkability(p));
 }
 
 Character::Character() : _pathfindingOverlay(g_engine->screenWidth() * g_engine->gameHeight(), 0) {
@@ -200,8 +200,8 @@ void Character::setPosition(const Common::Point &newPosition) {
 }
 
 uint16 Character::getVerticalOffset() const {
-	uint16 result = g_engine->getWalkabilityAt(getPosition());
-	if (Macs2Engine::isWalkabilityBlocking(result)) {
+	uint16 result = g_engine->_pathfinding.walkabilityAt(getPosition());
+	if (Pathfinding::isWalkabilityBlocking(result)) {
 		result = 0;
 	}
 
@@ -540,41 +540,41 @@ void Character::update() {
 			pos = savedPos;
 			// Wall-sliding: build push vector from +/-1 and +/-2 samples
 			int pushX = 0, pushY = 0;
-			if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x + 1, pos.y))))
+			if (Pathfinding::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x + 1, pos.y))))
 				pushX--;
-			if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x - 1, pos.y))))
+			if (Pathfinding::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x - 1, pos.y))))
 				pushX++;
-			if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x, pos.y + 1))))
+			if (Pathfinding::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x, pos.y + 1))))
 				pushY--;
-			if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x, pos.y - 1))))
+			if (Pathfinding::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x, pos.y - 1))))
 				pushY++;
-			if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x + 2, pos.y))))
+			if (Pathfinding::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x + 2, pos.y))))
 				pushX--;
-			if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x - 2, pos.y))))
+			if (Pathfinding::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x - 2, pos.y))))
 				pushX++;
-			if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x, pos.y + 2))))
+			if (Pathfinding::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x, pos.y + 2))))
 				pushY--;
-			if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x, pos.y - 2))))
+			if (Pathfinding::isWalkabilityBlocking(lookupWalkability(Common::Point(pos.x, pos.y - 2))))
 				pushY++;
 			// Apply push vector
 			while (pushX != 0 || pushY != 0) {
 				if (pushX < 0) {
-					if (Macs2Engine::isWalkabilityWalkable(lookupWalkability(Common::Point(pos.x - 1, pos.y))))
+					if (Pathfinding::isWalkabilityWalkable(lookupWalkability(Common::Point(pos.x - 1, pos.y))))
 						pos.x--;
 					pushX++;
 				}
 				if (pushX > 0) {
-					if (Macs2Engine::isWalkabilityWalkable(lookupWalkability(Common::Point(pos.x + 1, pos.y))))
+					if (Pathfinding::isWalkabilityWalkable(lookupWalkability(Common::Point(pos.x + 1, pos.y))))
 						pos.x++;
 					pushX--;
 				}
 				if (pushY < 0) {
-					if (Macs2Engine::isWalkabilityWalkable(lookupWalkability(Common::Point(pos.x, pos.y - 1))))
+					if (Pathfinding::isWalkabilityWalkable(lookupWalkability(Common::Point(pos.x, pos.y - 1))))
 						pos.y--;
 					pushY++;
 				}
 				if (pushY > 0) {
-					if (Macs2Engine::isWalkabilityWalkable(lookupWalkability(Common::Point(pos.x, pos.y + 1))))
+					if (Pathfinding::isWalkabilityWalkable(lookupWalkability(Common::Point(pos.x, pos.y + 1))))
 						pos.y++;
 					pushY--;
 				}
@@ -594,7 +594,7 @@ void Character::update() {
 				   "walk cancelled pixelsMoved=%d walkSpeed=%d at (%d,%d) area=%u walk=%u finalDest=(%d,%d)",
 				   pixelsMoved, walkSpeed, pos.x, pos.y, tileArea, lookupWalkability(pos),
 				   _pathFinalDestination.x, _pathFinalDestination.y);
-		} else if (Macs2Engine::isWalkabilityBlocking(lookupWalkability(pos))) {
+		} else if (Pathfinding::isWalkabilityBlocking(lookupWalkability(pos))) {
 			debugC(kDebugPath,
 				   "walk cancelled (non-walkable) pixelsMoved=%d walkSpeed=%d at (%d,%d) walk=%u",
 				   pixelsMoved, walkSpeed, pos.x, pos.y, lookupWalkability(pos));
diff --git a/engines/macs2/debugtools.cpp b/engines/macs2/debugtools.cpp
index a6e3c8d215e..8e333320626 100644
--- a/engines/macs2/debugtools.cpp
+++ b/engines/macs2/debugtools.cpp
@@ -1494,11 +1494,11 @@ static void showSceneMapsWindow() {
 					uint8 val = surface->getPixel(mx, my);
 					if (val >= 0xC8 && val <= 0xEF) {
 						uint16 overrideResult;
-						bool overrideActive = g_engine->getPathfindingOverride(val, overrideResult);
+						bool overrideActive = g_engine->_pathfinding.getWalkOverride(val, overrideResult);
 						if (overrideActive)
 							ImGui::SetTooltip("(%d, %d) = %u (0x%02X) [override zone → %u = %s]",
 											  mx, my, val, val, overrideResult,
-											  Macs2Engine::isWalkabilityWalkable(overrideResult) ? "WALKABLE" : "non-walkable");
+											  Pathfinding::isWalkabilityWalkable(overrideResult) ? "WALKABLE" : "non-walkable");
 						else
 							ImGui::SetTooltip("(%d, %d) = %u (0x%02X) [override zone, DISABLED → non-walkable]",
 											  mx, my, val, val);
@@ -1539,7 +1539,7 @@ static void showSceneMapsWindow() {
 			for (int i = 0; i < (int)g_engine->_pathfinding._points.size(); i++) {
 				const PathfindingPoint &pt = g_engine->_pathfinding._points[i];
 				// Check reachability from character
-				bool reachable = protagonist && g_engine->isPathWalkable(charPos.y, charPos.x, pt._position.y, pt._position.x);
+				bool reachable = protagonist && g_engine->_pathfinding.isLineWalkable(charPos.y, charPos.x, pt._position.y, pt._position.x);
 				// Check if node is in current path
 				bool inPath = false;
 				if (protagonist) {
diff --git a/engines/macs2/macs2.cpp b/engines/macs2/macs2.cpp
index cfd34aa303a..caf54a431de 100644
--- a/engines/macs2/macs2.cpp
+++ b/engines/macs2/macs2.cpp
@@ -2052,8 +2052,8 @@ void Macs2Engine::updateBackgroundAnimationDepthMap(size_t animIndex) {
 			if (px < 0 || px >= _depthMap.w || py < 0 || py >= _depthMap.h) {
 				continue;
 			}
-			const uint16 walkVal = getWalkabilityAt((int16)py, (int16)px);
-			if (isWalkabilityWalkable(walkVal)) {
+			const uint16 walkVal = _pathfinding.walkabilityAt((int16)py, (int16)px);
+			if (Pathfinding::isWalkabilityWalkable(walkVal)) {
 				_depthMap.setPixel(px, py, (byte)walkVal);
 			}
 		}
diff --git a/engines/macs2/macs2.h b/engines/macs2/macs2.h
index 3947ddbad08..963ad001876 100644
--- a/engines/macs2/macs2.h
+++ b/engines/macs2/macs2.h
@@ -375,43 +375,9 @@ public:
 	Pathfinding _pathfinding;
 	Common::Array<Common::Point> _path;
 
-	bool getPathfindingOverride(uint16 index, uint16 &result) const {
-		return _pathfinding.getWalkOverride(index, result);
-	}
-	void setPathfindingOverride(uint16 index, uint16 overrideValue) {
-		_pathfinding.setWalkOverride(index, overrideValue);
-	}
-
-	static inline bool isWalkabilityBlocking(uint16 value) {
-		return Pathfinding::isWalkabilityBlocking(value);
-	}
-	static inline bool isWalkabilityWalkable(uint16 value) {
-		return Pathfinding::isWalkabilityWalkable(value);
-	}
-
-	uint16 getPathfindingOverride2(uint16 index) const {
-		return _pathfinding.areaOverrideAt(index);
-	}
-	void removePathfindingOverride(uint16 index) {
-		_pathfinding.removeWalkOverride(index);
-	}
-
-	uint16 getWalkabilityAt(int16 y, int16 x) {
-		return _pathfinding.walkabilityAt(y, x);
-	}
-	uint16 getWalkabilityAt(const Common::Point &p) {
-		return _pathfinding.walkabilityAt(p);
-	}
 	/** Sync depth map with the current background animation frame (v1 gate fix). */
 	void updateBackgroundAnimationDepthMap(size_t animIndex);
 	void updateAllBackgroundAnimationDepthMaps();
-	bool isPathWalkable(int16 y1, int16 x1, int16 y2, int16 x2) {
-		return _pathfinding.isLineWalkable(y1, x1, y2, x2);
-	}
-	void snapToWalkablePosition(int16 *pTargetY, int16 *pTargetX, int16 charY, int16 charX) {
-		_pathfinding.snapToWalkable(pTargetY, pTargetX, charY, charX);
-	}
-	int getPathfindingNodeCount() const { return _pathfinding.nodeCount(); }
 
 	// This is the override list living at [5BD1]
 	// Savegames sync 16 words into indices 1..16 (array size 0x11 during sync).
diff --git a/engines/macs2/pathfinding.h b/engines/macs2/pathfinding.h
index 30aa667e906..d5326cc660b 100644
--- a/engines/macs2/pathfinding.h
+++ b/engines/macs2/pathfinding.h
@@ -82,7 +82,6 @@ public:
 	bool getWalkOverride(uint16 index, uint16 &result) const;
 	void setWalkOverride(uint16 index, uint16 overrideValue);
 	void removeWalkOverride(uint16 index);
-	uint16 areaOverrideAt(uint16 index) const;
 
 	bool isLineWalkable(int16 y1, int16 x1, int16 y2, int16 x2) const;
 	void snapToWalkable(int16 *pTargetY, int16 *pTargetX, int16 charY, int16 charX) const;
@@ -96,6 +95,7 @@ public:
 private:
 	int _visitedStack[17] {};
 	int _visitedCount = 0;
+	uint16 areaOverrideAt(uint16 index) const;
 
 	int computeMinCostToReachable(int nodeIndex, int prevNode, const bool *reachable, int nodeCount, const Common::Point &finalDest);
 	bool canNodeConnectSourceToTarget(uint16 nodeIndex, const Common::Point &charPos, const Common::Point &target, const bool *reachable, int nodeCount) const;
diff --git a/engines/macs2/scriptexecutor.cpp b/engines/macs2/scriptexecutor.cpp
index 7b5a9835fa3..aea4496357a 100644
--- a/engines/macs2/scriptexecutor.cpp
+++ b/engines/macs2/scriptexecutor.cpp
@@ -577,7 +577,7 @@ void ScriptExecutor::debugLogActorWalkState(const char *context) {
 	const int16 x = actor->_position.x;
 	const int16 y = actor->_position.y;
 	const uint16 area = getAreaAtPoint((uint16)x, (uint16)y);
-	const uint16 walk = _engine->getWalkabilityAt(y, x);
+	const uint16 walk = _engine->_pathfinding.walkabilityAt(y, x);
 	View1 *view = (View1 *)_engine->findView("View1");
 	Character *character = view ? view->getCharacterByIndex(actorIndex) : nullptr;
 
@@ -585,7 +585,7 @@ void ScriptExecutor::debugLogActorWalkState(const char *context) {
 		   "%s: actor=(%d,%d) area=%u walk=%u/0x%04x int16=%d walkable=%s var[122]=%u "
 		   "cursor=0x%02x executorState=%u walkWaitObj=%u frameWait=%u soundWait=%d musicWait=%d "
 		   "pendingVMotion=%s vOff=%u motionTgt=%u motionProg=%u/%u repeatRun=%d",
-		   context, x, y, area, walk, walk, (int16)walk, Macs2Engine::isWalkabilityWalkable(walk) ? "yes" : "NO",
+		   context, x, y, area, walk, walk, (int16)walk, Pathfinding::isWalkabilityWalkable(walk) ? "yes" : "NO",
 		   getVariableValue(122), (uint)_cursorMode, (uint)_state, _walkTargetObjectIndex,
 		   _frameWaitTicksRemaining, _waitForPcmSound ? 1 : 0, _waitForMusicControl ? 1 : 0,
 		   (character && character->hasPendingVerticalMotion()) ? "yes" : "no",
@@ -1808,7 +1808,7 @@ OpcodeResult Script::ScriptExecutor::scriptTestPathfinding() {
 		setScriptError(2);
 		return OpcodeResult::Continue;
 	}
-	_pathWalkableResult = _engine->isPathWalkable(y, x, object->_position.y, object->_position.x);
+	_pathWalkableResult = _engine->_pathfinding.isLineWalkable(y, x, object->_position.y, object->_position.x);
 	return OpcodeResult::Continue;
 }
 
@@ -2064,8 +2064,8 @@ OpcodeResult Script::ScriptExecutor::scriptMoveToPosition() {
 
 	const Common::Point target(x, y);
 	// Binary scriptMoveToPosition (1008:bafc): isPathWalkable(targetY, targetX, objY, objX).
-	if (!_engine->isPathWalkable(y, x, object->_position.y, object->_position.x) &&
-		Macs2Engine::isWalkabilityWalkable(_engine->getWalkabilityAt(target))) {
+	if (!_engine->_pathfinding.isLineWalkable(y, x, object->_position.y, object->_position.x) &&
+		Pathfinding::isWalkabilityWalkable(_engine->_pathfinding.walkabilityAt(target))) {
 		setScriptError(0x15);
 		return OpcodeResult::Continue;
 	}
@@ -2749,15 +2749,15 @@ OpcodeResult Script::ScriptExecutor::scriptSetPathfinding() {
 	uint16 overrideValue = scriptReadValue16();
 	debugC(kDebugScript, "SCRIPT::setPathfinding(areaID=%u, active=%u, overrideValue=%u/0x%04x int16=%d walkable=%s)",
 		   areaID, active, overrideValue, overrideValue, (int16)overrideValue,
-		   (!active || Macs2Engine::isWalkabilityWalkable(overrideValue)) ? "yes" : "NO");
+		   (!active || Pathfinding::isWalkabilityWalkable(overrideValue)) ? "yes" : "NO");
 	if (areaID < 200 || areaID > 0xEF) {
 		setScriptError(0x0D);
 		return OpcodeResult::Continue;
 	}
 	if (active) {
-		g_engine->setPathfindingOverride(areaID, overrideValue);
+		g_engine->_pathfinding.setWalkOverride(areaID, overrideValue);
 	} else {
-		g_engine->removePathfindingOverride(areaID);
+		g_engine->_pathfinding.removeWalkOverride(areaID);
 	}
 	debugLogActorWalkState("after setPathfinding");
 	return OpcodeResult::Continue;
diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index 88f8f4f7d98..3b078019477 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -39,6 +39,7 @@
 #include "macs2/macs2.h"
 #include "macs2/music.h"
 #include "macs2/actionbar.h"
+#include "macs2/pathfinding.h"
 
 namespace Macs2 {
 namespace {
@@ -2801,8 +2802,8 @@ void View1::drawAllCharacters(Graphics::ManagedSurface *surface, bool fullUpdate
 
 			int16 walkabilityOffset = 0;
 			if (g_engine->_pathfinding._map.w > 0) {
-				walkabilityOffset = g_engine->getWalkabilityAt(charY, charX);
-				if (Macs2Engine::isWalkabilityBlocking((uint16)walkabilityOffset))
+				walkabilityOffset = g_engine->_pathfinding.walkabilityAt(charY, charX);
+				if (Pathfinding::isWalkabilityBlocking((uint16)walkabilityOffset))
 					walkabilityOffset = 0;
 			}
 			if (g_engine->isV2())


Commit: c1d3617cf5e0b46d6e28500c9e2ecabf72666e67
    https://github.com/scummvm/scummvm/commit/c1d3617cf5e0b46d6e28500c9e2ecabf72666e67
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-09-03T20:16:00+02:00

Commit Message:
MACS2: removed unused members

Changed paths:
    engines/macs2/amiga_resources.cpp
    engines/macs2/macs2.cpp
    engines/macs2/macs2.h
    engines/macs2/view1.cpp


diff --git a/engines/macs2/amiga_resources.cpp b/engines/macs2/amiga_resources.cpp
index ba48b7a4671..2918f5583fa 100644
--- a/engines/macs2/amiga_resources.cpp
+++ b/engines/macs2/amiga_resources.cpp
@@ -142,8 +142,6 @@ bool Macs2Engine::loadAmigaSceneBackground(uint32 sceneResourceId) {
 
 	_backgroundAnimations.clear();
 	_backgroundAnimationsBlobs.clear();
-	_mapImageFileOffset = 0;
-	_mapSubSceneTableFilePos = 0;
 	if (amigaMxmmHasMxaaOverlay(mxmm.data(), size)) {
 		debugC(1, kDebugFilePath, "Amiga: MM_%04u has MXAA overlay data (not loaded yet)",
 			   (uint)sceneResourceId);
diff --git a/engines/macs2/macs2.cpp b/engines/macs2/macs2.cpp
index caf54a431de..c5cb495c365 100644
--- a/engines/macs2/macs2.cpp
+++ b/engines/macs2/macs2.cpp
@@ -1004,25 +1004,8 @@ bool Macs2Engine::loadSceneGraphicsV1(uint32 sceneIndex) {
 	// Background image
 	_fileStream->seek(0xC + 0x4 + 0xC * newSceneIndex - 0xC, SEEK_SET);
 	uint32 bgImageOffset = _fileStream->readUint32LE();
-	uint32 sceneTableEntry2 = _fileStream->readUint32LE();
-	uint32 sceneTableEntry3 = _fileStream->readUint32LE();
-	(void)sceneTableEntry3; // strings offset, not used here
-	_mapSubSceneTableFilePos = 0;
-	_mapImageFileOffset = 0;
-	// The map image file offset is stored in the scene data block
-	if (sceneTableEntry2 != 0 && sceneTableEntry2 < (uint32)_fileStream->size()) {
-		_fileStream->seek(sceneTableEntry2 + 0x3C0, SEEK_SET);
-		uint32 mapOffset = _fileStream->readUint32LE();
-		if (mapOffset != 0 && mapOffset < (uint32)_fileStream->size()) {
-			// Validate it's actually RLE data for a kScreenWidth-wide image
-			_fileStream->seek(mapOffset, SEEK_SET);
-			uint16 rowLen = _fileStream->readUint16LE();
-			if (rowLen >= 50 && rowLen <= 640) {
-				_mapImageFileOffset = mapOffset;
-				_mapSubSceneTableFilePos = sceneTableEntry2 + 0x3C0;
-			}
-		}
-	}
+	/* sceneTableEntry2 = */ _fileStream->readUint32LE();
+	/* sceneTableEntry3 = */ _fileStream->readUint32LE();
 	_fileStream->seek(bgImageOffset, SEEK_SET);
 
 	// TODO: Copy-pasted code here
@@ -1303,9 +1286,6 @@ bool Macs2Engine::loadSceneGraphicsV2(uint32 sceneIndex) {
 	_scenePaletteMode = stream->readUint16LE();
 	_paletteDarkenPercent = stream->readUint16LE();
 
-	_mapImageFileOffset = 0;
-	_mapSubSceneTableFilePos = 0;
-
 	stream->seek(_mcsDirectoryOffset + 0xC * sceneIndex - 0x8, SEEK_SET);
 	const uint32 scriptBlobOffset = stream->readUint32LE();
 	_sceneResourceOffsets.clear();
diff --git a/engines/macs2/macs2.h b/engines/macs2/macs2.h
index 963ad001876..b639cf3c02b 100644
--- a/engines/macs2/macs2.h
+++ b/engines/macs2/macs2.h
@@ -347,14 +347,6 @@ public:
 	Graphics::ManagedSurface _sceneBackground;
 	Graphics::ManagedSurface _hotspotMap;
 
-	// File offset to the map mode image for the current scene (scene table entry +8).
-	// When 0, the map mode is unavailable for this scene.
-	uint32 _mapImageFileOffset = 0;
-
-	// Per-depth sub-scene file offsets for map mode preview (binary: scene+0x5DD7+depth*4).
-	// File position where the sub-scene offset table starts (after map depth map).
-	int64 _mapSubSceneTableFilePos = 0;
-
 	// This is the depth map
 	Graphics::ManagedSurface _depthMap;
 	// Scene-load snapshot used to restore depth under background animation frame 0.
diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index 3b078019477..14817a40f96 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -1049,9 +1049,6 @@ void View1::closeScriptActionBar(Script::MouseMode &outSavedCursorMode) {
 }
 
 void View1::enterMapMode() {
-	// Binary handleInput end-block when scene+0x61db != 0 (1008:e8bf): fade, load map
-	// from scene+0x5DDB (_mapSceneOffsets[0]), set cursor 0x18 (PanelUse).
-	// this path is the DOS help-map overlay
 	const uint32 helpOffset = g_engine->_mapSceneOffsets[0];
 	if (helpOffset == 0 || helpOffset >= (uint32)g_engine->_fileStream->size()) {
 		return;
@@ -1065,7 +1062,6 @@ void View1::enterMapMode() {
 	g_engine->applyPaletteDarkening();
 	Graphics::ManagedSurface mapDepth = g_engine->readRLEImage(g_engine->_fileStream->pos(), g_engine->_fileStream);
 	g_engine->_depthMap.blitFrom(mapDepth);
-	g_engine->_mapSubSceneTableFilePos = g_engine->_fileStream->pos();
 	_currentMode = ViewMode::VM_HELP;
 	g_engine->setCursorMode(Script::MouseMode::PanelUse);
 	updateCursor();


Commit: d33053a6e2d4c2e625765fbebc8f9c3c722f9106
    https://github.com/scummvm/scummvm/commit/d33053a6e2d4c2e625765fbebc8f9c3c722f9106
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-09-03T20:22:31+02:00

Commit Message:
MACS2: fixed debug pathfinding rendering

we were using an old array from the engine class - but should have used the character path array instead

Changed paths:
    engines/macs2/character.cpp
    engines/macs2/character.h
    engines/macs2/debugtools.cpp
    engines/macs2/macs2.cpp
    engines/macs2/macs2.h
    engines/macs2/view1.cpp


diff --git a/engines/macs2/character.cpp b/engines/macs2/character.cpp
index 7976cd0b08d..507a3a992a5 100644
--- a/engines/macs2/character.cpp
+++ b/engines/macs2/character.cpp
@@ -191,6 +191,31 @@ void Character::setWalkTarget(const Common::Point &target, bool snap) {
 	_stepDirectionSet = false;
 }
 
+void Character::getPathPolyline(Common::Array<Common::Point> &out) const {
+	out.clear();
+	if (_gameObject == nullptr)
+		return;
+
+	out.push_back(getPosition());
+
+	const Common::Array<PathfindingPoint> &nodes = g_engine->_pathfinding._points;
+	int idx = _currentPathIndex;
+	if (idx < 0)
+		idx = 0;
+	for (int i = idx; i < (int)_path.size(); i++) {
+		const uint16 nodeIdx = _path[i];
+		if (nodeIdx == 0 || nodeIdx > nodes.size())
+			continue;
+		out.push_back(nodes[nodeIdx - 1]._position);
+	}
+
+	if (out.back() != _pathFinalDestination)
+		out.push_back(_pathFinalDestination);
+
+	if (out.size() < 2)
+		out.clear();
+}
+
 const Common::Point &Character::getPosition() const {
 	return _gameObject->_position;
 }
diff --git a/engines/macs2/character.h b/engines/macs2/character.h
index 5dad7d68258..ee92675daea 100644
--- a/engines/macs2/character.h
+++ b/engines/macs2/character.h
@@ -87,6 +87,8 @@ public:
 	bool calculatePath(Common::Point target);
 	void setWalkTarget(const Common::Point &target, bool snap);
 	void startPickup(Macs2::GameObject *object);
+	/** Remaining walk polyline: current position, unused path nodes, final destination. */
+	void getPathPolyline(Common::Array<Common::Point> &out) const;
 
 	const Common::Point &getPosition() const;
 	void setPosition(const Common::Point &newPosition);
diff --git a/engines/macs2/debugtools.cpp b/engines/macs2/debugtools.cpp
index 8e333320626..216ca341d0d 100644
--- a/engines/macs2/debugtools.cpp
+++ b/engines/macs2/debugtools.cpp
@@ -1340,11 +1340,16 @@ static void showSceneMapsWindow() {
 						}
 					}
 				}
-				// Draw current path
-				if (g_engine->_path.size() >= 2) {
-					for (uint i = 0; i < g_engine->_path.size() - 1; i++) {
-						overlayComposite.drawLine(g_engine->_path[i].x, g_engine->_path[i].y,
-												  g_engine->_path[i + 1].x, g_engine->_path[i + 1].y, 0x0F);
+				// Draw each character's remaining walk
+				Common::Array<Common::Point> pathPts;
+				for (uint i = 0; i < view->_characters.size(); i++) {
+					Character *c = view->_characters[i];
+					if (c == nullptr)
+						continue;
+					c->getPathPolyline(pathPts);
+					for (uint p = 0; p + 1 < pathPts.size(); p++) {
+						overlayComposite.drawLine(pathPts[p].x, pathPts[p].y,
+												  pathPts[p + 1].x, pathPts[p + 1].y, 0x0F);
 					}
 				}
 				// Draw character positions
@@ -1527,13 +1532,15 @@ static void showSceneMapsWindow() {
 		ImGui::Separator();
 		ImGui::Text("_walkDepthThresholdY=%u  _walkDepthScaleFactor=%u  _walkBaseSpeedPct=%u",
 					g_engine->_walkDepthThresholdY, g_engine->_walkDepthScaleFactor, g_engine->_walkBaseSpeedPct);
+
+		View1 *view = (View1 *)g_engine->findView("View1");
+		Character *protagonist = view ? view->getCharacterByIndex(Scenes::instance()._currentActorIndex) : nullptr;
 		ImGui::Text("Pathfinding points: %u  Path nodes: %u",
-					(uint)g_engine->_pathfinding._points.size(), (uint)g_engine->_path.size());
+					(uint)g_engine->_pathfinding._points.size(),
+					protagonist ? (uint)protagonist->_path.size() : 0);
 
 		// Node detail table
 		if (ImGui::CollapsingHeader("Node Graph", ImGuiTreeNodeFlags_DefaultOpen)) {
-			View1 *view = (View1 *)g_engine->findView("View1");
-			Character *protagonist = view ? view->getCharacterByIndex(Scenes::instance()._currentActorIndex) : nullptr;
 			Common::Point charPos = protagonist ? protagonist->getPosition() : Common::Point(0, 0);
 
 			for (int i = 0; i < (int)g_engine->_pathfinding._points.size(); i++) {
@@ -1544,7 +1551,7 @@ static void showSceneMapsWindow() {
 				bool inPath = false;
 				if (protagonist) {
 					for (uint p = 0; p < protagonist->_path.size(); p++) {
-						if (protagonist->_path[p] == (uint16)i) {
+						if (protagonist->_path[p] == (uint16)(i + 1)) {
 							inPath = true;
 							break;
 						}
diff --git a/engines/macs2/macs2.cpp b/engines/macs2/macs2.cpp
index c5cb495c365..233b0b63af4 100644
--- a/engines/macs2/macs2.cpp
+++ b/engines/macs2/macs2.cpp
@@ -244,7 +244,7 @@ void Macs2Engine::loadResourceFileV1() {
 
 	// Map scene offsets -> scene+0x5DDB. First entry is the help screen image offset.
 	for (uint i = 0; i < kMcsV1MapSceneOffsetCount; i++) {
-		_mapSceneOffsets[i] = _fileStream->readUint32LE();
+		_helpOffsets[i] = _fileStream->readUint32LE();
 	}
 
 	_fileStream->seek(kMcsV1ActorIndexOffset, SEEK_SET);
@@ -264,7 +264,7 @@ void Macs2Engine::loadResourceFileV2() {
 	_shadingTable.resize(0x800, 0);
 	_text._numGlyphs = 0;
 	_text.numPanelGlyphs = 0;
-	memset(_mapSceneOffsets, 0, sizeof(_mapSceneOffsets));
+	memset(_helpOffsets, 0, sizeof(_helpOffsets));
 	_imageResources.clear();
 	_imageResources.resize(33);
 	for (int i = 0; i < ARRAYSIZE(_cursorHotspots); i++) {
@@ -472,8 +472,8 @@ void Macs2Engine::loadResourceFileV2() {
 	if (!loadSizedFont(_text._panelGlyphs, _text.numPanelGlyphs, _text.maxPanelGlyphHeight))
 		warning("readGlobalAssetsV2: failed loading SysFont");
 
-	for (int i = 0; i < ARRAYSIZE(_mapSceneOffsets); i++)
-		_mapSceneOffsets[i] = _fileStream->readUint32LE();
+	for (int i = 0; i < ARRAYSIZE(_helpOffsets); i++)
+		_helpOffsets[i] = _fileStream->readUint32LE();
 
 	_saveListScroll = 1;
 	_saveSlotNames.clear();
diff --git a/engines/macs2/macs2.h b/engines/macs2/macs2.h
index b639cf3c02b..9ffcc824685 100644
--- a/engines/macs2/macs2.h
+++ b/engines/macs2/macs2.h
@@ -365,7 +365,6 @@ public:
 	Common::Array<Common::String> _textLog;
 
 	Pathfinding _pathfinding;
-	Common::Array<Common::Point> _path;
 
 	/** Sync depth map with the current background animation frame (v1 gate fix). */
 	void updateBackgroundAnimationDepthMap(size_t animIndex);
@@ -411,12 +410,13 @@ public:
 	};
 	struct DeltaSfxEvent {
 		uint16 frameIndex = 0;
-		Common::String fileName;
 		bool duckMusic = false;
+		Common::String fileName;
 	};
 	struct DeltaAnimState {
 		bool loaded = false;
 		bool playing = false;
+		bool applyPaletteOnStart = false;
 		uint16 frameCount = 0;
 		uint16 startFrame = 0;
 		uint16 endFrame = 0;
@@ -428,7 +428,6 @@ public:
 		uint16 clipMaX = 0;
 		uint16 clipMaY = 0;
 		Graphics::Palette palette{Graphics::PALETTE_COUNT};
-		bool applyPaletteOnStart = false;
 		Common::Array<DeltaFrame> frames;
 		Common::Array<DeltaSfxEvent> sfxEvents;
 		void clear(int screenW, int screenH) {
@@ -465,7 +464,7 @@ public:
 
 	// Map scene offsets from resource file (scene+0x5DDB, 256 entries x 4 bytes).
 	// Each entry is a file offset to a scene preview image for map mode.
-	uint32 _mapSceneOffsets[256] = {0};
+	uint32 _helpOffsets[256] = {0};
 
 	Common::Array<BackgroundAnimation> _backgroundAnimations;
 	Common::Array<BackgroundAnimationBlob> _backgroundAnimationsBlobs;
diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index 14817a40f96..30c5cb350f8 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -959,11 +959,13 @@ void View1::drawDebugOutput(Graphics::ManagedSurface &s) {
 }
 
 void View1::drawPath(Graphics::ManagedSurface &s) {
-	if (g_engine->_path.size() < 2) {
-		return;
-	}
-	for (uint i = 0; i < g_engine->_path.size() - 1; i++) {
-		s.drawLine(g_engine->_path[i].x, g_engine->_path[i].y, g_engine->_path[i + 1].x, g_engine->_path[i + 1].y, 0xFF);
+	Common::Array<Common::Point> pts;
+	for (Character *c : _characters) {
+		if (c == nullptr)
+			continue;
+		c->getPathPolyline(pts);
+		for (uint i = 0; i + 1 < pts.size(); i++)
+			s.drawLine(pts[i].x, pts[i].y, pts[i + 1].x, pts[i + 1].y, 0xFF);
 	}
 }
 
@@ -1049,7 +1051,7 @@ void View1::closeScriptActionBar(Script::MouseMode &outSavedCursorMode) {
 }
 
 void View1::enterMapMode() {
-	const uint32 helpOffset = g_engine->_mapSceneOffsets[0];
+	const uint32 helpOffset = g_engine->_helpOffsets[0];
 	if (helpOffset == 0 || helpOffset >= (uint32)g_engine->_fileStream->size()) {
 		return;
 	}
@@ -1741,7 +1743,7 @@ bool View1::handleHelpClick(const MouseDownMessage &msg) {
 		const uint8 depth = g_engine->_depthMap.getPixel(msg._pos.x, msg._pos.y);
 		if (depth > 0 && depth < 0xFA) {
 			// Binary: fileSeek(scene + 0x5DD7 + depth*4) = _mapSceneOffsets[depth-1]
-			uint32 subSceneOffset = g_engine->_mapSceneOffsets[depth - 1];
+			uint32 subSceneOffset = g_engine->_helpOffsets[depth - 1];
 			if (subSceneOffset != 0 && subSceneOffset < (uint32)g_engine->_fileStream->size()) {
 				startFadeToBlack(8);
 				Graphics::ManagedSurface preview = g_engine->readRLEImage(subSceneOffset, g_engine->_fileStream);


Commit: eb6150842f56f95026a94a5fb466845cdab6e70b
    https://github.com/scummvm/scummvm/commit/eb6150842f56f95026a94a5fb466845cdab6e70b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-09-03T20:36:37+02:00

Commit Message:
MACS2: fixed panther speed in scene 6 jump

... and most likely others, too - View::draw did a full update already
and then drawElements did another anim timer update - so it was twice as fast
as it should have been

Changed paths:
    engines/macs2/view1.cpp
    engines/macs2/view1.h


diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index 30c5cb350f8..b18f174b0d0 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -2233,6 +2233,10 @@ bool View1::msgKeypress(const KeypressMessage &msg) {
 }
 
 void View1::draw() {
+	drawSceneFrame(false);
+}
+
+void View1::drawSceneFrame(bool fullUpdate) {
 	if (_paletteDirty && _currentFadeValue < 0) {
 		setViewPaletteSafely(g_engine->_pal);
 		_paletteDirty = false;
@@ -2249,7 +2253,7 @@ void View1::draw() {
 
 	// Handle highlighting
 
-	drawAllCharacters(&s, true);
+	drawAllCharacters(&s, fullUpdate);
 	drawOverlayTextEntries();
 	if (shouldDrawPathfindingOverlay()) {
 		drawPathfindingPoints(s);
@@ -2376,7 +2380,7 @@ void View1::draw() {
 }
 
 void View1::drawSceneUpdate() {
-	draw();
+	drawSceneFrame(true);
 	_needsRedraw = false;
 }
 
@@ -2650,6 +2654,8 @@ bool View1::tick() {
 				g_engine->runScriptExecutor();
 			}
 		}
+		if (!exec->isScriptMidExecution())
+			drawSceneUpdate();
 	}
 
 	redraw();
diff --git a/engines/macs2/view1.h b/engines/macs2/view1.h
index 0106c066122..353d83b08da 100644
--- a/engines/macs2/view1.h
+++ b/engines/macs2/view1.h
@@ -392,6 +392,7 @@ public:
 	void layoutActionBarButtons();
 	void drawMainMenu(Graphics::ManagedSurface &s);
 	void drawSceneUpdate();
+	void drawSceneFrame(bool fullUpdate);
 
 	void handleTextBoxInput();
 	void dismissDialoguePanel();




More information about the Scummvm-git-logs mailing list