[Scummvm-git-logs] scummvm master -> 81b40efa31769200385fa6bc89b1700ac8b929c4

sev- sev at scummvm.org
Tue Jul 6 20:08:36 UTC 2021


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

Summary:
967f745c68 SAGA2: Initialize button.cpp classes
2223717753 SAGA2: Fix potential null dereference. CID 1457869
55a9867755 SAGA2: Move globalContainerList to Saga2Engine
173cf9ee28 SAGA2: Cleanup and formatting
cb2df677e9 SAGA2: Init ContainerView class members. CID 1457935
491dab058b SAGA2: Remove unnecessary check. CID 1457936
b6b6f184f2 SAGA2: Properly initialize ContainerNode on instantiation. CID 1457922
81b40efa31 SAGA2: Properly initialize DisplayNode on instantiation. CID 1457922


Commit: 967f745c684709e9cb20ecdef32891b4ddcd9554
    https://github.com/scummvm/scummvm/commit/967f745c684709e9cb20ecdef32891b4ddcd9554
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T21:14:56+02:00

Commit Message:
SAGA2: Initialize button.cpp classes

Changed paths:
    engines/saga2/button.cpp
    engines/saga2/button.h


diff --git a/engines/saga2/button.cpp b/engines/saga2/button.cpp
index d1d16a6fda..269324d270 100644
--- a/engines/saga2/button.cpp
+++ b/engines/saga2/button.cpp
@@ -49,7 +49,7 @@ void gCompImage::init(void) {
 	internalAlloc   = false;
 	currentImage    = 0;
 	numPtrAlloc     = 0;
-//	imageText[0]   = NULL;
+	textFont        = &Onyx10Font;  // default
 }
 
 gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, uint16 ident,
@@ -103,7 +103,8 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void *image, const c
 	// setup a single image configuration
 	init();
 
-	if (!image) return;
+	if (!image)
+		return;
 
 	compImages = (void **)malloc(sizeof(void *) * 1); // allocate room for one pointer
 
