Game Development Community

Question about containers

by Dave Myers · in Torque Game Engine · 10/04/2001 (6:11 am) · 4 replies

The engine has both a client and server container. Most functions that I have looked at that search through the containers do so on the server container only. I would like to know how best to use these containers, making sure that I am not causing unintended side-effects by using them incorrectly.

A good example would be object selection. If I wished to save off which shapeBase object id I have clicked on, and then later render that object with a cursor of sorts surrounding the object, it seems like I would need to have the id of that object from the client container. This would allow me to check if the player's currently-selected object id matches the object I am currently rendering, which is done purely on the client, and if so display the cursor or name or whatever.

What I'm wondering is if this is the correct approach, or if by allowing the client scripts to search through the client container is there an enhanced opportunity to cheat or will this cause other unintended problems?

Dave Myers
21-6 Productions
dave.myers@21-6.com

About the author

Considerable experience developing with Torque-based technologies and produced the first third-party game using any Torque technology (Orbz). Game designer, programmer, and producer, and credits include the innovative title Orbz and the colorful BuggOut.


#1
10/04/2001 (8:48 pm)
Allowing clients to run line of sights checks from the scripting language would basically allow them to write an auto-aim and shoot script. Probably not what you want :) Unless your writing a single player game.

Might want to run those checks on the server and simply inform the client which object he's selected.
#2
10/05/2001 (9:38 am)
You know, we actually started with doing the LOS check on the server - which worked fine and gave us an ID for the server instance of the shapeBase. But then, when we went to render the "selection cursor" in the shapeBase::onRender() override we ran into troubles figuring out how to use the server-side ID. That's because, as you know, the onRender() method is only called for client-side object instances (ghosts as we understand them). The ghost object has a different ID than that of the server instance of that same object - so we couldn't just compare the currently selected ID to the ID of the object beng rendered.

We have been trying to find a way to correlate the client ID of a ghost object to the corresponding server ID, but are not having any luck. It looks like there are mechanism to go the other way (getGhostIndex, for example) but those don't help.

We ended up doing the LOS on the client container so that we could get the client ID of the selected object in order to get it up an running quick. That doesn't sound like the way to go ultimately because of the cheating potentials you mentioned.

Do you have some guidance on how to solve this issue properly? Maybe using the object ID's and trying to correlate between the client and server instances - isnt the right way to go. Or, maybe there is an easy way to make that correlation that we haven't stumbled upon yet?

Thanks for your time on this Tim. We have really been stuggling with getting this one right.

Justin Mette
21-6 Productions
#3
10/05/2001 (10:51 pm)
You can call Connection->getGhostIndex(obj) on the server. This will give you the client side id of the object for that particular client connection (this number will be different for every client). You ship that over to the client, and the client calls Connection->resolveGhost(id) to get the local object. An example of this is in player.cc which transmits it's control object from server to client. The only thing to watch out for here is that the object may not be ghosted to a particular client, so you have to deal with that.
#4
10/09/2001 (5:54 am)
Thanks Tim. After seeing your suggestion above we really dug into the network layer and figured it out.

Thanks,

Dave Myers
21-6 Productions