From 114de658928969c7ac84f0ea0617d5afc4ebb870 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 8 Feb 2015 22:25:56 +0000 Subject: Corrected a bug in the launching code where the axis of the wrong slot was used. --- src/game/base/ship.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index 0a64c0e..15b995c 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -548,15 +548,20 @@ void Ship::launch() if (nbdocks) { // choose a random dock to launch from - core::Slots::iterator slit = ship_dock->slots()->begin(); - int launchbay_index = math::randomi(nbdocks); - for (int i = 0; i < launchbay_index; ++slit) { + int i = 0; + core::Slot *launchbay = 0; + + for (core::Slots::iterator slit = ship_dock->slots()->begin(); slit != ship_dock->slots()->end(); ++slit) { if ((*slit)->type() == model::Slot::Dock) { - ++i; + if (i == launchbay_index) { + launchbay = (*slit); + break; + } + + i++; } } - core::Slot *launchbay = (*slit); get_axis().assign(ship_dock->axis() * launchbay->axis()); get_location().assign(ship_dock->location() + ship_dock->axis() * ( launchbay->location() + launchbay->axis().forward() * radius())); -- cgit v1.2.3