home · contact · privacy
Some code-internal restructuring following the assumption that game map height /
[plomrogue] / src / client / io.c
index 4623b3d89bbe4e6aa1912c24b8acdec649637b34..2b1c165eb0435c78a37737e94f5250d3361820c3 100644 (file)
@@ -18,7 +18,7 @@
                                   * try_fgetc()
                                   */
 #include "control.h" /* try_key() */
-#include "map_window.h" /* map_center() */
+#include "map.h" /* map_center() */
 #include "misc.h" /* reset_windows() */
 #include "windows.h" /* reset_windows_on_winch(), draw_all_wins() */
 #include "world.h" /* world global */
@@ -67,8 +67,8 @@ static FILE * changed_server_out_file(char * path);
  * a hard-coded serialization format. Returns 1 on success and 0 if the out file
  * wasn't read for supposedly not having changed since a last read_world() call.
  *
- * Note that the first successful read_world() triggers map_center(), so that on
- * start the client focuses the map window on the player.
+ * map_center() is triggered by the first successful read_world() or on turn 1,
+ * so the client focuses the map window on the player on client and world start.
  */
 static uint8_t read_world();
 
@@ -110,7 +110,7 @@ static void read_map_cells(FILE * file)
     char * f_name = "read_map_cells()";
     free(world.map.cells);
     world.map.cells = try_malloc(world.map.size.y * world.map.size.x, f_name);
-    uint16_t y, x;
+    uint8_t y, x;
     for (y = 0; y < world.map.size.y; y++)
     {
         for (x = 0; x < world.map.size.x; x++)
@@ -196,12 +196,12 @@ static uint8_t read_world()
     uint32_t linemax = textfile_sizes(file, NULL);
     char * read_buf = try_malloc(linemax + 1, f_name);
     world.turn = read_value_from_line(read_buf, linemax, file);
-    world.score = read_value_from_line(read_buf, linemax, file);
+    world.player_score = read_value_from_line(read_buf, linemax, file);
     world.player_lifepoints = read_value_from_line(read_buf, linemax, file);
     read_inventory(read_buf, linemax, file);
     world.player_pos.y = read_value_from_line(read_buf, linemax, file);
     world.player_pos.x = read_value_from_line(read_buf, linemax, file);
-    if (first_read)
+    if (1 == world.turn || first_read)
     {
         map_center();
         first_read = 0;