X-Git-Url: https://plomlompom.com/repos/index.html?a=blobdiff_plain;f=src%2Fclient%2Fio.c;h=c2a3b4b23b453fd1acdaa7cd079ddb364dca3d10;hb=d31e6fe45b213eb5033cac5abdece4c2db59d284;hp=095577d32e1d84fa0d68a89eb31d41a6ac5a76e1;hpb=024b404c0db59dc6651b1c8f3d379c2797654fdf;p=plomrogue
diff --git a/src/client/io.c b/src/client/io.c
index 095577d..c2a3b4b 100644
--- a/src/client/io.c
+++ b/src/client/io.c
@@ -5,6 +5,7 @@
#include /* open() */
#include /* PIPE_BUF */
#include /* halfdelay(), getch() */
+#include /* NULL */
#include /* uint8_t, uint16_t, uint32_t */
#include /* FILE, sprintf(), fseek() */
#include /* strcmp(), strlen(), memcpy() */
@@ -66,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();
@@ -78,7 +79,7 @@ static void read_inventory(char * read_buf, uint32_t linemax, FILE * file)
char * f_name = "read_inventory()";
char * delimiter = "%\n";
free(world.player_inventory);
- world.player_inventory = NULL;
+ world.player_inventory = NULL; /* Avoids illegal strlen() below. */
while (1)
{
try_fgets(read_buf, linemax + 1, file, f_name);
@@ -200,7 +201,7 @@ static uint8_t read_world()
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;