コード例 #1
0
ファイル: MQ2Labels.cpp プロジェクト: Xackery/macroquest2
bool Anonymize(char *name)
{
	if(GetGameState()!=GAMESTATE_INGAME || !pLocalPlayer)
		return 0;
	BOOL bisTarget = false;
	BOOL isRmember = false;
	BOOL isGmember = false;
	bool bChange = false;
	int ItsMe = _stricmp(((PSPAWNINFO)pLocalPlayer)->Name, name);
	if(ItsMe!=0)//well if it is me, then there is no point in checking if its a group member
		isGmember = IsGroupMember(name);
	if(!isGmember && ItsMe!=0)//well if it is me or a groupmember, then there is no point in checking if its a raid member
		isRmember = IsRaidMember(name);
	if (ItsMe != 0 && !isGmember && !isRmember) {
		//my target?
		if (pTarget && ((PSPAWNINFO)pTarget)->Type!=SPAWN_NPC) {
			if (!_stricmp(((PSPAWNINFO)pTarget)->Name, name)) {
				bisTarget = true;
			}
		}
	}
	if (ItsMe==0 || isGmember || isRmember || bisTarget) {
		int len = strlen(name);
		bChange = true;
		for (int i = 1; i < len - 1; i++) {
			name[i] = '*';
		}
	}
	return bChange;
}
コード例 #2
0
hsBool plMaxNodeBase::CanConvert(bool recalculate)
{
    // Try and find a cached return value
    plMaxNodeData *md = GetMaxNodeData();
    if (md && !recalculate)
        return md->CanConvert();

    if (UserPropExists("IGNORE"))
        return false;

    Object *obj = EvalWorldState(0/*hsConverterUtils::Instance().GetTime(GetInterface())*/).obj;
    if (obj)
    {
        if  (  obj->CanConvertToType(triObjectClassID)      // MeshObjs are accepted here
            || obj->ClassID() == Class_ID(DUMMY_CLASS_ID,0) // Dummy boxes are accepted here
            || obj->SuperClassID() == CAMERA_CLASS_ID       // All Camera types are accepted here
            || obj->ClassID() == Class_ID(UTILITY_CLASS_ID, 0)      // All Camera targets are accepted here
            || (  obj->ClassID() ==  RTOMNI_LIGHT_CLASSID
                || obj->ClassID() == RTSPOT_LIGHT_CLASSID
                || obj->ClassID() == RTDIR_LIGHT_CLASSID 
                || obj->ClassID() == RTPDIR_LIGHT_CLASSID )
            || (  obj->SuperClassID() == LIGHT_CLASS_ID     // All run time lights are accepted here
               && UserPropExists("RunTimeLight"))

            || IsGroupMember()                              // Group objects are accepted here
            )
        return true;
    }
    return false;
}
コード例 #3
0
ファイル: aura.cpp プロジェクト: SecretsOTheP/Server
bool Aura::ShouldISpawnFor(Client *c)
{
	if (spawn_type == AuraSpawns::Noone)
		return false;

	if (spawn_type == AuraSpawns::Everyone)
		return true;

	// hey, it's our owner!
	if (c->GetID() == m_owner)
		return true;

	// so this one is a bit trickier
	auto owner = GetOwner();
	if (owner == nullptr)
		return false; // hmm

	owner = owner->GetOwnerOrSelf(); // pet auras we need the pet's owner
	if (owner == nullptr) // shouldn't really be needed
		return false;

	// gotta check again for pet aura case -.-
	if (owner == c)
		return true;

	if (owner->IsRaidGrouped() && owner->IsClient()) {
		auto raid = owner->GetRaid();
		if (raid == nullptr)
			return false; // hmm
		auto group_id = raid->GetGroup(owner->CastToClient());
		if (group_id == 0xFFFFFFFF) // owner handled above, and they're in a raid and groupless
			return false;

		auto idx = raid->GetPlayerIndex(c);
		if (idx == 0xFFFFFFFF) // they're not in our raid!
			return false;

		if (raid->members[idx].GroupNumber != group_id) // in our raid, but not our group
			return false;

		return true; // we got here so we know that 1 they're in our raid and 2 they're in our group!
	} else if (owner->IsGrouped()) {
		auto group = owner->GetGroup();
		if (group == nullptr)
			return false; // hmm

		// easy, in our group
		return group->IsGroupMember(c);
	}

	// our owner is not raided or grouped, and they're handled above so we don't spawn!
	return false;
}
コード例 #4
0
int CPVRChannelGroup::GetMembers(CFileItemList *results, bool bGroupMembers /* = true */) const
{
  int iOrigSize = results->Size();
  CSingleLock lock(m_critSection);

  const CPVRChannelGroup *channels = bGroupMembers ? this : CPVRManager::GetChannelGroups()->GetGroupAll(m_bRadio);
  for (unsigned int iChannelPtr = 0; iChannelPtr < channels->size(); iChannelPtr++)
  {
    CPVRChannel *channel = channels->at(iChannelPtr).channel;
    if (!channel)
      continue;

    if (bGroupMembers || !IsGroupMember(channel))
    {
      CFileItemPtr pFileItem(new CFileItem(*channel));
      results->Add(pFileItem);
    }
  }

  return results->Size() - iOrigSize;
}
コード例 #5
0
ファイル: aura.cpp プロジェクト: SecretsOTheP/Server
void Aura::ProcessOnGroupMembersPets(Mob *owner)
{
	auto &mob_list = entity_list.GetMobList(); // read only reference so we can do it all inline
	std::set<int> delayed_remove;
	bool is_buff = IsBuffSpell(spell_id); // non-buff spells don't cast on enter
	// This type can either live on the pet (level 55/70 MAG aura) or on the pet owner (level 85 MAG aura)
	auto group_member = owner->GetOwnerOrSelf();

	if (group_member->IsRaidGrouped() && group_member->IsClient()) { // currently raids are just client, but safety check
		auto raid = group_member->GetRaid();
		if (raid == nullptr) { // well shit
			owner->RemoveAura(GetID(), false, true);
			return;
		}
		auto group_id = raid->GetGroup(group_member->CastToClient());

		// some lambdas so the for loop is less horrible ...
		auto verify_raid_client_pet = [&raid, &group_id, &group_member, this](Mob *m) {
			auto idx = raid->GetPlayerIndex(m->GetOwner()->CastToClient());
			if (m->GetOwner()->GetID() == group_member->GetID()) {
				return DistanceSquared(GetPosition(), m->GetPosition()) <= distance;
			} else if (idx == 0xFFFFFFFF || raid->members[idx].GroupNumber != group_id || raid->members[idx].GroupNumber == 0xFFFFFFFF) {
				return false;
			} else if (DistanceSquared(GetPosition(), m->GetPosition()) > distance) {
				return false;
			}
			return true;
		};

		auto verify_raid_client_swarm = [&raid, &group_id, &group_member, this](NPC *n) {
			auto owner = entity_list.GetMob(n->GetSwarmOwner());
			if (owner == nullptr)
				return false;
			auto idx = raid->GetPlayerIndex(owner->CastToClient());
			if (owner->GetID() == group_member->GetID()) {
				return DistanceSquared(GetPosition(), n->GetPosition()) <= distance;
			} else if (idx == 0xFFFFFFFF || raid->members[idx].GroupNumber != group_id || raid->members[idx].GroupNumber == 0xFFFFFFFF) {
				return false;
			} else if (DistanceSquared(GetPosition(), n->GetPosition()) > distance) {
				return false;
			}
			return true;
		};

		for (auto &e : mob_list) {
			auto mob = e.second;
			// step 1: check if we're already managing this NPC's buff
			auto it = casted_on.find(mob->GetID());
			if (it != casted_on.end()) {
				// verify still good!
				if (mob->IsPet() && mob->IsPetOwnerClient() && mob->GetOwner()) {
					if (!verify_raid_client_pet(mob))
						delayed_remove.insert(mob->GetID());
				} else if (mob->IsNPC() && mob->IsPetOwnerClient()) {
					auto npc = mob->CastToNPC();
					if (!verify_raid_client_swarm(npc))
						delayed_remove.insert(mob->GetID());
				}
			} else { // we're not on it!
				if (mob->IsClient()) {
					continue; // never hit client
				} else if (mob->IsPet() && mob->IsPetOwnerClient() && mob->GetOwner() && verify_raid_client_pet(mob)) {
					casted_on.insert(mob->GetID());
					if (is_buff)
						SpellFinished(spell_id, mob);
				} else if (mob->IsNPC() && mob->IsPetOwnerClient()) {
					auto npc = mob->CastToNPC();
					if (verify_raid_client_swarm(npc)) {
						casted_on.insert(mob->GetID());
						if (is_buff)
							SpellFinished(spell_id, mob);
					}
				}
			}
		}
	} else if (group_member->IsGrouped()) {
		auto group = group_member->GetGroup();
		if (group == nullptr) { // uh oh
			owner->RemoveAura(GetID(), false, true);
			return;
		}

		// lambdas to make for loop less ugly
		auto verify_group_pet = [&group, this](Mob *m) {
			auto owner = m->GetOwner();
			if (owner != nullptr && group->IsGroupMember(owner) && DistanceSquared(GetPosition(), m->GetPosition()) <= distance)
				return true;
			return false;
		};

		auto verify_group_swarm = [&group, this](NPC *n) {
			auto owner = entity_list.GetMob(n->GetSwarmOwner());
			if (owner != nullptr && group->IsGroupMember(owner) && DistanceSquared(GetPosition(), n->GetPosition()) <= distance)
				return true;
			return false;
		};

		for (auto &e : mob_list) {
			auto mob = e.second;
			auto it = casted_on.find(mob->GetID());

			if (it != casted_on.end()) { // make sure we're still valid
				if (mob->IsPet()) {
					if (!verify_group_pet(mob))
						delayed_remove.insert(mob->GetID());
				} else if (mob->IsNPC() && mob->CastToNPC()->GetSwarmInfo()) {
					if (!verify_group_swarm(mob->CastToNPC()))
						delayed_remove.insert(mob->GetID());
				}
			} else { // not on, check if we should be!
				if (mob->IsClient()) {
					continue;
				} else if (mob->IsPet() && verify_group_pet(mob)) {
					casted_on.insert(mob->GetID());
					if (is_buff)
						SpellFinished(spell_id, mob);
				} else if (mob->IsNPC() && mob->CastToNPC()->GetSwarmInfo() && verify_group_swarm(mob->CastToNPC())) {
					casted_on.insert(mob->GetID());
					if (is_buff)
						SpellFinished(spell_id, mob);
				}
			}
		}
	} else {
		auto verify_solo = [&group_member, this](Mob *m) {
			if (m->IsPet() && m->GetOwnerID() == group_member->GetID())
				return true;
			else if (m->IsNPC() && m->CastToNPC()->GetSwarmOwner() == group_member->GetID())
				return true;
			else
				return false;
		};
		for (auto &e : mob_list) {
			auto mob = e.second;
			auto it = casted_on.find(mob->GetID());
			bool good = verify_solo(mob);

			if (it != casted_on.end()) { // make sure still valid
				if (!good || DistanceSquared(GetPosition(), mob->GetPosition()) > distance) {
					delayed_remove.insert(mob->GetID());
				}
			} else if (good && DistanceSquared(GetPosition(), mob->GetPosition()) <= distance) {
				casted_on.insert(mob->GetID());
				if (is_buff)
					SpellFinished(spell_id, mob);
			}
		}
	}

	for (auto &e : delayed_remove) {
		auto mob = entity_list.GetMob(e);
		if (mob != nullptr && is_buff) // some auras cast instant spells so no need to remove
			mob->BuffFadeBySpellIDAndCaster(spell_id, GetID());
		casted_on.erase(e);
	}

	// so if we have a cast timer and our set isn't empty and timer is disabled we need to enable it
	if (cast_timer.GetDuration() > 0 && !cast_timer.Enabled() && !casted_on.empty())
		cast_timer.Start();

	if (!cast_timer.Enabled() || !cast_timer.Check())
		return;

	// some auras have to recast (DRU for example, non-buff too)
	for (auto &e : casted_on) {
		auto mob = entity_list.GetMob(e);
		if (mob != nullptr)
			SpellFinished(spell_id, mob);
	}
}
コード例 #6
0
bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels)
{
  bool bChanged(false);
  CSingleLock lock(m_critSection);
  int iCurSize = size();

  CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
  if (!database || !database->Open())
    return false;

  /* go through the channel list and check for updated or new channels */
  for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++)
  {
    CPVRChannel *channel = channels.at(iChannelPtr).channel;
    int iChannelNumber   = channels.at(iChannelPtr).iChannelNumber;
    if (!channel)
      continue;

    CPVRChannel *realChannel = (CPVRChannel *) CPVRManager::GetChannelGroups()->GetGroupAll(m_bRadio)->GetByClient(channel->UniqueID(), channel->ClientID());
    if (!realChannel)
      continue;

    if (!IsGroupMember(realChannel))
    {
      AddToGroup(realChannel, iChannelNumber, false);

      bChanged = true;
      m_bChanged = true;
      CLog::Log(LOGINFO,"PVRChannelGroup - %s - added %s channel '%s' at position %d in group '%s'",
          __FUNCTION__, m_bRadio ? "radio" : "TV", realChannel->ChannelName().c_str(), iChannelNumber, GroupName().c_str());
    }
  }

  /* check for deleted channels */
  unsigned int iSize = size();
  for (unsigned int iChannelPtr = 0; iChannelPtr < iSize; iChannelPtr++)
  {
    CPVRChannel *channel = (CPVRChannel *) GetByIndex(iChannelPtr);
    if (!channel)
      continue;
    if (channels.GetByClient(channel->UniqueID(), channel->ClientID()) == NULL)
    {
      /* channel was not found */
      CLog::Log(LOGINFO,"PVRChannelGroup - %s - deleted %s channel '%s' from group '%s'",
          __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str(), GroupName().c_str());

      /* remove this channel from all non-system groups */
      RemoveFromGroup(channel);

      m_bChanged = true;
      bChanged = true;
      iChannelPtr--;
      iSize--;
    }
  }

  if (bChanged)
  {
    /* sort by client channel number if this is the first time */
    if (iCurSize == 0)
      SortByClientChannelNumber();

    /* renumber to make sure all channels have a channel number.
       new channels were added at the back, so they'll get the highest numbers */
    Renumber();

    return Persist();
  }

  return true;
}