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 bdcc157..0933e0f 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*/