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);
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. */
};
* mo_ptr_ptr = mo;
mo_ptr_ptr = &mo->next;
}
- world->last_map_obj = mo;
}
}
}
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;
}