From 92e4ee5afbe67c828225f1847f0d01b6e03f51c1 Mon Sep 17 00:00:00 2001
From: auria <auria@178a84e3-b1eb-0310-8ba1-8eac791a3b58>
Date: Fri, 24 Oct 2008 01:34:20 +0000
Subject: [PATCH] better time handling in battle mode

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2369 178a84e3-b1eb-0310-8ba1-8eac791a3b58
---
 src/gui/race_results_gui.cpp       | 13 +++++++------
 src/modes/three_strikes_battle.cpp | 12 ++++++++++++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/gui/race_results_gui.cpp b/src/gui/race_results_gui.cpp
index 3f70580f5..0b1c0cf98 100644
--- a/src/gui/race_results_gui.cpp
+++ b/src/gui/race_results_gui.cpp
@@ -162,10 +162,11 @@ Widget *RaceResultsGUI::displayKartList(Widget *w_prev, int *order, float horizo
     {
         if(order[i] == -1) continue;
         
-        const Kart *KART = RaceManager::getKart(order[i]);
-        const std::string& KART_NAME = KART->getName();
+        const Kart *current_kart = RaceManager::getKart(order[i]);
+        const std::string& kart_name = current_kart->getName();
         char sTime[20];sTime[0]=0;
-        const float T      = KART->getFinishTime();
+        const float T      = current_kart->getFinishTime();
+
         if(display_time)
             TimeToString(T, sTime);
 
@@ -173,18 +174,18 @@ Widget *RaceResultsGUI::displayKartList(Widget *w_prev, int *order, float horizo
         if(race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX)
         {
             sprintf((char*)(score + MAX_STR_LEN * i), "%d. %s %s +%d %d",
-                KART->getPosition(), KART_NAME.c_str(), sTime,
+                current_kart->getPosition(), kart_name.c_str(), sTime,
                 race_manager->getKartPrevScore(order[i]),
                 race_manager->getKartScore(order[i]));
         }
         else
         {
             sprintf((char*)(score + MAX_STR_LEN * i), "%d. %s %s",
-                    KART->getPosition(), KART_NAME.c_str(), sTime);
+                    current_kart->getPosition(), kart_name.c_str(), sTime);
         }
 
         Widget *image=widget_manager->addImgButtonWgt(WTOK_FIRST_IMAGE + kart_id, 7, 7,
-                                       KART->getKartProperties()->getIconFile() );
+                                       current_kart->getKartProperties()->getIconFile() );
         widget_manager->deactivateWgt(WTOK_FIRST_IMAGE+kart_id);
 
         image->setPosition(WGT_DIR_FROM_LEFT, horizontal, NULL, 
diff --git a/src/modes/three_strikes_battle.cpp b/src/modes/three_strikes_battle.cpp
index 87fcaf148..977d6a804 100644
--- a/src/modes/three_strikes_battle.cpp
+++ b/src/modes/three_strikes_battle.cpp
@@ -68,6 +68,17 @@ void ThreeStrikesBattle::onGo()
 void ThreeStrikesBattle::terminateRace()
 {
     updateKartRanks();
+    
+    // if some karts have not yet finished yet
+    const unsigned int kart_amount = m_kart.size();
+    for ( Karts::size_type i = 0; i < kart_amount; ++i)
+    {
+        if(!m_kart[i]->hasFinishedRace())
+        {
+            m_kart[i]->raceFinished(TimedRace::getTime());
+        }  // if !hasFinishedRace
+    }   // for i
+    
     World::terminateRace();
 }
 //-----------------------------------------------------------------------------
@@ -84,6 +95,7 @@ void ThreeStrikesBattle::kartHit(const int kart_id)
     // check if kart is 'dead'
     if(m_kart_info[kart_id].m_lives < 1)
     {
+        m_kart[kart_id]->raceFinished(TimedRace::getTime());
         removeKart(kart_id);
     }