[Scummvm-git-logs] scummvm master -> 8655f6b978c5a06a59b67889794e96001d43f6cd
mgerhardy
noreply at scummvm.org
Mon Feb 6 18:05:22 UTC 2023
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
21a7f52183 TWINE: unified with original sources
0517e015fc TWINE: unified with original sources and reduced the amount of globals
ddb73bc158 TWINE: renamed variables to match original sources
9c76b8689e TWINE: use toSeconds
c6b0b8ecef TWINE: replaced with macro
e0051c2aa8 TWINE: fixed LBAAngles usage
8655f6b978 TWINE: further renaming
Commit: 21a7f52183cbade4de9e4a1c8828177a81c86c7b
https://github.com/scummvm/scummvm/commit/21a7f52183cbade4de9e4a1c8828177a81c86c7b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-02-06T18:57:54+01:00
Commit Message:
TWINE: unified with original sources
Changed paths:
engines/twine/audio/sound.cpp
engines/twine/debugger/debug_scene.cpp
engines/twine/holomap.cpp
engines/twine/renderer/redraw.cpp
engines/twine/scene/actor.cpp
engines/twine/scene/animations.cpp
engines/twine/scene/collision.cpp
engines/twine/scene/collision.h
engines/twine/scene/extra.cpp
engines/twine/scene/gamestate.cpp
engines/twine/scene/grid.cpp
engines/twine/scene/grid.h
engines/twine/scene/movements.cpp
engines/twine/scene/scene.cpp
engines/twine/scene/scene.h
engines/twine/script/script_life.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/audio/sound.cpp b/engines/twine/audio/sound.cpp
index 241314c5f51..ce030444d76 100644
--- a/engines/twine/audio/sound.cpp
+++ b/engines/twine/audio/sound.cpp
@@ -54,7 +54,7 @@ void Sound::setSamplePosition(int32 channelIdx, int32 x, int32 y, int32 z) {
const int32 camY = _engine->_grid->_newCamera.y * SIZE_BRICK_Y;
const int32 camZ = _engine->_grid->_newCamera.z * SIZE_BRICK_XZ;
int32 distance = getDistance3D(camX, camY, camZ, x, y, z);
- distance = _engine->_collision->clampedLerp(0, distance, 10000, 255);
+ distance = _engine->_collision->boundRuleThree(0, distance, 10000, 255);
const byte targetVolume = CLIP<byte>(255 - distance, 0, 255);
_engine->_system->getMixer()->setChannelVolume(samplesPlaying[channelIdx], targetVolume);
}
diff --git a/engines/twine/debugger/debug_scene.cpp b/engines/twine/debugger/debug_scene.cpp
index 19428f16358..f0fe439e566 100644
--- a/engines/twine/debugger/debug_scene.cpp
+++ b/engines/twine/debugger/debug_scene.cpp
@@ -142,7 +142,7 @@ bool DebugScene::drawBox(const ScenePositionsProjected &positions, uint8 color)
bool DebugScene::displayActors() {
bool state = false;
- for (int32 a = 0; a < _engine->_scene->_sceneNumActors; a++) {
+ for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
const ActorStruct *actorPtr = _engine->_scene->getActor(a);
const IVec3 &pos = actorPtr->posObj();
const BoundingBox &bbox = actorPtr->_boundingBox;
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 8a8a507e712..975af4abbd6 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -617,8 +617,8 @@ void Holomap::holoMap() {
if (automove) {
const int32 dt = _engine->timerRef - otimer;
- calpha = _engine->_collision->clampedLerp(oalpha, dalpha, 75, dt);
- cbeta = _engine->_collision->clampedLerp(obeta, dbeta, 75, dt);
+ calpha = _engine->_collision->boundRuleThree(oalpha, dalpha, 75, dt);
+ cbeta = _engine->_collision->boundRuleThree(obeta, dbeta, 75, dt);
redraw = true;
}
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 9639b6dd19b..189df4ce6ee 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -200,7 +200,7 @@ void Redraw::updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2) {
int32 Redraw::fillActorDrawingList(DrawListStruct *drawList, bool flagflip) {
int32 drawListPos = 0;
- for (int32 a = 0; a < _engine->_scene->_sceneNumActors; a++) {
+ for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
ActorStruct *actor = _engine->_scene->getActor(a);
actor->_dynamicFlags.bIsDrawn = 0; // reset visible state
@@ -706,7 +706,7 @@ void Redraw::renderOverlays() {
break;
}
case OverlayType::koNumberRange: {
- const int32 range = _engine->_collision->clampedLerp(overlay->info1, overlay->info0, 100, overlay->lifeTime - _engine->timerRef - 50);
+ const int32 range = _engine->_collision->boundRuleThree(overlay->info1, overlay->info0, 100, overlay->lifeTime - _engine->timerRef - 50);
char text[10];
Common::sprintf_s(text, "%d", range);
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 1f3a49b5b55..365da6c1bb4 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -330,7 +330,7 @@ void Actor::processActorCarrier(int32 actorIdx) {
if (!actor->_staticFlags.bIsCarrierActor) {
return;
}
- for (int32 a = 0; a < _engine->_scene->_sceneNumActors; a++) {
+ for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
if (actor->_carryBy == actorIdx) {
actor->_carryBy = -1;
}
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index d9effeaee42..c75fbc7a8b7 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -669,7 +669,7 @@ void Animations::doAnim(int32 actorIdx) {
collision->receptionObj(actorIdx);
}
- collision->_causeActorDamage = 0;
+ collision->_col1 = 0;
// TODO: hack to fix tank-not-moving bug https://bugs.scummvm.org/ticket/13177
// remove processActorSave
@@ -695,8 +695,8 @@ void Animations::doAnim(int32 actorIdx) {
}
// process wall hit while running
- if (collision->_causeActorDamage && !actor->_dynamicFlags.bIsFalling && IS_HERO(actorIdx) && _engine->_actor->_heroBehaviour == HeroBehaviourType::kAthletic && actor->_genAnim == AnimationTypes::kForward) {
- IVec2 destPos = _engine->_renderer->rotate(actor->_boundingBox.mins.x, actor->_boundingBox.mins.z, actor->_beta + LBAAngles::LBAAngles::ANGLE_360 + LBAAngles::LBAAngles::ANGLE_135);
+ if (collision->_col1 && !actor->_dynamicFlags.bIsFalling && IS_HERO(actorIdx) && _engine->_actor->_heroBehaviour == HeroBehaviourType::kAthletic && actor->_genAnim == AnimationTypes::kForward) {
+ IVec2 destPos = _engine->_renderer->rotate(actor->_boundingBox.mins.x, actor->_boundingBox.mins.z, actor->_beta + LBAAngles::LBAAngles::ANGLE_315 + LBAAngles::LBAAngles::ANGLE_180);
destPos.x += processActor.x;
destPos.y += processActor.z;
@@ -798,7 +798,7 @@ void Animations::doAnim(int32 actorIdx) {
}
}
- if (collision->_causeActorDamage) {
+ if (collision->_col1) {
actor->setBrickCausesDamage();
}
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index 2e57aa33bde..890bd8f76b3 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -82,7 +82,7 @@ bool Collision::checkZvOnZv(int32 actorIdx1, int32 actorIdx2) const {
return true;
}
-int32 Collision::clampedLerp(int32 val1, int32 val2, int32 nbstep, int32 step) const { // BoundRegleTrois
+int32 Collision::boundRuleThree(int32 val1, int32 val2, int32 nbstep, int32 step) const { // BoundRegleTrois
if (step <= 0) {
return val1;
}
@@ -99,7 +99,7 @@ void Collision::reajustPos(IVec3 &processActor, ShapeType brickShape) const {
return;
}
- const int32 xw = (_collision.x * SIZE_BRICK_XZ) - DEMI_BRICK_XZ;
+ const int32 xw = (_collision.x * SIZE_BRICK_XZ) - DEMI_BRICK_XZ; // upper left corner of the brick
const int32 yw = _collision.y * SIZE_BRICK_Y;
const int32 zw = (_collision.z * SIZE_BRICK_XZ) - DEMI_BRICK_XZ;
@@ -167,67 +167,67 @@ void Collision::reajustPos(IVec3 &processActor, ShapeType brickShape) const {
switch (brickShape) {
case ShapeType::kStairsTopLeft:
- processActor.y = yw + clampedLerp(0, SIZE_BRICK_Y, SIZE_BRICK_XZ, processActor.x - xw);
+ processActor.y = yw + boundRuleThree(0, SIZE_BRICK_Y, SIZE_BRICK_XZ, processActor.x - xw);
break;
case ShapeType::kStairsTopRight:
- processActor.y = yw + clampedLerp(0, SIZE_BRICK_Y, SIZE_BRICK_XZ, processActor.z - zw);
+ processActor.y = yw + boundRuleThree(0, SIZE_BRICK_Y, SIZE_BRICK_XZ, processActor.z - zw);
break;
case ShapeType::kStairsBottomLeft:
- processActor.y = yw + clampedLerp(SIZE_BRICK_Y, 0, SIZE_BRICK_XZ, processActor.z - zw);
+ processActor.y = yw + boundRuleThree(SIZE_BRICK_Y, 0, SIZE_BRICK_XZ, processActor.z - zw);
break;
case ShapeType::kStairsBottomRight:
- processActor.y = yw + clampedLerp(SIZE_BRICK_Y, 0, SIZE_BRICK_XZ, processActor.x - xw);
+ processActor.y = yw + boundRuleThree(SIZE_BRICK_Y, 0, SIZE_BRICK_XZ, processActor.x - xw);
break;
default:
break;
}
}
-void Collision::handlePushing(const IVec3 &minsTest, const IVec3 &maxsTest, ActorStruct *actor, ActorStruct *actorTest) {
- IVec3 &processActor = actor->_processActor;
- const IVec3 &previousActor = actor->_previousActor;
-
- const int32 newAngle = _engine->_movements->getAngle(processActor, actorTest->posObj());
+void Collision::handlePushing(IVec3 &processActor, const IVec3 &minsTest, const IVec3 &maxsTest, ActorStruct *ptrobj, ActorStruct *ptrobjt) {
+ const int32 newAngle = _engine->_movements->getAngle(processActor, ptrobjt->posObj());
// protect against chain reactions
- if (actorTest->_staticFlags.bCanBePushed && !actor->_staticFlags.bCanBePushed) {
- actorTest->_animStep.y = 0;
+ if (ptrobjt->_staticFlags.bCanBePushed && !ptrobj->_staticFlags.bCanBePushed) {
+ ptrobjt->_animStep.y = 0;
- if (actorTest->_staticFlags.bUseMiniZv) {
- if (newAngle >= LBAAngles::ANGLE_45 && newAngle < LBAAngles::ANGLE_135 && actor->_beta >= LBAAngles::ANGLE_45 && actor->_beta < LBAAngles::ANGLE_135) {
- actorTest->_animStep.x = SIZE_BRICK_XZ / 4 + SIZE_BRICK_XZ / 8;
+ if (ptrobjt->_staticFlags.bUseMiniZv) {
+ if (newAngle >= LBAAngles::ANGLE_45 && newAngle < LBAAngles::ANGLE_135 && ptrobj->_beta >= LBAAngles::ANGLE_45 && ptrobj->_beta < LBAAngles::ANGLE_135) {
+ ptrobjt->_animStep.x = SIZE_BRICK_XZ / 4 + SIZE_BRICK_XZ / 8;
}
- if (newAngle >= LBAAngles::ANGLE_135 && newAngle < LBAAngles::ANGLE_225 && actor->_beta >= LBAAngles::ANGLE_135 && actor->_beta < LBAAngles::ANGLE_225) {
- actorTest->_animStep.z = -SIZE_BRICK_XZ / 4 + SIZE_BRICK_XZ / 8;
+ if (newAngle >= LBAAngles::ANGLE_135 && newAngle < LBAAngles::ANGLE_225 && ptrobj->_beta >= LBAAngles::ANGLE_135 && ptrobj->_beta < LBAAngles::ANGLE_225) {
+ ptrobjt->_animStep.z = -SIZE_BRICK_XZ / 4 + SIZE_BRICK_XZ / 8;
}
- if (newAngle >= LBAAngles::ANGLE_225 && newAngle < LBAAngles::ANGLE_315 && actor->_beta >= LBAAngles::ANGLE_225 && actor->_beta < LBAAngles::ANGLE_315) {
- actorTest->_animStep.x = -SIZE_BRICK_XZ / 4 + SIZE_BRICK_XZ / 8;
+ if (newAngle >= LBAAngles::ANGLE_225 && newAngle < LBAAngles::ANGLE_315 && ptrobj->_beta >= LBAAngles::ANGLE_225 && ptrobj->_beta < LBAAngles::ANGLE_315) {
+ ptrobjt->_animStep.x = -SIZE_BRICK_XZ / 4 + SIZE_BRICK_XZ / 8;
}
- if ((newAngle >= LBAAngles::ANGLE_315 || newAngle < LBAAngles::ANGLE_45) && (actor->_beta >= LBAAngles::ANGLE_315 || actor->_beta < LBAAngles::ANGLE_45)) {
- actorTest->_animStep.z = SIZE_BRICK_XZ / 4 + SIZE_BRICK_XZ / 8;
+ if ((newAngle >= LBAAngles::ANGLE_315 || newAngle < LBAAngles::ANGLE_45) && (ptrobj->_beta >= LBAAngles::ANGLE_315 || ptrobj->_beta < LBAAngles::ANGLE_45)) {
+ ptrobjt->_animStep.z = SIZE_BRICK_XZ / 4 + SIZE_BRICK_XZ / 8;
}
} else {
- actorTest->_animStep.x = processActor.x - actor->_oldPos.x;
- actorTest->_animStep.z = processActor.z - actor->_oldPos.z;
+ // induced displacement before readjustment?
+ ptrobjt->_animStep.x = processActor.x - ptrobj->_oldPos.x;
+ ptrobjt->_animStep.z = processActor.z - ptrobj->_oldPos.z;
}
}
- if ((actorTest->_boundingBox.maxs.x - actorTest->_boundingBox.mins.x == actorTest->_boundingBox.maxs.z - actorTest->_boundingBox.mins.z) &&
- (actor->_boundingBox.maxs.x - actor->_boundingBox.mins.x == actor->_boundingBox.maxs.z - actor->_boundingBox.mins.z)) {
+ // so patch tempo
+ if ((ptrobjt->_boundingBox.maxs.x - ptrobjt->_boundingBox.mins.x == ptrobjt->_boundingBox.maxs.z - ptrobjt->_boundingBox.mins.z) &&
+ (ptrobj->_boundingBox.maxs.x - ptrobj->_boundingBox.mins.x == ptrobj->_boundingBox.maxs.z - ptrobj->_boundingBox.mins.z)) {
if (newAngle >= LBAAngles::ANGLE_45 && newAngle < LBAAngles::ANGLE_135) {
- processActor.x = minsTest.x - actor->_boundingBox.maxs.x;
+ processActor.x = minsTest.x - ptrobj->_boundingBox.maxs.x;
}
if (newAngle >= LBAAngles::ANGLE_135 && newAngle < LBAAngles::ANGLE_225) {
- processActor.z = maxsTest.z - actor->_boundingBox.mins.z;
+ processActor.z = maxsTest.z - ptrobj->_boundingBox.mins.z;
}
if (newAngle >= LBAAngles::ANGLE_225 && newAngle < LBAAngles::ANGLE_315) {
- processActor.x = maxsTest.x - actor->_boundingBox.mins.x;
+ processActor.x = maxsTest.x - ptrobj->_boundingBox.mins.x;
}
if (newAngle >= LBAAngles::ANGLE_315 || newAngle < LBAAngles::ANGLE_45) {
- processActor.z = minsTest.z - actor->_boundingBox.maxs.z;
+ processActor.z = minsTest.z - ptrobj->_boundingBox.maxs.z;
}
- } else if (!actor->_dynamicFlags.bIsFalling) {
- processActor = previousActor;
+ } else if (!ptrobj->_dynamicFlags.bIsFalling) {
+ // refuse pos
+ processActor = ptrobj->_previousActor;
}
}
@@ -264,7 +264,7 @@ bool Collision::checkValidObjPos(int32 actorIdx) {
return false;
}
- for (int32 n = 0; n < _engine->_scene->_sceneNumActors; ++n) {
+ for (int32 n = 0; n < _engine->_scene->_nbObjets; ++n) {
const ActorStruct *actorTest = _engine->_scene->getActor(n);
if (n != actorIdx && actorTest->_body != -1 && !actor->_staticFlags.bIsHidden && actorTest->_carryBy != actorIdx) {
const IVec3 &t0 = actorTest->posObj() + actorTest->_boundingBox.mins;
@@ -278,50 +278,60 @@ bool Collision::checkValidObjPos(int32 actorIdx) {
}
int32 Collision::checkObjCol(int32 actorIdx) {
- ActorStruct *actor = _engine->_scene->getActor(actorIdx);
+ ActorStruct *ptrobj = _engine->_scene->getActor(actorIdx);
- IVec3 &processActor = actor->_processActor;
- IVec3 mins = processActor + actor->_boundingBox.mins;
- IVec3 maxs = processActor + actor->_boundingBox.maxs;
+ IVec3 &processActor = ptrobj->_processActor;
+ IVec3 mins = processActor + ptrobj->_boundingBox.mins;
+ IVec3 maxs = processActor + ptrobj->_boundingBox.maxs;
- actor->_collision = -1;
+ ptrobj->_collision = -1;
- for (int32 a = 0; a < _engine->_scene->_sceneNumActors; a++) {
- ActorStruct *actorTest = _engine->_scene->getActor(a);
+ for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
+ ActorStruct *ptrobjt = _engine->_scene->getActor(a);
// avoid current processed actor
- if (a != actorIdx && actorTest->_body != -1 && !actor->_staticFlags.bIsHidden && actorTest->_carryBy != actorIdx) {
- const IVec3 &minsTest = actorTest->posObj() + actorTest->_boundingBox.mins;
- const IVec3 &maxsTest = actorTest->posObj() + actorTest->_boundingBox.maxs;
+ if (a != actorIdx && ptrobjt->_body != -1 && !ptrobj->_staticFlags.bIsHidden && ptrobjt->_carryBy != actorIdx) {
+ const IVec3 &minsTest = ptrobjt->posObj() + ptrobjt->_boundingBox.mins;
+ const IVec3 &maxsTest = ptrobjt->posObj() + ptrobjt->_boundingBox.maxs;
if (mins.x < maxsTest.x && maxs.x > minsTest.x && mins.y < maxsTest.y && maxs.y > minsTest.y && mins.z < maxsTest.z && maxs.z > minsTest.z) {
- actor->_collision = a; // mark as collision with actor a
+ ptrobj->_collision = a; // mark as collision with actor a
- if (actorTest->_staticFlags.bIsCarrierActor) {
- if (actor->_dynamicFlags.bIsFalling || checkZvOnZv(actorIdx, a)) {
- processActor.y = maxsTest.y - actor->_boundingBox.mins.y + 1;
- actor->_carryBy = a;
+ if (ptrobjt->_staticFlags.bIsCarrierActor) {
+ if (ptrobj->_dynamicFlags.bIsFalling) {
+ // I touch a carrier
+ processActor.y = maxsTest.y - ptrobj->_boundingBox.mins.y + 1;
+ ptrobj->_carryBy = a;
continue;
+ } else if (checkZvOnZv(actorIdx, a)) {
+ // I walk on a carrier
+ processActor.y = maxsTest.y - ptrobj->_boundingBox.mins.y + 1;
+ ptrobj->_carryBy = a;
+ continue;
+ }
+ } else {
+ // I step on someone
+ if (checkZvOnZv(actorIdx, a)) {
+ _engine->_actor->hitObj(actorIdx, a, 1, -1);
}
- } else if (checkZvOnZv(actorIdx, a)) {
- _engine->_actor->hitObj(actorIdx, a, 1, -1);
}
- handlePushing(minsTest, maxsTest, actor, actorTest);
+ handlePushing(processActor, minsTest, maxsTest, ptrobj, ptrobjt);
}
}
}
- if (actor->_dynamicFlags.bIsHitting) {
- const IVec2 &destPos = _engine->_renderer->rotate(0, 200, actor->_beta);
- mins = processActor + actor->_boundingBox.mins;
+ // test moves ZV further if hit
+ if (ptrobj->_dynamicFlags.bIsHitting) {
+ const IVec2 &destPos = _engine->_renderer->rotate(0, 200, ptrobj->_beta);
+ mins = processActor + ptrobj->_boundingBox.mins;
mins.x += destPos.x;
mins.z += destPos.y;
- maxs = processActor + actor->_boundingBox.maxs;
+ maxs = processActor + ptrobj->_boundingBox.maxs;
maxs.x += destPos.x;
maxs.z += destPos.y;
- for (int32 a = 0; a < _engine->_scene->_sceneNumActors; a++) {
+ for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
const ActorStruct *actorTest = _engine->_scene->getActor(a);
// avoid current processed actor
@@ -329,14 +339,14 @@ int32 Collision::checkObjCol(int32 actorIdx) {
const IVec3 minsTest = actorTest->posObj() + actorTest->_boundingBox.mins;
const IVec3 maxsTest = actorTest->posObj() + actorTest->_boundingBox.maxs;
if (mins.x < maxsTest.x && maxs.x > minsTest.x && mins.y < maxsTest.y && maxs.y > minsTest.y && mins.z < maxsTest.z && maxs.z > minsTest.z) {
- _engine->_actor->hitObj(actorIdx, a, actor->_strengthOfHit, actor->_beta + LBAAngles::ANGLE_180);
- actor->_dynamicFlags.bIsHitting = 0;
+ _engine->_actor->hitObj(actorIdx, a, ptrobj->_strengthOfHit, ptrobj->_beta + LBAAngles::ANGLE_180);
+ ptrobj->_dynamicFlags.bIsHitting = 0;
}
}
}
}
- return actor->_collision;
+ return ptrobj->_collision;
}
void Collision::setCollisionPos(const IVec3 &pos) {
@@ -358,7 +368,7 @@ void Collision::doCornerReajustTwinkel(ActorStruct *actor, int32 x, int32 y, int
brickShape = _engine->_grid->worldColBrickFull(processActor, bbox.maxs.y, OWN_ACTOR_SCENE_INDEX);
if (brickShape == ShapeType::kSolid) {
- _causeActorDamage |= damageMask;
+ _col1 |= damageMask;
brickShape = _engine->_grid->worldColBrickFull(processActor.x, processActor.y, previousActor.z + z, bbox.maxs.y, OWN_ACTOR_SCENE_INDEX);
if (brickShape == ShapeType::kSolid) {
@@ -390,7 +400,7 @@ void Collision::doCornerReajust(ActorStruct *actor, int32 x, int32 y, int32 z, i
brickShape = _engine->_grid->worldColBrick(processActor);
if (brickShape == ShapeType::kSolid) {
- _causeActorDamage |= damageMask;
+ _col1 |= damageMask;
brickShape = _engine->_grid->worldColBrick(processActor.x, processActor.y, previousActor.z + z);
if (brickShape == ShapeType::kSolid) {
@@ -447,7 +457,7 @@ int32 Collision::extraCheckObjCol(ExtraListStruct *extra, int32 actorIdx) {
const IVec3 mins = bbox->mins + extra->pos;
const IVec3 maxs = bbox->maxs + extra->pos;
- for (int32 a = 0; a < _engine->_scene->_sceneNumActors; a++) {
+ for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
const ActorStruct *actorTest = _engine->_scene->getActor(a);
if (a != actorIdx && actorTest->_body != -1) {
diff --git a/engines/twine/scene/collision.h b/engines/twine/scene/collision.h
index 561b9bd35b7..26d14c2432a 100644
--- a/engines/twine/scene/collision.h
+++ b/engines/twine/scene/collision.h
@@ -35,7 +35,7 @@ class Collision {
private:
TwinEEngine *_engine;
- void handlePushing(const IVec3 &minsTest, const IVec3 &maxsTest, ActorStruct *actor, ActorStruct *actorTest);
+ void handlePushing(IVec3 &processActor, const IVec3 &minsTest, const IVec3 &maxsTest, ActorStruct *actor, ActorStruct *actorTest);
/** Actor collision coordinate */
IVec3 _processCollision; // SaveNxw, SaveNyw, SaveNzw
@@ -45,7 +45,7 @@ public:
IVec3 _collision;
/** Cause damage in current processed actor */
- int32 _causeActorDamage = 0; //fieldCauseDamage
+ int32 _col1 = 0;
/**
* Check if actor 1 is standing in actor 2
@@ -54,7 +54,7 @@ public:
*/
bool checkZvOnZv(int32 actorIdx1, int32 actorIdx2) const;
- int32 clampedLerp(int32 start, int32 end, int32 maxDelay, int32 delay) const;
+ int32 boundRuleThree(int32 start, int32 end, int32 maxDelay, int32 delay) const;
/**
* Reajust actor position in scene according with brick shape bellow actor
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index 18766248baf..27de8bee206 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -501,7 +501,7 @@ void Extra::gereExtras() {
const int32 deltaT = _engine->timerRef - extra->spawnTime;
if (extra->type & ExtraType::EXPLOSION) {
- extra->sprite = _engine->_collision->clampedLerp(SPRITEHQR_EXPLOSION_FIRST_FRAME, 100, 30, deltaT);
+ extra->sprite = _engine->_collision->boundRuleThree(SPRITEHQR_EXPLOSION_FIRST_FRAME, 100, 30, deltaT);
continue;
}
// process extra moving
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 7ebb9cfcb39..2b84d624768 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -528,7 +528,7 @@ void GameState::processGameoverAnimation() {
return;
}
- zoom = _engine->_collision->clampedLerp(40000, 3200, _engine->toSeconds(10), _engine->timerRef - startLbaTime);
+ zoom = _engine->_collision->boundRuleThree(40000, 3200, _engine->toSeconds(10), _engine->timerRef - startLbaTime);
const int32 angle = _engine->_screens->lerp(1, LBAAngles::ANGLE_360, _engine->toSeconds(2), (_engine->timerRef - startLbaTime) % _engine->toSeconds(2));
_engine->blitWorkToFront(rect);
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index a6d3a08e7ba..65e7a6cdee6 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -604,7 +604,7 @@ const uint8 *Grid::getBlockBufferGround(const IVec3 &pos, int32 &ground) {
return ptr;
}
-const BlockDataEntry* Grid::getBlockPointer(int32 blockIdx, int32 brickIdx) const {
+const BlockDataEntry* Grid::getAdrBlock(int32 blockIdx, int32 brickIdx) const {
const BlockData *blockPtr = getBlockLibrary(blockIdx);
return &blockPtr->entries[brickIdx];
}
@@ -619,7 +619,7 @@ void Grid::getBrickPos(int32 x, int32 y, int32 z, int32 &posx, int32 &posy) cons
}
void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, int32 z) { // AffBrickBlock
- const BlockDataEntry *blockPtr = getBlockPointer(blockIdx, brickBlockIdx);
+ const BlockDataEntry *blockPtr = getAdrBlock(blockIdx, brickBlockIdx);
const uint8 brickShape = blockPtr->brickShape;
const uint8 brickSound = blockPtr->brickType;
const uint16 brickIdx = blockPtr->brickIdx;
@@ -696,7 +696,7 @@ BlockEntry Grid::getBlockEntry(int32 xmap, int32 ymap, int32 zmap) const {
const uint8 *pCube = _bufCube;
pCube += xmap * SIZE_CUBE_Y * 2;
pCube += ymap * 2;
- pCube += (zmap * SIZE_CUBE_X * 2) * SIZE_CUBE_Y;
+ pCube += zmap * (SIZE_CUBE_X * SIZE_CUBE_Y * 2);
BlockEntry entry;
entry.blockIdx = *pCube;
@@ -725,10 +725,10 @@ ShapeType Grid::worldColBrick(int32 x, int32 y, int32 z) {
const BlockEntry entry = getBlockEntry(collision.x, collision.y, collision.z);
if (entry.blockIdx) {
- const BlockDataEntry *blockPtr = getBlockPointer(entry.blockIdx, entry.brickBlockIdx);
+ const BlockDataEntry *blockPtr = getAdrBlock(entry.blockIdx, entry.brickBlockIdx);
return (ShapeType)blockPtr->brickShape;
}
- return (ShapeType)entry.brickBlockIdx;
+ return (ShapeType)entry.brickBlockIdx; // eventually transparent color
}
const IVec3 &Grid::updateCollisionCoordinates(int32 x, int32 y, int32 z) {
@@ -775,7 +775,7 @@ ShapeType Grid::worldColBrickFull(int32 x, int32 y, int32 z, int32 y2, int32 act
ShapeType brickShape;
const uint8 tmpBrickIdx = *(pCube + 1);
if (block) {
- const BlockDataEntry *blockPtr = getBlockPointer(block, tmpBrickIdx);
+ const BlockDataEntry *blockPtr = getAdrBlock(block, tmpBrickIdx);
if (checkWater && blockPtr->brickType == WATER_BRICK) {
brickShape = ShapeType::kSolid; // full collision
} else {
@@ -789,7 +789,7 @@ ShapeType Grid::worldColBrickFull(int32 x, int32 y, int32 z, int32 y2, int32 act
pCode -= 2;
uint8 code = *pCode;
if (code) {
- const BlockDataEntry *blockPtr = getBlockPointer(block, 0);
+ const BlockDataEntry *blockPtr = getAdrBlock(block, 0);
if (blockPtr->brickType == WATER_BRICK) {
// Special check mount funfrock
if (_engine->_scene->_currentSceneIdx != LBA1SceneId::Polar_Island_on_the_rocky_peak) {
@@ -822,7 +822,7 @@ uint8 Grid::worldCodeBrick(int32 x, int32 y, int32 z) {
const BlockEntry entry = getBlockEntry(collision.x, collision.y, collision.z);
if (entry.blockIdx) {
- const BlockDataEntry *blockPtr = getBlockPointer(entry.blockIdx, entry.brickBlockIdx);
+ const BlockDataEntry *blockPtr = getAdrBlock(entry.blockIdx, entry.brickBlockIdx);
code = blockPtr->brickType;
}
}
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index 5c86354088f..1533f606811 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -267,7 +267,7 @@ public:
* @return pointer to the current block index
*/
const BlockData *getBlockLibrary(int32 blockIdx) const;
- const BlockDataEntry* getBlockPointer(int32 blockIdx, int32 tmpBrickIdx) const;
+ const BlockDataEntry* getAdrBlock(int32 blockIdx, int32 tmpBrickIdx) const;
/** Create grid map from current grid to block library buffer */
void copyMapToCube();
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index 5993c03150f..1254b2f09ce 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -47,7 +47,7 @@ IVec3 Movements::getShadow(const IVec3 &pos) { // GetShadow
const int32 blockIdx = *ptr;
if (blockIdx) {
const int32 brickIdx = *(ptr + 1);
- const BlockDataEntry *blockPtr = _engine->_grid->getBlockPointer(blockIdx, brickIdx);
+ const BlockDataEntry *blockPtr = _engine->_grid->getAdrBlock(blockIdx, brickIdx);
shadowCollisionType = (ShapeType)blockPtr->brickShape;
} else {
shadowCollisionType = ShapeType::kNone;
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 19fa63113d5..3128041c78c 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -191,9 +191,9 @@ bool Scene::loadSceneLBA2() {
/*uint32 checksum =*/ stream.readUint32LE();
- _sceneNumActors = (int16)stream.readUint16LE();
+ _nbObjets = (int16)stream.readUint16LE();
int cnt = 1;
- for (int32 a = 1; a < _sceneNumActors; a++, cnt++) {
+ for (int32 a = 1; a < _nbObjets; a++, cnt++) {
_engine->_actor->resetActor(a);
ActorStruct *act = &_sceneActors[a];
setActorStaticFlags(act, stream.readUint32LE());
@@ -237,7 +237,7 @@ bool Scene::loadSceneLBA2() {
stream.skip(act->_lifeScriptSize);
if (_engine->_debugScene->_onlyLoadActor != -1 && _engine->_debugScene->_onlyLoadActor != cnt) {
- _sceneNumActors--;
+ _nbObjets--;
a--;
}
}
@@ -322,9 +322,9 @@ bool Scene::loadSceneLBA1() {
_sceneHero->_lifeScript = _currentScene + stream.pos();
stream.skip(_sceneHero->_lifeScriptSize);
- _sceneNumActors = (int16)stream.readUint16LE();
+ _nbObjets = (int16)stream.readUint16LE();
int cnt = 1;
- for (int32 a = 1; a < _sceneNumActors; a++, cnt++) {
+ for (int32 a = 1; a < _nbObjets; a++, cnt++) {
_engine->_actor->resetActor(a);
ActorStruct *act = &_sceneActors[a];
@@ -365,7 +365,7 @@ bool Scene::loadSceneLBA1() {
stream.skip(act->_lifeScriptSize);
if (_engine->_debugScene->_onlyLoadActor != -1 && _engine->_debugScene->_onlyLoadActor != cnt) {
- _sceneNumActors--;
+ _nbObjets--;
a--;
}
}
@@ -480,7 +480,7 @@ void Scene::dumpSceneScript(const char *type, int actorIdx, const uint8* script,
}
void Scene::dumpSceneScripts() const {
- for (int32 a = 0; a < _sceneNumActors; ++a) {
+ for (int32 a = 0; a < _nbObjets; ++a) {
const ActorStruct &actor = _sceneActors[a];
dumpSceneScript("life", a, actor._lifeScript, actor._lifeScriptSize);
dumpSceneScript("move", a, actor._moveScript, actor._moveScriptSize);
@@ -581,7 +581,7 @@ void Scene::changeScene() {
_engine->_actor->restartHeroScene();
- for (int32 a = 1; a < _sceneNumActors; a++) {
+ for (int32 a = 1; a < _nbObjets; a++) {
_engine->_actor->initActor(a);
}
@@ -634,7 +634,7 @@ void Scene::initSceneVars() {
_sampleRound[2] = 0;
_sampleRound[3] = 0;
- _sceneNumActors = 0;
+ _nbObjets = 0;
_sceneNumZones = 0;
_sceneNumTracks = 0;
}
diff --git a/engines/twine/scene/scene.h b/engines/twine/scene/scene.h
index 55e97fc74e2..378d487ae84 100644
--- a/engines/twine/scene/scene.h
+++ b/engines/twine/scene/scene.h
@@ -176,7 +176,7 @@ public:
ScenePositionType _heroPositionType = ScenePositionType::kNoPosition; // twinsenPositionModeInNewCube
// ACTORS
- int32 _sceneNumActors = 0;
+ int32 _nbObjets = 0;
ActorStruct *_sceneHero = nullptr;
/** Meca penguin actor index */
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 676012fc609..f1c67d35f03 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1141,7 +1141,7 @@ int32 ScriptLife::lGIVE_GOLD_PIECES(TwinEEngine *engine, LifeScriptContext &ctx)
for (int16 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
OverlayListStruct *overlay = &engine->_redraw->overlayList[i];
if (overlay->info0 != -1 && overlay->type == OverlayType::koNumberRange) {
- overlay->info0 = engine->_collision->clampedLerp(overlay->info1, overlay->info0, engine->toSeconds(2), overlay->lifeTime - engine->timerRef - engine->toSeconds(1));
+ overlay->info0 = engine->_collision->boundRuleThree(overlay->info1, overlay->info0, engine->toSeconds(2), overlay->lifeTime - engine->timerRef - engine->toSeconds(1));
overlay->info1 = engine->_gameState->_goldPieces;
overlay->lifeTime = engine->timerRef + engine->toSeconds(3);
hideRange = true;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 8d4ccb901ce..21bf101a394 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -965,13 +965,13 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
_scene->processEnvironmentSound();
// Reset HitBy state
- for (int32 a = 0; a < _scene->_sceneNumActors; a++) {
+ for (int32 a = 0; a < _scene->_nbObjets; a++) {
_scene->getActor(a)->_hitBy = -1;
}
_extra->gereExtras();
- for (int32 a = 0; a < _scene->_sceneNumActors; a++) {
+ for (int32 a = 0; a < _scene->_nbObjets; a++) {
ActorStruct *actor = _scene->getActor(a);
if (actor->_dynamicFlags.bIsDead) {
Commit: 0517e015fc706bbf1915d968594aed13af0887b1
https://github.com/scummvm/scummvm/commit/0517e015fc706bbf1915d968594aed13af0887b1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-02-06T18:57:54+01:00
Commit Message:
TWINE: unified with original sources and reduced the amount of globals
Changed paths:
engines/twine/scene/actor.h
engines/twine/scene/animations.cpp
engines/twine/scene/collision.cpp
engines/twine/scene/collision.h
engines/twine/script/script_life.cpp
engines/twine/twine.cpp
engines/twine/twine.h
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index e60bac539d6..d1d80b73333 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -191,8 +191,6 @@ public:
/** Process actor coordinate Nxw, Nyw, Nzw */
IVec3 _processActor;
- /** Previous process actor coordinate */
- IVec3 _previousActor;
IVec3 _oldPos;
int32 _offsetTrack = -1;
@@ -210,7 +208,7 @@ public:
/**
* colliding actor id
*/
- int32 _collision = -1; // ObjCol
+ int32 _objCol = -1; // ObjCol
/**
* actor id we are standing on
*/
@@ -277,8 +275,6 @@ private:
public:
Actor(TwinEEngine *engine);
- ActorStruct *_processActorPtr = nullptr;
-
HeroBehaviourType _heroBehaviour = HeroBehaviourType::kNormal; // Comportement
/** Hero auto aggressive mode */
bool _combatAuto = true;
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index c75fbc7a8b7..0b1b7455132 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -463,16 +463,13 @@ bool Animations::initAnim(AnimationTypes newAnim, AnimType flag, AnimationTypes
void Animations::doAnim(int32 actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
- _engine->_actor->_processActorPtr = actor;
-
if (actor->_body == -1) {
return;
}
- IVec3 &previousActor = actor->_previousActor;
- previousActor = actor->_oldPos;
+ const IVec3 oldPos = actor->_oldPos;
- IVec3 &processActor = actor->_processActor;
+ IVec3 processActor = actor->_processActor;
if (actor->_staticFlags.bIsSpriteActor) {
if (actor->_strengthOfHit) {
actor->_dynamicFlags.bIsHitting = 1;
@@ -638,39 +635,38 @@ void Animations::doAnim(int32 actorIdx) {
processActor -= standOnActor->_oldPos;
processActor += standOnActor->posObj();
- if (!collision->checkZvOnZv(actorIdx, actor->_carryBy)) {
+ if (!collision->checkZvOnZv(processActor, actorIdx, actor->_carryBy)) {
actor->_carryBy = -1; // no longer standing on other actor
}
}
// actor falling Y speed
if (actor->_dynamicFlags.bIsFalling) {
- processActor = previousActor;
- processActor.y += _engine->_loopActorStep; // add step to fall
+ processActor = oldPos;
+ processActor.y += _engine->_stepFalling; // add step to fall
}
// actor collisions with bricks
+ int32 col1 = 0;
if (actor->_staticFlags.bComputeCollisionWithBricks) {
- ShapeType brickShape = _engine->_grid->worldColBrick(previousActor);
+ ShapeType col = _engine->_grid->worldColBrick(oldPos);
- if (brickShape != ShapeType::kNone) {
- if (brickShape == ShapeType::kSolid) {
+ if (col != ShapeType::kNone) {
+ if (col == ShapeType::kSolid) {
actor->_pos.y = processActor.y = (processActor.y / SIZE_BRICK_Y) * SIZE_BRICK_Y + SIZE_BRICK_Y; // go upper
} else {
- collision->reajustPos(processActor, brickShape);
+ collision->reajustPos(processActor, col);
}
}
if (actor->_staticFlags.bComputeCollisionWithObj) {
- collision->checkObjCol(actorIdx);
+ collision->checkObjCol(processActor, oldPos, actorIdx);
}
if (actor->_carryBy != -1 && actor->_dynamicFlags.bIsFalling) {
- collision->receptionObj(actorIdx);
+ collision->receptionObj(processActor, actorIdx);
}
- collision->_col1 = 0;
-
// TODO: hack to fix tank-not-moving bug https://bugs.scummvm.org/ticket/13177
// remove processActorSave
const IVec3 processActorSave = processActor;
@@ -678,16 +674,16 @@ void Animations::doAnim(int32 actorIdx) {
if (IS_HERO(actorIdx) && !actor->_staticFlags.bComputeLowCollision) {
// check hero collisions with bricks
- collision->doCornerReajustTwinkel(actor, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 1);
- collision->doCornerReajustTwinkel(actor, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 2);
- collision->doCornerReajustTwinkel(actor, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 4);
- collision->doCornerReajustTwinkel(actor, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 8);
+ col1 |= collision->doCornerReajustTwinkel(actor, processActor, oldPos, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 1);
+ col1 |= collision->doCornerReajustTwinkel(actor, processActor, oldPos, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 2);
+ col1 |= collision->doCornerReajustTwinkel(actor, processActor, oldPos, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 4);
+ col1 |= collision->doCornerReajustTwinkel(actor, processActor, oldPos, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 8);
} else {
// check other actors collisions with bricks
- collision->doCornerReajust(actor, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 1);
- collision->doCornerReajust(actor, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 2);
- collision->doCornerReajust(actor, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 4);
- collision->doCornerReajust(actor, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 8);
+ col1 |= collision->doCornerReajust(processActor, oldPos, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 1);
+ col1 |= collision->doCornerReajust(processActor, oldPos, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 2);
+ col1 |= collision->doCornerReajust(processActor, oldPos, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 4);
+ col1 |= collision->doCornerReajust(processActor, oldPos, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 8);
}
// TODO: hack to fix tank-not-moving bug https://bugs.scummvm.org/ticket/13177
if (actorIdx == 1 && _engine->_scene->_currentSceneIdx == LBA1SceneId::Hamalayi_Mountains_2nd_fighting_scene) {
@@ -695,7 +691,7 @@ void Animations::doAnim(int32 actorIdx) {
}
// process wall hit while running
- if (collision->_col1 && !actor->_dynamicFlags.bIsFalling && IS_HERO(actorIdx) && _engine->_actor->_heroBehaviour == HeroBehaviourType::kAthletic && actor->_genAnim == AnimationTypes::kForward) {
+ if (col1 && !actor->_dynamicFlags.bIsFalling && IS_HERO(actorIdx) && _engine->_actor->_heroBehaviour == HeroBehaviourType::kAthletic && actor->_genAnim == AnimationTypes::kForward) {
IVec2 destPos = _engine->_renderer->rotate(actor->_boundingBox.mins.x, actor->_boundingBox.mins.z, actor->_beta + LBAAngles::LBAAngles::ANGLE_315 + LBAAngles::LBAAngles::ANGLE_180);
destPos.x += processActor.x;
@@ -715,13 +711,13 @@ void Animations::doAnim(int32 actorIdx) {
}
}
- brickShape = _engine->_grid->worldColBrick(processActor);
- actor->setCollision(brickShape);
+ col = _engine->_grid->worldColBrick(processActor);
+ actor->setCollision(col);
- if (brickShape != ShapeType::kNone) {
- if (brickShape == ShapeType::kSolid) {
+ if (col != ShapeType::kNone) {
+ if (col == ShapeType::kSolid) {
if (actor->_dynamicFlags.bIsFalling) {
- collision->receptionObj(actorIdx);
+ collision->receptionObj(processActor, actorIdx);
processActor.y = (collision->_collision.y * SIZE_BRICK_Y) + SIZE_BRICK_Y;
} else {
if (IS_HERO(actorIdx) && _engine->_actor->_heroBehaviour == HeroBehaviourType::kAthletic && actor->_genAnim == AnimationTypes::kForward && _engine->_cfgfile.WallCollision) { // avoid wall hit damage
@@ -732,35 +728,35 @@ void Animations::doAnim(int32 actorIdx) {
}
// no Z coordinate issue
- if (_engine->_grid->worldColBrick(processActor.x, processActor.y, previousActor.z) != ShapeType::kNone) {
- if (_engine->_grid->worldColBrick(previousActor.x, processActor.y, processActor.z) != ShapeType::kNone) {
+ if (_engine->_grid->worldColBrick(processActor.x, processActor.y, oldPos.z) != ShapeType::kNone) {
+ if (_engine->_grid->worldColBrick(oldPos.x, processActor.y, processActor.z) != ShapeType::kNone) {
return;
} else {
- processActor.x = previousActor.x;
+ processActor.x = oldPos.x;
}
} else {
- processActor.z = previousActor.z;
+ processActor.z = oldPos.z;
}
}
} else {
if (actor->_dynamicFlags.bIsFalling) {
- collision->receptionObj(actorIdx);
+ collision->receptionObj(processActor, actorIdx);
}
- collision->reajustPos(processActor, brickShape);
+ collision->reajustPos(processActor, col);
}
actor->_dynamicFlags.bIsFalling = 0;
} else {
if (actor->_staticFlags.bCanFall && actor->_carryBy == -1) {
- brickShape = _engine->_grid->worldColBrick(processActor.x, processActor.y - 1, processActor.z);
+ col = _engine->_grid->worldColBrick(processActor.x, processActor.y - 1, processActor.z);
- if (brickShape != ShapeType::kNone) {
+ if (col != ShapeType::kNone) {
if (actor->_dynamicFlags.bIsFalling) {
- collision->receptionObj(actorIdx);
+ collision->receptionObj(processActor, actorIdx);
}
- collision->reajustPos(processActor, brickShape);
+ collision->reajustPos(processActor, col);
} else {
if (!actor->_dynamicFlags.bIsRotationByAnim) {
actor->_dynamicFlags.bIsFalling = 1;
@@ -794,11 +790,11 @@ void Animations::doAnim(int32 actorIdx) {
}
} else {
if (actor->_staticFlags.bComputeCollisionWithObj) {
- collision->checkObjCol(actorIdx);
+ collision->checkObjCol(processActor, oldPos, actorIdx);
}
}
- if (collision->_col1) {
+ if (col1) {
actor->setBrickCausesDamage();
}
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index 890bd8f76b3..81e45e3af2d 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -40,11 +40,10 @@ namespace TwinE {
Collision::Collision(TwinEEngine *engine) : _engine(engine) {
}
-bool Collision::checkZvOnZv(int32 actorIdx1, int32 actorIdx2) const {
+bool Collision::checkZvOnZv(const IVec3 &processActor, int32 actorIdx1, int32 actorIdx2) const {
const ActorStruct *actor1 = _engine->_scene->getActor(actorIdx1);
const ActorStruct *actor2 = _engine->_scene->getActor(actorIdx2);
- const IVec3 &processActor = actor1->_processActor;
const IVec3 &mins1 = processActor + actor1->_boundingBox.mins;
const IVec3 &maxs1 = processActor + actor1->_boundingBox.maxs;
@@ -183,7 +182,7 @@ void Collision::reajustPos(IVec3 &processActor, ShapeType brickShape) const {
}
}
-void Collision::handlePushing(IVec3 &processActor, const IVec3 &minsTest, const IVec3 &maxsTest, ActorStruct *ptrobj, ActorStruct *ptrobjt) {
+void Collision::handlePushing(IVec3 &processActor, const IVec3 &oldPos, const IVec3 &minsTest, const IVec3 &maxsTest, ActorStruct *ptrobj, ActorStruct *ptrobjt) {
const int32 newAngle = _engine->_movements->getAngle(processActor, ptrobjt->posObj());
// protect against chain reactions
@@ -227,7 +226,7 @@ void Collision::handlePushing(IVec3 &processActor, const IVec3 &minsTest, const
}
} else if (!ptrobj->_dynamicFlags.bIsFalling) {
// refuse pos
- processActor = ptrobj->_previousActor;
+ processActor = oldPos;
}
}
@@ -277,14 +276,13 @@ bool Collision::checkValidObjPos(int32 actorIdx) {
return true;
}
-int32 Collision::checkObjCol(int32 actorIdx) {
+int32 Collision::checkObjCol(IVec3 &processActor, const IVec3 &oldPos, int32 actorIdx) {
ActorStruct *ptrobj = _engine->_scene->getActor(actorIdx);
- IVec3 &processActor = ptrobj->_processActor;
IVec3 mins = processActor + ptrobj->_boundingBox.mins;
IVec3 maxs = processActor + ptrobj->_boundingBox.maxs;
- ptrobj->_collision = -1;
+ ptrobj->_objCol = -1;
for (int32 a = 0; a < _engine->_scene->_nbObjets; a++) {
ActorStruct *ptrobjt = _engine->_scene->getActor(a);
@@ -295,7 +293,7 @@ int32 Collision::checkObjCol(int32 actorIdx) {
const IVec3 &maxsTest = ptrobjt->posObj() + ptrobjt->_boundingBox.maxs;
if (mins.x < maxsTest.x && maxs.x > minsTest.x && mins.y < maxsTest.y && maxs.y > minsTest.y && mins.z < maxsTest.z && maxs.z > minsTest.z) {
- ptrobj->_collision = a; // mark as collision with actor a
+ ptrobj->_objCol = a; // mark as collision with actor a
if (ptrobjt->_staticFlags.bIsCarrierActor) {
if (ptrobj->_dynamicFlags.bIsFalling) {
@@ -303,7 +301,7 @@ int32 Collision::checkObjCol(int32 actorIdx) {
processActor.y = maxsTest.y - ptrobj->_boundingBox.mins.y + 1;
ptrobj->_carryBy = a;
continue;
- } else if (checkZvOnZv(actorIdx, a)) {
+ } else if (checkZvOnZv(processActor, actorIdx, a)) {
// I walk on a carrier
processActor.y = maxsTest.y - ptrobj->_boundingBox.mins.y + 1;
ptrobj->_carryBy = a;
@@ -311,11 +309,11 @@ int32 Collision::checkObjCol(int32 actorIdx) {
}
} else {
// I step on someone
- if (checkZvOnZv(actorIdx, a)) {
+ if (checkZvOnZv(processActor, actorIdx, a)) {
_engine->_actor->hitObj(actorIdx, a, 1, -1);
}
}
- handlePushing(processActor, minsTest, maxsTest, ptrobj, ptrobjt);
+ handlePushing(processActor, oldPos, minsTest, maxsTest, ptrobj, ptrobjt);
}
}
}
@@ -335,7 +333,7 @@ int32 Collision::checkObjCol(int32 actorIdx) {
const ActorStruct *actorTest = _engine->_scene->getActor(a);
// avoid current processed actor
- if (a != actorIdx && actorTest->_body != -1 && !actorTest->_staticFlags.bIsHidden && actorTest->_carryBy != actorIdx) {
+ if (a != actorIdx && actorTest->_body != -1 && !ptrobj->_staticFlags.bIsHidden && actorTest->_carryBy != actorIdx) {
const IVec3 minsTest = actorTest->posObj() + actorTest->_boundingBox.mins;
const IVec3 maxsTest = actorTest->posObj() + actorTest->_boundingBox.maxs;
if (mins.x < maxsTest.x && maxs.x > minsTest.x && mins.y < maxsTest.y && maxs.y > minsTest.y && mins.z < maxsTest.z && maxs.z > minsTest.z) {
@@ -346,96 +344,88 @@ int32 Collision::checkObjCol(int32 actorIdx) {
}
}
- return ptrobj->_collision;
+ return ptrobj->_objCol;
}
void Collision::setCollisionPos(const IVec3 &pos) {
_processCollision = pos;
}
-void Collision::doCornerReajustTwinkel(ActorStruct *actor, int32 x, int32 y, int32 z, int32 damageMask) {
- IVec3 &processActor = actor->_processActor;
- IVec3 &previousActor = actor->_previousActor;
- ShapeType brickShape = _engine->_grid->worldColBrick(processActor);
+int32 Collision::doCornerReajustTwinkel(const ActorStruct *actor, IVec3 &processActor, const IVec3 &oldPos, int32 x, int32 y, int32 z, int32 damageMask) {
+ ShapeType orgcol = _engine->_grid->worldColBrick(processActor);
+ int32 _col1 = 0;
processActor.x += x;
processActor.y += y;
processActor.z += z;
if (processActor.x >= 0 && processActor.z >= 0 && processActor.x <= SCENE_SIZE_MAX && processActor.z <= SCENE_SIZE_MAX) {
- const BoundingBox &bbox = _engine->_actor->_processActorPtr->_boundingBox;
- reajustPos(processActor, brickShape);
- brickShape = _engine->_grid->worldColBrickFull(processActor, bbox.maxs.y, OWN_ACTOR_SCENE_INDEX);
+ const BoundingBox &bbox = actor->_boundingBox;
+ reajustPos(processActor, orgcol);
+ ShapeType col = _engine->_grid->worldColBrickFull(processActor, bbox.maxs.y, OWN_ACTOR_SCENE_INDEX);
- if (brickShape == ShapeType::kSolid) {
+ if (col == ShapeType::kSolid) {
_col1 |= damageMask;
- brickShape = _engine->_grid->worldColBrickFull(processActor.x, processActor.y, previousActor.z + z, bbox.maxs.y, OWN_ACTOR_SCENE_INDEX);
-
- if (brickShape == ShapeType::kSolid) {
- brickShape = _engine->_grid->worldColBrickFull(x + previousActor.x, processActor.y, processActor.z, bbox.maxs.y, OWN_ACTOR_SCENE_INDEX);
-
- if (brickShape != ShapeType::kSolid) {
- _processCollision.x = previousActor.x;
+ if (_engine->_grid->worldColBrickFull(processActor.x, processActor.y, oldPos.z + z, bbox.maxs.y, OWN_ACTOR_SCENE_INDEX) == ShapeType::kSolid) {
+ if (_engine->_grid->worldColBrickFull(x + oldPos.x, processActor.y, processActor.z, bbox.maxs.y, OWN_ACTOR_SCENE_INDEX) != ShapeType::kSolid) {
+ _processCollision.x = oldPos.x;
}
} else {
- _processCollision.z = previousActor.z;
+ _processCollision.z = oldPos.z;
}
}
}
processActor = _processCollision;
+ return _col1;
}
-void Collision::doCornerReajust(ActorStruct *actor, int32 x, int32 y, int32 z, int32 damageMask) {
- IVec3 &processActor = actor->_processActor;
- IVec3 &previousActor = actor->_previousActor;
- ShapeType brickShape = _engine->_grid->worldColBrick(processActor);
+int32 Collision::doCornerReajust(IVec3 &processActor, const IVec3 &oldPos, int32 x, int32 y, int32 z, int32 damageMask) {
+ ShapeType orgcol = _engine->_grid->worldColBrick(processActor);
+ int32 _col1 = 0;
processActor.x += x;
processActor.y += y;
processActor.z += z;
if (processActor.x >= 0 && processActor.z >= 0 && processActor.x <= SCENE_SIZE_MAX && processActor.z <= SCENE_SIZE_MAX) {
- reajustPos(processActor, brickShape);
- brickShape = _engine->_grid->worldColBrick(processActor);
+ reajustPos(processActor, orgcol);
+ ShapeType col = _engine->_grid->worldColBrick(processActor);
- if (brickShape == ShapeType::kSolid) {
+ if (col == ShapeType::kSolid) {
_col1 |= damageMask;
- brickShape = _engine->_grid->worldColBrick(processActor.x, processActor.y, previousActor.z + z);
-
- if (brickShape == ShapeType::kSolid) {
- brickShape = _engine->_grid->worldColBrick(x + previousActor.x, processActor.y, processActor.z);
-
- if (brickShape != ShapeType::kSolid) {
- _processCollision.x = previousActor.x;
+ if (_engine->_grid->worldColBrick(processActor.x, processActor.y, oldPos.z + z) == ShapeType::kSolid) {
+ if (_engine->_grid->worldColBrick(x + oldPos.x, processActor.y, processActor.z) != ShapeType::kSolid) {
+ _processCollision.x = oldPos.x;
}
} else {
- _processCollision.z = previousActor.z;
+ _processCollision.z = oldPos.z;
}
}
}
processActor = _processCollision;
+ return _col1;
}
-void Collision::receptionObj(int actorIdx) {
+void Collision::receptionObj(const IVec3 &processActor, int actorIdx) {
+ ActorStruct *actor = _engine->_scene->getActor(actorIdx);
if (IS_HERO(actorIdx)) {
- const IVec3 &processActor = _engine->_actor->_processActorPtr->_processActor;
const int32 fall = _engine->_scene->_startYFalling - processActor.y;
if (fall >= SIZE_BRICK_Y * 8) {
- const IVec3 &actorPos = _engine->_actor->_processActorPtr->posObj();
+ const IVec3 &actorPos = actor->posObj();
_engine->_extra->initSpecial(actorPos.x, actorPos.y + 1000, actorPos.z, ExtraSpecialType::kHitStars);
if (fall >= SIZE_BRICK_Y * 16) {
- _engine->_actor->_processActorPtr->setLife(0);
+ actor->setLife(0);
} else {
- _engine->_actor->_processActorPtr->addLife(-1);
+ actor->addLife(-1);
}
_engine->_animations->initAnim(AnimationTypes::kLandingHit, AnimType::kAnimationAllThen, AnimationTypes::kStanding, actorIdx);
} else if (fall > 2 * SIZE_BRICK_Y) {
_engine->_animations->initAnim(AnimationTypes::kLanding, AnimType::kAnimationAllThen, AnimationTypes::kStanding, actorIdx);
} else {
- if (_engine->_actor->_processActorPtr->_dynamicFlags.bWasWalkingBeforeFalling) {
+ if (actor->_dynamicFlags.bWasWalkingBeforeFalling) {
// try to not interrupt walk animation if Twinsen falls down from small height
_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, actorIdx);
} else {
@@ -445,11 +435,11 @@ void Collision::receptionObj(int actorIdx) {
_engine->_scene->_startYFalling = 0;
} else {
- _engine->_animations->initAnim(AnimationTypes::kLanding, AnimType::kAnimationAllThen, _engine->_actor->_processActorPtr->_nextGenAnim, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kLanding, AnimType::kAnimationAllThen, actor->_nextGenAnim, actorIdx);
}
- _engine->_actor->_processActorPtr->_dynamicFlags.bIsFalling = 0;
- _engine->_actor->_processActorPtr->_dynamicFlags.bWasWalkingBeforeFalling = 0;
+ actor->_dynamicFlags.bIsFalling = 0;
+ actor->_dynamicFlags.bWasWalkingBeforeFalling = 0;
}
int32 Collision::extraCheckObjCol(ExtraListStruct *extra, int32 actorIdx) {
diff --git a/engines/twine/scene/collision.h b/engines/twine/scene/collision.h
index 26d14c2432a..975e65b682b 100644
--- a/engines/twine/scene/collision.h
+++ b/engines/twine/scene/collision.h
@@ -35,24 +35,21 @@ class Collision {
private:
TwinEEngine *_engine;
- void handlePushing(IVec3 &processActor, const IVec3 &minsTest, const IVec3 &maxsTest, ActorStruct *actor, ActorStruct *actorTest);
+ void handlePushing(IVec3 &processActor, const IVec3 &oldPos, const IVec3 &minsTest, const IVec3 &maxsTest, ActorStruct *actor, ActorStruct *actorTest);
/** Actor collision coordinate */
IVec3 _processCollision; // SaveNxw, SaveNyw, SaveNzw
public:
Collision(TwinEEngine *engine);
/** Actor collision coordinate */
- IVec3 _collision;
-
- /** Cause damage in current processed actor */
- int32 _col1 = 0;
+ IVec3 _collision; // YMap
/**
* Check if actor 1 is standing in actor 2
* @param actorIdx1 Actor 1 index
* @param actorIdx2 Actor 2 index
*/
- bool checkZvOnZv(int32 actorIdx1, int32 actorIdx2) const;
+ bool checkZvOnZv(const IVec3 &processActor, int32 actorIdx1, int32 actorIdx2) const;
int32 boundRuleThree(int32 start, int32 end, int32 maxDelay, int32 delay) const;
@@ -66,7 +63,7 @@ public:
* Check collision with actors
* @param actorIx Current process actor index
*/
- int32 checkObjCol(int32 actorIdx);
+ int32 checkObjCol(IVec3 &processActor, const IVec3 &oldPos, int32 actorIdx);
bool checkValidObjPos(int32 actorIdx);
void setCollisionPos(const IVec3 &pos);
@@ -77,7 +74,7 @@ public:
* @param z Hero Z coordinate
* @param damageMask Cause damage mask
*/
- void doCornerReajustTwinkel(ActorStruct *actor, int32 x, int32 y, int32 z, int32 damageMask);
+ int32 doCornerReajustTwinkel(const ActorStruct *actor, IVec3 &processActor, const IVec3 &oldPos, int32 x, int32 y, int32 z, int32 damageMask);
/**
* Check other actor collision with bricks
@@ -86,10 +83,10 @@ public:
* @param z Actor Z coordinate
* @param damageMask Cause damage mask
*/
- void doCornerReajust(ActorStruct *actor, int32 x, int32 y, int32 z, int32 damageMask);
+ int32 doCornerReajust(IVec3 &processActor, const IVec3 &oldPos, int32 x, int32 y, int32 z, int32 damageMask);
/** Make actor to stop falling */
- void receptionObj(int actorIdx);
+ void receptionObj(const IVec3 &processActor, int actorIdx);
/**
* Check extra collision with actors
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index f1c67d35f03..bda8e65838a 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -125,7 +125,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
if (ctx.actor->_lifePoint <= 0) {
engine->_scene->_currentScriptValue = -1;
} else {
- engine->_scene->_currentScriptValue = ctx.actor->_collision;
+ engine->_scene->_currentScriptValue = ctx.actor->_objCol;
}
debugCN(3, kDebugLevels::kDebugScripts, "collision(");
break;
@@ -134,7 +134,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
if (engine->_scene->getActor(actorIdx)->_lifePoint <= 0) {
engine->_scene->_currentScriptValue = -1;
} else {
- engine->_scene->_currentScriptValue = engine->_scene->getActor(actorIdx)->_collision;
+ engine->_scene->_currentScriptValue = engine->_scene->getActor(actorIdx)->_objCol;
}
debugCN(3, kDebugLevels::kDebugScripts, "col_obj(%i, ", actorIdx);
break;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 21bf101a394..c1c109bef85 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -954,9 +954,9 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
}
}
- _loopActorStep = _loopMovePtr.getRealValueFromTime(timerRef);
- if (!_loopActorStep) {
- _loopActorStep = 1;
+ _stepFalling = _loopMovePtr.getRealValueFromTime(timerRef);
+ if (!_stepFalling) {
+ _stepFalling = 1;
}
_movements->setActorAngle(LBAAngles::ANGLE_0, -LBAAngles::ANGLE_90, LBAAngles::ANGLE_1, &_loopMovePtr);
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 9a7c6fe9bf2..c4ab49234b4 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -305,7 +305,7 @@ public:
int32 timerRef = 0;
int32 _loopInventoryItem = 0;
- int32 _loopActorStep = 0;
+ int32 _stepFalling = 0;
uint32 _gameFlags;
Common::Platform _platform;
Commit: ddb73bc158d97550a06d1a48475ac5500d36c5ed
https://github.com/scummvm/scummvm/commit/ddb73bc158d97550a06d1a48475ac5500d36c5ed
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-02-06T18:57:54+01:00
Commit Message:
TWINE: renamed variables to match original sources
Changed paths:
engines/twine/scene/actor.h
engines/twine/scene/animations.cpp
engines/twine/scene/collision.cpp
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index d1d80b73333..25cf19af0f8 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -136,7 +136,7 @@ struct BonusParameter {
class ActorStruct {
private:
ShapeType _col = ShapeType::kNone; // collision
- bool _brickCausesDamage = false; // TODO: this is a bitmask with multiple values in the original source
+ bool _brickCausesDamage = false;
EntityData _entityData;
public:
@@ -191,7 +191,7 @@ public:
/** Process actor coordinate Nxw, Nyw, Nzw */
IVec3 _processActor;
- IVec3 _oldPos;
+ IVec3 _oldPos; // OldPosX, OldPosY, OldPosZ
int32 _offsetTrack = -1;
uint8 *_moveScript = nullptr;
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index 0b1b7455132..e5329b46055 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -667,9 +667,6 @@ void Animations::doAnim(int32 actorIdx) {
collision->receptionObj(processActor, actorIdx);
}
- // TODO: hack to fix tank-not-moving bug https://bugs.scummvm.org/ticket/13177
- // remove processActorSave
- const IVec3 processActorSave = processActor;
collision->setCollisionPos(processActor);
if (IS_HERO(actorIdx) && !actor->_staticFlags.bComputeLowCollision) {
@@ -679,15 +676,18 @@ void Animations::doAnim(int32 actorIdx) {
col1 |= collision->doCornerReajustTwinkel(actor, processActor, oldPos, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 4);
col1 |= collision->doCornerReajustTwinkel(actor, processActor, oldPos, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 8);
} else {
+ // TODO: hack to fix tank-not-moving bug https://bugs.scummvm.org/ticket/13177
+ // remove processActorSave
+ const IVec3 processActorSave = processActor;
// check other actors collisions with bricks
col1 |= collision->doCornerReajust(processActor, oldPos, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 1);
col1 |= collision->doCornerReajust(processActor, oldPos, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.mins.z, 2);
col1 |= collision->doCornerReajust(processActor, oldPos, actor->_boundingBox.maxs.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 4);
col1 |= collision->doCornerReajust(processActor, oldPos, actor->_boundingBox.mins.x, actor->_boundingBox.mins.y, actor->_boundingBox.maxs.z, 8);
- }
- // TODO: hack to fix tank-not-moving bug https://bugs.scummvm.org/ticket/13177
- if (actorIdx == 1 && _engine->_scene->_currentSceneIdx == LBA1SceneId::Hamalayi_Mountains_2nd_fighting_scene) {
- processActor = processActorSave;
+ // TODO: hack to fix tank-not-moving bug https://bugs.scummvm.org/ticket/13177
+ if (actorIdx == 1 && _engine->_scene->_currentSceneIdx == LBA1SceneId::Hamalayi_Mountains_2nd_fighting_scene) {
+ processActor = processActorSave;
+ }
}
// process wall hit while running
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index 81e45e3af2d..cf0724fa0b7 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -231,43 +231,43 @@ void Collision::handlePushing(IVec3 &processActor, const IVec3 &oldPos, const IV
}
bool Collision::checkValidObjPos(int32 actorIdx) {
- const ActorStruct *actor = _engine->_scene->getActor(actorIdx);
+ const ActorStruct *ptrobj = _engine->_scene->getActor(actorIdx);
- const IVec3 m0 = actor->posObj() + actor->_boundingBox.mins;
- const IVec3 m1 = actor->posObj() + actor->_boundingBox.maxs;
+ const IVec3 m0 = ptrobj->posObj() + ptrobj->_boundingBox.mins;
+ const IVec3 m1 = ptrobj->posObj() + ptrobj->_boundingBox.maxs;
- if (m0.x < 0 || m0.x > SIZE_BRICK_XZ * 63) {
+ if (m0.x < 0 || m0.x > SIZE_BRICK_XZ * (SIZE_CUBE_X - 1)) {
return false;
}
- if (m1.x < 0 || m1.x > SIZE_BRICK_XZ * 63) {
+ if (m1.x < 0 || m1.x > SIZE_BRICK_XZ * (SIZE_CUBE_X - 1)) {
return false;
}
- if (m0.z < 0 || m0.z > SIZE_BRICK_XZ * 63) {
+ if (m0.z < 0 || m0.z > SIZE_BRICK_XZ * (SIZE_CUBE_X - 1)) {
return false;
}
- if (m1.z < 0 || m1.z > SIZE_BRICK_XZ * 63) {
+ if (m1.z < 0 || m1.z > SIZE_BRICK_XZ * (SIZE_CUBE_X - 1)) {
return false;
}
Grid *grid = _engine->_grid;
- if (grid->worldColBrickFull(m0.x, m0.y, m0.z, actor->_boundingBox.maxs.y, actorIdx) != ShapeType::kNone) {
+ if (grid->worldColBrickFull(m0.x, m0.y, m0.z, ptrobj->_boundingBox.maxs.y, actorIdx) != ShapeType::kNone) {
return false;
}
- if (grid->worldColBrickFull(m1.x, m0.y, m0.z, actor->_boundingBox.maxs.y, actorIdx) != ShapeType::kNone) {
+ if (grid->worldColBrickFull(m1.x, m0.y, m0.z, ptrobj->_boundingBox.maxs.y, actorIdx) != ShapeType::kNone) {
return false;
}
- if (grid->worldColBrickFull(m1.x, m0.y, m1.z, actor->_boundingBox.maxs.y, actorIdx) != ShapeType::kNone) {
+ if (grid->worldColBrickFull(m1.x, m0.y, m1.z, ptrobj->_boundingBox.maxs.y, actorIdx) != ShapeType::kNone) {
return false;
}
- if (grid->worldColBrickFull(m0.x, m0.y, m1.z, actor->_boundingBox.maxs.y, actorIdx) != ShapeType::kNone) {
+ if (grid->worldColBrickFull(m0.x, m0.y, m1.z, ptrobj->_boundingBox.maxs.y, actorIdx) != ShapeType::kNone) {
return false;
}
for (int32 n = 0; n < _engine->_scene->_nbObjets; ++n) {
- const ActorStruct *actorTest = _engine->_scene->getActor(n);
- if (n != actorIdx && actorTest->_body != -1 && !actor->_staticFlags.bIsHidden && actorTest->_carryBy != actorIdx) {
- const IVec3 &t0 = actorTest->posObj() + actorTest->_boundingBox.mins;
- const IVec3 &t1 = actorTest->posObj() + actorTest->_boundingBox.maxs;
+ const ActorStruct *ptrobjt = _engine->_scene->getActor(n);
+ if (n != actorIdx && ptrobjt->_body != -1 && !ptrobj->_staticFlags.bIsHidden && ptrobjt->_carryBy != actorIdx) {
+ const IVec3 &t0 = ptrobjt->posObj() + ptrobjt->_boundingBox.mins;
+ const IVec3 &t1 = ptrobjt->posObj() + ptrobjt->_boundingBox.maxs;
if (m0.x < t1.x && m1.x > t0.x && m0.y < t1.y && m1.y > t0.y && m0.z < t1.z && m1.z > t0.z) {
return false;
}
Commit: 9c76b8689ec229ba6a06c6d46096bc8f648e7caa
https://github.com/scummvm/scummvm/commit/9c76b8689ec229ba6a06c6d46096bc8f648e7caa
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-02-06T18:57:54+01:00
Commit Message:
TWINE: use toSeconds
Changed paths:
engines/twine/scene/movements.cpp
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index 1254b2f09ce..e3111d5047c 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -434,7 +434,7 @@ void Movements::processRandomAction(int actorIdx) {
if (actor->brickCausesDamage()) {
const int32 angle = ClampAngle(actor->_beta + (_engine->getRandomNumber() & (LBAAngles::ANGLE_180 - 1)) - LBAAngles::ANGLE_90 + LBAAngles::ANGLE_180);
initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->realAngle);
- actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->timerRef + 300;
+ actor->_delayInMillis = _engine->timerRef + _engine->getRandomNumber(_engine->toSeconds(6)) + _engine->toSeconds(6);
_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
}
@@ -443,7 +443,7 @@ void Movements::processRandomAction(int actorIdx) {
if (_engine->timerRef > actor->_delayInMillis) {
const int32 angle = ClampAngle(actor->_beta + (_engine->getRandomNumber() & (LBAAngles::ANGLE_180 - 1)) - LBAAngles::ANGLE_90);
initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->realAngle);
- actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->timerRef + 300;
+ actor->_delayInMillis = _engine->timerRef + _engine->getRandomNumber(_engine->toSeconds(6)) + _engine->toSeconds(6);
}
}
}
Commit: c6b0b8ecefbc73a891382423b93a7a648edffc86
https://github.com/scummvm/scummvm/commit/c6b0b8ecefbc73a891382423b93a7a648edffc86
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-02-06T18:57:54+01:00
Commit Message:
TWINE: replaced with macro
Changed paths:
engines/twine/scene/collision.cpp
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index cf0724fa0b7..d081008c1ed 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -236,16 +236,16 @@ bool Collision::checkValidObjPos(int32 actorIdx) {
const IVec3 m0 = ptrobj->posObj() + ptrobj->_boundingBox.mins;
const IVec3 m1 = ptrobj->posObj() + ptrobj->_boundingBox.maxs;
- if (m0.x < 0 || m0.x > SIZE_BRICK_XZ * (SIZE_CUBE_X - 1)) {
+ if (m0.x < 0 || m0.x > SCENE_SIZE_MAX) {
return false;
}
- if (m1.x < 0 || m1.x > SIZE_BRICK_XZ * (SIZE_CUBE_X - 1)) {
+ if (m1.x < 0 || m1.x > SCENE_SIZE_MAX) {
return false;
}
- if (m0.z < 0 || m0.z > SIZE_BRICK_XZ * (SIZE_CUBE_X - 1)) {
+ if (m0.z < 0 || m0.z > SCENE_SIZE_MAX) {
return false;
}
- if (m1.z < 0 || m1.z > SIZE_BRICK_XZ * (SIZE_CUBE_X - 1)) {
+ if (m1.z < 0 || m1.z > SCENE_SIZE_MAX) {
return false;
}
Commit: e0051c2aa881cb713910130179d1ccf26e1c4e1f
https://github.com/scummvm/scummvm/commit/e0051c2aa881cb713910130179d1ccf26e1c4e1f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-02-06T18:57:54+01:00
Commit Message:
TWINE: fixed LBAAngles usage
Changed paths:
engines/twine/scene/animations.cpp
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index e5329b46055..61434f551f8 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -454,7 +454,7 @@ bool Animations::initAnim(AnimationTypes newAnim, AnimType flag, AnimationTypes
processAnimActions(actorIdx);
- actor->_animStepBeta = LBAAngles::LBAAngles::ANGLE_0;
+ actor->_animStepBeta = LBAAngles::ANGLE_0;
actor->_animStep = IVec3();
return true;
@@ -497,18 +497,18 @@ void Animations::doAnim(int32 actorIdx) {
processActor.x = actor->_pos.x + destPos.x;
processActor.z = actor->_pos.z + destPos.y;
- _engine->_movements->setActorAngle(LBAAngles::LBAAngles::ANGLE_0, actor->_speed, LBAAngles::LBAAngles::ANGLE_17, &actor->realAngle);
+ _engine->_movements->setActorAngle(LBAAngles::ANGLE_0, actor->_speed, LBAAngles::ANGLE_17, &actor->realAngle);
if (actor->_dynamicFlags.bIsSpriteMoving) {
if (actor->_doorWidth) { // open door
if (getDistance2D(processActor.x, processActor.z, actor->_animStep.x, actor->_animStep.z) >= actor->_doorWidth) {
- if (actor->_beta == LBAAngles::LBAAngles::ANGLE_0) { // down
+ if (actor->_beta == LBAAngles::ANGLE_0) { // down
processActor.z = actor->_animStep.z + actor->_doorWidth;
- } else if (actor->_beta == LBAAngles::LBAAngles::ANGLE_90) { // right
+ } else if (actor->_beta == LBAAngles::ANGLE_90) { // right
processActor.x = actor->_animStep.x + actor->_doorWidth;
- } else if (actor->_beta == LBAAngles::LBAAngles::ANGLE_180) { // up
+ } else if (actor->_beta == LBAAngles::ANGLE_180) { // up
processActor.z = actor->_animStep.z - actor->_doorWidth;
- } else if (actor->_beta == LBAAngles::LBAAngles::ANGLE_270) { // left
+ } else if (actor->_beta == LBAAngles::ANGLE_270) { // left
processActor.x = actor->_animStep.x - actor->_doorWidth;
}
@@ -518,19 +518,19 @@ void Animations::doAnim(int32 actorIdx) {
} else { // close door
bool updatePos = false;
- if (actor->_beta == LBAAngles::LBAAngles::ANGLE_0) { // down
+ if (actor->_beta == LBAAngles::ANGLE_0) { // down
if (processActor.z <= actor->_animStep.z) {
updatePos = true;
}
- } else if (actor->_beta == LBAAngles::LBAAngles::ANGLE_90) { // right
+ } else if (actor->_beta == LBAAngles::ANGLE_90) { // right
if (processActor.x <= actor->_animStep.x) {
updatePos = true;
}
- } else if (actor->_beta == LBAAngles::LBAAngles::ANGLE_180) { // up
+ } else if (actor->_beta == LBAAngles::ANGLE_180) { // up
if (processActor.z >= actor->_animStep.z) {
updatePos = true;
}
- } else if (actor->_beta == LBAAngles::LBAAngles::ANGLE_270) { // left
+ } else if (actor->_beta == LBAAngles::ANGLE_270) { // left
if (processActor.x >= actor->_animStep.x) {
updatePos = true;
}
@@ -621,7 +621,7 @@ void Animations::doAnim(int32 actorIdx) {
actor->_dynamicFlags.bAnimEnded = 1;
}
- actor->_animStepBeta = LBAAngles::LBAAngles::ANGLE_0;
+ actor->_animStepBeta = LBAAngles::ANGLE_0;
actor->_animStep = IVec3();
}
@@ -692,7 +692,7 @@ void Animations::doAnim(int32 actorIdx) {
// process wall hit while running
if (col1 && !actor->_dynamicFlags.bIsFalling && IS_HERO(actorIdx) && _engine->_actor->_heroBehaviour == HeroBehaviourType::kAthletic && actor->_genAnim == AnimationTypes::kForward) {
- IVec2 destPos = _engine->_renderer->rotate(actor->_boundingBox.mins.x, actor->_boundingBox.mins.z, actor->_beta + LBAAngles::LBAAngles::ANGLE_315 + LBAAngles::LBAAngles::ANGLE_180);
+ IVec2 destPos = _engine->_renderer->rotate(actor->_boundingBox.mins.x, actor->_boundingBox.mins.z, actor->_beta + LBAAngles::ANGLE_315 + LBAAngles::ANGLE_180);
destPos.x += processActor.x;
destPos.y += processActor.z;
Commit: 8655f6b978c5a06a59b67889794e96001d43f6cd
https://github.com/scummvm/scummvm/commit/8655f6b978c5a06a59b67889794e96001d43f6cd
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-02-06T19:04:39+01:00
Commit Message:
TWINE: further renaming
Changed paths:
engines/twine/holomap.cpp
engines/twine/menu/menuoptions.cpp
engines/twine/script/script_life.cpp
engines/twine/text.cpp
engines/twine/text.h
engines/twine/twine.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 975af4abbd6..48e834920f3 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -503,6 +503,7 @@ void Holomap::drawListPos(int calpha, int cbeta, int cgamma, bool pos) {
const int32 angleX = _locations[drawList.actorIdx].angleX;
const int32 angleY = _locations[drawList.actorIdx].angleY;
Common::Rect dummy;
+ // first scene with twinsen model: x = 0, y = -497, z -764, a 432, b: 172
_engine->_renderer->affObjetIso(drawList.x, drawList.y, drawList.z, angleX, angleY, LBAAngles::ANGLE_0, *bodyData, dummy);
}
}
diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index 94034f0755d..3ba28970444 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -59,7 +59,7 @@ void MenuOptions::newGame() {
_engine->_text->_renderTextTriangle = true;
_engine->_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
- _engine->_text->textClipFull();
+ _engine->_text->bigWinDial();
_engine->_text->setFontCrossColor(COLOR_WHITE);
bool aborted = _engine->_text->drawTextProgressive(TextId::kIntroText1);
@@ -84,7 +84,7 @@ void MenuOptions::newGame() {
_engine->_movie->playMovie(FLA_INTROD);
}
- _engine->_text->textClipSmall();
+ _engine->_text->normalWinDial();
} else {
_engine->_movie->playMovie(ACF_INTRO);
}
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index bda8e65838a..8a1f345020b 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1604,14 +1604,14 @@ int32 ScriptLife::lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
debugC(3, kDebugLevels::kDebugScripts, "LIFE::BIG_MESSAGE(%i)", (int)textIdx);
ScopedEngineFreeze scopedFreeze(engine);
- engine->_text->textClipFull();
+ engine->_text->bigWinDial();
if (engine->_text->_showDialogueBubble) {
engine->_redraw->drawBubble(ctx.actorIdx);
}
engine->_text->setFontCrossColor(ctx.actor->_talkColor);
engine->_scene->_talkingActor = ctx.actorIdx;
engine->_text->drawTextProgressive(textIdx);
- engine->_text->textClipSmall();
+ engine->_text->normalWinDial();
engine->_redraw->redrawEngineActions(true);
return 0;
@@ -1927,7 +1927,7 @@ int32 ScriptLife::lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx)
ScopedEngineFreeze scoped(engine);
engine->_screens->fadeToBlack(engine->_screens->_paletteRGBA);
engine->_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 25, 26));
- engine->_text->textClipFull();
+ engine->_text->bigWinDial();
engine->_text->setFontCrossColor(COLOR_WHITE);
engine->_text->_drawTextBoxBackground = false;
const bool tmpFlagDisplayText = engine->_cfgfile.FlagDisplayText;
@@ -1935,7 +1935,7 @@ int32 ScriptLife::lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx)
engine->_text->drawTextProgressive(TextId::kSendell);
engine->_cfgfile.FlagDisplayText = tmpFlagDisplayText;
engine->_text->_drawTextBoxBackground = true;
- engine->_text->textClipSmall();
+ engine->_text->normalWinDial();
engine->_screens->fadeToBlack(engine->_screens->_paletteRGBACustom);
engine->_screens->clearScreen();
engine->setPalette(engine->_screens->_paletteRGBA);
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 6ec91ac80a1..e3300a4fa7f 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -657,7 +657,7 @@ bool Text::displayText(TextId index, bool showText, bool playVox, bool loop) {
return aborted;
}
-bool Text::drawTextProgressive(TextId index, bool playVox, bool loop) {
+bool Text::drawTextProgressive(TextId index, bool playVox, bool loop) { // Dial
_engine->exitSceneryView();
_engine->_interface->memoClip();
_engine->_interface->unsetClip();
@@ -731,7 +731,7 @@ bool Text::getMenuText(TextId index, char *text, uint32 textSize) {
return true;
}
-void Text::textClipFull() {
+void Text::bigWinDial() {
const int32 margin = 8;
_dialTextBox.left = margin;
_dialTextBox.top = margin;
@@ -742,7 +742,7 @@ void Text::textClipFull() {
_dialTextBoxMaxX = _engine->width() - 2 * margin - 2 * PADDING;
}
-void Text::textClipSmall() {
+void Text::normalWinDial() {
const int32 margin = 16;
_dialTextBoxLines = 3;
const int32 textHeight = _dialTextBoxLines * lineHeight;
@@ -760,7 +760,7 @@ void Text::drawAskQuestion(TextId index) {
}
void Text::drawHolomapLocation(TextId index) {
- textClipSmall();
+ normalWinDial();
setFontCrossColor(COLOR_WHITE);
_engine->_interface->drawFilledRect(_dialTextBox, COLOR_BLACK);
const bool displayText = _engine->_cfgfile.FlagDisplayText;
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 6977040e8cb..4c427514c06 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -237,8 +237,8 @@ public:
*/
bool getMenuText(TextId index, char *text, uint32 textSize);
- void textClipFull();
- void textClipSmall();
+ void bigWinDial();
+ void normalWinDial();
void drawAskQuestion(TextId index);
void drawHolomapLocation(TextId index);
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index c1c109bef85..d4944d3dbb5 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -317,7 +317,7 @@ Common::Error TwinEEngine::run() {
} else {
debug("Boot parameter: %i\n", sceneIndex);
_gameState->initEngineVars();
- _text->textClipSmall();
+ _text->normalWinDial();
_text->_drawTextBoxBackground = true;
_text->_renderTextTriangle = false;
_scene->_needChangeScene = sceneIndex;
@@ -340,7 +340,7 @@ Common::Error TwinEEngine::run() {
_scene->_heroPositionType = ScenePositionType::kNoPosition;
}
_text->_renderTextTriangle = false;
- _text->textClipSmall();
+ _text->normalWinDial();
_text->_drawTextBoxBackground = true;
_state = EngineState::GameLoop;
break;
@@ -674,13 +674,13 @@ void TwinEEngine::processBookOfBu() {
_screens->loadImage(TwineImage(Resources::HQR_RESS_FILE, 15, 16));
_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
_text->_drawTextBoxBackground = false;
- _text->textClipFull();
+ _text->bigWinDial();
_text->setFontCrossColor(COLOR_WHITE);
const bool tmpFlagDisplayText = _cfgfile.FlagDisplayText;
_cfgfile.FlagDisplayText = true;
_text->drawTextProgressive(TextId::kBookOfBu);
_cfgfile.FlagDisplayText = tmpFlagDisplayText;
- _text->textClipSmall();
+ _text->normalWinDial();
_text->_drawTextBoxBackground = true;
_text->initSceneTextBank();
_screens->fadeToBlack(_screens->_paletteRGBACustom);
@@ -692,13 +692,13 @@ void TwinEEngine::processBookOfBu() {
void TwinEEngine::processBonusList() {
_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
- _text->textClipFull();
+ _text->bigWinDial();
_text->setFontCrossColor(COLOR_WHITE);
const bool tmpFlagDisplayText = _cfgfile.FlagDisplayText;
_cfgfile.FlagDisplayText = true;
_text->drawTextProgressive(TextId::kBonusList);
_cfgfile.FlagDisplayText = tmpFlagDisplayText;
- _text->textClipSmall();
+ _text->normalWinDial();
_text->initSceneTextBank();
}
More information about the Scummvm-git-logs
mailing list