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

mgerhardy martin.gerhardy at gmail.com
Fri Nov 6 19:51:59 UTC 2020


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

Summary:
38d5886b41 TWINE: const for src buffer
cd25f58842 TWINE: fixed endian issue while parsing the sprite bounding box for collisions
03df93afca TWINE: use IS_HERO macro
ed199ca4ae TWINE: fixed compiler warning about duplicate branch
515256d904 TWINE: replaced magic numbers and converted to boolean
955d2e71cf TWINE: converted to boolean
ce78c96474 TWINE: replaced magic numbers with constants
db9ab1d63e TWINE: fixed endian issues while parsing sprite bounding box for collisions
4783046f86 TWINE: fixed compiler warning about alignment issues
f969365688 TWINE: fixed endian issue in getText


Commit: 38d5886b412c4aecc2c5c6572a5c59a34ad0787f
    https://github.com/scummvm/scummvm/commit/38d5886b412c4aecc2c5c6572a5c59a34ad0787f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:40:00+01:00

Commit Message:
TWINE: const for src buffer

Changed paths:
    engines/twine/renderer.cpp
    engines/twine/renderer.h


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 5dfe6f784d..42954e4301 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1664,13 +1664,13 @@ int32 Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 an
 	return 0;
 }
 
-void Renderer::copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
+void Renderer::copyActorInternAnim(const uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
 	// check if both characters allow animation
-	if (!(*((int16 *)bodyPtrSrc) & 2)) {
+	if (!(*((const int16 *)bodyPtrSrc) & 2)) {
 		return;
 	}
 
-	if (!(*((int16 *)bodyPtrDest) & 2)) {
+	if (!(*((const int16 *)bodyPtrDest) & 2)) {
 		return;
 	}
 
@@ -1678,16 +1678,16 @@ void Renderer::copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
 	bodyPtrSrc += 16;
 	bodyPtrDest += 16;
 
-	*((uint32 *)bodyPtrDest) = *((uint32 *)bodyPtrSrc);
-	*((uint32 *)(bodyPtrDest + 4)) = *((uint32 *)(bodyPtrSrc + 4));
+	*((uint32 *)bodyPtrDest) = *((const uint32 *)bodyPtrSrc);
+	*((uint32 *)(bodyPtrDest + 4)) = *((const uint32 *)(bodyPtrSrc + 4));
 
-	bodyPtrSrc = bodyPtrSrc + *((int16 *)(bodyPtrSrc - 2));
-	bodyPtrSrc = bodyPtrSrc + (*((int16 *)bodyPtrSrc)) * 6 + 2;
-	int16 cx = *((int16 *)bodyPtrSrc);
+	bodyPtrSrc = bodyPtrSrc + *((const int16 *)(bodyPtrSrc - 2));
+	bodyPtrSrc = bodyPtrSrc + (*((const int16 *)bodyPtrSrc)) * 6 + 2;
+	int16 cx = *((const int16 *)bodyPtrSrc);
 
-	bodyPtrDest = bodyPtrDest + *((int16 *)(bodyPtrDest - 2));
-	bodyPtrDest = bodyPtrDest + (*((int16 *)bodyPtrDest)) * 6 + 2;
-	int16 ax = *((int16 *)bodyPtrDest);
+	bodyPtrDest = bodyPtrDest + *((const int16 *)(bodyPtrDest - 2));
+	bodyPtrDest = bodyPtrDest + (*((const int16 *)bodyPtrDest)) * 6 + 2;
+	int16 ax = *((const int16 *)bodyPtrDest);
 
 	if (cx > ax) {
 		cx = ax;
@@ -1697,8 +1697,8 @@ void Renderer::copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
 	bodyPtrDest += 10;
 
 	for (int32 i = 0; i < cx; i++) {
-		*((uint32 *)bodyPtrDest) = *((uint32 *)bodyPtrSrc);
-		*((uint32 *)(bodyPtrDest + 4)) = *((uint32 *)(bodyPtrSrc + 4));
+		*((uint32 *)bodyPtrDest) = *((const uint32 *)bodyPtrSrc);
+		*((uint32 *)(bodyPtrDest + 4)) = *((const uint32 *)(bodyPtrSrc + 4));
 
 		bodyPtrDest += 30;
 		bodyPtrSrc += 30;
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index 3de5614e70..a5a98d595b 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -234,7 +234,7 @@ public:
 
 	int32 renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ, uint8 *bodyPtr);
 
-	void copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest);
+	void copyActorInternAnim(const uint8 *bodyPtrSrc, uint8 *bodyPtrDest);
 
 	void renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight, int32 boxBottom, int32 Y, int32 angle, uint8 *entityPtr);
 


Commit: cd25f588429d93d65e3d03243d711b888234aaed
    https://github.com/scummvm/scummvm/commit/cd25f588429d93d65e3d03243d711b888234aaed
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:40:00+01:00

Commit Message:
TWINE: fixed endian issue while parsing the sprite bounding box for collisions

Changed paths:
    engines/twine/extra.cpp


diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 6a4f5bbbea..7e4b0d01d0 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "twine/extra.h"
+#include "common/memstream.h"
 #include "common/util.h"
 #include "twine/actor.h"
 #include "twine/collision.h"
@@ -840,8 +841,10 @@ void Extra::processExtras() {
 			}
 
 			if (process) {
-				const int16 *spriteBounds = (const int16 *)(_engine->_resources->spriteBoundingBoxPtr + extra->info0 * 16 + 8);
-				extra->y = (_engine->_collision->collisionY << 8) + 0x100 - *(spriteBounds);
+				Common::MemoryReadStream stream(_engine->_resources->spriteBoundingBoxPtr, _engine->_resources->spriteBoundingBoxSize);
+				stream.seek(extra->info0 * 16);
+				stream.skip(8);
+				extra->y = (_engine->_collision->collisionY << 8) + 0x100 - stream.readSint16LE();
 				extra->type &= 0xFFED;
 				continue;
 			}


Commit: 03df93afcaab8ed02472c69ed05a274c38a8b60e
    https://github.com/scummvm/scummvm/commit/03df93afcaab8ed02472c69ed05a274c38a8b60e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:40:00+01:00

Commit Message:
TWINE: use IS_HERO macro

Changed paths:
    engines/twine/animations.cpp
    engines/twine/collision.cpp


diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index eac0e82b88..2deaebade1 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -984,7 +984,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 		_engine->_collision->processCollisionY = _engine->_movements->processActorY;
 		_engine->_collision->processCollisionZ = _engine->_movements->processActorZ;
 
-		if (!actorIdx && !actor->staticFlags.bComputeLowCollision) {
+		if (IS_HERO(actorIdx) && !actor->staticFlags.bComputeLowCollision) {
 			// check hero collisions with bricks
 			_engine->_collision->checkHeroCollisionWithBricks(actor->boudingBox.x.bottomLeft, actor->boudingBox.y.bottomLeft, actor->boudingBox.z.bottomLeft, 1);
 			_engine->_collision->checkHeroCollisionWithBricks(actor->boudingBox.x.topRight, actor->boudingBox.y.bottomLeft, actor->boudingBox.z.bottomLeft, 2);
@@ -1010,7 +1010,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 					_engine->_extra->addExtraSpecial(actor->x, actor->y + 1000, actor->z, kHitStars);
 					initAnim(kBigHit, 2, 0, currentlyProcessedActorIdx);
 
-					if (currentlyProcessedActorIdx == 0) {
+					if (IS_HERO(currentlyProcessedActorIdx)) {
 						_engine->_movements->heroMoved = true;
 					}
 
@@ -1028,14 +1028,10 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 					_engine->_collision->stopFalling();
 					_engine->_movements->processActorY = (_engine->_collision->collisionY << 8) + 0x100;
 				} else {
-					if (!actorIdx && _engine->_actor->heroBehaviour == kAthletic && actor->anim == brickShape && _engine->cfgfile.WallCollision == 1) { // avoid wall hit damage
+					if (IS_HERO(actorIdx) && _engine->_actor->heroBehaviour == kAthletic && actor->anim == brickShape && _engine->cfgfile.WallCollision == 1) { // avoid wall hit damage
 						_engine->_extra->addExtraSpecial(actor->x, actor->y + 1000, actor->z, kHitStars);
 						initAnim(kBigHit, 2, 0, currentlyProcessedActorIdx);
-
-						if (!actorIdx) {
-							_engine->_movements->heroMoved = true;
-						}
-
+						_engine->_movements->heroMoved = true;
 						actor->life--;
 					}
 
@@ -1077,7 +1073,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 					if (!actor->dynamicFlags.bIsRotationByAnim) {
 						actor->dynamicFlags.bIsFalling = 1;
 
-						if (!actorIdx && _engine->_scene->heroYBeforeFall == 0) {
+						if (IS_HERO(actorIdx) && _engine->_scene->heroYBeforeFall == 0) {
 							_engine->_scene->heroYBeforeFall = _engine->_movements->processActorY;
 						}
 
diff --git a/engines/twine/collision.cpp b/engines/twine/collision.cpp
index dc122bd38a..99be613524 100644
--- a/engines/twine/collision.cpp
+++ b/engines/twine/collision.cpp
@@ -449,7 +449,7 @@ void Collision::checkActorCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 d
 }
 
 void Collision::stopFalling() { // ReceptionObj()
-	if (_engine->_animations->currentlyProcessedActorIdx == 0) {
+	if (IS_HERO(_engine->_animations->currentlyProcessedActorIdx)) {
 		const int32 fall = _engine->_scene->heroYBeforeFall - _engine->_movements->processActorY;
 
 		if (fall >= 0x1000) {


Commit: ed199ca4ae8d538366576fb7ba1888cb17df09eb
    https://github.com/scummvm/scummvm/commit/ed199ca4ae8d538366576fb7ba1888cb17df09eb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:40:00+01:00

Commit Message:
TWINE: fixed compiler warning about duplicate branch

Changed paths:
    engines/twine/collision.cpp


diff --git a/engines/twine/collision.cpp b/engines/twine/collision.cpp
index 99be613524..42d2100df3 100644
--- a/engines/twine/collision.cpp
+++ b/engines/twine/collision.cpp
@@ -452,12 +452,7 @@ void Collision::stopFalling() { // ReceptionObj()
 	if (IS_HERO(_engine->_animations->currentlyProcessedActorIdx)) {
 		const int32 fall = _engine->_scene->heroYBeforeFall - _engine->_movements->processActorY;
 
-		if (fall >= 0x1000) {
-			_engine->_extra->addExtraSpecial(_engine->_actor->processActorPtr->x, _engine->_actor->processActorPtr->y + 1000, _engine->_actor->processActorPtr->z, kHitStars);
-			_engine->_actor->processActorPtr->life--;
-			_engine->_animations->initAnim(kLandingHit, 2, 0, _engine->_animations->currentlyProcessedActorIdx);
-		} else if (fall >= 0x800) {
-			// TODO: the same as the other branch?
+		if (fall >= 2048) {
 			_engine->_extra->addExtraSpecial(_engine->_actor->processActorPtr->x, _engine->_actor->processActorPtr->y + 1000, _engine->_actor->processActorPtr->z, kHitStars);
 			_engine->_actor->processActorPtr->life--;
 			_engine->_animations->initAnim(kLandingHit, 2, 0, _engine->_animations->currentlyProcessedActorIdx);


Commit: 515256d904a8ffbbb37ea8e25e86eb05effd2557
    https://github.com/scummvm/scummvm/commit/515256d904a8ffbbb37ea8e25e86eb05effd2557
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:40:00+01:00

Commit Message:
TWINE: replaced magic numbers and converted to boolean

Changed paths:
    engines/twine/gamestate.cpp
    engines/twine/scene.cpp
    engines/twine/scene.h


diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index f2b7bfaa01..51a1b3c0c6 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -144,7 +144,7 @@ void GameState::initEngineVars() {
 	gameChapter = 0;
 
 	_engine->_scene->sceneTextBank = TextBankId::Options_and_menus;
-	_engine->_scene->currentlyFollowedActor = 0;
+	_engine->_scene->currentlyFollowedActor = OWN_ACTOR_SCENE_INDEX;
 	_engine->_actor->heroBehaviour = kNormal;
 	_engine->_actor->previousHeroAngle = 0;
 	_engine->_actor->previousHeroBehaviour = kNormal;
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index ad1c15536b..a9ae1a4df7 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -441,7 +441,7 @@ void Scene::processActorZones(int32 actorIdx) {
 	int32 tmpCellingGrid = 0;
 
 	if (IS_HERO(actorIdx)) {
-		currentActorInZone = actorIdx;
+		currentActorInZone = false;
 	}
 
 	for (int32 z = 0; z < sceneNumZones; z++) {
@@ -514,7 +514,7 @@ void Scene::processActorZones(int32 actorIdx) {
 
 					if (_engine->_renderer->destX >= 0 && _engine->_renderer->destZ >= 0 && _engine->_renderer->destX <= 0x7E00 && _engine->_renderer->destZ <= 0x7E00) {
 						if (_engine->_grid->getBrickShape(_engine->_renderer->destX, actor->y + 0x100, _engine->_renderer->destZ)) {
-							currentActorInZone = 1;
+							currentActorInZone = true;
 							if (actor->y >= ABS(zone->bottomLeft.y + zone->topRight.y) / 2) {
 								_engine->_animations->initAnim(kTopLadder, 2, 0, actorIdx); // reached end of ladder
 							} else {
diff --git a/engines/twine/scene.h b/engines/twine/scene.h
index 6f40621d33..110fe5d8f0 100644
--- a/engines/twine/scene.h
+++ b/engines/twine/scene.h
@@ -316,9 +316,9 @@ public:
 	int16 mecaPinguinIdx = 0; // currentPingouin
 
 	/** Current followed actor in scene */
-	int16 currentlyFollowedActor = 0;
-	/** Current actor in zone */
-	int16 currentActorInZone = 0; // currentActorInZoneProcess
+	int16 currentlyFollowedActor = OWN_ACTOR_SCENE_INDEX;
+	/** Current actor in zone - climbing a ladder */
+	bool currentActorInZone = false;
 	/** Current actor manipulated in scripts */
 	int16 currentScriptValue = 0; // manipActorResult
 


Commit: 955d2e71cfa648a83854b0f0c3eefc77724aa24c
    https://github.com/scummvm/scummvm/commit/955d2e71cfa648a83854b0f0c3eefc77724aa24c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:40:00+01:00

Commit Message:
TWINE: converted to boolean

Changed paths:
    engines/twine/gamestate.cpp
    engines/twine/gamestate.h
    engines/twine/movements.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 51a1b3c0c6..14cf4bdb96 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -103,7 +103,7 @@ void GameState::initHeroVars() {
 	inventoryNumKeys = 0;
 	inventoryMagicPoints = 0;
 
-	usingSabre = 0;
+	usingSabre = false;
 
 	_engine->_scene->sceneHero->body = 0;
 	_engine->_scene->sceneHero->life = 50;
@@ -139,7 +139,7 @@ void GameState::initEngineVars() {
 	_engine->_actor->cropBottomScreen = 0;
 
 	magicLevelIdx = 0;
-	usingSabre = 0;
+	usingSabre = false;
 
 	gameChapter = 0;
 
diff --git a/engines/twine/gamestate.h b/engines/twine/gamestate.h
index 8d6f2d5dee..9371f80777 100644
--- a/engines/twine/gamestate.h
+++ b/engines/twine/gamestate.h
@@ -139,7 +139,7 @@ public:
 	int16 inventoryNumGas = 0;
 
 	/** Its using FunFrock Sabre */
-	int16 usingSabre = 0;
+	bool usingSabre = false;
 
 	/** Inventory used flags */
 	uint8 inventoryFlags[NUM_INVENTORY_ITEMS];
diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index 4e79279acc..72f2a10f20 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -231,8 +231,7 @@ void Movements::update() {
 
 void Movements::processManualAction(int actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
-	// take this out when we want to give manual movements to other characters than Hero
-	if (actor == _engine->_scene->sceneHero) {
+	if (IS_HERO(actorIdx)) {
 		heroAction = false;
 
 		// If press W for action
@@ -254,7 +253,7 @@ void Movements::processManualAction(int actorIdx) {
 					heroMoved = true;
 					actor->angle = getRealAngle(&actor->move);
 					// TODO: previousLoopActionKey must be handled properly
-					if (!previousLoopActionKey || !actor->anim) {
+					if (!previousLoopActionKey || actor->anim == kAnimNone) {
 						const int32 aggresiveMode = _engine->getRandomNumber(3);
 
 						switch (aggresiveMode) {
@@ -291,7 +290,7 @@ void Movements::processManualAction(int actorIdx) {
 	}
 
 	if (_engine->_input->isActionActive(TwinEActionType::ThrowMagicBall) && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
-		if (_engine->_gameState->usingSabre == 0) { // Use Magic Ball
+		if (!_engine->_gameState->usingSabre) { // Use Magic Ball
 			if (_engine->_gameState->gameFlags[InventoryItems::kiMagicBall]) {
 				if (_engine->_gameState->magicBallIdx == -1) {
 					_engine->_animations->initAnim(kThrowBall, 1, 0, actorIdx);
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 36103f1f1f..4b71e48707 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -498,10 +498,10 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 				warning("Use inventory [kiHolomap] not implemented!\n");
 				break;
 			case kiMagicBall:
-				if (_gameState->usingSabre == 1) {
+				if (_gameState->usingSabre) {
 					_actor->initModelActor(0, 0);
 				}
-				_gameState->usingSabre = 0;
+				_gameState->usingSabre = false;
 				break;
 			case kiUseSabre:
 				if (_scene->sceneHero->body != InventoryItems::kiUseSabre) {
@@ -511,7 +511,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 					_actor->initModelActor(InventoryItems::kiUseSabre, 0);
 					_animations->initAnim(kSabreUnknown, 1, 0, 0);
 
-					_gameState->usingSabre = 1;
+					_gameState->usingSabre = true;
 				}
 				break;
 			case kiBookOfBu: {


Commit: ce78c96474cf2c48474fda3ca8d12092de0075b5
    https://github.com/scummvm/scummvm/commit/ce78c96474cf2c48474fda3ca8d12092de0075b5
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:40:00+01:00

Commit Message:
TWINE: replaced magic numbers with constants

Changed paths:
    engines/twine/extra.cpp
    engines/twine/extra.h
    engines/twine/resources.h


diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 7e4b0d01d0..bf8c1b6013 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -355,19 +355,19 @@ void Extra::addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int3
 	switch (_engine->_gameState->magicLevelIdx) {
 	case 0:
 	case 1:
-		ballSprite = 1;
+		ballSprite = SPRITEHQR_MAGICBALL_YELLOW;
 		ballStrength = 4;
 		break;
 	case 2:
-		ballSprite = 42;
+		ballSprite = SPRITEHQR_MAGICBALL_GREEN;
 		ballStrength = 6;
 		break;
 	case 3:
-		ballSprite = 43;
+		ballSprite = SPRITEHQR_MAGICBALL_RED;
 		ballStrength = 8;
 		break;
 	case 4:
-		ballSprite = 13;
+		ballSprite = SPRITEHQR_MAGICBALL_FIRE;
 		ballStrength = 10;
 		break;
 	}
diff --git a/engines/twine/extra.h b/engines/twine/extra.h
index 5194246e07..af5dd90e32 100644
--- a/engines/twine/extra.h
+++ b/engines/twine/extra.h
@@ -76,10 +76,12 @@ public:
 
 	int32 addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 info0, int32 targetActor, int32 maxSpeed, int32 strengthOfHit);
 
-	/** Add extra explosion
-	@param x Explostion X coordinate
-	@param y Explostion Y coordinate
-	@param z Explostion Z coordinate */
+	/**
+	 * Add extra explosion
+	 * @param x Explostion X coordinate
+	 * @param y Explostion Y coordinate
+	 * @param z Explostion Z coordinate
+	 */
 	int32 addExtraExplode(int32 x, int32 y, int32 z);
 
 	/** Reset all used extras */
diff --git a/engines/twine/resources.h b/engines/twine/resources.h
index 3c205709d7..9f77ee637a 100644
--- a/engines/twine/resources.h
+++ b/engines/twine/resources.h
@@ -86,6 +86,8 @@ namespace TwinE {
 #define SPRITEHQR_CLOVERLEAF 7
 #define SPRITEHQR_CLOVERLEAFBOX 41
 
+#define SPRITEHQR_MAGICBALL_YELLOW 1
+#define SPRITEHQR_MAGICBALL_FIRE 13
 #define SPRITEHQR_MAGICBALL_GREEN 42
 #define SPRITEHQR_MAGICBALL_RED 43
 #define SPRITEHQR_MAGICBALL_YELLOW_TRANS 44


Commit: db9ab1d63e1e74a5ec8db1569f14b7ae79711b4f
    https://github.com/scummvm/scummvm/commit/db9ab1d63e1e74a5ec8db1569f14b7ae79711b4f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:43:35+01:00

Commit Message:
TWINE: fixed endian issues while parsing sprite bounding box for collisions

Changed paths:
    engines/twine/collision.cpp


diff --git a/engines/twine/collision.cpp b/engines/twine/collision.cpp
index 42d2100df3..b2fca42dac 100644
--- a/engines/twine/collision.cpp
+++ b/engines/twine/collision.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "common/memstream.h"
 #include "twine/actor.h"
 #include "twine/animations.h"
 #include "twine/collision.h"
@@ -471,14 +472,16 @@ void Collision::stopFalling() { // ReceptionObj()
 }
 
 int32 Collision::checkExtraCollisionWithActors(ExtraListStruct *extra, int32 actorIdx) {
-	const int16 *spriteBounding = (const int16 *)(_engine->_resources->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
+	Common::MemoryReadStream stream(_engine->_resources->spriteBoundingBoxPtr, _engine->_resources->spriteBoundingBoxSize);
+	stream.seek(extra->info0 * 16);
+	stream.skip(4);
 
-	const int32 xLeft = *(spriteBounding++) + extra->x;
-	const int32 xRight = *(spriteBounding++) + extra->x;
-	const int32 yLeft = *(spriteBounding++) + extra->y;
-	const int32 yRight = *(spriteBounding++) + extra->y;
-	const int32 zLeft = *(spriteBounding++) + extra->z;
-	const int32 zRight = *(spriteBounding++) + extra->z;
+	const int32 xLeft = stream.readSint16LE() + extra->x;
+	const int32 xRight = stream.readSint16LE() + extra->x;
+	const int32 yLeft = stream.readSint16LE() + extra->y;
+	const int32 yRight = stream.readSint16LE() + extra->y;
+	const int32 zLeft = stream.readSint16LE() + extra->z;
+	const int32 zRight = stream.readSint16LE() + extra->z;
 
 	for (int32 a = 0; a < _engine->_scene->sceneNumActors; a++) {
 		const ActorStruct *actorTest = _engine->_scene->getActor(a);
@@ -529,27 +532,28 @@ int32 Collision::checkExtraCollisionWithBricks(int32 X, int32 Y, int32 Z, int32
 }
 
 int32 Collision::checkExtraCollisionWithExtra(ExtraListStruct *extra, int32 extraIdx) {
-	const int16 *spriteBounding = (const int16 *)(_engine->_resources->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
+	Common::MemoryReadStream stream(_engine->_resources->spriteBoundingBoxPtr, _engine->_resources->spriteBoundingBoxSize);
+	stream.seek(extra->info0 * 16);
+	stream.skip(4);
 
-	const int32 xLeft = *(spriteBounding++) + extra->x;
-	const int32 xRight = *(spriteBounding++) + extra->x;
-	const int32 yLeft = *(spriteBounding++) + extra->y;
-	const int32 yRight = *(spriteBounding++) + extra->y;
-	const int32 zLeft = *(spriteBounding++) + extra->z;
-	const int32 zRight = *(spriteBounding++) + extra->z;
+	const int32 xLeft = stream.readSint16LE() + extra->x;
+	const int32 xRight = stream.readSint16LE() + extra->x;
+	const int32 yLeft = stream.readSint16LE() + extra->y;
+	const int32 yRight = stream.readSint16LE() + extra->y;
+	const int32 zLeft = stream.readSint16LE() + extra->z;
+	const int32 zRight = stream.readSint16LE() + extra->z;
 
 	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		const ExtraListStruct *extraTest = &_engine->_extra->extraList[i];
 		if (i != extraIdx && extraTest->info0 != -1) {
-			//          const int16 * spriteBoundingTest;
-			//	        spriteBoundingTest = (const int16*)(_engine->_resources->spriteBoundingBoxPtr + extraTest->info0 * 16 + 4);
-
-			const int32 xLeftTest = *(spriteBounding++) + extraTest->x;
-			const int32 xRightTest = *(spriteBounding++) + extraTest->x;
-			const int32 yLeftTest = *(spriteBounding++) + extraTest->y;
-			const int32 yRightTest = *(spriteBounding++) + extraTest->y;
-			const int32 zLeftTest = *(spriteBounding++) + extraTest->z;
-			const int32 zRightTest = *(spriteBounding++) + extraTest->z;
+			// const int16 * spriteBoundingTest;
+			// spriteBoundingTest = (const int16*)(_engine->_resources->spriteBoundingBoxPtr + extraTest->info0 * 16 + 4);
+			const int32 xLeftTest = stream.readSint16LE() + extraTest->x;
+			const int32 xRightTest = stream.readSint16LE() + extraTest->x;
+			const int32 yLeftTest = stream.readSint16LE() + extraTest->y;
+			const int32 yRightTest = stream.readSint16LE() + extraTest->y;
+			const int32 zLeftTest = stream.readSint16LE() + extraTest->z;
+			const int32 zRightTest = stream.readSint16LE() + extraTest->z;
 
 			if (xLeft < xLeftTest) {
 				if (xLeft < xRightTest && xRight > xLeftTest && yLeft < yRightTest && yRight > yLeftTest && zLeft < zRightTest && zRight > zLeftTest) {


Commit: 4783046f866e9d7340368fa9c11affa72399da16
    https://github.com/scummvm/scummvm/commit/4783046f866e9d7340368fa9c11affa72399da16
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:45:44+01:00

Commit Message:
TWINE: fixed compiler warning about alignment issues

Changed paths:
    engines/twine/grid.cpp


diff --git a/engines/twine/grid.cpp b/engines/twine/grid.cpp
index 789fd425f5..6d121385b0 100644
--- a/engines/twine/grid.cpp
+++ b/engines/twine/grid.cpp
@@ -183,7 +183,7 @@ void Grid::drawOverSpriteActor(int32 x, int32 y, int32 z) {
 }
 
 int Grid::processGridMask(const uint8 *buffer, uint8 *ptr) {
-	const uint32 *ptrSave = (const uint32 *)ptr;
+	const uint8 *ptrSave = ptr;
 	int32 ebx = READ_UINT32(buffer); // brick flag
 	buffer += 4;
 	WRITE_LE_UINT32(ptr, (uint32)ebx);
@@ -243,7 +243,7 @@ int Grid::processGridMask(const uint8 *buffer, uint8 *ptr) {
 		*ptr2 = numOfBlock;
 	} while (--bh > 0);
 
-	return ((int)((const uint8 *)edi - (const uint8 *)ptrSave));
+	return (int)(edi - ptrSave);
 }
 
 void Grid::createGridMask() {


Commit: f969365688fe80b5ea71e7c79ee9215f23532db7
    https://github.com/scummvm/scummvm/commit/f969365688fe80b5ea71e7c79ee9215f23532db7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T20:49:18+01:00

Commit Message:
TWINE: fixed endian issue in getText

Changed paths:
    engines/twine/text.cpp


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 4aae06589f..7a042a1aff 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "twine/text.h"
+#include "common/endian.h"
 #include "common/memstream.h"
 #include "common/scummsys.h"
 #include "common/str.h"
@@ -702,8 +703,8 @@ bool Text::getText(int32 index) {
 		return false;
 	}
 
-	int32 ptrCurrentEntry = localTextBuf[currIdx];
-	int32 ptrNextEntry = localTextBuf[currIdx + 1];
+	int32 ptrCurrentEntry = READ_LE_INT16(&localTextBuf[currIdx]);
+	int32 ptrNextEntry = READ_LE_INT16(&localTextBuf[currIdx + 1]);
 
 	currDialTextPtr = (dialTextPtr + ptrCurrentEntry);
 	currDialTextSize = ptrNextEntry - ptrCurrentEntry;




More information about the Scummvm-git-logs mailing list