fixed bugs with battle mode
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2363 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c6abd628ca
commit
6ac6eb9623
@ -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 )
|
||||
|
@ -316,7 +316,12 @@ void World::updateHighscores()
|
||||
for (unsigned int i=0; i<kart_amount; i++ )
|
||||
{
|
||||
index[i] = 999; // first reset the contents of the array
|
||||
index[m_kart[i]->getPosition()-1] = i;
|
||||
}
|
||||
for (unsigned int i=0; i<kart_amount; i++ )
|
||||
{
|
||||
const int pos = m_kart[i]->getPosition()-1;
|
||||
if(pos < 0 || pos >= kart_amount) continue; // wrong position
|
||||
index[pos] = i;
|
||||
}
|
||||
|
||||
for(unsigned int pos=0; pos<kart_amount; pos++)
|
||||
@ -341,6 +346,8 @@ void World::updateHighscores()
|
||||
if(!m_kart[index[pos]]->isPlayerKart()) 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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user