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

neuromancer noreply at scummvm.org
Sat Nov 22 06:35:23 UTC 2025


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:
dcf4b73746 PRIVATE: Implement LoseInventory()


Commit: dcf4b73746202edf40be2deaa574b0cbca29da71
    https://github.com/scummvm/scummvm/commit/dcf4b73746202edf40be2deaa574b0cbca29da71
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2025-11-22T07:35:19+01:00

Commit Message:
PRIVATE: Implement LoseInventory()

Changed paths:
    engines/private/funcs.cpp
    engines/private/private.cpp
    engines/private/private.h


diff --git a/engines/private/funcs.cpp b/engines/private/funcs.cpp
index 6a163abec6b..6ab508d1b78 100644
--- a/engines/private/funcs.cpp
+++ b/engines/private/funcs.cpp
@@ -359,8 +359,9 @@ static void fNoStopSounds(ArgArray args) {
 
 static void fLoseInventory(ArgArray args) {
 	assert(args.size() == 0);
-	debugC(1, kPrivateDebugScript, "LoveInventory()");
-	g_private->inventory.clear();
+	debugC(1, kPrivateDebugScript, "LoseInventory()");
+
+	g_private->removeRandomInventory();
 }
 
 static void fInventory(ArgArray args) {
diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 2374bd6fe7d..5c63b3a199b 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -1081,6 +1081,31 @@ bool PrivateEngine::inInventory(const Common::String &bmp) const {
 	return false;
 }
 
+void PrivateEngine::removeRandomInventory() {
+	// This logic was extracted from the executable.
+	// Examples:
+	//   0-3 items:  0 items removed
+	//   4-6 items:  1 item removed
+	//   7-10 items: 2 items removed
+	//
+	// TODO: Clear the inventory flag for the item.
+	// We are currently only removing items from the diary. We need to also
+	// remove them from Marlowe's inventory by clearing their item flag.
+	// We can do this once item flags are stored and included in save files.
+	uint numberOfItemsToRemove = (inventory.size() * 30) / 100;
+	for (uint i = 0; i < numberOfItemsToRemove; i++) {
+		uint indexToRemove = _rnd->getRandomNumber(inventory.size() - 1);
+		uint index = 0;
+		for (InvList::iterator it = inventory.begin(); it != inventory.end(); ++it) {
+			if (index == indexToRemove) {
+				inventory.erase(it);
+				break;
+			}
+			index++;
+		}
+	}
+}
+
 void PrivateEngine::selectAMRadioArea(Common::Point mousePos) {
 	if (_AMRadioArea.surf == nullptr)
 		return;
diff --git a/engines/private/private.h b/engines/private/private.h
index fb45db8b4d0..5259867229a 100644
--- a/engines/private/private.h
+++ b/engines/private/private.h
@@ -335,6 +335,7 @@ public:
 	// Diary
 	InvList inventory;
 	bool inInventory(const Common::String &bmp) const;
+	void removeRandomInventory();
 	Common::String _diaryLocPrefix;
 	void loadLocations(const Common::Rect &);
 	void loadInventory(uint32, const Common::Rect &, const Common::Rect &);




More information about the Scummvm-git-logs mailing list