-#define WALK_UNTIL_MUST(point,coord,increm,last,edge) \
- do { \
- WALK_UNTIL(point,coord,increm,last,edge); \
- eassert((point).coord != (last)+(increm)); \
- } while(0)
-
-static void find_structure(void) {
- Rect whole = { {0,0}, {width-1,height-1} };
-
- WALK_UNTIL_MUST(mainr.tl, x,-1, whole.tl.x, '*');
- WALK_UNTIL_MUST(mainr.tl, y,-1, whole.tl.y, '*');
- WALK_UNTIL_MUST(mainr.br, x,+1, whole.br.x, '*');
- WALK_UNTIL_MUST(mainr.br, y,+1, whole.br.y, '*');
-
- require_rectangle(mainr.tl.x-1, mainr.tl.y, mainr.tl.x-1, mainr.br.y, "*");
- require_rectangle(mainr.br.x+1, mainr.tl.y, mainr.br.x+1, mainr.br.y, "*");
- require_rectangle(mainr.tl.x, mainr.tl.y-1, mainr.br.x, mainr.tl.y-1, "*");
- require_rectangle(mainr.tl.x, mainr.br.y+1, mainr.br.x, mainr.br.y+1, "*");
-
-#define CHECK_STRIP_BORDER(tlbr,xy,increm) \
- do { \
- Point csb_p; \
- Rect csb_r; \
- csb_p= mainr.tl; \
- csb_p.xy= mainr.tlbr.xy; \
- if (get_p(csb_p)=='+') { \
- csb_r= mainr; \
- csb_r.tl.xy= csb_p.xy; \
- csb_r.br.xy= csb_p.xy; \
- require_rectangle_r(csb_r, "+"); \
- mainr.tlbr.xy += increm; \
- } \
- } while(0)
-
- debug_rect("mainr",0, mainr);
-
- CHECK_STRIP_BORDER(tl,x,+1);
- CHECK_STRIP_BORDER(tl,y,+1);
- CHECK_STRIP_BORDER(br,x,-1);
- CHECK_STRIP_BORDER(br,y,-1);
-
- debug_rect("mainr",1, mainr);
-
- Point up = START_MAIN;
- WALK_UNTIL_MUST(up, y,-1, mainr.tl.y, '+');
-
- Point down = START_MAIN;
- down.y++;
- WALK_UNTIL_MUST(down, y,+1, mainr.br.y, '+');
-
-#ifdef DEBUG_RECTANGLES
- int xscaleunit, y,x;
- for (y=0, xscaleunit=1; y<4; y++, xscaleunit*=10) {
- fprintf(debug," ");
- for (x=0; x<=width; x++) {
- if (x % xscaleunit) fputc(' ',debug);
- else fprintf(debug,"%d",(x / xscaleunit)%10);
- }
- fputc('\n',debug);