Iterating through a connection to server
by Matt Huston · in Torque 3D Professional · 09/29/2010 (3:11 am) · 6 replies
I am creating GuiControl that displays all Players with some information on screen. The problem herein lies that once the Players move approximately > 1000 torque units away from the player, they're no longer in the iterating list
I'm not sure if this is a bug or working as intended as I haven't ever created a control that I wanted to get details of units at these kinds of distances. To reproduce, the basic setup is similar to that of GuiShapeNameHud, though to test that, you'd need to turn off the fading of text names.
GameConnection* conn = GameConnection::getConnectionToServer(); ... for (SimSetIterator itr(conn); *itr; ++itr) ... // I iterate through, getting only units that are < 1000 torque units from the player
I'm not sure if this is a bug or working as intended as I haven't ever created a control that I wanted to get details of units at these kinds of distances. To reproduce, the basic setup is similar to that of GuiShapeNameHud, though to test that, you'd need to turn off the fading of text names.
About the author
www.atomicbanzai.com
#2
In Beta 2 im using this code and there is no distance based object selection:
09/29/2010 (4:20 am)
What version are you using?In Beta 2 im using this code and there is no distance based object selection:
GameConnection* conn = GameConnection::getConnectionToServer();
if (!conn)
return 0;
for (SimSetIterator itr(conn); *itr; ++itr)
{
ShapeBase* shape = static_cast<ShapeBase*>(*itr);
...
#3
09/29/2010 (8:10 am)
Alternatively you could have the server to create a list based on ClientGroup. Whenever the client would ask for a player list, it would send the hash of its cached player list to the server which would compare it with a hash of its own list. If it changed, the list would be pushed through to the client. You could also let the client request a hash comparison only ie. once every 30 seconds (on the server side), so that clients can't flood the server.
#4
Reasonable from my point of view is to let the server send a stats message on a defined time interval. You could build your data as records, words, fields in a string and decompress and display it on the client. All done in script. But careful, the transferred stringlen is limited to 255 characters. So use tagged strings were possible.
09/29/2010 (11:14 am)
Ehm, IIRC there is a mechanism in Torque trashing all ghosts not in scope of the client. So they disappear from the client. Reasonable from my point of view is to let the server send a stats message on a defined time interval. You could build your data as records, words, fields in a string and decompress and display it on the client. All done in script. But careful, the transferred stringlen is limited to 255 characters. So use tagged strings were possible.
#5
09/29/2010 (11:26 am)
They disappear from the client, but they are all in ClientGroup as long as they are connected to the server. ClientGroup is a server side object where all clients are kept track of. Of course this is not propagated to clients. The way I explained will go around the ghosting issue and get you a list of all clients. However, you could still optimize it by pushing only changes in the list to the client. You should only send the data (ie. names) the client needs and not the actual client list of course.
#6
@Konrad - That is probably a good way to go, this is for single player purposes only so it should work. For now I'll just use the view distances and optimize later to use more of a 'smart' system.
09/29/2010 (12:00 pm)
@Adam - This is in T3D 1.1b3, I just updated last week and wasn't working on this portion of the code before so hadn't seen this. Basically, will be needing far view distances since the game I am making has wide open landscapes with lots of vehicles.@Konrad - That is probably a good way to go, this is for single player purposes only so it should work. For now I'll just use the view distances and optimize later to use more of a 'smart' system.
Torque 3D Owner Matt Huston
Atomic Banzai Games
new LevelInfo(theLevelInfo) { ... visibleDistance = "1000";