unsigned int Worker::loop() { for(;;) { // notify the boss that you are going into idle state. if (NULL != boss) boss->OnWorkerGoingIdle(*this); if (NULL == job) // there is no assigned job, then go on into idle state. { setIdle(true); assignmentControl->WaitForSingleObject(); setIdle(false); } if (IsSuiciding()) // if suicide was activated then perform it before starting the job. break; if (NULL != job) { perform(*job); if (NULL != boss) boss->OnWorkerDone(*this, *job); job = NULL; // done with this job. } if (IsSuiciding()) // before going idle check if the worker is asked to suicide. break; } return 0; }
void NPC::update (uint32_t deltaTime) { IEntity::update(deltaTime); if (isDying()) return; if (_dazedTime > 0 && _time - _dazedTime > _dazedTimeout) { if (_lastDirectionRight) setAnimationType(Animations::ANIMATION_WAKEUP_RIGHT); else setAnimationType(Animations::ANIMATION_WAKEUP_LEFT); const int length = SpriteDefinition::get().getAnimationLength(_type, getAnimationType()); if (length > 0) { TimeManager& t = _map.getTimeManager(); _idleTimer = t.setTimeout(length, this, &NPC::setIdle); } _dazedTime = 0; } if (isMoving()) { const float xPos = getPos().x; static const float gap = 0.1f; if (Between(xPos, _targetPos.x - gap, _targetPos.x + gap)) { // target reached setIdle(); } } else if (isDazed() || isIdle()) { setLinearVelocity(b2Vec2_zero); } }
void Monster::updateIdleStatus() { //heightMinimum is declared static to avoid //several calls for getNumber (updateIdleStatus is called often) static int heightMinimum = 0; if (heightMinimum <= 0) heightMinimum = std::max(g_config.getNumber(ConfigManager::HEIGHT_MINIMUM_FOR_IDLE),(int64_t)1); bool idle = false; semiIdle = false; if(conditions.empty()){ if(isSummon()){ if(!isMasterInRange){ idle = true; } else if(getMaster()->getMonster() && getMaster()->getMonster()->getIdleStatus()){ idle = true; } } else{ idle = targetList.empty(); semiIdle = !idle; for(CreatureList::iterator it = targetList.begin(); it != targetList.end(); ++it){ if (std::abs((*it)->getPosition().z - getPosition().z) < heightMinimum) { semiIdle = false; break; } } } } setIdle(idle); }
void keyEvent(rfbBool down, rfbKeySym key, rfbClientPtr cl) { int code; // L("Got keysym: %04x (down=%d)\n", (unsigned int)key, (int)down); setIdle(0); int sh = 0; int alt = 0; if ( inputfd == -1 ) return; if ((code = keysym2scancode(down, key, cl,&sh,&alt))) { int ret=0; if (key && down) { if (sh) suinput_press(inputfd, 42); //left shift if (alt) suinput_press(inputfd, 56); //left alt ret=suinput_press(inputfd,code); ret=suinput_release(inputfd,code); if (alt) suinput_release(inputfd, 56); //left alt if (sh) suinput_release(inputfd, 42); //left shift } else ;//ret=suinput_release(inputfd,code); // L("injectKey (%d, %d) ret=%d\n", code , down,ret); } }
void Npc::updateIdleStatus() { bool status = spectators.empty(); if (status != isIdle) { setIdle(status); } }
AutoMateUi::AutoMateUi(QWidget* parent) : QMainWindow(parent), logWatcher(NULL), applications_model(NULL), tweaks_model(NULL), selectedApplicationCount(0), last_database_location(CONFIG.database()) { setupUi(this); setIdle(); // Proxy models. must be ready before loading models. appsProxyModel = new QSortFilterProxyModel(this); tweaksProxyModel = new QSortFilterProxyModel(this); // Reload models reloadModels(); // Watch log file logWatcher = new TextFileWatcher(Logger::path(), log_browser); config = new ConfigurationUi(this); // Rearrange toolbar order // file_toolBar, action_toolBar addToolBar(Qt::TopToolBarArea, file_toolBar); addToolBarBreak(Qt::TopToolBarArea); addToolBar(Qt::TopToolBarArea, action_toolBar); connectUi(); actionsConnect(); }
void Actor::changeHealth(int32_t healthChange) { //In case a player with ignore flag set attacks the monster setIdle(false); Creature::changeHealth(healthChange); }
void OscarConnection::finishLogin() { setState(Connected); sendUserInfo(true); m_is_idle = true; setIdle(false); SNAC snac(ServiceFamily, ServiceClientReady); // imitate ICQ 6 behaviour snac.append(QByteArray::fromHex( "0022 0001 0110 164f" "0001 0004 0110 164f" "0013 0004 0110 164f" "0002 0001 0110 164f" "0003 0001 0110 164f" "0015 0001 0110 164f" "0004 0001 0110 164f" "0006 0001 0110 164f" "0009 0001 0110 164f" "000a 0001 0110 164f" "000b 0001 0110 164f")); send(snac); m_account->finishLogin(); if (m_account->d_func()->name.isEmpty()) { ShortInfoMetaRequest *req = new ShortInfoMetaRequest(m_account); // Requesting own information. connect(req, SIGNAL(done(bool)), this, SLOT(accountInfoReceived(bool))); req->send(); }
mp_sint32 PlayerBase::kick() { // if the player hasn't been initialized until now => DO IT if (!isInitialized()) { mp_sint32 err = initDevice(); if (err != MP_OK) { return err; } } // - configure player: -------------- // playing => song is not paused yet paused = false; // playing => song has not stopped yet halted = false; // set idle mode setIdle(idle); // - configure mixer: --------------- // mixer reset resetChannelsWithoutMuting(); // start playing (mixer flag) startPlay = true; // mix buffers startMixer(); // reset sample counters sampleCounter = 0; return MP_OK; }
void ST7735::init() { reset(); setSleep(false); setInverse(false); setIdle(false); on(); }
void Actor::alwaysThink(bool b) { alwaysThink_ = b; if(alwaysThink()) setIdle(false); else updateIdleStatus(); }
void Monster::onThink(uint32_t interval) { Creature::onThink(interval); if(despawn()) { g_game.removeCreature(this, true); setIdle(true); return; } updateIdleStatus(); if(isIdle) return; if(teleportToMaster && doTeleportToMaster()) teleportToMaster = false; addEventWalk(); if(getMaster()){ if(getPosition().z != getMaster()->getPosition().z){ g_game.internalTeleport(this, getMaster()->getPosition(), false); //g_game.addMagicEffect(getPosition(), MAGIC_EFFECT_SOUND_YELLOW); } } if(isSummon()) { if(!attackedCreature) { std::string strValue; if(getMaster() && getMaster()->getAttackedCreature()) //This happens if the monster is summoned during combat selectTarget(getMaster()->getAttackedCreature()); else{ setFollowCreature((getMaster()->getStorage(500, strValue) && strValue != "-1") ? NULL : getMaster()); } } else if(attackedCreature == this) setFollowCreature(NULL); else if(followCreature != attackedCreature) //This happens just after a master orders an attack, so lets follow it aswell. setFollowCreature(attackedCreature); } else if(!targetList.empty()) { if(!followCreature || !hasFollowPath) searchTarget(); else if(isFleeing() && attackedCreature && !canUseAttack(getPosition(), attackedCreature)) searchTarget(TARGETSEARCH_ATTACKRANGE); } onThinkTarget(interval); onThinkYell(interval); onThinkDefense(interval); }
void Monster::onThink(uint32_t interval) { Creature::onThink(interval); if(despawn()) { g_game.internalTeleport(this, masterPos); setIdle(true); } else { updateIdleStatus(); if(!isIdle) { addEventWalk(); if(isSummon()) { if(!attackedCreature) { if(getMaster() && getMaster()->getAttackedCreature()) { ///This happens if the monster is summoned during combat selectTarget(getMaster()->getAttackedCreature()); } else if(getMaster() != followCreature) { //Our master has not ordered us to attack anything, lets follow him around instead. setFollowCreature(getMaster()); } } else if(attackedCreature == this) setFollowCreature(NULL); else if(followCreature != attackedCreature) { //This happens just after a master orders an attack, so lets follow it aswell. setFollowCreature(attackedCreature); } } else if(!targetList.empty()) { if(!followCreature || !hasFollowPath) searchTarget(); else if(isFleeing()) { if(attackedCreature && !canUseAttack(getPosition(), attackedCreature)) searchTarget(TARGETSEARCH_ATTACKRANGE); } } onThinkTarget(interval); onThinkYell(interval); onThinkDefense(interval); } } }
ByteArray UDPInternalConnection::receiveImpl(unsigned long size) { if (readyForRead() == 0) { if (!isPending()) setPending(); else throw netman::SockConnectionError("Already pending"); std::unique_lock<std::mutex> lock(syncMutex); waitVar.wait(lock, [&] {return !isPending();}); if (isTimedOut()) { setIdle(); throw netman::SockRecieveFailed("Operation timeout"); } else setIdle(); } return readBuffer(); }
void Monster::updateIdleStatus() { bool idle = false; if (conditions.empty()) { if (!isSummon() && targetList.empty()) { idle = true; } } setIdle(idle); }
void Monster::onCreatureDisappear(const Creature* creature, bool isLogout) { Creature::onCreatureDisappear(creature, isLogout); if(creature == this) { if(spawn) spawn->startEvent(); setIdle(true); } else onCreatureLeave(const_cast<Creature*>(creature)); }
void Monster::onCreatureDisappear(const Creature* creature, uint32_t stackpos, bool isLogout) { Creature::onCreatureDisappear(creature, stackpos, isLogout); if(creature == this) { if(spawn) spawn->startSpawnCheck(); setIdle(true); } else onCreatureLeave(const_cast<Creature*>(creature)); }
bool CNextion::open() { bool ret = m_serial.open(); if (!ret) { LogError("Cannot open the port for the Nextion display"); return false; } sendCommand("bkcmd=0"); setIdle(); return true; }
void Actor::onCreatureDisappear(const Creature* creature, bool isLogout) { Creature::onCreatureDisappear(creature, isLogout); if(creature == this){ if(spawn){ spawn->startSpawnCheck(); } setIdle(true); } else{ onCreatureLeave(const_cast<Creature*>(creature)); } }
void Monster::updateIdleStatus() { bool idle = false; if(conditions.empty()) { if(isSummon()) { if(!isMasterInRange || (getMaster()->getMonster() && getMaster()->getMonster()->getIdleStatus())) idle = true; } else if(targetList.empty()) idle = true; } setIdle(idle); }
void UDPInternalConnection::notifyReceive() { auto packet = socket_->readDataFrom(); //data:address //if (packet.second == this->host_address_) { // Если мы получили данные от хоста, с которым работаем - читаем пакет // Иначе - отбрасываем как некорректный appendBuffer(packet.first); if (isPending()) { setIdle(); waitVar.notify_one(); } //} }
void Monster::updateIdleStatus() { bool idle = false; if(conditions.empty()) { if(isSummon()) { if((!isMasterInRange && !teleportToMaster) || (master->getMonster() && master->getMonster()->getIdleStatus())) idle = true; } else if(targetList.empty()) idle = true; } setIdle(idle); }
bool CTFTSerial::open() { bool ret = m_serial.open(); if (!ret) { LogError("Cannot open the port for the TFT Serial"); return false; } // Set background white m_serial.write((unsigned char*)"\x1B\x02\x07\xFF", 4U); // Set foreground black m_serial.write((unsigned char*)"\x1B\x01\x00\xFF", 4U); setIdle(); return true; }
/** * Draws the enemy image */ void MeleeEnemy::draw() { if (mDrawDirection == 1) { Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_FLIP_X); } CIwSVec2 screenCentre = CIwSVec2((int16)Iw2DGetSurfaceWidth() >> 1, (int16)Iw2DGetSurfaceHeight() >> 1); b2Transform t = mBody->GetTransform(); CIwSVec2 pos = screenCentre + (CIwSVec2(int16(t.p.x*8), -int16(t.p.y*8))); float normalRegionHeight = (52.0f/100.0f) * ((mHealth/mMaxHealth)*100.0f); float hurtRegionHeight = 52.0f - normalRegionHeight; CIwColour col; col.Set(255, 50, 50); Iw2DSetColour(col); Iw2DDrawImageRegion(mImg, pos - CIwSVec2((mFrameWidth/1.5)*mSpriteScale, ((52/2)*mSpriteScale)), CIwSVec2(mFrameWidth*1.5, hurtRegionHeight*mSpriteScale), CIwSVec2(mFrame, mVerFrame), CIwSVec2(mFrameWidth, hurtRegionHeight)); col.Set(255, 255, 255); Iw2DSetColour(col); Iw2DDrawImageRegion(mImg, pos - CIwSVec2((mFrameWidth/1.5)*mSpriteScale, (((52/2)*mSpriteScale))-hurtRegionHeight), CIwSVec2(mFrameWidth*1.5, normalRegionHeight*mSpriteScale), CIwSVec2(mFrame, hurtRegionHeight+mVerFrame), CIwSVec2(mFrameWidth, normalRegionHeight)); if(mFrameDelay <= 0) { mFrame += (mFrameWidth); if (mFrame > (mFrameCount*mFrameWidth)) { //setIdle(); mFrame = 0; if(punching) { setIdle(); mPunchTimer = 10.0f; } } mFrameDelay = 5; } mFrameDelay--; Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_NONE); }
bool CTFTSerial::open() { bool ret = m_serial.open(); if (!ret) { LogError("Cannot open the port for the TFT Serial"); return false; } setRotation(ROTATION_LANDSCAPE); setBrightness(m_brightness); setBackground(COLOUR_WHITE); setForeground(COLOUR_BLACK); setIdle(); return true; }
/** * Closes a connection */ void TNonblockingServer::TConnection::close() { setIdle(); if (serverEventHandler_) { serverEventHandler_->deleteContext(connectionContext_, inputProtocol_, outputProtocol_); } ioThread_ = NULL; // Close the socket tSocket_->close(); // close any factory produced transports factoryInputTransport_->close(); factoryOutputTransport_->close(); // release processor and handler processor_.reset(); // Give this object back to the server that owns it server_->returnConnection(this); }
void Monster::onRemoveCreature(Creature* creature, bool isLogout) { Creature::onRemoveCreature(creature, isLogout); if (mType->info.creatureDisappearEvent != -1) { // onCreatureDisappear(self, creature) LuaScriptInterface* scriptInterface = mType->info.scriptInterface; if (!scriptInterface->reserveScriptEnv()) { std::cout << "[Error - Monster::onCreatureDisappear] Call stack overflow" << std::endl; return; } ScriptEnvironment* env = scriptInterface->getScriptEnv(); env->setScriptId(mType->info.creatureDisappearEvent, scriptInterface); lua_State* L = scriptInterface->getLuaState(); scriptInterface->pushFunction(mType->info.creatureDisappearEvent); LuaScriptInterface::pushUserdata<Monster>(L, this); LuaScriptInterface::setMetatable(L, -1, "Monster"); LuaScriptInterface::pushUserdata<Creature>(L, creature); LuaScriptInterface::setCreatureMetatable(L, -1, creature); if (scriptInterface->callFunction(2)) { return; } } if (creature == this) { if (spawn) { spawn->startSpawnCheck(); } setIdle(true); } else { onCreatureLeave(creature); } }
mp_sint32 PlayerBase::kick() { // if the player hasn't been initialized until now => DO IT if (!isInitialized()) { mp_sint32 err = initDevice(); if (err!=0) { return err; } } // - configure player: -------------- // playing => song is not paused yet paused = false; // playing => song has not stopped yet halted = false; // repeat mode this->repeat = repeat; // set idle mode setIdle(idle); // - configure mixer: --------------- // mixer reset resetChannelsWithoutMuting(); // start playing (mixer flag) startPlay = true; // mix buffers startMixer(); //SetThreadPriority(hThread,THREAD_PRIORITY_NORMAL); // reset sample counters sampleCounter = 0; return 0; }
void ptrEvent(int buttonMask, int x, int y, rfbClientPtr cl) { static int leftClicked=0,rightClicked=0,middleClicked=0; if ( inputfd == -1 ) return; setIdle(0); transformTouchCoordinates(&x,&y,cl->screen->width,cl->screen->height); if((buttonMask & 1)&& leftClicked) {//left btn clicked and moving static int i=0; i=i+1; if (i%10==1)//some tweak to not report every move event { suinput_write(inputfd, EV_ABS, ABS_X, x); suinput_write(inputfd, EV_ABS, ABS_Y, y); suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); } } else if (buttonMask & 1)//left btn clicked { leftClicked=1; suinput_write(inputfd, EV_ABS, ABS_X, x); suinput_write(inputfd, EV_ABS, ABS_Y, y); suinput_write(inputfd,EV_KEY,BTN_TOUCH,1); suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); } else if (leftClicked)//left btn released { leftClicked=0; suinput_write(inputfd, EV_ABS, ABS_X, x); suinput_write(inputfd, EV_ABS, ABS_Y, y); suinput_write(inputfd,EV_KEY,BTN_TOUCH,0); suinput_write(inputfd, EV_SYN, SYN_REPORT, 0); } if (buttonMask & 4)//right btn clicked { rightClicked=1; suinput_press(inputfd,158); //back key } else if (rightClicked)//right button released { rightClicked=0; suinput_release(inputfd,158); } if (buttonMask & 2)//mid btn clicked { middleClicked=1; suinput_press( inputfd,KEY_END); } else if (middleClicked)// mid btn released { middleClicked=0; suinput_release( inputfd,KEY_END); } }
void ActualIdleDetector::handleTimerTick() { timer->stop(); setIdle(querier->getIdleTimeSeconds() >= getIdleTimeSeconds()); timer->start(); }