From f720132b92ae8bd5b003cab410b1cdcecffa269b Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:18:54 +0000 Subject: [PATCH 1/2] tr1/inventory: reset selected item on closing inventory This resets the selected key item when the inventory is closed to avoid it being pre-selected to a non-existent item when the inventory is re-opened. Resolves #1586. --- docs/tr1/CHANGELOG.md | 1 + src/tr1/config.h | 1 + src/tr1/config_map.def | 1 + src/tr1/game/inventory.h | 1 + src/tr1/game/inventory/inventory_func.c | 8 ++++++-- src/tr1/game/phase/phase_inventory.c | 4 ++++ tools/tr1/config/TR1X_ConfigTool/Resources/Lang/en.json | 4 ++++ tools/tr1/config/TR1X_ConfigTool/Resources/Lang/es.json | 4 ++++ tools/tr1/config/TR1X_ConfigTool/Resources/Lang/fr.json | 4 ++++ tools/tr1/config/TR1X_ConfigTool/Resources/Lang/it.json | 4 ++++ .../config/TR1X_ConfigTool/Resources/specification.json | 5 +++++ 11 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/tr1/CHANGELOG.md b/docs/tr1/CHANGELOG.md index 841ac034e..cdd70fbb7 100644 --- a/docs/tr1/CHANGELOG.md +++ b/docs/tr1/CHANGELOG.md @@ -5,6 +5,7 @@ - added a special target, "pickup", to item-based console commands - added support for custom levels to enforce values for any config setting (#1846) - added support for key/puzzle/pickup descriptions, allowing players to examine said items in the inventory (#1821) +- added an option to fix inventory item usage duplication (#1586) - changed OpenGL backend to use version 3.3, with fallback to 2.1 if initialization fails (#1738) - changed text backend to accept named sequences. Currently supported sequences (limited by the sprites available in OG): - `\{umlaut}` diff --git a/src/tr1/config.h b/src/tr1/config.h index e93f26d14..c4da95985 100644 --- a/src/tr1/config.h +++ b/src/tr1/config.h @@ -48,6 +48,7 @@ typedef struct { bool fix_wall_jump_glitch; bool fix_bridge_collision; bool fix_qwop_glitch; + bool fix_item_duplication_glitch; bool fix_alligator_ai; bool change_pierre_spawn; bool fix_bear_ai; diff --git a/src/tr1/config_map.def b/src/tr1/config_map.def index b5dd09eb4..bcf35b10c 100644 --- a/src/tr1/config_map.def +++ b/src/tr1/config_map.def @@ -26,6 +26,7 @@ CFG_BOOL(g_Config, fix_descending_glitch, false) CFG_BOOL(g_Config, fix_wall_jump_glitch, false) CFG_BOOL(g_Config, fix_bridge_collision, true) CFG_BOOL(g_Config, fix_qwop_glitch, false) +CFG_BOOL(g_Config, fix_item_duplication_glitch, false) CFG_BOOL(g_Config, fix_alligator_ai, true) CFG_BOOL(g_Config, change_pierre_spawn, true) CFG_BOOL(g_Config, fix_bear_ai, true) diff --git a/src/tr1/game/inventory.h b/src/tr1/game/inventory.h index 09b033031..890acf6c0 100644 --- a/src/tr1/game/inventory.h +++ b/src/tr1/game/inventory.h @@ -12,5 +12,6 @@ void Inv_AddItemNTimes(GAME_OBJECT_ID object_id, int32_t qty); void Inv_InsertItem(INVENTORY_ITEM *inv_item); int32_t Inv_RequestItem(GAME_OBJECT_ID object_id); void Inv_RemoveAllItems(void); +void Inv_ClearSelection(void); bool Inv_RemoveItem(GAME_OBJECT_ID object_id); GAME_OBJECT_ID Inv_GetItemOption(GAME_OBJECT_ID object_id); diff --git a/src/tr1/game/inventory/inventory_func.c b/src/tr1/game/inventory/inventory_func.c index c6bccb07a..e5131bdc7 100644 --- a/src/tr1/game/inventory/inventory_func.c +++ b/src/tr1/game/inventory/inventory_func.c @@ -263,9 +263,13 @@ int32_t Inv_RequestItem(const GAME_OBJECT_ID object_id) void Inv_RemoveAllItems(void) { g_InvMainObjects = 1; - g_InvMainCurrent = 0; - g_InvKeysObjects = 0; + Inv_ClearSelection(); +} + +void Inv_ClearSelection(void) +{ + g_InvMainCurrent = 0; g_InvKeysCurrent = 0; } diff --git a/src/tr1/game/phase/phase_inventory.c b/src/tr1/game/phase/phase_inventory.c index b2118c69b..bdeabd08d 100644 --- a/src/tr1/game/phase/phase_inventory.c +++ b/src/tr1/game/phase/phase_inventory.c @@ -211,6 +211,10 @@ static void Inv_Destroy(void) Inv_Ring_RemoveAllText(); m_InvChosen = NO_OBJECT; + if (g_Config.fix_item_duplication_glitch) { + Inv_ClearSelection(); + } + if (m_VersionText) { Text_Remove(m_VersionText); m_VersionText = NULL; diff --git a/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/en.json b/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/en.json index 71e68439d..56e657039 100644 --- a/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/en.json +++ b/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/en.json @@ -168,6 +168,10 @@ "Title": "Fix QWOP glitch", "Description": "Fixes Lara jumping on small steps sometimes resulting in a weird running animation, known as a QWOP state." }, + "fix_item_duplication_glitch": { + "Title": "Fix item duplication glitch", + "Description": "Fixes the ability to duplicate usage of key items in the inventory." + }, "fix_tihocan_secret_sound": { "Title": "Fix Tomb of Tihocan secret sound", "Description": "Prevents the secret sound from incorrectly playing when using the golden key in Tomb of Tihocan." diff --git a/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/es.json b/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/es.json index ea4b1967f..01c292c59 100644 --- a/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/es.json +++ b/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/es.json @@ -352,6 +352,10 @@ "Title": "Arreglar fallo de QWOP", "Description": "Corrige que Lara salte en pequeños pasos, lo que a veces resulta en una animación extraña de carrera, conocida como estado QWOP." }, + "fix_item_duplication_glitch": { + "Title": "Arreglar fallo de duplicación de elementos", + "Description": "Corrige la capacidad de duplicar el uso de elementos clave en el inventario." + }, "fix_secrets_killing_music": { "Title": "Evitar detener la música en recogidas de secretos", "Description": "Corrige el sonido de recoger un secreto que detiene la pista de música activa." diff --git a/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/fr.json b/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/fr.json index 5e9f76707..af82ef02c 100644 --- a/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/fr.json +++ b/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/fr.json @@ -168,6 +168,10 @@ "Title": "Correction du glitch QWOP", "Description": "Corrige le saut de Lara sur de petites étapes, entraînant parfois une animation de course étrange, connu sous le nom du glitch QWOP." }, + "fix_item_duplication_glitch": { + "Title": "Correction du glitch de duplication d'élément", + "Description": "Corrige la possibilité de dupliquer l'utilisation d'éléments clés dans l'inventaire." + }, "fix_tihocan_secret_sound": { "Title": "Correction du son du secret dans le niveau de la tombe de Tihocan", "Description": "Corrige le fait que le son du secret se joue de manière incorrecte lors de l'utilisation de la clé dorée dans le niveau de la tombe de Tihocan." diff --git a/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/it.json b/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/it.json index e741c533b..32a08e0df 100644 --- a/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/it.json +++ b/tools/tr1/config/TR1X_ConfigTool/Resources/Lang/it.json @@ -168,6 +168,10 @@ "Title": "Correggi il glitch QWOP", "Description": "Risolve il problema per cui a volte Lara, saltando da piccoli gradini, provoca una strana animazione di corsa nota come stato QWOP." }, + "fix_item_duplication_glitch": { + "Title": "Correggi il glitch duplicazione degli oggetti", + "Description": "Risolto il problema con la possibilità di duplicare l'utilizzo degli elementi chiave nell'inventario." + }, "fix_tihocan_secret_sound": { "Title": "Correggi il suono dei segreti nella Tomba di Tihocan", "Description": "Impedisce la riproduzione errata del suono dei segreti quando si utilizza la chiave dorata nella Tomba di Tihocan." diff --git a/tools/tr1/config/TR1X_ConfigTool/Resources/specification.json b/tools/tr1/config/TR1X_ConfigTool/Resources/specification.json index 4e814a0ff..6d2292b62 100644 --- a/tools/tr1/config/TR1X_ConfigTool/Resources/specification.json +++ b/tools/tr1/config/TR1X_ConfigTool/Resources/specification.json @@ -193,6 +193,11 @@ "DataType": "Bool", "DefaultValue": false }, + { + "Field": "fix_item_duplication_glitch", + "DataType": "Bool", + "DefaultValue": false + }, { "Field": "fix_tihocan_secret_sound", "DataType": "Bool", From fdc1d190863142579bea946b75ebeea83695df00 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:19:15 +0000 Subject: [PATCH 2/2] tr2/inventory: reset selected item on closing inventory This resets the selected key item when the inventory is closed to avoid it being pre-selected to a non-existent item when the inventory is re-opened. Resolves #1586. --- docs/tr2/CHANGELOG.md | 1 + src/tr2/config.h | 1 + src/tr2/config_map.def | 1 + src/tr2/game/inventory/backpack.c | 7 ++++++- src/tr2/game/inventory/backpack.h | 1 + src/tr2/game/inventory/common.c | 6 ++++++ tools/tr2/config/TR2X_ConfigTool/Resources/Lang/en.json | 4 ++++ .../config/TR2X_ConfigTool/Resources/specification.json | 5 +++++ 8 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/tr2/CHANGELOG.md b/docs/tr2/CHANGELOG.md index 40e755522..158023861 100644 --- a/docs/tr2/CHANGELOG.md +++ b/docs/tr2/CHANGELOG.md @@ -1,5 +1,6 @@ ## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-0.6...develop) - ××××-××-×× - added support for custom levels to enforce values for any config setting (#1846) +- added an option to fix inventory item usage duplication (#1586) - fixed depth problems when drawing certain rooms (#1853, regression from 0.6) - fixed Lara getting stuck in her hit animation if she is hit while mounting the boat or skidoo (#1606) - fixed being unable to go from surface swimming to underwater swimming without first stopping (#1863, regression from 0.6) diff --git a/src/tr2/config.h b/src/tr2/config.h index 232fca161..bdf370e1d 100644 --- a/src/tr2/config.h +++ b/src/tr2/config.h @@ -20,6 +20,7 @@ typedef struct { struct { bool fix_m16_accuracy; bool enable_cheats; + bool fix_item_duplication_glitch; } gameplay; struct { diff --git a/src/tr2/config_map.def b/src/tr2/config_map.def index ebe2a65a5..e8928ac98 100644 --- a/src/tr2/config_map.def +++ b/src/tr2/config_map.def @@ -1,5 +1,6 @@ CFG_BOOL(g_Config, gameplay.fix_m16_accuracy, true) CFG_BOOL(g_Config, gameplay.enable_cheats, false) +CFG_BOOL(g_Config, gameplay.fix_item_duplication_glitch, false) CFG_BOOL(g_Config, visuals.enable_3d_pickups, true) CFG_ENUM(g_Config, rendering.screenshot_format, SCREENSHOT_FORMAT_JPEG, SCREENSHOT_FORMAT) CFG_INT32(g_Config, rendering.turbo_speed, 0) diff --git a/src/tr2/game/inventory/backpack.c b/src/tr2/game/inventory/backpack.c index c140a820e..682e296e6 100644 --- a/src/tr2/game/inventory/backpack.c +++ b/src/tr2/game/inventory/backpack.c @@ -323,8 +323,13 @@ int32_t __cdecl Inv_RequestItem(const GAME_OBJECT_ID object_id) void __cdecl Inv_RemoveAllItems(void) { g_Inv_MainObjectsCount = 0; - g_Inv_MainCurrent = 0; g_Inv_KeyObjectsCount = 0; + Inv_ClearSelection(); +} + +void Inv_ClearSelection(void) +{ + g_Inv_MainCurrent = 0; g_Inv_KeysCurrent = 0; } diff --git a/src/tr2/game/inventory/backpack.h b/src/tr2/game/inventory/backpack.h index 9783e2ebd..947fc7eed 100644 --- a/src/tr2/game/inventory/backpack.h +++ b/src/tr2/game/inventory/backpack.h @@ -7,4 +7,5 @@ int32_t __cdecl Inv_AddItem(GAME_OBJECT_ID object_id); void Inv_AddItemNTimes(GAME_OBJECT_ID object_id, int32_t qty); int32_t __cdecl Inv_RequestItem(GAME_OBJECT_ID object_id); void __cdecl Inv_RemoveAllItems(void); +void Inv_ClearSelection(void); int32_t __cdecl Inv_RemoveItem(GAME_OBJECT_ID object_id); diff --git a/src/tr2/game/inventory/common.c b/src/tr2/game/inventory/common.c index 38a0a4087..0c73dc071 100644 --- a/src/tr2/game/inventory/common.c +++ b/src/tr2/game/inventory/common.c @@ -1,5 +1,6 @@ #include "game/inventory/common.h" +#include "config.h" #include "decomp/decomp.h" #include "game/clock.h" #include "game/console/common.h" @@ -810,6 +811,11 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) if (inventory_mode != INV_TITLE_MODE) { Music_Unpause(); } + + if (g_Config.gameplay.fix_item_duplication_glitch) { + Inv_ClearSelection(); + } + return 0; } diff --git a/tools/tr2/config/TR2X_ConfigTool/Resources/Lang/en.json b/tools/tr2/config/TR2X_ConfigTool/Resources/Lang/en.json index a88c64f3f..8ec992a08 100644 --- a/tools/tr2/config/TR2X_ConfigTool/Resources/Lang/en.json +++ b/tools/tr2/config/TR2X_ConfigTool/Resources/Lang/en.json @@ -25,6 +25,10 @@ "Title": "Fix M16 accuracy", "Description": "Fixes the accuracy of the M16 while Lara is running." }, + "fix_item_duplication_glitch": { + "Title": "Fix item duplication glitch", + "Description": "Fixes the ability to duplicate usage of key items in the inventory." + }, "screenshot_format": { "Title": "Screenshot format", "Description": "Screenshot file format." diff --git a/tools/tr2/config/TR2X_ConfigTool/Resources/specification.json b/tools/tr2/config/TR2X_ConfigTool/Resources/specification.json index 498c2c9eb..7d0d9dcb2 100644 --- a/tools/tr2/config/TR2X_ConfigTool/Resources/specification.json +++ b/tools/tr2/config/TR2X_ConfigTool/Resources/specification.json @@ -21,6 +21,11 @@ "Field": "fix_m16_accuracy", "DataType": "Bool", "DefaultValue": true + }, + { + "Field": "fix_item_duplication_glitch", + "DataType": "Bool", + "DefaultValue": false } ] },