From e04c208789fc16629fc17d59033cdddf8a8d7c17 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Mon, 18 Nov 2024 21:01:51 -0300 Subject: [PATCH] fix: reduce function body --- src/server/network/protocol/protocolgame.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 32d68ff78f9..e875663748f 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -5746,18 +5746,13 @@ void ProtocolGame::sendForgeHistory(uint8_t page) { auto historyVector = player->getForgeHistory(); auto historyVectorLen = historyVector.size(); - uint16_t currentPage = 1; - uint16_t lastPage = 1; - uint16_t pageFirstEntry = 0; - uint16_t pageLastEntry = 0; - std::vector historyPerPage; if (historyVectorLen > 0) { - lastPage = std::clamp(std::floor((historyVectorLen - 1) / 9) + 1, 0, std::numeric_limits::max()); - currentPage = (lastPage < page) ? lastPage : page; + uint16_t lastPage = std::clamp(std::floor((historyVectorLen - 1) / 9) + 1, 0, std::numeric_limits::max()); + uint16_t currentPage = (lastPage < page) ? lastPage : page; - pageFirstEntry = std::clamp(historyVectorLen - (currentPage - 1) * 9, 0, std::numeric_limits::max()); - pageLastEntry = historyVectorLen > currentPage * 9 ? std::clamp(historyVectorLen - currentPage * 9, 0, std::numeric_limits::max()) : 0; + uint16_t pageFirstEntry = std::clamp(historyVectorLen - (currentPage - 1) * 9, 0, std::numeric_limits::max()); + uint16_t pageLastEntry = historyVectorLen > currentPage * 9 ? std::clamp(historyVectorLen - currentPage * 9, 0, std::numeric_limits::max()) : 0; for (uint16_t entry = pageFirstEntry; entry > pageLastEntry; --entry) { historyPerPage.emplace_back(historyVector[entry - 1]);