- while (! null_bubble(touch)) {
- switch (merge_bubbles(nextbub, touch)) {
- case 2:
- /* touch ate nextbub and survived */
- nextbub = touch;
- break;
- case 1:
- /* nextbub ate touch and survived */
- break;
- case 0:
- /* somebody ate someone else but they exploded */
- nextbub = (Bubble *)NULL;
- break;
- default:
- /* something went wrong */
- fprintf(stderr, "Error occurred in insert_new_bubble()\n");
- exit(1);
- }
- /* Check to see if there are any other bubbles still in the area
- and if we need to do this all over again for them. */
- if (! null_bubble(nextbub))
- touch = get_closest_bubble(nextbub);
- else
- touch = (Bubble *)NULL;
+ if (null_bubble(touch))
+ return;
+
+ while (1) {
+
+ /* Merge all touching bubbles */
+ while (! null_bubble(touch)) {
+ switch (merge_bubbles(nextbub, touch)) {
+ case 2:
+ /* touch ate nextbub and survived */
+ nextbub = touch;
+ break;
+ case 1:
+ /* nextbub ate touch and survived */
+ break;
+ case 0:
+ /* somebody ate someone else but they exploded */
+ nextbub = (Bubble *)NULL;
+ break;
+ default:
+ /* something went wrong */
+ fprintf(stderr, "Error occurred in insert_new_bubble()\n");
+ exit(1);
+ }
+
+ /* Check to see if any bubble survived. */
+ if (null_bubble(nextbub))
+ break;
+
+ /* Check to see if there are any other bubbles still in the area
+ and if we need to do this all over again for them. */
+ touch = get_closest_bubble(nextbub);
+ }
+
+ if (null_bubble(nextbub))
+ break;
+
+ /* Shift bubble down. Break if we run off the screen. */
+ if (drop) {
+ if (drop_bubble( nextbub ) == -1)
+ break;
+ }
+
+ /* Check to see if there are any other bubbles still in the area
+ and if we need to do this all over again for them. */
+ touch = get_closest_bubble(nextbub);
+ if (null_bubble(touch)) {
+ /* We also continue every so often if we're dropping and the bubble is at max size */
+ if (drop) {
+ if (simple) {
+ if ((nextbub->area >= bubble_areas[bubble_max_radius - 1]) && (random() % 2 == 0))
+ continue;
+ }
+#ifdef FANCY_BUBBLES
+ else {
+ if ((nextbub->step >= num_bubble_pixmaps - 1) && (random() % 2 == 0))
+ continue;
+ }
+#endif /* FANCY_BUBBLES */
+ }
+ break;
+ }
+
+ }
+}
+
+
+static void
+leave_trail( Bubble *bb )
+{
+ Bubble *tmp;
+
+ tmp = new_bubble();
+ tmp->x = bb->x;
+ tmp->y = bb->y - ((bb->radius + 10) * drop_dir);
+ tmp->cell_index = pixel_to_mesh(tmp->x, tmp->y);
+ add_to_mesh(tmp);
+ insert_new_bubble(tmp);
+ show_bubble( tmp );
+}
+
+
+static int
+drop_bubble( Bubble *bb )
+{
+ int newmi;
+
+ hide_bubble( bb );
+
+ if (simple)
+ (bb->y) += (bubble_droppages[bb->radius] * drop_dir);
+#ifdef FANCY_BUBBLES
+ else
+ (bb->y) += (step_pixmaps[bb->step]->droppage * drop_dir);
+#endif /* FANCY_BUBBLES */
+ if ((bb->y < 0) || (bb->y > screen_height)) {
+ delete_bubble_in_mesh( bb, DELETE_BUBBLE );
+ return -1;