if (!strcmp("PING", msg))
{
free(msg);
- send_to_outfile("PONG\n");
+ send_to_outfile("PONG\n", 1);
return 1;
}
if (!strcmp("STACK", msg))
{
free(msg);
- send_to_outfile("THINGS_BELOW_PLAYER START\n");
+ send_to_outfile("THINGS_BELOW_PLAYER START\n", 1);
struct Thing * player = get_player();
struct Thing * t;
for (t = world.things; t; t = t->next)
&& t != player)
{
struct ThingType * tt = get_thing_type(t->type);
- send_to_outfile(tt->name);
- send_to_outfile("\n");
+ send_to_outfile(tt->name, 0);
+ send_to_outfile("\n", 1);
}
}
- send_to_outfile("THINGS_BELOW_PLAYER END\n");
+ send_to_outfile("THINGS_BELOW_PLAYER END\n", 1);
return 1;
}
return 0;
-extern void send_to_outfile(char * answer)
+extern void send_to_outfile(char * answer, uint8_t flush)
{
try_fwrite(answer, strlen(answer), 1, world.file_out, __func__);
- fflush(world.file_out);
+ if (flush)
+ {
+ fflush(world.file_out);
+ }
}
-/* Append "answer" to server output file, with instant fflush(). */
-extern void send_to_outfile(char * answer);
+/* Append "answer" to server output file, with instant fflush() if "flush". */
+extern void send_to_outfile(char * answer, uint8_t flush);
/* Record save and record file data. Both are only written if "force" is set, or
* on the first run with unset "force", or if 15 seconds have passed since the
static void update_log(char * text)
{
- send_to_outfile("LOG ");
- send_to_outfile(text);
- send_to_outfile("\n");
+ send_to_outfile("LOG ", 0);
+ send_to_outfile(text, 0);
+ send_to_outfile("\n", 1);
}