bool Monster::convince(const CreatureP& convincer, bool forced) { assert(convincer != nullptr); if (!canBeConvincedBy(convincer, forced)) { return false; } setMaster(convincer); return true; }
void Creature::onRemoveCreature(Creature* creature, bool) { onCreatureDisappear(creature, true); if (creature == this) { if (master && !master->isRemoved()) { setMaster(nullptr); } } else if (isMapLoaded) { if (creature->getPosition().z == getPosition().z) { updateTileCache(creature->getTile(), creature->getPosition()); } } }
EngineMicrophone::EngineMicrophone(const ChannelHandleAndGroup& handle_group, EffectsManager* pEffectsManager) : EngineChannel(handle_group, EngineChannel::CENTER), m_pEngineEffectsManager(pEffectsManager ? pEffectsManager->getEngineEffectsManager() : NULL), m_vuMeter(getGroup()), m_pEnabled(new ControlObject(ConfigKey(getGroup(), "enabled"))), m_pPregain(new ControlAudioTaperPot(ConfigKey(getGroup(), "pregain"), -12, 12, 0.5)), m_sampleBuffer(NULL), m_wasActive(false) { if (pEffectsManager != NULL) { pEffectsManager->registerChannel(handle_group); } setMaster(false); // Use "talkover" button to enable microphones m_pSampleRate = new ControlObjectSlave("[Master]", "samplerate"); }
EngineAux::EngineAux(const char* pGroup, EffectsManager* pEffectsManager) : EngineChannel(pGroup, EngineChannel::CENTER), m_pEngineEffectsManager(pEffectsManager ? pEffectsManager->getEngineEffectsManager() : NULL), m_vuMeter(pGroup), m_pEnabled(new ControlObject(ConfigKey(pGroup, "enabled"))), m_pPassing(new ControlPushButton(ConfigKey(pGroup, "passthrough"))), m_sampleBuffer(NULL), m_wasActive(false) { if (pEffectsManager != NULL) { pEffectsManager->registerGroup(getGroup()); } m_pPassing->setButtonMode(ControlPushButton::POWERWINDOW); // Default passthrough to enabled on the master and disabled on PFL. User // can over-ride by setting the "pfl" or "master" controls. setMaster(true); setPFL(false); }
/** * Bind an instance to it's master. Instance binding consists of two steps: * <ul> * <li> Bind instance to cell </li> * <li> Bind port references to ports of the cell </li> * </ul> * * @param[in] inMaster Source Master view for this instance. * @exception Error If there is any kind of mismatch between ports etc. */ void Instance::bindToMasterView(const ViewSharedPtr& inMaster, bool inMapPortReferences) throw (Error) { if(!mMaster) { //TDB::ERROR MASTER REBINDING NOT ALLOWED } ViewSharedPtr oldMaster = getMaster(); std::map<std::string, ParameterSharedPtr> myParams; if(oldMaster) { ParameterMapSharedPtr oldParams = oldMaster->getParameters(); oldParams->getOverriddenParameters(mMyContext, myParams); oldParams->unregisterContext(mMyContext); } setMaster(inMaster); ParameterMapSharedPtr paramMap = mMaster->getParameters(); mMyContext = paramMap->getNewContext(); //We do not create params here, they will be created only when //someone asks for params //For rebinding, however, if some params were there //.. we have to override them on the new master if(!myParams.empty()) { try { paramMap->registerContext(mMyContext, mMaster->getParameterContext()); for(std::map<std::string, ParameterSharedPtr>::iterator it = myParams.begin(); it != myParams.end(); ++it) { paramMap->set(mMyContext, (*it).first, (*it).second); } } catch(Error& e) { e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__); throw; } } if(inMaster->getIsExtern()) { return; //No port binding for extern } if(inMapPortReferences) { PortMapper mapper(inMaster); try { mPortReferences.applyOnAll(mapper); } catch(Error& e) { e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__); throw; } } }
NetworkManager::ConnectionSettings::ConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &other) : d_ptr(new ConnectionSettingsPrivate(this)) { Q_D(ConnectionSettings); setId(other->id()); setUuid(other->uuid()); setInterfaceName(other->interfaceName()); setConnectionType(other->connectionType()); setPermissions(other->permissions()); setAutoconnect(other->autoconnect()); setAutoconnectPriority(other->autoconnectPriority()); setTimestamp(other->timestamp()); setReadOnly(other->readOnly()); setZone(other->zone()); setMaster(other->master()); setSlaveType(other->slaveType()); setGatewayPingTimeout(other->gatewayPingTimeout()); d->initSettings(other); }
EngineMicrophone::EngineMicrophone(const char* pGroup, EffectsManager* pEffectsManager) : EngineChannel(pGroup, EngineChannel::CENTER), m_pEngineEffectsManager(pEffectsManager ? pEffectsManager->getEngineEffectsManager() : NULL), m_clipping(pGroup), m_vuMeter(pGroup), m_pEnabled(new ControlObject(ConfigKey(pGroup, "enabled"))), m_pConversionBuffer(SampleUtil::alloc(MAX_BUFFER_LEN)), // Need a +1 here because the CircularBuffer only allows its size-1 // items to be held at once (it keeps a blank spot open persistently) m_sampleBuffer(MAX_BUFFER_LEN+1), m_wasActive(false) { if (pEffectsManager != NULL) { pEffectsManager->registerGroup(getGroup()); } // You normally don't expect to hear yourself in the headphones. Default PFL // setting for mic to false. User can over-ride by setting the "pfl" or // "master" controls. setMaster(true); setPFL(false); }
EngineMicrophone::EngineMicrophone(const char* pGroup, EffectsManager* pEffectsManager) : EngineChannel(pGroup, EngineChannel::CENTER), m_pEngineEffectsManager(pEffectsManager ? pEffectsManager->getEngineEffectsManager() : NULL), m_vuMeter(pGroup), m_pEnabled(new ControlObject(ConfigKey(pGroup, "enabled"))), m_pPregain(new ControlAudioTaperPot(ConfigKey(pGroup, "pregain"), -12, 12, 0.5)), m_sampleBuffer(NULL), m_wasActive(false) { if (pEffectsManager != NULL) { pEffectsManager->registerGroup(getGroup()); } // You normally don't expect to hear yourself in the headphones. Default PFL // setting for mic to false. User can over-ride by setting the "pfl" or // "master" controls. setMaster(true); setPFL(false); m_pSampleRate = new ControlObjectSlave("[Master]", "samplerate"); }
void Creature::onDeath() { bool lastHitUnjustified = false; bool mostDamageUnjustified = false; Creature* lastHitCreature = g_game.getCreatureByID(lastHitCreatureId); Creature* lastHitCreatureMaster; if (lastHitCreature) { lastHitUnjustified = lastHitCreature->onKilledCreature(this); lastHitCreatureMaster = lastHitCreature->getMaster(); } else { lastHitCreatureMaster = nullptr; } Creature* mostDamageCreature = nullptr; const int64_t timeNow = OTSYS_TIME(); const uint32_t inFightTicks = g_config.getNumber(ConfigManager::PZ_LOCKED); int32_t mostDamage = 0; std::map<Creature*, uint64_t> experienceMap; for (const auto& it : damageMap) { if (Creature* attacker = g_game.getCreatureByID(it.first)) { CountBlock_t cb = it.second; if ((cb.total > mostDamage && (timeNow - cb.ticks <= inFightTicks))) { mostDamage = cb.total; mostDamageCreature = attacker; } if (attacker != this) { uint64_t gainExp = getGainedExperience(attacker); if (Player* attackerPlayer = attacker->getPlayer()) { attackerPlayer->removeAttacked(getPlayer()); Party* party = attackerPlayer->getParty(); if (party && party->getLeader() && party->isSharedExperienceActive() && party->isSharedExperienceEnabled()) { attacker = party->getLeader(); } } auto tmpIt = experienceMap.find(attacker); if (tmpIt == experienceMap.end()) { experienceMap[attacker] = gainExp; } else { tmpIt->second += gainExp; } } } } for (const auto& it : experienceMap) { it.first->onGainExperience(it.second, this); } if (mostDamageCreature) { if (mostDamageCreature != lastHitCreature && mostDamageCreature != lastHitCreatureMaster) { Creature* mostDamageCreatureMaster = mostDamageCreature->getMaster(); if (lastHitCreature != mostDamageCreatureMaster && (lastHitCreatureMaster == nullptr || mostDamageCreatureMaster != lastHitCreatureMaster)) { mostDamageUnjustified = mostDamageCreature->onKilledCreature(this, false); } } } bool droppedCorpse = dropCorpse(lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified); death(lastHitCreature); if (master) { setMaster(nullptr); } if (droppedCorpse) { g_game.removeCreature(this, false); } }
void Monster::release() { setMaster(nullptr); }