Sending sets to client
by Justin Tolchin · in Torque Game Engine · 06/14/2005 (1:21 pm) · 4 replies
Hi all,
If I have a SimSet on the server, is there a way to get it ghosted to the client? The set contains a list of other server-side objects (although I guess I really want to send the ghost id's down to the client). It seems like SimSets weren't designed to be ghosted through the network, which makes sense, so maybe I need another class that does this. Does anybody know what I should be using?
Or would I be better off just making a "clientCmdCreateGroup" call or something, and passing the ghost ids of the objects I want to exist in that group? I.e., something like:
for(%i = 0; %i < %group.getCount(); %i++)
{
%listOfGhostIds = %listOfGhostIds SPC %group.getObject(%i).getGhostId();
}
commandToClient(%client, 'CreateGroup', %listOfGhostIds);
and then reconstruct the set on the client?
Thanks!
If I have a SimSet on the server, is there a way to get it ghosted to the client? The set contains a list of other server-side objects (although I guess I really want to send the ghost id's down to the client). It seems like SimSets weren't designed to be ghosted through the network, which makes sense, so maybe I need another class that does this. Does anybody know what I should be using?
Or would I be better off just making a "clientCmdCreateGroup" call or something, and passing the ghost ids of the objects I want to exist in that group? I.e., something like:
for(%i = 0; %i < %group.getCount(); %i++)
{
%listOfGhostIds = %listOfGhostIds SPC %group.getObject(%i).getGhostId();
}
commandToClient(%client, 'CreateGroup', %listOfGhostIds);
and then reconstruct the set on the client?
Thanks!
#2
Presumably I need to recreate the SimSet on the client side, so the hierarchy info gets maintained, but maybe there's another way to do it? Bear in mind that there's actually going to be more than one level in this hierarchy, so I might have 5 units in a "group", and I might have 5 "groups" stored in a "parent group". The issue is just that I want to get the hierarchy information down to the client for purposes of displaying it in some way to the user, while sending the minimum amount of info necessary. I can say that each group will have at most 5 members, regardless of whether those members are sub-groups or actual units.
I hope that makes sense. :-)
06/14/2005 (2:18 pm)
Hi Stephen: ok, I'll try to explain a little further (but I'm pretty sure I want to go with the "commandToClient" approach). Basically I'm planning on having a set of RTSUnits (at most 5) bundled into a "group". So each unit needs to have a pointer to its "group" object. I figured I would just use a SimSet object as the "group" and add each unit to the SimSet. However, when a unit is selected on the client end of things, I might need to, for example, display what group it is in, and some information about the other members of the group. So after the group gets created on the server, I need to send back down to the client some information about what group it is in, and I wasn't sure what the best way to do that was. Presumably I need to recreate the SimSet on the client side, so the hierarchy info gets maintained, but maybe there's another way to do it? Bear in mind that there's actually going to be more than one level in this hierarchy, so I might have 5 units in a "group", and I might have 5 "groups" stored in a "parent group". The issue is just that I want to get the hierarchy information down to the client for purposes of displaying it in some way to the user, while sending the minimum amount of info necessary. I can say that each group will have at most 5 members, regardless of whether those members are sub-groups or actual units.
I hope that makes sense. :-)
#3
06/14/2005 (5:57 pm)
Yes it does--in fact, that is exactly how the RTS-SK implements the selelection group--look at selection.cs, and the server side catcher commands for things add to selection, etc.
#4
06/14/2005 (6:35 pm)
Ok, cool. I have it working properly now. Thanks for confirming that was a valid approach. It was probably seeing the selection logic that clued me in, actually (since I've been staring at it alot recently). :-)
Torque 3D Owner Stephen Zepp