+
+/* Replay game from record file up to the turn named in world.replay, then turn
+ * over to manual replay via io_loop().
+ */
+static void replay_game();
+
+
+
+static void replay_game()
+{
+ char * f_name = "replay_game()";
+ exit_err(access(s[PATH_RECORD], F_OK), "No record found to replay.");
+ FILE * file = try_fopen(s[PATH_RECORD], "r", f_name);
+ uint32_t linemax = textfile_width(file);
+ char * line = try_malloc(linemax + 1, f_name);
+ while ( world.turn < world.replay
+ && NULL != try_fgets(line, linemax + 1, file, f_name))
+ {
+ obey_msg(line, 0);
+ }
+ uint8_t end = 0;
+ while (!io_loop())
+ {
+ if (!end)
+ {
+ end = (NULL == try_fgets(line, linemax + 1, file, f_name));
+ if (!end)
+ {
+ obey_msg(line, 0);
+ }
+ }
+ }
+ free(line);
+ try_fclose(file, f_name);
+}
+
+
+