[Scummvm-git-logs] scummvm master -> 7a01a61e3dfd9b2abffa2d3ba3218ad98ac41783

Scorpeg noreply at scummvm.org
Tue Nov 3 14:42:53 UTC 2026


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

Summary:
7a01a61e3d TOUCHE: Fix hotspot visibility, placement, and label-cache staleness


Commit: 7a01a61e3dfd9b2abffa2d3ba3218ad98ac41783
    https://github.com/scummvm/scummvm/commit/7a01a61e3dfd9b2abffa2d3ba3218ad98ac41783
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-03T17:42:43+03:00

Commit Message:
TOUCHE: Fix hotspot visibility, placement, and label-cache staleness

Changed paths:
    engines/touche/touche.cpp
    engines/touche/touche.h


diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 62ee0b42d0a..166c0872e7e 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -1514,6 +1514,8 @@ void ToucheEngine::getHotspotPositions(Common::Array< ::Graphics::HotspotInfo> &
 
 	int scrollX = _flagsTable[614];
 	int scrollY = _flagsTable[615];
+	const int roomHeight = (_flagsTable[606] != 0) ? kScreenHeight : kRoomHeight;
+	const Common::Rect visibleRect(0, 0, kScreenWidth, roomHeight);
 
 	for (uint i = 0; i < _programHitBoxTable.size(); ++i) {
 		const ProgramHitBoxData &hitBox = _programHitBoxTable[i];
@@ -1528,7 +1530,7 @@ void ToucheEngine::getHotspotPositions(Common::Array< ::Graphics::HotspotInfo> &
 			continue;
 
 		int16 str = hitBox.str;
-		int screenX, screenY;
+		Common::Rect screenRect;
 		::Graphics::HotspotType hotspotType;
 
 		if (hitBox.item & 0x4000) {
@@ -1542,25 +1544,25 @@ void ToucheEngine::getHotspotPositions(Common::Array< ::Graphics::HotspotInfo> &
 			if (!charRect.isValidRect())
 				continue;
 
-			screenX = (charRect.left + charRect.right) / 2;
-			screenY = (charRect.top + charRect.bottom) / 2;
+			screenRect = charRect;
 			hotspotType = ::Graphics::kHotspotNPC;
 		} else {
 			const Common::Rect &objRect = hitBox.hitBoxes[0];
 			if (!objRect.isValidRect())
 				continue;
 
-			int centerX = (objRect.left + objRect.right) / 2;
-			int centerY = (objRect.top + objRect.bottom) / 2;
-
-			screenX = centerX - scrollX;
-			screenY = centerY - scrollY;
+			screenRect = objRect;
+			screenRect.translate(-scrollX, -scrollY);
 			hotspotType = ::Graphics::kHotspotObject;
 		}
 
-		if (screenX < 0 || screenX >= kScreenWidth || screenY < 0 || screenY >= kRoomHeight)
+		const Common::Rect visiblePart = screenRect.findIntersectingRect(visibleRect);
+		if (visiblePart.isEmpty())
 			continue;
 
+		const Common::Point center = screenRect.center();
+		const Common::Point position = visibleRect.contains(center) ? center : visiblePart.center();
+
 		Common::String name;
 		if (str > 0) {
 			const char *strData = getString(str);
@@ -1568,12 +1570,13 @@ void ToucheEngine::getHotspotPositions(Common::Array< ::Graphics::HotspotInfo> &
 				name = Common::String(strData);
 		}
 
-		hotspots.push_back(::Graphics::HotspotInfo(Common::Point(screenX, screenY), name, hotspotType));
+		hotspots.push_back(::Graphics::HotspotInfo(position, name, hotspotType));
 	}
 }
 
 void ToucheEngine::rebuildHotspotSnapshot() const {
 	_hotspotSnapshot.flag618 = _flagsTable[618];
+	_hotspotSnapshot.flag606 = _flagsTable[606];
 	_hotspotSnapshot.scrollX = _flagsTable[614];
 	_hotspotSnapshot.scrollY = _flagsTable[615];
 	_hotspotSnapshot.currentEpisodeNum = _currentEpisodeNum;
@@ -1591,17 +1594,20 @@ void ToucheEngine::rebuildHotspotSnapshot() const {
 	for (int i = 0; i < NUM_KEYCHARS; ++i) {
 		_hotspotSnapshot.chars[i].num = _keyCharsTable[i].num;
 		_hotspotSnapshot.chars[i].flags = _keyCharsTable[i].flags;
+		_hotspotSnapshot.chars[i].strNum = _keyCharsTable[i].strNum;
 		_hotspotSnapshot.chars[i].prevBoundingRect = _keyCharsTable[i].prevBoundingRect;
 	}
 }
 
 bool ToucheEngine::hotspotDirty() const {
 	const int16 flag618 = _flagsTable[618];
+	const int16 flag606 = _flagsTable[606];
 	const int16 scrollX = _flagsTable[614];
 	const int16 scrollY = _flagsTable[615];
 
 	// Fast path: any scalar change forces a snapshot rebuild.
 	if (flag618 != _hotspotSnapshot.flag618 ||
+		flag606 != _hotspotSnapshot.flag606 ||
 		scrollX != _hotspotSnapshot.scrollX ||
 		scrollY != _hotspotSnapshot.scrollY ||
 		_currentEpisodeNum != _hotspotSnapshot.currentEpisodeNum ||
@@ -1634,6 +1640,7 @@ bool ToucheEngine::hotspotDirty() const {
 			const HotspotSnapshot::CharEntry &cs = _hotspotSnapshot.chars[charIdx];
 			if (kc.num != cs.num ||
 				kc.flags != cs.flags ||
+				kc.strNum != cs.strNum ||
 				kc.prevBoundingRect != cs.prevBoundingRect) {
 				rebuildHotspotSnapshot();
 				return true;
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index c11675756d1..591fab88937 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -926,9 +926,11 @@ protected:
 		struct CharEntry {
 			uint16 num;
 			uint16 flags;
+			int16 strNum;
 			Common::Rect prevBoundingRect;
 		};
 		int16 flag618;
+		int16 flag606;
 		int16 scrollX;
 		int16 scrollY;
 		int currentEpisodeNum;




More information about the Scummvm-git-logs mailing list