On Feb 9, 2008 7:09 PM, Sandra et Yannig <[EMAIL PROTECTED]> wrote:

> Le Saturday 09 February 2008 13:13:00 Kurosu, vous avez écrit :
> > Hi,
> >
> > in RandomSync::Init(), a first seed is set, then if the computer is a
> > server, another one is generated and sent to the clients.
> >
> > Network works, so there's probably more to it than just this. Could some
> > senior (or knowledgeable) wormux developper explain me why (and possibly
> > add a comment in the code to make sense of this)?
>
> As far as I know, gentildemon as work on this part but he tells me that we
> don't need to store an array of random values synced up with the server.
> You
> just need a initial seed, next value are provided using a very simple
> function (in network/randomsync.cpp) :
>
> ....
> /* RAND_MAX assumed to be 32767 */
> static inline uint wormux_rand(void)
> {
>  next = next * 1103515245 + 12345;
>  return((uint)(next/65536) % 32768);
> }
> ....
>
> So, you just need to send the initial seed, next value are available using
> this function.
>




>
> To keep everybody sync, you send the original seed and you don't have to
> send
> a complete array.
>

That is only true if the function is called the same number of times on each
client machine.

Right now, I used randomSync for making camera shake, and that means, that
every client will make different number of calls depending on its FPS.

It is probably not the only case where number of randomSync calls can
differ, depending on client's performance... I guess that there can be (or
might be) weapons calling randomSync() on each update, and that means that
someone who plays with 50fps will get two times more random values than
someone who plays with 25 fps...

Is it somehow accounted for?

Best regards,
RCL
_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à