chiark / gitweb /
routesearch: middle arch is middle in list of arches, not arch of middle isle
[ypp-sc-tools.web-live.git] / yarrg / rscommon.h
index bdcc15759705bb5667d26583bdbd63315536d642..0933e0fecc9565b2368ebb0d3f4b55284aff5f6b 100644 (file)
@@ -163,5 +163,15 @@ static inline int isle2arch(int isle) {
   return arch;
 }
 
+static inline int route2midarch(const int *ports, int nports) {
+  int archs[nports], last_arch=-1, narchs=0, i;
+  for (i=0; i<nports; i++) {
+    int arch= isle2arch(ports[i]);
+    if (arch==last_arch) continue;
+    archs[narchs++]= last_arch= arch;
+  }
+  return archs[narchs/2];
+}
+
 
 #endif /*RSCOMMON_H*/