Skip to content

Commit

Permalink
items: fix TR1 item underwater SFX test
Browse files Browse the repository at this point in the history
This restores the TR1 behaviour of checking if the item is underwater
to determine the SFX play mode of anim commands. TR2 only plays
underwater SFX for specific object types.
  • Loading branch information
lahm86 committed Jan 19, 2025
1 parent 391bddc commit c873f55
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libtrx/game/items.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,15 @@ void Item_PlayAnimSFX(
}

const ITEM *const lara_item = Lara_GetItem();
const bool item_underwater =
(Room_Get(item->room_num)->flags & RF_UNDERWATER) != 0;
const ANIM_COMMAND_ENVIRONMENT mode = data->environment;

if (mode != ACE_ALL && item->room_num != NO_ROOM) {
int32_t height = NO_HEIGHT;
if (item == lara_item) {
height = Lara_GetLaraInfo()->water_surface_dist;
} else if (Room_Get(item->room_num)->flags & RF_UNDERWATER) {
} else if (item_underwater) {
height = -STEP_L;
}

Expand All @@ -252,7 +254,9 @@ void Item_PlayAnimSFX(
SOUND_PLAY_MODE play_mode = SPM_NORMAL;
if (item == lara_item) {
play_mode = SPM_ALWAYS;
} else if (Object_IsObjectType(item->object_id, g_WaterObjects)) {
} else if (
Object_IsObjectType(item->object_id, g_WaterObjects)
|| (TR_VERSION == 1 && item_underwater)) {
play_mode = SPM_UNDERWATER;
}
#if TR_VERSION > 1
Expand Down

0 comments on commit c873f55

Please sign in to comment.