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
This commit is contained in:
auria 2008-10-24 01:34:20 +00:00
parent ac886cb21a
commit 92e4ee5afb
2 changed files with 19 additions and 6 deletions

View File

@ -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,

View File

@ -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);
}