[Scummvm-git-logs] scummvm master -> 0cf8b150dc01aa3c28d3dacf28150355e353d5e3

a-yyg 76591232+a-yyg at users.noreply.github.com
Mon Sep 13 00:50:34 UTC 2021


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

Summary:
4b27f9f6c9 SAGA2: Remove globals in contain.cpp
0cf8b150dc SAGA2: Cleanup debug code in contain.cpp


Commit: 4b27f9f6c9ba41d918db497f5026ccd40664bd91
    https://github.com/scummvm/scummvm/commit/4b27f9f6c9ba41d918db497f5026ccd40664bd91
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-09-13T09:27:20+09:00

Commit Message:
SAGA2: Remove globals in contain.cpp

Changed paths:
    engines/saga2/contain.cpp
    engines/saga2/contain.h
    engines/saga2/tilemode.cpp


diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index c9d8194e0f..a6c19f5bcb 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -45,9 +45,6 @@ enum {
 	kMaxOpenDistance = 32
 };
 
-// selector image pointer
-static void *selImage;
-
 /* ===================================================================== *
    Imports
  * ===================================================================== */
@@ -83,25 +80,6 @@ ProtoObj::isSpell
 ProtoObj::isEnchantment
 */
 
-// used to ignore doubleClick when doubleClick == singleClick
-static bool alreadyDone;
-//  ID of the last object that the mouse moved over
-
-/* ===================================================================== *
-   ContainerView member functions
- * ===================================================================== */
-
-// static mouse info variables
-ObjectID    ContainerView::lastPickedObjectID = Nothing;
-int32       ContainerView::lastPickedObjectQuantity = - 1;
-bool        ContainerView::objTextAlarm = false;
-char        ContainerView::mouseText[ContainerView::bufSize] = { "" };
-bool        ContainerView::mouseInView = false;
-uint16      ContainerView::numPicked = 1;
-GameObject  *ContainerView::objToGet;
-int32       ContainerView::amountAccumulator = 0;
-int16       ContainerView::amountIndY = -1;
-
 //-----------------------------------------------------------------------
 //	Physical container appearance
 
@@ -438,7 +416,7 @@ void ContainerView::drawClipped(
 			    objColors);
 
 			// check to see if selecting amount for this objec
-			if (objToGet == item) {
+			if (g_vm->_cnm->_objToGet == item) {
 				Point16 selectorPos = Point16(x + ((iconWidth - selectorX) >> 1),
 				                              y + ((iconHeight - selectorY) >> 1));
 
@@ -446,7 +424,7 @@ void ContainerView::drawClipped(
 				drawSelector(port, selectorPos);
 
 				// set the position of the inc center
-				amountIndY = y - (selectorY >> 1) - 12;
+				g_vm->_cnm->_amountIndY = y - (selectorY >> 1) - 12;
 			} else drawQuantity(port, item, objProto, x, y);
 		}
 	}
