Multi-player spaceship bridge simulator game. Captain your starship through adventures with your friends. See https://smcameron.github.io/space-nerds-in-space
GNU General Public License v2.0
732
stars
75
forks
source link
Use of pseudo random numbers in clients can lead to discrepancies between clients #32
There are lots of places in snis_client.c where we use pseudo random numbers to generate object properties. For instance, the spin on asteroids, choosing of asteroid models, the trajectories of sparks, the configuration of nebulas, etc. If the clients do not happen to use the same seed and same random number algorithm, or if multiple threads in the client use the single random number generated (glibc's rand(), at the bottom of it all), then the different clients can display different things. For example, the same asteroid might use one model on one client, and another on a different client, and the asteroid might spin differently, the nebulas might appear different from one client to the next, etc. Actually, it so happens that the nebulas are generated early enough that it seems the clients do make the same nebulas (have not tried on 32 and 64 bit clients to see if those are the same), but relying on this behavior seems wrong.
There are lots of places in snis_client.c where we use pseudo random numbers to generate object properties. For instance, the spin on asteroids, choosing of asteroid models, the trajectories of sparks, the configuration of nebulas, etc. If the clients do not happen to use the same seed and same random number algorithm, or if multiple threads in the client use the single random number generated (glibc's rand(), at the bottom of it all), then the different clients can display different things. For example, the same asteroid might use one model on one client, and another on a different client, and the asteroid might spin differently, the nebulas might appear different from one client to the next, etc. Actually, it so happens that the nebulas are generated early enough that it seems the clients do make the same nebulas (have not tried on 32 and 64 bit clients to see if those are the same), but relying on this behavior seems wrong.