From 0f9a200e6b64ad49a80c860eee5624b48acea6f1 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Thu, 28 Mar 2024 04:46:07 +1100 Subject: fix: crafting interfaces not working with new middle-click opening --- source/frontend/StarMainInterface.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'source/frontend/StarMainInterface.cpp') diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index 4098705..4303a28 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -199,10 +199,7 @@ bool MainInterface::escapeDialogOpen() const { void MainInterface::openCraftingWindow(Json const& config, EntityId sourceEntityId) { if (m_craftingWindow && m_paneManager.isDisplayed(m_craftingWindow)) { m_paneManager.dismissPane(m_craftingWindow); - bool fromPlayer = false; - if (auto player = m_client->mainPlayer()) - fromPlayer = player->inWorld() && player->entityId() == sourceEntityId; - if (m_craftingWindow->sourceEntityId() == sourceEntityId) { + if (sourceEntityId != NullEntityId && m_craftingWindow->sourceEntityId() == sourceEntityId) { m_craftingWindow.reset(); return; } @@ -218,10 +215,7 @@ void MainInterface::openCraftingWindow(Json const& config, EntityId sourceEntity void MainInterface::openMerchantWindow(Json const& config, EntityId sourceEntityId) { if (m_merchantWindow && m_paneManager.isDisplayed(m_merchantWindow)) { m_paneManager.dismissPane(m_merchantWindow); - bool fromPlayer = false; - if (auto player = m_client->mainPlayer()) - fromPlayer = player->inWorld() && player->entityId() == sourceEntityId; - if (!fromPlayer && m_merchantWindow->sourceEntityId() == sourceEntityId) { + if (sourceEntityId != NullEntityId && m_merchantWindow->sourceEntityId() == sourceEntityId) { m_merchantWindow.reset(); return; } @@ -426,19 +420,19 @@ void MainInterface::handleInteractAction(InteractAction interactAction) { } else if (interactAction.type == InteractActionType::SitDown) { m_client->mainPlayer()->lounge(interactAction.entityId, interactAction.data.toUInt()); } else if (interactAction.type == InteractActionType::OpenCraftingInterface) { - if (!world->entity(interactAction.entityId)) + if (interactAction.entityId != NullEntityId && !world->entity(interactAction.entityId)) return; openCraftingWindow(interactAction.data, interactAction.entityId); } else if (interactAction.type == InteractActionType::OpenSongbookInterface) { m_paneManager.displayRegisteredPane(MainInterfacePanes::Songbook); } else if (interactAction.type == InteractActionType::OpenNpcCraftingInterface) { - if (!world->entity(interactAction.entityId)) + if (interactAction.entityId != NullEntityId && !world->entity(interactAction.entityId)) return; - + // wait, this is literally the exact same as OpenCraftingInterface. what the fuck? lol openCraftingWindow(interactAction.data, interactAction.entityId); } else if (interactAction.type == InteractActionType::OpenMerchantInterface) { - if (!world->entity(interactAction.entityId)) + if (interactAction.entityId != NullEntityId && !world->entity(interactAction.entityId)) return; openMerchantWindow(interactAction.data, interactAction.entityId); -- cgit v1.2.3