From: Christian Heller Date: Wed, 2 Oct 2013 09:24:10 +0000 (+0200) Subject: Changed the way the end of the map object list is identified. X-Git-Tag: tce~945 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/decks/calendar?a=commitdiff_plain;h=b05b66a27258c581a10e81348088c3486cb8f569;p=plomrogue Changed the way the end of the map object list is identified. --- diff --git a/src/main.c b/src/main.c index adeddce..68b1ebb 100644 --- a/src/main.c +++ b/src/main.c @@ -135,7 +135,6 @@ int main(int argc, char *argv[]) if (0 == world.turn) { world.map_objs = NULL; - world.last_map_obj = NULL; add_map_objects(&world, 0, 1); add_map_objects(&world, 1, 1 + rrand() % 27); add_map_objects(&world, 2, 1 + rrand() % 9); diff --git a/src/main.h b/src/main.h index cd6e6c0..56d458b 100644 --- a/src/main.h +++ b/src/main.h @@ -37,7 +37,6 @@ struct World uint8_t map_obj_count; /* Counts map objects generated so far. */ struct MapObjDef * map_obj_defs; /* Map object type definitions chain. */ struct MapObj * map_objs; /* Pointer to map objects chain start. */ - struct MapObj * last_map_obj; /* Pointer to map objects chain end. */ }; 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; }