From 87163147b32c260c69d35a976ad412dd4ffcaf50 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Thu, 22 Jun 2023 13:29:42 +1000 Subject: [PATCH] fix crash when disconnecting with inventory open additionally, fix humanoid identity being constantly sent by the server even when unchanged --- source/frontend/StarMainInterface.cpp | 15 ++++++++++----- source/game/StarPlayer.cpp | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index 4485ffa..2be8c2e 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -96,7 +96,8 @@ MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter, m_inventoryWindow = make_shared(this, m_client->mainPlayer(), m_containerInteractor); m_paneManager.registerPane(MainInterfacePanes::Inventory, PaneLayer::Window, m_inventoryWindow, [this](PanePtr const&) { - m_client->mainPlayer()->clearSwap(); + if (auto player = m_client->mainPlayer()) + player->clearSwap(); if (m_containerPane) { m_containerPane->dismiss(); m_containerPane = {}; @@ -216,7 +217,8 @@ void MainInterface::openCraftingWindow(Json const& config, EntityId sourceEntity m_craftingWindow = make_shared(m_client->worldClient(), m_client->mainPlayer(), config, sourceEntityId); m_paneManager.displayPane(PaneLayer::Window, m_craftingWindow, [this](PanePtr const&) { - m_client->mainPlayer()->clearSwap(); + if (auto player = m_client->mainPlayer()) + player->clearSwap(); }); } @@ -233,7 +235,8 @@ void MainInterface::openMerchantWindow(Json const& config, EntityId sourceEntity m_paneManager.displayPane(PaneLayer::Window, m_merchantWindow, [this](PanePtr const&) { - m_client->mainPlayer()->clearSwap(); + if (auto player = m_client->mainPlayer()) + player->clearSwap(); m_paneManager.dismissRegisteredPane(MainInterfacePanes::Inventory); }); m_paneManager.displayRegisteredPane(MainInterfacePanes::Inventory); @@ -401,7 +404,8 @@ void MainInterface::handleInteractAction(InteractAction interactAction) { m_containerPane = make_shared(world, m_client->mainPlayer(), m_containerInteractor); m_paneManager.displayPane(PaneLayer::Window, m_containerPane, [this](PanePtr const&) { - m_client->mainPlayer()->clearSwap(); + if (auto player = m_client->mainPlayer()) + player->clearSwap(); m_paneManager.dismissRegisteredPane(MainInterfacePanes::Inventory); }); @@ -496,7 +500,8 @@ void MainInterface::handleInteractAction(InteractAction interactAction) { if (scriptPane->openWithInventory()) { m_paneManager.displayPane(PaneLayer::Window, scriptPane, [this](PanePtr const&) { - m_client->mainPlayer()->clearSwap(); + if (auto player = m_client->mainPlayer()) + player->clearSwap(); m_paneManager.dismissRegisteredPane(MainInterfacePanes::Inventory); }); m_paneManager.displayRegisteredPane(MainInterfacePanes::Inventory); diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp index 47ded48..8d0ece5 100644 --- a/source/game/StarPlayer.cpp +++ b/source/game/StarPlayer.cpp @@ -1759,7 +1759,6 @@ void Player::getNetStates(bool initial) { if (m_identityNetState.pullUpdated()) { m_identity = m_identityNetState.get(); - m_identityUpdated = true; m_humanoid->setIdentity(m_identity); }