Author Topic: Strange error/bug with TCPObject  (Read 823 times)

I haven't really tested this with any other object, but I've noticed a strange error/bug when creating a TCPObject, and having a SimGroup be part of it.
Like this.

Code: [Select]
new TCPObject(TCPServer)
{
   IP = $MyTCPIpAddress;
   Port = 6788;
   Clients = new simGroup();
};
And doing that makes the TCPObject have no name, and if I remember correctly I can't set a name to it.
I solved it by doing this.
Code: [Select]
%tcpObj = new TCPObject(TCPServer)
{
    IP = $MyTCPIpAddress;
    Port = 6788;
};
%tcpObj.clients = new simGroup();
Anyway, it's not a problem to me (now), but I am just curious why did this happen, and wanted to know if it happened to anyone else before.


Also as I said before, it's not a problem since it's been solved, but I would like to know what caused this.


Known issue with torque.
Ah, never knew that.
Took forever to realise what was wrong.

I guess I'll leave this topic open in case anyone wanna discuss the topic.
Else I'll just let it die into page two.

I'd say the cleanest thing of preparing a structure like that is this way (since you'll probably want .clients for every TCPServer instance):

function TCPServer::onAdd(%this)
{
    %this.clients = new SimGroup();
}

function TCPServer::onRemove(%this)
{
    %this.clients.delete();
}

// other code implementing TCPServer functionality

new TCPObject(TCPServer)
{
    ip = $MyTCPIpAddress;
    port = 6788;
};