From 431225424ebc0af8e49a4de0ae4a1b5484e7f308 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Thu, 12 Dec 2024 16:59:32 +0500 Subject: [PATCH] Fix SOC/CS slots ordering support (#382, #392) In SOC and CS slots start from -1. e.g. knife slot is 0 in SOC/CS and 1 in COP. --- res/gamedata/configs/openxray.ltx | 4 ++++ src/xrGame/script_game_object_inventory_owner.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/res/gamedata/configs/openxray.ltx b/res/gamedata/configs/openxray.ltx index 33a5386167b..a97091cc2af 100644 --- a/res/gamedata/configs/openxray.ltx +++ b/res/gamedata/configs/openxray.ltx @@ -35,3 +35,7 @@ game_mode = cop ; Always try to put item in the slot, SOC behaviour ; For the comparison, COP tries to do that only if item has default_to_ruck = false default_to_slot = false + +; SOC/CS slots ordering +; e.g. knife slot is 0 in SOC/CS and 1 in COP +minus_one_slot_ordering = false diff --git a/src/xrGame/script_game_object_inventory_owner.cpp b/src/xrGame/script_game_object_inventory_owner.cpp index b36b6d54899..519ef41d3ec 100644 --- a/src/xrGame/script_game_object_inventory_owner.cpp +++ b/src/xrGame/script_game_object_inventory_owner.cpp @@ -1258,6 +1258,9 @@ CScriptGameObject* CScriptGameObject::item_in_slot(u32 slot_id) const return (0); } + if (pSettingsOpenXRay->read_if_exists("compatibility", "minus_one_slot_ordering", ShadowOfChernobylMode || ClearSkyMode)) + ++slot_id; + CInventoryItem* result = inventory_owner->inventory().ItemFromSlot((u16)slot_id); return (result ? result->object().lua_game_object() : 0); }