void Flow::update() { if (DebugActor::instance) { std::string str; for (size_t i = 1; i < scenes.size(); ++i) { str += scenes[i]->getName(); str += "->"; } if (!str.empty()) { str.pop_back(); str.pop_back(); str += "\n"; DebugActor::addDebugString(str.c_str()); } } bool quit = checkQuit(); static bool quitLast = false; if (quit && !quitLast) { _wasBackBlocked = true; } quitLast = quit; if (_transition) { if (_current->_transitionDone || (_trans && _trans->_done)) phaseEnd(); return; } checkDone(); if (!scenes2show.empty()) checkShow(); if (_transition) return; if (_wasBackBlocked && !scenes.empty()) { _wasBackBlocked = false; spScene current = scenes.back(); Event ev(Scene::EVENT_BACK); current->dispatchEvent(&ev); checkDone(); } }
static void searching_ball(Info * info) { info->sched_var.count ++; //mylogfd(SCHFD, "count = %d\n", info->sched_var.count); if (IsDoorSeen(info)) { if (getDoorMidx(info) != 0 && getDoorMidx(info) < info->sched_var.door_dis) { info->sched_var.door_dis = getDoorMidx(info); info->sched_var.door_count = info->sched_var.count; } } if (getGreenSum(info) > info->sched_var.max_green_sum) { info->sched_var.max_green_sum = getGreenSum(info); info->sched_var.max_green_count = info->sched_var.count; } if (IsBallSeen(info)) { mylogfd(SCHFD, "[sche]search_ball->forwarding_ball\n"); info->last_cmd = CMD_FORWARD; info->state = FORWARDING_BALL; mylogfd(SCHFD,"[sche]left %d %d %d %d, right %d %d %d %d\n", info->video_info->is_ball_seen, info->video_info->is_ball_acc, info->video_info->ball_acc_pos.x, info->video_info->ball_acc_pos.y, info->video_info2->is_ball_seen, info->video_info2->is_ball_acc, info->video_info2->ball_acc_pos.x, info->video_info2->ball_acc_pos.y); info->destP.x = gety(info); info->destP.y = - getx(info); if (!info->video_info->is_ball_acc && !info->video_info2->is_ball_acc) { info->destP.x = 100; info->destP.y = 0; } do_forward(info, DEFAULT_A); return; } if (info->sched_var.count >= 90 || checkDone()) { mylogfd(SCHFD, "[sche]searching_ball->change_place checkdone\n"); info->state = CHANGE_PLACE; do_search_ball(info, info->sched_var.search_dir); return; } }
void PlayerQuests::addQuest(int16_t questid, int32_t npcid) { QuestsPacket::acceptQuest(m_player, questid, npcid); addQuest(questid); giveRewards(questid, true); checkDone(m_quests[questid]); }
void InspectorResourceContentLoader::ensureResourcesContentLoaded(VoidCallback* callback) { if (!m_started) start(); m_callbacks.append(callback); checkDone(); }
// // XIDamageEffect::evolve // // Damage utilizes both motors to do effects that decay at different rates. // void XIDamageEffect::evolve(XINPUT_VIBRATION &xvib, uint32_t curTime) { if(checkDone(curTime)) { delete this; return; } // Do left motor processing DWORD endStrength = strength * 40 / 64; DWORD deltaStrength = (strength - endStrength); DWORD curStrength = strength - deltaStrength * (curTime - startTime) / duration; AddClamped(xvib, MOTOR_LEFT, static_cast<WORD>(curStrength)); // Do right motor processing if(curTime - startTime < duration / 2) { // Right motor is constant during first half of effect AddClamped(xvib, MOTOR_RIGHT, strength / 2); } else { // Linear descent to zero curStrength = strength / 2; curStrength -= curStrength * (curTime - startTime) / duration; AddClamped(xvib, MOTOR_RIGHT, static_cast<WORD>(curStrength)); } }
// // XILinearEffect::evolve // // A linear effect ramps up or down from the initial value to the end value // over a set course of time. // void XILinearEffect::evolve(XINPUT_VIBRATION &xvib, uint32_t curTime) { if(checkDone(curTime)) { delete this; return; } WORD curStrength; if(direction < 0) { // slope down WORD deltaStrength = (initStrength - endStrength); curStrength = initStrength - deltaStrength * (curTime - startTime) / duration; } else { // slope up WORD deltaStrength = (endStrength - initStrength); curStrength = initStrength + deltaStrength * (curTime - startTime) / duration; } AddClamped(xvib, which, curStrength); }
static void moving(Info * info) { if (checkDone()) { mylogfd(SCHFD, "[sche]checkDone moving\n"); info->state = FACE_DOOR; return; } if (!IsBallCatch(info)) { do_stop(info); info->state = SEARCH_BALL; return; } mylogfd(SCHFD,"MOVING"); /*static int step = 0; if (step == 1 && checkDone()) { step = 0; info->state = BALL_CATCHED; do_rota_with_ball(info, 360, 1); return; } if (step == 0 && checkDone()) { step = 1; info->destP.y = 70; info->destP.x = 0; do_catch_ball(info); return; }*/ }
static void changing_place(Info * info) { if (checkDone()) { mylogfd(SCHFD, "[sche]checkDone changing_place \n"); info->state = SEARCH_BALL; mylogfd(SCHFD, "[sche]changing_place->search_ball\n"); } }
// // XIConstantEffect::evolve // // Pulse the motor at a constant strength. Due to the behavior of the XBox360 // controller's non-solenoid motors however, there's a bit of "catch" which // adds some unavoidable pseudo-random variance into the mix. Depending on // where it stopped last time, you get no response at all until it seems to // "roll over" the catch, at which point you get more than you asked for. // void XIConstantEffect::evolve(XINPUT_VIBRATION &xvib, uint32_t curTime) { if(checkDone(curTime)) { delete this; return; } AddClamped(xvib, which, strength); }
void InspectorResourceContentLoader::ensureResourcesContentLoaded( int clientId, std::unique_ptr<WTF::Closure> callback) { if (!m_started) start(); m_callbacks.add(clientId, Callbacks()) .storedValue->value.append(std::move(callback)); checkDone(); }
void InspectorResourceContentLoader::stop() { HashSet<ResourceClient*> pendingResourceClients; m_pendingResourceClients.swap(pendingResourceClients); for (const auto& client : pendingResourceClients) client->m_loader = nullptr; m_resources.clear(); // Make sure all callbacks are called to prevent infinite waiting time. checkDone(); }
void InspectorResourceContentLoader::stop() { HeapHashSet<Member<ResourceClient>> pendingResourceClients; m_pendingResourceClients.swap(pendingResourceClients); for (const auto& client : pendingResourceClients) client->m_loader = nullptr; m_resources.clear(); // Make sure all callbacks are called to prevent infinite waiting time. checkDone(); m_allRequestsStarted = false; m_started = false; }
void Feld::done () { if (moving) return; emitStatus(); if (checkDone()) emit gameOver(moves); }
static void protect_door(Info * info) { static int angle = 180; if (IsBallSeen(info)) { do_stop(info); } if (checkDone()) { do_rota(info, angle, 1); angle = -angle; } }
void Quest::setPartsDone(int partsDone) { if (hasSubquests()) return; if( partsDone != mPartsDone ) { mPartsDone = partsDone; notify(QuestEvent::QUEST_PARTSDONE); checkDone(); } }
void Quest::increasePartsDone(int parts) { if (hasSubquests()) return; if (parts != 0) { mPartsDone += parts; notify(QuestEvent::QUEST_PARTSDONE); checkDone(); } }
bool JabberBrowser::checkDone(QListViewItem *item) { if (!item->text(COL_ID_DISCO_ITEMS).isEmpty() || !item->text(COL_ID_DISCO_INFO).isEmpty() || !item->text(COL_ID_BROWSE).isEmpty()){ return false; } for (item = item->firstChild(); item; item = item->nextSibling()){ if (!checkDone(item)) return false; } return true; }
// // XIRumbleEffect::evolve // // The rumble effect is entirely chaotic within a given min to max range. // void XIRumbleEffect::evolve(XINPUT_VIBRATION &xvib, uint32_t curTime) { if(checkDone(curTime)) { delete this; return; } int minStr = minStrength; int rndStr = abs(rand()) % (maxStrength - minStrength); WORD totStr = static_cast<WORD>(minStr + rndStr); AddClamped(xvib, which, totStr); }
static void start(Info * info){ mylogfd(SCHFD, "[sche]start\n"); info->destP.x = gety(info)+100; info->destP.y = getx(info)+POSITI*200; do_run(info); if(IsBallSeen(info)) info->state = FORWARDING_BALL; if(checkDone()) info->state = SEARCH_BALL; /* if(checkDone()) { mylogfd(SCHFD, "[sche]rotate_end\n"); // do_forward -- redwalker if(checkDone()){ info->state = SEARCH_BALL; mylogfd(SCHFD,"[sche]start->search_ball\n"); }*/ }
static void searching_adjust(Info * info) { if (IsMiddle(info)) { mylogfd(SCHFD, "[sche]searching_adjust->forwarding_ball\n"); info->last_cmd = CMD_STOP; info->state = FORWARDING_BALL; do_stop(info); return; } if (checkDone()) { mylogfd(SCHFD, "[sche]checkDone searching_adjust\n"); mylogfd(SCHFD, "[sche]searching_adjust->SEARCH_BALL\n"); //info->last_cmd = CMD_STOP; info->state = SEARCH_BALL; // do_stop(info); return; } }
char serialConfig(unsigned char * buffer, unsigned int length){ unsigned long int i ; unsigned long int timer = 0; clearClk(); setProgramm(); __delay_cycles(10*CONFIG_CYCLES); clearProgramm(); __delay_cycles(5*CONFIG_CYCLES); while(checkInit() > 0 && timer < 200) timer ++; // waiting for init pin to go down if(timer >= 200){ printf("Init pin not going down !"); setProgramm(); return -1; } timer = 0; __delay_cycles(5*CONFIG_CYCLES); #ifndef MARK1 setProgramm(); while(checkInit() == 0 && timer < 0xFFFFFF){ timer ++; // waiting for init pin to go up } if(timer >= 0xFFFFFF){ printf("Init pin not going high ! \n"); return -1; } #endif timer = 0; printf("Starting configuration ! \n"); for(i = 0 ; i < length ; i ++){ serialConfigWriteByte(buffer[i]); } while(timer < 50){ clearClk(); __delay_cycles(CONFIG_CYCLES); setClk(); timer ++ ; } clearClk(); clearDout(); if(!checkDone() && timer >= 255){ printf("Done pin not going high ! \n"); return -1; } return 1 ; }
static void forwarding_ball(Info * info) { if (IsRight(info)) info->sched_var.search_dir = -2; if (IsLeft(info)) info->sched_var.search_dir = 2; if (IsBallCatch(info)) { mylogfd(SCHFD, "[sche]forwarding_ball->ball_catched\n"); info->last_cmd = CMD_STOP; info->state = BALL_CATCHED; info->sched_var.doorseen = 0; do_stop(info); // delet // -- redwalker if (!IsDoorSeen(info)) do_rota_with_ball(info, POSITI*360, 1); return; } if (!IsBallSeen(info)) { mylogfd(SCHFD, "[sche]forwarding_ball->stop when lose ball\n"); info->state = SEARCH_BALL; do_stop(info); return; } /* else if (IsBallVeryNear(info)) { mylogfd(SCHFD, "[sche]catching_ball->forwarding_ball\n"); info->state = CATCHING_BALL; info->destP.x = gety(info); iinfo->destP.y = -getx(info); do_catch_ball(info); }*/ if (IsMiddle(info)) { do_adjust(-1); } if (IsLeft(info)) { do_adjust(1); } if (IsRight(info)) { do_adjust(0); } if (checkDone ()) { mylogfd(SCHFD, "[sche]checkDone forwarding_ball\n"); info->state = SEARCH_BALL; mylogfd(SCHFD, "[sche]forwarding_ball->SEARCH_BALL\n"); return; } }
void Quest::setState(Quest::State state) { if( mState != state ) { mState = state; notify(QuestEvent::QUEST_STATE); if (state == Quest::OPEN && mParent != NULL && mParent->getState() == Quest::UNKNOWN) { mParent->setState(Quest::OPEN); } if( mState == Quest::COMPLETED || mState == Quest::SUCCEEDED) mParent->checkDone(); else checkDone(); } }
void PlayerQuests::updateQuestMob(int32_t mobid) { if (m_mobtoquest.find(mobid) != m_mobtoquest.end()) { int16_t qid = 0; ActiveQuest q; Quest *realquest; for (size_t i = 0; i < m_mobtoquest[mobid].size(); i++) { qid = m_mobtoquest[mobid][i]; q = m_quests[qid]; realquest = QuestDataProvider::Instance()->getInfo(qid); int16_t maxcount = realquest->getMobRequestQuantity(mobid); if (!q.done && q.kills[mobid] < maxcount) { q.kills[mobid] += 1; QuestsPacket::updateQuest(m_player, q); if (q.kills[mobid] == maxcount) { checkDone(q); } m_quests[qid] = q; } } } }
static void catching_ball(Info* info) { if (IsBallCatch(info)) { mylogfd(SCHFD, "[sche]State changing:catching_ball->ball_catched\n"); info->state = BALL_CATCHED; info->sched_var.doorseen = 0; info->sched_var.waitlost = 3; do_stop(info); if (!IsDoorSeen(info)) do_rota_with_ball(info, -POSITI*360, 1); // get in a paramiter -- redwalker } else if (!IsBallAllSeen(info)) { mylogfd(SCHFD, "[sche]catching_ball->SEARCH_BALL\n"); info->state = SEARCH_BALL; do_stop(info); } else if (!IsBallVeryNear(info)) { mylogfd(SCHFD, "[sche]catching_ball->forwarding_ball\n"); info->state = FORWARDING_BALL; info->destP.x = gety(info); info->destP.y = - getx(info); do_forward(info, DEFAULT_A); } else if (checkDone()) { mylogfd(SCHFD,"[sche]checkDone catching_ball \n"); info->last_cmd = CMD_CATCH_BALL; info->destP.x = gety(info); info->destP.y = - getx(info); do_catch_ball(info); } if (IsMiddle(info)) { do_adjust(-1); } if (IsLeft(info)) { do_adjust(1); } if (IsRight(info)) { do_adjust(0); } }
static void shooting(Info* info) { if (checkDone()) { mylogfd(SCHFD, "[sche]checkDone shooting\n"); mylogfd(SCHFD, "[sche]shooted\n"); // do_adjust(-1); do_stop(info); // info->destP.x = -100; // info->destP.y = 0; // do_forward(info, DEFAULT_A); info->state = SHOOTED; return; } mylogfd(SCHFD, "shooting green %d\n", (info->video_info->green_sum + info->video_info->green_sum) / 2); if ((info->video_info->green_sum + info->video_info->green_sum) / 2 < 3500) { mylogfd(SCHFD, "[sche]door arrived then shooted\n"); do_stop(info); info->state = SHOOTED; return; } if (IsDoorLeft(info)) { do_adjust(1); } else if (IsDoorRight(info)) { do_adjust(0); } else if (IsDoorMiddle(info)) { do_adjust(-1); } if (!IsBallCatch(info)) { mylogfd(SCHFD, "shooting->search_ball when lose ball\n"); do_stop(info); info->state = SEARCH_BALL; } if (!IsDoorSeen(info)) { mylogfd(SCHFD, "shooting->ball_catched when lose door %d %d\n", info->video_info->is_door_seen, info->video_info2->is_door_seen); do_stop(info); info->state = BALL_CATCHED; } }
static void face_door(Info * info) { if (!IsBallCatch(info)) { mylogfd(SCHFD, "[sche]lose ball\n"); info->state = SEARCH_BALL; do_stop(info); return; } if (getDoorRightx(info) * getDoorMidx(info) < 0) { int cx = 0; int x1 = getDoorMidx(info); int y1 = getDoorMidy(info); int x2 = getDoorRightx(info); int y2 = getDoorRighty(info); int cy = abs(x1) * y1 / (abs(x1) + abs(x2)) + abs(x2) * y2 / (abs(x1) + abs(x2)); int d1 = Distance(getDoorRightx(info), getDoorRighty(info), getRobotX(info), getRobotY(info)); int d2 = Distance(getRobotX(info), getRobotY(info), cx, cy); int d = Distance(x2, y2, cx, cy); mylogfd(SCHFD, "right x1 = %d y1 = %d x2 = %d y2 = %d cy = %d d1 = %d d2 = %d d = %d %d\n", x1, y1, x2, y2, cy, d1, d2, d, getRobotX(info)); mylogfd(SCHFD, "robot=%d door=%d\n", getRobotX(info), getDoorMidx(info)); if (!IsRobotSeen(info) || getRobotX(info) <= getDoorMidx(info)) { // do_stop(info); info->state = SHOOTING; info->destP.x = cy + 100; info->destP.y = - getDoorRightx(info) + 5; do_forward(info, MAX_A); return; } } if (getDoorLeftx(info) * getDoorMidx(info) < 0) { int cx = 0; int x1 = getDoorMidx(info); int y1 = getDoorMidy(info); int x2 = getDoorLeftx(info); int y2 = getDoorLefty(info); int cy = abs(x1) * y1 / (abs(x1) + abs(x2)) + abs(x2) * y2 / (abs(x1) + abs(x2)); int d1 = Distance(getDoorLeftx(info), getDoorLefty(info), getRobotX(info), getRobotY(info)); int d2 = Distance(getRobotX(info), getRobotY(info), cx, cy); int d = Distance(x2, y2, cx, cy); mylogfd(SCHFD, "left:x1 = %d y1 = %d x2 = %d y2 = %d cy = %d d1 = %d d2 = %d d = %d %d\n", x1, y1, x2, y2, cy, d1, d2, d, getRobotX(info)); mylogfd(SCHFD, "robot=%d door = %d\n", getRobotX(info), getDoorMidx(info)); if (!IsRobotSeen(info) || getRobotX(info) >= getDoorMidx(info)) { info->state = SHOOTING; //do_stop(info); info->state = SHOOTING; info->destP.x = cy + 100; info->destP.y = - getDoorLeftx(info) - 5; do_forward(info, MAX_A); // adjust while shooting -- redwalker if (!IsBallCatch(info)) { mylogfd(SCHFD, "[sche]lose ball\n"); info->state = SEARCH_BALL; do_stop(info); return; } if (IsDoorMiddle(info)) { do_adjust(-1); } if (IsDoorLeft(info)) { do_adjust(1); } if (IsDoorRight(info)) { do_adjust(0); } return; } } if (checkDone()) { mylogfd(SCHFD,"[sche]checkDone face_door\n"); info->sched_var.search_door_dir = -info->sched_var.search_door_dir; do_rota_with_ball(info, 90 * info->sched_var.search_door_dir, 1); return; } }
static void obstacle(Info * info) { if (checkDone()) { info->state = SEARCH_BALL; } }
void InspectorResourceContentLoader::start() { m_started = true; Vector<Document*> documents; for (Frame* frame = m_inspectedFrame; frame; frame = frame->tree().traverseNext(m_inspectedFrame)) { if (!frame->isLocalFrame()) continue; LocalFrame* localFrame = toLocalFrame(frame); documents.append(localFrame->document()); documents.appendVector(InspectorPageAgent::importsForFrame(localFrame)); } for (Document* document : documents) { HashSet<String> urlsToFetch; ResourceRequest resourceRequest; HistoryItem* item = document->frame() ? document->frame()->loader().currentItem() : nullptr; if (item) { resourceRequest = FrameLoader::requestFromHistoryItem(item, ReturnCacheDataDontLoad); } else { resourceRequest = document->url(); resourceRequest.setCachePolicy(ReturnCacheDataDontLoad); } resourceRequest.setRequestContext(blink::WebURLRequest::RequestContextInternal); if (!resourceRequest.url().string().isEmpty()) { urlsToFetch.add(resourceRequest.url().string()); FetchRequest request(resourceRequest, FetchInitiatorTypeNames::internal); ResourcePtr<Resource> resource = document->fetcher()->fetchRawResource(request); if (resource) { // Prevent garbage collection by holding a reference to this resource. m_resources.append(resource.get()); ResourceClient* resourceClient = new ResourceClient(this); m_pendingResourceClients.add(resourceClient); resourceClient->waitForResource(resource.get()); } } WillBeHeapVector<RawPtrWillBeMember<CSSStyleSheet> > styleSheets; InspectorCSSAgent::collectAllDocumentStyleSheets(document, styleSheets); for (CSSStyleSheet* styleSheet : styleSheets) { if (styleSheet->isInline() || !styleSheet->contents()->loadCompleted()) continue; String url = styleSheet->baseURL().string(); if (url.isEmpty() || urlsToFetch.contains(url)) continue; urlsToFetch.add(url); FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::internal); request.mutableResourceRequest().setRequestContext(blink::WebURLRequest::RequestContextInternal); ResourcePtr<Resource> resource = document->fetcher()->fetchCSSStyleSheet(request); if (!resource) continue; // Prevent garbage collection by holding a reference to this resource. m_resources.append(resource.get()); ResourceClient* resourceClient = new ResourceClient(this); m_pendingResourceClients.add(resourceClient); resourceClient->waitForResource(resource.get()); } } m_allRequestsStarted = true; checkDone(); }
void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) { m_pendingResourceClients.remove(client); checkDone(); }