+static void write_map(struct Thing * player, FILE * file);
+
+
+
+static void write_key_value(FILE * file, char * key, uint32_t value)
+{
+ char * f_name = "write_key_value()";
+ try_fwrite(key, strlen(key), 1, file, f_name);
+ try_fputc(' ', file, f_name);
+ char * line = try_malloc(11, f_name);
+ exit_trouble(-1 == sprintf(line, "%u", value), f_name, s[S_FCN_SPRINTF]);
+ try_fwrite(line, strlen(line), 1, file, f_name);
+ free(line);
+ try_fputc('\n', file, f_name);
+}
+
+
+
+static void write_thing(FILE * file, struct Thing * t)
+{
+ char * f_name = "write_thing()";
+ struct Thing * o;
+ for (o = t->owns; o; o = o->next)
+ {
+ write_thing(file, o);
+ }
+ write_key_value(file, s[S_CMD_THING], t->id);
+ write_key_value(file, s[S_CMD_TYPE], t->type);
+ write_key_value(file, s[S_CMD_POS_Y], t->pos.y);
+ write_key_value(file, s[S_CMD_POS_X], t->pos.x);
+ write_key_value(file, s[S_CMD_COMMAND], t->command);
+ write_key_value(file, s[S_CMD_ARGUMENT], t->arg);
+ write_key_value(file, s[S_CMD_PROGRESS], t->progress);
+ write_key_value(file, s[S_CMD_LIFEPOINTS], t->lifepoints);
+ for (o = t->owns; o; o = o->next)
+ {
+ write_key_value(file, s[S_CMD_CARRIES], o->id);
+ }
+ try_fputc('\n', file, f_name);
+}