[Scummvm-git-logs] scummvm master -> 95516fd446aadb608b856d9c3412627a4440aff2

mgerhardy martin.gerhardy at gmail.com
Sun Oct 25 16:00:15 UTC 2020


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

Summary:
d13e4b4088 TWINE: reduced scopes, const + data hiding
153bfa03aa TWINE: removed own midi code - use MidiParser_XMIDI
55e82d6c0f TWINE: prepare for lba2
95516fd446 TWINE: renamed sub-engine from twine to lba to also support lba2


Commit: d13e4b4088a54f1df98e6b71d1f4e30e7c4d049e
    https://github.com/scummvm/scummvm/commit/d13e4b4088a54f1df98e6b71d1f4e30e7c4d049e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-25T16:57:26+01:00

Commit Message:
TWINE: reduced scopes, const + data hiding

Changed paths:
    engines/twine/actor.cpp
    engines/twine/animations.cpp
    engines/twine/collision.cpp
    engines/twine/collision.h
    engines/twine/extra.cpp
    engines/twine/extra.h
    engines/twine/movements.cpp
    engines/twine/redraw.cpp
    engines/twine/scene.cpp
    engines/twine/scene.h
    engines/twine/script_life.cpp
    engines/twine/script_move.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 6b9e2e47b7..1424519583 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -137,7 +137,7 @@ void Actor::setBehaviour(int32 behaviour) {
 }
 
 void Actor::initSpriteActor(int32 actorIdx) {
-	ActorStruct *localActor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *localActor = _engine->_scene->getActor(actorIdx);
 
 	if (localActor->staticFlags.bIsSpriteActor && localActor->sprite != -1 && localActor->entity != localActor->sprite) {
 		const int16 *ptr = (const int16 *)(_engine->_scene->spriteBoundingBoxPtr + localActor->sprite * 16 + 4);
@@ -153,7 +153,7 @@ void Actor::initSpriteActor(int32 actorIdx) {
 }
 
 int32 Actor::initBody(int32 bodyIdx, int32 actorIdx) {
-	ActorStruct *localActor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *localActor = _engine->_scene->getActor(actorIdx);
 	uint8 *bodyPtr = localActor->entityDataPtr;
 
 	do {
@@ -230,7 +230,7 @@ int32 Actor::initBody(int32 bodyIdx, int32 actorIdx) {
 }
 
 void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
-	ActorStruct *localActor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *localActor = _engine->_scene->getActor(actorIdx);
 	if (localActor->staticFlags.bIsSpriteActor) {
 		return;
 	}
@@ -320,7 +320,7 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 }
 
 void Actor::initActor(int16 actorIdx) {
-	ActorStruct *actor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
 	if (actor->staticFlags.bIsSpriteActor) { // if sprite actor
 		if (actor->strengthOfHit != 0) {
@@ -359,7 +359,7 @@ void Actor::initActor(int16 actorIdx) {
 }
 
 void Actor::resetActor(int16 actorIdx) {
-	ActorStruct *actor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
 	actor->body = 0;
 	actor->anim = kStanding;
@@ -410,8 +410,7 @@ void Actor::resetActor(int16 actorIdx) {
 }
 
 void Actor::hitActor(int32 actorIdx, int32 actorIdxAttacked, int32 strengthOfHit, int32 angle) {
-	ActorStruct *actor = &_engine->_scene->sceneActors[actorIdxAttacked];
-
+	ActorStruct *actor = _engine->_scene->getActor(actorIdxAttacked);
 	if (actor->life <= 0) {
 		return;
 	}
@@ -455,7 +454,7 @@ void Actor::hitActor(int32 actorIdx, int32 actorIdxAttacked, int32 strengthOfHit
 }
 
 void Actor::processActorCarrier(int32 actorIdx) { // CheckCarrier
-	ActorStruct *actor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	if (!actor->staticFlags.bIsCarrierActor) {
 		return;
 	}
@@ -467,7 +466,7 @@ void Actor::processActorCarrier(int32 actorIdx) { // CheckCarrier
 }
 
 void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
-	ActorStruct *actor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
 	int32 numBonus = 0;
 
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 8fbc5d20fa..7d68bf570d 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -360,7 +360,7 @@ int32 Animations::getBodyAnimIndex(int32 animIdx, int32 actorIdx) {
 	uint8 *costumePtr = NULL;
 	ActorStruct *actor;
 
-	actor = &_engine->_scene->sceneActors[actorIdx];
+	actor = _engine->_scene->getActor(actorIdx);
 	bodyPtr = actor->entityDataPtr;
 
 	do {
@@ -529,7 +529,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 	ActorStruct *actor;
 	DataReader *data;
 
-	actor = &_engine->_scene->sceneActors[actorIdx];
+	actor = _engine->_scene->getActor(actorIdx);
 	if (!actor->animExtraPtr) {
 		return; // avoid null pointers
 	}
@@ -774,27 +774,28 @@ void Animations::processAnimActions(int32 actorIdx) {
 }
 
 int32 Animations::initAnim(AnimationTypes newAnim, int16 animType, uint8 animExtra, int32 actorIdx) {
-	ActorStruct *actor;
-	int32 animIndex;
-
-	actor = &_engine->_scene->sceneActors[actorIdx];
-
-	if (actor->entity == -1)
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
+	if (actor->entity == -1) {
 		return 0;
+	}
 
-	if (actor->staticFlags.bIsSpriteActor)
+	if (actor->staticFlags.bIsSpriteActor) {
 		return 0;
+	}
 
-	if (newAnim == actor->anim && actor->previousAnimIdx != -1)
+	if (newAnim == actor->anim && actor->previousAnimIdx != -1) {
 		return 1;
+	}
 
-	if (animExtra == 255 && actor->animType != 2)
+	if (animExtra == 255 && actor->animType != 2) {
 		animExtra = (uint8)actor->anim;
+	}
 
-	animIndex = getBodyAnimIndex(newAnim, actorIdx);
+	int32 animIndex = getBodyAnimIndex(newAnim, actorIdx);
 
-	if (animIndex == -1)
+	if (animIndex == -1) {
 		animIndex = getBodyAnimIndex(0, actorIdx);
+	}
 
 	if (animType != 4 && actor->animType == 2) {
 		actor->animExtra = newAnim;
@@ -811,15 +812,17 @@ int32 Animations::initAnim(AnimationTypes newAnim, int16 animType, uint8 animExt
 		}
 	}
 
-	if (animType == 4)
+	if (animType == 4) {
 		animType = 2;
+	}
 
 	if (actor->previousAnimIdx == -1) { // if no previous animation
 		setAnimAtKeyframe(0, animTable[animIndex], _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
 	} else { // interpolation between animations
 		animBuffer2 += stockAnimation(animBuffer2, _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
-		if (animBuffer1 + 4488 < animBuffer2)
+		if (animBuffer1 + 4488 < animBuffer2) {
 			animBuffer2 = animBuffer1;
+		}
 	}
 
 	actor->previousAnimIdx = animIndex;
@@ -845,17 +848,14 @@ int32 Animations::initAnim(AnimationTypes newAnim, int16 animType, uint8 animExt
 }
 
 void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
-	int16 numKeyframe;
-	uint8 *animPtr;
-	ActorStruct *actor;
-
-	actor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
 	currentlyProcessedActorIdx = actorIdx;
 	_engine->_movements->processActorPtr = actor;
 
-	if (actor->entity == -1)
+	if (actor->entity == -1) {
 		return;
+	}
 
 	_engine->_movements->previousActorX = actor->collisionX;
 	_engine->_movements->previousActorY = actor->collisionY;
@@ -959,7 +959,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 	} else { // 3D actor
 		if (actor->previousAnimIdx != -1) {
 			int32 keyFramePassed;
-			animPtr = animTable[actor->previousAnimIdx];
+			uint8 *animPtr = animTable[actor->previousAnimIdx];
 
 			keyFramePassed = verifyAnimAtKeyframe(actor->animPosition, animPtr, _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
 
@@ -996,7 +996,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 					processAnimActions(actorIdx);
 				}
 
-				numKeyframe = actor->animPosition;
+				int16 numKeyframe = actor->animPosition;
 				if (numKeyframe == getNumKeyframes(animPtr)) {
 					actor->dynamicFlags.bIsHitting = 0;
 
@@ -1036,13 +1036,13 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 
 	// actor standing on another actor
 	if (actor->standOn != -1) {
-		_engine->_movements->processActorX -= _engine->_scene->sceneActors[actor->standOn].collisionX;
-		_engine->_movements->processActorY -= _engine->_scene->sceneActors[actor->standOn].collisionY;
-		_engine->_movements->processActorZ -= _engine->_scene->sceneActors[actor->standOn].collisionZ;
+		_engine->_movements->processActorX -= _engine->_scene->getActor(actor->standOn)->collisionX;
+		_engine->_movements->processActorY -= _engine->_scene->getActor(actor->standOn)->collisionY;
+		_engine->_movements->processActorZ -= _engine->_scene->getActor(actor->standOn)->collisionZ;
 
-		_engine->_movements->processActorX += _engine->_scene->sceneActors[actor->standOn].x;
-		_engine->_movements->processActorY += _engine->_scene->sceneActors[actor->standOn].y;
-		_engine->_movements->processActorZ += _engine->_scene->sceneActors[actor->standOn].z;
+		_engine->_movements->processActorX += _engine->_scene->getActor(actor->standOn)->x;
+		_engine->_movements->processActorY += _engine->_scene->getActor(actor->standOn)->y;
+		_engine->_movements->processActorZ += _engine->_scene->getActor(actor->standOn)->z;
 
 		if (!_engine->_collision->standingOnActor(actorIdx, actor->standOn)) {
 			actor->standOn = -1; // no longer standing on other actor
diff --git a/engines/twine/collision.cpp b/engines/twine/collision.cpp
index 9d4782541a..a363ac529c 100644
--- a/engines/twine/collision.cpp
+++ b/engines/twine/collision.cpp
@@ -37,57 +37,59 @@ namespace TwinE {
 Collision::Collision(TwinEEngine *engine) : _engine(engine) {
 }
 
-int32 Collision::standingOnActor(int32 actorIdx1, int32 actorIdx2) { // CheckZvOnZv
-	int32 x1Left, y1Left, z1Left, x1Right, y1Right, z1Right;
-	int32 x2Left, y2Left, z2Left, x2Right, y2Right, z2Right;
-	ActorStruct *actor1;
-	ActorStruct *actor2;
-
-	actor1 = &_engine->_scene->sceneActors[actorIdx1];
-	actor2 = &_engine->_scene->sceneActors[actorIdx2];
+bool Collision::standingOnActor(int32 actorIdx1, int32 actorIdx2) {
+	const ActorStruct *actor1 = _engine->_scene->getActor(actorIdx1);
+	const ActorStruct *actor2 = _engine->_scene->getActor(actorIdx2);
 
 	// Current actor (actor 1)
-	x1Left = _engine->_movements->processActorX + actor1->boudingBox.x.bottomLeft;
-	x1Right = _engine->_movements->processActorX + actor1->boudingBox.x.topRight;
+	const int32 x1Left = _engine->_movements->processActorX + actor1->boudingBox.x.bottomLeft;
+	const int32 x1Right = _engine->_movements->processActorX + actor1->boudingBox.x.topRight;
 
-	y1Left = _engine->_movements->processActorY + actor1->boudingBox.y.bottomLeft;
-	y1Right = _engine->_movements->processActorY + actor1->boudingBox.y.topRight;
+	const int32 y1Left = _engine->_movements->processActorY + actor1->boudingBox.y.bottomLeft;
+	const int32 y1Right = _engine->_movements->processActorY + actor1->boudingBox.y.topRight;
 
-	z1Left = _engine->_movements->processActorZ + actor1->boudingBox.z.bottomLeft;
-	z1Right = _engine->_movements->processActorZ + actor1->boudingBox.z.topRight;
+	const int32 z1Left = _engine->_movements->processActorZ + actor1->boudingBox.z.bottomLeft;
+	const int32 z1Right = _engine->_movements->processActorZ + actor1->boudingBox.z.topRight;
 
 	// Actor 2
-	x2Left = actor2->x + actor2->boudingBox.x.bottomLeft;
-	x2Right = actor2->x + actor2->boudingBox.x.topRight;
+	const int32 x2Left = actor2->x + actor2->boudingBox.x.bottomLeft;
+	const int32 x2Right = actor2->x + actor2->boudingBox.x.topRight;
 
-	y2Left = actor2->y + actor2->boudingBox.y.bottomLeft;
-	y2Right = actor2->y + actor2->boudingBox.y.topRight;
+	const int32 y2Left = actor2->y + actor2->boudingBox.y.bottomLeft;
+	const int32 y2Right = actor2->y + actor2->boudingBox.y.topRight;
 
-	z2Left = actor2->z + actor2->boudingBox.z.bottomLeft;
-	z2Right = actor2->z + actor2->boudingBox.z.topRight;
+	const int32 z2Left = actor2->z + actor2->boudingBox.z.bottomLeft;
+	const int32 z2Right = actor2->z + actor2->boudingBox.z.topRight;
 
-	if (x1Left >= x2Right)
-		return 0; // not standing
+	if (x1Left >= x2Right) {
+		return false; // not standing
+	}
 
-	if (x1Right <= x2Left)
-		return 0;
+	if (x1Right <= x2Left) {
+		return false;
+	}
 
-	if (y1Left > (y2Right + 1))
-		return 0;
+	if (y1Left > (y2Right + 1)) {
+		return false;
+	}
 
-	if (y1Left <= (y2Right - 0x100))
-		return 0;
+	if (y1Left <= (y2Right - 0x100)) {
+		return false;
+	}
 
-	if (y1Right <= y2Left)
-		return 0;
+	if (y1Right <= y2Left) {
+		return false;
+	}
 
-	if (z1Left >= z2Right)
-		return 0;
+	if (z1Left >= z2Right) {
+		return false;
+	}
 
-	if (z1Right <= z2Left)
-		return 0;
+	if (z1Right <= z2Left) {
+		return false;
+	}
 
-	return 1; // standing
+	return true; // standing
 }
 
 int32 Collision::getAverageValue(int32 var0, int32 var1, int32 var2, int32 var3) {
@@ -103,15 +105,13 @@ int32 Collision::getAverageValue(int32 var0, int32 var1, int32 var2, int32 var3)
 }
 
 void Collision::reajustActorPosition(int32 brickShape) {
-	int32 brkX, brkY, brkZ;
-
 	if (!brickShape) {
 		return;
 	}
 
-	brkX = (collisionX << 9) - 0x100;
-	brkY = collisionY << 8;
-	brkZ = (collisionZ << 9) - 0x100;
+	int32 brkX = (collisionX << 9) - 0x100;
+	int32 brkY = collisionY << 8;
+	int32 brkZ = (collisionZ << 9) - 0x100;
 
 	// double-side stairs
 	if (brickShape >= kDoubleSideStairsTop1 && brickShape <= kDoubleSideStairsRight2) {
@@ -201,37 +201,32 @@ void Collision::reajustActorPosition(int32 brickShape) {
 }
 
 int32 Collision::checkCollisionWithActors(int32 actorIdx) {
-	int32 a, xLeft, xRight, yLeft, yRight, zLeft, zRight;
-	ActorStruct *actor, *actorTest;
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
-	actor = &_engine->_scene->sceneActors[actorIdx];
+	int32 xLeft = _engine->_movements->processActorX + actor->boudingBox.x.bottomLeft;
+	int32 xRight = _engine->_movements->processActorX + actor->boudingBox.x.topRight;
 
-	xLeft = _engine->_movements->processActorX + actor->boudingBox.x.bottomLeft;
-	xRight = _engine->_movements->processActorX + actor->boudingBox.x.topRight;
+	int32 yLeft = _engine->_movements->processActorY + actor->boudingBox.y.bottomLeft;
+	int32 yRight = _engine->_movements->processActorY + actor->boudingBox.y.topRight;
 
-	yLeft = _engine->_movements->processActorY + actor->boudingBox.y.bottomLeft;
-	yRight = _engine->_movements->processActorY + actor->boudingBox.y.topRight;
-
-	zLeft = _engine->_movements->processActorZ + actor->boudingBox.z.bottomLeft;
-	zRight = _engine->_movements->processActorZ + actor->boudingBox.z.topRight;
+	int32 zLeft = _engine->_movements->processActorZ + actor->boudingBox.z.bottomLeft;
+	int32 zRight = _engine->_movements->processActorZ + actor->boudingBox.z.topRight;
 
 	actor->collision = -1;
 
-	for (a = 0; a < _engine->_scene->sceneNumActors; a++) {
-		actorTest = &_engine->_scene->sceneActors[a];
+	for (int32 a = 0; a < _engine->_scene->sceneNumActors; a++) {
+		ActorStruct *actorTest = _engine->_scene->getActor(a);
 
 		// aviod current processed actor
 		if (a != actorIdx && actorTest->entity != -1 && !actor->staticFlags.bComputeLowCollision && actorTest->standOn != actorIdx) {
-			int32 xLeftTest, xRightTest, yLeftTest, yRightTest, zLeftTest, zRightTest;
-
-			xLeftTest = actorTest->x + actorTest->boudingBox.x.bottomLeft;
-			xRightTest = actorTest->x + actorTest->boudingBox.x.topRight;
+			const int32 xLeftTest = actorTest->x + actorTest->boudingBox.x.bottomLeft;
+			const int32 xRightTest = actorTest->x + actorTest->boudingBox.x.topRight;
 
-			yLeftTest = actorTest->y + actorTest->boudingBox.y.bottomLeft;
-			yRightTest = actorTest->y + actorTest->boudingBox.y.topRight;
+			const int32 yLeftTest = actorTest->y + actorTest->boudingBox.y.bottomLeft;
+			const int32 yRightTest = actorTest->y + actorTest->boudingBox.y.topRight;
 
-			zLeftTest = actorTest->z + actorTest->boudingBox.z.bottomLeft;
-			zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
+			const int32 zLeftTest = actorTest->z + actorTest->boudingBox.z.bottomLeft;
+			const int32 zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
 
 			if (xLeft < xRightTest && xRight > xLeftTest && yLeft < yRightTest && yRight > yLeftTest && zLeft < zRightTest && zRight > zLeftTest) {
 				actor->collision = a; // mark as collision with actor a
@@ -245,9 +240,7 @@ int32 Collision::checkCollisionWithActors(int32 actorIdx) {
 							_engine->_movements->processActorY = yRightTest - actor->boudingBox.y.bottomLeft + 1;
 							actor->standOn = a;
 						} else {
-							int32 newAngle;
-
-							newAngle = _engine->_movements->getAngleAndSetTargetActorDistance(_engine->_movements->processActorX, _engine->_movements->processActorZ, actorTest->x, actorTest->z);
+							int32 newAngle = _engine->_movements->getAngleAndSetTargetActorDistance(_engine->_movements->processActorX, _engine->_movements->processActorZ, actorTest->x, actorTest->z);
 
 							if (actorTest->staticFlags.bCanBePushed && !actor->staticFlags.bCanBePushed) {
 								actorTest->lastY = 0;
@@ -295,13 +288,11 @@ int32 Collision::checkCollisionWithActors(int32 actorIdx) {
 						}
 					}
 				} else {
-					int32 newAngle;
-
 					if (standingOnActor(actorIdx, a)) {
 						_engine->_actor->hitActor(actorIdx, a, 1, -1);
 					}
 
-					newAngle = _engine->_movements->getAngleAndSetTargetActorDistance(_engine->_movements->processActorX, _engine->_movements->processActorZ, actorTest->x, actorTest->z);
+					int32 newAngle = _engine->_movements->getAngleAndSetTargetActorDistance(_engine->_movements->processActorX, _engine->_movements->processActorZ, actorTest->x, actorTest->z);
 
 					if (actorTest->staticFlags.bCanBePushed && !actor->staticFlags.bCanBePushed) {
 						actorTest->lastY = 0;
@@ -363,21 +354,19 @@ int32 Collision::checkCollisionWithActors(int32 actorIdx) {
 		zLeft = _engine->_renderer->destZ + _engine->_movements->processActorZ + actor->boudingBox.z.bottomLeft;
 		zRight = _engine->_renderer->destZ + _engine->_movements->processActorZ + actor->boudingBox.z.topRight;
 
-		for (a = 0; a < _engine->_scene->sceneNumActors; a++) {
-			actorTest = &_engine->_scene->sceneActors[a];
+		for (int32 a = 0; a < _engine->_scene->sceneNumActors; a++) {
+			const ActorStruct *actorTest = _engine->_scene->getActor(a);
 
 			// aviod current processed actor
 			if (a != actorIdx && actorTest->entity != -1 && !actorTest->staticFlags.bIsHidden && actorTest->standOn != actorIdx) {
-				int32 xLeftTest, xRightTest, yLeftTest, yRightTest, zLeftTest, zRightTest;
-
-				xLeftTest = actorTest->x + actorTest->boudingBox.x.bottomLeft;
-				xRightTest = actorTest->x + actorTest->boudingBox.x.topRight;
+				const int32 xLeftTest = actorTest->x + actorTest->boudingBox.x.bottomLeft;
+				const int32 xRightTest = actorTest->x + actorTest->boudingBox.x.topRight;
 
-				yLeftTest = actorTest->y + actorTest->boudingBox.y.bottomLeft;
-				yRightTest = actorTest->y + actorTest->boudingBox.y.topRight;
+				const int32 yLeftTest = actorTest->y + actorTest->boudingBox.y.bottomLeft;
+				const int32 yRightTest = actorTest->y + actorTest->boudingBox.y.topRight;
 
-				zLeftTest = actorTest->z + actorTest->boudingBox.z.bottomLeft;
-				zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
+				const int32 zLeftTest = actorTest->z + actorTest->boudingBox.z.bottomLeft;
+				const int32 zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
 
 				if (xLeft < xRightTest && xRight > xLeftTest && yLeft < yRightTest && yRight > yLeftTest && zLeft < zRightTest && zRight > zLeftTest) {
 					_engine->_actor->hitActor(actorIdx, a, actor->strengthOfHit, actor->angle + 0x200);
@@ -487,36 +476,29 @@ void Collision::stopFalling() { // ReceptionObj()
 }
 
 int32 Collision::checkExtraCollisionWithActors(ExtraListStruct *extra, int32 actorIdx) {
-	int32 a;
-	int32 xLeft, xRight, yLeft, yRight, zLeft, zRight;
-	int16 *spriteBounding;
-	ActorStruct *actorTest;
+	int16 *spriteBounding = (int16 *)(_engine->_scene->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
 
-	spriteBounding = (int16 *)(_engine->_scene->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
+	int32 xLeft = *(spriteBounding++) + extra->x;
+	int32 xRight = *(spriteBounding++) + extra->x;
 
-	xLeft = *(spriteBounding++) + extra->x;
-	xRight = *(spriteBounding++) + extra->x;
+	int32 yLeft = *(spriteBounding++) + extra->y;
+	int32 yRight = *(spriteBounding++) + extra->y;
 
-	yLeft = *(spriteBounding++) + extra->y;
-	yRight = *(spriteBounding++) + extra->y;
+	int32 zLeft = *(spriteBounding++) + extra->z;
+	int32 zRight = *(spriteBounding++) + extra->z;
 
-	zLeft = *(spriteBounding++) + extra->z;
-	zRight = *(spriteBounding++) + extra->z;
-
-	for (a = 0; a < _engine->_scene->sceneNumActors; a++) {
-		actorTest = &_engine->_scene->sceneActors[a];
+	for (int32 a = 0; a < _engine->_scene->sceneNumActors; a++) {
+		ActorStruct *actorTest = _engine->_scene->getActor(a);
 
 		if (a != actorIdx && actorTest->entity != -1) {
-			int32 xLeftTest, xRightTest, yLeftTest, yRightTest, zLeftTest, zRightTest;
-
-			xLeftTest = actorTest->x + actorTest->boudingBox.x.bottomLeft;
-			xRightTest = actorTest->x + actorTest->boudingBox.x.topRight;
+			int32 xLeftTest = actorTest->x + actorTest->boudingBox.x.bottomLeft;
+			int32 xRightTest = actorTest->x + actorTest->boudingBox.x.topRight;
 
-			yLeftTest = actorTest->y + actorTest->boudingBox.y.bottomLeft;
-			yRightTest = actorTest->y + actorTest->boudingBox.y.topRight;
+			int32 yLeftTest = actorTest->y + actorTest->boudingBox.y.bottomLeft;
+			int32 yRightTest = actorTest->y + actorTest->boudingBox.y.topRight;
 
-			zLeftTest = actorTest->z + actorTest->boudingBox.z.bottomLeft;
-			zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
+			int32 zLeftTest = actorTest->z + actorTest->boudingBox.z.bottomLeft;
+			int32 zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
 
 			if (xLeft < xRightTest && xRight > xLeftTest && yLeft < yRightTest && yRight > yLeftTest && zLeft < zRightTest && zRight > zLeftTest) {
 				if (extra->strengthOfHit != 0) {
@@ -532,15 +514,13 @@ int32 Collision::checkExtraCollisionWithActors(ExtraListStruct *extra, int32 act
 }
 
 int32 Collision::checkExtraCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 oldX, int32 oldY, int32 oldZ) {
-	int32 averageX, averageY, averageZ;
-
 	if (_engine->_grid->getBrickShape(oldX, oldY, oldZ)) {
 		return 1;
 	}
 
-	averageX = ABS(X + oldX) / 2;
-	averageY = ABS(Y + oldY) / 2;
-	averageZ = ABS(Z + oldZ) / 2;
+	int32 averageX = ABS(X + oldX) / 2;
+	int32 averageY = ABS(Y + oldY) / 2;
+	int32 averageZ = ABS(Z + oldZ) / 2;
 
 	if (_engine->_grid->getBrickShape(averageX, averageY, averageZ)) {
 		return 1;
@@ -558,36 +538,31 @@ int32 Collision::checkExtraCollisionWithBricks(int32 X, int32 Y, int32 Z, int32
 }
 
 int32 Collision::checkExtraCollisionWithExtra(ExtraListStruct *extra, int32 extraIdx) {
-	int32 i;
-	int32 xLeft, xRight, yLeft, yRight, zLeft, zRight;
-	int16 *spriteBounding;
-
-	spriteBounding = (int16 *)(_engine->_scene->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
+	int16 *spriteBounding = (int16 *)(_engine->_scene->spriteBoundingBoxPtr + extra->info0 * 16 + 4);
 
-	xLeft = *(spriteBounding++) + extra->x;
-	xRight = *(spriteBounding++) + extra->x;
+	int32 xLeft = *(spriteBounding++) + extra->x;
+	int32 xRight = *(spriteBounding++) + extra->x;
 
-	yLeft = *(spriteBounding++) + extra->y;
-	yRight = *(spriteBounding++) + extra->y;
+	int32 yLeft = *(spriteBounding++) + extra->y;
+	int32 yRight = *(spriteBounding++) + extra->y;
 
-	zLeft = *(spriteBounding++) + extra->z;
-	zRight = *(spriteBounding++) + extra->z;
+	int32 zLeft = *(spriteBounding++) + extra->z;
+	int32 zRight = *(spriteBounding++) + extra->z;
 
-	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extraTest = &_engine->_extra->extraList[i];
 		if (i != extraIdx && extraTest->info0 != -1) {
-			int32 xLeftTest, xRightTest, yLeftTest, yRightTest, zLeftTest, zRightTest;
 			//            int16 * spriteBoundingTest;
 			//	        spriteBoundingTest = (int16*)(_engine->_scene->spriteBoundingBoxPtr + extraTest->info0 * 16 + 4);
 
-			xLeftTest = *(spriteBounding++) + extraTest->x;
-			xRightTest = *(spriteBounding++) + extraTest->x;
+			int32 xLeftTest = *(spriteBounding++) + extraTest->x;
+			int32 xRightTest = *(spriteBounding++) + extraTest->x;
 
-			yLeftTest = *(spriteBounding++) + extraTest->y;
-			yRightTest = *(spriteBounding++) + extraTest->y;
+			int32 yLeftTest = *(spriteBounding++) + extraTest->y;
+			int32 yRightTest = *(spriteBounding++) + extraTest->y;
 
-			zLeftTest = *(spriteBounding++) + extraTest->z;
-			zRightTest = *(spriteBounding++) + extraTest->z;
+			int32 zLeftTest = *(spriteBounding++) + extraTest->z;
+			int32 zRightTest = *(spriteBounding++) + extraTest->z;
 
 			if (xLeft < xLeftTest) {
 				if (xLeft < xRightTest && xRight > xLeftTest && yLeft < yRightTest && yRight > yLeftTest && zLeft < zRightTest && zRight > zLeftTest) {
diff --git a/engines/twine/collision.h b/engines/twine/collision.h
index d0c006fbdd..71ddd5e752 100644
--- a/engines/twine/collision.h
+++ b/engines/twine/collision.h
@@ -53,11 +53,11 @@ public:
 	int32 causeActorDamage = 0; //fieldCauseDamage
 
 	/**
-	 * Check if actor 1 is standing in actor2
+	 * Check if actor 1 is standing in actor 2
 	 * @param actorIdx1 Actor 1 index
 	 * @param actorIdx2 Actor 2 index
 	 */
-	int32 standingOnActor(int32 actorIdx1, int32 actorIdx2);
+	bool standingOnActor(int32 actorIdx1, int32 actorIdx2);
 
 	int32 getAverageValue(int32 var0, int32 var1, int32 var2, int32 var3);
 
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 09bef1b3d1..f1320936ab 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -22,6 +22,7 @@
 
 #include "twine/extra.h"
 #include "common/util.h"
+#include "twine/actor.h"
 #include "twine/collision.h"
 #include "twine/gamestate.h"
 #include "twine/grid.h"
@@ -103,56 +104,53 @@ static const int16 explodeCloudShapeTable[] = {
 
 Extra::Extra(TwinEEngine *engine) : _engine(engine) {}
 
-int32 Extra::addExtra(int32 actorIdx, int32 X, int32 Y, int32 Z, int32 info0, int32 targetActor, int32 maxSpeed, int32 strengthOfHit) {
-	int32 i;
-
-	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+int32 Extra::addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 info0, int32 targetActor, int32 maxSpeed, int32 strengthOfHit) {
+	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
-		if (extra->info0 == -1) {
-			extra->info0 = info0;
-			extra->type = 0x80;
-			extra->info1 = 0;
-			extra->x = X;
-			extra->y = Y;
-			extra->z = Z;
-			extra->actorIdx = actorIdx;
-			extra->lifeTime = targetActor;
-			extra->destZ = maxSpeed;
-			extra->strengthOfHit = strengthOfHit;
-
-			_engine->_movements->setActorAngle(0, maxSpeed, 50, &extra->trackActorMove);
-			extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(X, Z, _engine->_scene->sceneActors[targetActor].x, _engine->_scene->sceneActors[targetActor].z);
-			return i;
+		if (extra->info0 != -1) {
+			continue;
 		}
+		extra->info0 = info0;
+		extra->type = 0x80;
+		extra->info1 = 0;
+		extra->x = x;
+		extra->y = y;
+		extra->z = z;
+		extra->actorIdx = actorIdx;
+		extra->lifeTime = targetActor;
+		extra->destZ = maxSpeed;
+		extra->strengthOfHit = strengthOfHit;
+
+		_engine->_movements->setActorAngle(0, maxSpeed, 50, &extra->trackActorMove);
+		const ActorStruct *actor = _engine->_scene->getActor(targetActor);
+		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, actor->x, actor->z);
+		return i;
 	}
 	return -1;
 }
 
-int32 Extra::addExtraExplode(int32 X, int32 Y, int32 Z) {
-	int32 i;
-
-	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+int32 Extra::addExtraExplode(int32 x, int32 y, int32 z) {
+	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
-		if (extra->info0 == -1) {
-			extra->info0 = 0x61;
-			extra->type = 0x1001;
-			extra->info1 = 0;
-			extra->x = X;
-			extra->y = Y;
-			extra->z = Z;
-			extra->actorIdx = 0x28;
-			extra->lifeTime = _engine->lbaTime;
-			extra->strengthOfHit = 0;
-			return i;
+		if (extra->info0 != -1) {
+			continue;
 		}
+		extra->info0 = 0x61;
+		extra->type = 0x1001;
+		extra->info1 = 0;
+		extra->x = x;
+		extra->y = y;
+		extra->z = z;
+		extra->actorIdx = 0x28;
+		extra->lifeTime = _engine->lbaTime;
+		extra->strengthOfHit = 0;
+		return i;
 	}
 	return -1;
 }
 
 void Extra::resetExtras() {
-	int32 i;
-
-	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
 		extra->info0 = -1;
 		extra->info1 = 1;
@@ -179,129 +177,129 @@ void Extra::throwExtra(ExtraListStruct *extra, int32 var1, int32 var2, int32 var
 	extra->lifeTime = _engine->lbaTime;
 }
 
-void Extra::addExtraSpecial(int32 X, int32 Y, int32 Z, int32 type) { // InitSpecial
-	int32 i;
-	int16 flag = 0x8000 + type;
+void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) { // InitSpecial
+	const int16 flag = 0x8000 + type;
 
-	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
-		if (extra->info0 == -1) {
-			extra->info0 = flag;
-			extra->info1 = 0;
-
-			if (type == kHitStars) {
-				extra->type = 9;
-
-				extra->x = X;
-				extra->y = Y;
-				extra->z = Z;
+		if (extra->info0 != -1) {
+			continue;
+		}
+		extra->info0 = flag;
+		extra->info1 = 0;
 
-				// same as InitFly
-				throwExtra(extra, _engine->getRandomNumber(0x100) + 0x80, _engine->getRandomNumber(0x400), 50, 20);
+		if (type == kHitStars) {
+			extra->type = 9;
 
-				extra->strengthOfHit = 0;
-				extra->lifeTime = _engine->lbaTime;
-				extra->actorIdx = 100;
+			extra->x = x;
+			extra->y = y;
+			extra->z = z;
 
-				return;
-			}
-			if (type == kExplodeCloud) {
-				extra->type = 1;
+			// same as InitFly
+			throwExtra(extra, _engine->getRandomNumber(0x100) + 0x80, _engine->getRandomNumber(0x400), 50, 20);
 
-				extra->x = X;
-				extra->y = Y;
-				extra->z = Z;
+			extra->strengthOfHit = 0;
+			extra->lifeTime = _engine->lbaTime;
+			extra->actorIdx = 100;
+		}
+		if (type == kExplodeCloud) {
+			extra->type = 1;
 
-				extra->strengthOfHit = 0;
-				extra->lifeTime = _engine->lbaTime;
-				extra->actorIdx = 5;
+			extra->x = x;
+			extra->y = y;
+			extra->z = z;
 
-				return;
-			}
+			extra->strengthOfHit = 0;
+			extra->lifeTime = _engine->lbaTime;
+			extra->actorIdx = 5;
 		}
+		break;
 	}
 }
 
-int32 Extra::addExtraBonus(int32 X, int32 Y, int32 Z, int32 param, int32 angle, int32 type, int32 bonusAmount) { // ExtraBonus
+int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle, int32 type, int32 bonusAmount) { // ExtraBonus
 	int32 i;
 
 	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
-		if (extra->info0 == -1) {
-			extra->info0 = type;
-			extra->type = 0x4071;
-
-			/*if(type == SPRITEHQR_KEY) {
-				extra->type = 0x4030;
-			}*/
+		if (extra->info0 != -1) {
+			continue;
+		}
+		extra->info0 = type;
+		extra->type = 0x4071;
 
-			extra->x = X;
-			extra->y = Y;
-			extra->z = Z;
+		/*if(type == SPRITEHQR_KEY) {
+			extra->type = 0x4030;
+		}*/
 
-			// same as InitFly
-			throwExtra(extra, param, angle, 40, 15);
+		extra->x = x;
+		extra->y = y;
+		extra->z = z;
 
-			extra->strengthOfHit = 0;
-			extra->lifeTime = _engine->lbaTime;
-			extra->actorIdx = 1000;
-			extra->info1 = bonusAmount;
+		// same as InitFly
+		throwExtra(extra, param, angle, 40, 15);
 
-			return i;
-		}
+		extra->strengthOfHit = 0;
+		extra->lifeTime = _engine->lbaTime;
+		extra->actorIdx = 1000;
+		extra->info1 = bonusAmount;
+		return i;
 	}
 
 	return -1;
 }
 
-int32 Extra::addExtraThrow(int32 actorIdx, int32 X, int32 Y, int32 Z, int32 sprite, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit) { // ThrowExtra
+int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 sprite, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit) { // ThrowExtra
 	int32 i;
 
 	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
-		if (extra->info0 == -1) {
-			extra->info0 = sprite;
-			extra->type = 0x210C;
-			extra->x = X;
-			extra->y = Y;
-			extra->z = Z;
+		if (extra->info0 != -1) {
+			continue;
+		}
+		extra->info0 = sprite;
+		extra->type = 0x210C;
+		extra->x = x;
+		extra->y = y;
+		extra->z = z;
 
-			// same as InitFly
-			throwExtra(extra, var2, var3, var4, var5);
+		// same as InitFly
+		throwExtra(extra, var2, var3, var4, var5);
 
-			extra->strengthOfHit = strengthOfHit;
-			extra->lifeTime = _engine->lbaTime;
-			extra->actorIdx = actorIdx;
-			extra->info1 = 0;
+		extra->strengthOfHit = strengthOfHit;
+		extra->lifeTime = _engine->lbaTime;
+		extra->actorIdx = actorIdx;
+		extra->info1 = 0;
 
-			return i;
-		}
+		return i;
 	}
 
 	return -1;
 }
 
-int32 Extra::addExtraAiming(int32 actorIdx, int32 X, int32 Y, int32 Z, int32 spriteIdx, int32 targetActorIdx, int32 maxSpeed, int32 strengthOfHit) { // ExtraSearch
+int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 maxSpeed, int32 strengthOfHit) { // ExtraSearch
 	int32 i;
 
 	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
-		if (extra->info0 == -1) {
-			extra->info0 = spriteIdx;
-			extra->type = 0x80;
-			extra->info1 = 0;
-			extra->x = X;
-			extra->y = Y;
-			extra->z = Z;
-			extra->actorIdx = actorIdx;
-			extra->lifeTime = targetActorIdx;
-			extra->destZ = maxSpeed;
-			extra->strengthOfHit = strengthOfHit;
-			_engine->_movements->setActorAngle(0, maxSpeed, 50, &extra->trackActorMove);
-			extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(X, Z, _engine->_scene->sceneActors[targetActorIdx].x, _engine->_scene->sceneActors[targetActorIdx].z);
-
-			return i;
+		if (extra->info0 != -1) {
+			continue;
 		}
+		extra->info0 = spriteIdx;
+		extra->type = 0x80;
+		extra->info1 = 0;
+		extra->x = x;
+		extra->y = y;
+		extra->z = z;
+		extra->actorIdx = actorIdx;
+		extra->lifeTime = targetActorIdx;
+		extra->destZ = maxSpeed;
+		extra->strengthOfHit = strengthOfHit;
+		_engine->_movements->setActorAngle(0, maxSpeed, 50, &extra->trackActorMove);
+		const ActorStruct *actor = _engine->_scene->getActor(targetActorIdx);
+		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, actor->x, actor->z);
+
+		return i;
 	}
 
 	return -1;
@@ -327,27 +325,28 @@ int32 Extra::addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int3
 
 	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
-		if (extra->info0 == -1) {
-			extra->info0 = spriteIdx;
-			extra->type = 0x200;
-			extra->info1 = 0;
-			extra->x = x;
-			extra->y = y;
-			extra->z = z;
-			extra->actorIdx = extraIdx;
-			extra->destZ = 0x0FA0;
-			extra->strengthOfHit = 0;
-			_engine->_movements->setActorAngle(0, 0x0FA0, 50, &extra->trackActorMove);
-			extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, extraList[extraIdx].x, extraList[extraIdx].z);
-
-			return i;
+		if (extra->info0 != -1) {
+			continue;
 		}
+		extra->info0 = spriteIdx;
+		extra->type = 0x200;
+		extra->info1 = 0;
+		extra->x = x;
+		extra->y = y;
+		extra->z = z;
+		extra->actorIdx = extraIdx;
+		extra->destZ = 0x0FA0;
+		extra->strengthOfHit = 0;
+		_engine->_movements->setActorAngle(0, 0x0FA0, 50, &extra->trackActorMove);
+		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, extraList[extraIdx].x, extraList[extraIdx].z);
+
+		return i;
 	}
 
 	return -1;
 }
 
-void Extra::addExtraThrowMagicball(int32 X, int32 Y, int32 Z, int32 param1, int32 angle, int32 param2, int32 param3) { // ThrowMagicBall
+void Extra::addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int32 angle, int32 param2, int32 param3) { // ThrowMagicBall
 	int32 ballSprite = -1;
 	int32 ballStrength = 0;
 	int32 extraIdx = -1;
@@ -384,21 +383,21 @@ void Extra::addExtraThrowMagicball(int32 X, int32 Y, int32 Z, int32 param1, int3
 
 	switch (_engine->_gameState->magicBallNumBounce) {
 	case 0:
-		_engine->_gameState->magicBallIdx = addExtraThrow(0, X, Y, Z, ballSprite, param1, angle, param2, param3, ballStrength);
+		_engine->_gameState->magicBallIdx = addExtraThrow(0, x, y, z, ballSprite, param1, angle, param2, param3, ballStrength);
 		break;
 	case 1:
 		_engine->_gameState->magicBallAuxBounce = 4;
-		_engine->_gameState->magicBallIdx = addExtraThrow(0, X, Y, Z, ballSprite, param1, angle, param2, param3, ballStrength);
+		_engine->_gameState->magicBallIdx = addExtraThrow(0, x, y, z, ballSprite, param1, angle, param2, param3, ballStrength);
 		break;
 	case 2:
 	case 3:
 	case 4:
 		_engine->_gameState->magicBallNumBounce = 1;
 		_engine->_gameState->magicBallAuxBounce = 4;
-		_engine->_gameState->magicBallIdx = addExtraThrow(0, X, Y, Z, ballSprite, param1, angle, param2, param3, ballStrength);
+		_engine->_gameState->magicBallIdx = addExtraThrow(0, x, y, z, ballSprite, param1, angle, param2, param3, ballStrength);
 		break;
 	case 5:
-		_engine->_gameState->magicBallIdx = addExtraAimingAtKey(0, X, Y, Z, ballSprite, extraIdx);
+		_engine->_gameState->magicBallIdx = addExtraAimingAtKey(0, x, y, z, ballSprite, extraIdx);
 		break;
 	}
 
@@ -407,22 +406,11 @@ void Extra::addExtraThrowMagicball(int32 X, int32 Y, int32 Z, int32 param1, int3
 	}
 }
 
-void Extra::drawSpecialShape(const int16 *shapeTable, int32 X, int32 Y, int32 color, int32 angle, int32 size) {
-	int16 currentShapeTable;
-	int16 var_8;
-	int16 temp1;
-	int32 computedX;
-	int32 computedY;
-	int32 oldComputedX;
-	int32 oldComputedY;
-	int32 numEntries;
-	int32 currentX;
-	int32 currentY;
+void Extra::drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 color, int32 angle, int32 size) {
+	int16 currentShapeTable = *(shapeTable++);
 
-	currentShapeTable = *(shapeTable++);
-
-	var_8 = ((*(shapeTable++)) * size) >> 4;
-	temp1 = ((*(shapeTable++)) * size) >> 4;
+	int16 var_8 = ((*(shapeTable++)) * size) >> 4;
+	int16 temp1 = ((*(shapeTable++)) * size) >> 4;
 
 	_engine->_redraw->renderLeft = 0x7D00;
 	_engine->_redraw->renderRight = -0x7D00;
@@ -431,52 +419,60 @@ void Extra::drawSpecialShape(const int16 *shapeTable, int32 X, int32 Y, int32 co
 
 	_engine->_movements->rotateActor(var_8, temp1, angle);
 
-	computedX = _engine->_renderer->destX + X;
-	computedY = _engine->_renderer->destZ + Y;
+	int32 computedX = _engine->_renderer->destX + x;
+	int32 computedY = _engine->_renderer->destZ + y;
 
-	if (computedX < _engine->_redraw->renderLeft)
+	if (computedX < _engine->_redraw->renderLeft) {
 		_engine->_redraw->renderLeft = computedX;
+	}
 
-	if (computedX > _engine->_redraw->renderRight)
+	if (computedX > _engine->_redraw->renderRight) {
 		_engine->_redraw->renderRight = computedX;
+	}
 
-	if (computedY < _engine->_redraw->renderTop)
+	if (computedY < _engine->_redraw->renderTop) {
 		_engine->_redraw->renderTop = computedY;
+	}
 
-	if (computedY > _engine->_redraw->renderBottom)
+	if (computedY > _engine->_redraw->renderBottom) {
 		_engine->_redraw->renderBottom = computedY;
+	}
 
-	numEntries = 1;
+	int32 numEntries = 1;
 
-	currentX = computedX;
-	currentY = computedY;
+	int32 currentX = computedX;
+	int32 currentY = computedY;
 
 	while (numEntries < currentShapeTable) {
 		var_8 = ((*(shapeTable++)) * size) >> 4;
 		temp1 = ((*(shapeTable++)) * size) >> 4;
 
-		oldComputedX = currentX;
-		oldComputedY = currentY;
+		int32 oldComputedX = currentX;
+		int32 oldComputedY = currentY;
 
 		_engine->_renderer->projPosX = currentX;
 		_engine->_renderer->projPosY = currentY;
 
 		_engine->_movements->rotateActor(var_8, temp1, angle);
 
-		currentX = _engine->_renderer->destX + X;
-		currentY = _engine->_renderer->destZ + Y;
+		currentX = _engine->_renderer->destX + x;
+		currentY = _engine->_renderer->destZ + y;
 
-		if (currentX < _engine->_redraw->renderLeft)
+		if (currentX < _engine->_redraw->renderLeft) {
 			_engine->_redraw->renderLeft = currentX;
+		}
 
-		if (currentX > _engine->_redraw->renderRight)
+		if (currentX > _engine->_redraw->renderRight) {
 			_engine->_redraw->renderRight = currentX;
+		}
 
-		if (currentY < _engine->_redraw->renderTop)
+		if (currentY < _engine->_redraw->renderTop) {
 			_engine->_redraw->renderTop = currentY;
+		}
 
-		if (currentY > _engine->_redraw->renderBottom)
+		if (currentY > _engine->_redraw->renderBottom) {
 			_engine->_redraw->renderBottom = currentY;
+		}
 
 		_engine->_renderer->projPosX = currentX;
 		_engine->_renderer->projPosY = currentY;
@@ -494,7 +490,7 @@ void Extra::drawSpecialShape(const int16 *shapeTable, int32 X, int32 Y, int32 co
 	_engine->_interface->drawLine(currentX, currentY, computedX, computedY, color);
 }
 
-void Extra::drawExtraSpecial(int32 extraIdx, int32 X, int32 Y) {
+void Extra::drawExtraSpecial(int32 extraIdx, int32 x, int32 y) {
 	int32 specialType;
 	ExtraListStruct *extra = &extraList[extraIdx];
 
@@ -502,7 +498,7 @@ void Extra::drawExtraSpecial(int32 extraIdx, int32 X, int32 Y) {
 
 	switch (specialType) {
 	case kHitStars:
-		drawSpecialShape(hitStarsShapeTable, X, Y, 15, (_engine->lbaTime << 5) & 0x300, 4);
+		drawSpecialShape(hitStarsShapeTable, x, y, 15, (_engine->lbaTime << 5) & 0x300, 4);
 		break;
 	case kExplodeCloud: {
 		int32 cloudTime = 1 + _engine->lbaTime - extra->lifeTime;
@@ -511,43 +507,42 @@ void Extra::drawExtraSpecial(int32 extraIdx, int32 X, int32 Y) {
 			cloudTime = 32;
 		}
 
-		drawSpecialShape(explodeCloudShapeTable, X, Y, 15, 0, cloudTime);
-	} break;
+		drawSpecialShape(explodeCloudShapeTable, x, y, 15, 0, cloudTime);
+		break;
+	}
 	}
 }
 
-void Extra::processMagicballBounce(ExtraListStruct *extra, int32 X, int32 Y, int32 Z) {
-	if (_engine->_grid->getBrickShape(X, extra->y, Z)) {
+void Extra::processMagicballBounce(ExtraListStruct *extra, int32 x, int32 y, int32 z) {
+	if (_engine->_grid->getBrickShape(x, extra->y, z)) {
 		extra->destY = -extra->destY;
 	}
-	if (_engine->_grid->getBrickShape(extra->x, Y, Z)) {
+	if (_engine->_grid->getBrickShape(extra->x, y, z)) {
 		extra->destX = -extra->destX;
 	}
-	if (_engine->_grid->getBrickShape(X, Y, extra->z)) {
+	if (_engine->_grid->getBrickShape(x, y, extra->z)) {
 		extra->destZ = -extra->destZ;
 	}
 
-	extra->x = X;
-	extra->lastX = X;
-	extra->y = Y;
-	extra->lastY = Y;
-	extra->z = Z;
-	extra->lastZ = Z;
+	extra->x = x;
+	extra->lastX = x;
+	extra->y = y;
+	extra->lastY = y;
+	extra->z = z;
+	extra->lastZ = z;
 
 	extra->lifeTime = _engine->lbaTime;
 }
 
 /** Process extras */
 void Extra::processExtras() {
-	int32 i;
-
 	int32 currentExtraX = 0;
 	int32 currentExtraY = 0;
 	int32 currentExtraZ = 0;
 	int32 currentExtraSpeedX = 0;
 	int32 currentExtraSpeedY = 0;
 
-	for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
 		if (extra->info0 != -1) {
 			// process extra life time
@@ -622,9 +617,10 @@ void Extra::processExtras() {
 				actorIdxAttacked = extra->lifeTime;
 				actorIdx = extra->actorIdx;
 
-				currentExtraX = _engine->_scene->sceneActors[actorIdxAttacked].x;
-				currentExtraY = _engine->_scene->sceneActors[actorIdxAttacked].y + 1000;
-				currentExtraZ = _engine->_scene->sceneActors[actorIdxAttacked].z;
+				const ActorStruct *actor = _engine->_scene->getActor(actorIdxAttacked);
+				currentExtraX = actor->x;
+				currentExtraY = actor->y + 1000;
+				currentExtraZ = actor->z;
 
 				tmpAngle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->x, extra->z, currentExtraX, currentExtraZ);
 				angle = (tmpAngle - extra->angle) & 0x3FF;
@@ -640,32 +636,30 @@ void Extra::processExtras() {
 
 					extra->info0 = -1;
 					continue;
-				} else {
-					const int32 angle2 = _engine->_movements->getAngleAndSetTargetActorDistance(extra->y, 0, currentExtraY, _engine->_movements->targetActorDistance);
-
-					int32 pos = _engine->_movements->getRealAngle(&extra->trackActorMove);
-
-					if (!pos) {
-						pos = 1;
-					}
+				}
 
-					_engine->_movements->rotateActor(pos, 0, angle2);
-					extra->y -= _engine->_renderer->destZ;
+				const int32 angle2 = _engine->_movements->getAngleAndSetTargetActorDistance(extra->y, 0, currentExtraY, _engine->_movements->targetActorDistance);
+				int32 pos = _engine->_movements->getRealAngle(&extra->trackActorMove);
+				if (!pos) {
+					pos = 1;
+				}
 
-					_engine->_movements->rotateActor(0, _engine->_renderer->destX, tmpAngle);
-					extra->x += _engine->_renderer->destX;
-					extra->z += _engine->_renderer->destZ;
+				_engine->_movements->rotateActor(pos, 0, angle2);
+				extra->y -= _engine->_renderer->destZ;
 
-					_engine->_movements->setActorAngle(0, extra->destZ, 50, &extra->trackActorMove);
+				_engine->_movements->rotateActor(0, _engine->_renderer->destX, tmpAngle);
+				extra->x += _engine->_renderer->destX;
+				extra->z += _engine->_renderer->destZ;
 
-					if (actorIdxAttacked == _engine->_collision->checkExtraCollisionWithActors(extra, actorIdx)) {
-						if (i == _engine->_gameState->magicBallIdx) {
-							_engine->_gameState->magicBallIdx = -1;
-						}
+				_engine->_movements->setActorAngle(0, extra->destZ, 50, &extra->trackActorMove);
 
-						extra->info0 = -1;
-						continue;
+				if (actorIdxAttacked == _engine->_collision->checkExtraCollisionWithActors(extra, actorIdx)) {
+					if (i == _engine->_gameState->magicBallIdx) {
+						_engine->_gameState->magicBallIdx = -1;
 					}
+
+					extra->info0 = -1;
+					continue;
 				}
 			}
 			// process magic ball extra aiming for key
@@ -822,9 +816,8 @@ void Extra::processExtras() {
 
 								extra->info0 = -1;
 								continue;
-							} else {
-								processMagicballBounce(extra, currentExtraX, currentExtraY, currentExtraZ);
 							}
+							processMagicballBounce(extra, currentExtraX, currentExtraY, currentExtraZ);
 						}
 					} else {
 						extra->info0 = -1;
@@ -876,27 +869,19 @@ void Extra::processExtras() {
 						if (_engine->_gameState->inventoryNumKashes > 999) {
 							_engine->_gameState->inventoryNumKashes = 999;
 						}
-					}
-
-					if (extra->info0 == SPRITEHQR_LIFEPOINTS) {
+					} else if (extra->info0 == SPRITEHQR_LIFEPOINTS) {
 						_engine->_scene->sceneHero->life += extra->info1;
 						if (_engine->_scene->sceneHero->life > 50) {
 							_engine->_scene->sceneHero->life = 50;
 						}
-					}
-
-					if (extra->info0 == SPRITEHQR_MAGICPOINTS && _engine->_gameState->magicLevelIdx) {
+					} else if (extra->info0 == SPRITEHQR_MAGICPOINTS && _engine->_gameState->magicLevelIdx) {
 						_engine->_gameState->inventoryMagicPoints += extra->info1 * 2;
 						if (_engine->_gameState->inventoryMagicPoints > _engine->_gameState->magicLevelIdx * 20) {
 							_engine->_gameState->inventoryMagicPoints = _engine->_gameState->magicLevelIdx * 20;
 						}
-					}
-
-					if (extra->info0 == SPRITEHQR_KEY) {
+					} else if (extra->info0 == SPRITEHQR_KEY) {
 						_engine->_gameState->inventoryNumKeys += extra->info1;
-					}
-
-					if (extra->info0 == SPRITEHQR_CLOVERLEAF) {
+					} else if (extra->info0 == SPRITEHQR_CLOVERLEAF) {
 						_engine->_gameState->inventoryNumLeafs += extra->info1;
 						if (_engine->_gameState->inventoryNumLeafs > _engine->_gameState->inventoryNumLeafsBox) {
 							_engine->_gameState->inventoryNumLeafs = _engine->_gameState->inventoryNumLeafsBox;
diff --git a/engines/twine/extra.h b/engines/twine/extra.h
index 259e615e4c..5194246e07 100644
--- a/engines/twine/extra.h
+++ b/engines/twine/extra.h
@@ -65,33 +65,33 @@ private:
 	TwinEEngine *_engine;
 
 	void throwExtra(ExtraListStruct *extra, int32 var1, int32 var2, int32 var3, int32 var4);
-	void processMagicballBounce(ExtraListStruct *extra, int32 X, int32 Y, int32 Z);
+	void processMagicballBounce(ExtraListStruct *extra, int32 x, int32 y, int32 z);
 	int32 findExtraKey();
-	int32 addExtraAimingAtKey(int32 actorIdx, int32 X, int32 Y, int32 Z, int32 spriteIdx, int32 extraIdx);
-	void drawSpecialShape(const int16 *shapeTable, int32 X, int32 Y, int32 color, int32 angle, int32 size);
+	int32 addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 extraIdx);
+	void drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 color, int32 angle, int32 size);
 
 public:
 	Extra(TwinEEngine *engine);
 	ExtraListStruct extraList[EXTRA_MAX_ENTRIES];
 
-	int32 addExtra(int32 actorIdx, int32 X, int32 Y, int32 Z, int32 info0, int32 targetActor, int32 maxSpeed, int32 strengthOfHit);
+	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 */
-	int32 addExtraExplode(int32 X, int32 Y, int32 Z);
+	@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 */
 	void resetExtras();
 
-	void addExtraSpecial(int32 X, int32 Y, int32 Z, int32 type);
-	int32 addExtraBonus(int32 X, int32 Y, int32 Z, int32 param, int32 angle, int32 type, int32 bonusAmount);
-	int32 addExtraThrow(int32 actorIdx, int32 X, int32 Y, int32 Z, int32 sprite, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit);
-	int32 addExtraAiming(int32 actorIdx, int32 X, int32 Y, int32 Z, int32 spriteIdx, int32 targetActorIdx, int32 maxSpeed, int32 strengthOfHit);
-	void addExtraThrowMagicball(int32 X, int32 Y, int32 Z, int32 param1, int32 angle, int32 param2, int32 param3);
+	void addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type);
+	int32 addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle, int32 type, int32 bonusAmount);
+	int32 addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 sprite, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit);
+	int32 addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 maxSpeed, int32 strengthOfHit);
+	void addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int32 angle, int32 param2, int32 param3);
 
-	void drawExtraSpecial(int32 extraIdx, int32 X, int32 Y);
+	void drawExtraSpecial(int32 extraIdx, int32 x, int32 y);
 
 	/** Process extras */
 	void processExtras();
diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index bb7413bade..7e3804a41a 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -259,13 +259,12 @@ void Movements::moveActor(int32 angleFrom, int32 angleTo, int32 speed, ActorMove
 }
 
 void Movements::processActorMovements(int32 actorIdx) {
-	ActorStruct *actor = &_engine->_scene->sceneActors[actorIdx];
-
-	if (actor->entity == -1)
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
+	if (actor->entity == -1) {
 		return;
+	}
 
 	if (actor->dynamicFlags.bIsFalling) {
-
 		if (actor->controlMode != 1) {
 			return;
 		}
@@ -291,7 +290,8 @@ void Movements::processActorMovements(int32 actorIdx) {
 		case kNoMove:
 			break;
 		case kManual:
-			if (!actorIdx) { // take this out when we want to give manual movements to other characters than Hero
+			// take this out when we want to give manual movements to other characters than Hero
+			if (actor == _engine->_scene->sceneHero) {
 				heroAction = 0;
 
 				// If press W for action
@@ -333,12 +333,10 @@ void Movements::processActorMovements(int32 actorIdx) {
 								}
 							}
 						} else {
-							if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
-								_engine->_animations->initAnim(kRightPunch, 1, 0, actorIdx);
-							}
-
 							if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
 								_engine->_animations->initAnim(kLeftPunch, 1, 0, actorIdx);
+							} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
+								_engine->_animations->initAnim(kRightPunch, 1, 0, actorIdx);
 							}
 
 							if (_engine->_input->toggleActionIfActive(TwinEActionType::MoveForward)) {
@@ -441,13 +439,15 @@ void Movements::processActorMovements(int32 actorIdx) {
 
 			break;
 		case kFollow: {
-			int32 newAngle = getAngleAndSetTargetActorDistance(actor->x, actor->z, _engine->_scene->sceneActors[actor->followedActor].x, _engine->_scene->sceneActors[actor->followedActor].z);
+			const ActorStruct* followedActor = _engine->_scene->getActor(actor->followedActor);
+			int32 newAngle = getAngleAndSetTargetActorDistance(actor->x, actor->z, followedActor->x, followedActor->z);
 			if (actor->staticFlags.bIsSpriteActor) {
 				actor->angle = newAngle;
 			} else {
 				moveActor(actor->angle, newAngle, actor->speed, &actor->move);
 			}
-		} break;
+			break;
+		}
 		case kTrack:
 			if (actor->positionInMoveScript == -1) {
 				actor->positionInMoveScript = 0;
@@ -456,10 +456,12 @@ void Movements::processActorMovements(int32 actorIdx) {
 		case kFollow2:     // unused
 		case kTrackAttack: // unused
 			break;
-		case kSameXZ:
-			actor->x = _engine->_scene->sceneActors[actor->followedActor].x;
-			actor->z = _engine->_scene->sceneActors[actor->followedActor].z;
+		case kSameXZ: {
+			const ActorStruct* followedActor = _engine->_scene->getActor(actor->followedActor);
+			actor->x = followedActor->x;
+			actor->z = followedActor->z;
 			break;
+		}
 		case kRandom: {
 			if (!actor->dynamicFlags.bIsRotationByAnim) {
 				if (actor->brickShape & 0x80) {
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index a16a160361..e08869166a 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -26,10 +26,11 @@
 #include "twine/actor.h"
 #include "twine/animations.h"
 #include "twine/collision.h"
+#include "twine/debug_scene.h"
 #include "twine/grid.h"
 #include "twine/hqrdepack.h"
-#include "twine/interface.h"
 #include "twine/input.h"
+#include "twine/interface.h"
 #include "twine/menu.h"
 #include "twine/movements.h"
 #include "twine/renderer.h"
@@ -38,7 +39,6 @@
 #include "twine/screens.h"
 #include "twine/sound.h"
 #include "twine/text.h"
-#include "twine/debug_scene.h"
 
 namespace TwinE {
 
@@ -149,7 +149,7 @@ void Redraw::blitBackgroundAreas() {
 	const RedrawStruct *currentArea = currentRedrawList;
 
 	for (int32 i = 0; i < numOfRedrawBox; i++) {
-		_engine->_interface->blitBox(currentArea->left, currentArea->top, currentArea->right, currentArea->bottom, (const int8*)_engine->workVideoBuffer.getPixels(), currentArea->left, currentArea->top, (int8*)_engine->frontVideoBuffer.getPixels());
+		_engine->_interface->blitBox(currentArea->left, currentArea->top, currentArea->right, currentArea->bottom, (const int8 *)_engine->workVideoBuffer.getPixels(), currentArea->left, currentArea->top, (int8 *)_engine->frontVideoBuffer.getPixels());
 		currentArea++;
 	}
 }
@@ -233,10 +233,10 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 
 	// Process actors drawing list
 	for (modelActorPos = 0; modelActorPos < _engine->_scene->sceneNumActors; modelActorPos++, spriteActorPos++, shadowActorPos++) {
-		actor = &_engine->_scene->sceneActors[modelActorPos];
+		actor = _engine->_scene->getActor(modelActorPos);
 		actor->dynamicFlags.bIsVisible = 0; // reset visible state
 
-		if ((_engine->_grid->useCellingGrid == -1) || actor->y <= (*(int16 *)(_engine->_grid->cellingGridIdx * 24 + (int8 *)_engine->_scene->sceneZones + 8))) {
+		if (_engine->_grid->useCellingGrid == -1 || actor->y <= (*(int16 *)(_engine->_grid->cellingGridIdx * 24 + (int8 *)_engine->_scene->sceneZones + 8))) {
 			// no redraw required
 			if (actor->staticFlags.bIsBackgrounded && bgRedraw == 0) {
 				// get actor position on screen
@@ -259,7 +259,8 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 
 						// if actor is above another actor
 						if (actor->standOn != -1) {
-							tmpVal = _engine->_scene->sceneActors[actor->standOn].x - _engine->_grid->cameraX + _engine->_scene->sceneActors[actor->standOn].z - _engine->_grid->cameraZ + 2;
+							const ActorStruct *standOnActor = _engine->_scene->getActor(actor->standOn);
+							tmpVal = standOnActor->x - _engine->_grid->cameraX + standOnActor->z - _engine->_grid->cameraZ + 2;
 						}
 
 						if (actor->staticFlags.bIsSpriteActor) {
@@ -346,7 +347,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 
 		do {
 			int32 actorIdx = drawList[pos].index & 0x3FF;
-			ActorStruct *actor2 = &_engine->_scene->sceneActors[actorIdx];
+			ActorStruct *actor2 = _engine->_scene->getActor(actorIdx);
 			uint32 flags = ((uint32)drawList[pos].index) & 0xFC00;
 
 			// Drawing actors
@@ -393,7 +394,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 							addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
 
 							if (actor2->staticFlags.bIsBackgrounded && bgRedraw == 1) {
-								_engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom, (const int8*)_engine->frontVideoBuffer.getPixels(), _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, (int8*)_engine->workVideoBuffer.getPixels());
+								_engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom, (const int8 *)_engine->frontVideoBuffer.getPixels(), _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, (int8 *)_engine->workVideoBuffer.getPixels());
 							}
 						}
 					}
@@ -479,7 +480,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 					addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->_interface->textWindowRight, _engine->_interface->textWindowBottom);
 
 					if (actor2->staticFlags.bIsBackgrounded && bgRedraw == 1) {
-						_engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->_interface->textWindowRight, _engine->_interface->textWindowBottom, (const int8*)_engine->frontVideoBuffer.getPixels(), _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, (int8*)_engine->workVideoBuffer.getPixels());
+						_engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->_interface->textWindowRight, _engine->_interface->textWindowBottom, (const int8 *)_engine->frontVideoBuffer.getPixels(), _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, (int8 *)_engine->workVideoBuffer.getPixels());
 					}
 
 					// show clipping area
@@ -543,7 +544,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				}
 				break;
 			case koFollowActor: {
-				ActorStruct *actor2 = &_engine->_scene->sceneActors[overlay->info1];
+				ActorStruct *actor2 = _engine->_scene->getActor(overlay->info1);
 
 				_engine->_renderer->projectPositionOnScreen(actor2->x - _engine->_grid->cameraX, actor2->y + actor2->boudingBox.y.topRight - _engine->_grid->cameraY, actor2->z - _engine->_grid->cameraZ);
 
@@ -554,7 +555,8 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 					overlay->info0 = -1;
 					continue;
 				}
-			} break;
+				break;
+			}
 			}
 
 			// process overlay type
@@ -579,8 +581,8 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
 					addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
 				}
-
-			} break;
+				break;
+			}
 			case koNumber: {
 				int32 textLength, textHeight;
 				char text[10];
@@ -603,7 +605,8 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
 					addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
 				}
-			} break;
+				break;
+			}
 			case koNumberRange: {
 				int32 textLength, textHeight, range;
 				char text[10];
@@ -629,7 +632,8 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
 					addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
 				}
-			} break;
+				break;
+			}
 			case koInventoryItem: {
 				int32 item = overlay->info0;
 
@@ -646,7 +650,8 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 				_engine->_menu->drawBox(10, 10, 69, 69);
 				addRedrawArea(10, 10, 69, 69);
 				_engine->_gameState->initEngineProjections();
-			} break;
+				break;
+			}
 			case koText: {
 				char text[256];
 
@@ -678,14 +683,15 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 
 				_engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
 
-				_engine->_text->setFontColor(_engine->_scene->sceneActors[overlay->info1].talkColor);
+				_engine->_text->setFontColor(_engine->_scene->getActor(overlay->info1)->talkColor);
 
 				_engine->_text->drawText(renderLeft, renderTop, text);
 
 				if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
 					addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
 				}
-			} break;
+				break;
+			}
 			}
 		}
 	}
@@ -724,7 +730,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 void Redraw::drawBubble(int32 actorIdx) {
 	int32 spriteWidth, spriteHeight;
 	uint8 *spritePtr;
-	ActorStruct *actor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
 	// get actor position on screen
 	_engine->_renderer->projectPositionOnScreen(actor->x - _engine->_grid->cameraX, actor->y + actor->boudingBox.y.topRight - _engine->_grid->cameraY, actor->z - _engine->_grid->cameraZ);
@@ -762,8 +768,8 @@ void Redraw::zoomScreenScale() {
 	zoomWorkVideoBuffer.copyFrom(_engine->workVideoBuffer);
 
 	// TODO: this is broken
-	const uint8 *src = (const uint8*)zoomWorkVideoBuffer.getPixels();
-	uint8 *dest = (uint8*)_engine->workVideoBuffer.getPixels();
+	const uint8 *src = (const uint8 *)zoomWorkVideoBuffer.getPixels();
+	uint8 *dest = (uint8 *)_engine->workVideoBuffer.getPixels();
 	for (int h = 0; h < zoomWorkVideoBuffer.h; h++) {
 		for (int w = 0; w < zoomWorkVideoBuffer.w; w++) {
 			*dest++ = *src;
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 3cbda28ee3..b6f71400c1 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -393,6 +393,12 @@ void Scene::changeScene() {
 	}
 }
 
+ActorStruct* Scene::getActor(int32 actorIdx) {
+	assert(actorIdx >= 0);
+	assert(actorIdx < NUM_MAX_ACTORS);
+	return &sceneActors[actorIdx];
+}
+
 void Scene::processEnvironmentSound() {
 	int16 s, currentAmb, decal, repeat;
 	int16 sampleIdx = -1;
diff --git a/engines/twine/scene.h b/engines/twine/scene.h
index abda61b194..8b59daceb7 100644
--- a/engines/twine/scene.h
+++ b/engines/twine/scene.h
@@ -99,6 +99,8 @@ enum ZoneType {
 	kLadder = 6    // Hero can climb on it
 };
 
+#define OWN_ACTOR_SCENE_INDEX 0
+
 class TwinEEngine;
 class Scene {
 private:
@@ -113,6 +115,9 @@ private:
 	/** Reset scene */
 	void resetScene();
 
+	// the first actor is the own hero
+	ActorStruct sceneActors[NUM_MAX_ACTORS];
+
 public:
 	Scene(TwinEEngine *engine) : _engine(engine) {}
 
@@ -162,9 +167,8 @@ public:
 
 	// ACTORS
 	int32 sceneNumActors = 0;
-	// the first actor is the own hero
-	ActorStruct sceneActors[NUM_MAX_ACTORS];
 	ActorStruct *sceneHero = nullptr;
+	ActorStruct* getActor(int32 actorIdx);
 
 	/** Meca pinguin actor index */
 	int16 mecaPinguinIdx = 0; // currentPingouin
diff --git a/engines/twine/script_life.cpp b/engines/twine/script_life.cpp
index 81d74dbf46..2dbb8d1301 100644
--- a/engines/twine/script_life.cpp
+++ b/engines/twine/script_life.cpp
@@ -126,17 +126,16 @@ static int32 processLifeConditions(TwinEEngine *engine, ActorStruct *actor) {
 		break;
 	case kcCOL_OBJ: {
 		int32 actorIdx = *(scriptPtr++);
-		if (engine->_scene->sceneActors[actorIdx].life <= 0) {
+		if (engine->_scene->getActor(actorIdx)->life <= 0) {
 			engine->_scene->currentScriptValue = -1;
 		} else {
-			engine->_scene->currentScriptValue = engine->_scene->sceneActors[actorIdx].collision;
+			engine->_scene->currentScriptValue = engine->_scene->getActor(actorIdx)->collision;
 		}
 	} break;
 	case kcDISTANCE: {
-		ActorStruct *otherActor;
 		int32 actorIdx = *(scriptPtr++);
 		conditionValueSize = 2;
-		otherActor = &engine->_scene->sceneActors[actorIdx];
+		ActorStruct *otherActor = engine->_scene->getActor(actorIdx);
 		if (!otherActor->dynamicFlags.bIsDead) {
 			if (ABS(actor->y - otherActor->y) >= 1500) {
 				engine->_scene->currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
@@ -158,41 +157,37 @@ static int32 processLifeConditions(TwinEEngine *engine, ActorStruct *actor) {
 		break;
 	case kcZONE_OBJ: {
 		int32 actorIdx = *(scriptPtr++);
-		engine->_scene->currentScriptValue = engine->_scene->sceneActors[actorIdx].zone;
+		engine->_scene->currentScriptValue = engine->_scene->getActor(actorIdx)->zone;
 	} break;
 	case kcBODY:
 		engine->_scene->currentScriptValue = actor->body;
 		break;
 	case kcBODY_OBJ: {
 		int32 actorIdx = *(scriptPtr++);
-		engine->_scene->currentScriptValue = engine->_scene->sceneActors[actorIdx].body;
+		engine->_scene->currentScriptValue = engine->_scene->getActor(actorIdx)->body;
 	} break;
 	case kcANIM:
 		engine->_scene->currentScriptValue = actor->anim;
 		break;
 	case kcANIM_OBJ: {
 		int32 actorIdx = *(scriptPtr++);
-		engine->_scene->currentScriptValue = engine->_scene->sceneActors[actorIdx].anim;
+		engine->_scene->currentScriptValue = engine->_scene->getActor(actorIdx)->anim;
 	} break;
 	case kcL_TRACK:
 		engine->_scene->currentScriptValue = actor->labelIdx;
 		break;
 	case kcL_TRACK_OBJ: {
 		int32 actorIdx = *(scriptPtr++);
-		engine->_scene->currentScriptValue = engine->_scene->sceneActors[actorIdx].labelIdx;
+		engine->_scene->currentScriptValue = engine->_scene->getActor(actorIdx)->labelIdx;
 	} break;
 	case kcFLAG_CUBE: {
 		int32 flagIdx = *(scriptPtr++);
 		engine->_scene->currentScriptValue = engine->_scene->sceneFlags[flagIdx];
 	} break;
 	case kcCONE_VIEW: {
-		int32 newAngle;
-		int32 targetActorIdx;
-		ActorStruct *targetActor;
-
-		newAngle = 0;
-		targetActorIdx = *(scriptPtr++);
-		targetActor = &engine->_scene->sceneActors[targetActorIdx];
+		int32 newAngle = 0;
+		int32 targetActorIdx = *(scriptPtr++);
+		ActorStruct *targetActor = engine->_scene->getActor(targetActorIdx);
 
 		conditionValueSize = 2;
 
@@ -261,7 +256,7 @@ static int32 processLifeConditions(TwinEEngine *engine, ActorStruct *actor) {
 		break;
 	case kcLIFE_POINT_OBJ: {
 		int32 actorIdx = *(scriptPtr++);
-		engine->_scene->currentScriptValue = engine->_scene->sceneActors[actorIdx].life;
+		engine->_scene->currentScriptValue = engine->_scene->getActor(actorIdx)->life;
 	} break;
 	case kcNUM_LITTLE_KEYS:
 		engine->_scene->currentScriptValue = engine->_gameState->inventoryNumKeys;
@@ -281,7 +276,7 @@ static int32 processLifeConditions(TwinEEngine *engine, ActorStruct *actor) {
 		ActorStruct *targetActor;
 
 		targetActorIdx = *(scriptPtr++);
-		targetActor = &engine->_scene->sceneActors[targetActorIdx];
+		targetActor = engine->_scene->getActor(targetActorIdx);
 
 		conditionValueSize = 2;
 
@@ -544,7 +539,7 @@ static int32 lSET_LIFE(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor)
 /*0x16*/
 static int32 lSET_LIFE_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor) {
 	int32 otherActorIdx = *(scriptPtr++);
-	engine->_scene->sceneActors[otherActorIdx].positionInLifeScript = *((int16 *)scriptPtr); // offset
+	engine->_scene->getActor(otherActorIdx)->positionInLifeScript = *((int16 *)scriptPtr); // offset
 	scriptPtr += 2;
 	return 0;
 }
@@ -559,7 +554,7 @@ static int32 lSET_TRACK(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor)
 /*0x18*/
 static int32 lSET_TRACK_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor) {
 	int32 otherActorIdx = *(scriptPtr++);
-	engine->_scene->sceneActors[otherActorIdx].positionInMoveScript = *((int16 *)scriptPtr); // offset
+	engine->_scene->getActor(otherActorIdx)->positionInMoveScript = *((int16 *)scriptPtr); // offset
 	scriptPtr += 2;
 	return 0;
 }
@@ -606,9 +601,9 @@ static int32 lSET_DIRMODE_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *
 	int32 otherActorIdx = *(scriptPtr++);
 	int32 controlMode = *(scriptPtr++);
 
-	engine->_scene->sceneActors[otherActorIdx].controlMode = controlMode;
+	engine->_scene->getActor(otherActorIdx)->controlMode = controlMode;
 	if (controlMode == kFollow) {
-		engine->_scene->sceneActors[otherActorIdx].followedActor = *(scriptPtr++);
+		engine->_scene->getActor(otherActorIdx)->followedActor = *(scriptPtr++);
 	}
 
 	return 0;
@@ -616,13 +611,13 @@ static int32 lSET_DIRMODE_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *
 
 /*0x1D*/
 static int32 lCAM_FOLLOW(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor) {
-	int32 followedActorIdx;
-	followedActorIdx = *(scriptPtr++);
+	int32 followedActorIdx = *(scriptPtr++);
 
 	if (engine->_scene->currentlyFollowedActor != followedActorIdx) {
-		engine->_grid->newCameraX = engine->_scene->sceneActors[followedActorIdx].x >> 9;
-		engine->_grid->newCameraY = engine->_scene->sceneActors[followedActorIdx].y >> 8;
-		engine->_grid->newCameraZ = engine->_scene->sceneActors[followedActorIdx].z >> 9;
+		const ActorStruct* followedActor = engine->_scene->getActor(followedActorIdx);
+		engine->_grid->newCameraX = followedActor->x >> 9;
+		engine->_grid->newCameraY = followedActor->y >> 8;
+		engine->_grid->newCameraZ = followedActor->z >> 9;
 
 		engine->_scene->currentlyFollowedActor = followedActorIdx;
 		engine->_redraw->reqBgRedraw = true;
@@ -668,7 +663,7 @@ static int32 lSET_COMPORTEMENT(TwinEEngine *engine, int32 actorIdx, ActorStruct
 static int32 lSET_COMPORTEMENT_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor) {
 	int32 otherActorIdx = *(scriptPtr++);
 
-	engine->_scene->sceneActors[otherActorIdx].positionInLifeScript = *((int16 *)scriptPtr);
+	engine->_scene->getActor(otherActorIdx)->positionInLifeScript = *((int16 *)scriptPtr);
 	scriptPtr += 2;
 
 	return 0;
@@ -694,10 +689,10 @@ static int32 lKILL_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor)
 	int32 otherActorIdx = *(scriptPtr++);
 
 	engine->_actor->processActorCarrier(otherActorIdx);
-	engine->_scene->sceneActors[otherActorIdx].dynamicFlags.bIsDead = 1;
-	engine->_scene->sceneActors[otherActorIdx].entity = -1;
-	engine->_scene->sceneActors[otherActorIdx].zone = -1;
-	engine->_scene->sceneActors[otherActorIdx].life = 0;
+	engine->_scene->getActor(otherActorIdx)->dynamicFlags.bIsDead = 1;
+	engine->_scene->getActor(otherActorIdx)->entity = -1;
+	engine->_scene->getActor(otherActorIdx)->zone = -1;
+	engine->_scene->getActor(otherActorIdx)->life = 0;
 
 	return 0;
 }
@@ -790,7 +785,7 @@ static int32 lMESSAGE_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *acto
 	if (engine->_text->showDialogueBubble) {
 		engine->_redraw->drawBubble(otherActorIdx);
 	}
-	engine->_text->setFontCrossColor(engine->_scene->sceneActors[otherActorIdx].talkColor);
+	engine->_text->setFontCrossColor(engine->_scene->getActor(otherActorIdx)->talkColor);
 	engine->_scene->talkingActor = otherActorIdx;
 	engine->_text->drawTextFullscreen(textIdx);
 	engine->unfreezeTime();
@@ -993,7 +988,7 @@ static int32 lSET_LIFE_POINT_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruc
 	int32 otherActorIdx = *(scriptPtr++);
 	static int32 lifeValue = *(scriptPtr++);
 
-	engine->_scene->sceneActors[otherActorIdx].life = lifeValue;
+	engine->_scene->getActor(otherActorIdx)->life = lifeValue;
 
 	return 0;
 }
@@ -1003,10 +998,10 @@ static int32 lSUB_LIFE_POINT_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruc
 	int32 otherActorIdx = *(scriptPtr++);
 	static int32 lifeValue = *(scriptPtr++);
 
-	engine->_scene->sceneActors[otherActorIdx].life -= lifeValue;
+	engine->_scene->getActor(otherActorIdx)->life -= lifeValue;
 
-	if (engine->_scene->sceneActors[otherActorIdx].life < 0) {
-		engine->_scene->sceneActors[otherActorIdx].life = 0;
+	if (engine->_scene->getActor(otherActorIdx)->life < 0) {
+		engine->_scene->getActor(otherActorIdx)->life = 0;
 	}
 
 	return 0;
@@ -1016,7 +1011,7 @@ static int32 lSUB_LIFE_POINT_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruc
 static int32 lHIT_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor) {
 	int32 otherActorIdx = *(scriptPtr++);
 	int32 strengthOfHit = *(scriptPtr++);
-	engine->_actor->hitActor(actorIdx, otherActorIdx, strengthOfHit, engine->_scene->sceneActors[otherActorIdx].angle);
+	engine->_actor->hitActor(actorIdx, otherActorIdx, strengthOfHit, engine->_scene->getActor(otherActorIdx)->angle);
 	return 0;
 }
 
@@ -1107,17 +1102,17 @@ static int32 lBIG_MESSAGE(TwinEEngine *engine, int32 actorIdx, ActorStruct *acto
 /*0x47*/
 static int32 lINIT_PINGOUIN(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor) {
 	int32 pingouinActor = *(scriptPtr++);
-	engine->_scene->sceneActors[pingouinActor].dynamicFlags.bIsDead = 1;
 	engine->_scene->mecaPinguinIdx = pingouinActor;
-	engine->_scene->sceneActors[pingouinActor].entity = -1;
-	engine->_scene->sceneActors[pingouinActor].zone = -1;
+	ActorStruct* mecaPinguin = engine->_scene->getActor(pingouinActor);
+	mecaPinguin->dynamicFlags.bIsDead = 1;
+	mecaPinguin->entity = -1;
+	mecaPinguin->zone = -1;
 	return 0;
 }
 
 /*0x48*/
 static int32 lSET_HOLO_POS(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor) {
 	static int32 location = *(scriptPtr++);
-
 	engine->_holomap->setHolomapPosition(location);
 	if (engine->_gameState->gameFlags[InventoryItems::kiHolomap]) {
 		engine->_redraw->addOverlay(koInventoryItem, 0, 0, 0, 0, koNormal, 3);
@@ -1280,7 +1275,7 @@ static int32 lFADE_PAL_ALARM(TwinEEngine *engine, int32 actorIdx, ActorStruct *a
 /*0x58*/
 static int32 lEXPLODE_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor) {
 	int32 otherActorIdx = *(scriptPtr++);
-	ActorStruct *otherActor = &engine->_scene->sceneActors[otherActorIdx];
+	ActorStruct *otherActor = engine->_scene->getActor(otherActorIdx);
 
 	engine->_extra->addExtraExplode(otherActor->x, otherActor->y, otherActor->z); // RECHECK this
 
@@ -1309,7 +1304,7 @@ static int32 lASK_CHOICE_OBJ(TwinEEngine *engine, int32 actorIdx, ActorStruct *a
 	if (engine->_text->showDialogueBubble) {
 		engine->_redraw->drawBubble(otherActorIdx);
 	}
-	engine->_text->setFontCrossColor(engine->_scene->sceneActors[otherActorIdx].talkColor);
+	engine->_text->setFontCrossColor(engine->_scene->getActor(otherActorIdx)->talkColor);
 	engine->_gameState->processGameChoices(choiceIdx);
 	engine->_gameState->numChoices = 0;
 	engine->unfreezeTime();
@@ -1602,17 +1597,14 @@ ScriptLife::ScriptLife(TwinEEngine *engine) : _engine(engine) {
 }
 
 void ScriptLife::processLifeScript(int32 actorIdx) {
-	int32 end, scriptOpcode;
-	ActorStruct *actor;
-
-	actor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	scriptPtr = actor->lifeScript + actor->positionInLifeScript;
 
-	end = -2;
+	int32 end = -2;
 
 	do {
 		opcodePtr = scriptPtr;
-		scriptOpcode = *(scriptPtr++);
+		int32 scriptOpcode = *(scriptPtr++);
 
 		if (scriptOpcode >= 0 && scriptOpcode < ARRAYSIZE(function_map)) {
 			end = function_map[scriptOpcode].function(_engine, actorIdx, actor);
diff --git a/engines/twine/script_move.cpp b/engines/twine/script_move.cpp
index 38e5a10b08..14ba9a7ece 100644
--- a/engines/twine/script_move.cpp
+++ b/engines/twine/script_move.cpp
@@ -583,17 +583,14 @@ ScriptMove::ScriptMove(TwinEEngine *engine) : _engine(engine) {
 }
 
 void ScriptMove::processMoveScript(int32 actorIdx) {
-	int32 scriptOpcode;
-	ActorStruct *actor;
-
 	continueMove = 1;
-	actor = &_engine->_scene->sceneActors[actorIdx];
+	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	move = &actor->move;
 
 	do {
 		scriptPosition = actor->positionInMoveScript;
 		scriptPtr = actor->moveScript + scriptPosition;
-		scriptOpcode = *(scriptPtr++);
+		int32 scriptOpcode = *(scriptPtr++);
 
 		actor->positionInMoveScript++;
 
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 5a5d2c6710..fee71112a7 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -295,7 +295,7 @@ void TwinEEngine::initAll() {
 
 	_redraw->bubbleSpriteIndex = SPRITEHQR_DIAG_BUBBLE_LEFT;
 
-	_scene->sceneHero = &_scene->sceneActors[0];
+	_scene->sceneHero = _scene->getActor(OWN_ACTOR_SCENE_INDEX);
 
 	_redraw->renderRight = SCREEN_TEXTLIMIT_RIGHT;
 	_redraw->renderBottom = SCREEN_TEXTLIMIT_BOTTOM;
@@ -328,7 +328,7 @@ void TwinEEngine::unfreezeTime() {
 }
 
 void TwinEEngine::processActorSamplePosition(int32 actorIdx) {
-	const ActorStruct *actor = &_scene->sceneActors[actorIdx];
+	const ActorStruct *actor = _scene->getActor(actorIdx);
 	const int32 channelIdx = _sound->getActorChannel(actorIdx);
 	_sound->setSamplePosition(channelIdx, actor->x, actor->y, actor->z);
 }
@@ -446,7 +446,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 				}
 				break;
 			case kiPinguin: {
-				ActorStruct *pinguin = &_scene->sceneActors[_scene->mecaPinguinIdx];
+				ActorStruct *pinguin = _scene->getActor(_scene->mecaPinguinIdx);
 
 				pinguin->x = _renderer->destX + _scene->sceneHero->x;
 				pinguin->y = _scene->sceneHero->y;
@@ -532,9 +532,10 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 
 		// Recenter Screen
 		if (_input->isActionActive(TwinEActionType::RecenterScreenOnTwinsen) && !disableScreenRecenter) {
-			_grid->newCameraX = _scene->sceneActors[_scene->currentlyFollowedActor].x >> 9;
-			_grid->newCameraY = _scene->sceneActors[_scene->currentlyFollowedActor].y >> 8;
-			_grid->newCameraZ = _scene->sceneActors[_scene->currentlyFollowedActor].z >> 9;
+			const ActorStruct* currentlyFollowedActor = _scene->getActor(_scene->currentlyFollowedActor);
+			_grid->newCameraX = currentlyFollowedActor->x >> 9;
+			_grid->newCameraY = currentlyFollowedActor->y >> 8;
+			_grid->newCameraZ = currentlyFollowedActor->z >> 9;
 			_redraw->reqBgRedraw = true;
 		}
 
@@ -578,13 +579,13 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 
 	// Reset HitBy state
 	for (int32 a = 0; a < _scene->sceneNumActors; a++) {
-		_scene->sceneActors[a].hitBy = -1;
+		_scene->getActor(a)->hitBy = -1;
 	}
 
 	_extra->processExtras();
 
 	for (int32 a = 0; a < _scene->sceneNumActors; a++) {
-		ActorStruct *actor = &_scene->sceneActors[a];
+		ActorStruct *actor = _scene->getActor(a);
 
 		if (!actor->dynamicFlags.bIsDead) {
 			if (actor->life == 0) {
@@ -723,7 +724,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 
 	// recenter screen automatically
 	if (!disableScreenRecenter && !_debugGrid->useFreeCamera) {
-		ActorStruct *actor = &_scene->sceneActors[_scene->currentlyFollowedActor];
+		ActorStruct *actor = _scene->getActor(_scene->currentlyFollowedActor);
 		_renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX << 9),
 		                                   actor->y - (_grid->newCameraY << 8),
 		                                   actor->z - (_grid->newCameraZ << 9));


Commit: 153bfa03aa9fbaf37038ede3986b6d276d7aaba0
    https://github.com/scummvm/scummvm/commit/153bfa03aa9fbaf37038ede3986b6d276d7aaba0
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-25T16:57:27+01:00

Commit Message:
TWINE: removed own midi code - use MidiParser_XMIDI

Changed paths:
  R engines/twine/xmidi.cpp
  R engines/twine/xmidi.h
    engines/twine/module.mk
    engines/twine/music.cpp
    engines/twine/music.h


diff --git a/engines/twine/module.mk b/engines/twine/module.mk
index 5589531b12..d5dfe8ebe1 100644
--- a/engines/twine/module.mk
+++ b/engines/twine/module.mk
@@ -30,8 +30,7 @@ MODULE_OBJS := \
 	script_move.o \
 	sound.o \
 	text.o \
-	twine.o \
-	xmidi.o
+	twine.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_TWINE), DYNAMIC_PLUGIN)
diff --git a/engines/twine/music.cpp b/engines/twine/music.cpp
index 0495ad3f93..5bbeb90c1c 100644
--- a/engines/twine/music.cpp
+++ b/engines/twine/music.cpp
@@ -30,7 +30,6 @@
 #include "twine/hqrdepack.h"
 #include "twine/resources.h"
 #include "twine/twine.h"
-#include "twine/xmidi.h"
 
 namespace TwinE {
 
@@ -63,35 +62,46 @@ namespace TwinE {
  */
 #define NUM_CD_TRACKS 10
 
-TwinEMidiPlayer::TwinEMidiPlayer() {
+TwinEMidiPlayer::TwinEMidiPlayer(TwinEEngine* engine) : _engine(engine) {
 	MidiPlayer::createDriver();
 
 	int ret = _driver->open();
 	if (ret == 0) {
-		if (_nativeMT32)
+		if (_nativeMT32) {
 			_driver->sendMT32Reset();
-		else
+		} else {
 			_driver->sendGMReset();
+		}
 		_driver->setTimerCallback(this, &timerCallback);
 	}
 }
 
 void TwinEMidiPlayer::play(byte *buf, int size) {
-	MidiParser *parser = MidiParser::createParser_SMF();
-	if (parser->loadMusic(buf, size)) {
-		parser->setTrack(0);
-		parser->setMidiDriver(this);
-		parser->setTimerRate(_driver->getBaseTempo());
-		parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
+	if (_parser == nullptr) {
+		if (_engine->cfgfile.MidiType == MIDIFILE_DOS) {
+			_parser = MidiParser::createParser_XMIDI();
+		} else {
+			_parser = MidiParser::createParser_SMF();
+		}
+	}
 
-		_parser = parser;
+	if (!_parser->loadMusic(buf, size)) {
+		warning("Failed to load midi music");
+		return;
+	}
+	_parser->setTrack(0);
+	_parser->setMidiDriver(this);
+	_parser->setTimerRate(_driver->getBaseTempo());
+	_parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
 
-		syncVolume();
+	syncVolume();
 
-		// All the tracks are supposed to loop
-		_isLooping = true;
-		_isPlaying = true;
-	}
+	// All the tracks are supposed to loop
+	_isLooping = true;
+	_isPlaying = true;
+}
+
+Music::Music(TwinEEngine *engine) : _engine(engine), _midiPlayer(engine) {
 }
 
 void Music::musicVolume(int32 volume) {
@@ -176,14 +186,6 @@ void Music::playMidiMusic(int32 midiIdx, int32 loop) {
 	}
 
 	int32 midiSize = _engine->_hqrdepack->hqrGetallocEntry(&midiPtr, filename, midiIdx);
-
-	if (_engine->cfgfile.MidiType == MIDIFILE_DOS) {
-		uint8 *dos_midi_ptr;
-		midiSize = convert_to_midi(midiPtr, midiSize, &dos_midi_ptr);
-		free(midiPtr);
-		midiPtr = dos_midi_ptr;
-	}
-
 	_midiPlayer.play(midiPtr, midiSize);
 }
 
diff --git a/engines/twine/music.h b/engines/twine/music.h
index 95e193ccc2..35efac4ea1 100644
--- a/engines/twine/music.h
+++ b/engines/twine/music.h
@@ -31,8 +31,10 @@ namespace TwinE {
 class TwinEEngine;
 
 class TwinEMidiPlayer : public Audio::MidiPlayer {
+private:
+	TwinEEngine *_engine;
 public:
-	TwinEMidiPlayer();
+	TwinEMidiPlayer(TwinEEngine *engine);
 	void play(byte *buf, int size);
 };
 
@@ -48,7 +50,7 @@ private:
 	uint8 *midiPtr = nullptr;
 
 public:
-	Music(TwinEEngine *engine) : _engine(engine) {}
+	Music(TwinEEngine *engine);
 	/** Track number of the current playing music */
 	int32 currentMusic = 0;
 
diff --git a/engines/twine/xmidi.cpp b/engines/twine/xmidi.cpp
deleted file mode 100644
index d7bfa22a92..0000000000
--- a/engines/twine/xmidi.cpp
+++ /dev/null
@@ -1,771 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "twine/xmidi.h"
-#include "common/textconsole.h"
-#include "common/util.h"
-#include "twine/twine.h"
-
-namespace TwinE {
-
-/**
- * Provides comprehensive information on the next event in the MIDI stream.
- * An EventInfo struct is instantiated by format-specific implementations
- * of MidiParser::parseNextEvent() each time another event is needed.
- *
- * Adapted from the ScummVM project
- */
-struct EventInfo {
-	uint8 *start; ///< Position in the MIDI stream where the event starts.
-	              ///< For delta-based MIDI streams (e.g. SMF and XMIDI), this points to the delta.
-	uint32 delta; ///< The number of ticks after the previous event that this event should occur.
-	uint8 event;  ///< Upper 4 bits are the command code, lower 4 bits are the MIDI channel.
-	              ///< For META, event == 0xFF. For SysEx, event == 0xF0.
-	union {
-		struct {
-			uint8 param1; ///< The first parameter in a simple MIDI message.
-			uint8 param2; ///< The second parameter in a simple MIDI message.
-		} basic;
-		struct {
-			uint8 type;  ///< For META events, this indicates the META type.
-			uint8 *data; ///< For META and SysEx events, this points to the start of the data.
-		} ext;
-	};
-	uint32 length; ///< For META and SysEx blocks, this indicates the length of the data.
-	               ///< For Note On events, a non-zero value indicates that no Note Off event
-	               ///< will occur, and the MidiParser will have to generate one itself.
-	               ///< For all other events, this value should always be zero.
-};
-
-// Adapted from the ScummVM project
-struct XMIDI_info {
-	uint8 num_tracks;
-	uint8 *tracks[120]; // Maximum 120 tracks
-};
-
-/* Linked list of saved note offs to be injected in the midi stream at a later
- * time. */
-struct CachedEvent {
-	struct EventInfo *eventInfo;
-	uint32 time;
-	struct CachedEvent *next;
-};
-static struct CachedEvent *cached_events = NULL;
-
-/*
- * Forward declarations
- */
-static uint16 read2low(uint8 **data);
-static uint32 read4high(uint8 **data);
-static void write4high(uint8 **data, uint32 val);
-static void write2high(uint8 **data, uint16 val);
-static uint32 readVLQ2(uint8 **data);
-static uint32 readVLQ(uint8 **data);
-static int32 putVLQ(uint8 *dest, uint32 value);
-
-/* Returns an EventInfo struct if there is a cached event that should be
- * played between current_time and current_time + delta. The cached event
- * is removed from the internal list of cached events! */
-static struct EventInfo *pop_cached_event(uint32 current_time, uint32 delta);
-static void save_event(struct EventInfo *info, uint32 current_time);
-
-static int32 read_event_info(uint8 *data, struct EventInfo *info, uint32 current_time);
-static int32 put_event(uint8 *dest, struct EventInfo *info);
-static int32 convert_to_mtrk(uint8 *data, uint32 size, uint8 *dest);
-static int32 read_XMIDI_header(uint8 *data, uint32 size, struct XMIDI_info *info);
-
-// Adapted from the ScummVM project
-static uint16 read2low(uint8 **data) {
-	uint8 *d = *data;
-	uint16 value = (d[1] << 8) | d[0];
-	*data = (d + 2);
-	return value;
-}
-
-// Adapted from the ScummVM project
-static uint32 read4high(uint8 **data) {
-	uint8 *d = *data;
-	uint16 value = (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | (d[3]);
-	*data = (d + 4);
-	return value;
-}
-
-// Adapted from the ScummVM project
-static void write4high(uint8 **data, uint32 val) {
-	uint8 *d = *data;
-	*d++ = (val >> 24) & 0xff;
-	*d++ = (val >> 16) & 0xff;
-	*d++ = (val >> 8) & 0xff;
-	*d++ = val & 0xff;
-	*data = d;
-}
-
-// Adapted from the ScummVM project
-static void write2high(uint8 **data, uint16 val) {
-	uint8 *d = *data;
-	*d++ = (val >> 8) & 0xff;
-	*d++ = val & 0xff;
-	*data = d;
-}
-
-// This is a special XMIDI variable length quantity
-//
-// Adapted from the ScummVM project
-static uint32 readVLQ2(uint8 **data) {
-	uint8 *pos = *data;
-	uint32 value = 0;
-	while (!(pos[0] & 0x80)) {
-		value += *pos++;
-	}
-	*data = pos;
-	return value;
-}
-
-// This is the conventional (i.e. SMF) variable length quantity
-//
-// Adapted from the ScummVM project
-static uint32 readVLQ(uint8 **data) {
-	uint8 *d = *data;
-	uint8 str;
-	uint32 value = 0;
-	int32 i;
-
-	for (i = 0; i < 4; ++i) {
-		str = *d++;
-		value = (value << 7) | (str & 0x7F);
-		if (!(str & 0x80))
-			break;
-	}
-	*data = d;
-	return value;
-}
-
-// PutVLQ
-//
-// Write a Conventional Variable Length Quantity
-//
-// Code adapted from the Exult engine
-static int32 putVLQ(uint8 *dest, uint32 value) {
-	int32 buffer;
-	int32 j, i = 1;
-
-	buffer = value & 0x7F;
-	while (value >>= 7) {
-		buffer <<= 8;
-		buffer |= ((value & 0x7F) | 0x80);
-		i++;
-	}
-	if (!dest)
-		return i;
-	for (j = 0; j < i; j++) {
-		*dest++ = buffer & 0xFF;
-		buffer >>= 8;
-	}
-	return i;
-}
-
-static void save_event(struct EventInfo *info, uint32 current_time) {
-	uint32 delta = info->length;
-	struct CachedEvent *prev, *next, *temp;
-
-	temp = (struct CachedEvent *)malloc(sizeof(struct CachedEvent));
-	if (!temp) {
-		error("Failed to allocate memory for the midi buffer");
-	}
-	temp->eventInfo = info;
-	temp->time = current_time + delta;
-	temp->next = NULL;
-
-	//info("Saving event to be stopped at %2X", temp->time);
-
-	if (!cached_events) {
-		cached_events = temp;
-	} else {
-		prev = NULL;
-		next = cached_events;
-
-		/* Find the proper time slot */
-		while (next && next->time < current_time + delta) {
-			prev = next;
-			next = next->next;
-		}
-
-		if (!next) {
-			prev->next = temp;
-		} else {
-			if (prev) {
-				temp->next = prev->next;
-				prev->next = temp;
-			} else {
-				temp->next = cached_events;
-				cached_events = temp;
-			}
-		}
-	}
-}
-
-static struct EventInfo *pop_cached_event(uint32 current_time, uint32 delta) {
-	struct EventInfo *info = NULL;
-	struct CachedEvent *old;
-
-	if (cached_events && cached_events->time < current_time + delta) {
-		info = cached_events->eventInfo;
-		info->delta = cached_events->time - current_time;
-		old = cached_events;
-		cached_events = cached_events->next;
-		free(old);
-	}
-
-	return info;
-}
-
-// Adapted from the ScummVM project
-static int32 read_event_info(uint8 *data, struct EventInfo *info, uint32 current_time) {
-	struct EventInfo *injectedEvent;
-	info->start = data;
-	info->delta = readVLQ2(&data);
-	info->event = *data++;
-
-	/* Advance current time here, but not yet in the main conversion loop.
-	 * This is so that cached events can still be injected correctly */
-	current_time += info->delta;
-
-	//info("%02X: Parsing event %02X", current_time, info->event);
-	switch (info->event >> 4) {
-	case 0x9: // Note On
-		info->basic.param1 = *(data++);
-		info->basic.param2 = *(data++);
-		info->length = readVLQ(&data);
-		if (info->basic.param2 == 0) {
-			info->event = (info->event & 0x0F) | 0x80;
-			info->length = 0;
-		} else {
-			//info("Found Note On with duration %X. Saving a Note Off for later", info->length);
-			injectedEvent = (struct EventInfo *)malloc(sizeof(struct EventInfo));
-			if (!injectedEvent) {
-				error("Could not allocate memory for event info");
-			}
-			injectedEvent->event = 0x80 | (info->event & 0x0f);
-			injectedEvent->basic.param1 = info->basic.param1;
-			injectedEvent->basic.param2 = info->basic.param2;
-			injectedEvent->length = info->length;
-			save_event(injectedEvent, current_time);
-		}
-		break;
-
-	case 0xC:
-	case 0xD:
-		info->basic.param1 = *(data++);
-		info->basic.param2 = 0;
-		break;
-
-	case 0x8:
-	case 0xA:
-	case 0xE:
-		info->basic.param1 = *(data++);
-		info->basic.param2 = *(data++);
-		break;
-
-	case 0xB:
-		info->basic.param1 = *(data++);
-		info->basic.param2 = *(data++);
-
-		// This isn't a full XMIDI implementation, but it should
-		// hopefully be "good enough" for most things.
-
-		switch (info->basic.param1) {
-		// Simplified XMIDI looping.
-		case 0x74: { // XMIDI_CONTROLLER_FOR_LOOP
-#if 0                // TODO
-				uint8 *pos = data;
-				if (_loopCount < ARRAYSIZE(_loop) - 1)
-					_loopCount++;
-				/*else
-					warning("XMIDI: Exceeding maximum loop count %d", ARRAYSIZE(_loop));*/
-
-				_loop[_loopCount].pos = pos;
-				_loop[_loopCount].repeat = info->basic.param2;
-#endif
-			break;
-		}
-
-		case 0x75: // XMIDI_CONTORLLER_NEXT_BREAK
-#if 0              // TODO
-			if (_loopCount >= 0) {
-				if (info->basic.param2 < 64) {
-					// End the current loop.
-					_loopCount--;
-				} else {
-					// Repeat 0 means "loop forever".
-					if (_loop[_loopCount].repeat) {
-						if (--_loop[_loopCount].repeat == 0)
-							_loopCount--;
-						else
-							data = _loop[_loopCount].pos;
-					} else {
-						data = _loop[_loopCount].pos;
-					}
-				}
-			}
-#endif
-			break;
-
-		case 0x77: // XMIDI_CONTROLLER_CALLBACK_TRIG
-#if 0              // TODO
-			if (_callbackProc)
-				_callbackProc(info->basic.param2, _callbackData);
-#endif
-			break;
-
-		case 0x6e: // XMIDI_CONTROLLER_CHAN_LOCK
-		case 0x6f: // XMIDI_CONTROLLER_CHAN_LOCK_PROT
-		case 0x70: // XMIDI_CONTROLLER_VOICE_PROT
-		case 0x71: // XMIDI_CONTROLLER_TIMBRE_PROT
-		case 0x72: // XMIDI_CONTROLLER_BANK_CHANGE
-		case 0x73: // XMIDI_CONTROLLER_IND_CTRL_PREFIX
-		case 0x76: // XMIDI_CONTROLLER_CLEAR_BB_COUNT
-		case 0x78: // XMIDI_CONTROLLER_SEQ_BRANCH_INDEX
-		default:
-			if (info->basic.param1 >= 0x6e && info->basic.param1 <= 0x78) {
-				/*warning("Unsupported XMIDI controller %d (0x%2x)",
-					info->basic.param1, info->basic.param1);*/
-			}
-		}
-
-		// Should we really keep passing the XMIDI controller events to
-		// the MIDI driver, or should we turn them into some kind of
-		// NOP events? (Dummy meta events, perhaps?) Ah well, it has
-		// worked so far, so it shouldn't cause any damage...
-
-		break;
-
-	case 0xF: // Meta or SysEx event
-		switch (info->event & 0x0F) {
-		case 0x2: // Song Position Pointer
-			info->basic.param1 = *(data++);
-			info->basic.param2 = *(data++);
-			break;
-
-		case 0x3: // Song Select
-			info->basic.param1 = *(data++);
-			info->basic.param2 = 0;
-			break;
-
-		case 0x6:
-		case 0x8:
-		case 0xA:
-		case 0xB:
-		case 0xC:
-		case 0xE:
-			info->basic.param1 = info->basic.param2 = 0;
-			break;
-
-		case 0x0: // SysEx
-			info->length = readVLQ(&data);
-			info->ext.data = data;
-			data += info->length;
-			break;
-
-		case 0xF: // META event
-			info->ext.type = *(data++);
-			info->length = readVLQ(&data);
-			info->ext.data = data;
-			data += info->length;
-			if (info->ext.type == 0x51 && info->length == 3) {
-				// Tempo event. We want to make these constant 500,000.
-				info->ext.data[0] = 0x07;
-				info->ext.data[1] = 0xA1;
-				info->ext.data[2] = 0x20;
-			}
-			break;
-
-		default:
-			//warning("MidiParser_XMIDI::parseNextEvent: Unsupported event code %x (delta: %X)", info->event, info->delta);
-			return 0;
-		}
-	}
-
-	return (data - info->start);
-}
-
-// Code adapted from the Exult engine
-static int32 put_event(uint8 *dest, struct EventInfo *info) {
-	int32 i = 0, j;
-	int32 rc = 0;
-	static uint8 last_event = 0;
-
-	rc = putVLQ(dest, info->delta);
-	if (dest)
-		dest += rc;
-	i += rc;
-
-	if ((info->event != last_event) || (info->event >= 0xF0)) {
-		if (dest)
-			*dest++ = (info->event);
-		i++;
-	}
-
-	last_event = info->event;
-
-	switch (info->event >> 4) {
-	// 2 bytes data
-	// Note off, Note on, Aftertouch, Controller and Pitch Wheel
-	case 0x8:
-	case 0x9:
-	case 0xA:
-	case 0xB:
-	case 0xE:
-		if (dest) {
-			*dest++ = (info->basic.param1);
-			*dest++ = (info->basic.param2);
-		}
-		i += 2;
-		break;
-
-	// 1 bytes data
-	// Program Change and Channel Pressure
-	case 0xC:
-	case 0xD:
-		if (dest)
-			*dest++ = (info->basic.param1);
-		i++;
-		break;
-
-	// Variable length
-	// SysEx
-	case 0xF:
-		if (info->event == 0xFF) {
-			if (dest)
-				*dest++ = (info->basic.param1);
-			i++;
-		}
-
-		rc = putVLQ(dest, info->length);
-		if (dest)
-			dest += rc;
-		i += rc;
-
-		if (info->length) {
-			for (j = 0; j < (int)info->length; j++) {
-				if (dest)
-					*dest++ = (info->ext.data[j]);
-				i++;
-			}
-		}
-
-		break;
-
-	// Never occur
-	default:
-		//warning("Not supposed to see this");
-		break;
-	}
-
-	return i;
-}
-
-// Code adapted from the Exult engine
-static int32 convert_to_mtrk(uint8 *data, uint32 size, uint8 *dest) {
-	int32 time = 0;
-	int32 lasttime = 0;
-	int32 rc;
-	uint32 i = 8;
-	uint8 *size_pos = NULL;
-	uint8 *data_end = data + size;
-	struct XMIDI_info xmidi_info;
-	struct EventInfo info;
-	struct EventInfo *cached_info;
-
-	if (dest) {
-		*dest++ = ('M');
-		*dest++ = ('T');
-		*dest++ = ('r');
-		*dest++ = ('k');
-
-		size_pos = dest;
-		dest += 4;
-	}
-
-	rc = read_XMIDI_header(data, size, &xmidi_info);
-	if (!rc) {
-		//warning("Failed to read XMIDI header");
-		return 0;
-	}
-
-	data = xmidi_info.tracks[0];
-
-	while (data < data_end) {
-		//info("=======================================================================");
-		// We don't write the end of stream marker here, we'll do it later
-		if (data[0] == 0xFF && data[1] == 0x2f) {
-			//info("Got EOX");
-			//			lasttime = event->time;
-			continue;
-		}
-
-		rc = read_event_info(data, &info, time);
-		if (!rc) {
-			//warning("Failed to read event info %ld bytes from the end!", data_end - data);
-			return 0;
-		}
-		data += rc;
-
-		cached_info = pop_cached_event(time, info.delta);
-		while (cached_info) {
-			//info("Injecting event %2X at time %2X", cached_info->event, time);
-			rc = put_event(dest, cached_info);
-			if (!rc) {
-				//warning("Failed to save injected event!");
-				return 0;
-			}
-			if (dest)
-				dest += rc;
-			i += rc;
-			time += cached_info->delta;
-			info.delta -= cached_info->delta;
-			free(cached_info);
-			cached_info = pop_cached_event(time, info.delta);
-		}
-
-		//info("Saving event %02X", info.event);
-		rc = put_event(dest, &info);
-		if (!rc) {
-			//warning("Failed to save event!");
-			return 0;
-		}
-		if (dest)
-			dest += rc;
-		i += rc;
-		time += info.delta;
-		if (info.event == 0xFF && info.ext.type == 0x2F) {
-			//info("GOT EOX");
-			data = data_end;
-		}
-	}
-
-	// Write out end of stream marker
-	if (lasttime > time) {
-		rc = putVLQ(dest, lasttime - time);
-		if (dest)
-			dest += rc;
-		i += rc;
-	} else {
-		rc = putVLQ(dest, 0);
-		if (dest)
-			dest += rc;
-		i += rc;
-	}
-	if (dest) {
-		*dest++ = (0xFF);
-		*dest++ = (0x2F);
-	}
-	rc = putVLQ(dest, 0);
-	i += 2 + rc;
-
-	if (dest) {
-		dest += rc;
-		write4high(&size_pos, i - 8);
-	}
-	return i;
-}
-
-/* Code adapted from the ScummVM project, which originally adapted it from the
- * Exult engine */
-static int32 read_XMIDI_header(uint8 *data, uint32 size, struct XMIDI_info *info) {
-	uint32 i = 0;
-	uint8 *start;
-	uint32 len;
-	uint32 chunkLen;
-	char buf[32];
-	uint8 *pos = data;
-	int32 tracksRead = 0;
-
-	if (!memcmp(pos, "FORM", 4)) {
-		pos += 4;
-
-		// Read length of
-		len = read4high(&pos);
-		start = pos;
-
-		// XDIRless XMIDI, we can handle them here.
-		if (!memcmp(pos, "XMID", 4)) {
-			//warning("XMIDI doesn't have XDIR");
-			pos += 4;
-			info->num_tracks = 1;
-		} else if (memcmp(pos, "XDIR", 4) != 0) {
-			// Not an XMIDI that we recognize
-			//warning("Expected 'XDIR' but found '%c%c%c%c'", pos[0], pos[1], pos[2], pos[3]);
-			return 0;
-		} else {
-			// Seems Valid
-			pos += 4;
-			info->num_tracks = 0;
-
-			for (i = 4; i < len; i++) {
-				// Read 4 bytes of type
-				memcpy(buf, pos, 4);
-				pos += 4;
-
-				// Read length of chunk
-				chunkLen = read4high(&pos);
-
-				// Add eight bytes
-				i += 8;
-
-				if (memcmp(buf, "INFO", 4) == 0) {
-					// Must be at least 2 bytes long
-					if (chunkLen < 2) {
-						//warning("Invalid chunk length %d for 'INFO' block", (int)chunkLen);
-						return 0;
-					}
-
-					info->num_tracks = (uint8)read2low(&pos);
-					pos += 2;
-
-					if (chunkLen > 2) {
-						//warning("Chunk length %d is greater than 2", (int)chunkLen);
-						//pos += chunkLen - 2;
-					}
-					break;
-				}
-
-				// Must align
-				pos += (chunkLen + 1) & ~1;
-				i += (chunkLen + 1) & ~1;
-			}
-
-			// Didn't get to fill the header
-			if (info->num_tracks == 0) {
-				//warning("Didn't find a valid track count");
-				return 0;
-			}
-
-			// Ok now to start part 2
-			// Goto the right place
-			pos = start + ((len + 1) & ~1);
-
-			if (memcmp(pos, "CAT ", 4) != 0) {
-				// Not an XMID
-				//warning("Expected 'CAT ' but found '%c%c%c%c'", pos[0], pos[1], pos[2], pos[3]);
-				return 0;
-			}
-			pos += 4;
-
-			// Now read length of this track
-			len = read4high(&pos);
-
-			if (memcmp(pos, "XMID", 4) != 0) {
-				// Not an XMID
-				//warning("Expected 'XMID' but found '%c%c%c%c'", pos[0], pos[1], pos[2], pos[3]);
-				return 0;
-			}
-			pos += 4;
-		}
-
-		// Ok it's an XMIDI.
-		// We're going to identify and store the location for each track.
-		if (info->num_tracks > ARRAYSIZE(info->tracks)) {
-			//warning("Can only handle %d tracks but was handed %d", (int)ARRAYSIZE(info->tracks), (int)info->num_tracks);
-			return 0;
-		}
-
-		while (tracksRead < info->num_tracks) {
-			if (!memcmp(pos, "FORM", 4)) {
-				// Skip this plus the 4 bytes after it.
-				pos += 8;
-			} else if (!memcmp(pos, "XMID", 4)) {
-				// Skip this.
-				pos += 4;
-			} else if (!memcmp(pos, "TIMB", 4)) {
-				// Custom timbres?
-				// We don't support them.
-				// Read the length, skip it, and hope there was nothing there.
-				pos += 4;
-				len = read4high(&pos);
-				pos += (len + 1) & ~1;
-			} else if (!memcmp(pos, "EVNT", 4)) {
-				// Ahh! What we're looking for at last.
-				info->tracks[tracksRead] = pos + 8; // Skip the EVNT and length bytes
-				pos += 4;
-				len = read4high(&pos);
-				pos += (len + 1) & ~1;
-				++tracksRead;
-			} else {
-				//warning("Hit invalid block '%c%c%c%c' while scanning for track locations", pos[0], pos[1], pos[2], pos[3]);
-				return 0;
-			}
-		}
-
-		return 1;
-	}
-
-	return 0;
-}
-
-/********************************* Public API *********************************/
-// Code adapted from the Exult engine
-uint32 convert_to_midi(uint8 *data, uint32 size, uint8 **dest) {
-	int32 len;
-	uint8 *d, *start;
-
-	if (!dest)
-		return 0;
-
-	/* Do a dry run first so we know how much memory to allocate */
-	len = convert_to_mtrk(data, size, NULL);
-	if (!len) {
-		//warning("Failed dummy conversion!");
-		return 0;
-	}
-
-	//info("Allocating %d bytes of memory", len);
-	d = (uint8 *)malloc(len + 14);
-	if (!d) {
-		perror("Could not allocate memory");
-		return 0;
-	}
-	start = d;
-
-	*d++ = ('M');
-	*d++ = ('T');
-	*d++ = ('h');
-	*d++ = ('d');
-
-	write4high(&d, 6);
-
-	write2high(&d, 0);
-	write2high(&d, 1);
-	write2high(&d, 60); // The PPQN
-
-	len = convert_to_mtrk(data, size, d);
-	if (!len) {
-		//warning("Failed to convert");
-		free(d);
-		return 0;
-	}
-
-	*dest = start;
-
-	return len + 14;
-}
-
-} // namespace TwinE
diff --git a/engines/twine/xmidi.h b/engines/twine/xmidi.h
deleted file mode 100644
index f8f31c640f..0000000000
--- a/engines/twine/xmidi.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TWINE_XMIDI_H
-#define TWINE_XMIDI_H
-
-#include "common/scummsys.h"
-
-namespace TwinE {
-
-/**
- * Credit where credit is due:
- * Most of code to convert XMIDI to MIDI is adapted from either the ScummVM
- * project or the Exult game engine.
- * //risca
- */
-
-// TODO: use MidiParser_XMIDI
-
-/*
- * Takes a pointer to XMIDI data of size 'size' and converts it to MIDI. The
- * result is allocated dynamically and saved to the 'dest' pointer. Returns
- * the size of the MIDI data or 0 on error.
- */
-uint32 convert_to_midi(uint8 *data, uint32 size, uint8 **dest);
-
-} // namespace TwinE
-
-#endif // XMIDI_H


Commit: 55e82d6c0ffddb81e326d155da8a234a7f16495e
    https://github.com/scummvm/scummvm/commit/55e82d6c0ffddb81e326d155da8a234a7f16495e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-25T16:57:27+01:00

Commit Message:
TWINE: prepare for lba2

Changed paths:
    engines/twine/detection.cpp
    engines/twine/detection.h
    engines/twine/metaengine.cpp
    engines/twine/twine.h


diff --git a/engines/twine/detection.cpp b/engines/twine/detection.cpp
index a20a106c94..e61c0f3b28 100644
--- a/engines/twine/detection.cpp
+++ b/engines/twine/detection.cpp
@@ -27,7 +27,8 @@
 #include "twine/detection.h"
 
 static const PlainGameDescriptor twineGames[] = {
-	{ "twine", "Little Big Adventure" },
+	{ "lba", "Little Big Adventure" },
+	{ "lba2", "Little Big Adventure 2" },
 	{ nullptr,  nullptr }
 };
 
diff --git a/engines/twine/detection.h b/engines/twine/detection.h
index f76f115396..5fb93b1ac3 100644
--- a/engines/twine/detection.h
+++ b/engines/twine/detection.h
@@ -25,6 +25,11 @@
 
 namespace TwinE {
 
+enum TwineGameType {
+	GType_LBA = (1 << 1),
+	GType_LBA2 = (1 << 2)
+};
+
 } // End of namespace TwinE
 
 #endif // TWINE_DETECTION_H
diff --git a/engines/twine/metaengine.cpp b/engines/twine/metaengine.cpp
index 0b6179acc4..41dfb91418 100644
--- a/engines/twine/metaengine.cpp
+++ b/engines/twine/metaengine.cpp
@@ -28,6 +28,7 @@
 #include "common/system.h"
 #include "common/translation.h"
 #include "engines/advancedDetector.h"
+#include "twine/detection.h"
 
 #include "twine/input.h"
 #include "twine/twine.h"
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 5f41bafc5a..4d29479a34 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -32,6 +32,7 @@
 #include "graphics/surface.h"
 #include "twine/actor.h"
 #include "twine/input.h"
+#include "twine/detection.h"
 
 namespace TwinE {
 
@@ -165,6 +166,9 @@ public:
 	Common::Error run() override;
 	bool hasFeature(EngineFeature f) const override;
 
+	bool isLBA1() const { return _gameFlags & TwineGameType::GType_LBA;};
+	bool isLBA2() const { return _gameFlags & TwineGameType::GType_LBA2;};
+
 	Actor *_actor;
 	Animations *_animations;
 	Collision *_collision;


Commit: 95516fd446aadb608b856d9c3412627a4440aff2
    https://github.com/scummvm/scummvm/commit/95516fd446aadb608b856d9c3412627a4440aff2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-10-25T16:58:23+01:00

Commit Message:
TWINE: renamed sub-engine from twine to lba to also support lba2

Changed paths:
    engines/twine/detection.cpp


diff --git a/engines/twine/detection.cpp b/engines/twine/detection.cpp
index e61c0f3b28..cca4caf114 100644
--- a/engines/twine/detection.cpp
+++ b/engines/twine/detection.cpp
@@ -37,7 +37,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// LBA.EXE
 	// 8 August 1994 at 19:30
 	{
-		"twine",
+		"lba",
 		"Preview Version",
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 294025),
 		Common::EN_ANY,
@@ -46,7 +46,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Preview Version",
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 294025),
 		Common::FR_FRA,
@@ -59,7 +59,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// RELENT.EXE
 	// 14 October 1994 at 10:18
 	{
-		"twine",
+		"lba",
 		"Demo Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::EN_ANY,
@@ -68,7 +68,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Demo Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::FR_FRA,
@@ -77,7 +77,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Demo Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::DE_DEU,
@@ -86,7 +86,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Demo Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::IT_ITA,
@@ -95,7 +95,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Demo Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::ES_ESP,
@@ -108,7 +108,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// LBA.EXE
 	// 14 Oct 1994 at 12:45
 	{
-		"twine",
+		"lba",
 		"CD Original European Version",
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::EN_ANY,
@@ -117,7 +117,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"CD Original European Version",
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::FR_FRA,
@@ -126,7 +126,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"CD Original European Version",
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::DE_DEU,
@@ -135,7 +135,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"CD Original European Version",
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::IT_ITA,
@@ -144,7 +144,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"CD Original European Version",
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::ES_ESP,
@@ -157,7 +157,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// RELENT.EXE
 	// 14 Oct 1994 at 13:22
 	{
-		"twine",
+		"lba",
 		"Relentless: Twinsen's Adventure - CD Original North America Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::EN_ANY,
@@ -166,7 +166,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Relentless: Twinsen's Adventure - CD Original North America Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::FR_FRA,
@@ -175,7 +175,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Relentless: Twinsen's Adventure - CD Original North America Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::DE_DEU,
@@ -184,7 +184,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Relentless: Twinsen's Adventure - CD Original North America Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::IT_ITA,
@@ -193,7 +193,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"Relentless: Twinsen's Adventure - CD Original North America Version",
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::ES_ESP,
@@ -206,7 +206,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// FLA_GIF.HQR
 	// 11 August 1995 at 23:28
 	{
-		"twine",
+		"lba",
 		"Floppy Disk Version",
 		AD_ENTRY1s("FLA_GIF.HQR", "3f7383f65afa212e3eec430627828b64", 1784466),
 		Common::EN_ANY,
@@ -219,7 +219,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// LBAJ.EXE
 	// 15 Oct 1995 at 13:28
 	{
-		"twine",
+		"lba",
 		"Original Japanese Version",
 		AD_ENTRY1s("LBAJ.EXE", "54a1e8749448e08086a1929510ec4b6a", 278043),
 		Common::JA_JPN,
@@ -232,7 +232,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// LBA.DOT
 	// 11 October 2011 at 17:30
 	{
-		"twine",
+		"lba",
 		"DotEmu Version (Steam)",
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::EN_ANY,
@@ -241,7 +241,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"DotEmu Version (Steam)",
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::FR_FRA,
@@ -250,7 +250,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"DotEmu Version (Steam)",
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::DE_DEU,
@@ -259,7 +259,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"DotEmu Version (Steam)",
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::IT_ITA,
@@ -268,7 +268,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"DotEmu Version (Steam)",
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::ES_ESP,
@@ -281,7 +281,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// LBA.exe
 	// 27 February 2018 at 08:10
 	{
-		"twine",
+		"lba",
 		"DotEmu Enhanced Version (Steam)",
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::EN_ANY,
@@ -290,7 +290,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"DotEmu Enhanced Version (Steam)",
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::FR_FRA,
@@ -299,7 +299,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"DotEmu Enhanced Version (Steam)",
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::DE_DEU,
@@ -308,7 +308,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"DotEmu Enhanced Version (Steam)",
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::IT_ITA,
@@ -317,7 +317,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"DotEmu Enhanced Version (Steam)",
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::ES_ESP,
@@ -330,7 +330,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 	// LBA.GOG
 	// 11 October 2011 at 17:30
 	{
-		"twine",
+		"lba",
 		"GOG Version",
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::EN_ANY,
@@ -339,7 +339,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"GOG Version",
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::FR_FRA,
@@ -348,7 +348,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"GOG Version",
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::DE_DEU,
@@ -357,7 +357,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"GOG Version",
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::IT_ITA,
@@ -366,7 +366,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 	{
-		"twine",
+		"lba",
 		"GOG Version",
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::ES_ESP,
@@ -379,7 +379,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 
 	// Portuguese by xesf (alexfont)
 	{
-		"twine",
+		"lba",
 		"Fan Translation by xesf",
 		AD_ENTRY1s("TEXT.HQR", "2a8df71946aa9ee4c777a9d6414b89ce", 282308),
 		Common::PT_POR,
@@ -390,7 +390,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 
 	// Polish by Zink
 	{
-		"twine",
+		"lba",
 		"Fan Translation by Zink",
 		AD_ENTRY1s("text.hqr", "7f41b5e8efb07dd413f59377e03b1b04", 413920),
 		Common::PL_POL,
@@ -401,7 +401,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 
 	// Hungarian by Gregorius
 	{
-		"twine",
+		"lba",
 		"Fan Translation by Gregorius",
 		AD_ENTRY1s("TEXT.HQR", "31d760b41a424ec2926f494d7ecac14a", 410709),
 		Common::HU_HUN,
@@ -412,7 +412,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 
 	// Hebrew by ChaosFish
 	{
-		"twine",
+		"lba",
 		"Fan Translation by ChaosFish",
 		AD_ENTRY1s("TEXT.HQR", "c1adf48ea71fead82d91c5b062eeeb99", 75866),
 		Common::HE_ISR,
@@ -423,7 +423,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 
 	// Brazilian Portuguese by spider_ruler33
 	{
-		"twine",
+		"lba",
 		"Fan Translation by spider_ruler33",
 		AD_ENTRY1s("TEXT.HQR", "2bf227f9e8fcdc7397372b68786c446e", 283631),
 		Common::PT_BRA,
@@ -434,7 +434,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 
 	// Russian by Cody
 	{
-		"twine",
+		"lba",
 		"Fan Translation by Cody",
 		AD_ENTRY1s("TEXT.HQR", "93b1a29711f0750156280012e53fdcd2", 280306),
 		Common::RU_RUS,




More information about the Scummvm-git-logs mailing list