]> git.lizzy.rs Git - minetest.git/commitdiff
Clamp player wieldindex when processing hotbar item selection (#13098)
authoriliekprogrammar <iliekprogrammar@gmail.com>
Sun, 8 Jan 2023 13:03:16 +0000 (13:03 +0000)
committerGitHub <noreply@github.com>
Sun, 8 Jan 2023 13:03:16 +0000 (14:03 +0100)
src/client/game.cpp

index cf0117046906acc1c4e9a10770a48d5e1635c590..56d4ae13e19408772ea14d1cc29a25dc983f74c6 100644 (file)
@@ -2133,7 +2133,6 @@ void Game::processItemSelection(u16 *new_playeritem)
        /* Item selection using mouse wheel
         */
        *new_playeritem = player->getWieldIndex();
-
        s32 wheel = input->getMouseWheel();
        u16 max_item = MYMIN(PLAYER_INVENTORY_SIZE - 1,
                    player->hud_hotbar_itemcount - 1);
@@ -2160,6 +2159,9 @@ void Game::processItemSelection(u16 *new_playeritem)
                        break;
                }
        }
+
+       // Clamp selection again in case it wasn't changed but max_item was
+       *new_playeritem = MYMIN(*new_playeritem, max_item);
 }