@@ -120,7 +121,8 @@ gCompImage::gCompImage(gPanelList &list, const Rect16 &box, void **images,
                        uint16 ident, AppFunc *cmd) : gControl(list, box, NULL, ident, cmd) {
 	init();
 
-	if (!images) return;
+	if (!images)
+		return;
 
 	compImages      = images;
 
@@ -729,6 +731,7 @@ gMultCompButton::gMultCompButton(gPanelList &list, const Rect16 &box, void **new
 		max     = 0;
 		min     = 0;
 		current = 0;
+		response = hitResponse;
 		return;
 	}
 
diff --git a/engines/saga2/button.h b/engines/saga2/button.h
index 75c1a43db0..25e886b714 100644
--- a/engines/saga2/button.h
+++ b/engines/saga2/button.h
@@ -52,7 +52,9 @@ struct textPallete {
 	uint8   inHilitePen;
 
 	// default constructor
-	textPallete(void) { ; }      // do nothing
+	textPallete() {
+		dlPen = urPen = inPen = dlHilitePen = urHilitePen = inHilitePen = 0;
+	 }
 
 	textPallete(uint8 dlP, uint8 urP, uint8 inP, uint8 dlHP, uint8 urHP, uint8 inHP) {
 		set(dlP, urP, inP, dlHP, urHP, inHP);


Commit: 2223717753a093e9ad0802bdab71287bbf369057
    https://github.com/scummvm/scummvm/commit/2223717753a093e9ad0802bdab71287bbf369057
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T21:19:03+02:00

Commit Message:
SAGA2: Fix potential null dereference. CID 1457869

Changed paths:
    engines/saga2/contain.cpp


diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index e80eda9e13..8cf8872490 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1488,9 +1488,6 @@ void ContainerNode::show(void) {
 	//  open the window; Object should already be "open"
 	if (window == NULL) {
 		switch (type) {
-		case readyType:
-			return;
-
 		case physicalType:
 			physicalContainerAppearance.rows    = proto->getViewableRows();
 			physicalContainerAppearance.cols    = proto->getViewableCols();
@@ -1512,6 +1509,10 @@ void ContainerNode::show(void) {
 		case enchantType:
 			window = new EnchantmentContainerWindow(*this, enchantmentContainerAppearance);
 			break;
+
+		case readyType:
+		default:
+			return;
 		}
 	}
 


Commit: 55a9867755ade7dbaac439f6c415ab5995b7008e
    https://github.com/scummvm/scummvm/commit/55a9867755ade7dbaac439f6c415ab5995b7008e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T21:34:48+02:00

Commit Message:
SAGA2: Move globalContainerList to Saga2Engine

Changed paths:
    engines/saga2/actor.cpp
    engines/saga2/contain.cpp
    engines/saga2/contain.h
    engines/saga2/motion.cpp
    engines/saga2/objects.cpp
    engines/saga2/objproto.cpp
    engines/saga2/player.cpp
    engines/saga2/saga2.cpp
    engines/saga2/saga2.h
    engines/saga2/sagafunc.cpp


diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index d24608bdf3..cfd4196432 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -202,7 +202,7 @@ bool ActorProto::closeAction(ObjectID dObj, ObjectID) {
 	assert(isActor(dObj));
 
 	GameObject      *dObjPtr = GameObject::objectAddress(dObj);
-	ContainerNode   *cn = globalContainerList.find(dObj, ContainerNode::deadType);
+	ContainerNode   *cn = g_vm->_containerList->find(dObj, ContainerNode::deadType);
 
 	assert(dObjPtr->isOpen());
 	assert(cn);
@@ -2189,7 +2189,9 @@ void Actor::holdInRightHand(ObjectID objID) {
 	assert(isObject(objID));
 	rightHandObject = objID;
 
-	if (isPlayerActor(this)) globalContainerList.setUpdate(thisID());
+	if (isPlayerActor(this))
+		g_vm->_containerList->setUpdate(thisID());
+
 	evalActorEnchantments(this);
 }
 
@@ -2197,7 +2199,9 @@ void Actor::holdInLeftHand(ObjectID objID) {
 	assert(isObject(objID));
 	leftHandObject = objID;
 
-	if (isPlayerActor(this)) globalContainerList.setUpdate(thisID());
+	if (isPlayerActor(this))
+		g_vm->_containerList->setUpdate(thisID());
+
 	evalActorEnchantments(this);
 }
 
@@ -2221,7 +2225,9 @@ void Actor::wear(ObjectID objID, uint8 where) {
 
 	armorObjects[where] = objID;
 
-	if (isPlayerActor(this)) globalContainerList.setUpdate(thisID());
+	if (isPlayerActor(this))
+		g_vm->_containerList->setUpdate(thisID());
+
 	evalActorEnchantments(this);
 
 	if (actorToPlayerID(this, playerID)) {
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 8cf8872490..a313833e65 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -109,8 +109,6 @@ GameObject  *ContainerView::objToGet;
 int32       ContainerView::amountAccumulator = 0;
 int16       ContainerView::amountIndY = -1;
 
-ContainerList       globalContainerList;
-
 //-----------------------------------------------------------------------
 //	Physical container appearance
 
@@ -1431,7 +1429,7 @@ ContainerNode::~ContainerNode() {
 	hide();
 
 	//  Remove from container list
-	globalContainerList.remove(this);
+	g_vm->_containerList->remove(this);
 }
 
 //  Restore the state of this ContainerNode from archive buffer
@@ -1680,12 +1678,9 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
 
 		if (((Actor *)obj)->isDead()) {
 			//  Open dead container for dead actor
-			if (!(cn = globalContainerList.find(owner, ContainerNode::deadType)))
-				cn = new ContainerNode(globalContainerList, id, ContainerNode::deadType);
+			if (!(cn = g_vm->_containerList->find(owner, ContainerNode::deadType)))
+				cn = new ContainerNode(*g_vm->_containerList, id, ContainerNode::deadType);
 		} else if (owner != ContainerNode::nobody) {
-			//  Open mental container for living player actor.
-//			if (!(cn = globalContainerList.find( owner, ContainerNode::mentalType )))
-//				cn = new ContainerNode( globalContainerList, id, ContainerNode::mentalType );
 			return OpenMindContainer(owner, open, /*mType*/ openMindType);
 		}
 #if DEBUG
@@ -1695,8 +1690,8 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
 		if (actorIDToPlayerID(obj->possessor(), owner) == false)
 			owner = ContainerNode::nobody;
 
-		if (!(cn = globalContainerList.find(id, ContainerNode::physicalType)))
-			cn = new ContainerNode(globalContainerList, id, ContainerNode::physicalType);
+		if (!(cn = g_vm->_containerList->find(id, ContainerNode::physicalType)))
+			cn = new ContainerNode(*g_vm->_containerList, id, ContainerNode::physicalType);
 	}
 
 	//  If node was successfull created, and we wanted it open, and the owner
@@ -1711,7 +1706,7 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
 }
 
 ContainerNode *CreateReadyContainerNode(PlayerActorID player) {
-	return new ContainerNode(globalContainerList,
+	return new ContainerNode(*g_vm->_containerList,
 	                            getPlayerActorAddress(player)->getActorID(),
 	                            ContainerNode::readyType);
 }
@@ -1720,8 +1715,8 @@ ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type) {
 	ContainerNode   *cn;
 	ObjectID        id = getPlayerActorAddress(player)->getActorID();
 
-	if (!(cn = globalContainerList.find(id, ContainerNode::mentalType))) {
-		cn = new ContainerNode(globalContainerList, id, ContainerNode::mentalType);
+	if (!(cn = g_vm->_containerList->find(id, ContainerNode::mentalType))) {
+		cn = new ContainerNode(*g_vm->_containerList, id, ContainerNode::mentalType);
 		cn->mindType = type;
 
 		//  If node was successfull created, and we wanted it open, and the owner
@@ -1755,11 +1750,14 @@ void initContainers(void) {
 }
 
 void cleanupContainers(void) {
-	if (selImage)       g_vm->_imageCache->releaseImage(selImage);
-	if (containerRes)   resFile->disposeContext(containerRes);
+	if (selImage)
+		g_vm->_imageCache->releaseImage(selImage);
+	if (containerRes)
+		resFile->disposeContext(containerRes);
 
 	selImage = NULL;
 	containerRes = NULL;
+	delete g_vm->_containerList;
 }
 
 void initContainerNodes(void) {
@@ -1769,9 +1767,7 @@ void initContainerNodes(void) {
 	ContainerNode   *node;
 	bool            onlyReady = true;
 
-	for (node = (ContainerNode *)globalContainerList.first();
-	        node != NULL;
-	        node = (ContainerNode *)node->next()) {
+	for (node = g_vm->_containerList->first(); node != NULL; node = node->next()) {
 		if (node->getType() != ContainerNode::readyType) {
 			onlyReady = false;
 			break;
@@ -1789,12 +1785,12 @@ void saveContainerNodes(SaveFileConstructor &saveGame) {
 	int32               archiveBufSize;
 
 	//  Make sure there are no pending container view actions
-	globalContainerList.doDeferredActions();
+	g_vm->_containerList->doDeferredActions();
 
 	archiveBufSize = sizeof(numNodes);
 
 	//  Count the number of nodes to save
-	for (Common::List<ContainerNode *>::iterator it = globalContainerList._list.begin(); it != globalContainerList._list.end(); ++it) {
+	for (Common::List<ContainerNode *>::iterator it = g_vm->_containerList->_list.begin(); it != g_vm->_containerList->_list.end(); ++it) {
 		ContainerNode *n = *it;
 
 		if (n->getType() != ContainerNode::readyType)
@@ -1816,7 +1812,7 @@ void saveContainerNodes(SaveFileConstructor &saveGame) {
 	bufferPtr = (int16 *)bufferPtr + 1;
 
 	//  Store the nodes
-	for (Common::List<ContainerNode *>::iterator it = globalContainerList._list.begin(); it != globalContainerList._list.end(); ++it) {
+	for (Common::List<ContainerNode *>::iterator it = g_vm->_containerList->_list.begin(); it != g_vm->_containerList->_list.end(); ++it) {
 		ContainerNode *n = *it;
 
 		if (n->getType() != ContainerNode::readyType)
@@ -1863,7 +1859,7 @@ void loadContainerNodes(SaveFileReader &saveGame) {
 		bufferPtr = node->restore(bufferPtr);
 
 		//  Add it back to the container list
-		globalContainerList.add(node);
+		g_vm->_containerList->add(node);
 	}
 
 	assert(tempList.empty());
@@ -1873,7 +1869,7 @@ void loadContainerNodes(SaveFileReader &saveGame) {
 }
 
 void cleanupContainerNodes(void) {
-	for (Common::List<ContainerNode *>::iterator it = globalContainerList._list.begin(); it != globalContainerList._list.end(); ++it) {
+	for (Common::List<ContainerNode *>::iterator it = g_vm->_containerList->_list.begin(); it != g_vm->_containerList->_list.end(); ++it) {
 		ContainerNode *n = *it;
 
 		if (n->getType() != ContainerNode::readyType)
@@ -1882,7 +1878,7 @@ void cleanupContainerNodes(void) {
 }
 
 void updateContainerWindows(void) {
-	globalContainerList.doDeferredActions();
+	g_vm->_containerList->doDeferredActions();
 }
 
 void setMindContainer(int index, IntangibleContainerWindow &cw) {
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index 7a2b8d5eb6..57785f44d4 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -522,8 +522,6 @@ public:
 	void setUpdate(ObjectID id);
 };
 
-extern ContainerList    globalContainerList;
-
 ContainerNode *CreateContainerNode(ObjectID id, bool open = true, int16 mindType = 0);
 ContainerNode *CreateReadyContainerNode(PlayerActorID player);
 ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type);
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 174b5b6a7f..127be79b25 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -3582,11 +3582,8 @@ void MotionTask::fireBowAction(void) {
 					                    * (actorCrossSection + projCrossSection);
 					actorLoc.z += a->proto()->height * 7 / 8;
 
-					if ((projID =   proj->extractMerged(
-					                    Location(actorLoc, a->IDParent()),
-					                    1))
-					        !=  Nothing) {
-						globalContainerList.setUpdate(a->thisID());
+					if ((projID =   proj->extractMerged(Location(actorLoc, a->IDParent()), 1)) !=  Nothing) {
+						g_vm->_containerList->setUpdate(a->thisID());
 						proj = GameObject::objectAddress(projID);
 						shootObject(*proj, *a, *targetObj, 16);
 					}
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 6a32959df3..c9c248214c 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -933,7 +933,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
 	        &&  isPlayerActor((Actor *)oldParent))
 	        || (isObject(oldParentID)
 	            &&  oldParent->isOpen())) {
-		globalContainerList.setUpdate(oldParentID);
+		g_vm->_containerList->setUpdate(oldParentID);
 	}
 
 	if (_data.parentID != oldParentID && isActor(oldParentID)) {
@@ -982,7 +982,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
 		        &&  isPlayerActor((Actor *)parent))
 		        || (isObject(_data.parentID) && parent->isOpen())
 		   ) {
-			globalContainerList.setUpdate(_data.parentID);
+			g_vm->_containerList->setUpdate(_data.parentID);
 		}
 	}
 }
@@ -1223,7 +1223,7 @@ void GameObject::deleteObject(void) {
 	removeAllSensors();
 
 	//  Delete any container nodes for this object
-	while ((cn = globalContainerList.find(dObj)) != nullptr)
+	while ((cn = g_vm->_containerList->find(dObj)) != nullptr)
 		delete cn;
 
 	if (isActor(_data.parentID)) {
@@ -2143,7 +2143,8 @@ void GameObject::setProtoNum(int32 nProto) {
 		}
 
 		//  If this object is in a container, then redraw the container window
-		if (!isWorld(oldParentID)) globalContainerList.setUpdate(oldParentID);
+		if (!isWorld(oldParentID))
+			g_vm->_containerList->setUpdate(oldParentID);
 	}
 }
 
@@ -2214,7 +2215,7 @@ void GameObject::mergeWith(GameObject *dropObj, GameObject *target, int16 count)
 		dropObj->deleteObject();
 	}
 
-	globalContainerList.setUpdate(target->IDParent());
+	g_vm->_containerList->setUpdate(target->IDParent());
 }
 
 
@@ -2243,7 +2244,7 @@ bool GameObject::stack(ObjectID enactor, ObjectID objToStackID) {
 		if (!objToStack->isMoving()) {
 			//  Increase the stack count
 			_data.location.z++;
-			globalContainerList.setUpdate(IDParent());
+			g_vm->_containerList->setUpdate(IDParent());
 		}
 
 		return true;
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index 6f49a1c2a1..5b5f61db1f 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1260,13 +1260,14 @@ bool PhysicalContainerProto::openAction(ObjectID dObj, ObjectID) {
 	cn = CreateContainerNode(dObj, false);
 	cn->markForShow();                                      //  Deferred open
 	dObjPtr->_data.objectFlags |= objectOpen;         //  Set open bit;
-	globalContainerList.setUpdate(dObjPtr->IDParent());
+	g_vm->_containerList->setUpdate(dObjPtr->IDParent());
+
 	return true;
 }
 
 bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
 	GameObject      *dObjPtr = GameObject::objectAddress(dObj);
-	ContainerNode   *cn = globalContainerList.find(dObj, ContainerNode::physicalType);
+	ContainerNode   *cn = g_vm->_containerList->find(dObj, ContainerNode::physicalType);
 
 	assert(dObjPtr->isOpen());
 	assert(cn);
@@ -1276,7 +1277,8 @@ bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
 
 	//  Clear open bit
 	dObjPtr->_data.objectFlags &= ~objectOpen;
-	globalContainerList.setUpdate(dObjPtr->IDParent());
+	g_vm->_containerList->setUpdate(dObjPtr->IDParent());
+
 	return true;
 }
 
@@ -1325,13 +1327,6 @@ bool PhysicalContainerProto::acceptInsertionAction(
 		}
 	}
 
-	//  If we extracted the dropped objects from a pile, then make sure
-	//  the old pile gets redrawn. PlaceObject already takes care of
-	//  redrawing the target container; But because extractMerged creates
-	//  the extracted portion inside of "Nothing" the source container might
-	//  not be redrawn in this case.
-//	if (prevItemPtr) globalContainerList.setUpdate( prevItemPtr->IDParent() );
-
 	return true;
 }
 
@@ -2244,7 +2239,7 @@ bool ArmorProto::useAction(ObjectID dObj, ObjectID enactor) {
 	else
 		a->wear(dObj, slot);
 
-	globalContainerList.setUpdate(obj->IDParent());
+	g_vm->_containerList->setUpdate(obj->IDParent());
 
 	return true;
 }
@@ -2934,7 +2929,7 @@ bool IntangibleContainerProto::openAction(ObjectID dObj, ObjectID enactor) {
 }
 
 bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
-	ContainerNode   *cn = globalContainerList.find(dObj, ContainerNode::mentalType);
+	ContainerNode *cn = g_vm->_containerList->find(dObj, ContainerNode::mentalType);
 
 	assert(cn);
 
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 382b6ee887..5d62cfebac 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -570,7 +570,7 @@ void setCenterActor(PlayerActorID newCenter) {
 	viewCenterObject = playerList[centerActor].getActorID();
 
 	indivReadyNode->changeOwner(newCenter);
-	globalContainerList.setPlayerNum(newCenter);
+	g_vm->_containerList->setPlayerNum(newCenter);
 	setEnchantmentDisplay();
 
 	if (a->curTask != NULL) {
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 449d098424..4985362ba5 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -36,6 +36,7 @@
 
 #include "saga2/gdraw.h"
 #include "saga2/mouseimg.h"
+#include "saga2/contain.h"
 
 namespace Saga2 {
 
@@ -79,6 +80,8 @@ Common::Error Saga2Engine::run() {
 	// Initialize graphics using following:
 	initGraphics(640, 480);
 
+	_containerList = new ContainerList;
+
 	readConfig();
 
 	loadExeResources();
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 9bc3e35ce2..601326aac2 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -40,6 +40,7 @@ class SmackerDecoder;
 
 namespace Saga2 {
 
+class ContainerList;
 class Timer;
 class TimerList;
 class BandList;
@@ -116,7 +117,7 @@ public:
 	GrabInfo *_mouseInfo;
 	EffectDisplayPrototypeList *_edpList;
 	SpellDisplayPrototypeList *_sdpList;
-
+	ContainerList *_containerList;
 
 	gDisplayPort _mainPort;
 
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index e6865bf8c3..6712b710f7 100644
--- a/engines/saga2/sagafunc.cpp
+++ b/engines/saga2/sagafunc.cpp
@@ -248,7 +248,7 @@ int16 scriptActorTransfer(int16 *args) {
 			obj->move(Location(targetSlot, targetID));
 			if ((cSet & (ProtoObj::isIntangible | ProtoObj::isContainer))
 			        == (ProtoObj::isIntangible | ProtoObj::isContainer))
-				globalContainerList.setUpdate(targetID);
+				g_vm->_containerList->setUpdate(targetID);
 		}
 	} else {
 		obj->move(Location(args[1], args[2], args[3], args[0]));
@@ -984,7 +984,7 @@ int16 scriptGameObjectSetMass(int16 *args) {
 	if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
 		obj->setExtra(args[0]);
 		if (obj->proto()->flags & ResourceObjectPrototype::objPropMergeable) {
-			globalContainerList.setUpdate(obj->IDParent());
+			g_vm->_containerList->setUpdate(obj->IDParent());
 		}
 		return true;
 	} else return false;
@@ -2096,13 +2096,13 @@ int16 scriptActorDeductPayment(int16 *args) {
 
 				if (massCount > paymentAmount) {
 					obj->setExtra(massCount - paymentAmount);
-					globalContainerList.setUpdate(obj->IDParent());
+					g_vm->_containerList->setUpdate(obj->IDParent());
 					break;
 				} else {
 					if (delObj) {
 						ObjectID    dParent = delObj->IDParent();
 						delObj->deleteObject();
-						globalContainerList.setUpdate(dParent);
+						g_vm->_containerList->setUpdate(dParent);
 					}
 					paymentAmount -= massCount;
 					delObj = obj;
@@ -2115,7 +2115,7 @@ int16 scriptActorDeductPayment(int16 *args) {
 				if (delObj) {
 					ObjectID    dParent = delObj->IDParent();
 					delObj->deleteObject();
-					globalContainerList.setUpdate(dParent);
+					g_vm->_containerList->setUpdate(dParent);
 				}
 				delObj = obj;
 			}
@@ -2125,7 +2125,7 @@ int16 scriptActorDeductPayment(int16 *args) {
 	if (delObj) {
 		ObjectID    dParent = delObj->IDParent();
 		delObj->deleteObject();
-		globalContainerList.setUpdate(dParent);
+		g_vm->_containerList->setUpdate(dParent);
 	}
 
 	//  Payment succeeded!
@@ -2989,7 +2989,8 @@ int16 scriptDeleteObject(int16 *args) {
 	assert(obj);
 	oldParentID = obj->IDParent();
 	obj->deleteObjectRecursive();
-	globalContainerList.setUpdate(oldParentID);
+	g_vm->_containerList->setUpdate(oldParentID);
+
 	return 0;
 }
 


Commit: 173cf9ee281992c3d67dbac7d61a6e6c3d16b7db
    https://github.com/scummvm/scummvm/commit/173cf9ee281992c3d67dbac7d61a6e6c3d16b7db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T21:39:48+02:00

Commit Message:
SAGA2: Cleanup and formatting

Changed paths:
    engines/saga2/contain.cpp


diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index a313833e65..21ec2f2e63 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -44,14 +44,12 @@
 
 namespace Saga2 {
 
-// debug
-uint8 weight = 0;
-uint8 encum  = 0;
+enum {
+	kMaxOpenDistance = 32
+};
 
-const int           maxOpenDistance = 32;
 // selector image pointer
-static void         *selImage;
-
+static void *selImage;
 
 /* ===================================================================== *
    Imports
@@ -1570,8 +1568,10 @@ bool ContainerNode::isAccessable(ObjectID enactor) {
 	holder = obj->possessor();
 	if (holder != Nothing || isActor(object)) {
 		//  "Reach" for other players is further than for other objects
-		if (holder != a->thisID() && dist > 96) return false;
-	} else if (dist > maxOpenDistance) return false;
+		if (holder != a->thisID() && dist > 96)
+			return false;
+	} else if (dist > kMaxOpenDistance)
+		return false;
 
 	return true;
 }
@@ -1624,7 +1624,7 @@ void ContainerList::doDeferredActions(void) {
 			//  from the protagonist, then quietly close the object.
 			GameObject  *obj = GameObject::objectAddress(n->object);
 			if (obj->world() != world
-			        || (obj->getWorldLocation() - tp).quickHDistance() > maxOpenDistance) {
+			        || (obj->getWorldLocation() - tp).quickHDistance() > kMaxOpenDistance) {
 				//  Close object image and window (silently)
 				obj->setFlags(0, objectOpen);
 				delete n;


Commit: cb2df677e995805f640b143a26c1f3c4d95c24d3
    https://github.com/scummvm/scummvm/commit/cb2df677e995805f640b143a26c1f3c4d95c24d3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T21:42:44+02:00

Commit Message:
SAGA2: Init ContainerView class members. CID 1457935

Changed paths:
    engines/saga2/contain.cpp


diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 21ec2f2e63..592ddec4b2 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -261,6 +261,9 @@ ContainerView::ContainerView(
 	scrollPosition  = 0;
 	totalRows       = app.totRows;
 	setMousePoll(true);
+	totalMass = 0;
+	totalBulk = 0;
+	numObjects = 0;
 }
 
 //  Destructor


Commit: 491dab058b77ffa4272344469dd5733a53fa9c21
    https://github.com/scummvm/scummvm/commit/491dab058b77ffa4272344469dd5733a53fa9c21
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T21:46:31+02:00

Commit Message:
SAGA2: Remove unnecessary check. CID 1457936

Changed paths:
    engines/saga2/contain.cpp


diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 592ddec4b2..aa56580cee 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1724,9 +1724,7 @@ ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type) {
 
 		//  If node was successfull created, and we wanted it open, and the owner
 		//  is the center actor or no-actor then make the container window visible.
-		if (cn != NULL
-		        &&  open
-		        &&  id == getCenterActorID()) {
+		if (open && id == getCenterActorID()) {
 			cn->show();
 		}
 	} else {


Commit: b6b6f184f2482e0b441c3c1a274e37377ed6b7df
    https://github.com/scummvm/scummvm/commit/b6b6f184f2482e0b441c3c1a274e37377ed6b7df
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T21:50:58+02:00

Commit Message:
SAGA2: Properly initialize ContainerNode on instantiation. CID 1457922

Changed paths:
    engines/saga2/contain.h


diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index 57785f44d4..de0549ea51 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -435,7 +435,14 @@ private:
 	};
 
 public:
-	ContainerNode(void) {}
+	ContainerNode(void) {
+		object = 0;
+		type = 0;
+		owner = 0;
+		window = nullptr;
+		action = 0;
+		mindType = 0;
+	}
 	ContainerNode(ContainerList &cl, ObjectID id, int type);
 	~ContainerNode();
 


Commit: 81b40efa31769200385fa6bc89b1700ac8b929c4
    https://github.com/scummvm/scummvm/commit/81b40efa31769200385fa6bc89b1700ac8b929c4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-06T21:54:05+02:00

Commit Message:
SAGA2: Properly initialize DisplayNode on instantiation. CID 1457922

Changed paths:
    engines/saga2/dispnode.cpp


diff --git a/engines/saga2/dispnode.cpp b/engines/saga2/dispnode.cpp
index 5d5b4d018d..9cebdb4996 100644
--- a/engines/saga2/dispnode.cpp
+++ b/engines/saga2/dispnode.cpp
@@ -129,7 +129,12 @@ void  DisplayNodeList::init(uint16 s) {
 // DisplayNode stuff
 
 DisplayNode::DisplayNode() {
-	efx = NULL;
+	nextDisplayed = nullptr;
+	sortDepth = 0;
+	object = nullptr;
+	flags = 0;                  // various flags
+	type = nodeTypeObject;
+	efx = nullptr;
 }
 
 TilePoint DisplayNode::SpellPos(void) {




More information about the Scummvm-git-logs mailing list