Exemplo n.º 1
0
void CParty::RemoveMember(CBattleEntity* PEntity)
{
	DSP_DEBUG_BREAK_IF(PEntity == NULL);
	DSP_DEBUG_BREAK_IF(PEntity->PParty != this);

	if (m_PLeader == PEntity)
	{
		RemovePartyLeader(PEntity);
	}
	else
	{
		for (uint32 i = 0; i < members.size(); ++i)
		{
			if (PEntity == members.at(i))
			{
				members.erase(members.begin()+i);

                if (m_PartyType == PARTY_PCS)
                {
                    CCharEntity* PChar = (CCharEntity*)PEntity;

				    if (m_PQuaterMaster == PChar)
				    {
					    SetQuaterMaster(NULL);
				    }
				    if (m_PSyncTarget == PChar)
				    {
					    SetSyncTarget(NULL);
				    }

				    PChar->pushPacket(new CPartyDefinePacket(NULL));
				    PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, PChar->getZone()));
				    PChar->pushPacket(new CCharUpdatePacket(PChar));
				    PChar->pushPacket(new CCharSyncPacket(PChar));
				    PChar->PParty = NULL;

				    ReloadParty();

				    if (PChar->PTreasurePool != NULL &&
					    PChar->PTreasurePool->GetPoolType() != TREASUREPOOL_ZONE)
				    {
					    PChar->PTreasurePool->DelMember(PChar);
					    PChar->PTreasurePool = new CTreasurePool(TREASUREPOOL_SOLO);
					    PChar->PTreasurePool->AddMember(PChar);
                        PChar->PTreasurePool->UpdatePool(PChar);
				    }
				    Sql_Query(SqlHandle,"UPDATE accounts_sessions SET partyid = 0 WHERE charid = %u", PChar->id);
                }
				break;
			}
		}
	}
}
Exemplo n.º 2
0
void CParty::DelMember(CBattleEntity* PEntity)
{
	DSP_DEBUG_BREAK_IF(PEntity == NULL);
	DSP_DEBUG_BREAK_IF(PEntity->PParty != this);

	if (m_PLeader == PEntity)
	{
		RemovePartyLeader(PEntity);
	}
	else
	{
		for (uint32 i = 0; i < members.size(); ++i)
		{
			if (PEntity == members.at(i))
			{
				members.erase(members.begin() + i);

				if (m_PartyType == PARTY_PCS)
				{
					CCharEntity* PChar = (CCharEntity*)PEntity;

					if (m_PQuaterMaster == PChar)
					{
						SetQuarterMaster(NULL);
					}
					if (m_PSyncTarget == PChar)
					{
						SetSyncTarget(NULL, 553);
						CStatusEffect* sync = PChar->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC);
						if (sync && sync->GetDuration() == 0)
						{
							PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 30, 553));
							sync->SetStartTime(gettick());
							sync->SetDuration(30000);
						}
						DisableSync();
					}
					if (m_PSyncTarget != NULL && m_PSyncTarget != PChar)
					{
						if (PChar->status != STATUS_DISAPPEAR &&
							PChar->getZone() == m_PSyncTarget->getZone())
						{
							CStatusEffect* sync = PChar->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC);
							if (sync && sync->GetDuration() == 0)
							{
								PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 30, 553));
								sync->SetStartTime(gettick());
								sync->SetDuration(30000);
							}
						}
					}
					PChar->PLatentEffectContainer->CheckLatentsPartyMembers(members.size());

					PChar->pushPacket(new CPartyDefinePacket(NULL));
					PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, PChar->getZone()));
					PChar->pushPacket(new CCharUpdatePacket(PChar));
					PChar->PParty = NULL;

					if (PChar->PTreasurePool != NULL &&
						PChar->PTreasurePool->GetPoolType() != TREASUREPOOL_ZONE)
					{
						PChar->PTreasurePool->DelMember(PChar);
						PChar->PTreasurePool = new CTreasurePool(TREASUREPOOL_SOLO);
						PChar->PTreasurePool->AddMember(PChar);
						PChar->PTreasurePool->UpdatePool(PChar);
					}
				}
				break;
			}
		}
	}
}
Exemplo n.º 3
0
void CParty::RemoveMember(CBattleEntity* PEntity)
{
    DSP_DEBUG_BREAK_IF(PEntity == nullptr);
    DSP_DEBUG_BREAK_IF(PEntity->PParty != this);

    if (m_PLeader == PEntity)
    {
        RemovePartyLeader(PEntity);
    }
    else
    {
        for (uint32 i = 0; i < members.size(); ++i)
        {
            if (PEntity == members.at(i))
            {
                members.erase(members.begin() + i);

                if (m_PartyType == PARTY_PCS)
                {
                    CCharEntity* PChar = (CCharEntity*)PEntity;

                    if (m_PQuaterMaster == PChar)
                    {
                        SetQuarterMaster(nullptr);
                    }
                    if (m_PSyncTarget == PChar)
                    {
                        SetSyncTarget(nullptr, 553);
                        CStatusEffect* sync = PChar->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC);
                        if (sync && sync->GetDuration() == 0)
                        {
                            PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 30, 553));
                            sync->SetStartTime(server_clock::now());
                            sync->SetDuration(30000);
                        }
                        DisableSync();
                    }
                    if (m_PSyncTarget != nullptr && m_PSyncTarget != PChar)
                    {
                        if (PChar->status != STATUS_DISAPPEAR)
                        {
                            CStatusEffect* sync = PChar->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC);
                            if (sync && sync->GetDuration() == 0)
                            {
                                PChar->pushPacket(new CMessageBasicPacket(PChar, PChar, 0, 30, 553));
                                sync->SetStartTime(server_clock::now());
                                sync->SetDuration(30000);
                            }
                        }
                    }
                    PChar->PLatentEffectContainer->CheckLatentsPartyMembers(members.size());

                    PChar->pushPacket(new CPartyDefinePacket(nullptr));
                    PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, 0, PChar->getZone()));
                    PChar->pushPacket(new CCharUpdatePacket(PChar));
                    PChar->PParty = nullptr;

                    Sql_Query(SqlHandle, "DELETE FROM accounts_parties WHERE charid = %u;", PChar->id);

                    uint8 data[4] {};
                    ref<uint32>(data, 0) = m_PartyID;
                    message::send(MSG_PT_RELOAD, data, sizeof data, nullptr);

                    if (PChar->PTreasurePool != nullptr &&
                        PChar->PTreasurePool->GetPoolType() != TREASUREPOOL_ZONE)
                    {
                        PChar->PTreasurePool->DelMember(PChar);
                        PChar->PTreasurePool = new CTreasurePool(TREASUREPOOL_SOLO);
                        PChar->PTreasurePool->AddMember(PChar);
                        PChar->PTreasurePool->UpdatePool(PChar);
                    }
                }
                break;
            }
        }
    }
}