[Beta 1.1] ServerConnection: Need to schedule it to get it working if in a ClientCmd function (sample inside)
by elvince · in Torque 3D Professional · 02/27/2010 (10:03 am) · 2 replies
Hi,
I'm really confused when dealing with this function.
Let's take a sample:
This is the implementation of a simple zoning function. The server send a message to the client to zone to another server.
result: Game Crash
Error: 0xC0000005: Access violation reading location 0xfeeefef2.
in void NetConnection::eventReadPacket(BitStream *bstream) at while(mWaitSeqEvents && mWaitSeqEvents->mSeqCount == mNextRecvEventSeq)
I hope someone can explain & fix this behavior?
Thanks,
I'm really confused when dealing with this function.
Let's take a sample:
This is the implementation of a simple zoning function. The server send a message to the client to zone to another server.
function ClientCmdZone()
{
Disconnect();
connect("127.0.0.1:28000");
}result: Game Crash
Error: 0xC0000005: Access violation reading location 0xfeeefef2.
in void NetConnection::eventReadPacket(BitStream *bstream) at while(mWaitSeqEvents && mWaitSeqEvents->mSeqCount == mNextRecvEventSeq)
function ClientCmdZone()
{
schedule(0, 0, "Disconnect");
schedule(0, 0,"connect","127.0.0.1:28000");
}Works perfectly!!I hope someone can explain & fix this behavior?
Thanks,
About the author
Recent Threads
#2
By reading your comment it seems so obvious that it leads to crash the game. I will take care of this later on.
02/28/2010 (10:51 am)
Thanks for this useful information.By reading your comment it seems so obvious that it leads to crash the game. I will take care of this later on.
Associate Rene Damm
Destroying the client connection while executing script code on it is bound to cause crashes. This is why the deferred disconnect works.
Generally, big world changing script code like disconnect calls should be moved as high up in the control loop as possible. By executing them through schedule(), they are guaranteed to run almost immediately underneath the main loop.
Executing dramatic changes from code executing in engine call-outs runs danger of destroying structures that are currently in use by the engine. A simple example is effecting the deletion of a GuiControl within one of its own script callbacks.