[Scummvm-git-logs] scummvm master -> 5b0938b0a7e39145baad79a2b75c99c4d75d385b

mgerhardy martin.gerhardy at gmail.com
Wed Jan 27 18:29:09 UTC 2021


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

Summary:
9f4d5809d4 TWINE: added constants
337b1ca353 TWINE: replaced magic numbers
5b0938b0a7 TWINE: fixed magic ball throwing input issue


Commit: 9f4d5809d427a6eaa61278d2c022a3b45bf191ef
    https://github.com/scummvm/scummvm/commit/9f4d5809d427a6eaa61278d2c022a3b45bf191ef
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-01-27T19:27:44+01:00

Commit Message:
TWINE: added constants

Changed paths:
    engines/twine/scene/actor.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/animations.cpp
    engines/twine/scene/collision.cpp
    engines/twine/scene/movements.cpp
    engines/twine/scene/scene.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index fb16abb826..2bb54773c4 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -422,9 +422,9 @@ void Actor::hitActor(int32 actorIdx, int32 actorIdxAttacked, int32 strengthOfHit
 			}
 
 			if (_engine->getRandomNumber() & 1) {
-				_engine->_animations->initAnim(AnimationTypes::kHit2, 3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
+				_engine->_animations->initAnim(AnimationTypes::kHit2, kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
 			} else {
-				_engine->_animations->initAnim(AnimationTypes::kBigHit, 3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
+				_engine->_animations->initAnim(AnimationTypes::kBigHit, kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
 			}
 		}
 
@@ -440,7 +440,7 @@ void Actor::hitActor(int32 actorIdx, int32 actorIdxAttacked, int32 strengthOfHit
 			actor->life = 0;
 		}
 	} else {
-		_engine->_animations->initAnim(AnimationTypes::kHit, 3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
+		_engine->_animations->initAnim(AnimationTypes::kHit, kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
 	}
 }
 
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 0249944ace..036c16b05c 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -141,6 +141,10 @@ struct BonusParameter {
 };
 
 #define kAnimationTypeLoop 0
+#define kAnimationType_1 1
+#define kAnimationType_2 2
+#define kAnimationType_3 3
+#define kAnimationType_4 4
 
 /**
  * Actors structure
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index f673f5b761..e805505b02 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -759,7 +759,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 			if (_engine->_renderer->destX >= 0 && _engine->_renderer->destZ >= 0 && _engine->_renderer->destX <= 0x7E00 && _engine->_renderer->destZ <= 0x7E00) {
 				if (_engine->_grid->getBrickShape(_engine->_renderer->destX, _engine->_movements->processActorY + BRICK_HEIGHT, _engine->_renderer->destZ) != ShapeType::kNone && _engine->cfgfile.WallCollision) { // avoid wall hit damage
 					_engine->_extra->addExtraSpecial(actor->x, actor->y + 1000, actor->z, ExtraSpecialType::kHitStars);
-					initAnim(AnimationTypes::kBigHit, 2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
+					initAnim(AnimationTypes::kBigHit, kAnimationType_2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
 
 					if (IS_HERO(currentlyProcessedActorIdx)) {
 						_engine->_movements->heroMoved = true;
@@ -781,7 +781,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 				} else {
 					if (IS_HERO(actorIdx) && _engine->_actor->heroBehaviour == HeroBehaviourType::kAthletic && actor->anim == AnimationTypes::kForward && _engine->cfgfile.WallCollision) { // avoid wall hit damage
 						_engine->_extra->addExtraSpecial(actor->x, actor->y + 1000, actor->z, ExtraSpecialType::kHitStars);
-						initAnim(AnimationTypes::kBigHit, 2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
+						initAnim(AnimationTypes::kBigHit, kAnimationType_2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
 						_engine->_movements->heroMoved = true;
 						actor->life--;
 					}
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index f7d67ffa0a..702a2dadfc 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -453,16 +453,16 @@ void Collision::stopFalling() { // ReceptionObj()
 		if (fall >= BRICK_HEIGHT * 8) {
 			_engine->_extra->addExtraSpecial(_engine->_actor->processActorPtr->x, _engine->_actor->processActorPtr->y + 1000, _engine->_actor->processActorPtr->z, ExtraSpecialType::kHitStars);
 			_engine->_actor->processActorPtr->life--;
-			_engine->_animations->initAnim(AnimationTypes::kLandingHit, 2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
+			_engine->_animations->initAnim(AnimationTypes::kLandingHit, kAnimationType_2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
 		} else if (fall > 10) {
-			_engine->_animations->initAnim(AnimationTypes::kLanding, 2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
+			_engine->_animations->initAnim(AnimationTypes::kLanding, kAnimationType_2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
 		} else {
 			_engine->_animations->initAnim(AnimationTypes::kStanding, kAnimationTypeLoop, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
 		}
 
 		_engine->_scene->heroYBeforeFall = 0;
 	} else {
-		_engine->_animations->initAnim(AnimationTypes::kLanding, 2, _engine->_actor->processActorPtr->animExtra, _engine->_animations->currentlyProcessedActorIdx);
+		_engine->_animations->initAnim(AnimationTypes::kLanding, kAnimationType_2, _engine->_actor->processActorPtr->animExtra, _engine->_animations->currentlyProcessedActorIdx);
 	}
 
 	_engine->_actor->processActorPtr->dynamicFlags.bIsFalling = 0;
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index 8068d50762..ede12a354d 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -224,7 +224,7 @@ bool Movements::processBehaviourExecution(int actorIdx) {
 		executeAction = true;
 		break;
 	case HeroBehaviourType::kAthletic:
-		_engine->_animations->initAnim(AnimationTypes::kJump, 1, AnimationTypes::kStanding, actorIdx);
+		_engine->_animations->initAnim(AnimationTypes::kJump, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 		break;
 	case HeroBehaviourType::kAggressive:
 		if (_engine->_actor->autoAggressive) {
@@ -237,23 +237,23 @@ bool Movements::processBehaviourExecution(int actorIdx) {
 
 				switch (aggresiveMode) {
 				case 0:
-					_engine->_animations->initAnim(AnimationTypes::kKick, 1, AnimationTypes::kStanding, actorIdx);
+					_engine->_animations->initAnim(AnimationTypes::kKick, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 					break;
 				case 1:
-					_engine->_animations->initAnim(AnimationTypes::kRightPunch, 1, AnimationTypes::kStanding, actorIdx);
+					_engine->_animations->initAnim(AnimationTypes::kRightPunch, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 					break;
 				case 2:
-					_engine->_animations->initAnim(AnimationTypes::kLeftPunch, 1, AnimationTypes::kStanding, actorIdx);
+					_engine->_animations->initAnim(AnimationTypes::kLeftPunch, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 					break;
 				}
 			}
 		} else {
 			if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
-				_engine->_animations->initAnim(AnimationTypes::kLeftPunch, 1, AnimationTypes::kStanding, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kLeftPunch, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 			} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
-				_engine->_animations->initAnim(AnimationTypes::kRightPunch, 1, AnimationTypes::kStanding, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kRightPunch, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 			} else if (_engine->_input->isActionActive(TwinEActionType::MoveForward)) {
-				_engine->_animations->initAnim(AnimationTypes::kKick, 1, AnimationTypes::kStanding, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kKick, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 			}
 		}
 		break;
@@ -271,7 +271,7 @@ bool Movements::processAttackExecution(int actorIdx) {
 	if (!_engine->_gameState->usingSabre) { // Use Magic Ball
 		if (_engine->_gameState->hasItem(InventoryItems::kiMagicBall)) {
 			if (_engine->_gameState->magicBallIdx == -1) {
-				_engine->_animations->initAnim(AnimationTypes::kThrowBall, 1, AnimationTypes::kStanding, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kThrowBall, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 			}
 
 			actor->angle = actor->move.getRealAngle(_engine->lbaTime);
@@ -282,7 +282,7 @@ bool Movements::processAttackExecution(int actorIdx) {
 			_engine->_actor->initModelActor(InventoryItems::kiUseSabre, actorIdx);
 		}
 
-		_engine->_animations->initAnim(AnimationTypes::kSabreAttack, 1, AnimationTypes::kStanding, actorIdx);
+		_engine->_animations->initAnim(AnimationTypes::kSabreAttack, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
 
 		actor->angle = actor->move.getRealAngle(_engine->lbaTime);
 		return true;
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index f80d1a94bf..91ad8d56c9 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -525,7 +525,7 @@ void Scene::processActorZones(int32 actorIdx) {
 				break;
 			case ZoneType::kObject:
 				if (IS_HERO(actorIdx) && _engine->_movements->shouldTriggerZoneAction()) {
-					_engine->_animations->initAnim(AnimationTypes::kAction, 1, AnimationTypes::kStanding, 0);
+					_engine->_animations->initAnim(AnimationTypes::kAction, kAnimationType_1, AnimationTypes::kStanding, 0);
 					processZoneExtraBonus(zone);
 				}
 				break;
@@ -549,7 +549,7 @@ void Scene::processActorZones(int32 actorIdx) {
 						if (_engine->_grid->getBrickShape(_engine->_renderer->destX, actor->y + ANGLE_90, _engine->_renderer->destZ) != ShapeType::kNone) {
 							currentActorInZone = true;
 							if (actor->y >= ABS(zone->bottomLeft.y + zone->topRight.y) / 2) {
-								_engine->_animations->initAnim(AnimationTypes::kTopLadder, 2, AnimationTypes::kStanding, actorIdx); // reached end of ladder
+								_engine->_animations->initAnim(AnimationTypes::kTopLadder, kAnimationType_2, AnimationTypes::kStanding, actorIdx); // reached end of ladder
 							} else {
 								_engine->_animations->initAnim(AnimationTypes::kClimbLadder, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx); // go up in ladder
 							}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index fc08c4337c..a9909692ff 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -606,7 +606,7 @@ void TwinEEngine::processInventoryAction() {
 				_actor->setBehaviour(HeroBehaviourType::kNormal);
 			}
 			_actor->initModelActor(2, OWN_ACTOR_SCENE_INDEX);
-			_animations->initAnim(AnimationTypes::kSabreUnknown, 1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
+			_animations->initAnim(AnimationTypes::kSabreUnknown, kAnimationType_1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
 
 			_gameState->usingSabre = true;
 		}
@@ -873,7 +873,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 
 		if (actor->life == 0) {
 			if (IS_HERO(a)) {
-				_animations->initAnim(AnimationTypes::kLandDeath, 4, AnimationTypes::kStanding, 0);
+				_animations->initAnim(AnimationTypes::kLandDeath, kAnimationType_4, AnimationTypes::kStanding, 0);
 				actor->controlMode = ControlMode::kNoMove;
 			} else {
 				_sound->playSample(Samples::Explode, 1, actor->x, actor->y, actor->z, a);
@@ -923,7 +923,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 					if (IS_HERO(a)) {
 						if (_actor->heroBehaviour != HeroBehaviourType::kProtoPack || actor->anim != AnimationTypes::kForward) {
 							if (!_actor->cropBottomScreen) {
-								_animations->initAnim(AnimationTypes::kDrawn, 4, AnimationTypes::kStanding, 0);
+								_animations->initAnim(AnimationTypes::kDrawn, kAnimationType_4, AnimationTypes::kStanding, 0);
 								_renderer->projectPositionOnScreen(actor->x - _grid->cameraX, actor->y - _grid->cameraY, actor->z - _grid->cameraZ);
 								_actor->cropBottomScreen = _renderer->projPosY;
 							}


Commit: 337b1ca35387485d15a075d4bceb74b254880f02
    https://github.com/scummvm/scummvm/commit/337b1ca35387485d15a075d4bceb74b254880f02
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-01-27T19:27:44+01:00

Commit Message:
TWINE: replaced magic numbers

Changed paths:
    engines/twine/scene/actor.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/animations.cpp
    engines/twine/scene/gamestate.cpp
    engines/twine/scene/movements.cpp
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life_v1.cpp
    engines/twine/script/script_move_v1.cpp
    engines/twine/shared.h
    engines/twine/twine.cpp


diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 2bb54773c4..5269e2fb85 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -136,15 +136,15 @@ void Actor::setBehaviour(HeroBehaviourType behaviour) {
 		break;
 	};
 
-	const int32 bodyIdx = sceneHero->body;
+	const BodyType bodyIdx = sceneHero->body;
 
 	sceneHero->entity = -1;
-	sceneHero->body = -1;
+	sceneHero->body = BodyType::btNone;
 
-	initModelActor(bodyIdx, 0);
+	initModelActor(bodyIdx, OWN_ACTOR_SCENE_INDEX);
 
 	sceneHero->anim = AnimationTypes::kAnimNone;
-	sceneHero->animType = 0;
+	sceneHero->animType = kAnimationTypeLoop;
 
 	_engine->_animations->initAnim(AnimationTypes::kStanding, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, 0);
 }
@@ -174,8 +174,8 @@ int32 Actor::getTextIdForBehaviour() const {
 }
 
 // see Animations::getBodyAnimIndex
-int32 Actor::initBody(int32 bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoundingBox) {
-	if (bodyIdx == -1) {
+int32 Actor::initBody(BodyType bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoundingBox) {
+	if (bodyIdx == BodyType::btNone) {
 		return -1;
 	}
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
@@ -186,7 +186,7 @@ int32 Actor::initBody(int32 bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoun
 			return -1;
 		}
 
-		uint8 idx = stream.readByte();
+		BodyType idx = (BodyType)stream.readByte();
 		const int32 pos = stream.pos();
 		const uint8 size = stream.readByte();
 		if (type == 1) { // 1 = body data - 3 is animdata
@@ -234,13 +234,13 @@ int32 Actor::initBody(int32 bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoun
 	} while (1);
 }
 
-void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
+void Actor::initModelActor(BodyType bodyIdx, int16 actorIdx) {
 	ActorStruct *localActor = _engine->_scene->getActor(actorIdx);
 	if (localActor->staticFlags.bIsSpriteActor) {
 		return;
 	}
 
-	debug(1, "Load body %i for actor %i", bodyIdx, actorIdx);
+	debug(1, "Load body %i for actor %i", (int)bodyIdx, actorIdx);
 
 	if (IS_HERO(actorIdx) && heroBehaviour == HeroBehaviourType::kProtoPack && localActor->armor != 0 && localActor->armor != 1) {
 		setBehaviour(HeroBehaviourType::kNormal);
@@ -249,7 +249,7 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 	ActorBoundingBox actorBoundingBox;
 	const int32 entityIdx = initBody(bodyIdx, actorIdx, actorBoundingBox);
 	if (entityIdx == -1) {
-		localActor->body = -1;
+		localActor->body = BodyType::btNone;
 		localActor->entity = -1;
 
 		ZVBox &bbox = localActor->boudingBox;
@@ -259,7 +259,7 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 		bbox.y.topRight = 0;
 		bbox.z.bottomLeft = 0;
 		bbox.z.topRight = 0;
-		debug("Failed to initialize body %i for actor %i", bodyIdx, actorIdx);
+		debug("Failed to initialize body %i for actor %i", (int)bodyIdx, actorIdx);
 		return;
 	}
 
@@ -329,11 +329,11 @@ void Actor::initActor(int16 actorIdx) {
 	} else {
 		actor->entity = -1;
 
-		debug(1, "Init actor %i with model %i", actorIdx, actor->body);
+		debug(1, "Init actor %i with model %i", actorIdx, (int)actor->body);
 		initModelActor(actor->body, actorIdx);
 
 		actor->previousAnimIdx = -1;
-		actor->animType = 0;
+		actor->animType = kAnimationTypeLoop;
 
 		if (actor->entity != -1) {
 			_engine->_animations->initAnim(actor->anim, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
@@ -350,7 +350,7 @@ void Actor::initActor(int16 actorIdx) {
 void Actor::resetActor(int16 actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 
-	actor->body = 0;
+	actor->body = BodyType::btNormal;
 	actor->anim = AnimationTypes::kStanding;
 	actor->x = 0;
 	actor->y = -1;
@@ -385,13 +385,13 @@ void Actor::resetActor(int16 actorIdx) {
 	actor->life = 50;
 	actor->armor = 1;
 	actor->hitBy = -1;
-	actor->lastRotationAngle = 0;
+	actor->lastRotationAngle = ANGLE_0;
 	actor->lastX = 0;
 	actor->lastY = 0;
 	actor->lastZ = 0;
 	actor->entity = -1;
 	actor->previousAnimIdx = -1;
-	actor->animType = 0;
+	actor->animType = kAnimationTypeLoop;
 	actor->animPosition = 0;
 
 	_engine->_movements->setActorAngleSafe(ANGLE_0, ANGLE_0, ANGLE_0, &actor->move);
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 036c16b05c..3c65d84ecf 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -142,8 +142,13 @@ struct BonusParameter {
 
 #define kAnimationTypeLoop 0
 #define kAnimationType_1 1
+// play animation and let animExtra follow as next animation
+// if there is already a next animation set - replace the value
 #define kAnimationType_2 2
+// replace animation and let the current animation follow
 #define kAnimationType_3 3
+// play animation and let animExtra follow as next animation
+// but don't take the current state in account
 #define kAnimationType_4 4
 
 /**
@@ -172,16 +177,7 @@ public:
 	void loadModel(int32 modelIndex);
 
 	int32 entity = 0; // costumeIndex - index into bodyTable
-	/**
-	 * 0: tunic + medallion
-	 * 1: tunic
-	 * 2: tunic + medallion + sword
-	 * 3: prison suit
-	 * 4: nurse outfit
-	 * 5: tunic + medallion + horn
-	 * 6: snowboard (WARNING, this can crash the game when you change behavior)
-	 */
-	int32 body = 0;
+	BodyType body = BodyType::btNormal;
 	AnimationTypes anim = AnimationTypes::kAnimNone;
 	AnimationTypes animExtra = AnimationTypes::kStanding; //field_2
 	AnimationTypes animExtraPtr = AnimationTypes::kAnimNone;
@@ -233,7 +229,7 @@ public:
 	int32 standOn = 0;
 	int32 zone = 0;
 
-	int32 lastRotationAngle = 0;
+	int32 lastRotationAngle = ANGLE_0;
 	int32 lastX = 0;
 	int32 lastZ = 0;
 	int32 lastY = 0;
@@ -277,7 +273,7 @@ private:
 	 * @param bodyIdx 3D actor body index
 	 * @param actorIdx 3D actor index
 	 */
-	int32 initBody(int32 bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoundingBox);
+	int32 initBody(BodyType bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoundingBox);
 
 	int32 loadBehaviourEntity(ActorStruct *sceneHero, uint8 **ptr, int16 &bodyAnimIndex, int32 index);
 
@@ -351,7 +347,7 @@ public:
 	 * @param bodyIdx 3D actor body index
 	 * @param actorIdx 3D actor index
 	 */
-	void initModelActor(int32 bodyIdx, int16 actorIdx);
+	void initModelActor(BodyType bodyIdx, int16 actorIdx);
 
 	/**
 	 * Initialize actors
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index e805505b02..d4aeb3812b 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -442,7 +442,7 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
 		return true;
 	}
 
-	if (animExtra == AnimationTypes::kAnimInvalid && actor->animType != 2) {
+	if (animExtra == AnimationTypes::kAnimInvalid && actor->animType != kAnimationType_2) {
 		animExtra = actor->anim;
 	}
 
@@ -452,13 +452,13 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
 		animIndex = getBodyAnimIndex(AnimationTypes::kStanding, actorIdx);
 	}
 
-	if (animType != 4 && actor->animType == 2) {
+	if (animType != kAnimationType_4 && actor->animType == kAnimationType_2) {
 		actor->animExtra = newAnim;
 		return false;
 	}
 
-	if (animType == 3) {
-		animType = 2;
+	if (animType == kAnimationType_3) {
+		animType = kAnimationType_2;
 
 		animExtra = actor->anim;
 
@@ -467,8 +467,8 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
 		}
 	}
 
-	if (animType == 4) {
-		animType = 2;
+	if (animType == kAnimationType_4) {
+		animType = kAnimationType_2;
 	}
 
 	if (actor->previousAnimIdx == -1) {
@@ -491,7 +491,7 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
 
 	processAnimActions(actorIdx);
 
-	actor->lastRotationAngle = 0;
+	actor->lastRotationAngle = ANGLE_0;
 	actor->lastX = 0;
 	actor->lastY = 0;
 	actor->lastZ = 0;
@@ -675,7 +675,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 					actor->dynamicFlags.bAnimEnded = 1;
 				}
 
-				actor->lastRotationAngle = 0;
+				actor->lastRotationAngle = ANGLE_0;
 
 				actor->lastX = 0;
 				actor->lastY = 0;
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 98cefc279f..1b3e74f252 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -99,7 +99,7 @@ void GameState::initHeroVars() {
 
 	usingSabre = false;
 
-	_engine->_scene->sceneHero->body = 0;
+	_engine->_scene->sceneHero->body = BodyType::btNormal;
 	_engine->_scene->sceneHero->life = 50;
 	_engine->_scene->sceneHero->talkColor = COLOR_BRIGHT_BLUE;
 }
@@ -195,7 +195,7 @@ bool GameState::loadGame(Common::SeekableReadStream *file) {
 	_engine->_scene->newHeroZ = file->readSint16LE();
 	_engine->_scene->sceneHero->angle = ToAngle(file->readSint16LE());
 	_engine->_actor->previousHeroAngle = _engine->_scene->sceneHero->angle;
-	_engine->_scene->sceneHero->body = file->readByte();
+	_engine->_scene->sceneHero->body = (BodyType)file->readByte();
 
 	const byte numHolomapFlags = file->readByte(); // number of holomap locations
 	if (numHolomapFlags != NUM_LOCATIONS) {
@@ -256,7 +256,7 @@ bool GameState::saveGame(Common::WriteStream *file) {
 	file->writeSint16LE(_engine->_scene->newHeroY);
 	file->writeSint16LE(_engine->_scene->newHeroZ);
 	file->writeSint16LE(FromAngle(_engine->_scene->sceneHero->angle));
-	file->writeByte(_engine->_scene->sceneHero->body);
+	file->writeByte((uint8)_engine->_scene->sceneHero->body);
 
 	// number of holomap locations
 	file->writeByte(NUM_LOCATIONS);
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index ede12a354d..4ccc0923bf 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -278,8 +278,8 @@ bool Movements::processAttackExecution(int actorIdx) {
 			return true;
 		}
 	} else if (_engine->_gameState->hasItem(InventoryItems::kiUseSabre)) {
-		if (actor->body != InventoryItems::kiUseSabre) {
-			_engine->_actor->initModelActor(InventoryItems::kiUseSabre, actorIdx);
+		if (actor->body != BodyType::btSabre) {
+			_engine->_actor->initModelActor(BodyType::btSabre, actorIdx);
 		}
 
 		_engine->_animations->initAnim(AnimationTypes::kSabreAttack, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 91ad8d56c9..7b226739d5 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -187,7 +187,7 @@ bool Scene::loadSceneLBA1() {
 
 		act->loadModel(stream.readUint16LE());
 
-		act->body = stream.readByte();
+		act->body = (BodyType)stream.readByte();
 		act->anim = (AnimationTypes)stream.readByte();
 		act->sprite = stream.readUint16LE();
 		act->x = stream.readUint16LE();
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index 68a11a0a0c..ff6b8ed26b 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -182,11 +182,11 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
 		break;
 	}
 	case kcBODY:
-		engine->_scene->currentScriptValue = ctx.actor->body;
+		engine->_scene->currentScriptValue = (int16)ctx.actor->body;
 		break;
 	case kcBODY_OBJ: {
 		int32 actorIdx = ctx.stream.readByte();
-		engine->_scene->currentScriptValue = engine->_scene->getActor(actorIdx)->body;
+		engine->_scene->currentScriptValue = (int16)engine->_scene->getActor(actorIdx)->body;
 		break;
 	}
 	case kcANIM:
@@ -563,7 +563,7 @@ static int32 lELSE(TwinEEngine *engine, LifeScriptContext &ctx) {
  * @note Opcode @c 0x11
  */
 static int32 lBODY(TwinEEngine *engine, LifeScriptContext &ctx) {
-	int32 bodyIdx = ctx.stream.readByte();
+	BodyType bodyIdx = (BodyType)ctx.stream.readByte();
 	engine->_actor->initModelActor(bodyIdx, ctx.actorIdx);
 	return 0;
 }
@@ -574,7 +574,7 @@ static int32 lBODY(TwinEEngine *engine, LifeScriptContext &ctx) {
  */
 static int32 lBODY_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
-	int32 otherBodyIdx = ctx.stream.readByte();
+	BodyType otherBodyIdx = (BodyType)ctx.stream.readByte();
 	engine->_actor->initModelActor(otherBodyIdx, otherActorIdx);
 	return 0;
 }
diff --git a/engines/twine/script/script_move_v1.cpp b/engines/twine/script/script_move_v1.cpp
index adc02cf6c3..63c2d67c15 100644
--- a/engines/twine/script/script_move_v1.cpp
+++ b/engines/twine/script/script_move_v1.cpp
@@ -91,7 +91,7 @@ static int32 mNOP(TwinEEngine *engine, MoveScriptContext &ctx) {
  * @note Opcode @c 0x02
  */
 static int32 mBODY(TwinEEngine *engine, MoveScriptContext &ctx) {
-	int32 bodyIdx = ctx.stream.readByte();
+	BodyType bodyIdx = (BodyType)ctx.stream.readByte();
 	engine->_actor->initModelActor(bodyIdx, ctx.actorIdx);
 	return 0;
 }
@@ -405,7 +405,7 @@ static int32 mWAIT_NUM_SECOND(TwinEEngine *engine, MoveScriptContext &ctx) {
  * @note Opcode @c 0x13
  */
 static int32 mNO_BODY(TwinEEngine *engine, MoveScriptContext &ctx) {
-	engine->_actor->initModelActor(-1, ctx.actorIdx);
+	engine->_actor->initModelActor(BodyType::btNone, ctx.actorIdx);
 	return 0;
 }
 
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index f08b8f994e..bb211eae8b 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -165,6 +165,26 @@ enum class HeroBehaviourType {
 	kProtoPack = 4
 };
 
+/**
+ * 0: tunic + medallion
+ * 1: tunic
+ * 2: tunic + medallion + sword
+ * 3: prison suit
+ * 4: nurse outfit
+ * 5: tunic + medallion + horn
+ * 6: snowboard (WARNING, this can crash the game when you change behavior)
+ */
+enum class BodyType {
+	btNone = -1,
+	btNormal = 0,
+	btTunic = 1,
+	btSabre = 2,
+	btPrisonSuit = 3,
+	btNurseSuit = 4,
+	btHorn = 5,
+	btSnowboard = 6
+};
+
 enum class ExtraSpecialType {
 	kHitStars = 0,
 	kExplodeCloud = 1
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index a9909692ff..3ea4d94727 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -596,16 +596,16 @@ void TwinEEngine::processInventoryAction() {
 		break;
 	case kiMagicBall:
 		if (_gameState->usingSabre) {
-			_actor->initModelActor(0, OWN_ACTOR_SCENE_INDEX);
+			_actor->initModelActor(BodyType::btNormal, OWN_ACTOR_SCENE_INDEX);
 		}
 		_gameState->usingSabre = false;
 		break;
 	case kiUseSabre:
-		if (_scene->sceneHero->body != 2) {
+		if (_scene->sceneHero->body != BodyType::btSabre) {
 			if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {
 				_actor->setBehaviour(HeroBehaviourType::kNormal);
 			}
-			_actor->initModelActor(2, OWN_ACTOR_SCENE_INDEX);
+			_actor->initModelActor(BodyType::btSabre, OWN_ACTOR_SCENE_INDEX);
 			_animations->initAnim(AnimationTypes::kSabreUnknown, kAnimationType_1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
 
 			_gameState->usingSabre = true;
@@ -617,9 +617,9 @@ void TwinEEngine::processInventoryAction() {
 	}
 	case kiProtoPack:
 		if (_gameState->hasItem(InventoryItems::kiBookOfBu)) {
-			_scene->sceneHero->body = 0;
+			_scene->sceneHero->body = BodyType::btNormal;
 		} else {
-			_scene->sceneHero->body = 1;
+			_scene->sceneHero->body = BodyType::btTunic;
 		}
 
 		if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {
@@ -640,8 +640,8 @@ void TwinEEngine::processInventoryAction() {
 
 		if (!_collision->checkCollisionWithActors(_scene->mecaPinguinIdx)) {
 			pinguin->life = 50;
-			pinguin->body = -1;
-			_actor->initModelActor(0, _scene->mecaPinguinIdx);
+			pinguin->body = BodyType::btNone;
+			_actor->initModelActor(BodyType::btNormal, _scene->mecaPinguinIdx);
 			pinguin->dynamicFlags.bIsDead = 0; // &= 0xDF
 			pinguin->setBrickShape(ShapeType::kNone);
 			_movements->moveActor(pinguin->angle, pinguin->angle, pinguin->speed, &pinguin->move);
@@ -797,9 +797,9 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 		// use Proto-Pack
 		if (_input->toggleActionIfActive(TwinEActionType::UseProtoPack) && _gameState->hasItem(InventoryItems::kiProtoPack)) {
 			if (_gameState->hasItem(InventoryItems::kiBookOfBu)) {
-				_scene->sceneHero->body = 0;
+				_scene->sceneHero->body = BodyType::btNormal;
 			} else {
-				_scene->sceneHero->body = 1;
+				_scene->sceneHero->body = BodyType::btTunic;
 			}
 
 			if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {


Commit: 5b0938b0a7e39145baad79a2b75c99c4d75d385b
    https://github.com/scummvm/scummvm/commit/5b0938b0a7e39145baad79a2b75c99c4d75d385b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-01-27T19:28:00+01:00

Commit Message:
TWINE: fixed magic ball throwing input issue

https://bugs.scummvm.org/ticket/12056

Changed paths:
    engines/twine/scene/actor.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/movements.cpp


diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 5269e2fb85..e30e7baca2 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -535,6 +535,10 @@ bool ActorStruct::isAttackAnimationActive() const {
 	return anim == AnimationTypes::kRightPunch || anim == AnimationTypes::kLeftPunch || anim == AnimationTypes::kKick;
 }
 
+bool ActorStruct::isAttackWeaponAnimationActive() const {
+	return anim == AnimationTypes::kSabreAttack || anim == AnimationTypes::kThrowBall || anim == AnimationTypes::kSabreUnknown;
+}
+
 bool ActorStruct::isJumpAnimationActive() const {
 	return anim == AnimationTypes::kJump;
 }
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 3c65d84ecf..884614d95a 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -185,6 +185,7 @@ public:
 	uint8 *entityDataPtr = nullptr;
 	int32 entityDataSize = 0;
 
+	bool isAttackWeaponAnimationActive() const;
 	bool isAttackAnimationActive() const;
 	bool isJumpAnimationActive() const;
 
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index 4ccc0923bf..54c7c3f2a2 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -298,6 +298,9 @@ void Movements::processMovementExecution(int actorIdx) {
 	if (actor->isJumpAnimationActive()) {
 		return;
 	}
+	if (actor->isAttackWeaponAnimationActive()) {
+		return;
+	}
 	if (!changedCursorKeys || heroAction) {
 		// if walking should get stopped
 		if (!_engine->_input->isActionActive(TwinEActionType::MoveForward) && !_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {




More information about the Scummvm-git-logs mailing list