[Scummvm-git-logs] scummvm master -> 4ca22fca5fb350d3a31c213909be9a4552fb84fc

mduggan noreply at scummvm.org
Thu Mar 6 06:19:44 UTC 2025


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:
07a82f4883 DGDS: Fix dialog area in HoC
3082cabc0c DGDS: Avoid crash from dialogs being reallocated
4ca22fca5f DGDS: Remove unused accessor


Commit: 07a82f488390a5d0787ad5f1f03aa23fb9a17b7c
    https://github.com/scummvm/scummvm/commit/07a82f488390a5d0787ad5f1f03aa23fb9a17b7c
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-03-06T17:18:25+11:00

Commit Message:
DGDS: Fix dialog area in HoC

HoC dialogs have a different usable width depending on whether they have a
header or not. Use numbers that better match the original.

This fixes #15780

Changed paths:
    engines/dgds/dialog.cpp


diff --git a/engines/dgds/dialog.cpp b/engines/dgds/dialog.cpp
index 0c5a5338064..585723b0af0 100644
--- a/engines/dgds/dialog.cpp
+++ b/engines/dgds/dialog.cpp
@@ -137,16 +137,15 @@ void Dialog::drawType2BackgroundDragon(Graphics::ManagedSurface *dst, const Comm
 }
 
 void Dialog::drawType2BackgroundChina(Graphics::ManagedSurface *dst, const Common::String &title) {
-	_state->_loc = DgdsRect(_rect.x + 12, _rect.y + 10, _rect.width - 24, _rect.height - 20);
 	if (title.empty()) {
+		_state->_loc = DgdsRect(_rect.x + 10, _rect.y + 10, _rect.width - 20, _rect.height - 20);
 		RequestData::fillBackground(dst, _rect.x, _rect.y, _rect.width, _rect.height, 0);
 		RequestData::drawCorners(dst, 1, _rect.x, _rect.y, _rect.width, _rect.height);
 	} else {
+		// This is 1 more pixel down than the original, but seems to be needed to get the right spot?
+		_state->_loc = DgdsRect(_rect.x + 6, _rect.y + 17, _rect.width - 12, _rect.height - 24);
 		dst->fillRect(Common::Rect(Common::Point(_rect.x, _rect.y), _rect.width, _rect.height), 0);
 		RequestData::drawCorners(dst, 11, _rect.x, _rect.y, _rect.width, _rect.height);
-		// TODO: Maybe should measure the font?
-		_state->_loc.y += 11;
-		_state->_loc.height -= 11;
 		RequestData::drawHeader(dst, _rect.x, _rect.y, _rect.width, 2, title, _fontColor, false, 0, 0);
 	}
 }


Commit: 3082cabc0ca14f8b1d138f938123f1b557c8e591
    https://github.com/scummvm/scummvm/commit/3082cabc0ca14f8b1d138f938123f1b557c8e591
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-03-06T17:18:25+11:00

Commit Message:
DGDS: Avoid crash from dialogs being reallocated

When we dynamically load dialog data it's possible for the list to be
reallocated during resize.  If we were also executing operations from one of
the reallocated dialogs, it would crash when accessing that pointer again.

Switch the dialog data to a List so it will not be reallocated when loading
more data.

This fixes #15781

Changed paths:
    engines/dgds/scene.cpp
    engines/dgds/scene.h


diff --git a/engines/dgds/scene.cpp b/engines/dgds/scene.cpp
index 291ec73d3de..92930da987e 100644
--- a/engines/dgds/scene.cpp
+++ b/engines/dgds/scene.cpp
@@ -257,16 +257,14 @@ bool Scene::readOpList(Common::SeekableReadStream *s, Common::Array<SceneOp> &li
 }
 
 
