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

dreammaster noreply at scummvm.org
Thu Jan 5 18:39:54 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:
f80b927a3e XEEN: Fix chest crash in Swords of Xeen


Commit: f80b927a3e404f10c8cddff502016c770fc31ead
    https://github.com/scummvm/scummvm/commit/f80b927a3e404f10c8cddff502016c770fc31ead
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-01-05T08:39:28-10:00

Commit Message:
XEEN: Fix chest crash in Swords of Xeen

Changed paths:
    engines/xeen/scripts.cpp


diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 34da4c5a79c..d3af6c275ec 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -1404,13 +1404,14 @@ bool Scripts::cmdDisplayLarge(ParamsIterator &params) {
 
 bool Scripts::cmdExchObj(ParamsIterator &params) {
 	int id1 = params.readByte(), id2 = params.readByte();
-
-	MazeObject &obj1 = _vm->_map->_mobData._objects[id1];
-	MazeObject &obj2 = _vm->_map->_mobData._objects[id2];
-
-	Common::Point pt = obj1._position;
-	obj1._position = obj2._position;
-	obj2._position = pt;
+	auto objects = _vm->_map->_mobData._objects;
+	Common::Point empty(-1, -1);
+
+	// WORKAROUND: In Swords of Xeen, there's an invalid indexing for a chest.
+	// In such cases, set the position to nowhere
+	Common::Point &objPos1 = (id1 >= objects.size()) ? empty : objects[id1]._position;
+	Common::Point &objPos2 = (id2 >= objects.size()) ? empty : objects[id2]._position;
+	SWAP(objPos1, objPos2);
 
 	return true;
 }




More information about the Scummvm-git-logs mailing list