[Scummvm-git-logs] scummvm master -> 176e81f5d36576d452a659082c60507c83b57022

a-yyg 76591232+a-yyg at users.noreply.github.com
Sat Aug 28 14:58:22 UTC 2021


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:
ab60363941 SAGA2: More const correctness in contain.cpp
5fd2ab4794 SAGA2: Rename _containerList
176e81f5d3 SAGA2: Use streams for locateRegion


Commit: ab60363941b7b748d9a67c5e50eafe3e14f8587f
    https://github.com/scummvm/scummvm/commit/ab60363941b7b748d9a67c5e50eafe3e14f8587f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-08-28T23:57:30+09:00

Commit Message:
SAGA2: More const correctness in contain.cpp

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


diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index a44ef22c8e..359fc17c8c 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -120,25 +120,25 @@ static ContainerAppearanceDef physicalContainerAppearance = {
 	0
 };
 
-static StaticWindow brassDecorations[] = {
+static const StaticWindow brassDecorations[] = {
 	{{0,  0, 268,  86},   nullptr, 3},
 	{{13, 86, 242, 109},  nullptr, 4},
 	{{13, 195, 242, 121}, nullptr, 5}
 };
 
-static StaticWindow clothDecorations[] = {
+static const StaticWindow clothDecorations[] = {
 	{{0,  0, 268,  86},   nullptr, 6},
 	{{13, 86, 242, 109},  nullptr, 7},
 	{{13, 195, 242, 121}, nullptr, 8}
 };
 
-static StaticWindow steelDecorations[] = {
+static const StaticWindow steelDecorations[] = {
 	{{0,  0, 268,  86},   nullptr, 9},
 	{{13, 86, 242, 109},  nullptr, 10},
 	{{13, 195, 242, 121}, nullptr, 11}
 };
 
-static StaticWindow woodDecorations[] = {
+static const StaticWindow woodDecorations[] = {
 	{{0,  0, 268,  86},   nullptr, 12},
 	{{13, 86, 242, 109},  nullptr, 13},
 	{{13, 195, 242, 121}, nullptr, 14}
@@ -163,14 +163,14 @@ static ContainerAppearanceDef deathContainerAppearance = {
 };
 
 // physal dialog window decorations
-static StaticWindow deathDecorations[] = {
+static const StaticWindow deathDecorations[] = {
 	{{0,  0, 206,  250}, nullptr, 15}
 };
 
 //-----------------------------------------------------------------------
 //	ReadyContainer appearance
 
-static ContainerAppearanceDef readyContainerAppearance = {
+static const ContainerAppearanceDef readyContainerAppearance = {
 	{0, 0, 0, 0},
 	{476, 105, 0, 0},
 	{0, 0, 0, 0},
@@ -188,7 +188,7 @@ static ContainerAppearanceDef readyContainerAppearance = {
 //-----------------------------------------------------------------------
 //	Mental Container appearance
 
-static ContainerAppearanceDef mentalContainerAppearance = {
+static const ContainerAppearanceDef mentalContainerAppearance = {
 	{478, 168 - 54, 158, 215},
 	{2, 86 - 18 - 4, 158 - 2, 215 - 66},
 	{2, 19, 44, 44},
@@ -203,13 +203,13 @@ static ContainerAppearanceDef mentalContainerAppearance = {
 	20
 };
 
-static StaticWindow mentalDecorations[] = {
+static const StaticWindow mentalDecorations[] = {
 	{{0,  0, 158,  215}, nullptr, 0}      //  Bottom decoration panel
 };
 //-----------------------------------------------------------------------
 //	Enchantment container appearance
 
-static ContainerAppearanceDef enchantmentContainerAppearance = {
+static const ContainerAppearanceDef enchantmentContainerAppearance = {
 	{262, 92, 116, 202},
 	{2, 87, 116 - 2, 202 - 87},
 	{7, 50, 44, 43},
@@ -244,7 +244,7 @@ ContainerView::ContainerView(
     gPanelList      &list,
     const Rect16    &rect,
     ContainerNode   &nd,
-    ContainerAppearanceDef &app,
+    const ContainerAppearanceDef &app,
     AppFunc         *cmd)
 	: gControl(list, rect, NULL, 0, cmd),
 	  iconOrigin(app.iconOrigin),
@@ -952,7 +952,7 @@ void ContainerView::setDelayedCursorText(GameObject *obj) {
 EnchantmentContainerView::EnchantmentContainerView(
     gPanelList      &list,
     ContainerNode   &nd,
-    ContainerAppearanceDef &app,
+    const ContainerAppearanceDef &app,
     AppFunc         *cmd)
 	: ContainerView(list, app.viewRect, nd, app, cmd) {
 }
@@ -1155,7 +1155,7 @@ void ReadyContainerView::drawClipped(
 //  ContainerWindow class
 
 ContainerWindow::ContainerWindow(ContainerNode &nd,
-                                 ContainerAppearanceDef &app,
+                                 const ContainerAppearanceDef &app,
                                  const char saveas[])
 	: FloatingWindow(nd.position, 0, saveas, cmdWindowFunc) {
 	//  Initialize view to NULL.
@@ -1184,7 +1184,7 @@ ContainerView &ContainerWindow::getView(void) {
  * ===================================================================== */
 
 ScrollableContainerWindow::ScrollableContainerWindow(
-    ContainerNode &nd, ContainerAppearanceDef &app, const char saveas[])
+    ContainerNode &nd, const ContainerAppearanceDef &app, const char saveas[])
 	: ContainerWindow(nd, app, saveas) {
 	view = new ContainerView(*this, app.viewRect, nd, app);
 
@@ -1207,7 +1207,7 @@ ScrollableContainerWindow::ScrollableContainerWindow(
  * ===================================================================== */
 
 TangibleContainerWindow::TangibleContainerWindow(
-    ContainerNode &nd, ContainerAppearanceDef &app)
+    ContainerNode &nd, const ContainerAppearanceDef &app)
 	: ScrollableContainerWindow(nd, app, "ObjectWindow") {
 #if DEBUG
 	assert(view->containerObject);
@@ -1227,7 +1227,7 @@ TangibleContainerWindow::TangibleContainerWindow(
 		               containerRes, 'F', 'R', 'M');
 		massWeightIndicator = NULL;
 	} else {
-		static StaticWindow *winDecs[] =  {
+		const StaticWindow *winDecs[] =  {
 			brassDecorations,
 		    clothDecorations,
 		    steelDecorations,
@@ -1309,7 +1309,7 @@ void TangibleContainerWindow::drawClipped(
  * ===================================================================== */
 
 IntangibleContainerWindow::IntangibleContainerWindow(
-    ContainerNode &nd, ContainerAppearanceDef &app)
+    ContainerNode &nd, const ContainerAppearanceDef &app)
 	: ScrollableContainerWindow(nd, app, "MentalWindow") {
 	// make the button conected to this window
 	mindSelectorCompButton = new GfxMultCompButton(
@@ -1337,7 +1337,7 @@ IntangibleContainerWindow::IntangibleContainerWindow(
  * ===================================================================== */
 
 EnchantmentContainerWindow::EnchantmentContainerWindow(
-    ContainerNode &nd, ContainerAppearanceDef &app)
+    ContainerNode &nd, const ContainerAppearanceDef &app)
 	: ContainerWindow(nd, app, "EnchantmentWindow") {
 	view = new EnchantmentContainerView(*this, nd, app);
 
@@ -1865,11 +1865,12 @@ void updateContainerWindows(void) {
 }
 
 void setMindContainer(int index, IntangibleContainerWindow &cw) {
-	static int classTable[] = { protoClassIdeaContainer,
-	                            protoClassSkillContainer,
-	                            protoClassMemoryContainer,
-	                            protoClassPsychContainer    // Not used anymore
-	                          };
+	const int classTable[] = {
+		protoClassIdeaContainer,
+		protoClassSkillContainer,
+		protoClassMemoryContainer,
+		protoClassPsychContainer    // Not used anymore
+	};
 
 	ObjectID        ownerID = cw.getView().node.getObject();
 	GameObject      *object = GameObject::objectAddress(ownerID);
@@ -1899,10 +1900,10 @@ APPFUNC(cmdMindContainerFunc) {
 		ContainerNode   &nd = cw->getView().node;
 		int             newMindType = nd.mindType;
 
-		static Rect16   idea(0, 0, 22, 67),       // idea button click area
-		       skill(22, 0, 11, 67),    // skill area
-		       memory(33, 0,  9, 67),   // memory area
-		       psych(42, 0, 10, 67);    // psych(ic?) area
+		const Rect16 idea(0, 0, 22, 67),      // idea button click area
+		             skill(22, 0, 11, 67),    // skill area
+		             memory(33, 0,  9, 67),   // memory area
+		             psych(42, 0, 10, 67);    // psych(ic?) area
 
 		if (idea.ptInside(ev.mouse))    newMindType = 0; //protoClassIdeaContainer;
 		if (skill.ptInside(ev.mouse))   newMindType = 1; //protoClassSkillContainer;
@@ -1917,9 +1918,9 @@ APPFUNC(cmdMindContainerFunc) {
 	} else if (ev.eventType == gEventMouseMove) {
 		//if (ev.value == gCompImage::enter)
 		{
-			static Rect16   idea(0, 0, 22, 67),       // idea button click area
-			       skill(22, 0, 11, 67),    // skill area
-			       memory(33, 0,  9, 67);   // memory area
+			const Rect16 idea(0, 0, 22, 67),      // idea button click area
+			             skill(22, 0, 11, 67),    // skill area
+			             memory(33, 0,  9, 67);   // memory area
 
 
 			const int BUF_SIZE = 64;
@@ -1989,8 +1990,8 @@ APPFUNC(cmdCloseButtonFunc) {
 
 APPFUNC(cmdScrollFunc) {
 	if (ev.panel && ev.eventType == gEventNewValue && ev.value) {
-		ScrollableContainerWindow       *cw;
-		static Rect16                   upArea(0, 0, 44, 22);
+		ScrollableContainerWindow *cw;
+		const Rect16 upArea(0, 0, 44, 22);
 
 		cw = (ScrollableContainerWindow *)ev.window;
 		if (upArea.ptInside(ev.mouse))
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index b24535667e..31517f098e 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -140,7 +140,7 @@ public:
 	    gPanelList &,
 	    const Rect16 &,
 	    ContainerNode &nd,
-	    ContainerAppearanceDef &app,
+	    const ContainerAppearanceDef &app,
 	    AppFunc *cmd = NULL);
 
 	//  Destructor
@@ -260,7 +260,7 @@ class  EnchantmentContainerView : public ContainerView {
 public:
 	EnchantmentContainerView(gPanelList &list,
 	                         ContainerNode &nd,
-	                         ContainerAppearanceDef &app,
+	                         const ContainerAppearanceDef &app,
 	                         AppFunc *cmd = NULL);
 
 	virtual void pointerMove(gPanelMessage &msg);
@@ -278,7 +278,7 @@ protected:
 
 public:
 	ContainerWindow(ContainerNode &nd,
-	                ContainerAppearanceDef &app,
+	                const ContainerAppearanceDef &app,
 	                const char saveas[]);
 
 	virtual ~ContainerWindow(void);
@@ -298,7 +298,7 @@ protected:
 
 public:
 	ScrollableContainerWindow(ContainerNode &nd,
-	                          ContainerAppearanceDef &app,
+	                          const ContainerAppearanceDef &app,
 	                          const char saveas[]);
 
 	void scrollUp(void) {
@@ -326,7 +326,7 @@ private:
 public:
 
 	TangibleContainerWindow(ContainerNode &nd,
-	                        ContainerAppearanceDef &app);
+	                        const ContainerAppearanceDef &app);
 	~TangibleContainerWindow(void);
 
 	void drawClipped(gPort &port, const Point16 &offset, const Rect16 &clip);
@@ -343,7 +343,7 @@ private:
 
 public:
 
-	IntangibleContainerWindow(ContainerNode &nd, ContainerAppearanceDef &app);
+	IntangibleContainerWindow(ContainerNode &nd, const ContainerAppearanceDef &app);
 };
 
 class EnchantmentContainerWindow : public ContainerWindow {
@@ -352,7 +352,7 @@ protected:
 
 public:
 	EnchantmentContainerWindow(ContainerNode &nd,
-	                           ContainerAppearanceDef &app);
+	                           const ContainerAppearanceDef &app);
 };
 
 /* ===================================================================== *
diff --git a/engines/saga2/floating.cpp b/engines/saga2/floating.cpp
index 83e173ac53..ae93942880 100644
--- a/engines/saga2/floating.cpp
+++ b/engines/saga2/floating.cpp
@@ -170,7 +170,7 @@ void DecoratedWindow::setDecorations(
 }
 
 void DecoratedWindow::setDecorations(
-    StaticWindow *dec,
+    const StaticWindow *dec,
     int16           count,
     hResContext     *con) {
 	int16           i;
@@ -186,16 +186,15 @@ void DecoratedWindow::setDecorations(
 
 	for (i = 0; i < numDecorations; i++, dec++) {
 		// request an image pointer from the image Cache
-		dec->image = g_vm->_imageCache->requestImage(con,
-		                                     MKTAG('B', 'R', 'D', dec->imageNumber));
 		decorations[i].extent = dec->extent;
-		decorations[i].image = dec->image;
+		decorations[i].image = g_vm->_imageCache->requestImage(con,
+		                                     MKTAG('B', 'R', 'D', dec->imageNumber));
 		decorations[i].imageNumber = dec->imageNumber;
 	}
 }
 
 void DecoratedWindow::setDecorations(
-    StaticWindow *dec,
+    const StaticWindow *dec,
     int16           count,
     hResContext     *con,
     hResID          id_) {
@@ -212,15 +211,14 @@ void DecoratedWindow::setDecorations(
 
 	for (i = 0; i < numDecorations; i++, dec++) {
 		// request an image pointer from the image Cache
-		dec->image = g_vm->_imageCache->requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
 		decorations[i].extent = dec->extent;
-		decorations[i].image = dec->image;
+		decorations[i].image = g_vm->_imageCache->requestImage(con, id_ | MKTAG(0, 0, 0, dec->imageNumber));
 		decorations[i].imageNumber = dec->imageNumber;
 	}
 }
 
 void DecoratedWindow::setDecorations(
-    StaticWindow *dec,
+    const StaticWindow *dec,
     int16           count,
     hResContext     *con,
     char a, char b, char c) {
diff --git a/engines/saga2/floating.h b/engines/saga2/floating.h
index 697a8f47e9..83483ed6f2 100644
--- a/engines/saga2/floating.h
+++ b/engines/saga2/floating.h
@@ -233,9 +233,9 @@ public:
 	void setDecorations(WindowDecoration *, int16, hResContext *, hResID);
 	void setDecorations(WindowDecoration *, int16, hResContext *, char, char, char);
 
-	void setDecorations(StaticWindow *, int16, hResContext *);
-	void setDecorations(StaticWindow *, int16, hResContext *, hResID);
-	void setDecorations(StaticWindow *, int16, hResContext *, char, char, char);
+	void setDecorations(const StaticWindow *, int16, hResContext *);
+	void setDecorations(const StaticWindow *, int16, hResContext *, hResID);
+	void setDecorations(const StaticWindow *, int16, hResContext *, char, char, char);
 
 
 	//  Free up memory used by decorative panels


Commit: 5fd2ab479456ea567c0dd76f545282af5bc91fa8
    https://github.com/scummvm/scummvm/commit/5fd2ab479456ea567c0dd76f545282af5bc91fa8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-08-28T23:57:30+09:00

Commit Message:
SAGA2: Rename _containerList

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 742ae603a4..e152b2f77d 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -168,7 +168,7 @@ bool ActorProto::closeAction(ObjectID dObj, ObjectID) {
 	assert(isActor(dObj));
 
 	GameObject      *dObjPtr = GameObject::objectAddress(dObj);
-	ContainerNode   *cn = g_vm->_containerList->find(dObj, ContainerNode::deadType);
+	ContainerNode   *cn = g_vm->_cnm->find(dObj, ContainerNode::deadType);
 
 	assert(dObjPtr->isOpen());
 	assert(cn);
@@ -2241,7 +2241,7 @@ void Actor::holdInRightHand(ObjectID objID) {
 	_rightHandObject = objID;
 
 	if (isPlayerActor(this))
-		g_vm->_containerList->setUpdate(thisID());
+		g_vm->_cnm->setUpdate(thisID());
 
 	evalActorEnchantments(this);
 }
@@ -2251,7 +2251,7 @@ void Actor::holdInLeftHand(ObjectID objID) {
 	_leftHandObject = objID;
 
 	if (isPlayerActor(this))
-		g_vm->_containerList->setUpdate(thisID());
+		g_vm->_cnm->setUpdate(thisID());
 
 	evalActorEnchantments(this);
 }
@@ -2277,7 +2277,7 @@ void Actor::wear(ObjectID objID, uint8 where) {
 	_armorObjects[where] = objID;
 
 	if (isPlayerActor(this))
-		g_vm->_containerList->setUpdate(thisID());
+		g_vm->_cnm->setUpdate(thisID());
 
 	evalActorEnchantments(this);
 
diff --git a/engines/saga2/contain.cpp b/engines/saga2/contain.cpp
index 359fc17c8c..0fc29a8f2a 100644
--- a/engines/saga2/contain.cpp
+++ b/engines/saga2/contain.cpp
@@ -1359,7 +1359,7 @@ EnchantmentContainerWindow::EnchantmentContainerWindow(
    ContainerNode functions
  * ===================================================================== */
 
-ContainerNode::ContainerNode(ContainerList &cl, ObjectID id, int typ) {
+ContainerNode::ContainerNode(ContainerManager &cl, ObjectID id, int typ) {
 	GameObject      *obj = GameObject::objectAddress(id);
 	PlayerActorID   ownerID;
 
@@ -1426,7 +1426,7 @@ ContainerNode::~ContainerNode() {
 	hide();
 
 	//  Remove from container list
-	g_vm->_containerList->remove(this);
+	g_vm->_cnm->remove(this);
 }
 
 void ContainerNode::read(Common::InSaveFile *in) {
@@ -1540,7 +1540,7 @@ void ContainerNode::update(void) {
 }
 
 //  Find a container node, given a specific object
-ContainerNode *ContainerList::find(ObjectID id) {
+ContainerNode *ContainerManager::find(ObjectID id) {
 	for (Common::List<ContainerNode *>::iterator it = _list.begin(); it != _list.end(); ++it)
 		if ((*it)->object == id)
 			return *it;
@@ -1548,7 +1548,7 @@ ContainerNode *ContainerList::find(ObjectID id) {
 	return NULL;
 }
 
-ContainerNode *ContainerList::find(ObjectID id, int16 type) {
+ContainerNode *ContainerManager::find(ObjectID id, int16 type) {
 	for (Common::List<ContainerNode *>::iterator it = _list.begin(); it != _list.end(); ++it)
 		if ((*it)->object == id && (*it)->type == type)
 			return *it;
@@ -1589,10 +1589,10 @@ void ContainerNode::changeOwner(int16 newOwner) {
 }
 
 /* ===================================================================== *
-   ContainerList functions
+   ContainerManager functions
  * ===================================================================== */
 
-void ContainerList::setPlayerNum(PlayerActorID playerNum) {
+void ContainerManager::setPlayerNum(PlayerActorID playerNum) {
 	//  Close all containers which are not on the ground and not owned
 	//  by the current protagonist.
 	for (Common::List<ContainerNode *>::iterator it = _list.begin(); it != _list.end(); ++it) {
@@ -1611,7 +1611,7 @@ void ContainerList::setPlayerNum(PlayerActorID playerNum) {
 	}
 }
 
-void ContainerList::doDeferredActions(void) {
+void ContainerManager::doDeferredActions(void) {
 	Common::List<ContainerNode *>::iterator nextIt;
 	Actor           *a = getCenterActor();
 	TilePoint       tp = a->getLocation();
@@ -1654,7 +1654,7 @@ void ContainerList::doDeferredActions(void) {
 	}
 }
 
-void ContainerList::setUpdate(ObjectID id) {
+void ContainerManager::setUpdate(ObjectID id) {
 	//  Close all containers which are not on the ground and not owned
 	//  by the current protagonist.
 	for (Common::List<ContainerNode *>::iterator it = _list.begin(); it != _list.end(); ++it) {
@@ -1684,8 +1684,8 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
 
 		if (((Actor *)obj)->isDead()) {
 			//  Open dead container for dead actor
-			if (!(cn = g_vm->_containerList->find(owner, ContainerNode::deadType)))
-				cn = new ContainerNode(*g_vm->_containerList, id, ContainerNode::deadType);
+			if (!(cn = g_vm->_cnm->find(owner, ContainerNode::deadType)))
+				cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::deadType);
 		} else if (owner != ContainerNode::nobody) {
 			return OpenMindContainer(owner, open, /*mType*/ openMindType);
 		}
@@ -1696,8 +1696,8 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
 		if (actorIDToPlayerID(obj->possessor(), owner) == false)
 			owner = ContainerNode::nobody;
 
-		if (!(cn = g_vm->_containerList->find(id, ContainerNode::physicalType)))
-			cn = new ContainerNode(*g_vm->_containerList, id, ContainerNode::physicalType);
+		if (!(cn = g_vm->_cnm->find(id, ContainerNode::physicalType)))
+			cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::physicalType);
 	}
 
 	//  If node was successfull created, and we wanted it open, and the owner
@@ -1712,7 +1712,7 @@ ContainerNode *CreateContainerNode(ObjectID id, bool open, int16) {
 }
 
 ContainerNode *CreateReadyContainerNode(PlayerActorID player) {
-	return new ContainerNode(*g_vm->_containerList,
+	return new ContainerNode(*g_vm->_cnm,
 	                            getPlayerActorAddress(player)->getActorID(),
 	                            ContainerNode::readyType);
 }
@@ -1721,8 +1721,8 @@ ContainerNode *OpenMindContainer(PlayerActorID player, int16 open, int16 type) {
 	ContainerNode   *cn;
 	ObjectID        id = getPlayerActorAddress(player)->getActorID();
 
-	if (!(cn = g_vm->_containerList->find(id, ContainerNode::mentalType))) {
-		cn = new ContainerNode(*g_vm->_containerList, id, ContainerNode::mentalType);
+	if (!(cn = g_vm->_cnm->find(id, ContainerNode::mentalType))) {
+		cn = new ContainerNode(*g_vm->_cnm, id, ContainerNode::mentalType);
 		cn->mindType = type;
 
 		//  If node was successfull created, and we wanted it open, and the owner
@@ -1770,7 +1770,7 @@ void initContainerNodes(void) {
 	ContainerNode   *node;
 	bool            onlyReady = true;
 
-	for (node = g_vm->_containerList->first(); node != NULL; node = node->next()) {
+	for (node = g_vm->_cnm->first(); node != NULL; node = node->next()) {
 		if (node->getType() != ContainerNode::readyType) {
 			onlyReady = false;
 			break;
@@ -1788,10 +1788,10 @@ void saveContainerNodes(Common::OutSaveFile *outS) {
 	int16 numNodes = 0;
 
 	//  Make sure there are no pending container view actions
-	g_vm->_containerList->doDeferredActions();
+	g_vm->_cnm->doDeferredActions();
 
 	//  Count the number of nodes to save
-	for (Common::List<ContainerNode *>::iterator it = g_vm->_containerList->_list.begin(); it != g_vm->_containerList->_list.end(); ++it) {
+	for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) {
 		ContainerNode *n = *it;
 
 		if (n->getType() != ContainerNode::readyType)
@@ -1806,7 +1806,7 @@ void saveContainerNodes(Common::OutSaveFile *outS) {
 	debugC(3, kDebugSaveload, "... numNodes = %d", numNodes);
 
 	//  Store the nodes
-	for (Common::List<ContainerNode *>::iterator it = g_vm->_containerList->_list.begin(); it != g_vm->_containerList->_list.end(); ++it) {
+	for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) {
 		ContainerNode *n = *it;
 
 		if (n->getType() != ContainerNode::readyType) {
@@ -1837,19 +1837,19 @@ void loadContainerNodes(Common::InSaveFile *in) {
 		node->read(in);
 
 		//  Add it back to the container list
-		g_vm->_containerList->add(node);
+		g_vm->_cnm->add(node);
 	}
 
 	assert(tempList.empty());
 }
 
 void cleanupContainerNodes(void) {
-	if (g_vm->_containerList == nullptr)
+	if (g_vm->_cnm == nullptr)
 		return;
 
 	Common::Array<ContainerNode *> deletionArray;
 
-	for (Common::List<ContainerNode *>::iterator it = g_vm->_containerList->_list.begin(); it != g_vm->_containerList->_list.end(); ++it) {
+	for (Common::List<ContainerNode *>::iterator it = g_vm->_cnm->_list.begin(); it != g_vm->_cnm->_list.end(); ++it) {
 		ContainerNode *n = *it;
 
 		if (n->getType() != ContainerNode::readyType)
@@ -1861,7 +1861,7 @@ void cleanupContainerNodes(void) {
 }
 
 void updateContainerWindows(void) {
-	g_vm->_containerList->doDeferredActions();
+	g_vm->_cnm->doDeferredActions();
 }
 
 void setMindContainer(int index, IntangibleContainerWindow &cw) {
diff --git a/engines/saga2/contain.h b/engines/saga2/contain.h
index 31517f098e..2f0b9c19b5 100644
--- a/engines/saga2/contain.h
+++ b/engines/saga2/contain.h
@@ -44,7 +44,7 @@ class EnchantContainerView;
 //				FloatingWindow
 class ContainerWindow;
 class ContainerNode;
-class ContainerList;
+class ContainerManager;
 struct ContainerAppearanceDef;
 
 class CMassWeightIndicator;
@@ -389,7 +389,7 @@ struct ContainerAppearanceDef {
 
 class ContainerNode {
 
-	friend class    ContainerList;
+	friend class    ContainerManager;
 	friend class    ContainerView;
 	friend class    ContainerWindow;
 
@@ -443,7 +443,7 @@ public:
 		action = 0;
 		mindType = 0;
 	}
-	ContainerNode(ContainerList &cl, ObjectID id, int type);
+	ContainerNode(ContainerManager &cl, ObjectID id, int type);
 	~ContainerNode();
 
 	static int32 archiveSize(void) {
@@ -504,7 +504,7 @@ public:
 
 //  A list of container nodes
 
-class ContainerList {
+class ContainerManager {
 public:
 	Common::List<ContainerNode *> _list;
 
diff --git a/engines/saga2/motion.cpp b/engines/saga2/motion.cpp
index 7dba743fe8..831e088cd2 100644
--- a/engines/saga2/motion.cpp
+++ b/engines/saga2/motion.cpp
@@ -3477,7 +3477,7 @@ void MotionTask::fireBowAction(void) {
 					actorLoc.z += a->proto()->height * 7 / 8;
 
 					if ((projID =   proj->extractMerged(Location(actorLoc, a->IDParent()), 1)) !=  Nothing) {
-						g_vm->_containerList->setUpdate(a->thisID());
+						g_vm->_cnm->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 758fe1988b..93d5281d60 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -1020,7 +1020,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
 	        &&  isPlayerActor((Actor *)oldParent))
 	        || (isObject(oldParentID)
 	            &&  oldParent->isOpen())) {
-		g_vm->_containerList->setUpdate(oldParentID);
+		g_vm->_cnm->setUpdate(oldParentID);
 	}
 
 	if (_data.parentID != oldParentID && isActor(oldParentID)) {
@@ -1069,7 +1069,7 @@ void GameObject::updateImage(ObjectID oldParentID) {
 		        &&  isPlayerActor((Actor *)parent))
 		        || (isObject(_data.parentID) && parent->isOpen())
 		   ) {
-			g_vm->_containerList->setUpdate(_data.parentID);
+			g_vm->_cnm->setUpdate(_data.parentID);
 		}
 	}
 }
@@ -1310,7 +1310,7 @@ void GameObject::deleteObject(void) {
 	removeAllSensors();
 
 	//  Delete any container nodes for this object
-	while ((cn = g_vm->_containerList->find(dObj)) != nullptr)
+	while ((cn = g_vm->_cnm->find(dObj)) != nullptr)
 		delete cn;
 
 	if (isActor(_data.parentID)) {
@@ -2240,7 +2240,7 @@ void GameObject::setProtoNum(int32 nProto) {
 
 		//  If this object is in a container, then redraw the container window
 		if (!isWorld(oldParentID))
-			g_vm->_containerList->setUpdate(oldParentID);
+			g_vm->_cnm->setUpdate(oldParentID);
 	}
 }
 
@@ -2311,7 +2311,7 @@ void GameObject::mergeWith(GameObject *dropObj, GameObject *target, int16 count)
 		dropObj->deleteObject();
 	}
 
-	g_vm->_containerList->setUpdate(target->IDParent());
+	g_vm->_cnm->setUpdate(target->IDParent());
 }
 
 
@@ -2340,7 +2340,7 @@ bool GameObject::stack(ObjectID enactor, ObjectID objToStackID) {
 		if (!objToStack->isMoving()) {
 			//  Increase the stack count
 			_data.location.z++;
-			g_vm->_containerList->setUpdate(IDParent());
+			g_vm->_cnm->setUpdate(IDParent());
 		}
 
 		return true;
diff --git a/engines/saga2/objproto.cpp b/engines/saga2/objproto.cpp
index b98365c4ca..63d27cfbba 100644
--- a/engines/saga2/objproto.cpp
+++ b/engines/saga2/objproto.cpp
@@ -1258,14 +1258,14 @@ bool PhysicalContainerProto::openAction(ObjectID dObj, ObjectID) {
 	cn = CreateContainerNode(dObj, false);
 	cn->markForShow();                                      //  Deferred open
 	dObjPtr->_data.objectFlags |= objectOpen;         //  Set open bit;
-	g_vm->_containerList->setUpdate(dObjPtr->IDParent());
+	g_vm->_cnm->setUpdate(dObjPtr->IDParent());
 
 	return true;
 }
 
 bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
 	GameObject      *dObjPtr = GameObject::objectAddress(dObj);
-	ContainerNode   *cn = g_vm->_containerList->find(dObj, ContainerNode::physicalType);
+	ContainerNode   *cn = g_vm->_cnm->find(dObj, ContainerNode::physicalType);
 
 	assert(dObjPtr->isOpen());
 	assert(cn);
@@ -1275,7 +1275,7 @@ bool PhysicalContainerProto::closeAction(ObjectID dObj, ObjectID) {
 
 	//  Clear open bit
 	dObjPtr->_data.objectFlags &= ~objectOpen;
-	g_vm->_containerList->setUpdate(dObjPtr->IDParent());
+	g_vm->_cnm->setUpdate(dObjPtr->IDParent());
 
 	return true;
 }
@@ -2237,7 +2237,7 @@ bool ArmorProto::useAction(ObjectID dObj, ObjectID enactor) {
 	else
 		a->wear(dObj, slot);
 
-	g_vm->_containerList->setUpdate(obj->IDParent());
+	g_vm->_cnm->setUpdate(obj->IDParent());
 
 	return true;
 }
@@ -2927,7 +2927,7 @@ bool IntangibleContainerProto::openAction(ObjectID dObj, ObjectID enactor) {
 }
 
 bool IntangibleContainerProto::closeAction(ObjectID dObj, ObjectID) {
-	ContainerNode *cn = g_vm->_containerList->find(dObj, ContainerNode::mentalType);
+	ContainerNode *cn = g_vm->_cnm->find(dObj, ContainerNode::mentalType);
 
 	assert(cn);
 
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 7f0357572b..a51099a8a7 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -564,7 +564,7 @@ void setCenterActor(PlayerActorID newCenter) {
 	viewCenterObject = g_vm->_playerList[centerActor]->getActorID();
 
 	indivReadyNode->changeOwner(newCenter);
-	g_vm->_containerList->setPlayerNum(newCenter);
+	g_vm->_cnm->setPlayerNum(newCenter);
 	setEnchantmentDisplay();
 
 	if (a->_curTask != NULL) {
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 0c9243a204..0176ee1c5e 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -74,6 +74,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
 	_act = nullptr;
 	_calender = nullptr;
 	_tmm = nullptr;
+	_cnm = nullptr;
 
 	_bandList = nullptr;
 	_mouseInfo = nullptr;
@@ -118,7 +119,6 @@ Saga2Engine::Saga2Engine(OSystem *syst)
 
 	_edpList = nullptr;
 	_sdpList = nullptr;
-	_containerList = nullptr;
 	_tileImageBanks = nullptr;
 	_stackList = nullptr;
 	_taskList = nullptr;
@@ -138,6 +138,7 @@ Saga2Engine::~Saga2Engine() {
 	delete _act;
 	delete _calender;
 	delete _tmm;
+	delete _cnm;
 
 	delete _imageCache;
 	delete _mTaskList;
@@ -150,15 +151,12 @@ Saga2Engine::~Saga2Engine() {
 	delete _properties;
 	delete _aTaskList;
 	delete _grandMasterFTA;
-	delete _containerList;
 }
 
 Common::Error Saga2Engine::run() {
 	// Initialize graphics using following:
 	initGraphics(640, 480);
 
-	_containerList = new ContainerList;
-
 	_console = new Console(this);
 	setDebugger(_console);
 
@@ -168,6 +166,7 @@ Common::Error Saga2Engine::run() {
 	_act = new ActorManager;
 	_calender = new CalenderTime;
 	_tmm = new TileModeManager;
+	_cnm = new ContainerManager;
 
 	readConfig();
 
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 16662adec5..5264f8cb34 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -46,7 +46,7 @@ class MemoryWriteStreamDynamic;
 
 namespace Saga2 {
 
-class ContainerList;
+class ContainerManager;
 class Timer;
 class TimerList;
 class BandList;
@@ -144,6 +144,7 @@ public:
 	ActorManager *_act;
 	CalenderTime *_calender;
 	TileModeManager *_tmm;
+	ContainerManager *_cnm;
 
 	WeaponStuff _weaponRack[kMaxWeapons];
 	weaponID _loadedWeapons;
@@ -166,7 +167,6 @@ public:
 	GrabInfo *_mouseInfo;
 	EffectDisplayPrototypeList *_edpList;
 	SpellDisplayPrototypeList *_sdpList;
-	ContainerList *_containerList;
 	DisplayNodeList *_mainDisplayList;
 	SpellDisplayList *_activeSpells;
 	gMousePointer *_pointer;
diff --git a/engines/saga2/sagafunc.cpp b/engines/saga2/sagafunc.cpp
index 0a7f196648..2a2c448387 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))
-				g_vm->_containerList->setUpdate(targetID);
+				g_vm->_cnm->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) {
-			g_vm->_containerList->setUpdate(obj->IDParent());
+			g_vm->_cnm->setUpdate(obj->IDParent());
 		}
 		return true;
 	} else return false;
@@ -2099,13 +2099,13 @@ int16 scriptActorDeductPayment(int16 *args) {
 
 				if (massCount > paymentAmount) {
 					obj->setExtra(massCount - paymentAmount);
-					g_vm->_containerList->setUpdate(obj->IDParent());
+					g_vm->_cnm->setUpdate(obj->IDParent());
 					break;
 				} else {
 					if (delObj) {
 						ObjectID    dParent = delObj->IDParent();
 						delObj->deleteObject();
-						g_vm->_containerList->setUpdate(dParent);
+						g_vm->_cnm->setUpdate(dParent);
 					}
 					paymentAmount -= massCount;
 					delObj = obj;
@@ -2118,7 +2118,7 @@ int16 scriptActorDeductPayment(int16 *args) {
 				if (delObj) {
 					ObjectID    dParent = delObj->IDParent();
 					delObj->deleteObject();
-					g_vm->_containerList->setUpdate(dParent);
+					g_vm->_cnm->setUpdate(dParent);
 				}
 				delObj = obj;
 			}
@@ -2128,7 +2128,7 @@ int16 scriptActorDeductPayment(int16 *args) {
 	if (delObj) {
 		ObjectID    dParent = delObj->IDParent();
 		delObj->deleteObject();
-		g_vm->_containerList->setUpdate(dParent);
+		g_vm->_cnm->setUpdate(dParent);
 	}
 
 	//  Payment succeeded!
@@ -2992,7 +2992,7 @@ int16 scriptDeleteObject(int16 *args) {
 	assert(obj);
 	oldParentID = obj->IDParent();
 	obj->deleteObjectRecursive();
-	g_vm->_containerList->setUpdate(oldParentID);
+	g_vm->_cnm->setUpdate(oldParentID);
 
 	return 0;
 }


Commit: 176e81f5d36576d452a659082c60507c83b57022
    https://github.com/scummvm/scummvm/commit/176e81f5d36576d452a659082c60507c83b57022
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-08-28T23:57:30+09:00

Commit Message:
SAGA2: Use streams for locateRegion

Changed paths:
    engines/saga2/automap.cpp


diff --git a/engines/saga2/automap.cpp b/engines/saga2/automap.cpp
index 80cc357a43..82391e838f 100644
--- a/engines/saga2/automap.cpp
+++ b/engines/saga2/automap.cpp
@@ -193,41 +193,41 @@ AutoMap::~AutoMap() {
 // read map data
 
 void AutoMap::locateRegion(void) {
-	hResContext     *areaRes;       // tile resource handle
-	uint16          *trRes;
-	int16           regionCount;
-	struct TileRect {
-		int16       uMin, vMin, uMax, vMax;
-	} *tr;
-	WorldMapData    *wMap = &mapList[currentWorld->mapNum];
-	int             i;
+	Common::SeekableReadStream *stream;
+	hResContext *areaRes;       // tile resource handle
+	int16 regionCount;
+	WorldMapData *wMap = &mapList[currentWorld->mapNum];
 
 	areaRes = auxResFile->newContext(MKTAG('A', 'M', 'A', 'P'), "AreaList");
 	assert(areaRes != NULL);
 
-	trRes = (uint16 *)LoadResource(areaRes, MKTAG('Z', 'O', 'N', currentWorld->mapNum), "AreaList");
-	assert(trRes != NULL);
-	regionCount = *trRes;
+	stream = loadResourceToStream(areaRes, MKTAG('Z', 'O', 'N', currentWorld->mapNum), "AreaList");
+	regionCount = stream->readUint16LE();
 
 	_centerCoords = _trackPos >> (kTileUVShift + kPlatShift);
 
 	_localAreaRegion.min.u = _localAreaRegion.min.v = 0;
 	_localAreaRegion.max.u = _localAreaRegion.max.v = wMap->mapSize;
 
-	for (i = 0, tr = (TileRect *)(trRes + 1); i < regionCount; i++, tr++) {
-		if (_centerCoords.u >= tr->uMin
-		        &&  _centerCoords.u <= tr->uMax
-		        &&  _centerCoords.v >= tr->vMin
-		        &&  _centerCoords.v <= tr->vMax) {
-			_localAreaRegion.min.u = tr->uMin;
-			_localAreaRegion.max.u = tr->uMax;
-			_localAreaRegion.min.v = tr->vMin;
-			_localAreaRegion.max.v = tr->vMax;
+	for (int i = 0; i < regionCount; i++) {
+		int uMin, vMin, uMax, vMax;
+		uMin = stream->readSint16LE();
+		vMin = stream->readSint16LE();
+		uMax = stream->readSint16LE();
+		vMax = stream->readSint16LE();
+		if (_centerCoords.u >= uMin
+		        &&  _centerCoords.u <= uMax
+		        &&  _centerCoords.v >= vMin
+		        &&  _centerCoords.v <= vMax) {
+			_localAreaRegion.min.u = uMin;
+			_localAreaRegion.max.u = uMax;
+			_localAreaRegion.min.v = vMin;
+			_localAreaRegion.max.v = vMax;
 			break;
 		}
 	}
 
-	free(trRes);
+	delete stream;
 
 	auxResFile->disposeContext(areaRes);
 




More information about the Scummvm-git-logs mailing list