-bool Scene::readDialogList(Common::SeekableReadStream *s, Common::Array<Dialog> &list, int16 filenum /* = 0 */) const {
+bool Scene::readDialogList(Common::SeekableReadStream *s, Common::List<Dialog> &list, int16 filenum /* = 0 */) const {
 	// Some data on this format here https://www.oldgamesitalia.net/forum/index.php?showtopic=24055&st=25&p=359214&#entry359214
 
 	uint16 nitems = s->readUint16LE();
 	_checkListNotTooLong(nitems, "dialogs");
-	uint startsize = list.size();
-	list.resize(startsize + nitems);
 
-	for (uint i = startsize; i < list.size(); i++) {
-		Dialog &dst = list[i];
+	for (uint i = 0; i < nitems; i++) {
+		Dialog dst;
 		dst._num = s->readUint16LE();
 		dst._fileNum = filenum;
 		dst._rect.x = s->readUint16LE();
@@ -324,6 +322,7 @@ bool Scene::readDialogList(Common::SeekableReadStream *s, Common::Array<Dialog>
 			else
 				dst._fontColor = dst._fontColor ^ 8;
 		}
+		list.push_back(dst);
 	}
 
 	return !s->err();
@@ -728,8 +727,9 @@ void SDSScene::loadDialogData(uint16 fileNum) {
 	if (_dialogs.size() != prevSize) {
 		debug(10, "Read %d dialogs from DDS %s (ver %s id '%s'):", _dialogs.size() - prevSize,
 			filename.c_str(), fileVersion.c_str(), fileId.c_str());
-		for (uint i = prevSize; i < _dialogs.size(); i++)
-			debug(10, "%s", _dialogs[i].dump("").c_str());
+		for (const auto &dlg: _dialogs)
+			if (dlg._fileNum == fileNum)
+				debug(10, "%s", dlg.dump("").c_str());
 	}
 
 	if (!result)
@@ -746,11 +746,9 @@ void SDSScene::freeDialogData(uint16 fileNum) {
 	if (!fileNum)
 		return;
 
-	for (int i = 0; i < (int)_dialogs.size(); i++) {
-		if (_dialogs[i]._fileNum == fileNum) {
-			_dialogs.remove_at(i);
-			i--;
-		}
+	for (Common::List<Dialog>::iterator iter = _dialogs.begin(); iter != _dialogs.end(); iter++) {
+		if (iter->_fileNum == fileNum)
+			iter = _dialogs.erase(iter);
 	}
 }
 
diff --git a/engines/dgds/scene.h b/engines/dgds/scene.h
index fced475bbcf..3e11f5db8f7 100644
--- a/engines/dgds/scene.h
+++ b/engines/dgds/scene.h
@@ -197,7 +197,7 @@ protected:
 	bool readMouseHotspotList(Common::SeekableReadStream *s, Common::Array<MouseCursor> &list) const;
 	bool readObjInteractionList(Common::SeekableReadStream *s, Common::Array<ObjectInteraction> &list) const;
 	bool readOpList(Common::SeekableReadStream *s, Common::Array<SceneOp> &list) const;
-	bool readDialogList(Common::SeekableReadStream *s, Common::Array<Dialog> &list, int16 filenum = 0) const;
+	bool readDialogList(Common::SeekableReadStream *s, Common::List<Dialog> &list, int16 filenum = 0) const;
 	bool readTriggerList(Common::SeekableReadStream *s, Common::Array<SceneTrigger> &list) const;
 	bool readDialogActionList(Common::SeekableReadStream *s, Common::Array<DialogAction> &list) const;
 	bool readConditionalSceneOpList(Common::SeekableReadStream *s, Common::Array<ConditionalSceneOp> &list) const;
@@ -367,7 +367,7 @@ private:
 	Common::Array<TalkData> _talkData;
 
 	// From here on is mutable stuff that might need saving
-	Common::Array<Dialog> _dialogs;
+	Common::List<Dialog> _dialogs;
 	Common::Array<SceneTrigger> _triggers;
 	Conversation _conversation;
 


Commit: 4ca22fca5fb350d3a31c213909be9a4552fb84fc
    https://github.com/scummvm/scummvm/commit/4ca22fca5fb350d3a31c213909be9a4552fb84fc
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2025-03-06T17:18:25+11:00

Commit Message:
DGDS: Remove unused accessor

Changed paths:
    engines/dgds/globals.h


diff --git a/engines/dgds/globals.h b/engines/dgds/globals.h
index 652732ffde6..f1e48dc8a2c 100644
--- a/engines/dgds/globals.h
+++ b/engines/dgds/globals.h
@@ -157,7 +157,6 @@ public:
 	int16 getSheckels() const { return _sheckels; }
 
 	int16 getShellBet() const { return _shellBet; }
-	void setShellBet(int16 bet) { _shellBet = bet; }
 
 	int16 getShellPea() const { return _shellPea; }
 	void setShellPea(int16 pea) { _shellPea = pea; }




More information about the Scummvm-git-logs mailing list