[Scummvm-git-logs] scummvm master -> cd03d7e8b671dbeb5a05a07338fa5348f2bb54f1
mgerhardy
noreply at scummvm.org
Tue Oct 8 19:27:29 UTC 2024
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:
5e90051f3a TWINE: unified code with original source release
0bd98f3b6e TWINE: renamed method to match original sources (checkCarrier)
6a66b4bbdd TWINE: fixed crash in debug window if actor has no entity data (e.g. a sprite)
cd03d7e8b6 TWINE: renamed flags to match the original sources
Commit: 5e90051f3ae5fdcce58b74c281277bd3d0498c47
https://github.com/scummvm/scummvm/commit/5e90051f3ae5fdcce58b74c281277bd3d0498c47
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-08T21:27:01+02:00
Commit Message:
TWINE: unified code with original source release
Changed paths:
engines/twine/script/script_life.cpp
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 208d8f9b846..5b1119d5a4d 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -144,20 +144,85 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
debugCN(3, kDebugLevels::kDebugScripts, "distance(%i, ", actorIdx);
conditionValueSize = ReturnType::RET_S16;
ActorStruct *otherActor = engine->_scene->getActor(actorIdx);
- if (!otherActor->_workFlags.bIsDead) {
- if (ABS(ctx.actor->_posObj.y - otherActor->_posObj.y) >= 1500) {
+ if (otherActor->_workFlags.bIsDead) {
+ engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
+ break;
+ }
+ if (ABS(ctx.actor->_posObj.y - otherActor->_posObj.y) < 1500) {
+ // Returns int32, so we check for integer overflow
+ int32 distance = getDistance2D(ctx.actor->posObj(), otherActor->posObj());
+ if (ABS(distance) > MAX_TARGET_ACTOR_DISTANCE) {
engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
} else {
- // Returns int32, so we check for integer overflow
- int32 distance = getDistance2D(ctx.actor->posObj(), otherActor->posObj());
- if (ABS(distance) > MAX_TARGET_ACTOR_DISTANCE) {
- engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
+ engine->_scene->_currentScriptValue = distance;
+ }
+ } else {
+ engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
+ }
+ break;
+ }
+ case kcDISTANCE_3D: {
+ int32 targetActorIdx = ctx.stream.readByte();
+ debugCN(3, kDebugLevels::kDebugScripts, "distance_3d(%i, ", targetActorIdx);
+ ActorStruct *targetActor = engine->_scene->getActor(targetActorIdx);
+
+ conditionValueSize = ReturnType::RET_S16;
+
+ if (targetActor->_workFlags.bIsDead) {
+ engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
+ break;
+ }
+ // Returns int32, so we check for integer overflow
+ int32 distance = getDistance3D(ctx.actor->posObj(), targetActor->posObj());
+ if (ABS(distance) > MAX_TARGET_ACTOR_DISTANCE) {
+ engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
+ } else {
+ engine->_scene->_currentScriptValue = distance;
+ }
+ break;
+ }
+ case kcCONE_VIEW: {
+ int32 newAngle = 0;
+ int32 targetActorIdx = ctx.stream.readByte();
+ debugCN(3, kDebugLevels::kDebugScripts, "cone_view(%i, ", targetActorIdx);
+ ActorStruct *targetActor = engine->_scene->getActor(targetActorIdx);
+
+ conditionValueSize = ReturnType::RET_S16;
+
+ if (targetActor->_workFlags.bIsDead) {
+ engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
+ break;
+ }
+
+ if (ABS(targetActor->_posObj.y - ctx.actor->_posObj.y) < 1500) {
+ newAngle = engine->_movements->getAngle(ctx.actor->posObj(), targetActor->posObj());
+ if (ABS(engine->_movements->_targetActorDistance) > MAX_TARGET_ACTOR_DISTANCE) {
+ engine->_movements->_targetActorDistance = MAX_TARGET_ACTOR_DISTANCE;
+ }
+ } else {
+ engine->_movements->_targetActorDistance = MAX_TARGET_ACTOR_DISTANCE;
+ }
+
+ if (IS_HERO(targetActorIdx)) {
+ if (engine->_actor->_heroBehaviour == HeroBehaviourType::kDiscrete) {
+ int32 heroAngle = ClampAngle((ctx.actor->_beta + LBAAngles::ANGLE_360 + LBAAngles::ANGLE_45) - (newAngle + LBAAngles::ANGLE_360));
+
+ if (ABS(heroAngle) <= LBAAngles::ANGLE_90) {
+ engine->_scene->_currentScriptValue = engine->_movements->_targetActorDistance;
} else {
- engine->_scene->_currentScriptValue = distance;
+ engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
}
+ } else {
+ engine->_scene->_currentScriptValue = engine->_movements->_targetActorDistance;
}
} else {
- engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
+ int32 heroAngle = ClampAngle((ctx.actor->_beta + LBAAngles::ANGLE_360 + LBAAngles::ANGLE_45) - (newAngle + LBAAngles::ANGLE_360));
+
+ if (ABS(heroAngle) <= LBAAngles::ANGLE_90) {
+ engine->_scene->_currentScriptValue = engine->_movements->_targetActorDistance;
+ } else {
+ engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
+ }
}
break;
}
@@ -209,51 +274,6 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
engine->_scene->_currentScriptValue = engine->_scene->_listFlagCube[flagIdx];
break;
}
- case kcCONE_VIEW: {
- int32 newAngle = 0;
- int32 targetActorIdx = ctx.stream.readByte();
- debugCN(3, kDebugLevels::kDebugScripts, "cone_view(%i, ", targetActorIdx);
- ActorStruct *targetActor = engine->_scene->getActor(targetActorIdx);
-
- conditionValueSize = ReturnType::RET_S16;
-
- if (targetActor->_workFlags.bIsDead) {
- engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
- break;
- }
-
- if (ABS(targetActor->_posObj.y - ctx.actor->_posObj.y) < 1500) {
- newAngle = engine->_movements->getAngle(ctx.actor->posObj(), targetActor->posObj());
- if (ABS(engine->_movements->_targetActorDistance) > MAX_TARGET_ACTOR_DISTANCE) {
- engine->_movements->_targetActorDistance = MAX_TARGET_ACTOR_DISTANCE;
- }
- } else {
- engine->_movements->_targetActorDistance = MAX_TARGET_ACTOR_DISTANCE;
- }
-
- if (IS_HERO(targetActorIdx)) {
- if (engine->_actor->_heroBehaviour == HeroBehaviourType::kDiscrete) {
- int32 heroAngle = ClampAngle(ctx.actor->_beta + LBAAngles::ANGLE_360 + LBAAngles::ANGLE_45 - newAngle + LBAAngles::ANGLE_360);
-
- if (ABS(heroAngle) <= LBAAngles::ANGLE_90) {
- engine->_scene->_currentScriptValue = engine->_movements->_targetActorDistance;
- } else {
- engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
- }
- } else {
- engine->_scene->_currentScriptValue = engine->_movements->_targetActorDistance;
- }
- } else {
- int32 heroAngle = ClampAngle(ctx.actor->_beta + LBAAngles::ANGLE_360 + LBAAngles::ANGLE_45 - newAngle + LBAAngles::ANGLE_360);
-
- if (ABS(heroAngle) <= LBAAngles::ANGLE_90) {
- engine->_scene->_currentScriptValue = engine->_movements->_targetActorDistance;
- } else {
- engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
- }
- }
- break;
- }
case kcHIT_BY:
debugCN(3, kDebugLevels::kDebugScripts, "hit_by(");
engine->_scene->_currentScriptValue = ctx.actor->_hitBy;
@@ -318,29 +338,6 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
debugCN(3, kDebugLevels::kDebugScripts, "chapter(");
engine->_scene->_currentScriptValue = engine->_gameState->getChapter();
break;
- case kcDISTANCE_3D: {
- int32 targetActorIdx;
- ActorStruct *targetActor;
-
- targetActorIdx = ctx.stream.readByte();
- debugCN(3, kDebugLevels::kDebugScripts, "distance_3d(%i, ", targetActorIdx);
- targetActor = engine->_scene->getActor(targetActorIdx);
-
- conditionValueSize = ReturnType::RET_S16;
-
- if (!targetActor->_workFlags.bIsDead) {
- // Returns int32, so we check for integer overflow
- int32 distance = getDistance3D(ctx.actor->posObj(), targetActor->posObj());
- if (ABS(distance) > MAX_TARGET_ACTOR_DISTANCE) {
- engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
- } else {
- engine->_scene->_currentScriptValue = distance;
- }
- } else {
- engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
- }
- break;
- }
case kcMAGIC_LEVEL:
debugCN(3, kDebugLevels::kDebugScripts, "magic_level(");
engine->_scene->_currentScriptValue = engine->_gameState->_magicLevelIdx;
Commit: 0bd98f3b6e3d11cea54a1c883d596746384247d8
https://github.com/scummvm/scummvm/commit/0bd98f3b6e3d11cea54a1c883d596746384247d8
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-08T21:27:01+02:00
Commit Message:
TWINE: renamed method to match original sources (checkCarrier)
Changed paths:
engines/twine/scene/actor.cpp
engines/twine/scene/actor.h
engines/twine/script/script_life.cpp
engines/twine/script/script_life_v2.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 62f86f6599a..3b0a4a6aeee 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -412,7 +412,7 @@ void Actor::hitObj(int32 actorIdx, int32 actorIdxAttacked, int32 hitforce, int32
}
}
-void Actor::processActorCarrier(int32 actorIdx) {
+void Actor::checkCarrier(int32 actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
if (!actor->_staticFlags.bIsCarrierActor) {
return;
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 969a9869806..1b899dd3b1c 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -370,7 +370,7 @@ public:
void hitObj(int32 actorIdx, int32 actorIdxAttacked, int32 strengthOfHit, int32 angle);
/** Process actor carrier */
- void processActorCarrier(int32 actorIdx); // CheckCarrier
+ void checkCarrier(int32 actorIdx); // CheckCarrier
/** Process actor extra bonus */
void giveExtraBonus(int32 actorIdx);
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 5b1119d5a4d..7fe398d855c 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1075,7 +1075,7 @@ int32 ScriptLife::lKILL_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
const int32 otherActorIdx = ctx.stream.readByte();
debugC(3, kDebugLevels::kDebugScripts, "LIFE::lKILL_OBJ(%i)", (int)otherActorIdx);
- engine->_actor->processActorCarrier(otherActorIdx);
+ engine->_actor->checkCarrier(otherActorIdx);
ActorStruct *otherActor = engine->_scene->getActor(otherActorIdx);
otherActor->_workFlags.bIsDead = 1;
otherActor->_body = -1;
@@ -1091,7 +1091,7 @@ int32 ScriptLife::lKILL_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
*/
int32 ScriptLife::lSUICIDE(TwinEEngine *engine, LifeScriptContext &ctx) {
debugC(3, kDebugLevels::kDebugScripts, "LIFE::SUICIDE()");
- engine->_actor->processActorCarrier(ctx.actorIdx);
+ engine->_actor->checkCarrier(ctx.actorIdx);
ctx.actor->_workFlags.bIsDead = 1;
ctx.actor->_body = -1;
ctx.actor->_zoneSce = -1;
diff --git a/engines/twine/script/script_life_v2.cpp b/engines/twine/script/script_life_v2.cpp
index 79cad5abc0a..fea2e50b2f9 100644
--- a/engines/twine/script/script_life_v2.cpp
+++ b/engines/twine/script/script_life_v2.cpp
@@ -967,7 +967,7 @@ int32 ScriptLifeV2::lINVERSE_BETA(TwinEEngine *engine, LifeScriptContext &ctx) {
}
// To tell an object that it is no longer being carried by me
- engine->_actor->processActorCarrier(ctx.actorIdx);
+ engine->_actor->checkCarrier(ctx.actorIdx);
return -1;
}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index dab7402bc92..edf40e813b3 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -1156,7 +1156,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
}
}
} else {
- _actor->processActorCarrier(a);
+ _actor->checkCarrier(a);
actor->_workFlags.bIsDead = 1;
actor->_body = -1;
actor->_zoneSce = -1;
Commit: 6a66b4bbdda1a78fe9b85ac30d0c266536db5f0a
https://github.com/scummvm/scummvm/commit/6a66b4bbdda1a78fe9b85ac30d0c266536db5f0a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-08T21:27:01+02:00
Commit Message:
TWINE: fixed crash in debug window if actor has no entity data (e.g. a sprite)
Changed paths:
engines/twine/debugger/debugtools.cpp
diff --git a/engines/twine/debugger/debugtools.cpp b/engines/twine/debugger/debugtools.cpp
index a99d885cfad..823ea388af5 100644
--- a/engines/twine/debugger/debugtools.cpp
+++ b/engines/twine/debugger/debugtools.cpp
@@ -496,8 +496,12 @@ static void actorDetailsWindow(int &actorIdx, TwinEEngine *engine) {
if (actor->_body != -1) {
ImGui::SeparatorText("Body");
- BodyData &bodyData = actor->_entityDataPtr->getBody(actor->_body);
- ImGuiEx::InputBoundingBox((int)(uintptr)&bodyData, "Bounding box", bodyData.bbox);
+ if (actor->_entityDataPtr != nullptr) {
+ BodyData &bodyData = actor->_entityDataPtr->getBody(actor->_body);
+ ImGuiEx::InputBoundingBox((int)(uintptr)&bodyData, "Bounding box", bodyData.bbox);
+ } else {
+ ImGui::Text("No entity data");
+ }
}
ImGui::SeparatorText("Entity");
Commit: cd03d7e8b671dbeb5a05a07338fa5348f2bb54f1
https://github.com/scummvm/scummvm/commit/cd03d7e8b671dbeb5a05a07338fa5348f2bb54f1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-08T21:27:01+02:00
Commit Message:
TWINE: renamed flags to match the original sources
Changed paths:
engines/twine/scene/actor.cpp
engines/twine/scene/actor.h
engines/twine/scene/animations.cpp
engines/twine/scene/scene.cpp
engines/twine/script/script_life.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 3b0a4a6aeee..bd22829a440 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -52,9 +52,9 @@ void Actor::restartHeroScene() {
sceneHero->_staticFlags.bComputeCollisionWithObj = 1;
sceneHero->_staticFlags.bComputeCollisionWithBricks = 1;
- sceneHero->_staticFlags.bIsZonable = 1;
+ sceneHero->_staticFlags.bCheckZone = 1;
sceneHero->_staticFlags.bCanDrown = 1;
- sceneHero->_staticFlags.bCanFall = 1;
+ sceneHero->_staticFlags.bObjFallable = 1;
sceneHero->_armor = 1;
sceneHero->_offsetTrack = -1;
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 1b899dd3b1c..6c090fb3fb6 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -61,7 +61,7 @@ struct AnimTimerDataStruct {
struct StaticFlagsStruct {
uint32 bComputeCollisionWithObj : 1; // 0x000001 CHECK_OBJ_COL
uint32 bComputeCollisionWithBricks : 1; // 0x000002 CHECK_BRICK_COL
- uint32 bIsZonable : 1; // 0x000004 CHECK_ZONE - testing of scenaric areas
+ uint32 bCheckZone : 1; // 0x000004 CHECK_ZONE - testing of scenaric areas
uint32 bSpriteClip : 1; // 0x000008 SPRITE_CLIP - (doors) fixed clip area
uint32 bCanBePushed : 1; // 0x000010 PUSHABLE
uint32 bComputeLowCollision : 1; // 0x000020 COL_BASSE
@@ -70,7 +70,7 @@ struct StaticFlagsStruct {
uint32 bUnk0100 : 1; // 0x000100
uint32 bIsInvisible : 1; // 0x000200 INVISIBLE - not drawn but all computed
uint32 bSprite3D : 1; // 0x000400 SPRITE_3D - a sprite not a 3D object
- uint32 bCanFall : 1; // 0x000800 OBJ_FALLABLE
+ uint32 bObjFallable : 1; // 0x000800 OBJ_FALLABLE
uint32 bNoShadow : 1; // 0x001000 NO_SHADOW - no auto shadow
uint32 bIsBackgrounded : 1; // 0x002000 OBJ_BACKGROUND - is embedded in the decor the 1st time
uint32 bIsCarrierActor : 1; // 0x004000 OBJ_CARRIER - can carry and move an obj
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index 7339842ce5e..5abb8120749 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -742,7 +742,7 @@ void Animations::doAnim(int32 actorIdx) {
actor->_workFlags.bIsFalling = 0;
} else {
- if (actor->_staticFlags.bCanFall && actor->_carryBy == -1) {
+ if (actor->_staticFlags.bObjFallable && actor->_carryBy == -1) {
col = _engine->_grid->worldColBrick(processActor.x, processActor.y - 1, processActor.z);
if (col != ShapeType::kNone) {
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index e21bb976383..b50d01bdc03 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -55,7 +55,7 @@ void Scene::setActorStaticFlags(ActorStruct *act, uint32 staticFlags) {
act->_staticFlags.bComputeCollisionWithBricks = 1;
}
if (staticFlags & 0x4) {
- act->_staticFlags.bIsZonable = 1;
+ act->_staticFlags.bCheckZone = 1;
}
if (staticFlags & 0x8) {
act->_staticFlags.bSpriteClip = 1;
@@ -83,7 +83,7 @@ void Scene::setActorStaticFlags(ActorStruct *act, uint32 staticFlags) {
act->_staticFlags.bSprite3D = 1;
}
if (staticFlags & 0x800) {
- act->_staticFlags.bCanFall = 1;
+ act->_staticFlags.bObjFallable = 1;
}
if (staticFlags & 0x1000) {
act->_staticFlags.bNoShadow = 1;
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 7fe398d855c..98c50c15f71 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -937,7 +937,7 @@ int32 ScriptLife::lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
*/
int32 ScriptLife::lFALLABLE(TwinEEngine *engine, LifeScriptContext &ctx) {
const int32 flag = ctx.stream.readByte();
- ctx.actor->_staticFlags.bCanFall = flag & 1;
+ ctx.actor->_staticFlags.bObjFallable = flag & 1;
debugC(3, kDebugLevels::kDebugScripts, "LIFE::FALLABLE(%i)", (int)flag);
return 0;
}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index edf40e813b3..6d884bbfcd5 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -1045,10 +1045,20 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
continue;
}
- if (actor->_lifePoint == 0) {
+ if (actor->_lifePoint <= 0) {
if (IS_HERO(a)) {
_animations->initAnim(AnimationTypes::kLandDeath, AnimType::kAnimationSet, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
actor->_controlMode = ControlMode::kNoMove;
+#if 0 // TODO: enable me - found in the lba1 community release source code
+ // Disable collisions on Twinsen to allow other objects to continue their tracks
+ // while the death animation is playing
+ actor->_staticFlags.bObjFallable = 1;
+ actor->_staticFlags.bCheckZone = 0;
+ actor->_staticFlags.bComputeCollisionWithObj = 0;
+ actor->_staticFlags.bComputeCollisionWithBricks = 0;
+ actor->_staticFlags.bCanDrown = 1;
+ actor->_workFlags.bIsHitting = 0;
+#endif
} else {
_sound->playSample(Samples::Explode, 1, actor->posObj(), a);
@@ -1072,7 +1082,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
_animations->doAnim(a);
- if (actor->_staticFlags.bIsZonable) {
+ if (actor->_staticFlags.bCheckZone) {
_scene->checkZoneSce(a);
}
More information about the Scummvm-git-logs
mailing list