bool Workbench::Drop(const int src, const int dest, const int num, Inventory* const inv_to) { if ( inv_to == nullptr || src >= GetSize() || dest >= inv_to->GetSize() || IsEmpty(src) ) { return false; } for (int i=0; i<num; ++i) { if ( not inv_to->Get(ShowBlock(src), dest) ) return false; Pull(src); if ( src < Start() ) { // remove materials: for (int slot=Start(); slot<GetSize(); ++slot) { while ( not IsEmpty(slot) ) { Block* const to_pull = ShowBlock(slot); Pull(slot); delete to_pull; } } } else { Craft(); } } return true; }
MatrixNode<T>::MatrixNode ( const vector<Int>& invMap, const NodeInfo& info, const Matrix<T>& X ) : parent(nullptr), duplicateMat(nullptr), duplicateMV(nullptr) { DEBUG_ONLY(CSE cse("MatrixNode::MatrixNode")) Pull( invMap, info, X ); }
void TopSubMenuItem::LeftDown(Point, dword) { if(isenabled && !menu.IsOpen()) { Pull(); Refresh(); } }
void TopSubMenuItem::MouseEnter(Point p, dword) { LLOG("TopSubMenuItem::MouseEnter"); Refresh(); if(isenabled && parentmenu->GetActiveSubmenu()) Pull(); }
bool TopSubMenuItem::Key(dword key, int) { if(isenabled && (key == K_ENTER || key == K_DOWN)) { Pull(); return true; } return false; }
void Converter::DoRareAction() { if ( isOn && fuelLevel < World::SECONDS_IN_DAY/DamageLevel() ) { for (int i=GetSize()-1; i>=0; --i) { Block* const block = ShowBlock(i); if ( block ) { const int add = ConvertRatio(block->Sub()); if ( add > 0 ) { fuelLevel += add; Pull(i); delete block; break; } } } } World* const world = World::GetWorld(); if ( fuelLevel <= 0 || ( Sub() == STONE && world->GetBlock(X(), Y(), Z()+1)->Sub() == WATER ) ) { Damage(1, damageKindOff); } else { if (world->Damage(X(), Y(), Z()+1, DamageLevel(), damageKindOn)<=0) { world->DestroyAndReplace(X(), Y(), Z()+1); } fuelLevel -= DamageLevel(); } }
BNJ::PullParser::State BNJ::PullParser::Up(void){ /* Loop until parser depth goes above destination depth. Drop the data. */ const unsigned dest_depth = _depth - 1; while(dest_depth < _depth) Pull(); return _parser_state; }
CMarkdown &CMarkdown::Pop() { if (!Pull()) { upper = ahead; } return *this; }
bool SubMenuItem::HotKey(dword key) { if(isenabled && (key == accel || CompareAccessKey(accesskey, key))) { Pull(); return true; } return false; }
bool SubMenuItem::Key(dword key, int count) { if(key == K_RIGHT || key == K_ENTER) { Pull(); return true; } return MenuItem::Key(key, count); }
inline DistNodalMultiVec<F>::DistNodalMultiVec ( const DistMap& inverseMap, const DistSymmInfo& info, const DistMultiVec<F>& X ) { DEBUG_ONLY(CallStackEntry cse("DistNodalMultiVec::DistNodalMultiVec")) Pull( inverseMap, info, X ); }
SymmFront<F>::SymmFront ( const SparseMatrix<F>& A, const vector<Int>& reordering, const SymmNodeInfo& info, bool conjugate ) : parent(nullptr), duplicate(nullptr) { DEBUG_ONLY(CallStackEntry cse("SymmFront::SymmFront")) Pull( A, reordering, info, conjugate ); }
bool TopSubMenuItem::HotKey(dword key) { if(BarCtrl::Scan(proc, key)) return true; if(isenabled && (key == accel || CompareAccessKey(accesskey, key))) { Pull(); return true; } return false; }
Front<F>::Front ( const SparseMatrix<F>& A, const vector<Int>& reordering, const NodeInfo& info, bool conjugate ) : sparseLeaf(false), parent(nullptr), duplicate(nullptr) { DEBUG_ONLY(CSE cse("Front::Front")) Pull( A, reordering, info, conjugate ); }
void LoadedChildBucket::Load(const ChildBucketAddr &addr, IndexBundle &bundle, EndianReadBuffer &tmpBuf) { if (addr) { // No CRC - the ChildBucket is written in two halves, each with // it's own CRC. The Pull will check each of the separate // CRCs bundle.LoadWithoutCRC(addr.WholeAddr(), tmpBuf); Pull(addr, tmpBuf); } }
/* -------------------------------------------------------------------------------------------- * Return a memory buffer to the pool. */ void Drop(Pointer & ptr, SzType & size) { if (!ptr) { ThrowMemExcept("Cannot store invalid memory buffer"); } // Request a node instance Node * node = Pull(); // Assign the specified memory node->mPtr = ptr; // Assign the specified size node->mCap = size; // Demote the current head node node->mNext = m_Head; // Promote as the head node m_Head = node; }
MatrixNode<T>::MatrixNode ( const vector<Int>& invMap, const NodeInfo& info, const Matrix<T>& X ) { EL_DEBUG_CSE Pull( invMap, info, X ); }
unsigned BNJ::PullParser::ChunkRead8(char* dest, unsigned destlen, unsigned key_enum) { if(_val_idx >= _val_len) throw std::runtime_error("No valid parser value!"); /* out will always point to first empty char. */ uint8_t* out = (uint8_t*)dest; unsigned remaining = destlen; bnj_val& val = _valbuff[_val_idx]; /* Verify enum and type. */ if(key_enum != 0xFFFFFFFF && val.key_enum != key_enum) s_throw_key_error(*this, key_enum); if(bnj_val_type(&val) != BNJ_STRING) s_throw_type_error(*this, BNJ_STRING); while(remaining > _utf8_remaining || !dest){ bnj_val& val = _valbuff[_val_idx]; bool completed = !bnj_incomplete(&_pstate, &val); /* Can fit entire string fragment in destination. */ if(dest) out = bnj_stpncpy8(out, &val, _utf8_remaining + 1, Buff()); _utf8_remaining = 0; /* If value is not a fragment, then have read the whole value. */ if(completed) return out - (uint8_t*)dest; /* Decrement remaining bytes, but add back in null terminator. */ remaining = destlen - (out - (uint8_t*)dest) + 1; /* Just finished reading data from fragment, so must be at end * of unparsed data. Refill the entire buffer. */ FillBuffer(_len); /* Pull will do the work of updating the buffer here. * Jump directly to PARSE_ST so Pull() will not jump back here! */ _state = PARSE_ST; State s = Pull(_ctx.key_set, _ctx.key_set_length); assert(ST_DATUM == s); } /* Save room for null terminator. */ --remaining; /* Copy fragmented char if applicable. */ if(val.significand_val != BNJ_EMPTY_CP){ out = bnj_utf8_char((uint8_t*)dest, remaining, (uint32_t)val.significand_val); if((uint8_t*)dest != out){ unsigned written = out - (uint8_t*)dest; remaining -= written; _utf8_remaining -= written; } else{ *out = '\0'; return out - (uint8_t*)dest; } } /* Only copy up to minimum of len and content length. */ const uint8_t* x = Buff() + val.strval_offset; const uint8_t* b = x; uint8_t* res = bnj_json2utf8(out, remaining, &b); /* Update bytes remaining in the input buffer. */ _offset += b - x; _utf8_remaining -= res - out; /* Return number of bytes written to output. */ return res - (uint8_t*)dest; }