Esempio n. 1
0
void gtb_init()
{
  int av;
  
  //already initialized
  if(gtb_ok) gtb_clear();
  
  if(gtb_cachesize == 0 || gtb_dec_scheme < 0 
  || gtb_dec_scheme > 9 || gtb_path[0] == 0)
  { gtb_ok == false;
    return;
  }
  
  gtb_paths = tbpaths_init();
  gtb_paths = tbpaths_add(gtb_paths, &gtb_path[0]);
  tb_init(GTB_VERBOSE, gtb_dec_scheme, gtb_paths);
  tbcache_init(gtb_cachesize, WDL_FRACTION);
  tbstats_reset();
  gtb_ok = (tb_is_initialized() && tbcache_is_on());
  if(!gtb_ok) return;
  
  av = tb_availability();
  if(av & 16) gtb_max_men = 5;
  else if(av & 8) gtb_max_men = 4;
  else if(av & 2) gtb_max_men = 3;
  else
  { gtb_max_men = 0;
    gtb_ok = false;
    gtb_clear();
  }
}
Esempio n. 2
0
bool GTB::load() {
    if (path.size() == 0)return false;
    memset(installedPieces, 0, sizeof(installedPieces));
    if (!FileUtil::fileExists(path)) {
        cout << "file not found " << path << endl;
        return false;
    }
    tbstats_reset();
    paths = tbpaths_done(paths);
    paths = tbpaths_init();
    _assert(paths);
    paths = tbpaths_add(paths, path.c_str());
    restart();
    unsigned av = tb_availability();
    if (0 != (av & 2)) {
        setInstalledPieces(3);
        cout << "3-pc TBs complete\n";
    } else if (0 != (av & 1)) {
        cout << "Some 3-pc TBs available\n";
    } else {
        cout << "No 3-pc TBs available\n";
    }
    if (0 != (av & 8)) {
        setInstalledPieces(4);
        cout << "4-pc TBs complete\n";
    } else if (0 != (av & 4)) {
        cout << "Some 4-pc TBs available\n";
    } else {
        cout << "No 4-pc TBs available\n";
    }
    if (0 != (av & 32)) {
        setInstalledPieces(5);
        cout << "5-pc TBs complete\n";
    } else if (0 != (av & 16)) {
        cout << "Some 5-pc TBs available\n";
    } else {
        cout << "No 5-pc TBs available\n";
    }
    cout << endl;
    if (!getAvailable()) {
        return false;
    }
    setCacheSize(cacheSize);
    tb_init(verbosity, scheme, paths);
    tbcache_init(cacheSize * 1024 * 1024, wdl_fraction);
    tbstats_reset();
    return true;
}
Esempio n. 3
0
int GaviotaTb::initTB(const string &path, const string &scheme,
                      uint64 cache_size) {

    if (NULL == paths) {
        cerr << "error in path initialization for Gaviota TBs" << endl;
        return 0;
    }
    paths = tbpaths_add(paths, path.c_str());
    if (NULL == paths) {
        cerr << "error in path initialization for Gaviota TBs" << endl;
        return 0;
    }
    int intScheme;
    if (scheme == "cp1") 
        intScheme = tb_CP1;
    else if (scheme == "cp2")
        intScheme = tb_CP2;
    else if (scheme == "cp3")
        intScheme = tb_CP3;
    else if (scheme == "cp4")
        intScheme = tb_CP4;
    else {
        cerr << "unrecognized compression scheme for GTBs: " << scheme << endl;
        return 0;
    }
    char *initinfo = tb_init (0, intScheme, paths);
    tbcache_init((size_t)cache_size, WDL_FRACTION);
    tbstats_reset();
    if (initinfo != NULL) {
        cout << initinfo << endl;
    }
    int avail = tb_availability();
    if (avail & (1<<6)) return 6;
    else if (avail & (1<<4)) return 5;
    else if (avail & (1<<2)) return 4;
    else if (avail & 1) return 3;
    else return 0; // error?
}