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

a-yyg 76591232+a-yyg at users.noreply.github.com
Mon Jul 19 03:09:27 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:
1fd8d05f6c SAGA2: Fix some global constructor warnings
ef860488e1 SAGA2: Fix more global constructor warning in path.cpp


Commit: 1fd8d05f6c08f57dba1ec3c510e3735b2ea3ef43
    https://github.com/scummvm/scummvm/commit/1fd8d05f6c08f57dba1ec3c510e3735b2ea3ef43
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-19T12:07:29+09:00

Commit Message:
SAGA2: Fix some global constructor warnings

Changed paths:
    engines/saga2/idtypes.h
    engines/saga2/path.cpp


diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 0edf8a26eb..78e80481ac 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -458,6 +458,10 @@ enum {
 	BASE_REC_RATE = 1
 };
 
+enum {
+	kObjectVolumeArraySize = 128
+};
+
 } // end of namespace Saga2
 
 #endif
diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 3006903aed..8e9a389f39 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -164,6 +164,12 @@ class PathTileRegion {
 
 public:
 
+	PathTileRegion() {
+		mapNum = 0;
+		array = nullptr;
+		subMetaFlags = nullptr;
+	}
+
 	void init(
 	    int16           map,
 	    const TilePoint &org,
@@ -1281,10 +1287,10 @@ static PathSubMetaFlags     subMetaFlags;
 
 static MaskComputer         *maskComp;
 
-static PriorityQueue<QueueItem, 192> queue;
+static PriorityQueue<QueueItem, 192> *queue;
 static PathArray            *cellArray;
 
-static TileRegion           objectVolumeArray[128];
+static TileRegion           *objectVolumeArray;
 
 struct VolumeLookupNode {
 	VolumeLookupNode        *next;
@@ -1360,7 +1366,7 @@ static void push(
 	newItem.direction = direction;
 	newItem.pad = 0;
 
-	if (queue.insert(newItem)) {
+	if (queue->insert(newItem)) {
 		cellPtr->direction = direction;
 		cellPtr->platformDelta = platformDelta;
 		cellPtr->cost = cost;
@@ -1372,31 +1378,6 @@ static void push(
 }
 
 
-/* ===================================================================== *
-   Path finder management functions
- * ===================================================================== */
-
-void initPathFinder(void) {
-	pathTileArray = (PathTilePosArray *)malloc( sizeof *pathTileArray);
-	maskComp = new MaskComputer;
-	cellArray = new PathArray;
-}
-
-void cleanupPathFinder(void) {
-	if (pathTileArray) {
-		free(pathTileArray);
-		pathTileArray = nullptr;
-	}
-	if (maskComp) {
-		delete maskComp;
-		maskComp = nullptr;
-	}
-	if (cellArray != nullptr) {
-		delete cellArray;
-		cellArray = nullptr;
-	}
-}
-
 /* ===================================================================== *
    Member Functions
  * ===================================================================== */
@@ -1452,7 +1433,7 @@ void PathRequest::initialize(void) {
 	baseCoords.z = 0;
 
 	//  Clear the priority queue
-	queue.clear();
+	queue->clear();
 
 	//  Initialize the tile array
 	tileArray.init(
@@ -1548,7 +1529,7 @@ void PathRequest::initialize(void) {
 			}
 		}
 
-		if (++objectVolumes >= ARRAYSIZE(objectVolumeArray)) break;
+		if (++objectVolumes >= kObjectVolumeArraySize) break;
 	}
 big_break:
 
@@ -1714,7 +1695,7 @@ PathResult PathRequest::findPath(void) {
 
 	int32 lastTick_ = gameTime;
 
-	while (queue.remove(qi)) {
+	while (queue->remove(qi)) {
 		assert(cellArray->getCell(qi.platform, qi.u, qi.v) != nullptr);
 		assert(qi.u >= 1 && qi.u < searchDiameter - 1);
 		assert(qi.v >= 1 && qi.v < searchDiameter - 1);
@@ -2028,7 +2009,7 @@ PathResult PathRequest::findPath(void) {
 			//  Cost should never be less than previous cost
 			cost = MAX<int16>(cost, qi.cost);
 
-			//  Push the new point onto the queue.
+			//  Push the new point onto the queue->
 
 			push(
 			    TilePoint(
@@ -2067,7 +2048,7 @@ bool PathRequest::timeLimitExceeded(void) {
 #ifdef OLD_PATHFINDER_TIME_MGMT
 	return (gameTime - firstTick >= timeLimit);
 #else
-	int32 cutoff = smartness / (queue.getCount() ? 5 : 8);
+	int32 cutoff = smartness / (queue->getCount() ? 5 : 8);
 	return (gameTime - firstTick >= cutoff);
 #endif
 }
@@ -2407,7 +2388,7 @@ enum cellStates {
 
 typedef uint8       SimpleCellArray[searchDiameter][searchDiameter];
 
-static PriorityQueue<QueueItem, 128> squeue;
+static PriorityQueue<QueueItem, 128> *squeue;
 
 static void spush(const TilePoint &tp, int cost, int direction) {
 	QueueItem       newItem;
@@ -2425,7 +2406,7 @@ static void spush(const TilePoint &tp, int cost, int direction) {
 	newItem.direction = direction;
 	newItem.platform = 0;
 
-	squeue.insert(newItem);
+	squeue->insert(newItem);
 }
 
 /*  ordering of bits:
@@ -2503,7 +2484,7 @@ TilePoint selectNearbySite(
 
 	//  Clear the search array and the queue
 	memset(cellArray1, cellUnvisited, sizeof(*cellArray1));
-	squeue.clear();
+	squeue->clear();
 
 	//  Iterate through all actors in the region and mark areas
 	//  as occupied.
@@ -2547,7 +2528,7 @@ TilePoint selectNearbySite(
 	      1,                              // initial cost is 1
 	      0);                             // facing irrelevant
 
-	while (squeue.remove(qi)) {
+	while (squeue->remove(qi)) {
 		TilePoint   centerTileCoords,
 		            distVector;
 		StaticTilePoint *tDir;
@@ -2689,7 +2670,7 @@ TilePoint selectNearbySite(
 
 			*cell |= cellVisited;
 
-			//  Push the new point onto the queue.
+			//  Push the new point onto the queue->
 			//  (Cost is random so as to allow site selection to
 			//  be somewhat non-deterministic).
 			spush(TilePoint(qi.u + tDir->u,
@@ -2771,7 +2752,7 @@ bool checkPath(
 
 	//  Clear the search array and the queue
 	memset(cellArray1, cellUnvisited, sizeof(* cellArray1));
-	squeue.clear();
+	squeue->clear();
 
 	//  Push the starting location in the center of the array.
 	minTileRegU = (startingCoords.u - kTileUVSize / 2) >> kTileUVShift;
@@ -2822,7 +2803,7 @@ bool checkPath(
 		}
 	}
 
-	while (squeue.remove(qi)) {
+	while (squeue->remove(qi)) {
 		TilePoint   centerTileCoords;
 		StaticTilePoint *tDir;
 		int16       centerDistFromDest;
@@ -2932,7 +2913,7 @@ bool checkPath(
 			}
 
 
-			//  Push the new point onto the queue.
+			//  Push the new point onto the queue->
 			spush(TilePoint(qi.u + tDir->u,
 			                qi.v + tDir->v,
 			                testPt.z),
@@ -2947,4 +2928,38 @@ bool checkPath(
 	return false;
 }
 
+
+/* ===================================================================== *
+   Path finder management functions
+ * ===================================================================== */
+
+void initPathFinder(void) {
+	queue = new PriorityQueue<QueueItem, 192>;
+	squeue = new PriorityQueue<QueueItem, 128>;
+	objectVolumeArray = new TileRegion[128];
+
+	pathTileArray = (PathTilePosArray *)malloc( sizeof *pathTileArray);
+	maskComp = new MaskComputer;
+	cellArray = new PathArray;
+}
+
+void cleanupPathFinder(void) {
+	if (pathTileArray) {
+		free(pathTileArray);
+		pathTileArray = nullptr;
+	}
+	if (maskComp) {
+		delete maskComp;
+		maskComp = nullptr;
+	}
+	if (cellArray != nullptr) {
+		delete cellArray;
+		cellArray = nullptr;
+	}
+
+	delete queue;
+	delete squeue;
+	delete[] objectVolumeArray;
+}
+
 } // end of namespace Saga2


Commit: ef860488e1f0a268c4176f6a81c46f5a22d791f2
    https://github.com/scummvm/scummvm/commit/ef860488e1f0a268c4176f6a81c46f5a22d791f2
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-19T12:07:29+09:00

Commit Message:
SAGA2: Fix more global constructor warning in path.cpp

Changed paths:
    engines/saga2/path.cpp


diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp
index 8e9a389f39..fbe6650fd6 100644
--- a/engines/saga2/path.cpp
+++ b/engines/saga2/path.cpp
@@ -1116,8 +1116,6 @@ protected:
 
 	static DirMaskGroup     *dirMasks;
 
-	static PathTileRegion   tileArray;
-
 	//  Calculates the center point given the base coordinate of the
 	//  cell array and a queue item which contains cell coordinates.
 	static void calcCenterPt(const TilePoint &baseTileCoords_, const QueueItem &qi) {
@@ -1134,6 +1132,8 @@ protected:
 	PathRequest(Actor *a, int16 howSmart);
 
 public:
+	static PathTileRegion   *tileArray;
+
 	virtual ~PathRequest() {
 		if (path)
 			delete[] path;
@@ -1316,9 +1316,9 @@ int16           PathRequest::fetchRadius;
 int32           PathRequest::firstTick,
                 PathRequest::timeLimit;
 
-DirMaskGroup    *PathRequest::dirMasks;
+DirMaskGroup    *PathRequest::dirMasks = nullptr;
 
-PathTileRegion  PathRequest::tileArray;
+PathTileRegion  *PathRequest::tileArray = nullptr;
 
 StaticTilePoint DestinationPathRequest::targetCoords = {0, 0, 0};
 uint8           DestinationPathRequest::targetPlatform;
@@ -1436,7 +1436,7 @@ void PathRequest::initialize(void) {
 	queue->clear();
 
 	//  Initialize the tile array
-	tileArray.init(
+	tileArray->init(
 	    actor->getMapNum(),
 	    TilePoint(
 	        baseTileCoords.u - 2,
@@ -1724,7 +1724,7 @@ PathResult PathRequest::findPath(void) {
 			tDir = tDirTable2;
 			endDir = 8;
 
-			tileArray.fetchTileSection(
+			tileArray->fetchTileSection(
 			    TilePoint(qi.u - fetchRadius, qi.v - fetchRadius, 0)
 			    +   baseTileCoords,
 			    TilePoint(
@@ -1739,7 +1739,7 @@ PathResult PathRequest::findPath(void) {
 
 			switch (qi.direction) {
 			case 0:
-				tileArray.fetchTileSection(
+				tileArray->fetchTileSection(
 				    TilePoint(
 				        qi.u + fetchRadius,
 				        qi.v - fetchRadius,
@@ -1748,7 +1748,7 @@ PathResult PathRequest::findPath(void) {
 				    TilePoint(1, fetchRadius << 1, 0));
 					// fall through
 			case 1:
-				tileArray.fetchTileSection(
+				tileArray->fetchTileSection(
 				    TilePoint(
 				        qi.u - fetchRadius,
 				        qi.v + fetchRadius,
@@ -1757,7 +1757,7 @@ PathResult PathRequest::findPath(void) {
 				    TilePoint((fetchRadius << 1) + 1, 1, 0));
 				break;
 			case 2:
-				tileArray.fetchTileSection(
+				tileArray->fetchTileSection(
 				    TilePoint(
 				        qi.u - fetchRadius + 1,
 				        qi.v + fetchRadius,
@@ -1766,7 +1766,7 @@ PathResult PathRequest::findPath(void) {
 				    TilePoint(fetchRadius << 1, 1, 0));
 					// fall through
 			case 3:
-				tileArray.fetchTileSection(
+				tileArray->fetchTileSection(
 				    TilePoint(
 				        qi.u - fetchRadius,
 				        qi.v - fetchRadius,
@@ -1775,7 +1775,7 @@ PathResult PathRequest::findPath(void) {
 				    TilePoint(1, (fetchRadius << 1) + 1, 0));
 				break;
 			case 4:
-				tileArray.fetchTileSection(
+				tileArray->fetchTileSection(
 				    TilePoint(
 				        qi.u - fetchRadius,
 				        qi.v - fetchRadius + 1,
@@ -1784,7 +1784,7 @@ PathResult PathRequest::findPath(void) {
 				    TilePoint(1, fetchRadius << 1, 0));
 					// fall through
 			case 5:
-				tileArray.fetchTileSection(
+				tileArray->fetchTileSection(
 				    TilePoint(
 				        qi.u - fetchRadius,
 				        qi.v - fetchRadius,
@@ -1793,7 +1793,7 @@ PathResult PathRequest::findPath(void) {
 				    TilePoint((fetchRadius << 1) + 1, 1, 0));
 				break;
 			case 6:
-				tileArray.fetchTileSection(
+				tileArray->fetchTileSection(
 				    TilePoint(
 				        qi.u - fetchRadius,
 				        qi.v - fetchRadius,
@@ -1802,7 +1802,7 @@ PathResult PathRequest::findPath(void) {
 				    TilePoint(fetchRadius << 1, 1,  0));
 					// fall through
 			case 7:
-				tileArray.fetchTileSection(
+				tileArray->fetchTileSection(
 				    TilePoint(
 				        qi.u + fetchRadius,
 				        qi.v - fetchRadius,
@@ -1842,7 +1842,7 @@ PathResult PathRequest::findPath(void) {
 				testPt.u += tDirTable[dir].u;
 				testPt.v += tDirTable[dir].v;
 				testPt.z =  tileSlopeHeight(
-				                tileArray,
+				                *tileArray,
 				                testPt,
 				                actor,
 				                &pti,
@@ -1872,9 +1872,9 @@ PathResult PathRequest::findPath(void) {
 				        u < maskReg.max.u;
 				        u++, maskU++) {
 					PathTilePosInfo *arrRow =
-					    &tileArray.array[
-					        (u - tileArray.origin.u)
-					        *   tileArray.area.v];
+					    &tileArray->array[
+					        (u - tileArray->origin.u)
+					        *   tileArray->area.v];
 
 					for (v = maskReg.min.v, maskV = 0;
 					        v < maskReg.max.v;
@@ -1901,7 +1901,7 @@ PathResult PathRequest::findPath(void) {
 						}
 
 						terrain |=  tileTerrain(
-						                &arrRow[v - tileArray.origin.v],
+						                &arrRow[v - tileArray->origin.v],
 						                ptMask.mask[(maskU << 2) | maskV],
 						                testPt.z,
 						                testPt.z + aph);
@@ -2941,6 +2941,7 @@ void initPathFinder(void) {
 	pathTileArray = (PathTilePosArray *)malloc( sizeof *pathTileArray);
 	maskComp = new MaskComputer;
 	cellArray = new PathArray;
+	PathRequest::tileArray = new PathTileRegion;
 }
 
 void cleanupPathFinder(void) {
@@ -2960,6 +2961,7 @@ void cleanupPathFinder(void) {
 	delete queue;
 	delete squeue;
 	delete[] objectVolumeArray;
+	delete PathRequest::tileArray;
 }
 
 } // end of namespace Saga2




More information about the Scummvm-git-logs mailing list