chiark / gitweb /
swap require_rectangle_r and require_rectangle so we can have FOR_P_RECT
[ypp-sc-tools.web-live.git] / pctb / structure.c
index 2dc98d1c77a1590e0ae8d91e78eed19d4cbf90d0..370892c2785b02fb26c9e2dbfe91f4a4f975c34c 100644 (file)
@@ -92,10 +92,16 @@ const CanonColourInfo canoncolourinfos[]= {
 
 static void mustfail1(const char *file, int line, const char *what) {
   fprintf(stderr,
-         "\n\n"
-         "Unable to figure out contents of YPP client display.\n"
-         " Check that your client is logged in has the correct display.\n"
-         " If that isn't the problem, please report this as a fault.\n\n"
+ "\n\n"
+ "Unable to figure out contents of YPP client display.\n"
+ "Please check the following:\n"
+ "   * YPP client is showing commodity listing screen\n"
+ "   * YPP client has antialiased text turned off (Ye / Options / General)\n"
+ "   * YPP client window is on top (we try to raise it but your window\n"
+ "      manager might have prevented that from succeeding)\n"
+ "   * Your X display is 24bpp (NB some VNC servers use 16bpp by default)\n"
+ "\n"
+ "If all of these are true, please report this as a fault.\n\n"
          "Technical details:"
          " %s:%d: requirement failed:\n"
          " %s\n",
@@ -127,20 +133,23 @@ static void mustfail2(void) {
 #define REQUIRE_RECTANGLE(tlx,tly,brx,bry,ok) \
  require_rectangle(tlx, tly, brx, bry, ok, __LINE__);
 
-static void require_rectangle(int tlx, int tly, int brx, int bry,
-                             const char *ok, int lineno) {
+#define FOR_P_RECT(p,rect)                             \
+  for ((p).x=(rr).tl.x; (p).x<=(rr).br.x; (p).x++)     \
+    for ((p).y=(rr).tl.y; (p).y<=(rr).br.y; (p).y++)
+
+static void require_rectangle_r(Rect rr, const char *ok, int lineno) {
   Point p;
-  for (p.x=tlx; p.x<=brx; p.x++)
-    for (p.y=tly; p.y<=bry; p.y++) {
-      int c= get_p(p);
-      MUST( strchr(ok,c), ({
-            Rect rm={{tlx,tly},{brx,bry}};
-            MI(lineno),MR(rm);MP(p);MS(ok);
-      }));
-    }
+  FOR_P_RECT(p,rr) {
+    int c= get_p(p);
+    MUST( strchr(ok,c), ({
+      MI(lineno),MR(rr);MP(p);MS(ok);
+    }));
+  }
 }
-static void require_rectangle_r(Rect rr, const char *ok, int lineno) {
-  require_rectangle(rr.tl.x,rr.tl.y, rr.br.x,rr.br.y, ok, lineno);
+static void require_rectangle(int tlx, int tly, int brx, int bry,
+                             const char *ok, int lineno) {
+  Rect rr= {{tlx,tly},{brx,bry}};
+  require_rectangle_r(rr, ok, lineno);
 }
 
 static void debug_rect(const char *what, int whati, Rect rr) {
@@ -547,6 +556,8 @@ Rect find_sunshine_widget(void) {
 }
 
 void find_islandname(RgbImage *ri) {
+  find_structure(page_images[0], 0);
+
   Rect sunshiner= find_sunshine_widget();
   char sunshine[MAXIMGIDENT], archisland[MAXIMGIDENT];
 
@@ -628,6 +639,7 @@ void find_islandname(RgbImage *ri) {
     Point p;
     int nspaces=1, might_be_colon=0;
     uint32_t colon_pattern= 0;
+    p.y=-1;
 
     for (p.x=islandnamer.br.x; p.x>islandnamer.tl.x; p.x--) {
       colondebugf("structcolon: x=%4d nsp=%2d mbc=%d cp=%08"PRIx32" ",
@@ -679,8 +691,6 @@ void find_islandname(RgbImage *ri) {
     islandnamer.br.x= p.x;
 
     identify_rgbimage(ri, islandnamer, archisland, "island");
-
-    assert(!"not vessel");
   }
 
   char *delim= strstr(archisland," - ");