Skip to content

Commit

Permalink
tr2/objects/switch: fix weird airlock interaction
Browse files Browse the repository at this point in the history
Resolves #2186.
  • Loading branch information
rr- committed Jan 1, 2025
1 parent 13c15af commit 7c4a95a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- fixed Lara spawning air bubbles above water surfaces during the fly cheat (#2115, regression from 0.3)
- fixed demos playing too eagerly (#2068, regression from 0.3)
- fixed Lara sometimes being unable to use switches (#2184, regression from 0.6)
- fixed Lara interacting with airlock switches in unexpected ways (#2186, regression from 0.6)
- improved the animation of Lara's braid (#2094)

## [0.7.1](https://github.com/LostArtefacts/TRX/compare/tr2-0.7...tr2-0.7.1) - 2024-12-17
Expand Down
20 changes: 11 additions & 9 deletions src/tr2/game/objects/general/switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ static void M_AlignLara(ITEM *const lara_item, ITEM *const switch_item)
{
switch (switch_item->object_id) {
case O_SWITCH_TYPE_AIRLOCK:
if (switch_item->current_anim_state == SWITCH_STATE_ON) {
return;
}
Item_AlignPosition(&m_AirlockPosition, switch_item, lara_item);
break;

Expand All @@ -65,17 +62,17 @@ static void M_AlignLara(ITEM *const lara_item, ITEM *const switch_item)
static void M_SwitchOn(ITEM *const switch_item, ITEM *const lara_item)
{
switch (switch_item->object_id) {
default:
lara_item->anim_num = g_Objects[O_LARA].anim_idx + LA_WALL_SWITCH_DOWN;
break;

case O_SWITCH_TYPE_SMALL:
lara_item->anim_num = g_Objects[O_LARA].anim_idx + LA_SWITCH_SMALL_DOWN;
break;

case O_SWITCH_TYPE_BUTTON:
lara_item->anim_num = g_Objects[O_LARA].anim_idx + LA_BUTTON_PUSH;
break;

default:
lara_item->anim_num = g_Objects[O_LARA].anim_idx + LA_WALL_SWITCH_DOWN;
break;
}

lara_item->current_anim_state = LS_SWITCH_ON;
Expand Down Expand Up @@ -123,16 +120,21 @@ void Switch_Setup(OBJECT *const obj, const bool underwater)
void Switch_Collision(
const int16_t item_num, ITEM *const lara_item, COLL_INFO *const coll)
{
ITEM *const item = &g_Items[item_num];
ITEM *const item = Item_Get(item_num);
if (!g_Input.action || item->status != IS_INACTIVE
|| g_Lara.gun_status != LGS_ARMLESS || lara_item->gravity
|| lara_item->current_anim_state != LS_STOP
|| !Item_TestPosition(m_SwitchBounds, &g_Items[item_num], lara_item)) {
|| !Item_TestPosition(m_SwitchBounds, item, lara_item)) {
return;
}

lara_item->rot.y = item->rot.y;

if (item->object_id == O_SWITCH_TYPE_AIRLOCK
&& item->current_anim_state == SWITCH_STATE_ON) {
return;
}

M_AlignLara(lara_item, item);

if (item->current_anim_state == SWITCH_STATE_ON) {
Expand Down

0 comments on commit 7c4a95a

Please sign in to comment.