[ENet-discuss] Object unique ID's

Ruud van Gaal ruud at racer.nl
Mon Mar 17 03:31:44 PDT 2008


Hi Martin,

Thanks for that. Indeed your method is what I attempt to do. The only thing
left is to determine which client actually owns the car after the new-car
message comes in. The flow:

- client1 requests car
- server accepts, sends newCar message (with unique car.NetworkID) to all
clients
- client1 sees the newCar message and creates the car

Now how does client1 know that it's his car and not a car from another
client? A useful method then would be if clients also had an ID that would
be the same on each computer. That way you can say 'newCar with networkID
<x> and ownerClient <y>' which would work on all clients.
You'd need the following (I really think I'll add that to ENet):
- server starts
- client attempts connect to server
- server generates unique ID for client and replies connectOK with uniqueID

If this happens in connection phase (inside ENet) that would help in
debugging connections.

How would you determine whether the car just generated was owned by the
requesting client?

Cheers,
Ruud
(who now goes to have a look at the enet source to see if there's something
in the structures that could help)

> Date: Sun, 16 Mar 2008 19:38:22 +0000
> From: Martin Sherburn <spacedude at konggame.co.uk>
> Subject: Re: [ENet-discuss] Object unique ID's
> To: Discussion of the ENet library <enet-discuss at cubik.org>
> Message-ID: <47DD772E.1060600 at konggame.co.uk>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Hi Ruud,
> 
> I think this is beyond the scope of what enet is for. But 
> it's really not that hard to implement some ID tracking 
> system yourself once you get your head around it.
> 
> As your are implementing a client/server system, the server 
> should be in charge of creating objects in the game (e.g. 
> cars) and telling all the clients about it. So here is what 
> you can do:
> 
> 1) Server creates car and assigns it a unique ID
> 2) Server tells clients about this new car that was created 
> and sends the ID it assigned to it
> 3) All clients create a copy of the car and assign it the ID 
> the server gave
> 
> So the basic rule is, only the server should generate IDs. 
> The clients will always receive the ID from the server.
> 
> In the case where the client may want to spawn a new car by 
> joining the game. Then the client should send a request to 
> the server to create the car (without generating an ID for 
> it). If the server accepts the request, it will create a car 
> and generate and ID for it and tell all the clients about it 
> including the one that sent the request in the first place.
> 
> Martin.
> 
> Ruud van Gaal wrote:
> > Hi,
> >
> > I'm re-designing part of my multiplayer game to improve 
> object updates.
> > Before using ENet, I had a UDP connection scheme where every client 
> > would get sent a unique ID from the server. The server was 
> for example 
> > ID 70, the first connected client got 71 etc. This way, on all 
> > connected computers you could see who was who and you could 
> simply send updates for ID <x>.

No virus found in this outgoing message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.21.7/1331 - Release Date: 16/03/2008
10:34
 



More information about the ENet-discuss mailing list