Skip to content

Commit

Permalink
tr2/inventory: reset selected item on closing inventory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lahm86 committed Nov 12, 2024
1 parent f3a29d3 commit e1f77f9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/tr2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ typedef struct {
struct {
bool fix_m16_accuracy;
bool enable_cheats;
bool fix_item_duplication_glitch;
} gameplay;

struct {
Expand Down
1 change: 1 addition & 0 deletions src/tr2/config_map.def
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 6 additions & 1 deletion src/tr2/game/inventory/backpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/tr2/game/inventory/backpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 6 additions & 0 deletions src/tr2/game/inventory/common.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions tools/tr2/config/TR2X_ConfigTool/Resources/Lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 5 additions & 0 deletions tools/tr2/config/TR2X_ConfigTool/Resources/specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"Field": "fix_m16_accuracy",
"DataType": "Bool",
"DefaultValue": true
},
{
"Field": "fix_item_duplication_glitch",
"DataType": "Bool",
"DefaultValue": false
}
]
},
Expand Down

0 comments on commit e1f77f9

Please sign in to comment.