- struct MapObj * mo = try_malloc(sizeof(struct MapObj), w, f_name);
- mo->id = w->map_obj_count;
- w->map_obj_count++;
- mo->type = mod->id;
- mo->next = NULL;
- mo->lifepoints = mod->lifepoints;
- mo->pos = find_passable_pos(w->map);
- i++;
- * mo_ptr_ptr = mo;
- mo_ptr_ptr = &mo->next;
+ struct yx_uint16 pos = find_passable_pos(world->map);
+ struct MapObj * mo_ptr;
+ uint8_t clear = 1;
+ for (mo_ptr = world->map_objs;
+ mo_ptr != NULL;
+ mo_ptr = mo_ptr->next)
+ {
+ if (yx_uint16_cmp(&pos, &mo_ptr->pos) && 0 != mo_ptr->lifepoints)
+ {
+ clear = 0;
+ break;
+ }
+ }
+ if (1 == clear)
+ {
+ mo->pos = pos;
+ break;
+ }
+ }
+ mo->next = NULL;
+ if (NULL == world->last_map_obj)
+ {
+ world->map_objs = mo;
+ }
+ else
+ {
+ world->last_map_obj->next = mo;
+ }
+ world->last_map_obj = mo;
+}
+
+
+
+extern void add_map_objects(struct World * world, uint8_t type, uint8_t n)
+{
+ uint8_t i;
+ for (i = 0; i < n; i++)
+ {
+ add_map_object(world, type);