From 446fdbea07e16227e2fd59e47e73492fea926271 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 6 Sep 2024 09:29:40 +0200 Subject: [PATCH] inv/backpack: fix regression in Inv_AddItem Resolves #204. Resolves #205. Regression from 5ca75e4. --- src/game/inventory/backpack.c | 7 ++++--- src/game/objects/vars.c | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/game/inventory/backpack.c b/src/game/inventory/backpack.c index fb91c88a..c140a820 100644 --- a/src/game/inventory/backpack.c +++ b/src/game/inventory/backpack.c @@ -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]; @@ -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: diff --git a/src/game/objects/vars.c b/src/game/objects/vars.c index 0b2c00f4..0bec1e9a 100644 --- a/src/game/objects/vars.c +++ b/src/game/objects/vars.c @@ -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 },