From d2b8eb7a6588b8728399fafbdb86692407816b57 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 12 Mar 2024 14:57:07 -0300 Subject: [PATCH] fix: null pointers check --- src/io/iomarket.cpp | 1 + src/server/network/connection/connection.cpp | 4 +++- src/server/network/protocol/protocolgame.cpp | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/io/iomarket.cpp b/src/io/iomarket.cpp index ac79ef4c541..ca1bdb209d2 100644 --- a/src/io/iomarket.cpp +++ b/src/io/iomarket.cpp @@ -55,6 +55,7 @@ MarketOfferList IOMarket::getActiveOffers(MarketAction_t action) { } while (result->next()); return offerList; } + MarketOfferList IOMarket::getActiveOffers(MarketAction_t action, uint16_t itemId, uint8_t tier) { MarketOfferList offerList; diff --git a/src/server/network/connection/connection.cpp b/src/server/network/connection/connection.cpp index 7d9de916263..41789b88387 100644 --- a/src/server/network/connection/connection.cpp +++ b/src/server/network/connection/connection.cpp @@ -175,7 +175,9 @@ void Connection::parseHeader(const std::error_code &error) { readTimer.cancel(); if (error) { - g_logger().debug("[Connection::parseHeader] - Read error: {}", error.message()); + if (error != asio::error::operation_aborted && error != asio::error::eof && error != asio::error::connection_reset) { + g_logger().debug("[Connection::parseHeader] - Read error: {}", error.message()); + } close(FORCE_CLOSE); return; } else if (connectionState == CONNECTION_STATE_CLOSED) { diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 43fa9046cbb..d8b6b226e16 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -5921,7 +5921,12 @@ void ProtocolGame::sendRestingStatus(uint8_t protection) { msg.addByte(0xA9); msg.addByte(protection); // 1 / 0 - int32_t dailyStreak = static_cast(player->kv()->scoped("daily-reward")->get("streak")->getNumber()); + uint8_t dailyStreak = 0; + auto dailyRewardKV = player->kv()->scoped("daily-reward")->get("streak"); + if (dailyRewardKV && dailyRewardKV.has_value()) { + dailyStreak = static_cast(dailyRewardKV->getNumber()); + } + msg.addByte(dailyStreak < 2 ? 0 : 1); if (dailyStreak < 2) { msg.addString("Resting Area (no active bonus)", "ProtocolGame::sendRestingStatus - Resting Area (no active bonus)"); @@ -8618,7 +8623,7 @@ void ProtocolGame::sendMonsterPodiumWindow(std::shared_ptr podium, const P } void ProtocolGame::parseSetMonsterPodium(NetworkMessage &msg) const { - if (oldProtocol) { + if (!player || oldProtocol) { return; }