+ cat = gethostcachenumber(SLIST_FIELD_CATEGORY, middle);
+ if(cat > x) { last = middle - 1; }
+ else if(cat == x)
+ {
+ if(middle == 0 || (gethostcachenumber(SLIST_FIELD_CATEGORY, middle - 1) != x)) // check if middle is the first of its category
+ {
+ //print(sprintf("hit: x='%d', dc='%d', first='%d', middle='%d', last='%d', cat='%d'.\n", x, category_draw_count, first, middle, last, cat));
+ category_name[category_draw_count] = cat;
+ category_item[category_draw_count] = middle;
+ ++category_draw_count;
+ ++me.nItems;
+ newfirst = middle + 1; // already scanned through these, skip 'em
+ break;
+ }
+ else { last = middle - 1; } // nope, try again
+ }
+ else { first = middle + 1; }
+ middle = floor((first + last) / 2);