- free(mem_map_copy);
- struct ThingInMemory * tm = t->t_mem;
- for (; tm; tm = tm->next)
- {
- write_key_space(file, s[S_CMD_T_MEMTHING]);
- write_value(file, tm->type);
- try_fputc(' ', file, __func__);
- write_value(file, tm->pos.y);
- try_fputc(' ', file, __func__);
- write_value(file, tm->pos.x);
- try_fputc('\n', file, __func__);
- }
+ free(map_copy);
+ }
+}
+
+
+
+static void write_thing(FILE * file, struct Thing * t)
+{
+ struct Thing * o;
+ for (o = t->owns; o; o = o->next)
+ {
+ write_thing(file, o);
+ }
+ write_key_space_uvalue(file, s[S_CMD_T_ID], t->id);
+ write_key_space_uvalue(file, s[S_CMD_T_TYPE], t->type);
+ write_key_space_uvalue(file, s[S_CMD_T_POSY], t->pos.y);
+ write_key_space_uvalue(file, s[S_CMD_T_POSX], t->pos.x);
+ write_key_space_uvalue(file, s[S_CMD_T_COMMAND], t->command);
+ write_key_space_uvalue(file, s[S_CMD_T_ARGUMENT], t->arg);
+ write_key_space_uvalue(file, s[S_CMD_T_PROGRESS], t->progress);
+ write_key_space_uvalue(file, s[S_CMD_T_HP], t->lifepoints);
+ write_key_space_svalue(file, s[S_CMD_T_SATIATION], t->satiation);
+ for (o = t->owns; o; o = o->next)
+ {
+ write_key_space_uvalue(file, s[S_CMD_T_CARRIES], o->id);
+ }
+ write_mem_map(file, t->mem_depth_map, s[S_CMD_T_MEMDEPTHMAP]);
+ write_mem_map(file, t->mem_map, s[S_CMD_T_MEMMAP]);
+ struct ThingInMemory * tm = t->t_mem;
+ for (; tm; tm = tm->next)
+ {
+ write_key_space(file, s[S_CMD_T_MEMTHING]);
+ write_uvalue(file, tm->type);
+ try_fputc(' ', file, __func__);
+ write_uvalue(file, tm->pos.y);
+ try_fputc(' ', file, __func__);
+ write_uvalue(file, tm->pos.x);
+ try_fputc('\n', file, __func__);