Skip to content

Commit

Permalink
fix incorrectly passing peer pointer to on_disconnect parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ZTzTopia committed Feb 23, 2024
1 parent c17cc4e commit 8c76ce9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,6 @@ void Client::on_disconnect(ENetPeer* peer)

enet_host_flush(host_); // Flush all outgoing packets before disconnecting
to_player->disconnect_now();
core_->get_server()->on_disconnect(peer);
core_->get_server()->on_disconnect(to_player->get_peer());
}
}
2 changes: 2 additions & 0 deletions src/player/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Player {

[[nodiscard]] bool send_packet(const std::vector<std::byte>& data, int channel = 0) const;

[[nodiscard]] ENetPeer* get_peer() const { return peer_; }

private:
ENetPeer* peer_;
};
Expand Down
2 changes: 1 addition & 1 deletion src/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,6 @@ void Server::on_disconnect(ENetPeer* peer)

enet_host_flush(host_); // Flush all outgoing packets before disconnecting
to_player->disconnect_now();
core_->get_client()->on_disconnect(peer);
core_->get_client()->on_disconnect(to_player->get_peer());
}
}

0 comments on commit 8c76ce9

Please sign in to comment.