Skip to content

Commit

Permalink
fix: null pointers check
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Mar 12, 2024
1 parent 5ba510d commit d2b8eb7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/io/iomarket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion src/server/network/connection/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5921,7 +5921,12 @@ void ProtocolGame::sendRestingStatus(uint8_t protection) {
msg.addByte(0xA9);
msg.addByte(protection); // 1 / 0

int32_t dailyStreak = static_cast<int32_t>(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<uint8_t>(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)");
Expand Down Expand Up @@ -8618,7 +8623,7 @@ void ProtocolGame::sendMonsterPodiumWindow(std::shared_ptr<Item> podium, const P
}

void ProtocolGame::parseSetMonsterPodium(NetworkMessage &msg) const {
if (oldProtocol) {
if (!player || oldProtocol) {
return;
}

Expand Down

0 comments on commit d2b8eb7

Please sign in to comment.