Skip to content

Commit

Permalink
fix: suppress get byte log
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Dec 21, 2024
1 parent 34b6fa8 commit 34d26fc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/server/network/message/networkmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ int32_t NetworkMessage::decodeHeader() {
}

// Simply read functions for incoming message
uint8_t NetworkMessage::getByte(const std::source_location &location /*= std::source_location::current()*/) {
uint8_t NetworkMessage::getByte(bool suppresLog /*= false*/, const std::source_location &location /*= std::source_location::current()*/) {
// Check if there is at least 1 byte to read
if (!canRead(1)) {
g_logger().error("[{}] Not enough data to read a byte. Current position: {}, Length: {}. Called line {}:{} in {}", __FUNCTION__, info.position, info.length, location.line(), location.column(), location.function_name());
if (!suppresLog) {
g_logger().error("[{}] Not enough data to read a byte. Current position: {}, Length: {}. Called line {}:{} in {}", __FUNCTION__, info.position, info.length, location.line(), location.column(), location.function_name());
}
return {};
}

Expand Down Expand Up @@ -113,7 +115,7 @@ Position NetworkMessage::getPosition() {
Position pos;
pos.x = get<uint16_t>();
pos.y = get<uint16_t>();
pos.z = getByte();
pos.z = getByte(true);
return pos;
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/network/message/networkmessage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NetworkMessage {
}

// simply read functions for incoming message
uint8_t getByte(const std::source_location &location = std::source_location::current());
uint8_t getByte(bool suppresLog = false, const std::source_location &location = std::source_location::current());

uint8_t getPreviousByte();

Expand Down
2 changes: 1 addition & 1 deletion src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2176,7 +2176,7 @@ void ProtocolGame::parseTaskHuntingAction(NetworkMessage &msg) {

uint8_t slot = msg.getByte();
uint8_t action = msg.getByte();
bool upgrade = msg.getByte() != 0;
bool upgrade = msg.getByte(true) != 0;
auto raceId = msg.get<uint16_t>();

if (!g_configManager().getBoolean(TASK_HUNTING_ENABLED)) {
Expand Down

0 comments on commit 34d26fc

Please sign in to comment.