Simplified more code, fixed some coding style.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12593 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2013-04-03 21:15:13 +00:00
parent aea7a001c5
commit 9429beef79
3 changed files with 15 additions and 26 deletions

View File

@ -63,22 +63,23 @@ void LinearWorld::init()
m_last_lap_sfx_playing = false;
const unsigned int kart_amount = m_karts.size();
for(unsigned int n=0; n<kart_amount; n++)
{
KartInfo info;
info.getSector()->update(m_karts[n]->getXYZ());
m_kart_info.push_back(info);
} // next kart
// The values are initialised in reset()
m_kart_info.resize(m_karts.size());
} // init
//-----------------------------------------------------------------------------
/** The destructor frees al data structures.
*/
LinearWorld::~LinearWorld()
{
sfx_manager->deleteSFX(m_last_lap_sfx);
} // ~LinearWorld
//-----------------------------------------------------------------------------
/** Called before a race is started (or restarted). It resets the data
* structures that keep track of position and distance long track of
* all karts.
*/
void LinearWorld::reset()
{
WorldWithRank::reset();
@ -102,7 +103,8 @@ void LinearWorld::reset()
// be used everywhere
#define assertExpr( ARG1, OP, ARG2 ) if (!(ARG1 OP ARG2)) \
{ \
std::cerr << "Failed assert " << #ARG1 << #OP << #ARG2 << " @ " << __FILE__ << ":" << __LINE__ \
std::cerr << "Failed assert " << #ARG1 << #OP << #ARG2 << " @ " \
<< __FILE__ << ":" << __LINE__ \
<< "; values are (" << ARG1 << #OP << ARG2 << ")\n"; \
assert(false); \
}
@ -266,7 +268,8 @@ void LinearWorld::newLap(unsigned int kart_index)
}
}
}
else if (raceHasLaps() && kart_info.m_race_lap > 0 && kart_info.m_race_lap+1 < lap_count)
else if (raceHasLaps() && kart_info.m_race_lap > 0 &&
kart_info.m_race_lap+1 < lap_count)
{
m_race_gui->addMessage(_("Lap %i", kart_info.m_race_lap+1),
kart, 3.0f, video::SColor(255, 210, 100, 50),
@ -769,7 +772,7 @@ void LinearWorld::updateRacePosition()
continue;
}
if(m_kart_info[j].m_overall_distance == my_distance &&
m_karts[j]->getInitialPosition()<kart->getInitialPosition() )
m_karts[j]->getInitialPosition()<kart->getInitialPosition())
{
p++;
std::cout << " " << p << " : " << m_karts[j]->getIdent()

View File

@ -102,11 +102,6 @@ protected:
*/
AlignedArray<KartInfo> m_kart_info;
/** Linear races can trigger rescues for one additional reason : shortcuts.
* It may need to do some specific world before calling the generic Kart::forceRescue
*/
void rescueKartAfterShortcut(AbstractKart* kart, KartInfo& kart_info);
virtual void checkForWrongDirection(unsigned int i);
void updateRacePosition();
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;

View File

@ -59,17 +59,8 @@ void ThreeStrikesBattle::init()
{
fprintf(stderr, "No AI exists for this game mode\n");
exit(1);
}
const unsigned int kart_amount = m_karts.size();
for(unsigned int n=0; n<kart_amount; n++)
{
// create the struct that ill hold each player's lives
BattleInfo info;
m_kart_info.push_back(info);
} // next kart
m_kart_info.resize(kart_amount);
}
m_kart_info.resize(m_karts.size());
} // ThreeStrikesBattle
//-----------------------------------------------------------------------------