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

neuromancer neuromancer at users.noreply.github.com
Fri May 21 17:53:43 UTC 2021


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:
ac43a4318f PRIVATE: inventory and rendering fixes


Commit: ac43a4318fbeb044a27b7a28f921a2cf6daa6e70
    https://github.com/scummvm/scummvm/commit/ac43a4318fbeb044a27b7a28f921a2cf6daa6e70
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2021-05-21T14:53:32-03:00

Commit Message:
PRIVATE: inventory and rendering fixes

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


diff --git a/engines/private/funcs.cpp b/engines/private/funcs.cpp
index d781325ab0..b5881f19ba 100644
--- a/engines/private/funcs.cpp
+++ b/engines/private/funcs.cpp
@@ -298,6 +298,14 @@ static void fLoseInventory(ArgArray args) {
 	g_private->inventory.clear();
 }
 
+bool inInventory(Common::String &bmp) {
+	for (NameList::const_iterator it = g_private->inventory.begin(); it != g_private->inventory.end(); ++it) {
+		if (*it == bmp)
+			return true;
+	}
+	return false;
+}
+
 static void fInventory(ArgArray args) {
 	// assert types
 	Datum b1 = args[0];
@@ -354,18 +362,22 @@ static void fInventory(ArgArray args) {
 			g_private->playSound(g_private->getTakeLeaveSound(), 1, false, false);
 		}
 
-		g_private->inventory.push_back(bmp);
+		if (!inInventory(bmp))
+			g_private->inventory.push_back(bmp);
 	} else {
 		if (v1.type == NAME) {
 			if (strcmp(c.u.str, "\"REMOVE\"") == 0) {
 				v1.u.sym->u.val = 0;
-				g_private->inventory.remove(bmp);
+				if (inInventory(bmp))
+					g_private->inventory.remove(bmp);
 			} else {
 				v1.u.sym->u.val = 1;
-				g_private->inventory.push_back(bmp);
+				if (!inInventory(bmp))
+					g_private->inventory.push_back(bmp);
 			}
 		} else {
-			g_private->inventory.push_back(bmp);
+			if (!inInventory(bmp))
+				g_private->inventory.push_back(bmp);
 		}
 		if (v2.type == NAME)
 			v2.u.sym->u.val = 1;
diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 0086a2dae4..51ce14253d 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -770,12 +770,16 @@ Common::Error PrivateEngine::loadGameStream(Common::SeekableReadStream *stream)
 		Private::Symbol *sym = maps.locations.getVal(*it);
 		sym->u.val = val;
 	}
+
+	// Inventory
+	inventory.clear();
 	uint32 size = stream->readUint32LE();
 	for (uint32 i = 0; i < size; ++i) {
 		inventory.push_back(stream->readString());
 	}
 
 	// Dossiers
+	_dossiers.clear();
 	size = stream->readUint32LE();
 	DossierInfo m;
 	for (uint32 i = 0; i < size; ++i) {
@@ -1046,7 +1050,16 @@ Graphics::Surface *PrivateEngine::loadMask(const Common::String &name, int x, in
 	surf->create(_screenW, _screenH, _pixelFormat);
 	surf->fillRect(screenRect, _transparentColor);
 	Graphics::Surface *csurf = decodeImage(name);
-	Common::Rect crect(csurf->w, csurf->h);
+
+	uint32 hdiff = 0;
+	uint32 wdiff = 0;
+
+	if (x+csurf->h > _screenH)
+		hdiff = x+csurf->h - _screenH;
+	if (y+csurf->w > _screenW)
+		wdiff = y+csurf->w - _screenW;
+
+	Common::Rect crect(csurf->w - wdiff, csurf->h - hdiff);
 	surf->copyRectToSurface(*csurf, x, y, crect);
 	csurf->free();
 	delete csurf;




More information about the Scummvm-git-logs mailing list