From: Christian Heller Date: Thu, 20 Nov 2014 21:37:29 +0000 (+0100) Subject: On world (re-)generation, server sends 'NEW_WORLD', client clears log. X-Git-Tag: tce~589 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/template?a=commitdiff_plain;h=25cb881d3f6b7f98d4b52e084c75b6322c57f2bc;p=plomrogue On world (re-)generation, server sends 'NEW_WORLD', client clears log. --- diff --git a/SERVER_COMMANDS b/SERVER_COMMANDS index 6d011c7..5760e54 100644 --- a/SERVER_COMMANDS +++ b/SERVER_COMMANDS @@ -99,7 +99,8 @@ MAKE_WORLD [0 to 4294967296] Set map seed and randomness seed to argument. Remove all things. (Re-)generate map. Add to map things specified in thing types table in quantity defined there by START_NUMBER command, with first thing (of thing ID of 0) of type defined as -player type by PLAYER_TYPE command. Set world turn to 1. Activate world. +player type by PLAYER_TYPE command. Set world turn to 1. Activate world. Answer +with 'NEW_WORLD' message in ./server/out file. MAP_LENGTH [1 to 256] Deactivate world. Remove ./server/worldstate file. Remove all things. Remove diff --git a/src/client/io.c b/src/client/io.c index 233a60c..4500815 100644 --- a/src/client/io.c +++ b/src/client/io.c @@ -80,7 +80,7 @@ static uint8_t read_worldstate(); */ static void test_and_poll_server(); -/* Read queue, act on them (as of right now only: derive log messages). */ +/* Read messages from queue, act on them. */ static uint8_t read_queue(); @@ -237,7 +237,14 @@ static uint8_t read_queue() while (NULL != (msg = get_message_from_queue(&world.queue))) { char * log_prefix = "LOG "; - if (!strncmp(msg, log_prefix, strlen(log_prefix))) + char * new_world = "NEW_WORLD"; + if (!strcmp(msg, new_world)) + { + ret = 1; + free(world.log); + world.log = NULL; + } + else if (!strncmp(msg, log_prefix, strlen(log_prefix))) { ret = 1; char * log_msg = msg + strlen(log_prefix); diff --git a/src/server/init.c b/src/server/init.c index ee9f9c2..f4c191b 100644 --- a/src/server/init.c +++ b/src/server/init.c @@ -31,7 +31,7 @@ #include "things.h" /* Thing, ThingType, free_things(), add_things(), * get_thing_id_action_id_by_name() */ -#include "run.h" /* obey_msg(), io_loop(), record() */ +#include "run.h" /* obey_msg(), io_loop(), record(), send_to_outfile() */ #include "world.h" /* global world */ @@ -226,6 +226,7 @@ extern uint8_t remake_world() world.turn = 1; world.do_update = 1; world.exists = 1; + send_to_outfile("NEW_WORLD\n"); return 0; }