home · contact · privacy
Changed the way the end of the map object list is identified.
[plomrogue] / src / map_objects.c
index 93f46841447aec667f1ddd0322268a0a330c0d6d..ed41d93ac62f30ab65c5fd194182782a8d034156 100644 (file)
@@ -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;
 }