Server side groups
by Radoslaw Marcin Kurczewski · in Torque Game Engine · 05/26/2003 (11:16 pm) · 8 replies
The following problem occures in multiplayer game:
We have created (using Mission Editor) several SimSets holding various information e.g. beacon marker objects. Now we would like to have access to them from the client (GUI control displaying map and markers):
1. We pass name of such a group from server to client using messages (earlier we used id)...
2. Client receives correct name (checked!)
3. Using 'Sim::findObject(name)' we try to find appropriate group, but...
4. ...it always results in NULL pointer (which means, object could not be found)
5. Command echo( nameToID( "MissionGroup" ) ); typed in console window on client returns -1!
6. Attempt to launch Mission Editor results in message similar to'You need to download mission first', but we CAN play that mission over the LAN!!!
7. Points 5-6 were tested also in RealmWars example and results were the same...
Any suggestions?
Roman
We have created (using Mission Editor) several SimSets holding various information e.g. beacon marker objects. Now we would like to have access to them from the client (GUI control displaying map and markers):
1. We pass name of such a group from server to client using messages (earlier we used id)...
2. Client receives correct name (checked!)
3. Using 'Sim::findObject(name)' we try to find appropriate group, but...
4. ...it always results in NULL pointer (which means, object could not be found)
5. Command echo( nameToID( "MissionGroup" ) ); typed in console window on client returns -1!
6. Attempt to launch Mission Editor results in message similar to'You need to download mission first', but we CAN play that mission over the LAN!!!
7. Points 5-6 were tested also in RealmWars example and results were the same...
Any suggestions?
Roman
#2
Above classes are Torque core and we hope there is some simpler solution to do this...
Regards
Roman
05/27/2003 (1:51 am)
That's fact, SimSet is implemented as CONOBJECT not CO_NETOBJECT. Do you suggest Bryan to rewrite SimSet/SimGroup classes (we cannot just replace IMPLEMENT_CONOBJECT macro with IMPLEMENT_CO_NETOBJECT)?Above classes are Torque core and we hope there is some simpler solution to do this...
Regards
Roman
#3
05/27/2003 (2:35 am)
Your objects themselves need to be netobjects as well in order fo the client to see them. Once that's done you'll want to write a specialized group class rather than modify SimSet to be a netobject.
#4
The same problem refers to AudioProfiles - client has no information about them.
We've got message: "Unable to locate audio profile/description..."
Roman
05/28/2003 (3:42 am)
Hi again,The same problem refers to AudioProfiles - client has no information about them.
We've got message: "Unable to locate audio profile/description..."
Roman
#5
You cannot refer to an object on the client with a server ID. What you will find is that you're actually passing an object Id and not the object itself.
The thing to remember is that there is actually no seperate server-side/client-side to the scripts. It may seem that way under some circumstances such as if your client is running locally e.g. the client-pc actually creates the server. In this case, things like global variables will be available to both because they are the one and same executing piece of code.
The problems occur when you run them independantly e.g. with a dedicated server and/or the client is run on another PC.
Things created on the server don't get automagically transmitted to the client(s) unless their corresponding C++ object is designed to do so and in most cases this is simply a ghost object (with a new ID and no name) to allow rendering on the client (or some other job) with appropriate information channelled to the ghost object from the server object.
Creating a SimSet or what-not on the server doesn't mean that it will instantly be available on the client by name/id. Its ghost may be there (not the case with a SimSet) but it *typically* does not need referencing. If this did happen, then all clients would see things such as groups, ids etc which would be pretty bad security-wise.
Most of this comes down to the fact that the server ultimately controls all the objects in its simulation and ghosts objects to the clients normally so that they can begin their client-specific job, whether rendering of whatnot. During this period, the server object may stream relevant information to it to allow it to complete its work.
When a client is connected and its scripts are executing, it does not have access to these objects. When you get the server to send the 'name' of one of your object then the client receives this number or string fine, as you would expect. You then try to search for it and shouldn't be suprised that its not there because it isn't. Its ghost may be but it will have a different ID.
The only thing that you see are datablocks that are designed to be sent upon mission download as static information to initialise your local objects.
If you've got a list on the server that you want on the client(s) and assuming that the clients have the objects/details to put in the list already, then you'll have to send that information to the client 'manually' with commands.
Be careful that you're not doing something that you should be doing another way. Working with the engine is much easier. An example is the mission description during download. The server uploads this to the client, line by line with a set of functions to handle it. This may seem laborious but when you think about it, unless you've got an 'intelligent' client script running, you shouldn't need to send much bulk information using the scripts, the C++ objects should deal with the net communications and you scripts should simply orchestrate their actions.
Hey, I'm far from an expert when it comes to the scripts but I know that I found the fact that there is no specific client-side scripting, very confusing.
Hope this helps a little.
- Melv.
05/28/2003 (4:43 am)
Hi,You cannot refer to an object on the client with a server ID. What you will find is that you're actually passing an object Id and not the object itself.
The thing to remember is that there is actually no seperate server-side/client-side to the scripts. It may seem that way under some circumstances such as if your client is running locally e.g. the client-pc actually creates the server. In this case, things like global variables will be available to both because they are the one and same executing piece of code.
The problems occur when you run them independantly e.g. with a dedicated server and/or the client is run on another PC.
Things created on the server don't get automagically transmitted to the client(s) unless their corresponding C++ object is designed to do so and in most cases this is simply a ghost object (with a new ID and no name) to allow rendering on the client (or some other job) with appropriate information channelled to the ghost object from the server object.
Creating a SimSet or what-not on the server doesn't mean that it will instantly be available on the client by name/id. Its ghost may be there (not the case with a SimSet) but it *typically* does not need referencing. If this did happen, then all clients would see things such as groups, ids etc which would be pretty bad security-wise.
Most of this comes down to the fact that the server ultimately controls all the objects in its simulation and ghosts objects to the clients normally so that they can begin their client-specific job, whether rendering of whatnot. During this period, the server object may stream relevant information to it to allow it to complete its work.
When a client is connected and its scripts are executing, it does not have access to these objects. When you get the server to send the 'name' of one of your object then the client receives this number or string fine, as you would expect. You then try to search for it and shouldn't be suprised that its not there because it isn't. Its ghost may be but it will have a different ID.
The only thing that you see are datablocks that are designed to be sent upon mission download as static information to initialise your local objects.
If you've got a list on the server that you want on the client(s) and assuming that the clients have the objects/details to put in the list already, then you'll have to send that information to the client 'manually' with commands.
Be careful that you're not doing something that you should be doing another way. Working with the engine is much easier. An example is the mission description during download. The server uploads this to the client, line by line with a set of functions to handle it. This may seem laborious but when you think about it, unless you've got an 'intelligent' client script running, you shouldn't need to send much bulk information using the scripts, the C++ objects should deal with the net communications and you scripts should simply orchestrate their actions.
Hey, I'm far from an expert when it comes to the scripts but I know that I found the fact that there is no specific client-side scripting, very confusing.
Hope this helps a little.
- Melv.
#6
On the other hand it did not make me happy to much :-(
My current problem is:
1. There are some group of object on the server, which information (location) I would like to render in player GUI, e.g. beacons and other players...
2. While beacons are 'static' that way, their position does not change during the game, maybe it is a solution to read and parse mission file (containing beacons def) and create such a group on client side? Please correct me if I'm wrong or even worse...
3. Above won't work for 'dynamic' objects (i.e. moving around the level), like other players and so on... Is there any possibility to traverse list of objects on client side (since there have(?) to be there at least for render purposes, as you wrote: with different IDs and without name).
Regards
Roman
05/29/2003 (12:15 am)
Thaks Melv, you clarified me a lot an essence of that problem!On the other hand it did not make me happy to much :-(
My current problem is:
1. There are some group of object on the server, which information (location) I would like to render in player GUI, e.g. beacons and other players...
2. While beacons are 'static' that way, their position does not change during the game, maybe it is a solution to read and parse mission file (containing beacons def) and create such a group on client side? Please correct me if I'm wrong or even worse...
3. Above won't work for 'dynamic' objects (i.e. moving around the level), like other players and so on... Is there any possibility to traverse list of objects on client side (since there have(?) to be there at least for render purposes, as you wrote: with different IDs and without name).
Regards
Roman
#7
05/29/2003 (12:41 am)
You should look at the source to the ShapeNameHUD control and the radar resources. This should give you the some of the information you're looking for.
#8
06/03/2003 (2:48 am)
That's it! It finally works as expected! Thanks a lot!
Torque Owner Bryan "daerid" Ross