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:
parent
aea7a001c5
commit
9429beef79
@ -63,22 +63,23 @@ void LinearWorld::init()
|
|||||||
m_last_lap_sfx_playing = false;
|
m_last_lap_sfx_playing = false;
|
||||||
const unsigned int kart_amount = m_karts.size();
|
const unsigned int kart_amount = m_karts.size();
|
||||||
|
|
||||||
for(unsigned int n=0; n<kart_amount; n++)
|
// The values are initialised in reset()
|
||||||
{
|
m_kart_info.resize(m_karts.size());
|
||||||
KartInfo info;
|
|
||||||
info.getSector()->update(m_karts[n]->getXYZ());
|
|
||||||
m_kart_info.push_back(info);
|
|
||||||
} // next kart
|
|
||||||
|
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
/** The destructor frees al data structures.
|
||||||
|
*/
|
||||||
LinearWorld::~LinearWorld()
|
LinearWorld::~LinearWorld()
|
||||||
{
|
{
|
||||||
sfx_manager->deleteSFX(m_last_lap_sfx);
|
sfx_manager->deleteSFX(m_last_lap_sfx);
|
||||||
} // ~LinearWorld
|
} // ~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()
|
void LinearWorld::reset()
|
||||||
{
|
{
|
||||||
WorldWithRank::reset();
|
WorldWithRank::reset();
|
||||||
@ -102,7 +103,8 @@ void LinearWorld::reset()
|
|||||||
// be used everywhere
|
// be used everywhere
|
||||||
#define assertExpr( ARG1, OP, ARG2 ) if (!(ARG1 OP ARG2)) \
|
#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"; \
|
<< "; values are (" << ARG1 << #OP << ARG2 << ")\n"; \
|
||||||
assert(false); \
|
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),
|
m_race_gui->addMessage(_("Lap %i", kart_info.m_race_lap+1),
|
||||||
kart, 3.0f, video::SColor(255, 210, 100, 50),
|
kart, 3.0f, video::SColor(255, 210, 100, 50),
|
||||||
@ -769,7 +772,7 @@ void LinearWorld::updateRacePosition()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(m_kart_info[j].m_overall_distance == my_distance &&
|
if(m_kart_info[j].m_overall_distance == my_distance &&
|
||||||
m_karts[j]->getInitialPosition()<kart->getInitialPosition() )
|
m_karts[j]->getInitialPosition()<kart->getInitialPosition())
|
||||||
{
|
{
|
||||||
p++;
|
p++;
|
||||||
std::cout << " " << p << " : " << m_karts[j]->getIdent()
|
std::cout << " " << p << " : " << m_karts[j]->getIdent()
|
||||||
|
@ -102,11 +102,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
AlignedArray<KartInfo> m_kart_info;
|
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);
|
virtual void checkForWrongDirection(unsigned int i);
|
||||||
void updateRacePosition();
|
void updateRacePosition();
|
||||||
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
|
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
|
||||||
|
@ -60,16 +60,7 @@ void ThreeStrikesBattle::init()
|
|||||||
fprintf(stderr, "No AI exists for this game mode\n");
|
fprintf(stderr, "No AI exists for this game mode\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
m_kart_info.resize(m_karts.size());
|
||||||
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);
|
|
||||||
} // ThreeStrikesBattle
|
} // ThreeStrikesBattle
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user