- size_t cutout_len = strlen(world.queue);
- if (0 < cutout_len)
- {
- cutout_len++;
- message = try_malloc(cutout_len, __func__);
- memcpy(message, world.queue, cutout_len);
- }
- for (;
- cutout_len != world.queue_size && '\0' == world.queue[cutout_len];
- cutout_len++);
- world.queue_size = world.queue_size - cutout_len;
- if (0 == world.queue_size)
- {
- free(world.queue); /* NULL so read_file_into_queue() may free() */
- world.queue = NULL; /* this every time, even when it's */
- } /* un-allocated first. */
- else
+ write_thing(file, o);
+ }
+ write_key_space_uvalue(file, s[S_CMD_T_ID], t->id);
+ 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__);
+ }
+ write_key_space_uvalue(file, s[S_CMD_T_COMMAND], t->command);
+ write_key_space_uvalue(file, s[S_CMD_T_HP], t->lifepoints);
+ write_key_space_uvalue(file, s[S_CMD_T_TYPE], t->type);
+ write_key_space_uvalue(file, s[S_CMD_T_ARGUMENT], t->arg);
+ 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_PROGRESS], t->progress);
+ write_mem_map(file, t->mem_depth_map, s[S_CMD_T_MEMDEPTHMAP]);
+ write_key_space_svalue(file, s[S_CMD_T_SATIATION], t->satiation);
+ write_mem_map(file, t->mem_map, s[S_CMD_T_MEMMAP]);
+}
+
+
+
+static void write_thing_carrying(FILE * file, struct Thing * t)
+{
+ if (t->owns)
+ {
+ write_key_space_uvalue(file, s[S_CMD_T_ID], t->id);
+ struct Thing * o;
+ for (o = t->owns; o; o = o->next)