mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
feat(gameplay): add player logout and disconnect handling
This commit is contained in:
@@ -200,6 +200,18 @@ void ClientWorld::receive_other_player(const PlayerInfoRsp& rsp) {
|
||||
}
|
||||
}
|
||||
|
||||
void ClientWorld::receive_player_logout(const LogoutRsp& rsp) {
|
||||
{
|
||||
std::lock_guard lock(m_other_players_mutex);
|
||||
int sum = m_other_players.erase(rsp.uuid());
|
||||
if (sum == 0) {
|
||||
Logger::warn("Player {} not find", rsp.uuid());
|
||||
} else {
|
||||
Logger::info("Player {} erase", rsp.uuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ClientWorld::init(std::string_view player_name,
|
||||
std::shared_ptr<NetworkClient> client) {
|
||||
m_chunks.reserve(MAX_DISTANCE * MAX_DISTANCE * 4);
|
||||
@@ -405,6 +417,12 @@ void ClientWorld::receive_chunk(const ChunkDataRsp& data) {
|
||||
});
|
||||
}
|
||||
|
||||
void ClientWorld::exit() {
|
||||
LogoutReq req;
|
||||
req.set_uuid(m_player.get_uuid());
|
||||
m_client->send(make_packet(req));
|
||||
}
|
||||
|
||||
void ClientWorld::update(float delta_time) {
|
||||
m_player.update(delta_time);
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user