diff options
author | Stijn Buys <ingar@osirion.org> | 2014-11-14 19:57:19 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2014-11-14 19:57:19 +0000 |
commit | 67727f0ad5b5cd9902b6b5e6369eba16cc48cf9e (patch) | |
tree | 830631b5a8525cc2b3c298deb2bbf8fb9376af1a /src/game | |
parent | 7550a2e19516d7924bcd89356f3f1b0402180e2f (diff) |
Corrected a segfault when adding wingmen.
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/base/npc.cc | 23 |
1 files changed, 11 insertions, 12 deletions
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(); |