X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=src%2Fmap_objects.c;h=7e2472d0da521abe19b873088e7cb96f36571563;hb=9d35a239f47714198b942deca3171334409a27bb;hp=e69028122d694d64ea24d5ffd9724541d34ec645;hpb=fb8ddca6abc66eb7e52a007850689309b4cda938;p=plomrogue diff --git a/src/map_objects.c b/src/map_objects.c index e690281..7e2472d 100644 --- a/src/map_objects.c +++ b/src/map_objects.c @@ -98,27 +98,29 @@ extern void read_map_objects(struct World * world, FILE * file, char * line, -extern struct MapObj ** build_map_objects(struct World * w, - struct MapObj ** mo_ptr_ptr, - uint8_t type, uint8_t n) +extern void add_map_object(struct World * world, uint8_t type) { - char * f_name = "build_map_objects()"; - uint8_t i = 0; - struct MapObjDef * mod = get_map_object_def(w, type); - while (i < n) + char * f_name = "add_map_object"; + struct MapObjDef * mod = get_map_object_def(world, type); + struct MapObj * mo = try_malloc(sizeof(struct MapObj), world, f_name); + mo->id = world->map_obj_count; + world->map_obj_count++; + mo->type = mod->id; + mo->lifepoints = mod->lifepoints; + mo->pos = find_passable_pos(world->map); + mo->next = world->map_objs; + world->map_objs = mo; +} + + + +extern void add_map_objects(struct World * world, uint8_t type, uint8_t n) +{ + uint8_t i; + for (i = 0; i < n; i++) { - 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; + add_map_object(world, type); } - return mo_ptr_ptr; }