From 0936e6722a8a651a85343d42fa2fb802cfc567ef Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 30 Mar 2011 13:34:16 +0000 Subject: Corrected a segfault in Jumpgate::validate() if it had an invalid destination. --- src/game/base/jumppoint.cc | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc index 1f2c0a9..80c99ef 100644 --- a/src/game/base/jumppoint.cc +++ b/src/game/base/jumppoint.cc @@ -125,23 +125,30 @@ JumpGate::~JumpGate() void JumpGate::validate() { JumpPoint::validate(); - - // overwrite name and info - // overwrite name and info, remove the "system" part from the name - std::string name("Jumpgate " + zone()->name() + " -> " + target()->zone()->name()); - for (size_t pos = name.find(" system"); pos != std::string::npos; pos = name.find(" system")) { - name.erase(pos, 7); - } - set_name(name); - - core::Info *entity_info = core::Info::find(info()); - entity_info->clear_text(); - entity_info->add_text("Jumpgate to the " + target()->zone()->name()); if (target()) { set_flag(core::Entity::Dockable); + + // overwrite name and info + // overwrite name and info, remove the "system" part from the name + std::string name("Jumpgate " + zone()->name() + " -> " + target()->zone()->name()); + for (size_t pos = name.find(" system"); pos != std::string::npos; pos = name.find(" system")) { + name.erase(pos, 7); + } + set_name(name); + + core::Info *entity_info = core::Info::find(info()); + entity_info->clear_text(); + + // FIXME if 'system' was erased from the name, 'the' should not appear in the info text + // e.g. Jumpgate to Kor Telos + entity_info->add_text("Jumpgate to the " + target()->zone()->name()); + } else { unset_flag(core::Entity::Dockable); + + std::string name("Inactive Jumpgate"); + set_name(name); } } -- cgit v1.2.3