From 67727f0ad5b5cd9902b6b5e6369eba16cc48cf9e Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 14 Nov 2014 19:57:19 +0000 Subject: Corrected a segfault when adding wingmen. --- src/game/base/npc.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/game') diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc index 44cad7c..e0999da 100644 --- a/src/game/base/npc.cc +++ b/src/game/base/npc.cc @@ -51,20 +51,19 @@ NPC *NPC::add_wingman(Ship *leader) for (size_t i = 0; i < leader->slots()->size(); ++i) { core::Slot *slot = leader->slots()->operator[](i); - if (!slot->has_flag(core::Slot::Mounted) && slot->item()) { - continue; - } + if (slot->item() && slot->has_flag(core::Slot::Mounted)) { - core::Item *npc_item = new core::Item(slot->item()->info()); - npc_item->set_amount(slot->item()->amount()); - npc_item->set_flags(slot->item()->flags()); - npc_item->set_flag(core::Item::Mounted); - npc->inventory()->add(npc_item); + core::Item *npc_item = new core::Item(slot->item()->info()); + npc_item->set_amount(slot->item()->amount()); + npc_item->set_flags(slot->item()->flags()); + npc_item->set_flag(core::Item::Mounted); + npc->inventory()->add(npc_item); - core::Slot *npc_slot = npc->slots()->operator[](i); - npc_slot->set_item(npc_item); - npc_slot->set_flag(core::Slot::Active); - npc_slot->set_flag(core::Slot::Mounted); + core::Slot *npc_slot = npc->slots()->operator[](i); + npc_slot->set_item(npc_item); + npc_slot->set_flag(core::Slot::Active); + npc_slot->set_flag(core::Slot::Mounted); + } } npc->calculate_weapon_range(); -- cgit v1.2.3