changed player join/leave message
This commit is contained in:
@@ -63,7 +63,6 @@ void Lobby::SendTimeRemaining() {
|
||||
|
||||
void Lobby::OnPlayerJoin(std::uint8_t playerID) {
|
||||
m_Players.push_back(playerID);
|
||||
utils::LOG("(Server) Player Joined Lobby !");
|
||||
|
||||
if (!m_LobbyOpened)
|
||||
return;
|
||||
@@ -83,7 +82,6 @@ void Lobby::OnPlayerLeave(std::uint8_t playerID)
|
||||
|
||||
m_Players.erase(it);
|
||||
|
||||
utils::LOG("(Server) Player Leaved Lobby !");
|
||||
if (!m_LobbyOpened)
|
||||
return;
|
||||
|
||||
|
||||
@@ -164,8 +164,10 @@ void Server::BroadcastPacket(const protocol::Packet* packet) {
|
||||
|
||||
void Server::RemoveConnexion(std::uint8_t connexionID) {
|
||||
auto it = GetPlayers().find(connexionID);
|
||||
if (it != GetPlayers().end())
|
||||
if (it != GetPlayers().end()) {
|
||||
GetPlayers().erase(it);
|
||||
utils::LOG(utils::format("\t[%s] left !", it->second.GetName().c_str()));
|
||||
}
|
||||
m_Connections.erase(connexionID);
|
||||
m_Lobby.OnPlayerLeave(connexionID);
|
||||
OnPlayerLeave(connexionID);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "td/misc/Time.h"
|
||||
#include "td/misc/Random.h"
|
||||
#include "td/misc/Format.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@@ -96,6 +97,8 @@ void ServerConnexion::HandlePacket(const protocol::PlayerLoginPacket* packet) {
|
||||
if (m_Player->GetName().empty() && !packet->GetPlayerName().empty()) {
|
||||
m_Player->SetName(packet->GetPlayerName());
|
||||
|
||||
utils::LOG(utils::format("\t[%s] joined !", m_Player->GetName().c_str()));
|
||||
|
||||
protocol::PlayerJoinPacket joinPacket(m_ID, m_Player->GetName());
|
||||
m_Server->BroadcastPacket(&joinPacket);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user