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);