As discussed with Joerg : started removing maximum number of karts limitations

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5410 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-05-07 18:39:07 +00:00
parent 4a66d148c9
commit e84cb5d10c
3 changed files with 33 additions and 11 deletions

View File

@ -12,7 +12,7 @@
<spacer width="50" height="25"/>
<!--
<spinner id="aikartamount" proportion="3" height="100%" min_value="0" max_value="8" icon="gui/karts%i.png"/> -->
<spinner id="aikartamount" proportion="1" height="100%" min_value="0" max_value="7"/>
<spinner id="aikartamount" proportion="1" height="100%" min_value="0" max_value="20"/>
</div>
<spacer proportion="2" width="25"/>

View File

@ -329,7 +329,7 @@ std::vector<std::string> KartPropertiesManager::getRandomKartList(int count,
// there are no more karts in the current group
while(count>0 && karts.size()>0)
{
used[karts.back()] = true;
//used[karts.back()] = true;
random_karts.push_back(m_karts_properties[karts.back()]->getIdent());
karts.pop_back();
count --;
@ -347,13 +347,34 @@ std::vector<std::string> KartPropertiesManager::getRandomKartList(int count,
karts.push_back(i);
}
std::random_shuffle(karts.begin(), karts.end());
// Then fill up the remaining empty spaces
while(count>0 && karts.size()>0)
do
{
random_karts.push_back(m_karts_properties[karts.back()]->getIdent());
karts.pop_back();
count --;
}
while(count>0 && karts.size()>0)
{
random_karts.push_back(m_karts_properties[karts.back()]->getIdent());
karts.pop_back();
count --;
}
// we used all karts but still need more... we'll have no choice but
// to use the same karts more than once.
if (count>0 && karts.size() == 0)
{
for(unsigned int i=0; i<getNumberOfKarts(); i++)
{
std::cout << "Refill : i=" << i << ", used[i]=" << used[i] << ", m_kart_available[i]=" << m_kart_available[i] << std::endl;
if(!used[i] && m_kart_available[i] &&
!unlock_manager->isLocked(m_karts_properties[i]->getIdent()) )
karts.push_back(i);
}
assert(karts.size() > 0);
std::random_shuffle(karts.begin(), karts.end());
}
} while(count>0);
// There should always be enough karts
assert(count==0);
return random_karts;

View File

@ -215,19 +215,20 @@ void LinearWorld::update(float delta)
#ifdef DEBUG
// FIXME: Debug output in case that the double position error occurs again.
int pos_used[10];
for(int i=0; i<10; i++) pos_used[i]=-99;
int pos_used[kart_amount+1];
for(int i=0; i<=kart_amount; i++) pos_used[i]=-99;
for(unsigned int i=0; i<kart_amount; i++)
{
if(pos_used[m_karts[i]->getPosition()]!=-99)
{
for(unsigned int j =0; j<kart_amount; j++)
{
printf("kart id=%d, position=%d, finished=%d, laps=%d, distanceDownTrack=%f\n",
printf("kart id=%d, position=%d, finished=%d, laps=%d, distanceDownTrack=%f %s\n",
j, m_karts[j]->getPosition(),
m_karts[j]->hasFinishedRace(),
m_kart_info[j].m_race_lap,
getDistanceDownTrackForKart(m_karts[j]->getWorldKartId()));
getDistanceDownTrackForKart(m_karts[j]->getWorldKartId()),
(m_karts[j]->getPosition() == m_karts[i]->getPosition() ? "<--- !!!" : ""));
}
}
pos_used[m_karts[i]->getPosition()]=i;