~ubuntu-branches/ubuntu/quantal/sgt-puzzles/quantal

« back to all changes in this revision

Viewing changes to bridges.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings
  • Date: 2011-03-01 04:16:54 UTC
  • mfrom: (1.2.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20110301041654-949qy9qrroziy7vq
* New upstream version:
  - Add Range and Signpost puzzles
  - Use stock icons and conventional order for dialog buttons
  - Use Cairo for screen rendering
* Update German translation, thanks to Helge Kreutzmann
* Remove or update patches applied or partially applied upstream
* Use Debian source format 3.0 (quilt)

Show diffs side-by-side

added added

removed removed

Lines of Context:
542
542
        assert(is_orth);
543
543
 
544
544
        ifree = is_orth->count - island_countbridges(is_orth);
545
 
        if (ifree > 0)
546
 
            nsurrspc += min(ifree, MAXIMUM(is->state, dx,
547
 
                                           is->adj.points[i].x, is->adj.points[i].y));
 
545
        if (ifree > 0) {
 
546
            /*
 
547
             * ifree is the number of bridges unfilled in the other
 
548
             * island, which is clearly an upper bound on the number
 
549
             * of extra bridges this island may run to it.
 
550
             *
 
551
             * Another upper bound is the number of bridges unfilled
 
552
             * on the specific line between here and there. We must
 
553
             * take the minimum of both.
 
554
             */
 
555
            int bmax = MAXIMUM(is->state, dx,
 
556
                               is->adj.points[i].x, is->adj.points[i].y);
 
557
            int bcurr = GRIDCOUNT(is->state,
 
558
                                  is->adj.points[i].x, is->adj.points[i].y,
 
559
                                  dx ? G_LINEH : G_LINEV);
 
560
            assert(bcurr <= bmax);
 
561
            nsurrspc += min(ifree, bmax - bcurr);
 
562
        }
548
563
    }
549
564
    if (nsurrspc < nspc) {
550
565
        debug(("island at (%d,%d) impossible: surr. islands %d spc, need %d.\n",
2720
2735
    int ink = print_mono_colour(dr, 0);
2721
2736
    int paper = print_mono_colour(dr, 1);
2722
2737
    int x, y, cx, cy, i, nl;
2723
 
    int loff = ts/8;
 
2738
    int loff;
2724
2739
    grid_type grid;
2725
2740
 
2726
2741
    /* Ick: fake up `ds->tilesize' for macro expansion purposes */
2730
2745
    /* I don't think this wants a border. */
2731
2746
 
2732
2747
    /* Bridges */
 
2748
    loff = ts / (8 * sqrt((state->params.maxb - 1)));
2733
2749
    print_line_width(dr, ts / 12);
2734
2750
    for (x = 0; x < state->w; x++) {
2735
2751
        for (y = 0; y < state->h; y++) {
2739
2755
 
2740
2756
            if (grid & G_ISLAND) continue;
2741
2757
            if (grid & G_LINEV) {
2742
 
                if (nl > 1) {
2743
 
                    draw_line(dr, cx+ts/2-loff, cy, cx+ts/2-loff, cy+ts, ink);
2744
 
                    draw_line(dr, cx+ts/2+loff, cy, cx+ts/2+loff, cy+ts, ink);
2745
 
                } else {
2746
 
                    draw_line(dr, cx+ts/2,      cy, cx+ts/2,      cy+ts, ink);
2747
 
                }
 
2758
                for (i = 0; i < nl; i++)
 
2759
                    draw_line(dr, cx+ts/2+(2*i-nl+1)*loff, cy,
 
2760
                              cx+ts/2+(2*i-nl+1)*loff, cy+ts, ink);
2748
2761
            }
2749
2762
            if (grid & G_LINEH) {
2750
 
                if (nl > 1) {
2751
 
                    draw_line(dr, cx, cy+ts/2-loff, cx+ts, cy+ts/2-loff, ink);
2752
 
                    draw_line(dr, cx, cy+ts/2+loff, cx+ts, cy+ts/2+loff, ink);
2753
 
                } else {
2754
 
                    draw_line(dr, cx, cy+ts/2,      cx+ts,      cy+ts/2, ink);
2755
 
                }
 
2763
                for (i = 0; i < nl; i++)
 
2764
                    draw_line(dr, cx, cy+ts/2+(2*i-nl+1)*loff,
 
2765
                              cx+ts, cy+ts/2+(2*i-nl+1)*loff, ink);
2756
2766
            }
2757
2767
        }
2758
2768
    }