From 8e70cd7a37c81b2691dd2d41dc37a8da4e9b40e6 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 19 Oct 2021 23:58:51 +0200 Subject: [PATCH] [gamepad] Fix OOB when using equiped items --- Source/controls/plrctrls.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 48978fd3b..d1a7227e1 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -1521,7 +1521,9 @@ void CtrlUseInvItem() auto &myPlayer = Players[MyPlayerId]; - if (pcursinvitem <= INVITEM_INV_LAST) + if (pcursinvitem < INVITEM_INV_FIRST) + item = &myPlayer.InvBody[pcursinvitem]; + else if (pcursinvitem <= INVITEM_INV_LAST) item = &myPlayer.InvList[pcursinvitem - INVITEM_INV_FIRST]; else item = &myPlayer.SpdList[pcursinvitem - INVITEM_BELT_FIRST];