From f8f92c151390ad1a1641b50c4d4c9d46983903e1 Mon Sep 17 00:00:00 2001 From: Sara Date: Sat, 16 Mar 2024 20:56:26 +0100 Subject: [PATCH] feat: implemented GameRoot::player_disconnected --- game_root.cpp | 6 ++++++ game_root.hpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/game_root.cpp b/game_root.cpp index 805f4eb..4f2bf70 100644 --- a/game_root.cpp +++ b/game_root.cpp @@ -50,6 +50,12 @@ void GameRoot::player_connected() { this->emit_signal(StringName("player_connected"), input); } +void GameRoot::player_disconnected(uint32_t player_id) { + if(!this->players.has(player_id)) + return; + this->players.get(player_id).second = nullptr; +} + bool GameRoot::initialize_player(IPlayer *player, uint32_t id) { Pair &found{this->players.get(id)}; this->add_child(player->to_node()); diff --git a/game_root.hpp b/game_root.hpp index 76012fa..bee96a2 100644 --- a/game_root.hpp +++ b/game_root.hpp @@ -27,7 +27,7 @@ public: virtual void _exit_tree() override; void player_connected(); - void player_disconnected(); + void player_disconnected(uint32_t player_id); bool initialize_player(IPlayer *player, uint32_t id); void reset_game_mode();