Esempio n. 1
0
void Journal::processNextJournalEntry()
{
   if(mCurrentMode != Playback)
      return;

#ifdef TNL_ENABLE_BIG_JOURNALS
   U16 token;
   TNL_JOURNAL_READ( (&token) );
   if(token != 0x1234)
      TNL_DEBUGBREAK();
#endif

   U32 index = mReadStream.readRangedU32(0, JournalEntryRecord::mEntryVector->size());

   JournalEntryRecord *theEntry = (*JournalEntryRecord::mEntryVector)[index];

   // check for errors...
   if(!theEntry)
   {
      TNLAssert(0, "blech!");
   }
   theEntry->mFunctor->read(mReadStream);

#ifdef TNL_ENABLE_BIG_JOURNALS
   TNL_JOURNAL_READ( (&token) );
   if(token != 0x5678)
      TNL_DEBUGBREAK();
#endif

   checkReadPosition();

   mInsideEntrypoint = true;
   theEntry->mFunctor->dispatch(this);
   mInsideEntrypoint = false;
}
Esempio n. 2
0
void Journal::beginBlock(U32 blockId, bool writeBlock)
{
   if(writeBlock)
   {
#ifdef TNL_ENABLE_BIG_JOURNALS
      TNL_JOURNAL_WRITE( (U16(0x1234 ^ blockId)) );
#endif
   }
   else
   {
      mBlockIndex++;
      if(mBreakBlockIndex && mBlockIndex >= mBreakBlockIndex)
         TNL_DEBUGBREAK();

#ifdef TNL_ENABLE_BIG_JOURNALS
      U16 startToken;
      TNL_JOURNAL_READ( (&startToken) );
      if((startToken ^ 0x1234) != blockId)
      {
         logprintf("Expected token %s - got %s", JournalBlockTypeToken::findName(blockId), JournalBlockTypeToken::findName(startToken ^ 0x1234));
         TNL_DEBUGBREAK();
      }
#endif
   }
}
Esempio n. 3
0
void Journal::checkReadPosition()
{
   if(!mReadStream.isValid() || mReadStream.getBitPosition() > mReadBreakBitPos)    // Was >=, but that caused crashing on very last command of the file.  
                                                                                    // Changing to > fixes the problem, or at least the symptom.
   {
      if(!mReadStream.isValid())
         logprintf(LogConsumer::LogFatalError, "checkReadPosition failed: Invalid stream read");
      else
         logprintf(LogConsumer::LogFatalError, "checkReadPosition failed: Read past end of journal");

      TNL_DEBUGBREAK();
   }
}
Esempio n. 4
0
void Journal::endBlock(U32 blockId, bool writeBlock)
{
   if(writeBlock)
   {
#ifdef TNL_ENABLE_BIG_JOURNALS
      TNL_JOURNAL_WRITE( (U16(0x5678 ^ blockId)) );
#endif
      syncWriteStream();
   }
   else
   {
#ifdef TNL_ENABLE_BIG_JOURNALS
      U16 endToken;
      TNL_JOURNAL_READ( (&endToken) );
      if((endToken ^ 0x5678) != blockId)
      {
         logprintf("Expected token %s - got %s", JournalBlockTypeToken::findName(blockId), JournalBlockTypeToken::findName(endToken ^ 0x5678));
         TNL_DEBUGBREAK();
      }
#endif
      checkReadPosition();
   }
}
Esempio n. 5
0
void Journal::checkReadPosition()
{
   if(!mReadStream.isValid() || mReadStream.getBitPosition() >= mReadBreakBitPos)
      TNL_DEBUGBREAK();
}