Game Development Community

[Problem Solved] Crash upon disconnect

by St. · in Torque 3D Professional · 10/03/2009 (5:43 pm) · 4 replies

I've stumbled upon a strange problem; my client crashes if the disconnect function is issued from the server side, after a trigger activates the following function:

function clientCmdClDisc()
{
disconnect();
}

The trigger is implemented on the server side and is supposed to disconnect player upon collision by calling the "commandToClient(%client, 'ClDisc');" function respectively.

Calling clientCmdDisc() or disconnect() from the client console disconnects me successfully, but if I stumble upon the aforementioned trigger (and the server is triggering clientCmdClDisc) - the client crashes at the following place:

if (isObject(ServerConnection))
      ServerConnection.delete();

Added: this issue exists only when the ClDisc command is issued by a dedicated server. In the "single game mode" the problem disappears and I'm disconnected without any crashes.

I'm fighting with this issue for two days now, it's simply driving me mad...

Do you have any suggestions...?

#1
10/03/2009 (6:56 pm)
While I'm not sure why you are getting that crash without busting out the debugger, I do think that is the wrong approach.

If the server wants to disconnect a client it can do so directly by deleting the client connection, sending a command to the client requesting that they disconnect seems almost to nice '-)

For example, see kickban.cs
#2
10/03/2009 (7:05 pm)
Though if you are just in need of a quick-fix, you might also try scheduling the call to disconnect.
function clientCmdClDisc()  
{  
   schedule( 1, 0, "disconnect();" );
}

Though I don't know this, I suspect its the typical "deleting an object within a callback of that object" problem.
#3
10/03/2009 (7:15 pm)
I'm actually trying to follow the "Map Trigger" tutorial (http://www.garagegames.com/community/resources/view/2421), but it doesn't work on T3D as running another "connect(...)" function on the fly is not possible (existing ServerConnection cannot be redefined). That is why I wanted to try disconnecting the client and then re-connecting it again afterwards.
Believe me or not, but I managed to make this work at first in a sequence that I cannot remember (unfortunately, dammit!) and then it started crashing...
I tried reverting all my steps but it just doesn't help any more. I know, it's weird.

I also think that I tried deleting the client connection as it's implemented in kickban, but it didn't work for some reason.. I'll retry again and refresh my memory...

Added: Hmm, right, scheduling hasn't come to my mind yet. :) Thanks, I'll try.
#4
10/03/2009 (7:34 pm)
I can't believe it, Schedule really fixed my problem!

James Ford, thank you *very* much!

I'll be able to sleep at last! Yay!