remove mobs on player leave
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "server/Server.h"
|
||||
|
||||
#include "td/protocol/packets/DisconnectPacket.h"
|
||||
#include "td/protocol/packets/RemoveMobPacket.h"
|
||||
#include "td/protocol/packets/RemoveTowerPacket.h"
|
||||
#include "td/protocol/packets/UpdatePlayerTeamPacket.h"
|
||||
#include "td/protocol/packets/UpdateGameStatePacket.h"
|
||||
@@ -135,13 +136,26 @@ void ServerGame::OnGameClose() {
|
||||
m_Server->Restart();
|
||||
}
|
||||
|
||||
void ServerGame::OnPlayerJoin(game::PlayerID id){
|
||||
void ServerGame::OnPlayerJoin(game::PlayerID id) {
|
||||
if (m_GameState == game::GameState::Game)
|
||||
BalanceTeams();
|
||||
}
|
||||
|
||||
void ServerGame::OnPlayerLeave(game::PlayerID playerId){
|
||||
void ServerGame::OnPlayerLeave(game::PlayerID playerId) {
|
||||
// temporary fix
|
||||
|
||||
auto& mobList = GetWorld()->GetMobList();
|
||||
for(std::size_t i = 0; i < mobList.size(); i++) {
|
||||
auto mob = mobList.at(i);
|
||||
|
||||
if(mob->GetSender() == playerId) {
|
||||
protocol::RemoveMobPacket packet(mob->GetMobID());
|
||||
m_Server->BroadcastPacket(&packet);
|
||||
|
||||
mobList.erase(mobList.begin() + i);
|
||||
}
|
||||
}
|
||||
|
||||
auto& towerList = GetWorld()->GetTowers();
|
||||
for(std::size_t i = 0; i < towerList.size(); i++) {
|
||||
auto tower = towerList.at(i);
|
||||
|
||||
Reference in New Issue
Block a user