Ejemplo n.º 1
0
void Player::SetAtWar(uint32 Faction, bool Set)
{
	if( Faction >= 128 )
		return;

	FactionReputation * rep = reputationByListId[Faction];
	if(!rep) return;
	
	if(GetReputationRankFromStanding(rep->standing) <= STANDING_HOSTILE && !Set) // At this point we have to be at war.
		return;

	FactionDBC * f = dbcFaction.LookupEntry(Faction);
	if(rep->flag & 0x4)
		return;

	if(Set)
	{
		if(!AtWar(rep->flag))
			SetFlagAtWar(rep->flag);

		UpdateInrangeSetsBasedOnReputation();
	}
	else
	{
		if(AtWar(rep->flag))
			UnsetFlagAtWar(rep->flag);

		UpdateInrangeSetsBasedOnReputation();
	}

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}
void Player::SetAtWar(uint32 Faction, bool Set)
{
    if( Faction >= 128 )
        return;

    FactionReputation * rep = reputationByListId[Faction];
    if(!rep)
        return;

    if(GetReputationRankFromStanding(rep->standing) <= STANDING_HOSTILE && !Set) // At this point we have to be at war.
        return;

    if(rep->flag & 0x4 || rep->flag & 16 )
        return;

    if(Set)
    {
        if(!AtWar(rep->flag))
            SetFlagAtWar(rep->flag);

        UpdateInrangeSetsBasedOnReputation();
    }
    else
    {
        if(AtWar(rep->flag))
            UnsetFlagAtWar(rep->flag);

        UpdateInrangeSetsBasedOnReputation();
    }
}
Ejemplo n.º 3
0
void Player::SetStanding(uint32 Faction, int32 Value)
{
	ReputationMap::iterator itr = m_reputation.find(Faction);
	FactionDBC * dbc = dbcFaction.LookupEntry(Faction);
	if(dbc == 0) return;

	if(itr == m_reputation.end())
	{
		// New faction!
		FactionReputation * rep = new FactionReputation;
		rep->flag = 0;
		rep->standing = Value;
		rep->baseStanding = 0;
		m_reputation[dbc->ID] = rep;
		if(dbc->RepListId >= 0)
			reputationByListId[dbc->RepListId] = rep;
	}
	else
	{
		// Increment it.
		if(RankChangedFlat(itr->second->standing, Value))
		{
			itr->second->standing = Value;
			UpdateInrangeSetsBasedOnReputation();
		}
		else
		{
			itr->second->standing = Value;
		}

		// Set visible if invisible.
		if(!Visible(itr->second->flag))
		{
			SetFlagVisible(itr->second->flag);
			if(IsInWorld())
				m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &dbc->RepListId);
		}

		// Set at war if we're beyond hostile.
		Standing rank = GetReputationRankFromStanding(itr->second->standing);
		if(rank <= STANDING_HOSTILE && !AtWar(itr->second->flag))
			SetFlagAtWar(itr->second->flag);
		else if(rank >= STANDING_NEUTRAL && AtWar(itr->second->flag))
			UnsetFlagAtWar(itr->second->flag);

		if(IsInWorld())
		{
			WorldPacket data(SMSG_SET_FACTION_STANDING, 12);
			data << uint32(0) << uint8(0) << uint32(itr->second->flag) << dbc->RepListId << itr->second->CalcStanding();
			m_session->SendPacket(&data);
		}
	}

#ifdef OPTIMIZED_PLAYER_SAVING
	save_Reputation();
#endif
}