From 7775780ad721db24b620f0f5389ffe0cb796e947 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 4 Jul 2018 05:56:10 +0300 Subject: [PATCH] [Cllient] Update multiplayer code for handling quick keys --- apps/openmw/mwgui/quickkeysmenu.cpp | 12 ++++++------ apps/openmw/mwgui/windowmanagerimp.cpp | 11 ++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 6c189e1cc..298fa5836 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -169,7 +169,7 @@ namespace MWGui */ if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen() && !mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys) { - mwmp::Main::get().getLocalPlayer()->sendQuickKey(index, Type_Unassigned); + mwmp::Main::get().getLocalPlayer()->sendQuickKey(key->index, Type_Unassigned); } /* End of tes3mp addition @@ -183,7 +183,7 @@ namespace MWGui */ void QuickKeysMenu::unassignIndex(int index) { - unassign(mQuickKeyButtons[index], index); + unassign(&mKey[index]); } /* End of tes3mp addition @@ -281,7 +281,7 @@ namespace MWGui by a player, not by a packet received from the server */ if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys) - mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, Type_Item, item.getCellRef().getRefId()); + mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelected->index, Type_Item, item.getCellRef().getRefId()); /* End of tes3mp addition */ @@ -316,7 +316,7 @@ namespace MWGui Send a PLAYER_QUICKKEYS packet whenever a key is assigned to an item's magic */ if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys) - mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, Type_MagicItem, item.getCellRef().getRefId()); + mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelected->index, Type_MagicItem, item.getCellRef().getRefId()); /* End of tes3mp addition */ @@ -360,7 +360,7 @@ namespace MWGui Send a PLAYER_QUICKKEYS packet whenever a key is assigned to a spell */ if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys) - mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, Type_Magic, spellId); + mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelected->index, Type_Magic, spellId); /* End of tes3mp addition */ @@ -517,7 +517,7 @@ namespace MWGui */ void QuickKeysMenu::setSelectedIndex(int index) { - mSelectedIndex = index; + mSelected = &mKey[index]; } /* End of tes3mp addition diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 6bb454cd6..03c281198 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1565,10 +1565,14 @@ namespace MWGui */ void WindowManager::setQuickKey(int slot, int quickKeyType, MWWorld::Ptr item, const std::string& spellId) { - mQuickKeysMenu->setSelectedIndex(slot); - - switch (quickKeyType) + if (slot > 0) { + // The actual indexes recorded for quick keys are always 1 higher than their + // indexes in the mKey vector, so adjust for the latter + mQuickKeysMenu->setSelectedIndex(slot - 1); + + switch (quickKeyType) + { case QuickKeysMenu::Type_Unassigned: mQuickKeysMenu->unassignIndex(slot); break; @@ -1581,6 +1585,7 @@ namespace MWGui case QuickKeysMenu::Type_Magic: mQuickKeysMenu->onAssignMagic(spellId); break; + } } } /*