Furnace::Furnace(furnaceData *data_) { data = data_; uint8_t block; uint8_t meta; Mineserver::get()->map(data->map)->getBlock(data->x, data->y, data->z, &block, &meta); if(!configIsRead) { readConfig(); configIsRead=true; } // Check if this is a burning block if(block == BLOCK_BURNING_FURNACE) { m_burning = true; } else { m_burning = false; } // Make sure we're the right kind of block based on our current status updateBlock(); }
void Furnace::consumeFuel() { // Check that we have fuel if(m_slots[SLOT_FUEL].count == 0) return; // Increment the fuel burning time based on fuel type // http://www.minecraftwiki.net/wiki/Furnace#Fuel_efficiency Slot fuelSlot = m_slots[SLOT_FUEL]; m_initialBurningTime = 0; if(fuelSlot.id == ITEM_COAL) { m_initialBurningTime += 80; } if(fuelSlot.id == BLOCK_PLANK) { m_initialBurningTime += 15; } if(fuelSlot.id == ITEM_STICK) { m_initialBurningTime += 5; } if(fuelSlot.id == BLOCK_WOOD) { m_initialBurningTime += 15; } if(fuelSlot.id == BLOCK_WORKBENCH) { m_initialBurningTime += 15; } if(fuelSlot.id == BLOCK_CHEST) { m_initialBurningTime += 15; } if(fuelSlot.id == BLOCK_BOOKSHELF) { m_initialBurningTime += 15; } if(fuelSlot.id == BLOCK_JUKEBOX) { m_initialBurningTime += 15; } if(fuelSlot.id == BLOCK_FENCE) { m_initialBurningTime += 15; } if(fuelSlot.id == BLOCK_WOODEN_STAIRS) { m_initialBurningTime += 15; } if(fuelSlot.id == ITEM_LAVA_BUCKET) { m_initialBurningTime += 1000; } m_fuelBurningTime += m_initialBurningTime; // Now decrement the fuel & reset m_slots[SLOT_FUEL].count--; if(m_slots[SLOT_FUEL].count < 0) m_slots[SLOT_FUEL].count = 0; // Update our block type if need be updateBlock(); }
double AnimationControllerPrivate::updateAnimations(SetChanged callSetChanged/* = DoNotCallSetChanged*/) { AnimationPrivateUpdateBlock updateBlock(*this); double timeToNextService = -1; bool calledSetChanged = false; for (auto& compositeAnimation : m_compositeAnimations) { CompositeAnimation& animation = *compositeAnimation.value; if (!animation.isSuspended() && animation.hasAnimations()) { double t = animation.timeToNextService(); if (t != -1 && (t < timeToNextService || timeToNextService == -1)) timeToNextService = t; if (!timeToNextService) { if (callSetChanged != CallSetChanged) break; Element* element = compositeAnimation.key->element(); ASSERT(element); ASSERT(!element->document().inPageCache()); element->setNeedsStyleRecalc(SyntheticStyleChange); calledSetChanged = true; } } } if (calledSetChanged) m_frame.document()->updateStyleIfNeeded(); return timeToNextService; }
void DocBlock::addLink(QUrl url) { myTextItem->setTextInteractionFlags(Qt::TextSelectableByKeyboard); docType = Link; path = url.toString(); QString str = path; // add file icon QTextCursor cursor = QTextCursor(myTextItem->document()); QFileInfo info(url.toLocalFile()); QFileIconProvider *provider = new QFileIconProvider(); QImage image(provider->icon(info).pixmap(16, 16).toImage()); cursor.document()->setPlainText(" "); cursor.insertImage(image); if (str.lastIndexOf("/") > -1) str = str.right(str.size() - str.lastIndexOf("/") - 1); QString html = "<a href=\""+path+"\">"+str+"</a>"; cursor.insertHtml(html); if (arrow != 0) arrow->setColor(getHoverColor()); updateBlock(false); }
Furnace::Furnace(furnaceDataPtr data) : m_data(data) { uint8_t block; uint8_t meta; ServerInstance->map(m_data->map)->getBlock(m_data->x, m_data->y, m_data->z, &block, &meta); if (!configIsRead) { readConfig(); configIsRead = true; } // Check if this is a burning block if (block == BLOCK_BURNING_FURNACE) { m_burning = true; } else { m_burning = false; } // Make sure we're the right kind of block based on our current status updateBlock(); }
void TextDocument::lowlight(int block) { if (block == -1) block = totalCount() - 1; if (d.lowlight != block) { d.lowlight = block; updateBlock(block); } }
/** * Overview: * myRIO main function. This template contains basic code to open the myRIO * FPGA session. You can remove this code if you only need to use the UART. * * Code in myRIO example projects is designed for reuse. You can copy source * files from the example project to use in this template. * * Note: * The Eclipse project defines the preprocessor symbol for the myRIO-1900. * Change the preprocessor symbol to use this example with the myRIO-1950. */ int main(int argc, char **argv) { NiFpga_Status status; /* * Open the myRIO NiFpga Session. * This function MUST be called before all other functions. After this call * is complete the myRIO target will be ready to be used. */ status = MyRio_Open(); if (MyRio_IsNotSuccess(status)) { return status; } /* * Your application code goes here. */ //we're gonna need lots of ram boss //layout of memory: //0-MEM_WIDTH: memory blocks of MEM_DEPTH size //MEM_ITER = MEM_WIDTH+1: a table of current indexes for each block //MEM_VAL = MEM_WIDTH+2: a table of current averages for each block double reference[MEM_WIDTH] = [0,1,5,2,7,8,2,6,7,3]; //something to test with double* memory[MEM_WIDTH+2]; initializeMemory(memory); int keepGoing = 1; int index = getIndex(0); double Kp = 1; double Ki = 1; double lastError[MEM_WIDTH] = {0}; while(keepGoing) { index = getIndex(index); double toSet = (Kp*lastError[index])+(Ki*MEM_VAL[index])+reference[index]; setOutput(outputHandle, toSet); //wait for a bit (outputs aren't instantaneous!) double result = measureFeedback(feedbackHandle); //some sort of unit conversion needs to take place here lastError[index] = result-reference[index]; updateBlock(memory, index, lastError[index]); } /* * Close the myRIO NiFpga Session. * This function MUST be called after all other functions. */ freeTheMemory(memory); status = MyRio_Close(); return status; }
void AnimationControllerPrivate::resumeAnimationsForDocument(Document* document) { AnimationPrivateUpdateBlock updateBlock(*this); for (auto& animation : m_compositeAnimations) { if (&animation.key->document() == document) animation.value->resumeAnimations(); } updateAnimationTimer(); }
void TextDocument::addHighlight(int block) { const int max = totalCount() - 1; if (block == -1) block = max; if (block >= 0 && block <= max) { QList<int>::iterator it = qLowerBound(d.highlights.begin(), d.highlights.end(), block); d.highlights.insert(it, block); updateBlock(block); } }
void DocBlock::addText(QString text) { myTextItem->setTextInteractionFlags(Qt::TextEditable | Qt::TextSelectableByKeyboard); myTextItem->setPlainText(text); docType = Text; if (arrow != 0) arrow->setColor(getHoverColor()); path = ""; updateBlock(false); }
void DocBlock::addImage(const QImage &image, QString imagePath) { myTextItem->setTextInteractionFlags(Qt::TextSelectableByKeyboard); docType = Image; QTextCursor cursor = QTextCursor(myTextItem->document()); cursor.document()->setPlainText(""); cursor.insertImage(image); path = imagePath; if (arrow != 0) arrow->setColor(getHoverColor()); updateBlock(false); }
Motogame::Motogame(bool LowQ, bool OGL3, bool Fullscreen, CWallet* pWallet, QObject *parent) : QObject(parent), m_Motogame(this), m_pWallet(pWallet), m_ReserveKey(pWallet), m_pPrevBest(nullptr) { m_Motogame.setWorkingDirectory(QCoreApplication::applicationDirPath()); m_Motogame.start(getMotogame(LowQ, OGL3, Fullscreen)); connect(&m_Motogame, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadAvailable())); connect(&m_Motogame, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(onGameFinished(int, QProcess::ExitStatus))); connect(&m_Motogame, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError(QProcess::ProcessError))); updateBlock(); startTimer(500); }
Furnace::Furnace(NBT_Value* entity, uint8_t blockType) { // Setup this furnace m_x = (int32_t)(*(*entity)["x"]); m_y = (int32_t)(*(*entity)["y"]); m_z = (int32_t)(*(*entity)["z"]); //m_fuelBurningTime = (int16_t)(*(*entity)["BurnTime"]); // Clean out the slots m_slots[SLOT_INPUT].count = 0; m_slots[SLOT_INPUT].damage = 0; m_slots[SLOT_INPUT].id = 0; m_slots[SLOT_FUEL].count = 0; m_slots[SLOT_FUEL].damage = 0; m_slots[SLOT_FUEL].id = 0; m_slots[SLOT_OUTPUT].count = 0; m_slots[SLOT_OUTPUT].damage= 0; m_slots[SLOT_OUTPUT].id = 0; // Set the cooking time based on input type (currently all smelting takes 10 secs but this gives us flexivibility in future) Slot inputSlot = m_slots[SLOT_INPUT]; m_cookingTime = 0; if(inputSlot.id == BLOCK_IRON_ORE) { m_cookingTime = 10; } if(inputSlot.id == BLOCK_GOLD_ORE) { m_cookingTime = 10; } if(inputSlot.id == BLOCK_SAND) { m_cookingTime = 10; } if(inputSlot.id == BLOCK_COBBLESTONE) { m_cookingTime = 10; } if(inputSlot.id == ITEM_PORK) { m_cookingTime = 10; } if(inputSlot.id == ITEM_CLAY_BALLS) { m_cookingTime = 10; } if(inputSlot.id == ITEM_RAW_FISH) { m_cookingTime = 10; } // Reset our active duration m_fuelBurningTime = 0; m_activeCookDuration = 0; // Check if this is a burning block if(blockType == BLOCK_BURNING_FURNACE) { m_burning = true; } else { m_burning = false; } // Make sure we're the right kind of block based on our current status updateBlock(); }
void AnimationControllerPrivate::animationTimerFired() { // We need to keep the frame alive, since it owns us. Ref<Frame> protector(m_frame); // Make sure animationUpdateTime is updated, so that it is current even if no // styleChange has happened (e.g. accelerated animations) AnimationPrivateUpdateBlock updateBlock(*this); // When the timer fires, all we do is call setChanged on all DOM nodes with running animations and then do an immediate // updateStyleIfNeeded. It will then call back to us with new information. updateAnimationTimer(CallSetChanged); // Fire events right away, to avoid a flash of unanimated style after an animation completes, and before // the 'end' event fires. fireEventsAndUpdateStyle(); }
static uint replacePairs(CRDS *crds, PAIR *target, CODE new_code) { uint i, j; uint num_replaced = 0; SEQ *seq = crds->seq; i = target->f_pos; while (i != DUMMY_POS) { j = seq[i].next; if (j == rightPos(crds, i)) { j = seq[j].next; } updateBlock(crds, new_code, i); i = j; num_replaced++; } return num_replaced; }
void Furnace::consumeFuel() { // Check that we have fuel if(slots()[SLOT_FUEL].count == 0) return; // Increment the fuel burning time based on fuel type // http://www.minecraftwiki.net/wiki/Furnace#Fuel_efficiency Item *fuelSlot = &slots()[SLOT_FUEL]; uint16_t fuelTime = 0; switch(fuelSlot->type) { case ITEM_COAL: fuelTime = 80; break; case BLOCK_PLANK: fuelTime = 15; break; case ITEM_STICK: fuelTime = 5; break; case BLOCK_WOOD: fuelTime = 15; break; case BLOCK_WORKBENCH: fuelTime = 15; break; case BLOCK_CHEST: fuelTime = 15; break; case BLOCK_BOOKSHELF: fuelTime = 15; break; case BLOCK_JUKEBOX: fuelTime = 15; break; case BLOCK_FENCE: fuelTime = 15; break; case BLOCK_WOODEN_STAIRS: fuelTime = 15; break; case ITEM_LAVA_BUCKET: fuelTime = 1000; break; default: break; } if(fuelTime > 0) { data->burnTime += fuelTime; // Now decrement the fuel & reset fuelSlot->count--; if (fuelSlot->count == 0) { *fuelSlot = Item(); } } // Update our block type if need be updateBlock(); }
void DocBlock::setFolded(bool fold) { if (fold == folded) return; //! do nothing folded = fold; if (fold) { backup = myTextItem->document()->clone(); if (docType == Image) { QTextCursor cursor = QTextCursor(myTextItem->document()); cursor.document()->setPlainText(" "); cursor.insertImage(QImage(":/image.png")); cursor.insertText(QFileInfo(path).fileName()); } else { QString cue = myTextItem->toPlainText(); int index = cue.indexOf("\n"); cue.truncate(qMin(8, index)); cue.append(" ..."); myTextItem->setPlainText(cue); myTextItem->setTextInteractionFlags(Qt::TextEditable | Qt::TextSelectableByKeyboard); } } else { Q_ASSERT(backup != 0); myTextItem->setDocument(backup); if (!docType == Text) myTextItem->setTextInteractionFlags(Qt::NoTextInteraction); backup = 0; } updateBlock(); }
void DocBlock::textChanged() { if (docType == Generic) return; QString text = myTextItem->toPlainText(); if (text.isEmpty() && !myTextItem->hasFocus() && docType != Image) { removeBlock(true); } else { if (element->getType() != text) { // if(!isFolded()) { // element->setType(text); // } group->setModified(true); updateBlock(false); } } }
void DocBlock::addWebLink(QUrl url) { myTextItem->setTextInteractionFlags(Qt::TextSelectableByKeyboard); docType = WebLink; // add web icon QTextCursor cursor = QTextCursor(myTextItem->document()); cursor.document()->setPlainText(" "); cursor.insertImage(QImage(":/weblink.png")); path = url.toString(); QString str = path; if (str.lastIndexOf("/") > 7) str = str.left(str.lastIndexOf("/")); QString html = "<a href=\""+path+"\">"+str+"</a>"; cursor.insertHtml(html); if (arrow != 0) arrow->setColor(getHoverColor()); updateBlock(false); }
void ShadowManager::update(float dt) { std::vector<V2F_C4B_T2F_Triangle> triangles[NUM_SHADOW_LAYERS]; GameLevel::instance().traverseObjects([&](GameObject* block){ updateBlock(block, triangles[block->getRenderer()->getShadowLayer()]); }, true); auto cameraPos = GameLevel::instance().getGameLayer()->getCamera()->getPosition(); for (int i = 0; i < NUM_SHADOW_LAYERS; ++i) { #if EDITOR_MODE mRenderTextures[i]->setPosition(cameraPos - Vec2(0, UI_LAYER_HIGHT / 2)); #else mRenderTextures[i]->setPosition(cameraPos); #endif mShadowDrawers[i]->clear(); if (!triangles[i].empty()) { mShadowDrawers[i]->drawTriangles(triangles[i]); } mRenderTextures[i]->beginWithClear(0, 0, 0, 0); mShadowDrawers[i]->visit(); mRenderTextures[i]->end(); } }
void Motogame::onReadAvailable() { while (true) { QByteArray Msg = m_Motogame.readLine(); if (Msg.size() == 0) break; MotoWork Work; MotoPoW PoW; if (motoParseMessage(Msg.data(), Work)) { auto iter = findBlock(Work); if (iter != m_Templates.end()) m_Templates.erase(iter); } else if (motoParseMessage(Msg.data(), Work, PoW)) { auto iter = findBlock(Work); if (iter != m_Templates.end()) { CBlock *pBlock = &(*iter)->block; pBlock->Nonce = PoW; CheckWork(pBlock, *m_pWallet, m_ReserveKey); } updateBlock(); } else if (strncmp(Msg.data(), "***Config:*", 11) == 0) { QString Controls(Msg.data() + 11); Controls.remove("\n"); QSettings settings; settings.setValue("GameControls", Controls); } } }
void TextDocument::removeHighlight(int block) { if (d.highlights.removeOne(block) && block >= 0 && block < totalCount()) updateBlock(block); }
void erodeBunker(unsigned int* framePointer, int which_bunker){ int which_block = rand()%8; short* bunker; int i, j; int block_row, block_col; switch(which_bunker){ // select a bunker that I want to erode case 0: bunker = getBunker4(); break; case 1: bunker = getBunker3(); break; case 2: bunker = getBunker2(); break; case 3: bunker = getBunker1(); break; default : break; } switch(which_block){ // 'block_row, block_col' are used to calculate to find out the position of framePointer case 0: block_row = 0; block_col = 0; blankBlock(framePointer, which_bunker, which_block, block_row, block_col); updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); break; case 1: block_row = 0; block_col = 1; blankBlock(framePointer, which_bunker, which_block, block_row, block_col); updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); break; case 2 : block_row = 0; block_col = 2; blankBlock(framePointer, which_bunker, which_block, block_row, block_col); updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); break; case 3 : block_row = 1; block_col = 0; blankBlock(framePointer, which_bunker, which_block, block_row, block_col); updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); break; case 4 : block_row = 1; block_col = 1; blankBlock(framePointer, which_bunker, which_block, block_row, block_col); updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); break; case 5 : block_row = 1; block_col = 2; blankBlock(framePointer, which_bunker, which_block, block_row, block_col); updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); break; case 6 : block_row = 2; block_col = 0; blankBlock(framePointer, which_bunker, which_block, block_row, block_col); updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); break; case 7 : block_row = 2; block_col = 2; blankBlock(framePointer, which_bunker, which_block, block_row, block_col); updateBlock(framePointer, which_bunker, which_block, block_row, block_col, bunker); break; default : break; } }
/*! \reimp */ void TextDocumentLayout::documentChanged(int from, int /*charsRemoved*/, int charsAdded) { QTextDocument *doc = document(); int newBlockCount = doc->blockCount(); QTextBlock changeStartBlock = doc->findBlock(from); QTextBlock changeEndBlock = doc->findBlock(qMax(0, from + charsAdded - 1)); if (changeStartBlock == changeEndBlock && newBlockCount == d->blockCount) { QTextBlock block = changeStartBlock; if (block.isValid() && block.layout()->lineCount()) { QRectF oldBr = blockBoundingRect(block); layoutBlock(block); QRectF newBr = blockBoundingRect(block); if (newBr.height() == oldBr.height()) { if (!d->blockUpdate) emit updateBlock(block); return; } } } else { QTextBlock block = changeStartBlock; do { block.clearLayout(); if (block == changeEndBlock) break; block = block.next(); } while(block.isValid()); } if (newBlockCount != d->blockCount) { int changeEnd = changeEndBlock.blockNumber(); int blockDiff = newBlockCount - d->blockCount; int oldChangeEnd = changeEnd - blockDiff; if (d->maximumWidthBlockNumber > oldChangeEnd) d->maximumWidthBlockNumber += blockDiff; d->blockCount = newBlockCount; if (d->blockCount == 1) d->maximumWidth = blockWidth(doc->firstBlock()); if (!d->blockDocumentSizeChanged) emit documentSizeChanged(documentSize()); if (blockDiff == 1 && changeEnd == newBlockCount -1 ) { if (!d->blockUpdate) { QTextBlock b = changeStartBlock; for(;;) { emit updateBlock(b); if (b == changeEndBlock) break; b = b.next(); } } return; } } if (!d->blockUpdate) emit update(QRectF(0., -doc->documentMargin(), 1000000000., 1000000000.)); // optimization potential }
void TextDocumentLayout::layoutBlock(const QTextBlock &block) { QTextDocument *doc = document(); qreal margin = doc->documentMargin(); qreal blockMaximumWidth = 0; qreal height = 0; QTextLayout *tl = block.layout(); QTextOption option = doc->defaultTextOption(); tl->setTextOption(option); int extraMargin = 0; if (option.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators) { QFontMetrics fm(block.charFormat().font()); extraMargin += fm.width(QChar(0x21B5)); } tl->beginLayout(); qreal availableWidth = d->width; if (availableWidth <= 0) { availableWidth = qreal(INT_MAX); // similar to text edit with pageSize.width == 0 } availableWidth -= 2*margin + extraMargin; qreal indentMargin = 0; while (1) { QTextLine line = tl->createLine(); if (!line.isValid()) break; line.setLeadingIncluded(true); line.setLineWidth(availableWidth - indentMargin); line.setPosition(QPointF(margin + indentMargin, height)); if(!height) //enter only in the first iteration { indentMargin = indentWidth(block); } height += line.height(); blockMaximumWidth = qMax(blockMaximumWidth, line.naturalTextWidth() + 2*margin); } tl->endLayout(); int previousLineCount = doc->lineCount(); const_cast<QTextBlock&>(block).setLineCount(block.isVisible() ? tl->lineCount() : 0); int lineCount = doc->lineCount(); bool emitDocumentSizeChanged = previousLineCount != lineCount; if (blockMaximumWidth > d->maximumWidth) { // new longest line d->maximumWidth = blockMaximumWidth; d->maximumWidthBlockNumber = block.blockNumber(); emitDocumentSizeChanged = true; } else if (block.blockNumber() == d->maximumWidthBlockNumber && blockMaximumWidth < d->maximumWidth) { // longest line shrinking QTextBlock b = doc->firstBlock(); d->maximumWidth = 0; QTextBlock maximumBlock; while (b.isValid()) { qreal blockMaximumWidth = blockWidth(b); if (blockMaximumWidth > d->maximumWidth) { d->maximumWidth = blockMaximumWidth; maximumBlock = b; } b = b.next(); } if (maximumBlock.isValid()) { d->maximumWidthBlockNumber = maximumBlock.blockNumber(); emitDocumentSizeChanged = true; } } if (emitDocumentSizeChanged)// && !d->blockDocumentSizeChanged) emit documentSizeChanged(documentSize()); emit updateBlock(block); }
/* Writes SIZE bytes from BUFFER into INODE, starting at OFFSET. Returns the number of bytes actually written, which may be less than SIZE if end of file is reached or an error occurs. (Normally a write at end of file would extend the inode, but growth is not yet implemented.) */ off_t inode_write_at (struct inode *inode, const void *buffer_, off_t size, off_t offset) { const uint8_t *buffer = buffer_; off_t bytes_written = 0; uint8_t *bounce = NULL; /* Debugging */ bool debug = false; if (inode->deny_write_cnt) return 0; //printf("inode_length : %d\n",inode_length(inode)); ASSERT(inode->sector <20000); //printf("*node[%d]->extension=%d \n", inode->sector, inode->extension); while(inode->extension); //printf("inode_write_at called size: %d, offset : %d, inode_length : %d\n",size,offset,inode->data.length); while (size > 0) { /* Sector to write, starting byte offset within sector. */ block_sector_t sector_idx = byte_to_sector (inode, offset); int sector_ofs = offset % BLOCK_SECTOR_SIZE; /* Bytes left in inode, bytes left in sector, lesser of the two. */ off_t inode_left = inode_length (inode) - offset; int sector_left = BLOCK_SECTOR_SIZE - sector_ofs; int min_left = inode_left < sector_left ? inode_left : sector_left; /* Number of bytes to actually write into this sector. */ int chunk_size = size < min_left ? size : min_left; struct cache * cache = find_cache(sector_idx); //if(debug) printf("sector_idx : %d\n",sector_idx); if(offset > inode_length(inode)) { //printf("setting node[%d]->extension=true \n", inode->sector); inode->extension = true; //printf("You made me true\n"); int left = (offset - inode_length(inode)); int i; int sectors = (left+1)/BLOCK_SECTOR_SIZE; //printf("Offset Over\n"); block_sector_t new_sector; int check = inode_length(inode) + BLOCK_SECTOR_SIZE - inode_length(inode)%512+1; inode->data.length += left; block_write(fs_device,inode->sector,&(inode->data)); //printf("offset inode length increase from :%d to %d sector num : %d check : %d\n",inode_length(inode),inode_length(inode)-left,sectors,check); for(i=0; i<sectors; i++) { //printf("check is : %d\n",check); if(!free_map_allocate(1,&new_sector)) { printf("Fail to allocate freemap\n"); ASSERT(false); } updateBlock(inode,check,new_sector); //printf("Allocate new Sector : %d\n",new_sector); check += BLOCK_SECTOR_SIZE; } //debug = true; continue; } else if((size >= inode_left - offset) && min_left == 0) { int sector_num; int i; //printf("Size Over\n"); if((size-sector_left+1) <=0) sector_num = 0; else sector_num = bytes_to_sectors((size-sector_left)+1); //printf("size : %d , offset : %d, sector_left : %d\n",size,offset,sector_left); block_sector_t new_sector; int check = inode_length(inode) + sector_left ; //printf("setting node[%d]->extension=true \n", inode->sector); inode->extension = true; //printf("You made me true\n"); //file_extension(inode,buffer+bytes_written,size); inode->data.length = inode->data.length + size; block_write(fs_device,inode->sector,&(inode->data)); //printf("Sector_left : %d\n",sector_left); //printf("size inode length increase from :%d to %d now sector num : %d sector_num : %d\n",inode_length(inode),inode_length(inode)-size,sector_idx,sector_num); for(i=0; i<sector_num; i++) { if(!free_map_allocate(1,&new_sector)) { printf("Freemap Fail\n"); ASSERT(false); } updateBlock(inode,check,new_sector); //printf("Allocate new Sector : %d\n",new_sector); // print_table_info(inode); check +=BLOCK_SECTOR_SIZE; } debug = true; continue; } else if(sector_idx == -1) { print_table_info(inode); //printf("offset : %d inode : %#x inode_sector : %d length : %d\n",offset,inode,inode->sector,inode_length(inode)); } if(debug) { } //ASSERT(sector_idx < 20000); if (chunk_size <= 0) break; /* if(debug) { print_table_info(inode); } */ //printf("inode read at called chunksize : %d , sector_ofs : %d, sector_idx : %d\n",chunk_size,sector_ofs,sector_idx); if(cache == NULL) { cache = add_cache(sector_idx); if(cache == NULL) { print_table_info(inode); printf("read Error\n"); return bytes_written; } } cache->accessed = true; cache->pin = true; //if(inode_left - sector_ofs > 512) // read_ahead(sector_idx +1); write_cache(cache , buffer+bytes_written , sector_ofs ,chunk_size); /* Advance. */ cache->pin = false; size -= chunk_size; offset += chunk_size; bytes_written += chunk_size; } // free (bounce); if(inode->extension == true) { //printf("set node[%d]->extension as false\n", inode->sector); inode->extension = false; ASSERT(inode->extension==false); } return bytes_written; }
void Motogame::timerEvent(QTimerEvent*) { updateBlock(); }
void DocBlock::updateGeometryAfter(bool doAnimation) { updateBlock(doAnimation); }