scp-fs2open / scp-fs2open/fs2open.github.com

Review how RNG seeds are generated/used in multiplayer

Open
#3,336 1 comment 0 reactions 0 assignees View on GitHub
enhancement gameplay multi physics question
Dominant language
C++
Stars
487
Forks
184
Avg merge
3d 9h
Merged PRs (30d)
44

Description

In multiplayer, the RNG is seeded in `game_level_init()` in freespace.cpp using `Netgame.security`, in `shipfx_blow_up_model()` in shipfx.cpp using `obj->net_signature`, and potentially by SEXP in `rand_sexp()`.

The `security` value is generated in `multi_sg_init_gamenet()` in multiui.cpp. The range of possible values is 1-32766, presumably because `RAND_MAX` on Windows was and still is 32767.

However, once PR #3332 is merged, then the RNG can generate values as high as `util::Random::MAX_VALUE` which is `0x7fffffff` or 2,147,483,647.

We might want to take advantage of this increased range, to help allow for a wider range of multiplayer experiences.

Similarly, since the RNG is re-seeded in `shipfx_blow_up_model()` using an object's `net_signature`, which has a pretty limited range of possible values, we may want to explore ways to increase the range of possible seeds, for the same reason as above.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.