+ world.turn++;
+ thing = world.things;
+ free(whitelist);
+ whitelist = build_whitelist();/* The whitelist excludes things */
+ } /* that appear only during the turn.*/
+ if (thing_in_whitelist(thing->id, whitelist))
+ {
+ if (0 < thing->lifepoints)
+ {
+ if (0 == thing->command)
+ {
+ if (thing == player)
+ {
+ break;
+ }
+ ai(thing);
+ }
+ thing->progress++;
+ struct ThingAction * ta = get_thing_action(thing->command);
+ if (thing->progress == ta->effort)
+ {
+ ta->func(thing);
+ thing->command = 0;
+ thing->progress = 0;
+ }
+ }
+ try_thing_proliferation(thing);
+ }
+ thing = thing->next;
+ }
+ free(whitelist);
+}
+
+
+
+static uint8_t meta_commands(char * msg)
+{
+ if (!strcmp("QUIT", msg))
+ {
+ free(msg);
+ return 2;
+ }
+ if (!strcmp("PING", msg))
+ {
+ free(msg);
+ send_to_outfile("PONG\n");
+ return 1;
+ }
+ if (!strcmp("STACK", msg))
+ {
+ free(msg);
+ send_to_outfile("THINGS_BELOW_PLAYER START\n");
+ struct Thing * player = get_player();
+ struct Thing * t;
+ for (t = world.things; t; t = t->next)
+ {
+ if ( t->pos.y == player->pos.y && t->pos.x == player->pos.x
+ && t != player)
+ {
+ struct ThingType * tt = get_thing_type(t->type);
+ send_to_outfile(tt->name);
+ send_to_outfile("\n");
+ }
+ }
+ send_to_outfile("THINGS_BELOW_PLAYER END\n");
+ return 1;
+ }
+ return 0;
+}
+
+
+
+extern void send_to_outfile(char * answer)
+{
+ try_fwrite(answer, strlen(answer), 1, world.file_out, __func__);
+ fflush(world.file_out);
+}
+
+
+
+extern void record(char * msg, uint8_t force)
+{
+ static FILE * file_tmp = NULL;
+ static time_t save_wait = 0;
+ static char * path_tmp;
+ if (!file_tmp)
+ {
+ path_tmp = build_temp_path(s[S_PATH_RECORD]);
+ file_tmp = try_fopen(path_tmp, "w", __func__);
+ if (!access(s[S_PATH_RECORD], F_OK))
+ {
+ FILE * file_read = try_fopen(s[S_PATH_RECORD], "r", __func__);