From 2509fa9f54e81abdc877565a7f97277a8b9d0a56 Mon Sep 17 00:00:00 2001 From: Elson Costa Date: Tue, 23 Apr 2024 13:22:02 -0300 Subject: [PATCH] Improved checks and removed redundant code. --- src/server/network/protocol/protocolgame.cpp | 30 +++++++------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index db7c6ec48a0..2255a7d2f20 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -6612,15 +6612,23 @@ void ProtocolGame::sendOutfitWindow() { NetworkMessage msg; msg.addByte(0xC8); - if (oldProtocol) { - Outfit_t currentOutfit = player->getDefaultOutfit(); + Outfit_t currentOutfit = player->getDefaultOutfit(); + auto isSupportOutfit = player->isSupportOutfit(); + bool mounted = false; + + if (!isSupportOutfit) { const auto currentMount = g_game().mounts.getMountByID(player->getLastMount()); if (currentMount) { + mounted = (currentOutfit.lookMount == currentMount->clientId); currentOutfit.lookMount = currentMount->clientId; } + } else { + currentOutfit.lookMount = 0; + } - AddOutfit(msg, currentOutfit); + AddOutfit(msg, currentOutfit); + if (oldProtocol) { std::vector protocolOutfits; const auto outfits = Outfits::getInstance().getOutfits(player->getSex()); protocolOutfits.reserve(outfits.size()); @@ -6661,22 +6669,6 @@ void ProtocolGame::sendOutfitWindow() { return; } - bool mounted = false; - Outfit_t currentOutfit = player->getDefaultOutfit(); - - auto isSupportOutfit = player->isSupportOutfit(); - const auto currentMount = g_game().mounts.getMountByID(player->getLastMount()); - if (!isSupportOutfit) { - if (currentMount) { - mounted = (currentOutfit.lookMount == currentMount->clientId); - currentOutfit.lookMount = currentMount->clientId; - } - } else { - currentOutfit.lookMount = 0; - } - - AddOutfit(msg, currentOutfit, !isSupportOutfit); - msg.addByte(isSupportOutfit ? 0 : currentOutfit.lookMountHead); msg.addByte(isSupportOutfit ? 0 : currentOutfit.lookMountBody); msg.addByte(isSupportOutfit ? 0 : currentOutfit.lookMountLegs);