// Allocate a continous block of memory of the specified size. void *VarlenPool::Allocate(std::size_t size) { void *retval = nullptr; // Protect using pool lock // TODO: Can make locking more fine-grained { std::lock_guard<std::mutex> pool_lock(pool_mutex); // See if there is space in the current chunk Chunk *current_chunk = &chunks[current_chunk_index]; if (size > current_chunk->size - current_chunk->offset) { // Not enough space. Check if it is greater than our allocation size. if (size > allocation_size) { // Allocate an oversize chunk that will not be reused. auto &storage_manager = storage::StorageManager::GetInstance(); char *storage = reinterpret_cast<char *>( storage_manager.Allocate(backend_type, size)); oversize_chunks.push_back(Chunk(nexthigher(size), storage)); Chunk &newChunk = oversize_chunks.back(); newChunk.offset = size; return newChunk.chunk_data; } // Check if there is an already allocated chunk we can use. current_chunk_index++; if (current_chunk_index < chunks.size()) { current_chunk = &chunks[current_chunk_index]; current_chunk->offset = size; return current_chunk->chunk_data; } else { // Need to allocate a new chunk auto &storage_manager = storage::StorageManager::GetInstance(); char *storage = reinterpret_cast<char *>( storage_manager.Allocate(backend_type, allocation_size)); chunks.push_back(Chunk(allocation_size, storage)); Chunk &new_chunk = chunks.back(); new_chunk.offset = size; return new_chunk.chunk_data; } } // Get the offset into the current chunk. Then increment the // offset counter by the amount being allocated. retval = current_chunk->chunk_data + current_chunk->offset; current_chunk->offset += size; // Ensure 8 byte alignment of future allocations current_chunk->offset += (8 - (current_chunk->offset % 8)); if (current_chunk->offset > current_chunk->size) { current_chunk->offset = current_chunk->size; } } return retval; }
//--------------------------------------------------------------------- StreamSerialiser::Chunk* StreamSerialiser::readChunkImpl() { Chunk *chunk = OGRE_NEW Chunk(); chunk->offset = static_cast<uint32>(mStream->tell()); read(&chunk->id); read(&chunk->version); read(&chunk->length); uint32 checksum; read(&checksum); if (checksum != calculateChecksum(chunk)) { // no good, this is an invalid chunk uint32 off = chunk->offset; OGRE_DELETE chunk; OGRE_EXCEPT(Exception::ERR_INVALID_STATE, "Corrupt chunk detected in stream " + mStream->getName() + " at byte " + StringConverter::toString(off), "StreamSerialiser::readChunkImpl"); } else { return chunk; } }
void VarlenPool::Init() { auto &storage_manager = storage::StorageManager::GetInstance(); char *storage = reinterpret_cast<char *>( storage_manager.Allocate(backend_type, allocation_size)); chunks.push_back(Chunk(allocation_size, storage)); }
HRESULT CWavRiffParser::ReadFormatBlock() { assert(Chunk().FourCC() == ckid_WAVE_FMT); assert(m_pWaveFormat == NULL); HRESULT hr = S_OK; // Some .wav files do not include the cbSize field of the WAVEFORMATEX // structure. For uncompressed PCM audio, field is always zero. const DWORD cbMinFormatSize = sizeof(WAVEFORMATEX) - sizeof(WORD); DWORD cbFormatSize = 0; // Size of the actual format block in the file. // Validate the size if (Chunk().DataSize() < cbMinFormatSize) { return MF_E_INVALID_FILE_FORMAT; } // Allocate a buffer for the WAVEFORMAT structure. cbFormatSize = Chunk().DataSize(); // We store a WAVEFORMATEX structure, so our format block must be at // least sizeof(WAVEFORMATEX) even if the format block in the file // is smaller. See note above about cbMinFormatSize. m_cbWaveFormat = max(cbFormatSize, sizeof(WAVEFORMATEX)); m_pWaveFormat = (WAVEFORMATEX*)CoTaskMemAlloc(m_cbWaveFormat); if (m_pWaveFormat == NULL) { return E_OUTOFMEMORY; } // Zero our structure, in case cbFormatSize < m_cbWaveFormat. ZeroMemory(m_pWaveFormat, m_cbWaveFormat); // Now read cbFormatSize bytes from the file. hr = ReadDataFromChunk((BYTE*)m_pWaveFormat, cbFormatSize); if (FAILED(hr)) { CoTaskMemFree(m_pWaveFormat); m_pWaveFormat = NULL; m_cbWaveFormat = 0; } return hr; }
void StreamBuffer::write(const void* vdata, UInt32 n) { assert(vdata != NULL); // ignore if no data, otherwise update size if (n == 0) { return; } m_size += n; // cast data to bytes const UInt8* data = reinterpret_cast<const UInt8*>(vdata); // point to last chunk if it has space, otherwise append an empty chunk ChunkList::iterator scan = m_chunks.end(); if (scan != m_chunks.begin()) { --scan; if (scan->size() >= kChunkSize) { ++scan; } } if (scan == m_chunks.end()) { scan = m_chunks.insert(scan, Chunk()); } // append data in chunks while (n > 0) { // choose number of bytes for next chunk assert(scan->size() <= kChunkSize); UInt32 count = kChunkSize - (UInt32)scan->size(); if (count > n) count = n; // transfer data scan->insert(scan->end(), data, data + count); n -= count; data += count; // append another empty chunk if we're not done yet if (n > 0) { ++scan; scan = m_chunks.insert(scan, Chunk()); } } }
HRESULT CWavRiffParser::ParseWAVEHeader() { HRESULT hr = S_OK; BOOL bFoundData = FALSE; // Iterate through the RIFF chunks. Ignore chunks we don't recognize. while (SUCCEEDED(hr)) { if (Chunk().FourCC() == ckid_WAVE_FMT) { // Read the WAVEFORMATEX structure allegedly contained in this chunk. // This method does NOT validate the contents of the structure. hr = ReadFormatBlock(); } else if (Chunk().FourCC() == ckid_WAVE_DATA) { // Found the start of the audio data. The format chunk should precede the // data chunk. If we did not find the formt chunk yet, that is a failure // case (see below) bFoundData = TRUE; break; } if (SUCCEEDED(hr)) { hr = MoveToNextChunk(); } } // To be valid, the file must have a format chunk and a data chunk. // Fail if either of these conditions is not met. if (SUCCEEDED(hr)) { if (m_pWaveFormat == NULL || !bFoundData) { hr = MF_E_INVALID_FILE_FORMAT; } } if (SUCCEEDED(hr)) { m_rtDuration = AudioDurationFromBufferSize(m_pWaveFormat, Chunk().DataSize()); } return hr; }
void Patch::patchAddr( int32_t addr, const Chunk& expected, void* func, uint8_t op) { int32_t addrFunc = reinterpret_cast<int32_t>(func); int32_t addrCallNew = addrFunc - addr - 5; patch(addr, expected, Chunk() << op << addrCallNew); }
inline void LineDrawer::addChunk( int first_col, int last_col, QColor fore, QColor back ) { if ( first_col < 0 ) first_col = 0; int length = last_col - first_col + 1; if ( length > 0 ) { list << Chunk ( first_col, length, fore, back ); } }
Chunk GridFile::getChunk( int n ){ _exists(); BSONObjBuilder b; b.appendAs( _obj["_id"] , "files_id" ); b.append( "n" , n ); BSONObj o = _grid->_client.findOne( _grid->_chunksNS.c_str() , b.obj() ); uassert( "chunk is empty!" , ! o.isEmpty() ); return Chunk(o); }
McnkCataTextures::McnkCataTextures(std::ifstream & adtFile, int offsetInFile) : Mcnk(adtFile, offsetInFile, 128) { const int absoluteMcnkEnd = offsetInFile + chunkLettersAndSize + givenSize; offsetInFile = chunkLettersAndSize + offsetInFile; int chunkName (Utilities::getIntFromFile(adtFile, offsetInFile)); while (offsetInFile < absoluteMcnkEnd) { switch (chunkName) { case 'MCLY' : mcly = Chunk(adtFile, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mcly.getGivenSize(); break; case 'MCSH' : mcsh = Chunk(adtFile, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mcsh.getGivenSize(); break; case 'MCAL' : mcal = Chunk(adtFile, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mcal.getGivenSize(); break; case 'MCMT' : mcmt = Chunk(adtFile, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mcmt.getGivenSize(); break; default : texturesMcnkUnknown.push_back(Chunk(adtFile, offsetInFile)); offsetInFile = offsetInFile + chunkLettersAndSize + texturesMcnkUnknown.back().getGivenSize(); } chunkName = Utilities::getIntFromFile(adtFile, offsetInFile); } }
static sample_t diff_resampled(const SRCParams ¶ms, sample_t *buf1, sample_t *buf2, size_t size) { ///////////////////////////////////////////////////////////////////////////// // After resample only q*nyquist of the bandwidth is preserved. Therefore, // to compare output of the resampler with the original signal we must feed // the resampler with the bandlimited signal. Bandlimiting filter has a // transition band and we must guarantee: // passband + transition_band <= q*nyquist. // // It looks reasonable to make the transition band of the bandlimiting filter // to be equal to the transition band of the resampler. In this case we have: // passband + (1-q)*nyquist <= q*nyquist // passband <= (2q - 1)*nyquist // // In normalized form nyquist = 0.5, so we have following parameters of the // bandlimiting filter: passband = q-0.5, transition band = 0.5*(1-q) ParamFIR low_pass(ParamFIR::low_pass, params.q-0.5, 0, 0.5*(1-params.q), params.a + 10, true); const FIRInstance *fir = low_pass.make(params.fs); BOOST_REQUIRE(fir != 0); int trans_len = fir->length * 2; delete fir; Speakers spk(FORMAT_LINEAR, MODE_MONO, params.fs); samples_t s1, s2; s1.zero(); s1[0] = buf1; s2.zero(); s2[0] = buf2; ChunkSource src1(spk, Chunk(s1, size)); ChunkSource src2(spk, Chunk(s2, size)); Convolver conv1(&low_pass); Convolver conv2(&low_pass); SliceFilter slice1(trans_len, size - trans_len); SliceFilter slice2(trans_len, size - trans_len); FilterChain chain1(&conv1, &slice1); FilterChain chain2(&conv2, &slice2); return calc_diff(&src1, &chain1, &src2, &chain2); }
void cChunkSender::Execute(void) { while (!m_ShouldTerminate) { cCSLock Lock(m_CS); while (m_ChunksReady.empty() && m_SendChunks.empty()) { int RemoveCount = m_RemoveCount; m_RemoveCount = 0; cCSUnlock Unlock(Lock); for (int i = 0; i < RemoveCount; i++) { m_evtRemoved.Set(); // Notify that the removed clients are safe to be deleted } m_evtQueue.Wait(); if (m_ShouldTerminate) { return; } } // while (empty) if (!m_ChunksReady.empty()) { // Take one from the queue: cChunkCoords Coords(m_ChunksReady.front()); m_ChunksReady.pop_front(); Lock.Unlock(); SendChunk(Coords.m_ChunkX, Coords.m_ChunkY, Coords.m_ChunkZ, NULL); } else { // Take one from the queue: sSendChunk Chunk(m_SendChunks.front()); m_SendChunks.pop_front(); Lock.Unlock(); SendChunk(Chunk.m_ChunkX, Chunk.m_ChunkY, Chunk.m_ChunkZ, Chunk.m_Client); } Lock.Lock(); int RemoveCount = m_RemoveCount; m_RemoveCount = 0; Lock.Unlock(); for (int i = 0; i < RemoveCount; i++) { m_evtRemoved.Set(); // Notify that the removed clients are safe to be deleted } } // while (!mShouldTerminate) }
Chunk& ChunkContainer::getChunk( const ChunkPosition& position ) { auto it = find_if( begin( m_chunks ), end( m_chunks ), [&]( const Chunk& chunk ) { return chunk.getPosition() == position; } ); if( it != end( m_chunks ) ) return *it; else { m_chunks.push_back( Chunk( position ) ); return m_chunks.back(); } }
void Http::TCommonProtocol::WriteContent(TStreamBuffer& Buffer) { if ( mChunkedContent ) { // keep pushing data until eof auto& Content = *mChunkedContent; while ( true ) { // done! if ( Content.HasEndOfStream() && Content.GetBufferedSize() == 0 ) break; try { Http::TChunkedProtocol Chunk( *mChunkedContent ); Chunk.Encode( Buffer ); } catch(std::exception& e) { std::stringstream Error; Error << "Exception whilst chunking HTTP content; " << e.what(); std::Debug << Error.str() << std::endl; static bool PushExceptionData = true; if ( PushExceptionData ) Buffer.Push( Error.str() ); break; } } } else if ( mWriteContent ) { // this could block for infinite streaming, but should be writing to buffer so data still gets out! woooo! mWriteContent( Buffer ); } else { Buffer.Push( GetArrayBridge(mContent) ); } /* // note: this is DATA because we MUST NOT have a trailing terminator. Fine for HTTP, not for websocket/binary data! Soy::StringToArray( Http.str(), GetArrayBridge(RequestData) ); if ( !Soy::Assert( RequestData.GetBack() != '\0', "Unwanted terminator in HTTP response" ) ) RequestData.PopBack(); */ }
//--------------------------------------------------------------------- void StreamSerialiser::writeChunkImpl(uint32 id, uint16 version) { Chunk* c = OGRE_NEW Chunk(); c->id = id; c->version = version; c->offset = static_cast<uint32>(mStream->tell()); c->length = 0; mChunkStack.push_back(c); write(&c->id); write(&c->version); write(&c->length); // write length again, this is just a placeholder for the checksum (to come later) write(&c->length); }
Chunk::Chunk(FILE* stream, uint16 count = 0) { Chunk(); this->stream = stream; fseek(stream, count * Chunk::SIZE + Header::SIZE, SEEK_SET);// pass to the chunk start fseek(stream, Chunk::MAGIC_LENGTH, SEEK_CUR); // TODO: check whether chunk signature is correct fread(&NumLogRecFirst, sizeof int64, 1, stream); fread(&NumLogRecLast, sizeof int64, 1, stream); fread(&NumFileRecFirst, sizeof int64, 1, stream); fread(&NumFileRecLast, sizeof int64, 1, stream); fseek(stream, sizeof uint32, SEEK_CUR); // pass OfsTables fread(&OfsRecLast, sizeof uint32, 1, stream); fread(&OfsRecNext, sizeof uint32, 1, stream); fread(&DataCRC, sizeof uint32, 1, stream); fseek(stream, (sizeof (char)) * UnknownBlockSize, SEEK_CUR);// pass unknown block fread(&HeaderCRC, sizeof uint32, 1, stream); fread(&StringTable, sizeof uint32, StringTableSize, stream); fread(&TemplateTable, sizeof uint32, TemplateTableSize, stream); }
Maybe<SourceBuffer::Chunk> SourceBuffer::CreateChunk(size_t aCapacity, bool aRoundUp /* = true */) { if (MOZ_UNLIKELY(aCapacity == 0)) { MOZ_ASSERT_UNREACHABLE("Appending a chunk of zero size?"); return Nothing(); } // Round up if requested. size_t finalCapacity = aRoundUp ? RoundedUpCapacity(aCapacity) : aCapacity; // Use the size of the SurfaceCache as an additional heuristic to avoid // allocating huge buffers. Generally images do not get smaller when decoded, // so if we could store the source data in the SurfaceCache, we assume that // there's no way we'll be able to store the decoded version. if (MOZ_UNLIKELY(!SurfaceCache::CanHold(finalCapacity))) { return Nothing(); } return Some(Chunk(finalCapacity)); }
std::vector<Chunk> HTMLFilter::filterMarkup(const std::string & content) { std::vector<Chunk> Chunks; std::vector<std::string> lines = split(content, '\n'); for (int i = 0; i < lines.size(); i++) { bool inMarkup = false; int numCharsMarkup = 0; int numCharsText = 0; std::string text = ""; for (char c : lines[i]) { switch (c) { case '<': inMarkup = true; break; case '>': inMarkup = false; break; default: if (inMarkup) { numCharsMarkup++; } else { text.push_back(c); } break; } } numCharsText = text.size(); float density = ((float)numCharsText + 1) / ((float)numCharsMarkup + (float)numCharsText + 1); Chunks.push_back(Chunk(text, density)); } std::vector<Chunk> usefulChunks(Chunks.size()); auto it = std::copy_if(Chunks.begin(), Chunks.end(), usefulChunks.begin(), [](Chunk c) {return (c.getTextDensity() > 0.5); }); usefulChunks.resize(std::distance(usefulChunks.begin(), it)); return usefulChunks; }
std::list<Chunk> Chunk::splice ( dimensions atDim )const { std::list<Chunk> ret; //@todo should be locking typedef std::vector<ValueArrayReference> ValueArrayList; const util::FixedVector<size_t, dims> wholesize = getSizeAsVector(); util::FixedVector<size_t, dims> spliceSize; spliceSize.fill( 1 ); //init size of one chunk-splice to 1x1x1x1 //copy the relevant dimensional sizes from wholesize (in case of sliceDim we copy only the first two elements of wholesize - making slices) spliceSize.copyFrom( &wholesize[0], &wholesize[atDim] ); //get the spliced ValueArray's (the volume of the requested dims is the split-size - in case of sliceDim it is rows*columns) const ValueArrayList pointers = this->getValueArrayBase().splice( spliceSize.product() ); const util::PropertyMap::KeyList lists = this->findLists(); size_t list_idx = 0; //create new Chunks from this ValueArray's BOOST_FOREACH( ValueArrayList::const_reference ref, pointers ) { ret.push_back( Chunk( ref, spliceSize[0], spliceSize[1], spliceSize[2], spliceSize[3] ) ); //@todo make sure this is only one copy-operation static_cast<util::PropertyMap &>( ret.back() ) = static_cast<const util::PropertyMap &>( *this ); // copy all props into the splices BOOST_FOREACH( const util::PropertyMap::KeyType & key, lists ) { // override list-entries in the splices with their respective entries ret.back().propertyValue( key ) = this->propertyValueAt( key, list_idx ); }
void motor::World::load(unsigned int sizeX,unsigned int sizeY, unsigned int sizeZ, unsigned int chunkSizeX, unsigned int chunkSizeY, unsigned int chunkSizeZ) { worldDimX = sizeX; worldDimY = sizeY; worldDimZ = sizeZ; this->chunkSizeX = chunkSizeX; this->chunkSizeY = chunkSizeY; this->chunkSizeZ = chunkSizeZ; chunks = new Chunk**[sizeX]; for(unsigned int i = 0; i < sizeX; i++) { chunks[i] = new Chunk*[sizeY]; for(unsigned int j = 0; j < sizeY; j++) { chunks[i][j] = new Chunk[sizeZ]; for(unsigned int k = 0; k < sizeZ; k++) { chunks[i][j][k] = Chunk(chunkSizeX, chunkSizeY, chunkSizeZ); chunks[i][j][k].setWorldRef(this); } } } }
Chunk ChunkIterator::operator * () const throw () { return Chunk (_doc.get (), *the_chunk); }
PRUint32 mLength; const char* mData; }; struct Test { Test(Chunk* c, const char* r) : mChunks(c), mResult(r) {} Chunk* mChunks; const char* mResult; }; static Chunk kTest1Chunks[] = { Chunk(9, "Hello sir"), Chunk(0, nsnull) }; static Chunk kTest2Chunks[] = { Chunk(3, "Hel"), Chunk(3, "lo "), Chunk(3, "sir"), Chunk(0, nsnull) }; static Chunk kTest3Chunks[] = { Chunk(1, "I"), Chunk(0, nsnull)
Chunk& ChunkManager::getChunk(Coords coords) { return Chunk(coords, _gridContainer->getBaseNode()); }
Tool::AuxiliaryFile::Chunk Tool::AuxiliaryFile::Chunk:: Data(std::vector<uint8_t> const &data) { return Chunk(Type::Data, data, ext::nullopt); }
RpcParameter::operator Chunk() const { return Chunk(data_.buf_, data_.size_); }
// Protected methods void Map::generateChunk(Vector3 pos) { _chunks[pos] = Chunk(pos); _chunks[pos] = extract<Chunk>(_generator(_chunks[pos], _seed)); }
Tool::AuxiliaryFile::Chunk Tool::AuxiliaryFile::Chunk:: File(std::string const &file) { return Chunk(Type::File, ext::nullopt, file); }
//--------------------------------------------------------------------------// //--------------------------------------------------------------------------// void MemPool::init(size_t size){ m_data=new byte[m_size=m_available=size]; m_free.push_back( Chunk(0, m_size) ); }
AdtCataObjects::AdtCataObjects(const std::string & adtFileName) : adtName(adtFileName) { std::vector<char> buffer(0); Utilities::getWholeFile(adtFileName, buffer); const int fileSize (buffer.size()); int offsetInFile (0); int chunkName (Utilities::get<int>(buffer, offsetInFile)); while (offsetInFile < fileSize) { switch (chunkName) { case 'MVER' : objectsMver = Chunk(buffer, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + objectsMver.getGivenSize(); break; case 'MMDX' : mmdx = Chunk(buffer, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mmdx.getGivenSize(); break; case 'MMID' : mmid = Chunk(buffer, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mmid.getGivenSize(); break; case 'MWMO' : mwmo = Chunk(buffer, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mwmo.getGivenSize(); break; case 'MWID' : mwid = Chunk(buffer, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mwid.getGivenSize(); break; case 'MDDF' : mddf = Chunk(buffer, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + mddf.getGivenSize(); break; case 'MODF' : modf = Chunk(buffer, offsetInFile); offsetInFile = offsetInFile + chunkLettersAndSize + modf.getGivenSize(); break; /*case 'MCNK' : objectsMcnks.push_back(McnkCataObjects(buffer, offsetInFile)); offsetInFile = offsetInFile + chunkLettersAndSize + objectsMcnks.back().getGivenSize(); break;*/ default : //std::cout << offsetInFile << std::endl; objectsUnknown.push_back(Chunk(buffer, offsetInFile)); offsetInFile = offsetInFile + chunkLettersAndSize + objectsUnknown.back().getGivenSize(); } chunkName = Utilities::get<int>(buffer, offsetInFile); } }
Replay::Replay(QString filepath, bool loadInfosOnly) { QFile file(filepath); m_filepath = filepath; if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); in.setCodec("UTF-8"); while(!in.atEnd()) { QString line = in.readLine(); if(!loadInfosOnly && line.startsWith("::ORChunk:")) { // A Chunk line ::ORChunk:id:keyframeid:duration:data:: line.remove(0, 10); line.chop(2); QStringList elements = line.split(':', QString::KeepEmptyParts); if(elements.size() >= 4){ int chunkid = elements.at(0).toInt(); int keyframeid = elements.at(1).toInt(); int chunkduration = elements.at(2).toInt(); if(chunkid <= m_endstartupchunkid.toInt()) { m_primarychunks.append(Chunk(chunkid, QByteArray::fromBase64(elements.at(3).toLocal8Bit()), keyframeid, chunkduration)); } else { m_chunks.append(Chunk(chunkid, QByteArray::fromBase64(elements.at(3).toLocal8Bit()), keyframeid, chunkduration)); } } } else if(!loadInfosOnly && line.startsWith("::ORKeyFrame:")) { // A KeyFrame line ::ORKeyFrame:id:nextchunkid:data:: line.remove(0, 13); line.chop(2); QStringList elements = line.split(':', QString::KeepEmptyParts); if(elements.size() >= 3){ int keyframeid = elements.at(0).toInt(); int nextchunkid = elements.at(1).toInt(); m_keyframes.append(Keyframe(keyframeid, QByteArray::fromBase64(elements.at(2).toLocal8Bit()), nextchunkid)); } } else if(line.startsWith("::ORHeader:")) { // File Header ::ORHeader:platformid:gameid:encryptionkey:serverversion:endstartupchunkid:startgamechunkid:: line.remove(0, 11); line.chop(2); QStringList elements = line.split(':', QString::KeepEmptyParts); if(elements.size() >= 6){ m_platformid = elements.at(0); m_gameid = elements.at(1); m_encryptionkey = elements.at(2); m_serverversion = elements.at(3); m_endstartupchunkid = elements.at(4); m_startgamechunkid = elements.at(5); } } else if(line.startsWith("::ORGameInfos:")) { line.remove(0, 14); line.chop(2); m_gameinfos = QJsonDocument::fromJson(QByteArray::fromBase64(line.toLocal8Bit())); } else if(line.startsWith("::ORGameStats:")) { line.remove(0, 14); line.chop(2); m_endofgamestats = QByteArray::fromBase64(line.toLocal8Bit()); } else if(line == "::OREnd::") { break; } if(loadInfosOnly && !m_gameinfos.isEmpty() && !m_endofgamestats.isEmpty() && !m_encryptionkey.isEmpty()){ break; } } file.close(); if(m_encryptionkey.isEmpty() && !m_gameinfos.isEmpty() && !m_gameinfos.object().value("observers").toObject().value("encryptionKey").toString().isEmpty()){ m_encryptionkey = m_gameinfos.object().value("observers").toObject().value("encryptionKey").toString(); } if(m_platformid.isEmpty() && !m_gameinfos.isEmpty() && !m_gameinfos.object().value("platformId").toString().isEmpty()){ m_platformid = m_gameinfos.object().value("platformId").toString(); } if(m_gameid.isEmpty() && !m_gameinfos.isEmpty() && m_gameinfos.object().value("gameId").toVariant().toULongLong() != 0){ m_gameid = QString::number(m_gameinfos.object().value("gameId").toVariant().toULongLong()); } } else{ //ERROR : cannot open the file } }