X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fmap_objects.c;h=ed41d93ac62f30ab65c5fd194182782a8d034156;hb=b05b66a27258c581a10e81348088c3486cb8f569;hp=93f46841447aec667f1ddd0322268a0a330c0d6d;hpb=5d8fc2d8efb2cf22d27051df09b63c852541db83;p=plomrogue diff --git a/src/map_objects.c b/src/map_objects.c index 93f4684..ed41d93 100644 --- a/src/map_objects.c +++ b/src/map_objects.c @@ -96,7 +96,6 @@ extern void read_map_objects(struct World * world, FILE * file, char * line, * mo_ptr_ptr = mo; mo_ptr_ptr = &mo->next; } - world->last_map_obj = mo; } @@ -132,15 +131,14 @@ extern void add_map_object(struct World * world, uint8_t type) } } mo->next = NULL; - if (NULL == world->last_map_obj) + struct MapObj ** last_ptr_ptr = &world->map_objs; + struct MapObj * mo_ptr; + while (NULL != * last_ptr_ptr) { - world->map_objs = mo; + mo_ptr = * last_ptr_ptr; + last_ptr_ptr = & mo_ptr->next; } - else - { - world->last_map_obj->next = mo; - } - world->last_map_obj = mo; + * last_ptr_ptr = mo; }