@@ -460,10 +438,10 @@ void ContainerView::drawSelector(gPort &port, Point16 &pos) {
 	SAVE_GPORT_STATE(port);
 
 	// draw the arrow images
-	drawCompressedImage(port, pos, selImage);
+	drawCompressedImage(port, pos, g_vm->_cnm->_selImage);
 
 	// draw the number of items selected thus far
-	num = sprintf(buf, " %d ", numPicked);
+	num = sprintf(buf, " %d ", g_vm->_cnm->_numPicked);
 
 	port.moveTo(Point16(pos.x - ((3 * (num - 3)) + 1),  pos.y + 7));
 	port.setFont(&Helv11Font);
@@ -592,21 +570,21 @@ void ContainerView::deactivate() {
 
 void ContainerView::pointerMove(gPanelMessage &msg) {
 	if (msg.pointerLeave) {
-		lastPickedObjectID = Nothing;
-		lastPickedObjectQuantity = -1;
+		g_vm->_cnm->_lastPickedObjectID = Nothing;
+		g_vm->_cnm->_lastPickedObjectQuantity = -1;
 		g_vm->_mouseInfo->setText(NULL);
-		mouseText[0] = 0;
+		g_vm->_cnm->_mouseText[0] = 0;
 
 		// static bool that tells if the mouse cursor
 		// is in a panel
-		mouseInView = false;
+		g_vm->_cnm->_mouseInView = false;
 		g_vm->_mouseInfo->setDoable(true);
 	} else {
 //		if( msg.pointerEnter )
 		{
 			// static bool that tells if the mouse cursor
 			// is in a panel
-			mouseInView = true;
+			g_vm->_cnm->_mouseInView = true;
 
 			GameObject *mouseObject;
 			mouseObject = g_vm->_mouseInfo->getObject();
@@ -636,11 +614,11 @@ bool ContainerView::pointerHit(gPanelMessage &msg) {
 
 	if (!g_vm->_mouseInfo->getDoable()) return false;
 
-	if (msg.doubleClick && !alreadyDone) {
+	if (msg.doubleClick && !g_vm->_cnm->_alreadyDone) {
 		dblClick(mouseObject, slotObject, msg);
 	} else { // single click
 		if (mouseObject != NULL) {
-			alreadyDone = true;    // if object then no doubleClick
+			g_vm->_cnm->_alreadyDone = true;    // if object then no doubleClick
 
 			if (g_vm->_mouseInfo->getIntent() == GrabInfo::Drop) {
 				if (mouseSet & ProtoObj::isTangible) {
@@ -672,7 +650,7 @@ bool ContainerView::pointerHit(gPanelMessage &msg) {
 			}
 		} else {
 			// default to doubleClick active
-			alreadyDone = false;
+			g_vm->_cnm->_alreadyDone = false;
 			clickOn(msg, mouseObject, slotObject);
 		}
 	}
@@ -686,13 +664,13 @@ bool ContainerView::pointerHit(gPanelMessage &msg) {
 
 void ContainerView::pointerRelease(gPanelMessage &) {
 	// see if in multi-item get mode
-	if (objToGet) {
-		objToGet->take(getCenterActorID(), numPicked);
+	if (g_vm->_cnm->_objToGet) {
+		g_vm->_cnm->_objToGet->take(getCenterActorID(), g_vm->_cnm->_numPicked);
 
 		// reset the flags and pointer dealing with merged object movement
-		objToGet            = NULL;
-		numPicked           = 1;
-		amountIndY          = -1;
+		g_vm->_cnm->_objToGet = NULL;
+		g_vm->_cnm->_numPicked = 1;
+		g_vm->_cnm->_amountIndY = -1;
 	}
 
 	gPanel::deactivate();
@@ -701,28 +679,28 @@ void ContainerView::pointerRelease(gPanelMessage &) {
 void ContainerView::timerTick(gPanelMessage &msg) {
 	// validate objToGet and make sure that the number selected for move
 	// is less then or equal to the number of items present in the merged object
-	if (objToGet && amountIndY != -1) {
-		int32   rate = (amountIndY - msg.pickAbsPos.y);
+	if (g_vm->_cnm->_objToGet && g_vm->_cnm->_amountIndY != -1) {
+		int32   rate = (g_vm->_cnm->_amountIndY - msg.pickAbsPos.y);
 
 		rate = rate * ((rate > 0) ? rate : -rate);
 
 		//  Add to the amount accumulator based on the mouse position
-		amountAccumulator += rate / 4 /* * accelSpeed */;
+		g_vm->_cnm->_amountAccumulator += rate / 4;
 
 		//  Take the top bits of the amount accumulator and add to
 		//  the mergeable amount.
-		numPicked = clamp(1,
-		                  numPicked + (amountAccumulator >> 8),
-		                  objToGet->getExtra());
+		g_vm->_cnm->_numPicked = clamp(1,
+		                  g_vm->_cnm->_numPicked + (g_vm->_cnm->_amountAccumulator >> 8),
+		                  g_vm->_cnm->_objToGet->getExtra());
 
 		//  Now remove the bits that we added to the grab amount
 		//  keep the remaining bits to accumulate for next time
-		amountAccumulator &= 0x00ff;
+		g_vm->_cnm->_amountAccumulator &= 0x00ff;
 	}
 }
 
 void ContainerView::dblClick(GameObject *mouseObject, GameObject *slotObject, gPanelMessage &msg) {
-	alreadyDone = true;
+	g_vm->_cnm->_alreadyDone = true;
 
 	// double click stuff
 	dblClickOn(msg, mouseObject, slotObject);
@@ -742,21 +720,21 @@ void ContainerView::clickOn(
 				// activate multi-object get interface if a mergeable object
 				getMerged(cObj);
 				g_vm->_mouseInfo->setText(NULL);
-				mouseText[0] = 0;
+				g_vm->_cnm->_mouseText[0] = 0;
 			}
 		} else {
 			//  just get the object into the cursor
-			cObj->take(getCenterActorID(), numPicked);
+			cObj->take(getCenterActorID(), g_vm->_cnm->_numPicked);
 		}
 	}
 }
 
 void ContainerView::getMerged(GameObject *obj) {
 	// reset the number picked.
-	numPicked = 1;
+	g_vm->_cnm->_numPicked = 1;
 
 	// set the object to be gotten
-	objToGet = obj;
+	g_vm->_cnm->_objToGet = obj;
 }
 
 // Activate the double click function
@@ -809,7 +787,7 @@ void ContainerView::dropPhysical(
 			MotionTask::dropObjectOnObject(*centerActor, *mObj, *cObj, num);
 		}
 
-		alreadyDone = true;
+		g_vm->_cnm->_alreadyDone = true;
 	}
 }
 
@@ -856,7 +834,7 @@ void ContainerView::useConcept(
 			//  If there is an object here drop the mouse object onto it
 			mObj->dropOn(centerActorID, cObj->thisID());
 
-		alreadyDone = true;
+		g_vm->_cnm->_alreadyDone = true;
 	}
 }
 
@@ -877,14 +855,14 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
 	if (slotID == Nothing) {
 		// clear out the mouse text
 		g_vm->_mouseInfo->setText(NULL);
-		mouseText[0] = 0;
+		g_vm->_cnm->_mouseText[0] = 0;
 
 		// reset the last picked thingy
-		lastPickedObjectID          = Nothing;
-		lastPickedObjectQuantity    = -1;
+		g_vm->_cnm->_lastPickedObjectID          = Nothing;
+		g_vm->_cnm->_lastPickedObjectQuantity    = -1;
 
 		// set the display alarm to false
-		objTextAlarm = false;
+		g_vm->_cnm->_objTextAlarm = false;
 
 		return;
 	}
@@ -892,25 +870,25 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
 	// get handles to the object in question
 	GameObject  *slotObject = GameObject::objectAddress(slotID);
 
-	if (slotID == lastPickedObjectID && slotObject->getExtra() == lastPickedObjectQuantity) {
+	if (slotID == g_vm->_cnm->_lastPickedObjectID && slotObject->getExtra() == g_vm->_cnm->_lastPickedObjectQuantity) {
 		return; // same object, bug out
 	} else {
 		// was not same, but is now.
-		lastPickedObjectID          = slotID;
-		lastPickedObjectQuantity    = slotObject->getExtra();
+		g_vm->_cnm->_lastPickedObjectID          = slotID;
+		g_vm->_cnm->_lastPickedObjectQuantity    = slotObject->getExtra();
 
 		// clear out the mouse text
 		g_vm->_mouseInfo->setText(NULL);
-		mouseText[0] = 0;
+		g_vm->_cnm->_mouseText[0] = 0;
 
 		// reset the alarm flag
-		objTextAlarm = false;
+		g_vm->_cnm->_objTextAlarm = false;
 
 		// set the hint alarm
 		containerObjTextAlarm.set(ticksPerSecond / 2);
 
 		// put the normalized text into mouseText
-		slotObject->objCursorText(mouseText, bufSize);
+		slotObject->objCursorText(g_vm->_cnm->_mouseText, ContainerManager::kBufSize);
 	}
 }
 
@@ -1002,7 +980,7 @@ void ReadyContainerView::setScrollOffset(int8 num) {
 void ReadyContainerView::timerTick(gPanelMessage &msg) {
 	// validate objToGet and make sure that the number selected for move
 	// is less then or equal to the number of items present in the merged object
-	if (objToGet && amountIndY != -1) {
+	if (g_vm->_cnm->_objToGet && g_vm->_cnm->_amountIndY != -1) {
 		ContainerView::timerTick(msg);
 
 		// redraw the container to draw the amount indicator
@@ -1134,7 +1112,7 @@ void ReadyContainerView::drawClipped(
 			    objColors);
 
 			// check to see if selecting amount for this objec
-			if (objToGet == item) {
+			if (g_vm->_cnm->_objToGet == item) {
 				Point16 selectorPos = Point16(x + ((iconWidth - selectorX) >> 1),
 				                              y + ((iconHeight - selectorY) >> 1));
 
@@ -1142,7 +1120,7 @@ void ReadyContainerView::drawClipped(
 				drawSelector(port, selectorPos);
 
 				// set the position of the inc center
-				amountIndY = y - (selectorY >> 1) + 28;   // extent.y;
+				g_vm->_cnm->_amountIndY = y - (selectorY >> 1) + 28;   // extent.y;
 			} else drawQuantity(port, item, objProto, x, y);
 		}
 	}
@@ -1750,16 +1728,16 @@ void initContainers() {
 	if (containerRes == NULL)
 		containerRes = resFile->newContext(MKTAG('C', 'O', 'N', 'T'), "cont.resources");
 
-	selImage = g_vm->_imageCache->requestImage(imageRes, MKTAG('A', 'M', 'N', 'T'));
+	g_vm->_cnm->_selImage = g_vm->_imageCache->requestImage(imageRes, MKTAG('A', 'M', 'N', 'T'));
 }
 
 void cleanupContainers() {
-	if (selImage)
-		g_vm->_imageCache->releaseImage(selImage);
+	if (g_vm->_cnm->_selImage)
+		g_vm->_imageCache->releaseImage(g_vm->_cnm->_selImage);
 	if (containerRes)
 		resFile->disposeContext(containerRes);
 
-	selImage = NULL;
+	g_vm->_cnm->_selImage = NULL;
 	containerRes = NULL;
 }
 
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index a1c383291a..4e62f88ce6 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -100,41 +100,6 @@ public:
 	//  Number of visible objects currently in the container
 	int16           numObjects;
 
-	// These indicators are static
-	// becuase there is only one mouse cursor,
-	// and therefore only one set of information
-	// about the last place it's been anywhere on the game screen.
-	//  ID of the last object the mouse was on
-	enum {
-		bufSize     = 60,
-		accelSpeed  = 8     // this tells the multi-item getting gadget how many items to grab per time unit
-	};
-
-	static ObjectID lastPickedObjectID;
-
-	// this will be used to hold a value of uint16 plus a -1 as a flag
-	static int32    lastPickedObjectQuantity;
-
-	// this will be used to determine if the cursor has been
-	// held over an object long enough to qualify for the hint to be displayed
-	static bool objTextAlarm;
-
-	// buffer for the mouse text
-	static char mouseText[bufSize];
-
-	// determines if the cursor is in *A* container view
-	static bool mouseInView;
-
-	// number of items to move for merged objects
-	static uint16 numPicked;
-
-	// merged object currently being gotten
-	static GameObject *objToGet;
-
-	static int32 amountAccumulator;
-
-	static int16 amountIndY;
-
 	//  Constructor
 	ContainerView(
 	    gPanelList &,
@@ -508,6 +473,53 @@ class ContainerManager {
 public:
 	Common::List<ContainerNode *> _list;
 
+	enum {
+		kBufSize     = 60,
+	};
+
+	// used to ignore doubleClick when doubleClick == singleClick
+	bool _alreadyDone;
+
+	// this will be used to determine if the cursor has been
+	// held over an object long enough to qualify for the hint to be displayed
+	bool _objTextAlarm;
+
+	// determines if the cursor is in *A* container view
+	bool _mouseInView;
+
+	ObjectID _lastPickedObjectID;
+
+	// number of items to move for merged objects
+	uint16 _numPicked;
+
+	int16 _amountIndY;
+
+	// this will be used to hold a value of uint16 plus a -1 as a flag
+	int32 _lastPickedObjectQuantity;
+
+	int32 _amountAccumulator;
+
+	// merged object currently being gotten
+	GameObject *_objToGet;
+
+	// selector image pointer
+	void *_selImage;
+
+	// buffer for the mouse text
+	char _mouseText[kBufSize];
+
+	ContainerManager() {
+		_alreadyDone = _objTextAlarm = _mouseInView = false;
+		_lastPickedObjectID = Nothing;
+		_numPicked = 1;
+		_amountIndY = -1;
+		_lastPickedObjectQuantity = - 1;
+		_amountAccumulator = 0;
+		_objToGet = nullptr;
+		_selImage = nullptr;
+		memset(_mouseText, 0, sizeof(_mouseText));
+	}
+
 	void add(ContainerNode *cn) {
 		_list.push_front(cn);
 	}
diff --git a/engines/saga2/tilemode.cpp b/engines/saga2/tilemode.cpp
index 783ffe0134..d8ce2fcb3f 100644
--- a/engines/saga2/tilemode.cpp
+++ b/engines/saga2/tilemode.cpp
@@ -762,13 +762,13 @@ void TileModeHandleTask() {
 
 		// do an alarm check for container views
 		if (containerObjTextAlarm.check()) {
-			ContainerView::objTextAlarm = true;
+			g_vm->_cnm->_objTextAlarm = true;
 		}
 
-		if (ContainerView::objTextAlarm == true) {
+		if (g_vm->_cnm->_objTextAlarm == true) {
 			// if the mouse is in a container...
-			if (ContainerView::mouseInView) {
-				g_vm->_mouseInfo->setText(ContainerView::mouseText);
+			if (g_vm->_cnm->_mouseInView) {
+				g_vm->_mouseInfo->setText(g_vm->_cnm->_mouseText);
 			}
 		}
 


Commit: 0cf8b150dc01aa3c28d3dacf28150355e353d5e3
    https://github.com/scummvm/scummvm/commit/0cf8b150dc01aa3c28d3dacf28150355e353d5e3
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-09-13T09:49:55+09:00

Commit Message:
SAGA2: Cleanup debug code in contain.cpp

Changed paths:
    engines/saga2/contain.cpp


diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index a6c19f5bcb..9badf07ec5 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -205,19 +205,6 @@ static const ContainerAppearanceDef enchantmentContainerAppearance = {
 //-----------------------------------------------------------------------
 //	ContainerView class
 
-//  Constructor
-/* ContainerView::ContainerView(
-    gPanelList      &list,
-    const Rect16    &box,
-    ContainerNode   &nd,
-    Point16         org,
-    Point16         space,
-    int16           numRows,
-    int16           numCols,
-    int16           totRows,
-    uint16          ident,
-    AppFunc         *cmd ) */
-
 ContainerView::ContainerView(
     gPanelList      &list,
     const Rect16    &rect,
@@ -243,31 +230,6 @@ ContainerView::ContainerView(
 ContainerView::~ContainerView() {
 }
 
-/****** contain.cpp/ContainerView::findPane ***********************
-*
-*   NAME
-*             findPane - find a ContainerView control that is
-*                        viewing the contents of the target object
-*
-*   SYNOPSIS
-*             If pane is NULL, start search at first ContainerView
-*             else, start search at pane->next.
-*
-*             Iterate through ContainerView list until a
-*             ContainerView is found that is viewing the
-*             target object (obj).
-*
-*   INPUTS
-*             obj   Target Game Object
-*             pane  Previously found pane, or NULL if search start
-*
-*   RESULT
-*             Returns a pointer to a ContainterPanel if one is found
-*             or NULL if no more found.
-*
-********************************************************************
-*/
-
 //  returns true if the object is visible for this type of
 //  container.
 bool ContainerView::isVisible(GameObject *item) {
@@ -318,10 +280,6 @@ void ContainerView::totalObjects() {
 			totalBulk += proto->bulk * numItems;
 		}
 	}
-
-//	ContainerView *viewToUpdate = ContainerView::findPane( containerObject );
-
-//	viewToUpdate->getWindow()->update( viewToUpdate->getExtent() );
 }
 
 //  Return the Nth visible object from this container.
@@ -892,37 +850,6 @@ void ContainerView::updateMouseText(Point16 &pickPos) {
 	}
 }
 
-#if 0
-//  Functions do not appear to be called
-
-void ContainerView::setCursorText(GameObject *obj) {
-	assert(obj);
-
-	const   bufSize = 40;
-	char cursorText[bufSize];
-
-	// put the normalized text into cursorText
-	obj->objCursorText(cursorText, bufSize);
-
-	g_vm->_mouseInfo->setText(cursorText);
-}
-
-void ContainerView::setDelayedCursorText(GameObject *obj) {
-	// clear out the mouse text
-	g_vm->_mouseInfo->setText(NULL);
-	mouseText[0] = 0;
-
-	// reset the alarm flag
-	objTextAlarm = false;
-
-	// set the hint alarm
-	containerObjTextAlarm.set(ticksPerSecond / 2);
-
-	// put the normalized text into mouseText
-	obj->objCursorText(mouseText, bufSize);
-}
-#endif
-
 /* ===================================================================== *
     EnchantmentContainerView member functions
  * ===================================================================== */
@@ -1187,10 +1114,6 @@ ScrollableContainerWindow::ScrollableContainerWindow(
 TangibleContainerWindow::TangibleContainerWindow(
     ContainerNode &nd, const ContainerAppearanceDef &app)
 	: ScrollableContainerWindow(nd, app, "ObjectWindow") {
-#if DEBUG
-	assert(view->containerObject);
-	assert(view->containerObject->proto());
-#endif
 
 	const int weightIndicatorType = 2;
 	objRect = app.iconRect;
@@ -1666,10 +1589,9 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
 				cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::deadType);
 		} else if (owner != ContainerNode::nobody) {
 			return OpenMindContainer(owner, open, /*mType*/ openMindType);
+		} else {
+			error("Attempt to open non-dead actor as a container");
 		}
-#if DEBUG
-		else fatal("Attempt to open non-dead actor as a container.\n");
-#endif
 	} else {
 		if (actorIDToPlayerID(obj->possessor(), owner) == false)
 			owner = ContainerNode::nobody;
@@ -1742,21 +1664,15 @@ void cleanupContainers() {
 }
 
 void initContainerNodes() {
-#if DEBUG
 	//  Verify the globalContainerList only has ready ContainerNodes
 
-	ContainerNode   *node;
-	bool            onlyReady = true;
+	Common::List<ContainerNode *>::iterator it;
 
-	for (node = g_vm->_cnm->first(); node != NULL; node = node->next()) {
-		if (node->getType() != ContainerNode::readyType) {
-			onlyReady = false;
-			break;
+	for (it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) {
+		if ((*it)->getType() != ContainerNode::readyType) {
+			error("initContainerNodes: ContainerNode type not readyType (%d != %d)", (*it)->getType(), ContainerNode::readyType);
 		}
 	}
-
-	assert(onlyReady);
-#endif
 }
 
 void saveContainerNodes(Common::OutSaveFile *outS) {




More information about the Scummvm-git-logs mailing list