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

a-yyg 76591232+a-yyg at users.noreply.github.com
Fri Jul 16 21:54:50 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:
ce6b9a1a1b SAGA2: Fix global constructor in speech.cpp
cc93ff8ff4 SAGA2: Fix global constructor in object.cpp


Commit: ce6b9a1a1b0603d9d0a0307097e37f14b858b99f
    https://github.com/scummvm/scummvm/commit/ce6b9a1a1b0603d9d0a0307097e37f14b858b99f
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-17T06:52:37+09:00

Commit Message:
SAGA2: Fix global constructor in speech.cpp

Changed paths:
    engines/saga2/speech.cpp
    engines/saga2/speech.h
    engines/saga2/tile.cpp
    engines/saga2/tile.h


diff --git a/engines/saga2/speech.cpp b/engines/saga2/speech.cpp
index 52c32bf25e..6ccf743978 100644
--- a/engines/saga2/speech.cpp
+++ b/engines/saga2/speech.cpp
@@ -93,7 +93,7 @@ static TextSpan     speechLineList[64],   // list of speech lines
 int16               speechLineCount,        // count of speech lines
                     speechButtonCount;      // count of speech buttons
 
-static Point16      initialSpeechPosition;  // inital coords of speech
+static StaticPoint16 initialSpeechPosition = {0, 0};  // inital coords of speech
 
 //  Image data for the little "bullet"
 static uint8 BulletData[] = {
@@ -460,7 +460,7 @@ void Speech::setWidth() {
 //-----------------------------------------------------------------------
 //	Calculate the position of the speech, emanating from the actor.
 
-bool Speech::calcPosition(Point16 &p) {
+bool Speech::calcPosition(StaticPoint16 &p) {
 	GameObject      *obj = GameObject::objectAddress(objID);
 	TilePoint       tp = obj->getWorldLocation();
 
@@ -483,13 +483,15 @@ bool Speech::calcPosition(Point16 &p) {
 //	Draw the text on the back buffer
 
 bool Speech::displayText(void) {
-	Point16         p;
+	StaticPoint16 p;
 
 	//  If there are button in the speech, then don't scroll the
 	//  speech along with the display. Otherwise, calculate the
 	//  position from the actor.
-	if (speechButtonCount > 0) p = initialSpeechPosition;
-	else if (!calcPosition(p)) return false;
+	if (speechButtonCount > 0)
+		p = initialSpeechPosition;
+	else if (!calcPosition(p))
+		return false;
 
 	//  Blit to the port
 	backPort.setMode(drawModeMatte);
diff --git a/engines/saga2/speech.h b/engines/saga2/speech.h
index 22c7c7a126..4b8ab914e1 100644
--- a/engines/saga2/speech.h
+++ b/engines/saga2/speech.h
@@ -38,6 +38,7 @@ namespace Saga2 {
 
 extern  gPort       backPort;
 void    TileToScreenCoords(const TilePoint &tp, Point16 &p);
+void    TileToScreenCoords(const TilePoint &tp, StaticPoint16 &p);
 void    updateSpeech();
 extern  TilePoint centerActorCoords(void);
 bool    isVisible(GameObject *obj);
@@ -125,7 +126,7 @@ private:
 	bool displayText(void);
 	int16 fits(int16 space);
 	void setWidth(void);
-	bool calcPosition(Point16 &p);       // calculate position
+	bool calcPosition(StaticPoint16 &p);       // calculate position
 	void remove(void);                   //  Remove from active list
 
 public:
diff --git a/engines/saga2/tile.cpp b/engines/saga2/tile.cpp
index f2dc6475ee..ed3c4c1cb4 100644
--- a/engines/saga2/tile.cpp
+++ b/engines/saga2/tile.cpp
@@ -1721,6 +1721,14 @@ void TileToScreenCoords(const TilePoint &tp, Point16 &p) {
 	p.y = mapHeight - tileScroll.y - ((int32)tp.u + (int32)tp.v) - tp.z;
 }
 
+void TileToScreenCoords(const TilePoint &tp, StaticPoint16 &p) {
+	int32       mapHeight = mapList[currentMapNum].mapHeight;
+
+	//  screen coords of the point
+	p.x = (((int32)tp.u - (int32)tp.v) << 1) - tileScroll.x + mapHeight;
+	p.y = mapHeight - tileScroll.y - ((int32)tp.u + (int32)tp.v) - tp.z;
+}
+
 TilePoint::TilePoint(Common::SeekableReadStream *stream) {
 	u = stream->readSint16LE();
 	v = stream->readSint16LE();
diff --git a/engines/saga2/tile.h b/engines/saga2/tile.h
index 871d3b5e23..d55dfb2f12 100644
--- a/engines/saga2/tile.h
+++ b/engines/saga2/tile.h
@@ -1030,6 +1030,7 @@ inline bool platformRipped(Platform *pl) {
 //  Compute visible area in U/V coords
 TilePoint XYToUV(const Point32 &pt);
 void TileToScreenCoords(const TilePoint &tp, Point16 &p);
+void TileToScreenCoords(const TilePoint &tp, StaticPoint16 &p);
 
 //  Determine height of point on a tile based on four corner heights
 int16 ptHeight(const TilePoint &tp, uint8 *cornerHeight);


Commit: cc93ff8ff44c48b4e83666730b5de466c5895fb8
    https://github.com/scummvm/scummvm/commit/cc93ff8ff44c48b4e83666730b5de466c5895fb8
Author: a/ (yuri.kgpps at gmail.com)
Date: 2021-07-17T06:53:06+09:00

Commit Message:
SAGA2: Fix global constructor in object.cpp

Changed paths:
    engines/saga2/actor.cpp
    engines/saga2/idtypes.h
    engines/saga2/intrface.cpp
    engines/saga2/objects.cpp
    engines/saga2/player.cpp
    engines/saga2/player.h
    engines/saga2/saga2.cpp
    engines/saga2/saga2.h


diff --git a/engines/saga2/actor.cpp b/engines/saga2/actor.cpp
index 103b5e8b12..b83fdb2d4b 100644
--- a/engines/saga2/actor.cpp
+++ b/engines/saga2/actor.cpp
@@ -1460,7 +1460,7 @@ Actor *Actor::newActor(
 		int16       i;
 
 		//  Search actor list for first scavangable actor
-		for (i = playerActors; i < kActorCount; i++) {
+		for (i = kPlayerActors; i < kActorCount; i++) {
 			a = &actorList[i];
 
 			if ((a->flags & temporary)
diff --git a/engines/saga2/idtypes.h b/engines/saga2/idtypes.h
index 9e2534e970..c5b3be2415 100644
--- a/engines/saga2/idtypes.h
+++ b/engines/saga2/idtypes.h
@@ -456,6 +456,12 @@ enum {
 	kBubbleSpriteCount = 8
 };
 
+enum {
+	kPlayerActors = 3,
+	kMinAutoAggressionVitality = 5,
+	BASE_REC_RATE = 1
+};
+
 } // end of namespace Saga2
 
 #endif
diff --git a/engines/saga2/intrface.cpp b/engines/saga2/intrface.cpp
index 3bdc324d15..ad07700d5a 100644
--- a/engines/saga2/intrface.cpp
+++ b/engines/saga2/intrface.cpp
@@ -1886,8 +1886,8 @@ void setIndivBtns(uint16 brotherID) {    // top = 0, mid = 1, bot = 2
 	setEnchantmentDisplay();
 
 	// point the read containers to the correct brother
-	if (brotherID >= playerActors)
-		brotherID = playerActors - 1;
+	if (brotherID >= kPlayerActors)
+		brotherID = kPlayerActors - 1;
 
 	indivCviewTop->setContainer(GameObject::objectAddress(ActorBaseID + brotherID));
 	indivCviewTop->ghost(TrioCviews[brotherID]->isGhosted());
@@ -2212,7 +2212,7 @@ void toggleAgression(PlayerActorID bro, bool all) {
 	int16   wasAggressive = isAggressive(bro);
 
 	if (all) {
-		for (int i = 0; i < playerActors; i++)
+		for (int i = 0; i < kPlayerActors; i++)
 			setAggression(i, !wasAggressive);
 	} else setAggression(bro, !wasAggressive);
 }
@@ -2228,7 +2228,7 @@ APPFUNC(cmdAggressive) {
 
 //		if (rightButtonState())
 //		{
-//			for (int i = 0; i < playerActors; i++)
+//			for (int i = 0; i < kPlayerActors; i++)
 //				setAggression( i, !wasAggressive );
 //		}
 //		else setAggression( transBroID, !wasAggressive );
@@ -2294,7 +2294,7 @@ APPFUNC(cmdCenter) {
 
 	if (ev.eventType == gEventNewValue) {
 		if (rightButtonState())
-			setCenterBrother((transBroID + 1) % playerActors);
+			setCenterBrother((transBroID + 1) % kPlayerActors);
 		else setCenterBrother(transBroID);
 	}
 	if (ev.eventType == gEventMouseMove) {
@@ -2313,7 +2313,7 @@ void toggleBanding(PlayerActorID bro, bool all) {
 	int16   wasBanded = isBanded(bro);
 
 	if (all) {
-		for (int i = 0; i < playerActors; i++)
+		for (int i = 0; i < kPlayerActors; i++)
 			setBanded(i, !wasBanded);
 	} else setBanded(bro, !wasBanded);
 }
@@ -2327,7 +2327,7 @@ APPFUNC(cmdBand) {
 //
 //		if (rightButtonState())
 //		{
-//			for (int i = 0; i < playerActors; i++)
+//			for (int i = 0; i < kPlayerActors; i++)
 //				setBanded( i, !wasBanded );
 //		}
 //		else setBanded( transBroID, !wasBanded );
diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp
index 16638a03a9..3752f97c7f 100644
--- a/engines/saga2/objects.cpp
+++ b/engines/saga2/objects.cpp
@@ -3216,38 +3216,34 @@ void ActiveRegion::update(void) {
    ActiveRegion array
  * ======================================================================= */
 
-//	Global active region array
-
-static ActiveRegion activeRegionList[playerActors];
-
 //-------------------------------------------------------------------
 //	Iterate through the active regions, updating each
 
 void updateActiveRegions(void) {
 	int16   i;
 
-	for (i = 0; i < ARRAYSIZE(activeRegionList); i++)
-		activeRegionList[i].update();
+	for (i = 0; i < kPlayerActors; i++)
+		g_vm->_activeRegionList[i].update();
 }
 
 //-------------------------------------------------------------------
 //	Return a pointer to an active region given its PlayerActor's ID
 
 ActiveRegion *getActiveRegion(PlayerActorID id) {
-	return &activeRegionList[id];
+	return &g_vm->_activeRegionList[id];
 }
 
 //-------------------------------------------------------------------
 //	Initialize the state of the active regions
 
 void initActiveRegions(void) {
-	static PlayerActorID    playerIDArray[playerActors] =
+	static PlayerActorID    playerIDArray[kPlayerActors] =
 	{ FTA_JULIAN, FTA_PHILIP, FTA_KEVIN };
 
 	int16   i;
 
-	for (i = 0; i < playerActors; i++) {
-		ActiveRegion    *reg = &activeRegionList[i];
+	for (i = 0; i < kPlayerActors; i++) {
+		ActiveRegion    *reg = &g_vm->_activeRegionList[i];
 		ObjectID        actorID = getPlayerActorAddress(playerIDArray[i])->getActorID();
 
 		reg->anchor = actorID;
@@ -3263,9 +3259,9 @@ void saveActiveRegions(Common::OutSaveFile *outS) {
 
 	outS->write("AREG", 4);
 	CHUNK_BEGIN;
-	for (int i = 0; i < playerActors; ++i) {
+	for (int i = 0; i < kPlayerActors; ++i) {
 		debugC(3, kDebugSaveload, "Saving Active Region %d", i);
-		activeRegionList[i].write(out);
+		g_vm->_activeRegionList[i].write(out);
 	}
 	CHUNK_END;
 }
@@ -3273,9 +3269,9 @@ void saveActiveRegions(Common::OutSaveFile *outS) {
 void loadActiveRegions(Common::InSaveFile *in) {
 	debugC(2, kDebugSaveload, "Loading ActiveRegions");
 
-	for (int i = 0; i < playerActors; ++i) {
+	for (int i = 0; i < kPlayerActors; ++i) {
 		debugC(3, kDebugSaveload, "Loading Active Region %d", i);
-		activeRegionList[i].read(in);
+		g_vm->_activeRegionList[i].read(in);
 	}
 }
 
@@ -3745,12 +3741,12 @@ bool ActiveRegionObjectIterator::nextActiveRegion(void) {
 	TilePoint           currentRegionSize;
 
 	do {
-		if (++activeRegionIndex >= ARRAYSIZE(activeRegionList))
+		if (++activeRegionIndex >= kPlayerActors)
 			return false;
 
 		int16               prevRegionIndex;
 
-		currentRegion = &activeRegionList[activeRegionIndex];
+		currentRegion = &g_vm->_activeRegionList[activeRegionIndex];
 
 		sectorBitMask = 0;
 		currentRegionSize.u =       currentRegion->region.max.u
@@ -3764,7 +3760,7 @@ bool ActiveRegionObjectIterator::nextActiveRegion(void) {
 		        prevRegionIndex++) {
 			ActiveRegion    *prevRegion;
 
-			prevRegion = &activeRegionList[prevRegionIndex];
+			prevRegion = &g_vm->_activeRegionList[prevRegionIndex];
 
 			//  Determine if the current region and the previous region
 			//  overlap.
@@ -3925,7 +3921,7 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
 
 ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
 	assert(activeRegionIndex >= 0);
-	assert(activeRegionIndex < ARRAYSIZE(activeRegionList));
+	assert(activeRegionIndex < kPlayerActors);
 
 	ObjectID        currentObjectID;
 
@@ -4314,7 +4310,7 @@ void readyContainerSetup(void) {
 
 	indivReadyNode = CreateReadyContainerNode(0);
 
-	for (i = 0; i < kNumViews && i < playerActors ; i++) {
+	for (i = 0; i < kNumViews && i < kPlayerActors ; i++) {
 		playerList[i].readyNode = CreateReadyContainerNode(i);
 
 		TrioCviews[i] = new ReadyContainerView(
@@ -4375,7 +4371,7 @@ void cleanupReadyContainers(void) {
 		unloadImageRes(backImages, numReadyContRes);
 	}
 
-	for (int16 i = 0; i < kNumViews && i < playerActors ; i++) {
+	for (int16 i = 0; i < kNumViews && i < kPlayerActors ; i++) {
 		delete TrioCviews[i];
 		TrioCviews[i] = nullptr;
 
diff --git a/engines/saga2/player.cpp b/engines/saga2/player.cpp
index 7df8e12975..9668622de8 100644
--- a/engines/saga2/player.cpp
+++ b/engines/saga2/player.cpp
@@ -68,7 +68,7 @@ static PlayerActorID    centerActor;        //  Index of the current center
 bool                    brotherBandingEnabled;
 
 //  Master list of all playerActor structures
-PlayerActor playerList[playerActors] = {
+PlayerActor playerList[kPlayerActors] = {
 	PlayerActor(ActorBaseID +  0),       //  Julian
 	PlayerActor(ActorBaseID +  1),       //  Philip
 	PlayerActor(ActorBaseID +  2),       //  Kevin
@@ -546,7 +546,7 @@ PlayerActorID getCenterActorPlayerID(void) {
 void setCenterActor(PlayerActorID newCenter) {
 	extern void setEnchantmentDisplay(void);
 
-	assert(newCenter < playerActors);
+	assert(newCenter < kPlayerActors);
 
 	Actor                       *a = playerList[newCenter].getActor();
 	PlayerActorIterator         iter;
@@ -600,7 +600,7 @@ void setCenterActor(Actor *newCenter) {
 //	Set a new center actor based upon a PlayerActor address
 
 void setCenterActor(PlayerActor *newCenter) {
-	assert(newCenter >= playerList && newCenter < &playerList[playerActors]);
+	assert(newCenter >= playerList && newCenter < &playerList[kPlayerActors]);
 	setCenterActor(newCenter - playerList);
 }
 
@@ -619,7 +619,7 @@ TilePoint centerActorCoords(void) {
 //	Set or clear a player's aggressive state
 
 void setAggression(PlayerActorID player, bool aggression) {
-	assert(player >= 0 && player < playerActors);
+	assert(player >= 0 && player < kPlayerActors);
 
 	Actor       *a = playerList[player].getActor();
 
@@ -642,7 +642,7 @@ void setAggression(PlayerActorID player, bool aggression) {
 //	Determine if player actor is in an aggressive state
 
 bool isAggressive(PlayerActorID player) {
-	assert(player >= 0 && player < playerActors);
+	assert(player >= 0 && player < kPlayerActors);
 	return playerList[player].isAggressive();
 }
 
@@ -654,12 +654,12 @@ void autoAdjustAggression(void) {
 	PlayerActorID       i;
 
 	//  Iterate through all player actors
-	for (i = 0; i < playerActors; i++) {
+	for (i = 0; i < kPlayerActors; i++) {
 		if (i == centerActor || isBanded(i)) {
 			bool            enemiesPresent = false;
 			Actor           *actor = playerList[i].getActor();
 
-			if (actor->getStats()->vitality >= minAutoAggressionVitality) {
+			if (actor->getStats()->vitality >= kMinAutoAggressionVitality) {
 				GameObject      *obj;
 				ActiveRegion    *activeReg = getActiveRegion(i);
 				TileRegion      region = activeReg->getRegion();
@@ -694,7 +694,7 @@ void autoAdjustAggression(void) {
 //	Set a player actor's banding
 
 void setBanded(PlayerActorID player, bool banded) {
-	assert(player >= 0 && player < playerActors);
+	assert(player >= 0 && player < kPlayerActors);
 
 	if (playerList[player].getActor()->isDead()) return;
 
@@ -712,7 +712,7 @@ void setBanded(PlayerActorID player, bool banded) {
 //	Determine if a player actor is banded
 
 bool isBanded(PlayerActorID player) {
-	assert(player >= 0 && player < playerActors);
+	assert(player >= 0 && player < kPlayerActors);
 	return playerList[player].isBanded();
 }
 
@@ -782,7 +782,7 @@ bool actorIDToPlayerID(ObjectID id, PlayerActorID &result) {
 }
 
 void handlePlayerActorDeath(PlayerActorID id) {
-	assert(id >= 0 && id < playerActors);
+	assert(id >= 0 && id < kPlayerActors);
 
 	if (getCenterActor()->isDead()) {
 		PlayerActor                 *newCenter;
@@ -871,7 +871,7 @@ void handleEndOfCombat(void) {
 	PlayerActorID       i;
 
 	//  Iterate through all player actors
-	for (i = 0; i < playerActors; i++)
+	for (i = 0; i < kPlayerActors; i++)
 		playerList[i].resetAttackNotification();
 }
 
@@ -900,7 +900,7 @@ struct PlayerActorArchive {
 void initPlayerActors(void) {
 	PlayerActorID   i;
 
-	for (i = 0; i < playerActors; i++) {
+	for (i = 0; i < kPlayerActors; i++) {
 		PlayerActor     *p = &playerList[i];
 		Actor           *a = p->getActor();
 		ActorProto      *proto = (ActorProto *)a->proto();
@@ -940,7 +940,7 @@ void savePlayerActors(Common::OutSaveFile *outS) {
 
 	outS->write("PLYR", 4);
 	CHUNK_BEGIN;
-	for (int i = 0; i < playerActors; i++) {
+	for (int i = 0; i < kPlayerActors; i++) {
 		debugC(3, kDebugSaveload, "Saving PlayerActor %d", i);
 
 		PlayerActor *p = &playerList[i];
@@ -981,7 +981,7 @@ void savePlayerActors(Common::OutSaveFile *outS) {
 void loadPlayerActors(Common::InSaveFile *in) {
 	debugC(2, kDebugSaveload, "Loading PlayerActors");
 
-	for (int i = 0; i < playerActors; i++) {
+	for (int i = 0; i < kPlayerActors; i++) {
 		debugC(3, kDebugSaveload, "Loading PlayerActor %d", i);
 
 		PlayerActor *p = &playerList[i];
@@ -1083,7 +1083,7 @@ PlayerActor *PlayerActorIterator::first(void) {
 }
 
 PlayerActor *PlayerActorIterator::next(void) {
-	return (index < playerActors) ? &playerList[index++] : NULL;
+	return (index < kPlayerActors) ? &playerList[index++] : NULL;
 }
 
 //-----------------------------------------------------------------------
@@ -1095,18 +1095,18 @@ PlayerActor *LivingPlayerActorIterator::first(void) {
 }
 
 PlayerActor *LivingPlayerActorIterator::next(void) {
-	if (index >= playerActors)
+	if (index >= kPlayerActors)
 		return nullptr;
 
 	Actor       *a = playerList[index].getActor();
 
 	while (a == nullptr || a->isDead()) {
-		if (++index >= playerActors)
+		if (++index >= kPlayerActors)
 			break;
 		a = playerList[index].getActor();
 	}
 
-	return (index < playerActors) ? &playerList[index++] : nullptr;
+	return (index < kPlayerActors) ? &playerList[index++] : nullptr;
 }
 
 } // end of namespace Saga2
diff --git a/engines/saga2/player.h b/engines/saga2/player.h
index ad795237bd..a6c8099822 100644
--- a/engines/saga2/player.h
+++ b/engines/saga2/player.h
@@ -35,11 +35,6 @@ namespace Saga2 {
 #define FTA_PHILIP  (PlayerActorID)1
 #define FTA_KEVIN   (PlayerActorID)2
 
-const int playerActors  = 3;
-const int BASE_REC_RATE = 1;
-
-const int minAutoAggressionVitality = 5;
-
 /* ======================================================================= *
    PlayerActor -- data specific to possible center actors
  * ======================================================================= */
diff --git a/engines/saga2/saga2.cpp b/engines/saga2/saga2.cpp
index 445ded4f03..ca9896f7c2 100644
--- a/engines/saga2/saga2.cpp
+++ b/engines/saga2/saga2.cpp
@@ -82,6 +82,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
 	_mainDisplayList = new DisplayNodeList;
 	_activeSpells = new SpellDisplayList(kMaxActiveSpells);
 	_pointer = new gMousePointer(_mainPort);
+	_activeRegionList = new ActiveRegion[kPlayerActors];
 
 	_edpList = nullptr;
 	_sdpList = nullptr;
@@ -101,6 +102,7 @@ Saga2Engine::~Saga2Engine() {
 	delete _mainDisplayList;
 	delete _activeSpells;
 	delete _pointer;
+	delete[] _activeRegionList;
 }
 
 Common::Error Saga2Engine::run() {
diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h
index 6da38a367a..8cc6cae234 100644
--- a/engines/saga2/saga2.h
+++ b/engines/saga2/saga2.h
@@ -62,6 +62,7 @@ class SpellDisplayPrototypeList;
 class DisplayNodeList;
 class SpellDisplayList;
 class gMousePointer;
+class ActiveRegion;
 
 enum {
 	kDebugResources = 1 << 0,
@@ -138,6 +139,7 @@ public:
 	DisplayNodeList *_mainDisplayList;
 	SpellDisplayList *_activeSpells;
 	gMousePointer *_pointer;
+	ActiveRegion *_activeRegionList;
 
 	gDisplayPort _mainPort;
 




More information about the Scummvm-git-logs mailing list