From 6529381acd8f3edb02d308ceb0c243d03ea4eb0c Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Mon, 10 Aug 2015 19:01:58 -0400 Subject: [PATCH] Fix rescue code in tutorial mode, fixes #2279 --- src/modes/tutorial_world.cpp | 26 ++++++++++++++++++++++++++ src/modes/tutorial_world.hpp | 9 +++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/modes/tutorial_world.cpp b/src/modes/tutorial_world.cpp index 8bf0eec48..27def25a0 100644 --- a/src/modes/tutorial_world.cpp +++ b/src/modes/tutorial_world.cpp @@ -26,3 +26,29 @@ TutorialWorld::TutorialWorld() { m_stop_music_when_dialog_open = false; } // TutorialWorld + +unsigned int TutorialWorld::getRescuePositionIndex(AbstractKart *kart) +{ + const int start_spots_amount = getTrack()->getNumberOfStartPositions(); + assert(start_spots_amount > 0); + + float closest_distance = 999999.0f; + int closest_id_found = 0; + + Vec3 kart_pos = kart->getFrontXYZ(); + + for (int n = 0; n