tr2/inventory: fix button mashing loading game instead of saving

Resolves #2863.
This commit is contained in:
Marcin Kurczewski 2025-04-26 17:59:35 +02:00
parent 0ba717edd5
commit 88f41c5a75
4 changed files with 25 additions and 11 deletions

View file

@ -5,6 +5,7 @@
- changed the sound dialog appearance (repositioned, added text labels and arrows)
- fixed Lara voiding if she stops on a tile with a closing door, and the door isn't on a portal (#2848)
- fixed guns carried by enemies not being converted to ammo if Lara has picked up the same gun elsewhere in the same level (#2856)
- fixed button mashing triggering load instead of save on a specific passport animation frame (#2863, regression from 1.0)
- fixed guns carried by enemies not being converted to ammo if Lara starts the level with the gun and the game has later been reloaded (#2850, regression from 1.0)
- fixed 1920x1080 screenshots in 16:9 aspect mode being saved as 1919x1080 (#2845, regression from 0.8)
- fixed clicks in audio sounds (#2846, regression from 0.2)

View file

@ -694,7 +694,6 @@ static GF_COMMAND M_Control(INV_RING *const ring)
InvRing_MotionSetup(ring, RNG_CLOSING_ITEM, RNG_DESELECT, 0);
g_Input = (INPUT_STATE) {};
g_InputDB = (INPUT_STATE) {};
if (ring->mode == INV_LOAD_MODE || ring->mode == INV_SAVE_MODE
|| ring->mode == INV_SAVE_CRYSTAL_MODE) {
InvRing_MotionSetup(
@ -713,7 +712,7 @@ static GF_COMMAND M_Control(INV_RING *const ring)
}
if (ring->mode == INV_TITLE_MODE
&& ((inv_item->object_id == O_DETAIL_OPTION)
&& (inv_item->object_id == O_DETAIL_OPTION
|| inv_item->object_id == O_SOUND_OPTION
|| inv_item->object_id == O_CONTROL_OPTION
|| inv_item->object_id == O_GAMMA_OPTION)) {

View file

@ -639,10 +639,10 @@ static GF_COMMAND M_Control(INV_RING *const ring)
if (g_InputDB.menu_confirm) {
g_Inv_Chosen = inv_item->object_id;
if (ring->type != RT_MAIN) {
g_InvRing_Source[RT_OPTION].current = ring->current_object;
} else {
if (ring->type == RT_MAIN) {
g_InvRing_Source[RT_MAIN].current = ring->current_object;
} else {
g_InvRing_Source[RT_OPTION].current = ring->current_object;
}
if (ring->mode == INV_TITLE_MODE
&& (inv_item->object_id == O_DETAIL_OPTION
@ -783,7 +783,7 @@ INV_RING *InvRing_Open(const INVENTORY_MODE mode)
}
for (int32_t i = 0; i < 8; i++) {
g_Inv_ExtraData[i] = 0;
g_Inv_ExtraData[i] = -1;
}
g_InvRing_Source[RT_MAIN].current = 0;

View file

@ -66,6 +66,8 @@ static void M_LoadGame(INVENTORY_ITEM *inv_item);
static void M_SaveGame(INVENTORY_ITEM *inv_item);
static void M_NewGame(void);
static void M_PlayAnyLevel(INVENTORY_ITEM *inv_item);
static int32_t M_GetCurrentPage(const INVENTORY_ITEM *inv_item);
static bool M_IsFlipping(const INVENTORY_ITEM *inv_item);
static void M_FlipLeft(INVENTORY_ITEM *inv_item);
static void M_FlipRight(INVENTORY_ITEM *inv_item);
static void M_Close(INVENTORY_ITEM *inv_item);
@ -318,6 +320,17 @@ static void M_PlayAnyLevel(INVENTORY_ITEM *const inv_item)
}
}
static int32_t M_GetCurrentPage(const INVENTORY_ITEM *const inv_item)
{
const int32_t frame = inv_item->goal_frame - inv_item->open_frame;
return frame % 5 == 0 ? frame / 5 : -1;
}
static bool M_IsFlipping(const INVENTORY_ITEM *const inv_item)
{
return M_GetCurrentPage(inv_item) == -1;
}
static void M_FlipLeft(INVENTORY_ITEM *const inv_item)
{
M_RemoveAllText();
@ -413,18 +426,19 @@ void Option_Passport_Control(INVENTORY_ITEM *const item, const bool is_busy)
InvRing_RemoveAllText();
const int32_t frame = item->goal_frame - item->open_frame;
const int32_t page = frame % 5 == 0 ? frame / 5 : -1;
const bool is_flipping = page == -1;
if (is_flipping) {
if (M_IsFlipping(item)) {
return;
}
m_State.current_page = page;
m_State.current_page = M_GetCurrentPage(item);
if (m_State.current_page < m_State.active_page) {
M_FlipRight(item);
g_Input = (INPUT_STATE) {};
g_InputDB = (INPUT_STATE) {};
} else if (m_State.current_page > m_State.active_page) {
M_FlipLeft(item);
g_Input = (INPUT_STATE) {};
g_InputDB = (INPUT_STATE) {};
} else {
m_State.is_ready = true;
M_ShowPage(item);