Follow-up Comment #1, bug #20217 (project wesnoth):

Random events are driven by random seeds.
The following table is giving the seed for different connection at different
stage of the game (using --log-debug=random):
+============+============+============+============+
| Stage      | Host       | Scenario 1 | Scenario 2 |
|            |            | observer   | observer   |
+============+============+============+============+
| Generate   | 10 digit   |     -      |     -      |
|   map      |   integer  |            |            |
|            | 1712165034 |            |            |
+------------+------------+------------+------------+
| Scenario 1 | 1 digit    |   digit    |     -      |
|   start    |   integer  |   integer  |            |
|            | 1          | 1          |            |
+------------+------------+------------+------------+
| Scenario 2 | 9 digit    | 9 digit    | 1 digit    |
|   start    |   integer  |   integer  |   integer  |
|            | 282104759  | 282104759  | 2          |
+------------+------------+------------+------------+
| Scenario 2 | 1 digit    | 1 digit    | 1 digit    |
| save/reload|   integer  |   integer  |   integer  |
|   start    | 2          | 2          | 2          |
+============+============+============+============+
We see the seed is sometimes a single digit integer and sometimes a 9-10 digit
integer. The table also shows that the length of the seed is different between
the host and an observer joining at scenario 2 as soon as scenario 2 starts.
It finally shows that the save/reload of scenario 2 is changing the seed and
make it the same for host and observer.

The random seed is defined as an integer in the wesnoth engine while it is
stored into WML using a string. This means that a conversion from string to
integer is needed. This is done in two circumstances:
|  - reading save game from WML
|  - parsing server data structured in WML

This is done in two different places using two different conversion rules:
- save (savegame.cpp):
|       load_config_["random_seed"].to_int(42)
- server (multiplayer_ui.cpp):
|       const std::string seed = level["random_seed"];
|       state.rng().seed_random(lexical_cast<int>(seed), calls);

The second casting is turning any string-format integer into a single digit
integer ('4.444444E09' to 4).

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?20217>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to