Review animateMoveObjectToObject

See #32
This commit is contained in:
Alexander Batalov 2022-06-10 10:40:22 +03:00
parent dae87e0964
commit e3c27a3def
1 changed files with 10 additions and 13 deletions

View File

@ -1866,36 +1866,33 @@ int _make_straight_path_func(Object* a1, int from, int to, STRUCT_530014_28* a4,
// 0x4167F8 // 0x4167F8
int animateMoveObjectToObject(Object* from, Object* to, int a3, int anim, int animationSequenceIndex) int animateMoveObjectToObject(Object* from, Object* to, int a3, int anim, int animationSequenceIndex)
{ {
int v10;
int v13;
STRUCT_530014* ptr;
bool hidden = (to->flags & OBJECT_HIDDEN); bool hidden = (to->flags & OBJECT_HIDDEN);
to->flags |= OBJECT_HIDDEN; to->flags |= OBJECT_HIDDEN;
v10 = _anim_move(from, to->tile, to->elevation, -1, anim, 0, animationSequenceIndex); int moveSadIndex = _anim_move(from, to->tile, to->elevation, -1, anim, 0, animationSequenceIndex);
if (!hidden) { if (!hidden) {
to->flags &= ~OBJECT_HIDDEN; to->flags &= ~OBJECT_HIDDEN;
} }
if (v10 == -1) { if (moveSadIndex == -1) {
return -1; return -1;
} }
ptr = &(_sad[v10]); STRUCT_530014* ptr = &(_sad[moveSadIndex]);
v13 = (((from->flags & OBJECT_MULTIHEX) != 0) + 1); // TODO: What the hell is this? // NOTE: Original code is somewhat different. Due to some kind of
ptr->field_1C -= v13; // optimization this value is either 1 or 2, which is later used in
// subsequent calculations and rotations array lookup.
bool isMultihex = (from->flags & OBJECT_MULTIHEX);
ptr->field_1C -= (isMultihex ? 2 : 1);
if (ptr->field_1C <= 0) { if (ptr->field_1C <= 0) {
ptr->field_20 = -1000; ptr->field_20 = -1000;
_anim_set_continue(animationSequenceIndex, 0); _anim_set_continue(animationSequenceIndex, 0);
} }
if (v13) { ptr->field_24 = tileGetTileInDirection(to->tile, ptr->rotations[isMultihex ? ptr->field_1C + 1 : ptr->field_1C], 1);
ptr->field_24 = tileGetTileInDirection(to->tile, ptr->field_24 + v13 + ptr->field_1C + 3, 1);
}
if (v13 == 2) { if (isMultihex) {
ptr->field_24 = tileGetTileInDirection(ptr->field_24, ptr->rotations[ptr->field_1C], 1); ptr->field_24 = tileGetTileInDirection(ptr->field_24, ptr->rotations[ptr->field_1C], 1);
} }