コード例 #1
0
void BuffList::clearBuffs(bool updateclient) {
	Locker guard(&mutex);

	while (buffList.size() > 0) {
		ManagedReference<Buff*> buff = buffList.get(0);

		Locker locker(buff);

		if (buff->isActive())
			buff->clearBuffEvent();

		buff->clearBuffEvent();

		buffList.remove(0);

		//Already null checked the buff.
		if (buff->isSpiceBuff())
			buff->deactivate(false); // this wont create the downer
		else
			buff->deactivate();

		if (buff->isPersistent())
			ObjectManager::instance()->destroyObjectFromDatabase(buff->_getObjectID());
	}

	spiceActive = false;
}
int SquadLeaderBuffObserverImplementation::notifyObserverEvent(unsigned int eventType, Observable* observable, ManagedObject* arg1, int64 arg2) {
	if (eventType != ObserverEventType::PARENTCHANGED)
		return 0;

	ManagedReference<SquadLeaderBuff* > buff = this->buff.get();

	if (buff == NULL)
		return 1;

	Locker locker(buff);

	ManagedReference<CreatureObject*> player = buff->getPlayer();
	if (player == NULL)
		return 1;

	ManagedReference<CreatureObject*> leader = buff->getLeader();
	if (leader == NULL || player->getGroup() == NULL || player->getGroup()->getLeader() != leader) {
		player->removeBuff(buff->getBuffCRC());
		return 1;
	}

	if (player->getParentRecursively(SceneObjectType::BUILDING) == leader->getParentRecursively(SceneObjectType::BUILDING)) {
		if (!buff->isActive())
			buff->activate();
	} else if (buff->isActive())
		buff->deactivate();

	return 0;
}