Le Sunday 10 February 2008 00:08:06 RCL, vous avez écrit : > 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.
I have to say, It's not the good way to achieve this ... Wormux use 2 number generators : random sync and random (aka without sync). And we use them for different things : - things that need to be sync (weapon interaction against ground, character position, wind direction and strength etc) - things that don't need it (every thing else like wind particles, camera shake ;) ). So, a camera shake is obvously falling in the 2nd type. > > 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... > About our internal physical engine, we are not limited about the FPS. the physical engine is working at a fixed rate of 50 Hz. To see how we achieve this, take a look at game/game.cpp in void Game::MainLoop() method. In every Refresh methods, we don't use a direct access to the computer timer but our own value that we try to keep as close as possible to the real computer clock. To get an idea of the ratio of processing between all Refresh methods (RefreshClock(), RefreshInput(), RefreshObject() and world.Refresh()) and CallDraw() (which is drawing everything on screen), CallDraw is something like almost 10 times CPU consuming compare to Refresh* (we can call it physical engine). But to be honest, I cannot say that there's no place where we don't call more often randomsync on the client or server side. > Is it somehow accounted for? > > Best regards, > RCL Regards, Yannig > _______________________________________________ > Wormux-dev mailing list > Wormux-dev@gna.org > https://mail.gna.org/listinfo/wormux-dev _______________________________________________ Wormux-dev mailing list Wormux-dev@gna.org https://mail.gna.org/listinfo/wormux-dev