Moved call to RaceGUI::init out of world::reset to avoid
duplicated thunderbird: reset is called each time before a race is (re)started, while an init function must only be called once. This properly fixes #918 (referees not removed), which was caused by init actually being called twice. Also changed order of when the referee position is computed: before it was computed before World::resetAllKarts was executed (which settles the karts at their stable start position). This resulted in slightly different start positions (depending on positions set in blender, not the position in which the kart were finally stable. This fixed #917. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12664 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9773df37ee
commit
9860f5f576
@ -109,13 +109,14 @@ World::World() : WorldStatus(), m_clear_color(255,100,101,140)
|
||||
m_stop_music_when_dialog_open = true;
|
||||
|
||||
WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||
|
||||
} // World
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This function is called after instanciating. This can't be moved to the
|
||||
* contructor as child classes must be instanciated, otherwise polymorphism
|
||||
* will fail and the results will be incorrect . Also in init() functions
|
||||
* can be called that use World::getWorld().
|
||||
/** This function is called after instanciating. The code here can't be moved
|
||||
* to the contructor as child classes must be instanciated, otherwise
|
||||
* polymorphism will fail and the results will be incorrect . Also in init()
|
||||
* functions can be called that use World::getWorld().
|
||||
*/
|
||||
void World::init()
|
||||
{
|
||||
@ -128,7 +129,10 @@ void World::init()
|
||||
|
||||
// Create the race gui before anything else is attached to the scene node
|
||||
// (which happens when the track is loaded). This allows the race gui to
|
||||
// do any rendering on texture.
|
||||
// do any rendering on texture. Note that this function can NOT be called
|
||||
// in the World constuctor, since it might be overwritten by a the game
|
||||
// mode class, which would not have been constructed at the time that this
|
||||
// constructor is called, so the wrong race gui would be created.
|
||||
createRaceGUI();
|
||||
|
||||
// Grab the track file
|
||||
@ -165,7 +169,10 @@ void World::init()
|
||||
m_track->adjustForFog(newkart->getNode());
|
||||
|
||||
} // for i
|
||||
|
||||
|
||||
// Must be called after all karts are created
|
||||
m_race_gui->init();
|
||||
|
||||
if(ReplayPlay::get())
|
||||
ReplayPlay::get()->Load();
|
||||
|
||||
@ -191,17 +198,6 @@ void World::reset()
|
||||
m_saved_race_gui = NULL;
|
||||
}
|
||||
|
||||
// erase messages left over
|
||||
RaceGUIBase* rg = getRaceGUI();
|
||||
if (rg)
|
||||
{
|
||||
rg->init();
|
||||
rg->clearAllMessages();
|
||||
}
|
||||
|
||||
m_race_gui->restartRace();
|
||||
m_race_gui->clearAllMessages();
|
||||
|
||||
m_schedule_pause = false;
|
||||
m_schedule_unpause = false;
|
||||
|
||||
@ -229,6 +225,9 @@ void World::reset()
|
||||
// of karts.
|
||||
m_track->reset();
|
||||
|
||||
// Reset the race gui.
|
||||
m_race_gui->reset();
|
||||
|
||||
// Start music from beginning
|
||||
music_manager->stopMusic();
|
||||
|
||||
|
@ -101,12 +101,28 @@ RaceGUIBase::RaceGUIBase()
|
||||
* gui. This is called after the world has been initialised, e.g. all karts
|
||||
* do exist (while the constructor is called before the karts are created).
|
||||
* In the base gui this is used to initialise the referee data (which needs
|
||||
* the start positions of the karts).
|
||||
* the start positions of the karts). Note that this function is (and must
|
||||
* be called only once, after its constructor).
|
||||
* \pre All karts must be created, since this object defines the
|
||||
* positions for the referees based on the karts.
|
||||
*/
|
||||
void RaceGUIBase::init()
|
||||
{
|
||||
m_kart_display_infos.resize(race_manager->getNumberOfKarts());
|
||||
|
||||
// Do everything else required at a race restart as well, esp.
|
||||
// resetting the height of the referee.
|
||||
m_referee = new Referee();
|
||||
m_referee_pos.resize(race_manager->getNumberOfKarts());
|
||||
m_referee_rotation.resize(race_manager->getNumberOfKarts());
|
||||
} // init
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** This is called when restarting a race. In the race gui base it resets
|
||||
* height of the referee, so that it can start flying down again.
|
||||
*/
|
||||
void RaceGUIBase::reset()
|
||||
{
|
||||
// While we actually only need the positions for local players,
|
||||
// we add all karts, since it's easier to get a world kart id from
|
||||
// the kart then the local player id (and it avoids problems in
|
||||
@ -114,36 +130,20 @@ void RaceGUIBase::init()
|
||||
for(unsigned int i=0; i<race_manager->getNumberOfKarts(); i++)
|
||||
{
|
||||
const AbstractKart *kart = World::getWorld()->getKart(i);
|
||||
m_referee_pos.push_back(kart->getTrans()(Referee::getStartOffset()));
|
||||
Vec3 hpr = Referee::getStartRotation()
|
||||
+ Vec3(0, kart->getHeading()*RAD_TO_DEGREE, 0);
|
||||
m_referee_rotation.push_back(hpr);
|
||||
m_referee_pos[i] = kart->getTrans()(Referee::getStartOffset());
|
||||
m_referee_rotation[i] = Referee::getStartRotation()
|
||||
+ Vec3(0, kart->getHeading()*RAD_TO_DEGREE, 0);
|
||||
}
|
||||
|
||||
// Do everything else required at a race restart as well, esp.
|
||||
// resetting the height of the referee.
|
||||
restartRace();
|
||||
} // init
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** This is called when restarting a race. In the race gui base it resets
|
||||
* height of the referee, so that it can start flying down again.
|
||||
*/
|
||||
void RaceGUIBase::restartRace()
|
||||
{
|
||||
//fixes multiple referee problem.
|
||||
//create a referee only if it is not created, uses the existing referee for multiple restarts
|
||||
if(m_referee == NULL)
|
||||
{
|
||||
m_referee = new Referee();
|
||||
}
|
||||
m_referee_height = 10.0f;
|
||||
m_referee->attachToSceneNode();
|
||||
m_plunger_move_time = 0;
|
||||
m_plunger_offset = core::vector2di(0,0);
|
||||
m_plunger_speed = core::vector2df(0,0);
|
||||
m_plunger_state = PLUNGER_STATE_INIT;
|
||||
} // restartRace
|
||||
clearAllMessages();
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** The destructor removes the marker texture and the referee scene node.
|
||||
|
@ -220,7 +220,7 @@ public:
|
||||
virtual ~RaceGUIBase();
|
||||
virtual void renderGlobal(float dt);
|
||||
virtual void init();
|
||||
virtual void restartRace();
|
||||
virtual void reset();
|
||||
virtual void renderPlayerView(const Camera *camera, float dt);
|
||||
virtual void addMessage(const irr::core::stringw &m,
|
||||
const AbstractKart *kart, float time,
|
||||
|
Loading…
Reference in New Issue
Block a user