<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40166 >

On 24/03/2008, Marko Lindqvist  wrote:
>
>  On 24/03/2008, Marko Lindqvist wrote:
>  >
>  >   Current S2_2 svn, trying to start Tutorial, results in server crash.
>  >
>  >  rand.c:87: myrand_debug: Assertion `rand_state.is_init' failed.
>
>   This myrand() -call originates from savegame.c:3983 call to
>  randomize_base64url_string().

 Fix attached. Not that this alone is enough to allow scenario loading.

>   I think we need to make separate rand to be used outside actual game 
> context.

 Leaving that to future tickets.


  - ML

diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c	2008-03-12 21:58:28.000000000 +0200
+++ freeciv/server/savegame.c	2008-03-24 18:50:55.000000000 +0200
@@ -3978,11 +3978,9 @@
                                        "game.scoreturn");
     sz_strlcpy(server.game_identifier,
                secfile_lookup_str_default(file, "", "game.id"));
-    if (0 == strlen(server.game_identifier)
-     || !is_base64url(server.game_identifier)) {
-      randomize_base64url_string(server.game_identifier,
-                                 sizeof(server.game_identifier));
-    }
+    /* We are not checking game_identifier legality just yet.
+     * That's done when we are sure that rand seed has been initialized,
+     * so that we can generate new game_identifier, if needed. */
 
     game.info.fogofwar = secfile_lookup_bool_default(file, FALSE, "game.fogofwar");
     game.fogofwar_old = game.info.fogofwar;
@@ -4229,6 +4227,12 @@
     }
   }
 
+  if (0 == strlen(server.game_identifier)
+      || !is_base64url(server.game_identifier)) {
+    /* This uses myrand(), so random state has to be initialized before this. */
+    randomize_base64url_string(server.game_identifier,
+                               sizeof(server.game_identifier));
+  }
 
   game.info.is_new_game = !secfile_lookup_bool_default(file, TRUE,
 						  "game.save_players");
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to