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]);