int Scene::Tick(int* currFunction, int* currTask) { if(IsDone()) return (int)SUCCES; if(stack.empty()) return (int)FAILURE; // Go to stack and execute last entry if not null-pointer. If null-pointer, remove and take next. If stack is empty, return false. while(functions[stack.back().x][stack.back().y] == UNDEFINED) { // Find entry which is not undefined stack.pop_back(); if(stack.empty()) return FAILURE; // No more commmands. We already checked if we solved the task, so we return FAILURE } *currFunction = stack.back().x; *currTask = stack.back().y; // Execute function int returnValue = CallFunc(functions[stack.back().x][stack.back().y]); // (x, y+1) into stack. stack.back().y++; // If return is not -1, put (return, 0) into stack; if(returnValue != -1) stack.push_back((Pos){returnValue, 0}); return (int)NOT_DONE; }
CVariant CKadOperation::AddLoadRes(const CVariant& LoadRes, CKadNode* pNode) { SOpProgress* pProgress = GetProgress(pNode); CVariant FilteredRes = LoadRes.Clone(false); // Make a Shellow Copy const CVariant& LoadedList = LoadRes["RES"]; CVariant FilteredList; for(uint32 i=0; i < LoadedList.Count(); i++) { CVariant Loaded = LoadedList.At(i).Clone(false); // Make a Shellow Copy const CVariant& XID = Loaded["XID"]; // Counting if(pProgress) // might be NULL if we filter our own index response right now { SOpStatus &Status = pProgress->Loads[XID]; Status.Results++; if(!Loaded.Get("MORE")) Status.Done = true; // this marks that no more results are to be expected form this node } SOpStatus* pStatus = &m_LoadMap[XID].Status; pStatus->Results++; if(!pStatus->Done) pStatus->Done = IsDone(SOpProgress::GetLoads, XID); if(!pStatus->Done) Loaded.Insert("MORE", true); else Loaded.Remove("MORE"); // if(Loaded.Has("ERR")) { FilteredList.Append(Loaded); continue; } // Filtering CVariant UniquePayloads; const CVariant& Payloads = Loaded["PLD"]; for(uint32 j=0; j < Payloads.Count(); j++) { const CVariant& Payload = Payloads.At(j); if(m_LoadFilter[XID].insert(Payload["DATA"].GetFP()).second) UniquePayloads.Append(Payload); } // Note: we must add this even if UniquePayloads is empty or else we will misscount replys CVariant NewLoaded; NewLoaded["XID"] = XID; NewLoaded["PLD"] = UniquePayloads; FilteredList.Append(NewLoaded); // } FilteredRes.Insert("RES", FilteredList); return FilteredRes; }
void CLoadLTADlg::OnTimer(UINT nIDEvent) { CEdit* pEdit = ((CEdit*)GetDlgItem(IDC_LOADLOG)); pEdit->SetSel(-1, 0, TRUE); if(nIDEvent == TIMER_ID) { BOOL bDone = IsDone(); //see if we need to update the load log //(the check is done so that when it is running, we don't refresh it //continually) if(m_bPrevLoaderDone == FALSE) { UpdateLoadLog(); } //see if the finishing state has finished at all if(bDone != m_bPrevLoaderDone) { ((CButton*)GetDlgItem(IDC_SAVELOADLOG))->EnableWindow(bDone); ((CButton*)GetDlgItem(IDOK))->EnableWindow(bDone); m_bPrevLoaderDone = bDone; } // automatically close the dialog on load completion if( m_bAutoConfirm && bDone && m_bPrevLoaderDone ) { OnOK(); } } CDialog::OnTimer(nIDEvent); }
//------------------------------------------------------------ void nsFilteredContentIterator::Last() { if (!mCurrentIterator) { NS_ERROR("Missing iterator!"); return; } // If we are switching directions then // we need to switch how we process the nodes if (mDirection != eBackward) { mCurrentIterator = mIterator; mDirection = eBackward; mIsOutOfRange = false; } mCurrentIterator->Last(); if (mCurrentIterator->IsDone()) { return; } nsINode *currentNode = mCurrentIterator->GetCurrentNode(); nsCOMPtr<nsIDOMNode> node(do_QueryInterface(currentNode)); bool didCross; CheckAdvNode(node, didCross, eBackward); }
void nsFilteredContentIterator::Prev() { if (mIsOutOfRange || !mCurrentIterator) { NS_ASSERTION(mCurrentIterator, "Missing iterator!"); return; } // If we are switching directions then // we need to switch how we process the nodes if (mDirection != eBackward) { nsresult rv = SwitchDirections(false); if (NS_FAILED(rv)) { return; } } mCurrentIterator->Prev(); if (mCurrentIterator->IsDone()) { return; } // If we can't get the current node then // don't check to see if we can skip it nsINode *currentNode = mCurrentIterator->GetCurrentNode(); nsCOMPtr<nsIDOMNode> node(do_QueryInterface(currentNode)); CheckAdvNode(node, mDidSkip, eBackward); }
PyObject *pyllbc_PackLemma_Top::Read(pyllbc_Stream *stream) { if (UNLIKELY(!IsDone())) { pyllbc_SetError("top-lemma not done, could not unpack data"); return NULL; } size_t idx = 0; PyObject *values = PyTuple_New(_lemmas.size()); for (; idx < _lemmas.size(); idx++) { PyObject *value; Base *lemma = _lemmas[idx]; if (!(value = lemma->Read(stream))) break; PyTuple_SET_ITEM(values, idx, value); } if (idx != _lemmas.size()) { Py_DECREF(values); values = NULL; } return values; }
HRESULT SoundD3D::Play() { if (IsPlaying()) return S_OK; if (!buffer) return E_FAIL; HRESULT hr = E_FAIL; if (IsDone()) hr = Rewind(); if (IsReady()) { if (moved) Localize(); if (flags & LOOP || flags & STREAMED) hr = buffer->Play(0, 0, DSBPLAY_LOOPING); else hr = buffer->Play(0, 0, 0); if (SUCCEEDED(hr)) status = PLAYING; } return hr; }
bool CLIENTFX_INSTANCE::IsFinished() { if (IsDone()) return true; CLinkListNode<FX_LINK> *pActiveNode = m_collActiveFX.GetHead(); CBaseFX *pFX = LTNULL; while (pActiveNode) { pFX = pActiveNode->m_Data.m_pFX; // Check for expiration if( pFX ) { //determine if this effect has expired bool bExpired = ((pFX->GetElapsed() >= pFX->GetEndTime()) || pFX->IsShuttingDown()) && (pFX->IsFinishedShuttingDown() || !pActiveNode->m_Data.m_pRef->m_bSmoothShutdown); if (!bExpired) return false; } pActiveNode = pActiveNode->m_pNext; } return true; }
/* ================== Sound::Update ================== */ bool Sound::Update() { if (GetDeleteWhenDone() && IsDone()) { return false; } if (!IsPlaying()) { /* Nothing went wrong, so there's no need to alert AudioManager */ return true; } int processed = 0; alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed); while (processed--) { /* There's no need to initialize the 'buffer' variable, as it is set to the relevant buffer when calling alSourceUnqueueBuffers. */ ALuint buffer; alSourceUnqueueBuffers(source, 1, &buffer); if (!FillBuffer(buffer)) { /* Either something went wrong, or we've reached * the end of the sound-buffer. The AudioManager will * delete this sound if (deleteWhenDone && !loop) */ return false; } alSourceQueueBuffers(source, 1, &buffer); } return true; }
PBYTE *A3( PBYTE *pMem ) { int i; int s = 8137; BYTE byBuffer[256]; sprintf( byBuffer, WIDE("allocate to fill memory\n"), MAX_I,MAX_I); ODS( byBuffer ); IsDone(); for( i = 0; i < MAX_I; i++ ) { while( !( pMem[i] = Allocate( s )) ) { s /= 2; if( !s ) break; } if( !s ) { BYTE byDebug[256]; sprintf( byDebug, WIDE("Failed at %d...\n"), i ); break; } } return pMem; }
void BattleAnimation::DrawAt(int x, int y) { if (!sprite) return; // Initialization failed if (IsDone()) return; const RPG::AnimationFrame& anim_frame = animation.frames[frame]; std::vector<RPG::AnimationCellData>::const_iterator it; for (it = anim_frame.cells.begin(); it != anim_frame.cells.end(); ++it) { const RPG::AnimationCellData& cell = *it; if (!cell.valid) { // Skip unused cells (they are created by deleting cells in the // animation editor, resulting in gaps) continue; } sprite->SetX(cell.x + x); sprite->SetY(cell.y + y); int sx = cell.cell_id % 5; int sy = cell.cell_id / 5; int size = large ? 128 : 96; sprite->SetSrcRect(Rect(sx * size, sy * size, size, size)); sprite->SetOx(size / 2); sprite->SetOy(size / 2); sprite->SetTone(Tone(cell.tone_red * 128 / 100, cell.tone_green * 128 / 100, cell.tone_blue * 128 / 100, cell.tone_gray * 128 / 100)); sprite->SetOpacity(255 * (100 - cell.transparency) / 100); sprite->SetZoomX(cell.zoom / 100.0); sprite->SetZoomY(cell.zoom / 100.0); sprite->Draw(); } }
const LLBC_String &pyllbc_PackLemma::ToString() const { if (!IsDone()) return _emptyStr; return _str; }
void Environment::Run(const int n_steps) { int t; unsigned int i; for(i = 0; i < agents.size(); i++) { agents[i]->SetPerformance(0); } UpdateDisplays(); if(delay) { sleep(delay); } for(t = 0; t < n_steps; t++) { if(IsDone()) { return; } Step(); if(delay) { sleep(delay); } } }
PBYTE *T5( PBYTE *pMem ) { ODS( WIDE("Starting Defrag test\n")); DumpStats(); { int i, r; for( i = 0; i < MAX_I/2; i++ ) { r = i*2; if( r >= MAX_I ) r -= (MAX_I - 1); pMem[r] = Release( pMem[r] ); } DumpStats(); for( i = 0; i < (MAX_I)/2; i++ ) { r = i*2; Defragment( &pMem[r+1] ); } DumpStats(); for( ; i < MAX_I; i++ ) { r = i*2; if( r >= MAX_I ) r -= (MAX_I - 1); pMem[r] = Release( pMem[r] ); } DumpStats(); } IsDone(); return pMem; }
void T_SimpleListIterator<Item>::Next() { NAssert(!IsDone()) ; if (_reverse) { _current=_current->prev ; } else { _current=_current->next ; } }
const char& String::StringIterator::CurrentItem() const { if (IsDone()) { throw IteratorOutOfBoundException(); } return (_string->operator[](_current)); }
void CLoadLTADlg::OnCancel() { //don't let them quit while the thread is running if(IsDone() == FALSE) return; CDialog::OnCancel(); }
Item MyListIterator<Item>::CurrentItem() const { if(IsDone()) { throw IteratorOutOfBounds; } return _list->Get(_current); }
virtual ~FXmppMessageReceiveTask() { // task shouldn't really be deleted until done but just in case if (!IsDone()) { Stop(); } }
bool nsFilteredContentIterator::IsDone() { if (mIsOutOfRange || !mCurrentIterator) { return true; } return mCurrentIterator->IsDone(); }
Job* CryptTask::CreateNextJob() { if (IsDone()) return NULL; CryptJob* job = CreateJob(); _PrepareJob(job); return job; }
bool CItem::MustShowReadJobs() const { if (GetParent() != NULL) { return !GetParent()->IsDone(); } else { return !IsDone(); } }
void Window::Render(const boost::shared_ptr<Surface>& target) { if (IsDone()) { return; } target->PushState(); target->SetViewportRelative(GetBounds()); OnRender(target); target->PopState(); }
bool S3FileRequest::WaitUntilDone() const { unsigned timeoutCount = 0; float totalProgress = GetProgress(); while (timeoutCount++ < DOWNLOAD_WAIT_TIMEOUT) { if (IsDone()) { break; } // Let's reset our timeout if (GetProgress() != totalProgress) { timeoutCount = 0; totalProgress = GetProgress(); } std::this_thread::sleep_for(std::chrono::seconds(1)); } return IsDone(); }
PBYTE *T2( PBYTE *pMem ) { ODS( WIDE("Starting FirstAllocFirstRelease\n")); { int i; for( i = 0; i < MAX_I; i++ ) { pMem[i] = Release( pMem[i] ); } } IsDone(); return pMem; }
PBYTE *T1( PBYTE *pMem ) { ODS( WIDE("Starting FALR\n")); { int i; for( i = MAX_I-1; i >=0; i-- ) { pMem[i] = Release( pMem[i] ); } } IsDone(); return pMem; }
PBYTE *A1( PBYTE *pMem ) { int i; ODS("Allocate 1 byte\n"); IsDone(); for( i = 0; i < MAX_I; i++ ) { if( i < MAX_I-1) pMem[i+1] = (PBYTE)1; pMem[i] = Allocate(1); } return pMem; }
PBYTE *A2( PBYTE *pMem ) { int i; BYTE byBuffer[256]; sprintf( byBuffer, WIDE("allocate (n*32) 0..%d\n"), MAX_I); ODS( byBuffer ); IsDone(); for( i = 0; i < MAX_I; i++ ) { pMem[i] = Allocate( i * 32 ); } return pMem; }
unsigned VChatClient::GetAllChannelsEx() { Reset(); VChatAPI::GetAllChannels(NULL); while(!IsDone() && !HasFailed()) { Process(); soe::Sleep(10); } return m_result; }
int pyllbc_PackLemma_Top::Write(pyllbc_Stream *stream, PyObject *values) { if (UNLIKELY(!IsDone())) { pyllbc_SetError("top-lemma not done, could not pack data"); return LLBC_FAILED; } const bool valuesIsNone = pyllbc_TypeDetector::IsNone(values); if (valuesIsNone) { if (!_lemmas.empty()) { pyllbc_SetError("not found any values to pack, but has been specified format character symbol"); return LLBC_FAILED; } return LLBC_OK; } else if (!pyllbc_TypeDetector::IsSequence(values)) { pyllbc_SetError("will pack data not iterable"); return LLBC_FAILED; } const Py_ssize_t seqSize = PySequence_Size(values); if (seqSize != static_cast<Py_ssize_t>(_lemmas.size())) { LLBC_String errStr; pyllbc_SetError(errStr.format( "will pack data sequence size[%ld] not equal format character size[%d]", seqSize, _lemmas.size())); return LLBC_FAILED; } for (Py_ssize_t i = 0; i < seqSize; i++) { Base *lemma = _lemmas.at(i); PyObject *obj = PySequence_GetItem(values, i); if (lemma->Write(stream, obj) != LLBC_OK) { Py_DECREF(obj); return LLBC_FAILED; } Py_DECREF(obj); } return LLBC_OK; }