]> git.treefish.org Git - phys/latlib.git/blobdiff - configcache.cpp
...
[phys/latlib.git] / configcache.cpp
index 168de5e14494c122e8a262bd3176c223635a76fe..35e85488d34e1a315301a283ad310e77df8a54b7 100644 (file)
@@ -73,7 +73,7 @@ bool configcache::isValidInFile(const string& infile, infiledesc *filedesc)
 
   filedesc->filename = infile;
   filedesc->doVirtualEquilibration = false;
-  filedesc->readEquilibratedConfigs = 0;
+  filedesc->firstConfig = true;
 
   if( infile.size() < 4 ) return false;
 
@@ -183,7 +183,6 @@ void * configcache::getHeader(const string& headerid) {
 void configcache::readConfig(bool& readnewconfig, int& nequileft, vector<unsigned long> *excludeFileHashes)
 {
   readnewconfig = false;
-  nequileft = NEQUI;
 
   if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return;
 
@@ -196,7 +195,11 @@ void configcache::readConfig(bool& readnewconfig, int& nequileft, vector<unsigne
     {
       vector<infiledesc>::iterator inFileIt = getNextInfile(excludeFileHashes);
 
-      if( (!inFile.is_open()) && inFileIt == inFiles.end() ) return;
+      if( (!inFile.is_open()) && inFileIt == inFiles.end() ) {
+       cout << "RETURNING..." << endl;
+       nequileft = nequileft_internal;
+       return;
+      }
 
       while( (!inFile.is_open()) && inFiles.size() > 0 ) {
        openFileDesc = *inFileIt;
@@ -221,20 +224,27 @@ void configcache::readConfig(bool& readnewconfig, int& nequileft, vector<unsigne
            for (int iskip=0; iskip < (NEQUI-openFileDesc.nequi)/openFileDesc.nskip; iskip++) {
              if( readFullBlock(tmpConfig, configSize) != configSize || ! inFile.is_open() )
                break;
-             else if ( (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip < nequileft ) {
+             else if ( (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip < nequileft_internal ) {
                memcpy(configMem, tmpConfig, configSize);
-               nequileft = (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip;
+               nequileft_internal = NEQUI - openFileDesc.nequi - (iskip+1)*openFileDesc.nskip;
+               cout << "blabla:" << nequileft_internal << endl;
                readnewconfig = true;
              }
            }
+           openFileDesc.firstConfig = false;
          }
 
          if( readFullBlock(tmpConfig, configSize) == configSize && inFile.is_open() )
            {
              memcpy(configMem, tmpConfig, configSize);
              readnewconfig = true;
-             nequileft = NEQUI - openFileDesc.nequi - openFileDesc.readEquilibratedConfigs*openFileDesc.nskip;
-             openFileDesc.readEquilibratedConfigs++;
+             if (openFileDesc.firstConfig) {
+               openFileDesc.firstConfig = false;
+               nequileft_internal = NEQUI - openFileDesc.nequi;
+             }
+             nequileft_internal -= openFileDesc.nskip;
+             cout << "sadasd:" << nequileft_internal << endl;
+             nequileft = nequileft_internal;
              return;
            }
          else {