Game Development Community

Connection Arguments...

by Melv May · in Torque Game Engine · 03/23/2003 (12:18 pm) · 7 replies

Hi,

Alright, I give up, what gives here? When using %con.setConnectArgs(...) and passing two arguments, everything is fine and the GameConnection::onConnect(...) function can see them without problem. It gets the %client plus the extra variables.

If I attempt to pass any more then it fails! Looking deep within the engine reveals that the extra local variable in the function onConnect is not being registered by the script engine.

With tracing on, the variables are showing but for some reason the extra local variable is not being created!

Is this something anyone else has come across or should I look at a potential corruption within my script files?

It's getting late on Sunday and I've spent the last two hours trying to figure this thing out.

- Melv.

#1
03/23/2003 (2:47 pm)
Hmm
Thats very strange Melv
I used to pass 4 variables in Trakers.
ie. %client, %name, %password, %skin, %model

and that worked ok.
Shouldnt require any engine changes

Probably a stupid thing to ask but are you sure that the scripts are compiling to dso properly? (occasionally you need to actually delete the previous dsos to force it to recompile)
#2
03/23/2003 (4:31 pm)
Latest code seems to work... I've merged it in with my own code which has diverged quite a bit from what's in the cvs, but (in my code at least) calling:

%profile = Profile.getCurrent();
%conn.setConnectArgs(%profile.getName(), %profile.getSkin(), %profile.getAvatar());

...and then:

function GameConnection::onConnect(%client, %name, %skin, %avatar)
{
    echo("Client Connection\n  Name: " @ %name @ "\n  Skin: " @ %skin @ "\n  Avatar = " @ %avatar @ "\n\n");

...seems to work fine.

Just doing a search through the torque code, though... There's quite a few places that the connection arguements are getting set, so maybe that's the problem...

Edit: Incidentally, is there any reason why all the connection stuff is strewn around throughout the code? In my code, I just whacked the following function in main.cs:

// Connect to server -- if no address is specified, assumes a local connection.
function connectToServer(%address)
{
	%conn = new GameConnection(ServerConnection);
	if (%address $= "")
		RootGroup.add(ServerConnection);

	%profile = Profile.getCurrent();
	%conn.setConnectArgs(%profile.getName(), %profile.getSkin(), %profile.getAvatar());
	%conn.setJoinPassword(%profile.getPassword());
	
	if (%address $= "")
		%conn.connectLocal();
	else
		%conn.connect(%address);
}

... and then just call connectToServer(); or connectToServer($JoinGameAddress); or whatever.
#3
03/23/2003 (10:08 pm)
Thanks guys,

I thought it should work without problem but it's definately not. I just double-checked that it is compiling, everything seems fine.

Hmmm, much be a 'glitch', I'll keep looking, thanks again. :)

- Melv.
#4
03/23/2003 (11:31 pm)
I hate those damn code gremlins. I told you not to feed the mogwai after midnight...
#5
03/24/2003 (3:47 am)
I just deleted *all* the DSOs and it now works. I guess I was too knackered last night to bother with that.

It was probably the calling DSO that was at fault.

Thanks guys.

- Melv.
#6
03/24/2003 (1:50 pm)
np
I hate it when that happens.
:)
#7
03/24/2003 (1:53 pm)
Tell me about it.

All is now quiet now back on this side of the fence and development continues at a steady pace. :)

- Melv.