From cd755a8336172dcc884f6811aa53efda7c66cecf Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 3 Oct 2023 19:29:12 +1100 Subject: [PATCH] - Duke: Move `PlayerUseItem()` wrapper into `DDukePlayer`. --- source/games/duke/src/inlines.h | 6 ------ source/games/duke/src/input.cpp | 4 ++-- source/games/duke/src/types.h | 5 +++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 3f103985c..095f111e4 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -105,12 +105,6 @@ inline bool isIn(int value, const std::initializer_list& list) return false; } -// these are mainly here to avoid directly accessing the input data so that it can be more easily refactored later. -inline void PlayerSetItemUsed(int pl, int num) -{ - getPlayer(pl)->cmd.ucmd.setItemUsed(num - 1); -} - inline void clearfriction() { for (int i = 0; i != -1; i = connectpoint2[i]) diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 083b6dc9a..006caa50b 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -123,9 +123,9 @@ void hud_input(int plnum) { SetGameVarID(g_iReturnVarID, 0, nullptr, plnum); OnEvent(EVENT_INVENTORY, plnum, nullptr, -1); - if (GetGameVarID(g_iReturnVarID, nullptr, plnum).value() == 0) + if (GetGameVarID(g_iReturnVarID, nullptr, plnum).value() == 0 && p->inven_icon > ICON_NONE && p->inven_icon <= ICON_HEATS) { - if (p->inven_icon > ICON_NONE && p->inven_icon <= ICON_HEATS) PlayerSetItemUsed(plnum, p->inven_icon); + p->useItem(p->inven_icon); } } diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 7962e7a49..7d7f6a469 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -404,6 +404,11 @@ public: { return cmd.ucmd.isItemUsed(num - 1); } + + inline void useItem(int num) + { + cmd.ucmd.setItemUsed(num - 1); + } }; struct Cycler