added player ship delete event and for missiles too.

This commit is contained in:
Andreas Ortmann 2016-10-05 23:53:22 +02:00
parent 8ec3f47276
commit dc5cc89792

View file

@ -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<ShipEvent*>(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<MissileEvent*>(evt);