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 } ] },