Game Development Community

Stupid Question

by Matt "Mr. Pig" Razza · in Torque Game Engine · 04/16/2006 (8:00 pm) · 8 replies

I'll just get to the point :P

How would I find the "gameConnection" of my client. I.E. I am character A, in the engine I am running a tick on character B's weapon. How can I figure out if I am the one that is "ticking" on my client.

Thanks. :)

#1
04/22/2006 (5:46 pm)
Bumb?
#2
04/22/2006 (6:30 pm)
I also need to know. (Rather he does, so he can fix something I need working) :P
#3
04/22/2006 (7:46 pm)
You guys want the ID of the client-side gameConnection in a given client? If that's so, search in the scripts for the place where a gameConnection is created .connect() is called. Just store that gameConnection ID in a global, or give it a name when creating it, and you're set.

To keep the code generic, do the same with the connection used for the connectLocal (now that I think about it... that one already gets named localClientConnection... so maybe trying to name it something else could break loads of stuff. Maybe it's better store it in a global).
#4
04/23/2006 (12:20 pm)
I was going to try that but I'd be comparing a GameConnection object (the class in C++) to a integer that was stored in the var. Will that still work?
#5
04/25/2006 (1:38 pm)
Con::printf(":%s:", (S32)getControllingClient()->getIdString());
	 if (S32(getControllingClient()->getIdString()) - S32(Con::getVariable("$Client::gameConnection")) == 0)
	 {
		 Con::printf("=");
	 }
	 else if (S32(getControllingClient()->getIdString()) - S32(Con::getVariable("$Client::gameConnection")) > 0)
	 {
		 Con::printf(">");
	 }
	 else if (S32(getControllingClient()->getIdString()) - S32(Con::getVariable("$Client::gameConnection")) < 0)
	 {
		 Con::printf("<");
	 }
	 Con::printf(":%s:", (S32)Con::getVariable("$Client::gameConnection"));

Guess what that prints in the console:
:1424:
<
:1424:

How is 1424 < 1424... anyhelp?
#6
04/27/2006 (12:53 pm)
Bump?
#7
04/27/2006 (1:16 pm)
You are doing completely radical casting of string pointers to S32, and then doing mathematical operations on the result. None of these casts are valid (they give you completely worthless information, not in any way what you are trying to accomplish).

You can't turn a string that represents a number ("1424") into the number without using a function like atoi("string");
#8
04/27/2006 (1:28 pm)
Ah. Well my casting was to see if there was a difference in the ascii characters or if my origanal string comparison was just flawed. I forgot to take the code out after I finished testing.

I'll try that.