+ for (granui=granus-1; granui>=0; granui--) {
+ Bucket *bucket= buckets[granui];
+
+ if (value[A] <= bucket->prs[A].value[A] &&
+ value[P] <= bucket->prs[P].value[P])
+ continue;
+
+ debugf(" SOMEHOW %d BEST\n",granui);
+
+ fildebugf("granu %d f%d:%3d mid%d:%3d ",granui,
+ finarch,finisle,midarch,midisle);
+
+ for (ap=0; ap<AP; ap++) {
+ HighScoreEntry *scores= highscores[granui][ap];
+ int nscores= nhighscores[granui][ap];
+
+ fildebugf("ap=%d %15f", ap, value[ap]);
+ if (value[ap] < bucket->prs[ap].value[ap]) {
+ debugf(" ");
+ } else {
+ int pos;
+ ctr_newbests_granu[granui*AP+ap]++;
+ bucket->prs[ap].length= totaldist;
+ memcpy(bucket->prs[ap].value, value, sizeof(value));
+ memcpy(bucket->prs[ap].ports, ports, sizeof(*ports) * nports);
+ if (nports < MAX_ROUTELEN-1) bucket->prs[ap].ports[nports]= -1;
+ fildebugf("** ");
+ for (pos=0; pos < nscores; pos++)
+ if (scores[pos].bucket == bucket) goto found;
+ /* not found */
+ pos= -1;
+ found:
+ for (;;) {
+ pos++;
+ if (pos >= nscores) break; /* new top */
+ if (scores[pos].value >= value[ap]) break; /* found spot */
+ if (pos>0)
+ scores[pos-1]= scores[pos];
+ }
+ pos--;
+ if (pos>0) {
+ scores[pos].value= value[ap];
+ scores[pos].bucket= bucket;
+ if (granui < granus-1 &&
+ highscores[granui][A][0].bucket &&
+ highscores[granui][P][0].bucket) {
+ /* both absolute and perleague are full at this granularity,
+ * so we don't care about anything more granular */
+ fildebugf("\n STOP-GRANU ");
+ granus= granui+1;
+ }
+ }
+ fildebugf("@%2d/%2d ", pos, nscores);
+ } /* new best */
+ } /* ap */
+ } /* granui */