Dedicated Server Crash
by Daniel Neilsen · in Torque Game Engine · 06/09/2002 (5:59 pm) · 17 replies
Hey guys,
In my game the following loines of code work fine on a hosted game but on a dedicated server causes a crash.
any ideas?
In my game the following loines of code work fine on a hosted game but on a dedicated server causes a crash.
any ideas?
%p = new explosion()
{
dataBlock = %type;
position = %pos;
};
MissionCleanup.add(%p);About the author
#2
06/09/2002 (8:05 pm)
One I have created but like I said, works fine for a hosted game.
#3
Moreover, it does not surprised me. I had the same error with waterblock using stagnat type. I should remove them in order to be able to have a dedicated server.
06/10/2002 (7:05 am)
I suggest that you trace your code zith the NET_DEBUG activated. You will then find very quickly the problems.Moreover, it does not surprised me. I had the same error with waterblock using stagnat type. I should remove them in order to be able to have a dedicated server.
#4
Labrat has tested it on the latest HEAD and spanwing an explosion will still crash the dedicated server.
06/23/2002 (2:06 pm)
This bug still exists.Labrat has tested it on the latest HEAD and spanwing an explosion will still crash the dedicated server.
#5
FATAL:(c:\torque\engine\game\fx\explosion.cc @712)
error, must have a connection to server!
07/18/2002 (8:19 am)
I was just wanted to say what error we get when the server crashes.FATAL:(c:\torque\engine\game\fx\explosion.cc @712)
error, must have a connection to server!
#6
07/19/2002 (12:48 pm)
Make sure the required textures and sounds for the explosion exist.
#7
07/19/2002 (7:07 pm)
My textures are correct and I have no sound for my explosion yet. Are you saying that not having an explosion sound may be causing the crash?
#8
07/19/2002 (9:18 pm)
Ok, I've successfully fixed the problem. I'll submit a patch to GarageGames for inclusion.
#9
07/19/2002 (9:42 pm)
Sweet Thank you.
#10
07/20/2002 (2:29 am)
Robert, what WAS the problem??? Could you post it here, too? Thanks!
#11
Now usually this isn't an issue, because there are two ways to tell if the object is client side, or server side (either isServerObject() or isClientObject() ). Keep in mind that, in code you have to deal with both cases because there will always be a client object and a server object from the code aspect. However, in the working model the code will always branch to either the client or the server portion of the code, depending on if you are a client connecting to a server or a server hosting a game.
Is the the code subject to this issue of server/client objects. There are two cases where in the Explosion::onAdd() function where this particular code is at. I just rewrote the function to include the server/client object check
07/20/2002 (7:27 am)
Well the problem resides in the fact that an object has both client side components and server side components. In the case of the explosion object, the code was attempting to peform a client specific function on the server resulting in the server crashing and the clients connected to them to time out.Now usually this isn't an issue, because there are two ways to tell if the object is client side, or server side (either isServerObject() or isClientObject() ). Keep in mind that, in code you have to deal with both cases because there will always be a client object and a server object from the code aspect. However, in the working model the code will always branch to either the client or the server portion of the code, depending on if you are a client connecting to a server or a server hosting a game.
GameConnection* connection = GameConnection::getServerConnection();
Is the the code subject to this issue of server/client objects. There are two cases where in the Explosion::onAdd() function where this particular code is at. I just rewrote the function to include the server/client object check
#12
As far as why this only occured when we created a new explosion object in script, here is why. Normally, when you create a projectile datablock you also specify an explosion datablock attached to it. This means that all the important information regarding that particular type of explosion is sent to the clients when they join the server. However, when you create an explosion in script, this isn't the case, even though the datablock you specify for the explosion will already be on the client, the explosion object itself is not.
07/20/2002 (7:34 am)
I also wanted to add that other areas of code in the engine could be subject to the same type of crash, it is just a matter of finding them.As far as why this only occured when we created a new explosion object in script, here is why. Normally, when you create a projectile datablock you also specify an explosion datablock attached to it. This means that all the important information regarding that particular type of explosion is sent to the clients when they join the server. However, when you create an explosion in script, this isn't the case, even though the datablock you specify for the explosion will already be on the client, the explosion object itself is not.
#13
Would be great! Thanks a lot! :-)
07/20/2002 (7:36 am)
Could you post a snipit where and how you've included this check in the case of this explosion creation?Would be great! Thanks a lot! :-)
#14
07/20/2002 (7:49 am)
Here is the rewritten function.bool Explosion::onAdd()
{
if(!Parent::onAdd())
return false;
mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );
if( mFabs( mDataBlock->offset ) > 0.001 )
{
MatrixF axisOrient = MathUtils::createOrientFromDir( mInitialNormal );
MatrixF trans = getTransform();
Point3F randVec;
randVec.x = sgRandom.randF( -1.0, 1.0 );
randVec.y = sgRandom.randF( 0.0, 1.0 );
randVec.z = sgRandom.randF( -1.0, 1.0 );
randVec.normalize();
randVec *= mDataBlock->offset;
axisOrient.mulV( randVec );
trans.setPosition( trans.getPosition() + randVec );
setTransform( trans );
}
if( mDelayMS == 0 )
{
if( !explode() )
{
return false;
}
}
// shake camera
GameConnection* connection = GameConnection::getServerConnection();
if(isClientObject() && connection)
{
if( mDataBlock->shakeCamera )
{
// first check if explosion is near player
//GameConnection* connection = GameConnection::getServerConnection();
ShapeBase* obj = connection->getControlObject();
bool applyShake = true;
if( obj )
{
ShapeBase* cObj = obj;
while((cObj = cObj->getControlObject()) != 0)
{
if(cObj->useObjsEyePoint())
{
applyShake = false;
break;
}
}
}
if( applyShake && obj )
{
VectorF diff = obj->getPosition() - getPosition();
F32 dist = diff.len();
if( dist < mDataBlock->camShakeRadius )
{
CameraShake *camShake = new CameraShake;
camShake->setDuration( mDataBlock->camShakeDuration );
camShake->setFrequency( mDataBlock->camShakeFreq );
F32 falloff = dist / mDataBlock->camShakeRadius;
falloff = 1 + falloff * 10.0;
falloff = 1.0 / (falloff * falloff);
VectorF shakeAmp = mDataBlock->camShakeAmp * falloff;
camShake->setAmplitude( shakeAmp );
camShake->setFalloff( mDataBlock->camShakeFalloff );
camShake->init();
gCamFXMgr.addFX( camShake );
}
}
}
gClientContainer.addObject(this);
gClientSceneGraph->addObjectToScene(this);
removeFromProcessList();
gClientProcessList.addObject(this);
//NetConnection* pNC = NetConnection::getServerConnection();
//AssertFatal(pNC != NULL, "Error, must have a connection to the server!");
connection->addObject(this);
}
mRandomVal = sgRandom.randF();
// Initialize the light structure and register as a dynamic light
if (mDataBlock->lightStartRadius != 0 || mDataBlock->lightEndRadius) {
mLight.mType = LightInfo::Point;
mLight.mRadius = mDataBlock->lightStartRadius;
mLight.mColor = mDataBlock->lightStartColor;
Sim::getLightSet()->addObject(this);
}
return true;
}
#15
07/20/2002 (8:00 am)
Cool, thanks alot!!
#16
We'll include Robert's fix so that the server doesn't crash, but long term it seems like we should update the explosion object to act as a networked object when constructed on the server.
07/21/2002 (9:37 am)
The Explosion class is not a networked object and should not be created on the server. None of the example objects, nor did any T2 objects, ever create an explosion on the server, it's a clients side only object. The fix that Robert posted allows you to create an explosion object on the server without it crashing, but that doesn't do you a lot of good as there is no network support, which means the explosion will not appear on all the clients. Explosions are create indirectly on the client by other networked objects, such as the projectile, vehicles, etc.We'll include Robert's fix so that the server doesn't crash, but long term it seems like we should update the explosion object to act as a networked object when constructed on the server.
#17
01/17/2007 (12:30 pm)
Revisiting this old thread.... this still has not be fixed as Tim outlined above. This resource is the best fix available, but it would be really great if someone took the initiative to fix this one correctly. ;)
Torque 3D Owner Robert Blanchet Jr.
Um, is the datablock your giving a default one or one that you've created/modified?