[Scummvm-git-logs] scummvm master -> 298dd1f4686b968b0561433c1ac03e32004e364b
mgerhardy
martin.gerhardy at gmail.com
Mon Dec 7 16:08:17 UTC 2020
This automated email contains information about 14 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ec503b7b89 TWINE: use OverlayType and OverlayPosType enums
9d8eaa3f97 TWINE: converted to enum class
4010c23d69 TWINE: replaced magic numbers
a4b236b2ce TWINE: renamed variable
346b5b9f4d TWINE: added ExtraType bit values as enum and renamed member
d6031e74d6 TWINE: replaced magic numbers with ExtraType constants
4c04e76adb TWINE: replaced magic numbers with ExtraType constants
26f72efe84 TWINE: replaced magic number for angle
5445b17344 TWINE: renamed struct members and stack vars
ddc7e22753 TWINE: renamed members + const
ae7e2c0eda TWINE: const + converted to bool
3747cdd901 TWINE: helper method to check model header value
ef92147a25 TWINE: cleanup in animation code
298dd1f468 TWINE: cleanup in animation code
Commit: ec503b7b898f2871b038e981777d4c3f09e742f0
https://github.com/scummvm/scummvm/commit/ec503b7b898f2871b038e981777d4c3f09e742f0
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T16:58:52+01:00
Commit Message:
TWINE: use OverlayType and OverlayPosType enums
Changed paths:
engines/twine/extra.cpp
engines/twine/grid.cpp
engines/twine/redraw.cpp
engines/twine/redraw.h
engines/twine/sound.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 6c3ff35c9e..c35775dbe6 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -698,10 +698,10 @@ void Extra::processExtras() {
if (extraKey->info1 > 1) {
_engine->_renderer->projectPositionOnScreen(extraKey->x - _engine->_grid->cameraX, extraKey->y - _engine->_grid->cameraY, extraKey->z - _engine->_grid->cameraZ);
- _engine->_redraw->addOverlay(koNumber, extraKey->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, koNormal, 0, 2);
+ _engine->_redraw->addOverlay(koNumber, extraKey->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 0, koNormal, 2);
}
- _engine->_redraw->addOverlay(koSprite, SPRITEHQR_KEY, 10, 30, koNormal, 0, 2);
+ _engine->_redraw->addOverlay(koSprite, SPRITEHQR_KEY, 10, 30, 0, koNormal, 2);
_engine->_gameState->inventoryNumKeys += extraKey->info1;
extraKey->info0 = -1;
@@ -731,10 +731,10 @@ void Extra::processExtras() {
if (extraKey->info1 > 1) {
_engine->_renderer->projectPositionOnScreen(extraKey->x - _engine->_grid->cameraX, extraKey->y - _engine->_grid->cameraY, extraKey->z - _engine->_grid->cameraZ);
- _engine->_redraw->addOverlay(koNumber, extraKey->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, koNormal, 0, 2);
+ _engine->_redraw->addOverlay(koNumber, extraKey->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 0, koNormal, 2);
}
- _engine->_redraw->addOverlay(koSprite, SPRITEHQR_KEY, 10, 30, koNormal, 0, 2);
+ _engine->_redraw->addOverlay(koSprite, SPRITEHQR_KEY, 10, 30, 0, koNormal, 2);
_engine->_gameState->inventoryNumKeys += extraKey->info1;
extraKey->info0 = -1;
diff --git a/engines/twine/grid.cpp b/engines/twine/grid.cpp
index 6b93bde112..c9866a24dc 100644
--- a/engines/twine/grid.cpp
+++ b/engines/twine/grid.cpp
@@ -724,12 +724,12 @@ ShapeType Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
blockPtr += READ_LE_UINT32(blockPtr + blockIdx * 4 - 4);
blockPtr += 3;
- uint8 tmpBrickIdx = *(blockBufferPtr + 1);
+ const uint8 tmpBrickIdx = *(blockBufferPtr + 1);
blockPtr = blockPtr + tmpBrickIdx * 4;
- ShapeType brickShape = (ShapeType)*blockPtr;
+ const ShapeType brickShape = (ShapeType)*blockPtr;
- int32 newY = (y2 + 255) >> 8;
+ const int32 newY = (y2 + 255) >> 8;
int32 currY = _engine->_collision->collisionY;
for (int32 i = 0; i < newY; i++) {
@@ -747,9 +747,9 @@ ShapeType Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
return brickShape;
}
- ShapeType brickShape = (ShapeType)*(blockBufferPtr + 1);
+ const ShapeType brickShape = (ShapeType)*(blockBufferPtr + 1);
- int32 newY = (y2 + 255) >> 8;
+ const int32 newY = (y2 + 255) >> 8;
int32 currY = _engine->_collision->collisionY;
for (int32 i = 0; i < newY; i++) {
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 54ebcf667a..95f78928ec 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -176,7 +176,7 @@ void Redraw::sortDrawingList(DrawListStruct *list, int32 listSize) {
}
}
-void Redraw::addOverlay(int16 type, int16 info0, int16 x, int16 y, int16 info1, int16 posType, int16 lifeTime) {
+void Redraw::addOverlay(OverlayType type, int16 info0, int16 x, int16 y, int16 info1, OverlayPosType posType, int16 lifeTime) {
for (int32 i = 0; i < ARRAYSIZE(overlayList); i++) {
OverlayListStruct *overlay = &overlayList[i];
if (overlay->info0 == -1) {
diff --git a/engines/twine/redraw.h b/engines/twine/redraw.h
index 3b814d961f..9aeb2e7491 100644
--- a/engines/twine/redraw.h
+++ b/engines/twine/redraw.h
@@ -45,12 +45,12 @@ enum OverlayPosType {
/** Overlay list structure */
struct OverlayListStruct {
- int16 type = 0;
+ OverlayType type = koSprite;
int16 info0 = 0; // sprite/3d model entry | number | number range
int16 x = 0;
int16 y = 0;
int16 info1 = 0; // followed actor | total coins
- int16 posType = 0;
+ OverlayPosType posType = koNormal;
int16 lifeTime = 0;
};
@@ -117,7 +117,7 @@ public:
OverlayListStruct overlayList[OVERLAY_MAX_ENTRIES];
- void addOverlay(int16 type, int16 info0, int16 x, int16 y, int16 info1, int16 posType, int16 lifeTime);
+ void addOverlay(OverlayType type, int16 info0, int16 x, int16 y, int16 info1, OverlayPosType posType, int16 lifeTime);
/**
* Add a certain region to redraw list array
diff --git a/engines/twine/sound.cpp b/engines/twine/sound.cpp
index fb875fd8f7..43eb6aafa0 100644
--- a/engines/twine/sound.cpp
+++ b/engines/twine/sound.cpp
@@ -54,10 +54,6 @@ void Sound::setSamplePosition(int32 channelIdx, int32 x, int32 y, int32 z) {
const int32 camZ = _engine->_grid->newCameraZ << 9;
int32 distance = _engine->_movements->getDistance3D(camX, camY, camZ, x, y, z);
distance = _engine->_collision->getAverageValue(0, distance, 10000, 255);
- if (distance > 255) { // don't play it if its to far away
- distance = 255;
- }
-
const byte targetVolume = CLIP(255 - distance, 0, 255);
_engine->_system->getMixer()->setChannelVolume(samplesPlaying[channelIdx], targetVolume);
}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 759ed8ab67..4668941da3 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -599,12 +599,12 @@ void TwinEEngine::centerScreenOnActor() {
_grid->newCameraY = actor->y >> 8;
_grid->newCameraZ = ((actor->z + 0x100) >> 9) + (((actor->z + 0x100) >> 9) - _grid->newCameraZ) / 2;
- if (_grid->newCameraX >= 64) {
- _grid->newCameraX = 63;
+ if (_grid->newCameraX >= GRID_SIZE_X) {
+ _grid->newCameraX = GRID_SIZE_X - 1;
}
- if (_grid->newCameraZ >= 64) {
- _grid->newCameraZ = 63;
+ if (_grid->newCameraZ >= GRID_SIZE_Z) {
+ _grid->newCameraZ = GRID_SIZE_Z - 1;
}
_redraw->reqBgRedraw = true;
Commit: 9d8eaa3f9755695a978a7307769e9907e34b4e5b
https://github.com/scummvm/scummvm/commit/9d8eaa3f9755695a978a7307769e9907e34b4e5b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T16:59:29+01:00
Commit Message:
TWINE: converted to enum class
and added TODO about value mixing
Changed paths:
engines/twine/extra.cpp
engines/twine/redraw.cpp
engines/twine/redraw.h
engines/twine/script_life_v1.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index c35775dbe6..68e6386efe 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -698,10 +698,10 @@ void Extra::processExtras() {
if (extraKey->info1 > 1) {
_engine->_renderer->projectPositionOnScreen(extraKey->x - _engine->_grid->cameraX, extraKey->y - _engine->_grid->cameraY, extraKey->z - _engine->_grid->cameraZ);
- _engine->_redraw->addOverlay(koNumber, extraKey->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 0, koNormal, 2);
+ _engine->_redraw->addOverlay(OverlayType::koNumber, extraKey->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 0, OverlayPosType::koNormal, 2);
}
- _engine->_redraw->addOverlay(koSprite, SPRITEHQR_KEY, 10, 30, 0, koNormal, 2);
+ _engine->_redraw->addOverlay(OverlayType::koSprite, SPRITEHQR_KEY, 10, 30, 0, OverlayPosType::koNormal, 2);
_engine->_gameState->inventoryNumKeys += extraKey->info1;
extraKey->info0 = -1;
@@ -731,10 +731,10 @@ void Extra::processExtras() {
if (extraKey->info1 > 1) {
_engine->_renderer->projectPositionOnScreen(extraKey->x - _engine->_grid->cameraX, extraKey->y - _engine->_grid->cameraY, extraKey->z - _engine->_grid->cameraZ);
- _engine->_redraw->addOverlay(koNumber, extraKey->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 0, koNormal, 2);
+ _engine->_redraw->addOverlay(OverlayType::koNumber, extraKey->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 0, OverlayPosType::koNormal, 2);
}
- _engine->_redraw->addOverlay(koSprite, SPRITEHQR_KEY, 10, 30, 0, koNormal, 2);
+ _engine->_redraw->addOverlay(OverlayType::koSprite, SPRITEHQR_KEY, 10, 30, 0, OverlayPosType::koNormal, 2);
_engine->_gameState->inventoryNumKeys += extraKey->info1;
extraKey->info0 = -1;
@@ -879,10 +879,10 @@ void Extra::processExtras() {
if (extra->info1 > 1 && !_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {
_engine->_renderer->projectPositionOnScreen(extra->x - _engine->_grid->cameraX, extra->y - _engine->_grid->cameraY, extra->z - _engine->_grid->cameraZ);
- _engine->_redraw->addOverlay(koNumber, extra->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 158, koNormal, 2);
+ _engine->_redraw->addOverlay(OverlayType::koNumber, extra->info1, _engine->_renderer->projPosX, _engine->_renderer->projPosY, 158, OverlayPosType::koNormal, 2);
}
- _engine->_redraw->addOverlay(koSprite, extra->info0, 10, 30, 0, koNormal, 2);
+ _engine->_redraw->addOverlay(OverlayType::koSprite, extra->info0, 10, 30, 0, OverlayPosType::koNormal, 2);
if (extra->info0 == SPRITEHQR_KASHES) {
_engine->_gameState->inventoryNumKashes += extra->info1;
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 95f78928ec..6c3983456c 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -198,7 +198,9 @@ void Redraw::updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2) {
for (int32 i = 0; i < ARRAYSIZE(overlayList); i++) {
OverlayListStruct *overlay = &overlayList[i];
- if (overlay->type == koFollowActor) {
+ // TODO: this comparison is wrong - either posType or koNumber
+ //if (overlay->type == OverlayPosType::koFollowActor) {
+ if (overlay->posType == OverlayPosType::koFollowActor) {
overlay->x = newX;
overlay->y = newY;
}
@@ -549,13 +551,13 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
if (overlay->info0 != -1) {
// process position overlay
switch (overlay->posType) {
- case koNormal:
+ case OverlayPosType::koNormal:
if (_engine->lbaTime >= overlay->lifeTime) {
overlay->info0 = -1;
continue;
}
break;
- case koFollowActor: {
+ case OverlayPosType::koFollowActor: {
ActorStruct *actor2 = _engine->_scene->getActor(overlay->info1);
_engine->_renderer->projectPositionOnScreen(actor2->x - _engine->_grid->cameraX, actor2->y + actor2->boudingBox.y.topRight - _engine->_grid->cameraY, actor2->z - _engine->_grid->cameraZ);
@@ -573,7 +575,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
// process overlay type
switch (overlay->type) {
- case koSprite: {
+ case OverlayType::koSprite: {
const uint8 *spritePtr = _engine->_resources->spriteTable[overlay->info0];
int32 spriteWidth, spriteHeight;
@@ -596,7 +598,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
}
break;
}
- case koNumber: {
+ case OverlayType::koNumber: {
char text[10];
snprintf(text, sizeof(text), "%d", overlay->info0);
@@ -619,7 +621,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
}
break;
}
- case koNumberRange: {
+ case OverlayType::koNumberRange: {
const int32 range = _engine->_collision->getAverageValue(overlay->info1, overlay->info0, 100, overlay->lifeTime - _engine->lbaTime - 50);
char text[10];
@@ -644,7 +646,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
}
break;
}
- case koInventoryItem: {
+ case OverlayType::koInventoryItem: {
const int32 item = overlay->info0;
const Common::Rect rect(10, 10, 69, 69);
@@ -663,7 +665,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
_engine->_gameState->initEngineProjections();
break;
}
- case koText: {
+ case OverlayType::koText: {
char text[256];
_engine->_text->getMenuText(overlay->info0, text, sizeof(text));
diff --git a/engines/twine/redraw.h b/engines/twine/redraw.h
index 9aeb2e7491..3a8d3b0db4 100644
--- a/engines/twine/redraw.h
+++ b/engines/twine/redraw.h
@@ -30,7 +30,7 @@ namespace TwinE {
#define OVERLAY_MAX_ENTRIES 10
-enum OverlayType {
+enum class OverlayType {
koSprite = 0,
koNumber = 1,
koNumberRange = 2,
@@ -38,19 +38,19 @@ enum OverlayType {
koText = 4
};
-enum OverlayPosType {
+enum class OverlayPosType {
koNormal = 0,
koFollowActor = 1
};
/** Overlay list structure */
struct OverlayListStruct {
- OverlayType type = koSprite;
+ OverlayType type = OverlayType::koSprite;
int16 info0 = 0; // sprite/3d model entry | number | number range
int16 x = 0;
int16 y = 0;
int16 info1 = 0; // followed actor | total coins
- OverlayPosType posType = koNormal;
+ OverlayPosType posType = OverlayPosType::koNormal;
int16 lifeTime = 0;
};
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 693ebd7774..b6adde5c30 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -334,7 +334,7 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
}
if (engine->_scene->currentScriptValue == 1) {
- engine->_redraw->addOverlay(koInventoryItem, item, 0, 0, 0, koNormal, 3);
+ engine->_redraw->addOverlay(OverlayType::koInventoryItem, item, 0, 0, 0, OverlayPosType::koNormal, 3);
}
} else {
engine->_scene->currentScriptValue = 0;
@@ -834,7 +834,7 @@ static int32 lUSE_ONE_LITTLE_KEY(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_gameState->inventoryNumKeys = 0;
}
- engine->_redraw->addOverlay(koSprite, SPRITEHQR_KEY, 0, 0, 0, koFollowActor, 1);
+ engine->_redraw->addOverlay(OverlayType::koSprite, SPRITEHQR_KEY, 0, 0, 0, OverlayPosType::koFollowActor, 1);
return 0;
}
@@ -853,11 +853,11 @@ static int32 lGIVE_GOLD_PIECES(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->_gameState->inventoryNumKashes = 0;
}
- engine->_redraw->addOverlay(koSprite, SPRITEHQR_KASHES, 10, 15, 0, koNormal, 3);
+ engine->_redraw->addOverlay(OverlayType::koSprite, SPRITEHQR_KASHES, 10, 15, 0, OverlayPosType::koNormal, 3);
for (int16 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
OverlayListStruct *overlay = &engine->_redraw->overlayList[i];
- if (overlay->info0 != -1 && overlay->type == koNumberRange) {
+ if (overlay->info0 != -1 && overlay->type == OverlayType::koNumberRange) {
overlay->info0 = engine->_collision->getAverageValue(overlay->info1, overlay->info0, 100, overlay->lifeTime - engine->lbaTime - 50);
overlay->info1 = engine->_gameState->inventoryNumKashes;
overlay->lifeTime = engine->lbaTime + 150;
@@ -867,7 +867,7 @@ static int32 lGIVE_GOLD_PIECES(TwinEEngine *engine, LifeScriptContext &ctx) {
}
if (!hideRange) {
- engine->_redraw->addOverlay(koNumberRange, oldNumKashes, 50, 20, engine->_gameState->inventoryNumKashes, koNormal, 3);
+ engine->_redraw->addOverlay(OverlayType::koNumberRange, oldNumKashes, 50, 20, engine->_gameState->inventoryNumKashes, OverlayPosType::koNormal, 3);
}
return 0;
@@ -1331,7 +1331,7 @@ static int32 lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 location = ctx.stream.readByte();
engine->_holomap->setHolomapPosition(location);
if (engine->_gameState->hasItem(InventoryItems::kiHolomap)) {
- engine->_redraw->addOverlay(koInventoryItem, 0, 0, 0, 0, koNormal, 3);
+ engine->_redraw->addOverlay(OverlayType::koInventoryItem, 0, 0, 0, 0, OverlayPosType::koNormal, 3);
}
return 0;
@@ -1388,7 +1388,7 @@ static int32 lSET_GRM(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lSAY_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
int16 textEntry = ctx.stream.readSint16LE();
- engine->_redraw->addOverlay(koText, textEntry, 0, 0, ctx.actorIdx, koFollowActor, 2);
+ engine->_redraw->addOverlay(OverlayType::koText, textEntry, 0, 0, ctx.actorIdx, OverlayPosType::koFollowActor, 2);
ScopedEngineFreeze scoped(engine);
engine->_text->initVoxToPlay(textEntry);
@@ -1404,7 +1404,7 @@ static int32 lSAY_MESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
int32 otherActorIdx = ctx.stream.readByte();
int16 textEntry = ctx.stream.readSint16LE();
- engine->_redraw->addOverlay(koText, textEntry, 0, 0, otherActorIdx, koFollowActor, 2);
+ engine->_redraw->addOverlay(OverlayType::koText, textEntry, 0, 0, otherActorIdx, OverlayPosType::koFollowActor, 2);
ScopedEngineFreeze scoped(engine);
engine->_text->initVoxToPlay(textEntry);
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 4668941da3..017d5d7b7a 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -570,7 +570,7 @@ void TwinEEngine::processInventoryAction() {
_scene->sceneHero->life = 50;
_gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
_gameState->inventoryNumLeafs--;
- _redraw->addOverlay(koInventoryItem, 27, 0, 0, 0, koNormal, 3);
+ _redraw->addOverlay(OverlayType::koInventoryItem, 27, 0, 0, 0, OverlayPosType::koNormal, 3);
}
}
break;
Commit: 4010c23d69fc8b8e361ff8ba69dc2325775efbcc
https://github.com/scummvm/scummvm/commit/4010c23d69fc8b8e361ff8ba69dc2325775efbcc
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:00:17+01:00
Commit Message:
TWINE: replaced magic numbers
Changed paths:
engines/twine/actor.cpp
engines/twine/animations.cpp
engines/twine/redraw.h
engines/twine/scene.cpp
engines/twine/script_life_v1.cpp
engines/twine/shared.h
engines/twine/twine.cpp
diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index e6e4439dea..b34e18924e 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -492,12 +492,12 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
return;
}
if (actor->dynamicFlags.bIsDead) {
- _engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, ANGLE_90, 0, bonusSprite, actor->bonusAmount);
+ _engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, ANGLE_90, ANGLE_0, bonusSprite, actor->bonusAmount);
_engine->_sound->playSample(Samples::ItemPopup, 1, actor->x, actor->y, actor->z, actorIdx);
} else {
ActorStruct *sceneHero = _engine->_scene->sceneHero;
const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(actor->x, actor->z, sceneHero->x, sceneHero->z);
- _engine->_extra->addExtraBonus(actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, 200, angle, bonusSprite, actor->bonusAmount);
+ _engine->_extra->addExtraBonus(actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, ANGLE_70, angle, bonusSprite, actor->bonusAmount);
_engine->_sound->playSample(Samples::ItemPopup, 1, actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, actorIdx);
}
}
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index d3fbd6323f..8f6dbb2413 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -40,11 +40,11 @@
namespace TwinE {
static const int32 magicLevelStrengthOfHit[] = {
- kNoBallStrength,
- kYellowBallStrength,
- kGreenBallStrength,
- kRedBallStrength,
- kFireBallStrength,
+ MagicballStrengthType::kNoBallStrength,
+ MagicballStrengthType::kYellowBallStrength,
+ MagicballStrengthType::kGreenBallStrength,
+ MagicballStrengthType::kRedBallStrength,
+ MagicballStrengthType::kFireBallStrength,
0
};
diff --git a/engines/twine/redraw.h b/engines/twine/redraw.h
index 3a8d3b0db4..c47f58800c 100644
--- a/engines/twine/redraw.h
+++ b/engines/twine/redraw.h
@@ -49,7 +49,7 @@ struct OverlayListStruct {
int16 info0 = 0; // sprite/3d model entry | number | number range
int16 x = 0;
int16 y = 0;
- int16 info1 = 0; // followed actor | total coins
+ int16 info1 = 0; // text = actor | total coins
OverlayPosType posType = OverlayPosType::koNormal;
int16 lifeTime = 0;
};
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 99cec049ee..c2970ffc5f 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -447,7 +447,7 @@ void Scene::processZoneExtraBonus(ZoneStruct *zone) {
const int16 amount = zone->infoData.Bonus.amount;
const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, sceneHero->x, sceneHero->z);
- const int32 index = _engine->_extra->addExtraBonus(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, zone->topRight.y, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, 180, angle, bonusSprite, amount);
+ const int32 index = _engine->_extra->addExtraBonus(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, zone->topRight.y, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, ANGLE_63, angle, bonusSprite, amount);
if (index != -1) {
_engine->_extra->extraList[index].type |= 0x400;
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index b6adde5c30..ee3a48beee 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1331,7 +1331,7 @@ static int32 lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 location = ctx.stream.readByte();
engine->_holomap->setHolomapPosition(location);
if (engine->_gameState->hasItem(InventoryItems::kiHolomap)) {
- engine->_redraw->addOverlay(OverlayType::koInventoryItem, 0, 0, 0, 0, OverlayPosType::koNormal, 3);
+ engine->_redraw->addOverlay(OverlayType::koInventoryItem, InventoryItems::kiHolomap, 0, 0, 0, OverlayPosType::koNormal, 3);
}
return 0;
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index 6af695bf55..c3e837f363 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -123,6 +123,8 @@ enum class ExtraSpecialType {
#define ANGLE_180 512
#define ANGLE_135 384
#define ANGLE_90 256
+#define ANGLE_70 200
+#define ANGLE_63 180
#define ANGLE_45 128
#define ANGLE_0 0
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 017d5d7b7a..f0c466eff2 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -570,7 +570,7 @@ void TwinEEngine::processInventoryAction() {
_scene->sceneHero->life = 50;
_gameState->inventoryMagicPoints = _gameState->magicLevelIdx * 20;
_gameState->inventoryNumLeafs--;
- _redraw->addOverlay(OverlayType::koInventoryItem, 27, 0, 0, 0, OverlayPosType::koNormal, 3);
+ _redraw->addOverlay(OverlayType::koInventoryItem, InventoryItems::kiCloverLeaf, 0, 0, 0, OverlayPosType::koNormal, 3);
}
}
break;
Commit: a4b236b2ce1abddbf9f4c5e0299345dbf30cca59
https://github.com/scummvm/scummvm/commit/a4b236b2ce1abddbf9f4c5e0299345dbf30cca59
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:00:35+01:00
Commit Message:
TWINE: renamed variable
Changed paths:
engines/twine/animations.cpp
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 8f6dbb2413..9de700a282 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -533,10 +533,10 @@ void Animations::processAnimActions(int32 actorIdx) {
const int32 yOffset = stream.readSint16LE();
const int32 spriteIdx = stream.readByte();
const int32 targetActorIdx = stream.readByte();
- const int32 maxSpeed = stream.readSint16LE();
+ const int32 finalAngle = stream.readSint16LE();
const int32 strengthOfHit = stream.readByte();
- _engine->_extra->addExtraAiming(actorIdx, actor->x, actor->y + yOffset, actor->z, spriteIdx, targetActorIdx, maxSpeed, strengthOfHit);
+ _engine->_extra->addExtraAiming(actorIdx, actor->x, actor->y + yOffset, actor->z, spriteIdx, targetActorIdx, finalAngle, strengthOfHit);
} else {
stream.skip(6);
}
Commit: 346b5b9f4df7dbcd62ae09bdabb2cc0932c51efe
https://github.com/scummvm/scummvm/commit/346b5b9f4df7dbcd62ae09bdabb2cc0932c51efe
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:01:37+01:00
Commit Message:
TWINE: added ExtraType bit values as enum and renamed member
Changed paths:
engines/twine/extra.cpp
engines/twine/extra.h
engines/twine/redraw.cpp
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 68e6386efe..3f57f51909 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -117,7 +117,7 @@ int32 Extra::addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx
extra->x = x;
extra->y = y;
extra->z = z;
- extra->actorIdx = actorIdx;
+ extra->spawnTime = actorIdx;
extra->lifeTime = targetActor;
extra->destZ = maxSpeed;
extra->strengthOfHit = strengthOfHit;
@@ -142,7 +142,7 @@ int32 Extra::addExtraExplode(int32 x, int32 y, int32 z) {
extra->x = x;
extra->y = y;
extra->z = z;
- extra->actorIdx = 0x28;
+ extra->spawnTime = 40;
extra->lifeTime = _engine->lbaTime;
extra->strengthOfHit = 0;
return i;
@@ -201,7 +201,7 @@ void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
extra->strengthOfHit = 0;
extra->lifeTime = _engine->lbaTime;
- extra->actorIdx = 100;
+ extra->spawnTime = 100;
}
if (type == ExtraSpecialType::kExplodeCloud) {
extra->type = 1;
@@ -212,7 +212,7 @@ void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
extra->strengthOfHit = 0;
extra->lifeTime = _engine->lbaTime;
- extra->actorIdx = 5;
+ extra->spawnTime = 5;
}
break;
}
@@ -275,7 +275,7 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle
extra->strengthOfHit = 0;
extra->lifeTime = _engine->lbaTime;
- extra->actorIdx = 1000;
+ extra->spawnTime = 1000;
extra->info1 = bonusAmount;
return i;
}
@@ -300,7 +300,7 @@ int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spri
extra->strengthOfHit = strengthOfHit;
extra->lifeTime = _engine->lbaTime;
- extra->actorIdx = actorIdx;
+ extra->spawnTime = actorIdx;
extra->info1 = 0;
return i;
@@ -321,7 +321,7 @@ int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spr
extra->x = x;
extra->y = y;
extra->z = z;
- extra->actorIdx = actorIdx;
+ extra->spawnTime = actorIdx;
extra->lifeTime = targetActorIdx;
extra->destZ = finalAngle;
extra->strengthOfHit = strengthOfHit;
@@ -360,7 +360,7 @@ int32 Extra::addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int3
extra->x = x;
extra->y = y;
extra->z = z;
- extra->actorIdx = extraIdx;
+ extra->spawnTime = extraIdx;
extra->destZ = 4000;
extra->strengthOfHit = 0;
_engine->_movements->setActorAngle(ANGLE_0, 4000, 50, &extra->trackActorMove);
@@ -571,7 +571,7 @@ void Extra::processExtras() {
}
// process extra life time
if (extra->type & 0x1) {
- if (extra->actorIdx + extra->lifeTime <= _engine->lbaTime) {
+ if (extra->spawnTime + extra->lifeTime <= _engine->lbaTime) {
extra->info0 = -1;
continue;
}
@@ -637,7 +637,7 @@ void Extra::processExtras() {
// process actor target hit
if (extra->type & 0x80) {
int32 actorIdxAttacked = extra->lifeTime;
- int32 actorIdx = extra->actorIdx;
+ int32 actorIdx = extra->spawnTime;
const ActorStruct *actor = _engine->_scene->getActor(actorIdxAttacked);
currentExtraX = actor->x;
@@ -687,8 +687,8 @@ void Extra::processExtras() {
// process magic ball extra aiming for key
if (extra->type & 0x200) {
// int32 actorIdxAttacked = extra->lifeTime;
- ExtraListStruct *extraKey = &extraList[extra->actorIdx];
- int32 actorIdx = extra->actorIdx;
+ ExtraListStruct *extraKey = &extraList[extra->spawnTime];
+ int32 actorIdx = extra->spawnTime;
int32 tmpAngle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->x, extra->z, extraKey->x, extraKey->z);
int32 angle = ClampAngle(tmpAngle - extra->angle);
@@ -760,7 +760,7 @@ void Extra::processExtras() {
}
// process extra collision with actors
if (extra->type & 0x4) {
- if (_engine->_collision->checkExtraCollisionWithActors(extra, extra->actorIdx) != -1) {
+ if (_engine->_collision->checkExtraCollisionWithActors(extra, extra->spawnTime) != -1) {
// if extra is Magic Ball
if (i == _engine->_gameState->magicBallIdx) {
int32 spriteIdx = SPRITEHQR_MAGICBALL_YELLOW_TRANS;
diff --git a/engines/twine/extra.h b/engines/twine/extra.h
index f7ce14229d..36e177b78e 100644
--- a/engines/twine/extra.h
+++ b/engines/twine/extra.h
@@ -30,6 +30,25 @@ namespace TwinE {
#define EXTRA_MAX_ENTRIES 50
+enum ExtraType {
+ TIME_OUT = 1 << 0, // 0x0001
+ FLY = 1 << 1, // 0x0002
+ UNK2 = 1 << 2, // 0x0004
+ UNK3 = 1 << 3, // 0x0008
+ STOP_COL = 1 << 4, // 0x0010
+ TAKABLE = 1 << 5, // 0x0020
+ FLASH = 1 << 6, // 0x0040
+ UNK7 = 1 << 7, // 0x0080
+ UNK8 = 1 << 8, // 0x0100
+ UNK9 = 1 << 9, // 0x0200
+ TIME_IN = 1 << 10, // 0x0400
+ UNK11 = 1 << 11, // 0x0800
+ UNK12 = 1 << 12, // 0x1000
+ WAIT_NO_COL = 1 << 13, // 0x2000
+ BONUS = 1 << 14, // 0x4000
+ UNK15 = 1 << 15 // 0x8000
+};
+
struct ExtraListStruct {
int16 info0 = 0; // field_0
int16 x = 0;
@@ -45,10 +64,10 @@ struct ExtraListStruct {
int16 destX = 0; // field_E
int16 destY = 0; // field_10
int16 destZ = 0; // field_12
- int16 type = 0; // field_14
+ uint16 type = 0; /**< ExtraType bitmask */
int16 angle = 0; // field_16
int32 lifeTime = 0;
- int16 actorIdx = 0; // field_ 1C
+ int16 spawnTime = 0; // field_ 1C
int16 strengthOfHit = 0; // field_1E
int16 info1 = 0; // field_20
};
@@ -62,7 +81,7 @@ private:
void throwExtra(ExtraListStruct *extra, int32 xAngle, int32 yAngle, int32 x, int32 extraAngle);
void processMagicballBounce(ExtraListStruct *extra, int32 x, int32 y, int32 z);
int32 findExtraKey();
- int32 addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 extraIdx);
+ int32 addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 spawnTime);
void drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 color, int32 angle, int32 size);
public:
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 6c3983456c..67cab68ce9 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -320,7 +320,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
_engine->_sound->playSample(Samples::ItemPopup, 1, extra->x, extra->y, extra->z);
}
} else {
- if ((extra->type & 1) || (extra->type & 0x40) || (extra->actorIdx + extra->lifeTime - 150 < _engine->lbaTime) || (!((_engine->lbaTime + extra->lifeTime) & 8))) {
+ if ((extra->type & 1) || (extra->type & 0x40) || (extra->spawnTime + extra->lifeTime - 150 < _engine->lbaTime) || (!((_engine->lbaTime + extra->lifeTime) & 8))) {
_engine->_renderer->projectPositionOnScreen(extra->x - _engine->_grid->cameraX, extra->y - _engine->_grid->cameraY, extra->z - _engine->_grid->cameraZ);
if (_engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < 680 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < 580) {
Commit: d6031e74d6e8764bfdcaf529dc6ae3b0d89be7c7
https://github.com/scummvm/scummvm/commit/d6031e74d6e8764bfdcaf529dc6ae3b0d89be7c7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:03:11+01:00
Commit Message:
TWINE: replaced magic numbers with ExtraType constants
Changed paths:
engines/twine/extra.cpp
engines/twine/redraw.cpp
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 3f57f51909..2f0e7ee83d 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -112,7 +112,7 @@ int32 Extra::addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx
continue;
}
extra->info0 = spriteIdx;
- extra->type = 0x80;
+ extra->type = ExtraType::UNK7;
extra->info1 = 0;
extra->x = x;
extra->y = y;
@@ -137,7 +137,7 @@ int32 Extra::addExtraExplode(int32 x, int32 y, int32 z) {
continue;
}
extra->info0 = SPRITEHQR_EXPLOSION_FIRST_FRAME;
- extra->type = 0x1001;
+ extra->type = ExtraType::TIME_OUT | ExtraType::UNK12;
extra->info1 = 0;
extra->x = x;
extra->y = y;
@@ -159,7 +159,7 @@ void Extra::resetExtras() {
}
void Extra::throwExtra(ExtraListStruct *extra, int32 xAngle, int32 yAngle, int32 x, int32 extraAngle) { // InitFly
- extra->type |= 2;
+ extra->type |= ExtraType::FLY;
extra->lastX = extra->x;
extra->lastY = extra->y;
@@ -190,7 +190,7 @@ void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
extra->info1 = 0;
if (type == ExtraSpecialType::kHitStars) {
- extra->type = 9;
+ extra->type = ExtraType::TIME_OUT | ExtraType::UNK3;
extra->x = x;
extra->y = y;
@@ -204,7 +204,7 @@ void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
extra->spawnTime = 100;
}
if (type == ExtraSpecialType::kExplodeCloud) {
- extra->type = 1;
+ extra->type = ExtraType::TIME_OUT;
extra->x = x;
extra->y = y;
@@ -316,7 +316,7 @@ int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spr
continue;
}
extra->info0 = spriteIdx;
- extra->type = 0x80;
+ extra->type = ExtraType::UNK7;
extra->info1 = 0;
extra->x = x;
extra->y = y;
@@ -355,7 +355,7 @@ int32 Extra::addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int3
continue;
}
extra->info0 = spriteIdx;
- extra->type = 0x200;
+ extra->type = ExtraType::UNK9;
extra->info1 = 0;
extra->x = x;
extra->y = y;
@@ -570,24 +570,24 @@ void Extra::processExtras() {
continue;
}
// process extra life time
- if (extra->type & 0x1) {
+ if (extra->type & ExtraType::TIME_OUT) {
if (extra->spawnTime + extra->lifeTime <= _engine->lbaTime) {
extra->info0 = -1;
continue;
}
}
// reset extra
- if (extra->type & 0x800) {
+ if (extra->type & ExtraType::UNK11) {
extra->info0 = -1;
continue;
}
//
- if (extra->type & 0x1000) {
+ if (extra->type & ExtraType::UNK12) {
extra->info0 = _engine->_collision->getAverageValue(97, 100, 30, _engine->lbaTime - extra->lifeTime);
continue;
}
// process extra moving
- if (extra->type & 0x2) {
+ if (extra->type & ExtraType::FLY) {
currentExtraX = extra->x;
currentExtraY = extra->y;
currentExtraZ = extra->z;
@@ -618,7 +618,7 @@ void Extra::processExtras() {
}
// if can take extra on ground
- if (extra->type & 0x20) {
+ if (extra->type & ExtraType::TAKABLE) {
extra->type &= 0xFFED;
} else {
extra->info0 = -1;
@@ -628,14 +628,14 @@ void Extra::processExtras() {
}
}
//
- if (extra->type & 0x4000) {
+ if (extra->type & ExtraType::BONUS) {
if (_engine->lbaTime - extra->lifeTime > 40) {
extra->type &= 0xBFFF;
}
continue;
}
// process actor target hit
- if (extra->type & 0x80) {
+ if (extra->type & ExtraType::UNK7) {
int32 actorIdxAttacked = extra->lifeTime;
int32 actorIdx = extra->spawnTime;
@@ -685,7 +685,7 @@ void Extra::processExtras() {
}
}
// process magic ball extra aiming for key
- if (extra->type & 0x200) {
+ if (extra->type & ExtraType::UNK9) {
// int32 actorIdxAttacked = extra->lifeTime;
ExtraListStruct *extraKey = &extraList[extra->spawnTime];
int32 actorIdx = extra->spawnTime;
@@ -759,7 +759,7 @@ void Extra::processExtras() {
}
}
// process extra collision with actors
- if (extra->type & 0x4) {
+ if (extra->type & ExtraType::UNK2) {
if (_engine->_collision->checkExtraCollisionWithActors(extra, extra->spawnTime) != -1) {
// if extra is Magic Ball
if (i == _engine->_gameState->magicBallIdx) {
@@ -780,24 +780,24 @@ void Extra::processExtras() {
}
}
// process extra collision with scene ground
- if (extra->type & 0x8) {
+ if (extra->type & ExtraType::UNK3) {
int32 process = 0;
if (_engine->_collision->checkExtraCollisionWithBricks(currentExtraX, currentExtraY, currentExtraZ, extra->x, extra->y, extra->z)) {
// if not touch the ground
- if (!(extra->type & 0x2000)) {
+ if (!(extra->type & ExtraType::WAIT_NO_COL)) {
process = 1;
}
} else {
// if touch the ground
- if (extra->type & 0x2000) {
+ if (extra->type & ExtraType::WAIT_NO_COL) {
extra->type &= 0xDFFF; // set flag out of ground
}
}
if (process) {
// show explode cloud
- if (extra->type & 0x100) {
+ if (extra->type & ExtraType::UNK8) {
addExtraSpecial(currentExtraX, currentExtraY, currentExtraZ, ExtraSpecialType::kExplodeCloud);
}
// if extra is magic ball
@@ -847,17 +847,17 @@ void Extra::processExtras() {
}
}
// extra stop moving while collision with bricks
- if (extra->type & 0x10) {
+ if (extra->type & ExtraType::STOP_COL) {
int32 process = 0;
if (_engine->_collision->checkExtraCollisionWithBricks(currentExtraX, currentExtraY, currentExtraZ, extra->x, extra->y, extra->z)) {
// if not touch the ground
- if (!(extra->type & 0x2000)) {
+ if (!(extra->type & ExtraType::WAIT_NO_COL)) {
process = 1;
}
} else {
// if touch the ground
- if (extra->type & 0x2000) {
+ if (extra->type & ExtraType::WAIT_NO_COL) {
extra->type &= 0xDFFF; // set flag out of ground
}
}
@@ -872,7 +872,7 @@ void Extra::processExtras() {
}
}
// get extras on ground
- if ((extra->type & 0x20) && !(extra->type & 0x2)) {
+ if ((extra->type & ExtraType::TAKABLE) && !(extra->type & ExtraType::FLY)) {
// if hero touch extra
if (_engine->_collision->checkExtraCollisionWithActors(extra, -1) == 0) {
_engine->_sound->playSample(Samples::ItemFound, 1, extra->x, extra->y, extra->z);
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 67cab68ce9..d527449d3c 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -313,14 +313,14 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &_engine->_extra->extraList[i];
if (extra->info0 != -1) {
- if (extra->type & 0x400) {
+ if (extra->type & ExtraType::TIME_IN) {
if (_engine->lbaTime - extra->lifeTime > 35) {
extra->lifeTime = _engine->lbaTime;
extra->type &= 0xFBFF;
_engine->_sound->playSample(Samples::ItemPopup, 1, extra->x, extra->y, extra->z);
}
} else {
- if ((extra->type & 1) || (extra->type & 0x40) || (extra->spawnTime + extra->lifeTime - 150 < _engine->lbaTime) || (!((_engine->lbaTime + extra->lifeTime) & 8))) {
+ if ((extra->type & ExtraType::TIME_OUT) || (extra->type & ExtraType::FLASH) || (extra->spawnTime + extra->lifeTime - 150 < _engine->lbaTime) || (!((_engine->lbaTime + extra->lifeTime) & 8))) {
_engine->_renderer->projectPositionOnScreen(extra->x - _engine->_grid->cameraX, extra->y - _engine->_grid->cameraY, extra->z - _engine->_grid->cameraZ);
if (_engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < 680 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < 580) {
Commit: 4c04e76adb4e7f550f0255b5b7c15dc9ba9bff0d
https://github.com/scummvm/scummvm/commit/4c04e76adb4e7f550f0255b5b7c15dc9ba9bff0d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:04:48+01:00
Commit Message:
TWINE: replaced magic numbers with ExtraType constants
Changed paths:
engines/twine/extra.cpp
engines/twine/redraw.cpp
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 2f0e7ee83d..7d5b4f3b2f 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -260,10 +260,10 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle
continue;
}
extra->info0 = type;
- extra->type = 0x4071;
+ extra->type = ExtraType::TIME_OUT | ExtraType::TAKABLE | ExtraType::FLASH | ExtraType::STOP_COL | ExtraType::BONUS;
/*if(type == SPRITEHQR_KEY) {
- extra->type = 0x4030;
+ extra->type = ExtraFlag::STOP_COL | ExtraFlag::TAKABLE | ExtraFlag::BONUS;
}*/
extra->x = x;
@@ -290,7 +290,7 @@ int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spri
continue;
}
extra->info0 = spriteIdx;
- extra->type = 0x210C;
+ extra->type = ExtraType::UNK2 | ExtraType::UNK3 | ExtraType::UNK8 | ExtraType::WAIT_NO_COL;
extra->x = x;
extra->y = y;
extra->z = z;
@@ -619,7 +619,7 @@ void Extra::processExtras() {
// if can take extra on ground
if (extra->type & ExtraType::TAKABLE) {
- extra->type &= 0xFFED;
+ extra->type &= ~(ExtraType::FLY | ExtraType::STOP_COL);
} else {
extra->info0 = -1;
}
@@ -630,7 +630,7 @@ void Extra::processExtras() {
//
if (extra->type & ExtraType::BONUS) {
if (_engine->lbaTime - extra->lifeTime > 40) {
- extra->type &= 0xBFFF;
+ extra->type &= ~ExtraType::BONUS;
}
continue;
}
@@ -791,7 +791,7 @@ void Extra::processExtras() {
} else {
// if touch the ground
if (extra->type & ExtraType::WAIT_NO_COL) {
- extra->type &= 0xDFFF; // set flag out of ground
+ extra->type &= ~ExtraType::WAIT_NO_COL; // set flag out of ground
}
}
@@ -858,7 +858,7 @@ void Extra::processExtras() {
} else {
// if touch the ground
if (extra->type & ExtraType::WAIT_NO_COL) {
- extra->type &= 0xDFFF; // set flag out of ground
+ extra->type &= ~ExtraType::WAIT_NO_COL; // set flag out of ground
}
}
@@ -867,7 +867,7 @@ void Extra::processExtras() {
stream.seek(extra->info0 * 16);
stream.skip(8);
extra->y = (_engine->_collision->collisionY << 8) + 0x100 - stream.readSint16LE();
- extra->type &= 0xFFED;
+ extra->type &= ~(ExtraType::STOP_COL | ExtraType::FLY);
continue;
}
}
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index d527449d3c..3042a579a9 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -316,7 +316,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
if (extra->type & ExtraType::TIME_IN) {
if (_engine->lbaTime - extra->lifeTime > 35) {
extra->lifeTime = _engine->lbaTime;
- extra->type &= 0xFBFF;
+ extra->type &= ~ExtraType::TIME_IN;
_engine->_sound->playSample(Samples::ItemPopup, 1, extra->x, extra->y, extra->z);
}
} else {
Commit: 26f72efe84b16928070292a065bdf2ec2ff6ac3a
https://github.com/scummvm/scummvm/commit/26f72efe84b16928070292a065bdf2ec2ff6ac3a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:05:07+01:00
Commit Message:
TWINE: replaced magic number for angle
Changed paths:
engines/twine/extra.cpp
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 7d5b4f3b2f..320ef341e3 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -523,7 +523,7 @@ void Extra::drawExtraSpecial(int32 extraIdx, int32 x, int32 y) {
switch (specialType) {
case ExtraSpecialType::kHitStars:
- drawSpecialShape(hitStarsShapeTable, x, y, 15, (_engine->lbaTime << 5) & 0x300, 4);
+ drawSpecialShape(hitStarsShapeTable, x, y, 15, (_engine->lbaTime << 5) & ANGLE_270, 4);
break;
case ExtraSpecialType::kExplodeCloud: {
int32 cloudTime = 1 + _engine->lbaTime - extra->lifeTime;
Commit: 5445b1734466fe1d0e7b8d718a5a468464124498
https://github.com/scummvm/scummvm/commit/5445b1734466fe1d0e7b8d718a5a468464124498
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:05:44+01:00
Commit Message:
TWINE: renamed struct members and stack vars
Changed paths:
engines/twine/animations.cpp
engines/twine/extra.cpp
engines/twine/extra.h
engines/twine/redraw.cpp
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 9de700a282..d11fce2115 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -207,7 +207,7 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
const uint8* keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animPtr + 8;
- int32 keyFrameLength = READ_LE_INT16(keyFramePtr);
+ const int32 keyFrameLength = READ_LE_INT16(keyFramePtr);
const Model *bodyHeader = (Model *)bodyPtr;
if (!bodyHeader->bodyFlag.animated) {
@@ -216,31 +216,29 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
uint8 *edi = bodyPtr + 16;
- const uint8 *ebx = animTimerDataPtr->ptr;
- int32 ebp = animTimerDataPtr->time;
+ const uint8 *lastKeyFramePtr = animTimerDataPtr->ptr;
+ int32 remainingFrameTime = animTimerDataPtr->time;
- if (!ebx) {
- ebx = keyFramePtr;
- ebp = keyFrameLength;
+ if (!lastKeyFramePtr) {
+ lastKeyFramePtr = keyFramePtr;
+ remainingFrameTime = keyFrameLength;
}
- const uint8* lastKeyFramePtr = ebx;
-
edi += bodyHeader->offsetToData;
int16 eax = READ_LE_INT16(edi);
eax = eax + eax * 2;
edi = edi + eax * 2 + 12;
- int32 numOfPointInBody = READ_LE_INT16(edi - 10);
+ const int32 numOfPointInBody = READ_LE_INT16(edi - 10);
if (numOfPointInAnim > numOfPointInBody) {
numOfPointInAnim = numOfPointInBody;
}
- eax = _engine->lbaTime - ebp;
+ const int32 deltaTime = _engine->lbaTime - remainingFrameTime;
- if (eax >= keyFrameLength) {
+ if (deltaTime >= keyFrameLength) {
const int32 *sourcePtr = (const int32 *)(keyFramePtr + 8);
int32 *destPtr = (int32 *)edi; // keyframe
@@ -268,7 +266,7 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
keyFramePtr += 8;
processRotationByAnim = READ_LE_INT16(keyFramePtr);
- processLastRotationAngle = ToAngle((READ_LE_INT16(keyFramePtr + 4) * eax) / keyFrameLength);
+ processLastRotationAngle = ToAngle((READ_LE_INT16(keyFramePtr + 4) * deltaTime) / keyFrameLength);
lastKeyFramePtr += 8;
keyFramePtr += 8;
@@ -279,19 +277,19 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
int16 tmpNumOfPoints = numOfPointInAnim;
do {
- int16 animOpcode = getAnimMode(&edi, &keyFramePtr, &lastKeyFramePtr);
+ const int16 animOpcode = getAnimMode(&edi, &keyFramePtr, &lastKeyFramePtr);
switch (animOpcode) {
case 0: // allow global rotate
- applyAnimStepRotation(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
- applyAnimStepRotation(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
- applyAnimStepRotation(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStepRotation(&edi, deltaTime, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStepRotation(&edi, deltaTime, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStepRotation(&edi, deltaTime, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
break;
case 1: // dissallow global rotate
case 2: // dissallow global rotate + hide
- applyAnimStep(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
- applyAnimStep(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
- applyAnimStep(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStep(&edi, deltaTime, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStep(&edi, deltaTime, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStep(&edi, deltaTime, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
break;
default:
error("Unsupported animation rotation mode %d", animOpcode);
@@ -301,9 +299,9 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
} while (--tmpNumOfPoints);
}
- currentStepX = (READ_LE_INT16(keyFramePtrOld + 2) * eax) / keyFrameLength;
- currentStepY = (READ_LE_INT16(keyFramePtrOld + 4) * eax) / keyFrameLength;
- currentStepZ = (READ_LE_INT16(keyFramePtrOld + 6) * eax) / keyFrameLength;
+ currentStepX = (READ_LE_INT16(keyFramePtrOld + 2) * deltaTime) / keyFrameLength;
+ currentStepY = (READ_LE_INT16(keyFramePtrOld + 4) * deltaTime) / keyFrameLength;
+ currentStepZ = (READ_LE_INT16(keyFramePtrOld + 6) * deltaTime) / keyFrameLength;
return false;
}
@@ -398,19 +396,17 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
return 0;
}
- const uint8 *ebx = animTimerDataPtr->ptr;
- int32 ebp = animTimerDataPtr->time;
+ const uint8 *lastKeyFramePtr = animTimerDataPtr->ptr;
+ int32 remainingFrameTime = animTimerDataPtr->time;
- if (!ebx) {
- ebx = keyFramePtr;
- ebp = keyFrameLength;
+ if (!lastKeyFramePtr) {
+ lastKeyFramePtr = keyFramePtr;
+ remainingFrameTime = keyFrameLength;
}
- const uint8* lastKeyFramePtr = ebx;
-
- const int32 eax = _engine->lbaTime - ebp;
+ const int32 deltaTime = _engine->lbaTime - remainingFrameTime;
- if (eax >= keyFrameLength) {
+ if (deltaTime >= keyFrameLength) {
animTimerDataPtr->ptr = keyFramePtr;
animTimerDataPtr->time = _engine->lbaTime;
@@ -429,14 +425,14 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
keyFramePtr += 8;
processRotationByAnim = READ_LE_INT16(keyFramePtr);
- processLastRotationAngle = ToAngle((READ_LE_INT16(keyFramePtr + 4) * eax) / keyFrameLength);
+ processLastRotationAngle = ToAngle((READ_LE_INT16(keyFramePtr + 4) * deltaTime) / keyFrameLength);
lastKeyFramePtr += 8;
keyFramePtr += 8;
- currentStepX = (READ_LE_INT16(keyFramePtrOld + 2) * eax) / keyFrameLength;
- currentStepY = (READ_LE_INT16(keyFramePtrOld + 4) * eax) / keyFrameLength;
- currentStepZ = (READ_LE_INT16(keyFramePtrOld + 6) * eax) / keyFrameLength;
+ currentStepX = (READ_LE_INT16(keyFramePtrOld + 2) * deltaTime) / keyFrameLength;
+ currentStepY = (READ_LE_INT16(keyFramePtrOld + 4) * deltaTime) / keyFrameLength;
+ currentStepZ = (READ_LE_INT16(keyFramePtrOld + 6) * deltaTime) / keyFrameLength;
return 0;
}
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 320ef341e3..c3e4bc2e98 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -117,8 +117,8 @@ int32 Extra::addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx
extra->x = x;
extra->y = y;
extra->z = z;
- extra->spawnTime = actorIdx;
- extra->lifeTime = targetActor;
+ extra->payload.actorIdx = actorIdx;
+ extra->spawnTime = targetActor;
extra->destZ = maxSpeed;
extra->strengthOfHit = strengthOfHit;
@@ -142,8 +142,8 @@ int32 Extra::addExtraExplode(int32 x, int32 y, int32 z) {
extra->x = x;
extra->y = y;
extra->z = z;
- extra->spawnTime = 40;
- extra->lifeTime = _engine->lbaTime;
+ extra->payload.lifeTime = 40;
+ extra->spawnTime = _engine->lbaTime;
extra->strengthOfHit = 0;
return i;
}
@@ -175,10 +175,10 @@ void Extra::throwExtra(ExtraListStruct *extra, int32 xAngle, int32 yAngle, int32
extra->destZ = _engine->_renderer->destZ;
extra->angle = extraAngle;
- extra->lifeTime = _engine->lbaTime;
+ extra->spawnTime = _engine->lbaTime;
}
-void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) { // InitSpecial
+int32 Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) { // InitSpecial
const int16 flag = 0x8000 + (int16)type;
for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
@@ -200,10 +200,8 @@ void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
throwExtra(extra, _engine->getRandomNumber(ANGLE_90) + ANGLE_45, _engine->getRandomNumber(ANGLE_360), 50, 20);
extra->strengthOfHit = 0;
- extra->lifeTime = _engine->lbaTime;
- extra->spawnTime = 100;
- }
- if (type == ExtraSpecialType::kExplodeCloud) {
+ extra->payload.lifeTime = 100;
+ } else if (type == ExtraSpecialType::kExplodeCloud) {
extra->type = ExtraType::TIME_OUT;
extra->x = x;
@@ -211,11 +209,12 @@ void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
extra->z = z;
extra->strengthOfHit = 0;
- extra->lifeTime = _engine->lbaTime;
- extra->spawnTime = 5;
+ extra->spawnTime = _engine->lbaTime;
+ extra->payload.lifeTime = 5;
}
- break;
+ return i;
}
+ return -1;
}
int Extra::getBonusSprite(BonusParameter bonusParameter) const {
@@ -274,8 +273,7 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle
throwExtra(extra, xAngle, yAngle, 40, ToAngle(15));
extra->strengthOfHit = 0;
- extra->lifeTime = _engine->lbaTime;
- extra->spawnTime = 1000;
+ extra->payload.lifeTime = 1000;
extra->info1 = bonusAmount;
return i;
}
@@ -299,8 +297,8 @@ int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spri
throwExtra(extra, xAngle, yAngle, xRotPoint, extraAngle);
extra->strengthOfHit = strengthOfHit;
- extra->lifeTime = _engine->lbaTime;
- extra->spawnTime = actorIdx;
+ extra->spawnTime = _engine->lbaTime;
+ extra->payload.actorIdx = actorIdx;
extra->info1 = 0;
return i;
@@ -321,8 +319,8 @@ int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spr
extra->x = x;
extra->y = y;
extra->z = z;
- extra->spawnTime = actorIdx;
- extra->lifeTime = targetActorIdx;
+ extra->payload.actorIdx = actorIdx;
+ extra->spawnTime = targetActorIdx;
extra->destZ = finalAngle;
extra->strengthOfHit = strengthOfHit;
_engine->_movements->setActorAngle(ANGLE_0, finalAngle, 50, &extra->trackActorMove);
@@ -360,7 +358,7 @@ int32 Extra::addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int3
extra->x = x;
extra->y = y;
extra->z = z;
- extra->spawnTime = extraIdx;
+ extra->payload.extraIdx = extraIdx;
extra->destZ = 4000;
extra->strengthOfHit = 0;
_engine->_movements->setActorAngle(ANGLE_0, 4000, 50, &extra->trackActorMove);
@@ -526,7 +524,7 @@ void Extra::drawExtraSpecial(int32 extraIdx, int32 x, int32 y) {
drawSpecialShape(hitStarsShapeTable, x, y, 15, (_engine->lbaTime << 5) & ANGLE_270, 4);
break;
case ExtraSpecialType::kExplodeCloud: {
- int32 cloudTime = 1 + _engine->lbaTime - extra->lifeTime;
+ int32 cloudTime = 1 + _engine->lbaTime - extra->spawnTime;
if (cloudTime > 32) {
cloudTime = 32;
@@ -556,7 +554,7 @@ void Extra::processMagicballBounce(ExtraListStruct *extra, int32 x, int32 y, int
extra->z = z;
extra->lastZ = z;
- extra->lifeTime = _engine->lbaTime;
+ extra->spawnTime = _engine->lbaTime;
}
void Extra::processExtras() {
@@ -571,7 +569,7 @@ void Extra::processExtras() {
}
// process extra life time
if (extra->type & ExtraType::TIME_OUT) {
- if (extra->spawnTime + extra->lifeTime <= _engine->lbaTime) {
+ if (extra->payload.lifeTime + extra->spawnTime <= _engine->lbaTime) {
extra->info0 = -1;
continue;
}
@@ -583,7 +581,7 @@ void Extra::processExtras() {
}
//
if (extra->type & ExtraType::UNK12) {
- extra->info0 = _engine->_collision->getAverageValue(97, 100, 30, _engine->lbaTime - extra->lifeTime);
+ extra->info0 = _engine->_collision->getAverageValue(97, 100, 30, _engine->lbaTime - extra->spawnTime);
continue;
}
// process extra moving
@@ -592,14 +590,14 @@ void Extra::processExtras() {
currentExtraY = extra->y;
currentExtraZ = extra->z;
- int32 currentExtraSpeedX = extra->destX * (_engine->lbaTime - extra->lifeTime);
+ int32 currentExtraSpeedX = extra->destX * (_engine->lbaTime - extra->spawnTime);
extra->x = currentExtraSpeedX + extra->lastX;
- int32 currentExtraSpeedY = extra->destY * (_engine->lbaTime - extra->lifeTime);
+ int32 currentExtraSpeedY = extra->destY * (_engine->lbaTime - extra->spawnTime);
currentExtraSpeedY += extra->lastY;
- extra->y = currentExtraSpeedY - ABS(((extra->angle * (_engine->lbaTime - extra->lifeTime)) * (_engine->lbaTime - extra->lifeTime)) >> 4);
+ extra->y = currentExtraSpeedY - ABS(((extra->angle * (_engine->lbaTime - extra->spawnTime)) * (_engine->lbaTime - extra->spawnTime)) >> 4);
- extra->z = extra->destZ * (_engine->lbaTime - extra->lifeTime) + extra->lastZ;
+ extra->z = extra->destZ * (_engine->lbaTime - extra->spawnTime) + extra->lastZ;
// check if extra is out of scene
if (extra->y < 0 || extra->x < 0 || extra->x > 0x7E00 || extra->z < 0 || extra->z > 0x7E00) {
@@ -629,15 +627,15 @@ void Extra::processExtras() {
}
//
if (extra->type & ExtraType::BONUS) {
- if (_engine->lbaTime - extra->lifeTime > 40) {
+ if (_engine->lbaTime - extra->spawnTime > 40) {
extra->type &= ~ExtraType::BONUS;
}
continue;
}
// process actor target hit
if (extra->type & ExtraType::UNK7) {
- int32 actorIdxAttacked = extra->lifeTime;
- int32 actorIdx = extra->spawnTime;
+ int32 actorIdxAttacked = extra->spawnTime;
+ int32 actorIdx = extra->payload.actorIdx;
const ActorStruct *actor = _engine->_scene->getActor(actorIdxAttacked);
currentExtraX = actor->x;
@@ -687,8 +685,8 @@ void Extra::processExtras() {
// process magic ball extra aiming for key
if (extra->type & ExtraType::UNK9) {
// int32 actorIdxAttacked = extra->lifeTime;
- ExtraListStruct *extraKey = &extraList[extra->spawnTime];
- int32 actorIdx = extra->spawnTime;
+ ExtraListStruct *extraKey = &extraList[extra->payload.extraIdx];
+ int32 extraIdx = extra->payload.extraIdx;
int32 tmpAngle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->x, extra->z, extraKey->x, extraKey->z);
int32 angle = ClampAngle(tmpAngle - extra->angle);
@@ -726,7 +724,7 @@ void Extra::processExtras() {
_engine->_movements->setActorAngle(0, extra->destZ, 50, &extra->trackActorMove);
- if (actorIdx == _engine->_collision->checkExtraCollisionWithExtra(extra, _engine->_gameState->magicBallIdx)) {
+ if (extraIdx == _engine->_collision->checkExtraCollisionWithExtra(extra, _engine->_gameState->magicBallIdx)) {
_engine->_sound->playSample(Samples::ItemFound, 1, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->y, _engine->_scene->sceneHero->z, 0);
if (extraKey->info1 > 1) {
@@ -760,7 +758,7 @@ void Extra::processExtras() {
}
// process extra collision with actors
if (extra->type & ExtraType::UNK2) {
- if (_engine->_collision->checkExtraCollisionWithActors(extra, extra->spawnTime) != -1) {
+ if (_engine->_collision->checkExtraCollisionWithActors(extra, extra->payload.actorIdx) != -1) {
// if extra is Magic Ball
if (i == _engine->_gameState->magicBallIdx) {
int32 spriteIdx = SPRITEHQR_MAGICBALL_YELLOW_TRANS;
diff --git a/engines/twine/extra.h b/engines/twine/extra.h
index 36e177b78e..5423fb8261 100644
--- a/engines/twine/extra.h
+++ b/engines/twine/extra.h
@@ -66,8 +66,13 @@ struct ExtraListStruct {
int16 destZ = 0; // field_12
uint16 type = 0; /**< ExtraType bitmask */
int16 angle = 0; // field_16
- int32 lifeTime = 0;
- int16 spawnTime = 0; // field_ 1C
+ int32 spawnTime = 0;
+ union payload { // field_ 1C
+ int16 lifeTime;
+ int16 actorIdx;
+ int16 extraIdx;
+ int16 unknown;
+ } payload{0};
int16 strengthOfHit = 0; // field_1E
int16 info1 = 0; // field_20
};
@@ -81,7 +86,7 @@ private:
void throwExtra(ExtraListStruct *extra, int32 xAngle, int32 yAngle, int32 x, int32 extraAngle);
void processMagicballBounce(ExtraListStruct *extra, int32 x, int32 y, int32 z);
int32 findExtraKey();
- int32 addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 spawnTime);
+ int32 addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 extraIdx);
void drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 color, int32 angle, int32 size);
public:
@@ -101,7 +106,7 @@ public:
/** Reset all used extras */
void resetExtras();
- void addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type);
+ int32 addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type);
int32 addExtraBonus(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle, int32 type, int32 bonusAmount);
int32 addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 xAngle, int32 yAngle, int32 xRotPoint, int32 extraAngle, int32 strengthOfHit);
int32 addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 finalAngle, int32 strengthOfHit);
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 3042a579a9..6333df73c1 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -314,13 +314,13 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
ExtraListStruct *extra = &_engine->_extra->extraList[i];
if (extra->info0 != -1) {
if (extra->type & ExtraType::TIME_IN) {
- if (_engine->lbaTime - extra->lifeTime > 35) {
- extra->lifeTime = _engine->lbaTime;
+ if (_engine->lbaTime - extra->spawnTime > 35) {
+ extra->spawnTime = _engine->lbaTime;
extra->type &= ~ExtraType::TIME_IN;
_engine->_sound->playSample(Samples::ItemPopup, 1, extra->x, extra->y, extra->z);
}
} else {
- if ((extra->type & ExtraType::TIME_OUT) || (extra->type & ExtraType::FLASH) || (extra->spawnTime + extra->lifeTime - 150 < _engine->lbaTime) || (!((_engine->lbaTime + extra->lifeTime) & 8))) {
+ if ((extra->type & ExtraType::TIME_OUT) || (extra->type & ExtraType::FLASH) || (extra->payload.lifeTime + extra->spawnTime - 150 < _engine->lbaTime) || (!((_engine->lbaTime + extra->spawnTime) & 8))) {
_engine->_renderer->projectPositionOnScreen(extra->x - _engine->_grid->cameraX, extra->y - _engine->_grid->cameraY, extra->z - _engine->_grid->cameraZ);
if (_engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < 680 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < 580) {
Commit: ddc7e2275311c00cd477d2b9f0de28ff143ffc4c
https://github.com/scummvm/scummvm/commit/ddc7e2275311c00cd477d2b9f0de28ff143ffc4c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:06:10+01:00
Commit Message:
TWINE: renamed members + const
Changed paths:
engines/twine/animations.cpp
engines/twine/animations.h
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index d11fce2115..9d210118ac 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -68,12 +68,12 @@ enum ActionType {
ACTION_LAST
};
-Animations::Animations(TwinEEngine *engine) : _engine(engine) {
- animBuffer1 = animBuffer2 = (uint8 *)malloc(5000 * sizeof(uint8));
+Animations::Animations(TwinEEngine *engine) : _engine(engine), animBuffer((uint8 *)malloc(5000 * sizeof(uint8))) {
+ animBufferPos = animBuffer;
}
Animations::~Animations() {
- free(animBuffer1);
+ free(animBuffer);
}
int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
@@ -344,14 +344,14 @@ int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
return 0;
}
-int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
- uint8 *animPtr = animBuffer2;
+int32 Animations::stockAnimation(const uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
+ uint8 *animPtr = animBufferPos;
int32 bodyHeader = READ_LE_INT16(bodyPtr);
if (!(bodyHeader & 2)) {
return 0;
}
- const uint8 *ptr = (bodyPtr + 0x10);
+ const uint8 *ptr = bodyPtr + 16;
animTimerDataPtr->time = _engine->lbaTime;
animTimerDataPtr->ptr = animPtr;
@@ -378,10 +378,10 @@ int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerD
esi = (const int32 *)(((const int8 *)esi) + 30);
} while (counter--);
- animBuffer2 += var2;
+ animBufferPos += var2;
- if (animBuffer1 + 4488 < animBuffer2) {
- animBuffer2 = animBuffer1;
+ if (animBuffer + 4488 < animBufferPos) {
+ animBufferPos = animBuffer;
}
return var2;
@@ -708,9 +708,9 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
if (actor->previousAnimIdx == -1) { // if no previous animation
setAnimAtKeyframe(0, _engine->_resources->animTable[animIndex], _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
} else { // interpolation between animations
- animBuffer2 += stockAnimation(_engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
- if (animBuffer1 + 4488 < animBuffer2) {
- animBuffer2 = animBuffer1;
+ animBufferPos += stockAnimation(_engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
+ if (animBuffer + 4488 < animBufferPos) {
+ animBufferPos = animBuffer;
}
}
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index 116b145fda..cb66bf5520 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -47,8 +47,8 @@ private:
*/
int32 verifyAnimAtKeyframe(int32 animPos, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
- uint8 *animBuffer1 = nullptr;
- uint8 *animBuffer2 = nullptr;
+ uint8 *const animBuffer;
+ uint8 *animBufferPos = nullptr;
/** Rotation by anim and not by engine */
int16 processRotationByAnim = 0; // processActorVar5
@@ -113,7 +113,7 @@ public:
* @param bodyPtr Body model poitner
* @param animTimerDataPtr Animation time data
*/
- int32 stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
+ int32 stockAnimation(const uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
/**
* Initialize animation
Commit: ae7e2c0eda108258d04590e3f5f03579b9ed1483
https://github.com/scummvm/scummvm/commit/ae7e2c0eda108258d04590e3f5f03579b9ed1483
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:06:29+01:00
Commit Message:
TWINE: const + converted to bool
Changed paths:
engines/twine/animations.cpp
engines/twine/animations.h
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 9d210118ac..d81db4f19e 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -387,13 +387,13 @@ int32 Animations::stockAnimation(const uint8 *bodyPtr, AnimTimerDataStruct *anim
return var2;
}
-int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
+bool Animations::verifyAnimAtKeyframe(int32 animIdx, const uint8 *animPtr, const uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
const int32 numOfPointInAnim = READ_LE_INT16(animPtr + 2);
const uint8 *keyFramePtr = ((numOfPointInAnim * 8 + 8) * animIdx) + animPtr + 8;
const int32 keyFrameLength = READ_LE_INT16(keyFramePtr);
const int16 bodyHeader = READ_LE_INT16(bodyPtr);
if (!(bodyHeader & 2)) {
- return 0;
+ return false;
}
const uint8 *lastKeyFramePtr = animTimerDataPtr->ptr;
@@ -417,7 +417,7 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
processRotationByAnim = READ_LE_INT16(keyFramePtr + 8);
processLastRotationAngle = ToAngle(READ_LE_INT16(keyFramePtr + 12));
- return 1;
+ return true;
}
const uint8 *keyFramePtrOld = keyFramePtr;
@@ -434,7 +434,7 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
currentStepY = (READ_LE_INT16(keyFramePtrOld + 4) * deltaTime) / keyFrameLength;
currentStepZ = (READ_LE_INT16(keyFramePtrOld + 6) * deltaTime) / keyFrameLength;
- return 0;
+ return false;
}
void Animations::processAnimActions(int32 actorIdx) {
@@ -847,9 +847,9 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
}
} else { // 3D actor
if (actor->previousAnimIdx != -1) {
- uint8 *animPtr = _engine->_resources->animTable[actor->previousAnimIdx];
+ const uint8 *animPtr = _engine->_resources->animTable[actor->previousAnimIdx];
- int32 keyFramePassed = verifyAnimAtKeyframe(actor->animPosition, animPtr, _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
+ bool keyFramePassed = verifyAnimAtKeyframe(actor->animPosition, animPtr, _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
if (processRotationByAnim) {
actor->dynamicFlags.bIsRotationByAnim = 1;
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index cb66bf5520..dd454a80cb 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -45,7 +45,7 @@ private:
* @param bodyPtr Body model poitner
* @param animTimerDataPtr Animation time data
*/
- int32 verifyAnimAtKeyframe(int32 animPos, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
+ bool verifyAnimAtKeyframe(int32 animPos, const uint8 *animPtr, const uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
uint8 *const animBuffer;
uint8 *animBufferPos = nullptr;
Commit: 3747cdd901a76c8c193d450bdddee6e1a0d7895a
https://github.com/scummvm/scummvm/commit/3747cdd901a76c8c193d450bdddee6e1a0d7895a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:07:01+01:00
Commit Message:
TWINE: helper method to check model header value
Changed paths:
engines/twine/animations.cpp
engines/twine/animations.h
engines/twine/renderer.h
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index d81db4f19e..0263d9ef73 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -82,16 +82,14 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
return numOfKeyframeInAnim;
}
+ if (!Model::isAnimated(bodyPtr)) {
+ return 0;
+ }
+
int16 numOfBonesInAnim = READ_LE_INT16(animPtr + 2);
const uint8 *ptrToData = (const uint8 *)((numOfBonesInAnim * 8 + 8) * keyframeIdx + animPtr + 8);
- const int16 bodyHeader = READ_LE_INT16(bodyPtr);
-
- if (!(bodyHeader & 2)) {
- return 0;
- }
-
uint8 *ptrToBodyData = bodyPtr + 14;
animTimerDataPtr->ptr = ptrToData;
@@ -345,12 +343,11 @@ int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
}
int32 Animations::stockAnimation(const uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
- uint8 *animPtr = animBufferPos;
- int32 bodyHeader = READ_LE_INT16(bodyPtr);
-
- if (!(bodyHeader & 2)) {
+ if (!Model::isAnimated(bodyPtr)) {
return 0;
}
+ uint8 *animPtr = animBufferPos;
+
const uint8 *ptr = bodyPtr + 16;
animTimerDataPtr->time = _engine->lbaTime;
@@ -387,14 +384,10 @@ int32 Animations::stockAnimation(const uint8 *bodyPtr, AnimTimerDataStruct *anim
return var2;
}
-bool Animations::verifyAnimAtKeyframe(int32 animIdx, const uint8 *animPtr, const uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
+bool Animations::verifyAnimAtKeyframe(int32 animIdx, const uint8 *animPtr, AnimTimerDataStruct *animTimerDataPtr) {
const int32 numOfPointInAnim = READ_LE_INT16(animPtr + 2);
const uint8 *keyFramePtr = ((numOfPointInAnim * 8 + 8) * animIdx) + animPtr + 8;
const int32 keyFrameLength = READ_LE_INT16(keyFramePtr);
- const int16 bodyHeader = READ_LE_INT16(bodyPtr);
- if (!(bodyHeader & 2)) {
- return false;
- }
const uint8 *lastKeyFramePtr = animTimerDataPtr->ptr;
int32 remainingFrameTime = animTimerDataPtr->time;
@@ -849,7 +842,10 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
if (actor->previousAnimIdx != -1) {
const uint8 *animPtr = _engine->_resources->animTable[actor->previousAnimIdx];
- bool keyFramePassed = verifyAnimAtKeyframe(actor->animPosition, animPtr, _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
+ bool keyFramePassed = false;
+ if (Model::isAnimated(_engine->_actor->bodyTable[actor->entity])) {
+ keyFramePassed = verifyAnimAtKeyframe(actor->animPosition, animPtr, &actor->animTimerData);;
+ }
if (processRotationByAnim) {
actor->dynamicFlags.bIsRotationByAnim = 1;
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index dd454a80cb..5ecb81ba7d 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -42,10 +42,9 @@ private:
* Verify animation at keyframe
* @param animIdx Animation index
* @param animPtr Animation pointer
- * @param bodyPtr Body model poitner
* @param animTimerDataPtr Animation time data
*/
- bool verifyAnimAtKeyframe(int32 animPos, const uint8 *animPtr, const uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
+ bool verifyAnimAtKeyframe(int32 animPos, const uint8 *animPtr, AnimTimerDataStruct *animTimerDataPtr);
uint8 *const animBuffer;
uint8 *animBufferPos = nullptr;
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index 07f7d6558c..6a67c2c929 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -23,6 +23,7 @@
#ifndef TWINE_RENDERER_H
#define TWINE_RENDERER_H
+#include "common/endian.h"
#include "common/scummsys.h"
#include "common/rect.h"
@@ -65,22 +66,22 @@ struct Matrix {
struct Model {
struct BodyFlags {
- uint16 unk1 : 1;
- uint16 animated : 1;
- uint16 unk3 : 1;
- uint16 unk4 : 1;
- uint16 unk5 : 1;
- uint16 unk6 : 1;
- uint16 unk7 : 1;
- uint16 alreadyPrepared : 1;
- uint16 unk9 : 1;
- uint16 unk10 : 1;
- uint16 unk11 : 1;
- uint16 unk12 : 1;
- uint16 unk13 : 1;
- uint16 unk14 : 1;
- uint16 unk15 : 1;
- uint16 unk16 : 1;
+ uint16 unk1 : 1; // 1 << 0
+ uint16 animated : 1; // 1 << 1
+ uint16 unk3 : 1; // 1 << 2
+ uint16 unk4 : 1; // 1 << 3
+ uint16 unk5 : 1; // 1 << 4
+ uint16 unk6 : 1; // 1 << 5
+ uint16 unk7 : 1; // 1 << 6
+ uint16 alreadyPrepared : 1; // 1 << 7
+ uint16 unk9 : 1; // 1 << 8
+ uint16 unk10 : 1; // 1 << 9
+ uint16 unk11 : 1; // 1 << 10
+ uint16 unk12 : 1; // 1 << 11
+ uint16 unk13 : 1; // 1 << 12
+ uint16 unk14 : 1; // 1 << 13
+ uint16 unk15 : 1; // 1 << 14
+ uint16 unk16 : 1; // 1 << 15
} bodyFlag;
int16 minsx = 0;
int16 maxsx = 0;
@@ -89,6 +90,11 @@ struct Model {
int16 minsz = 0;
int16 maxsz = 0;
int16 offsetToData = 0;
+
+ static inline bool isAnimated(const uint8* bodyPtr) {
+ const int16 bodyHeader = READ_LE_INT16(bodyPtr);
+ return (bodyHeader & 2) != 0;
+ }
};
class Renderer {
Commit: ef92147a259a5cfacbd799da9c527d208a16d633
https://github.com/scummvm/scummvm/commit/ef92147a259a5cfacbd799da9c527d208a16d633
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:07:23+01:00
Commit Message:
TWINE: cleanup in animation code
Changed paths:
engines/twine/animations.cpp
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 0263d9ef73..1f8aa8b3d5 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -348,25 +348,23 @@ int32 Animations::stockAnimation(const uint8 *bodyPtr, AnimTimerDataStruct *anim
}
uint8 *animPtr = animBufferPos;
- const uint8 *ptr = bodyPtr + 16;
+ const uint8 *verticesBase = bodyPtr + 0x1A;
animTimerDataPtr->time = _engine->lbaTime;
animTimerDataPtr->ptr = animPtr;
- int32 var0 = READ_LE_INT16(ptr - 2);
- ptr = ptr + var0;
+ int32 numVertices = READ_LE_INT16(verticesBase);
+ const uint8 *ptr = verticesBase + numVertices * 6 + 2;
- int32 var1 = READ_LE_INT16(ptr);
- var1 = var1 + var1 * 2;
+ int32 numBones = READ_LE_INT16(ptr);
+ ptr += 2;
- ptr = ptr + var1 * 2 + 2;
-
- int32 var2 = READ_LE_INT16(ptr);
- int32 counter = var2;
- var2 = (var2 * 8) + 8;
+ int32 counter = numBones;
+ // 8 = 4xint16 - firstpoint, numpoints, basepoint, baseelement - see elementEntry
+ int32 var2 = (numBones * 8) + 8;
int32 *edi = (int32 *)(animPtr + 8);
- const int32 *esi = (const int32 *)(ptr + 10);
+ const int32 *esi = (const int32 *)(ptr + 8);
do {
*(edi++) = *(esi++);
@@ -698,9 +696,11 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
animType = 2;
}
- if (actor->previousAnimIdx == -1) { // if no previous animation
+ if (actor->previousAnimIdx == -1) {
+ // if no previous animation
setAnimAtKeyframe(0, _engine->_resources->animTable[animIndex], _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
- } else { // interpolation between animations
+ } else {
+ // interpolation between animations
animBufferPos += stockAnimation(_engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
if (animBuffer + 4488 < animBufferPos) {
animBufferPos = animBuffer;
Commit: 298dd1f4686b968b0561433c1ac03e32004e364b
https://github.com/scummvm/scummvm/commit/298dd1f4686b968b0561433c1ac03e32004e364b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:07:31+01:00
Commit Message:
TWINE: cleanup in animation code
Changed paths:
engines/twine/animations.cpp
engines/twine/animations.h
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 1f8aa8b3d5..78936dbf2d 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -76,7 +76,7 @@ Animations::~Animations() {
free(animBuffer);
}
-int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
+int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
const int16 numOfKeyframeInAnim = READ_LE_INT16(animPtr);
if (keyframeIdx >= numOfKeyframeInAnim) {
return numOfKeyframeInAnim;
@@ -90,21 +90,20 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
const uint8 *ptrToData = (const uint8 *)((numOfBonesInAnim * 8 + 8) * keyframeIdx + animPtr + 8);
- uint8 *ptrToBodyData = bodyPtr + 14;
-
animTimerDataPtr->ptr = ptrToData;
animTimerDataPtr->time = _engine->lbaTime;
- ptrToBodyData = ptrToBodyData + READ_LE_INT16(ptrToBodyData) + 2;
-
- const int16 numOfElementInBody = READ_LE_INT16(ptrToBodyData);
+ uint8 *verticesBase = bodyPtr + 0x1A;
+ int32 numVertices = READ_LE_INT16(verticesBase);
- ptrToBodyData = ptrToBodyData + numOfElementInBody * 6 + 12;
+ uint8 *bonesBase = verticesBase + numVertices * 6 + 2;
+ const int16 numBones = READ_LE_INT16(bonesBase);
- const int16 numOfPointInBody = READ_LE_INT16(ptrToBodyData - 10); // num elements
+ uint8 *bonesPtr = bonesBase + 2;
+ bonesPtr += 8;
- if (numOfBonesInAnim > numOfPointInBody) {
- numOfBonesInAnim = numOfPointInBody;
+ if (numOfBonesInAnim > numBones) {
+ numOfBonesInAnim = numBones;
}
const uint8 *ptrToDataBackup = ptrToData;
@@ -113,16 +112,15 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
do {
for (int32 i = 0; i < 8; i++) {
- *(ptrToBodyData++) = *(ptrToData++);
+ *bonesPtr++ = *ptrToData++;
}
- ptrToBodyData += 30;
-
+ bonesPtr += 30;
} while (--numOfBonesInAnim);
ptrToData = ptrToDataBackup + 2;
- currentStepX = READ_LE_INT16(ptrToData);
+ currentStepX = READ_LE_INT16(ptrToData + 0);
currentStepY = READ_LE_INT16(ptrToData + 2);
currentStepZ = READ_LE_INT16(ptrToData + 4);
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index 5ecb81ba7d..4e03b7c159 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -77,7 +77,7 @@ public:
* @param bodyPtr Body model poitner
* @param animTimerDataPtr Animation time data
*/
- int32 setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
+ int32 setAnimAtKeyframe(int32 keyframeIdx, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
/**
* Get total number of keyframes in animation
More information about the Scummvm-git-logs
mailing list