+ middle_angle = right_angle + ((left_angle - right_angle) / 2);
+ }
+ uint16_t pos_in_map = test_pos->y * world.map.length + test_pos->x;
+ uint8_t all_shaded = shade_hex(left_angle, right_angle_1st, middle_angle,
+ shadows, pos_in_map, fov_map);
+ if (!all_shaded && 'X' == world.map.cells[pos_in_map])
+ {
+ set_shadow(left_angle, right_angle_1st, shadows);
+ if (right_angle_1st != right_angle)
+ {
+ left_angle = CIRCLE;
+ set_shadow(left_angle, right_angle, shadows);
+ }
+ }
+}
+
+
+
+static void update_map_memory(struct Thing * t_eye, uint32_t map_size)
+{
+ if (!t_eye->mem_map)
+ {
+ t_eye->mem_map = try_malloc(map_size, __func__);
+ memset(t_eye->mem_map, ' ', map_size);
+ }
+ uint32_t i;
+ for (i = 0; i < map_size; i++)
+ {
+ if (' ' == t_eye->mem_map[i] && t_eye->fov_map[i] == 'v')
+ {
+ t_eye->mem_map[i] = world.map.cells[i];
+ }
+ }
+ struct ThingInMemory * tm = t_eye->t_mem;
+ struct ThingInMemory * tm_prev = NULL;
+ struct ThingInMemory * tm_next = NULL;
+ for (; tm; tm = tm_next)
+ {
+ tm_next = tm->next;
+ if ('v' == t_eye->fov_map[tm->pos.y * world.map.length + tm->pos.x])
+ {
+ if (tm_prev)
+ {
+ tm_prev->next = tm->next;
+ }
+ else
+ {
+ t_eye->t_mem = tm->next;
+ }
+ free(tm);
+ continue;
+ }
+ tm_prev = tm;
+ }
+ struct Thing * t = world.things;
+ for (; t; t = t->next)
+ {
+ if ( !t->lifepoints
+ && 'v' == t_eye->fov_map[t->pos.y * world.map.length + t->pos.x])
+ {
+ add_thing_to_memory_map(t_eye, t->type, t->pos.y, t->pos.x);
+ }