diff --git a/src/modes/three_strikes_battle.cpp b/src/modes/three_strikes_battle.cpp index 8bb68179f..68a6ac794 100644 --- a/src/modes/three_strikes_battle.cpp +++ b/src/modes/three_strikes_battle.cpp @@ -25,6 +25,7 @@ ThreeStrikesBattle::ThreeStrikesBattle() : World() { TimedRace::setClockMode(CHRONO); + m_use_highscores = false; // FIXME - disable AI karts in the GUI if(race_manager->getNumKarts() > race_manager->getNumPlayers()) @@ -66,6 +67,14 @@ void ThreeStrikesBattle::onGo() //----------------------------------------------------------------------------- void ThreeStrikesBattle::terminateRace() { + // give a fake rank to each kart to avoid crashes + // FIXME - implement properly, and don't duplicate like now + const unsigned int NUM_KARTS = race_manager->getNumKarts(); + for( unsigned int kart_id = 0; kart_id < NUM_KARTS; ++kart_id ) + { + m_kart[kart_id]->setPosition(kart_id+1); + } + World::terminateRace(); } //----------------------------------------------------------------------------- @@ -75,11 +84,21 @@ void ThreeStrikesBattle::kartHit(const int kart_id) assert(kart_id < (int)m_kart.size()); // make kart lose a life - m_kart_info[kart_id].m_lives --; + m_kart_info[kart_id].m_lives -= 3; // check if kart is 'dead' if(m_kart_info[kart_id].m_lives < 1) + { + // give a fake rank to each kart to avoid crashes + // FIXME - implement properly, and don't duplicate like now + const unsigned int NUM_KARTS = race_manager->getNumKarts(); + for( unsigned int n = 0; n < NUM_KARTS; ++n ) + { + m_kart[n]->setPosition(n+1); + } + removeKart(kart_id); + } // almost over, use fast music if(getCurrentNumKarts()==2 && m_faster_music_active==false) @@ -217,7 +236,8 @@ void ThreeStrikesBattle::moveKartAfterRescue(Kart* kart, btRigidBody* body) //----------------------------------------------------------------------------- void ThreeStrikesBattle::raceResultOrder( int* order ) { - // FIXME - implement properly + // give fake rank to karts + // FIXME - implement properly, and don't duplicate like now const unsigned int NUM_KARTS = race_manager->getNumKarts(); for( unsigned int kart_id = 0; kart_id < NUM_KARTS; ++kart_id ) diff --git a/src/modes/world.cpp b/src/modes/world.cpp index e4ff62931..335280f8a 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -316,7 +316,12 @@ void World::updateHighscores() for (unsigned int i=0; igetPosition()-1] = i; + } + for (unsigned int i=0; igetPosition()-1; + if(pos < 0 || pos >= kart_amount) continue; // wrong position + index[pos] = i; } for(unsigned int pos=0; posisPlayerKart()) continue; if (!m_kart[index[pos]]->hasFinishedRace()) continue; + assert(index[pos] >= 0); + assert(index[pos] < m_kart.size()); PlayerKart *k = (PlayerKart*)m_kart[index[pos]]; HighscoreEntry* highscores = getHighscores(); diff --git a/src/race_manager.cpp b/src/race_manager.cpp index fe8f823e5..603ba044c 100644 --- a/src/race_manager.cpp +++ b/src/race_manager.cpp @@ -354,6 +354,9 @@ void RaceManager::RaceFinished(const Kart *kart, float time) if(pos<=0) pos=stk_config->m_max_karts; } + assert(pos-1 >= 0); + assert(pos-1 < m_kart_status.size()); + m_kart_status[i].m_score += m_score_for_position[pos-1]; m_kart_status[i].m_last_score = m_score_for_position[pos-1]; m_kart_status[i].m_overall_time += time;