Skip to content

Commit

Permalink
tr2/lara/control: fix testing triggers too early
Browse files Browse the repository at this point in the history
This puts Lara's calls to test triggers before her animation updates,
to be in line with the original game.

Resolves LostArtefacts#2205.
  • Loading branch information
lahm86 committed Jan 3, 2025
1 parent d9df2a5 commit 93f3a97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-0.8...develop) - ××××-××-××
- added Linux builds and toolchain (#1598)
- fixed Lara activating triggers one frame too early (#2205, regression from 0.7)

## [0.8](https://github.com/LostArtefacts/TRX/compare/tr2-0.8...tr2-0.8) - 2025-01-01
- completed decompilation efforts – TR2X.dll is gone, Tomb2.exe no longer needed (#1694)
Expand Down
1 change: 0 additions & 1 deletion src/libtrx/include/libtrx/game/collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ typedef struct __PACKING {
int16_t facing;
int16_t quadrant;
int16_t coll_type;
int16_t *trigger; // TODO: linked to g_TriggerIndex, so to be eliminated
int8_t x_tilt;
int8_t z_tilt;
int8_t hit_by_baddie;
Expand Down
11 changes: 5 additions & 6 deletions src/tr2/game/lara/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ void Lara_HandleAboveWater(ITEM *const item, COLL_INFO *const coll)
coll->old_anim_num = item->anim_num;
coll->old_frame_num = item->frame_num;
coll->radius = LARA_RADIUS;
coll->trigger = NULL;

coll->slopes_are_walls = 0;
coll->slopes_are_pits = 0;
Expand Down Expand Up @@ -251,6 +250,7 @@ void Lara_HandleAboveWater(ITEM *const item, COLL_INFO *const coll)
}
item->rot.y += g_Lara.turn_rate;

Room_TestTriggers(item);
Lara_Animate(item);

if (!g_Lara.extra_anim && g_Lara.water_status != LWS_CHEAT) {
Expand All @@ -262,7 +262,6 @@ void Lara_HandleAboveWater(ITEM *const item, COLL_INFO *const coll)

Item_UpdateRoom(item, -LARA_HEIGHT / 2);
Gun_Control();
Room_TestTriggers(item);
}

void Lara_HandleSurface(ITEM *const item, COLL_INFO *const coll)
Expand All @@ -273,7 +272,6 @@ void Lara_HandleSurface(ITEM *const item, COLL_INFO *const coll)
coll->old.y = item->pos.y;
coll->old.z = item->pos.z;
coll->radius = LARA_RADIUS;
coll->trigger = NULL;

coll->bad_pos = NO_BAD_POS;
coll->bad_neg = -STEP_L / 2;
Expand Down Expand Up @@ -306,7 +304,9 @@ void Lara_HandleSurface(ITEM *const item, COLL_INFO *const coll)
Lara_WaterCurrent(coll);
}

Room_TestTriggers(item);
Lara_Animate(item);

item->pos.x +=
(item->fall_speed * Math_Sin(g_Lara.move_angle)) >> (W2V_SHIFT + 2);
item->pos.z +=
Expand All @@ -320,7 +320,6 @@ void Lara_HandleSurface(ITEM *const item, COLL_INFO *const coll)

Item_UpdateRoom(item, 100);
Gun_Control();
Room_TestTriggers(item);
}

void Lara_HandleUnderwater(ITEM *const item, COLL_INFO *const coll)
Expand All @@ -329,7 +328,6 @@ void Lara_HandleUnderwater(ITEM *const item, COLL_INFO *const coll)
coll->old.y = item->pos.y;
coll->old.z = item->pos.z;
coll->radius = LARA_RADIUS_UW;
coll->trigger = NULL;

coll->bad_pos = NO_BAD_POS;
coll->bad_neg = -LARA_HEIGHT_UW;
Expand Down Expand Up @@ -378,7 +376,9 @@ void Lara_HandleUnderwater(ITEM *const item, COLL_INFO *const coll)
Lara_WaterCurrent(coll);
}

Room_TestTriggers(item);
Lara_Animate(item);

item->pos.y -=
(item->fall_speed * Math_Sin(item->rot.x)) >> (W2V_SHIFT + 2);
item->pos.x +=
Expand Down Expand Up @@ -409,7 +409,6 @@ void Lara_HandleUnderwater(ITEM *const item, COLL_INFO *const coll)

Item_UpdateRoom(item, 0);
Gun_Control();
Room_TestTriggers(item);
}

void Lara_Control(const int16_t item_num)
Expand Down

0 comments on commit 93f3a97

Please sign in to comment.