From dc5cc897927ba3bf70d4ba91d319a6fc4bb23c59 Mon Sep 17 00:00:00 2001 From: Andreas Ortmann Date: Wed, 5 Oct 2016 23:53:22 +0200 Subject: [PATCH] added player ship delete event and for missiles too. --- game/state/state.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/game/state/state.cpp b/game/state/state.cpp index af4a2f7..daecb33 100644 --- a/game/state/state.cpp +++ b/game/state/state.cpp @@ -165,9 +165,16 @@ namespace game { if (player != nullptr) { for (Missile *missile : player->missiles) { missile->player = nullptr; + m_nextEvents.push_back(new MissileEvent(LifeCycle::Destroy, missile)); } + if (player->ship != nullptr) { + ships.remove(player->ship); + m_nextEvents.push_back(new ShipEvent(LifeCycle::Destroy, player->ship)); + } + players.remove(player); + delete(player); } } @@ -534,6 +541,16 @@ namespace game { } break; + case EventType::Ship: + { + auto *se = static_cast(evt); + //std::cout<<"got missile delete event, finally deleting missile #" + // << me->object()->id << std::endl; + + delete(se->object()); + } + break; + case EventType::Missile: { auto *me = static_cast(evt);