Fixed various crashes on server.

This commit is contained in:
hiker
2016-04-19 17:36:12 +10:00
parent f2b67f75b6
commit 245045f575
5 changed files with 21 additions and 8 deletions

View File

@@ -53,10 +53,12 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char
*/
Explosion::~Explosion()
{
#ifndef SERVER_ONLY
if(m_emitter)
{
delete m_emitter;
}
#endif
} // ~Explosion
//-----------------------------------------------------------------------------
@@ -73,6 +75,7 @@ bool Explosion::updateAndDelete(float dt)
m_emission_frames++;
m_remaining_time -= dt;
#ifndef SERVER_ONLY
if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time)
{
scene::ISceneNode* node = m_emitter->getNode();
@@ -90,7 +93,7 @@ bool Explosion::updateAndDelete(float dt)
node->getMaterial(0).DiffuseColor.setRed(intensity);
node->getMaterial(0).EmissiveColor.setRed(intensity);
}
#endif
// Do nothing more if the animation is still playing
if (m_remaining_time>0) return false;
@@ -100,6 +103,7 @@ bool Explosion::updateAndDelete(float dt)
// object is removed.
if (m_remaining_time > -explosion_time)
{
#ifndef SERVER_ONLY
// if framerate is very low, emit for at least a few frames, in case
// burst time is lower than the time of 1 frame
if (m_emission_frames > 2)
@@ -108,6 +112,7 @@ bool Explosion::updateAndDelete(float dt)
m_emitter->getNode()->getEmitter()->setMinParticlesPerSecond(0);
m_emitter->getNode()->getEmitter()->setMaxParticlesPerSecond(0);
}
#endif
}
else
{

View File

@@ -214,7 +214,11 @@ void Kart::init(RaceManager::KartType type)
}
#ifdef SERVER_ONLY
bool animations = false; // server never animates
#else
bool animations = true;
#endif
const int anims = UserConfigParams::m_show_steering_animations;
if (anims == ANIMS_NONE)
{

View File

@@ -55,6 +55,7 @@ KartGFX::KartGFX(const AbstractKart *kart)
m_nitro_light = irr_driver->addLight(location, /*force*/ 0.4f,
/*radius*/5.0f, 0.0f, 0.4f, 1.0f,
false, node);
#ifndef SERVER_ONLY
m_nitro_light->setVisible(false);
#ifdef DEBUG
m_nitro_light->setName( ("nitro emitter (" + m_kart->getIdent()
@@ -79,6 +80,7 @@ KartGFX::KartGFX(const AbstractKart *kart)
m_skidding_light_2->setVisible(false);
m_skidding_light_2->setName( ("skidding emitter 2 (" + m_kart->getIdent()
+ ")").c_str() );
#endif
#ifndef SERVER_ONLY
if (CVS->isGLSL())
@@ -419,8 +421,10 @@ void KartGFX::updateNitroGraphics(float nitro_frac)
*/
void KartGFX::updateSkidLight(unsigned int level)
{
#ifndef SERVER_ONLY
m_skidding_light_1->setVisible(level == 1);
m_skidding_light_2->setVisible(level > 1);
#endif
} // updateSkidLight
// ----------------------------------------------------------------------------
@@ -520,7 +524,9 @@ void KartGFX::setGFXFromReplay(int nitro, bool zipper,
// ----------------------------------------------------------------------------
void KartGFX::setGFXInvisible()
{
#ifndef SERVER_ONLY
m_nitro_light->setVisible(false);
m_skidding_light_1->setVisible(false);
m_skidding_light_2->setVisible(false);
#endif
} // setGFXInvisible

View File

@@ -66,6 +66,7 @@ void Moveable::setNode(scene::ISceneNode *n)
void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
const btQuaternion& rotation)
{
#ifndef SERVER_ONLY
Vec3 xyz=getXYZ()+offset_xyz;
m_node->setPosition(xyz.toIrrVector());
btQuaternion r_all = getRotation()*rotation;
@@ -75,6 +76,7 @@ void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
Vec3 hpr;
hpr.setHPR(r_all);
m_node->setRotation(hpr.toIrrHPR());
#endif
} // updateGraphics
//-----------------------------------------------------------------------------

View File

@@ -42,8 +42,7 @@ CheckCannon::CheckCannon(const XMLNode &node, unsigned int index)
m_curve = new Ipo(*(node.getNode("curve")),
/*fps*/25,
/*reverse*/race_manager->getReverseTrack());
#ifndef SERVER_ONLY
#ifdef DEBUG
#if defined(DEBUG) && !defined(SERVER_ONLY)
if(UserConfigParams::m_track_debug)
{
m_show_curve = new ShowCurve(0.5f, 0.5f);
@@ -51,8 +50,7 @@ CheckCannon::CheckCannon(const XMLNode &node, unsigned int index)
for(unsigned int i=0; i<p.size(); i++)
m_show_curve->addPoint(p[i]);
}
#endif // DEBUG
#endif // SERVER_ONLY
#endif // DEBUG AND !SERVER_ONLY
} // CheckCannon
// ----------------------------------------------------------------------------
@@ -62,12 +60,10 @@ CheckCannon::CheckCannon(const XMLNode &node, unsigned int index)
CheckCannon::~CheckCannon()
{
delete m_curve;
#ifndef SERVER_ONLY
#ifdef DEBUG
#if defined(DEBUG) && !defined(SERVER_ONLY)
if(UserConfigParams::m_track_debug)
delete m_show_curve;
#endif
#endif
} // ~CheckCannon
// ----------------------------------------------------------------------------