Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: null pointers check #2422

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 16 additions & 3 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3949,6 +3949,10 @@ void ProtocolGame::sendStats() {
}

void ProtocolGame::sendBasicData() {
if (!player) {
return;
}

NetworkMessage msg;
msg.addByte(0x9F);
if (player->isPremium() || player->isVip()) {
Expand Down Expand Up @@ -5921,7 +5925,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 @@ -6105,6 +6114,10 @@ void ProtocolGame::sendPartyCreatureShowStatus(std::shared_ptr<Creature> target,
}

void ProtocolGame::sendPartyPlayerVocation(std::shared_ptr<Player> target) {
if (!target) {
return;
}

uint32_t cid = target->getID();
if (!knownCreatureSet.contains(cid)) {
sendPartyCreatureUpdate(target);
Expand All @@ -6124,7 +6137,7 @@ void ProtocolGame::sendPartyPlayerVocation(std::shared_ptr<Player> target) {
}

void ProtocolGame::sendPlayerVocation(std::shared_ptr<Player> target) {
if (!player || oldProtocol) {
if (!player || !target || oldProtocol) {
return;
}

Expand Down Expand Up @@ -8618,7 +8631,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
Loading