Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
inv/backpack: fix regression in Inv_AddItem
Browse files Browse the repository at this point in the history
Resolves #204. Resolves #205. Regression from 5ca75e4.
  • Loading branch information
rr- committed Sep 6, 2024
1 parent bb47db1 commit 446fdbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/game/inventory/backpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ void __cdecl Inv_InsertItem(INVENTORY_ITEM *const inv_item)
int32_t __cdecl Inv_AddItem(const GAME_OBJECT_ID object_id)
{
const GAME_OBJECT_ID inv_object_id = Inv_GetItemOption(object_id);
if (!g_Objects[object_id].loaded) {
return false;
}

for (int32_t i = 0; i < g_Inv_MainObjectsCount; i++) {
const INVENTORY_ITEM *const inv_item = g_Inv_MainList[i];
Expand All @@ -64,6 +61,10 @@ int32_t __cdecl Inv_AddItem(const GAME_OBJECT_ID object_id)
}
}

if (!g_Objects[inv_object_id == NO_OBJECT ? object_id : inv_object_id]
.loaded) {
return false;
}
switch (object_id) {
case O_COMPASS_OPTION:
case O_COMPASS_ITEM:
Expand Down
1 change: 1 addition & 0 deletions src/game/objects/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const GAME_OBJECT_ID g_InvObjects[] = {

const GAME_OBJECT_PAIR g_ItemToInvObjectMap[] = {
// clang-format off
{ O_COMPASS_ITEM, O_COMPASS_OPTION },
{ O_PISTOL_ITEM, O_PISTOL_OPTION },
{ O_SHOTGUN_ITEM, O_SHOTGUN_OPTION },
{ O_MAGNUM_ITEM, O_MAGNUM_OPTION },
Expand Down

0 comments on commit 446fdbe

Please sign in to comment.