示例#1
0
void P2PManager::ProcessDataPeer(const SOCKADDR_IN& stRemote, PU_PEERADDRTYPE enumAddrType, ULONG ulLen, const BYTE* pbyBuff)
{
	printf("From [%d][%s, %d], DATA[%d]\n", enumAddrType, inet_ntoa(stRemote.sin_addr), ntohs(stRemote.sin_port), ulLen);	

//각 분기가 다른 쓰레드이지만 똑같이 Push해도 크게 문제는 없다.
	if(enumAddrType == PU_PEERADDRTYPE_NONE)
	{
		//m_pUDPCallback->HandleUDPNetworkMessage(pbyBuff, ulLen);
		PushPacket((BYTE*)pbyBuff, ulLen);
	}
	else
	{
		//m_pUDPCallback->HandleUDPNetworkMessage(pbyBuff + PU_PACKET_HEAD_LEN, ulLen - PU_PACKET_HEAD_LEN);
		PushPacket((BYTE*)(pbyBuff + PU_PACKET_HEAD_LEN), ulLen - PU_PACKET_HEAD_LEN);
	}
}
示例#2
0
void CParty::DisbandParty()
{
	SetSyncTarget(NULL);
	SetQuaterMaster(NULL);

	m_PLeader = NULL;
	m_PAlliance	= NULL;

    if (m_PartyType == PARTY_PCS)
    {
        PushPacket(NULL, 0, new CPartyDefinePacket(NULL));

	    for (uint8 i = 0; i < members.size(); ++i)
	    {
		    CCharEntity* PChar = (CCharEntity*)members.at(i);

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

		    // TODO: TreasurePool должен оставаться у последнего персонажа, но сейчас это не критично

            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 = %u WHERE partyid = %u", 0, m_PartyID);
    }
	delete this;
}
示例#3
0
void CParty::DisbandParty(bool playerInitiated)
{
    if (m_PAlliance)
    {
        m_PAlliance->removeParty(this);
    }
    m_PSyncTarget = nullptr;
    SetQuarterMaster(nullptr);

    m_PLeader = nullptr;
    m_PAlliance = nullptr;

    if (m_PartyType == PARTY_PCS)
    {
        PushPacket(0, 0, new CPartyDefinePacket(nullptr));

        for (uint8 i = 0; i < members.size(); ++i)
        {
            CCharEntity* PChar = (CCharEntity*)members.at(i);

            PChar->PParty = nullptr;
            PChar->PLatentEffectContainer->CheckLatentsPartyJobs();
            PChar->PLatentEffectContainer->CheckLatentsPartyMembers(members.size());
            PChar->PLatentEffectContainer->CheckLatentsPartyAvatar();
            PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, 0, PChar->getZone()));

            // TODO: TreasurePool должен оставаться у последнего персонажа, но сейчас это не критично

            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);
            }
            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);
            }
            Sql_Query(SqlHandle, "DELETE FROM accounts_parties WHERE charid = %u;", PChar->id);
        }

        // make sure chat server isn't notified of a disband if this came from the chat server already
        if (playerInitiated)
        {
            uint8 data[8] {};
            ref<uint32>(data, 0) = m_PartyID;
            ref<uint32>(data, 4) = m_PartyID;
            message::send(MSG_PT_DISBAND, data, sizeof data, nullptr);
        }
    }
    delete this;
}
示例#4
0
STDMETHODIMP CBaseMuxerInputPin::Receive(IMediaSample* pSample)
{
	CAutoLock cAutoLock(&m_csReceive);

	HRESULT hr = __super::Receive(pSample);
	if(FAILED(hr)) return hr;

	CAutoPtr<MuxerPacket> pPacket(new MuxerPacket(this));

	long len = pSample->GetActualDataLength();

	BYTE* pData = NULL;
	if(FAILED(pSample->GetPointer(&pData)) || !pData)
		return S_OK;

	pPacket->pData.SetCount(len);
	memcpy(pPacket->pData.GetData(), pData, len);

	if(S_OK == pSample->IsSyncPoint() || m_mt.majortype == MEDIATYPE_Audio && !m_mt.bTemporalCompression)
	{
		pPacket->flags |= MuxerPacket::syncpoint;
	}

	if(S_OK == pSample->GetTime(&pPacket->rtStart, &pPacket->rtStop))
	{
		pPacket->flags |= MuxerPacket::timevalid;

		pPacket->rtStart += m_tStart; 
		pPacket->rtStop += m_tStart;

		if((pPacket->flags & MuxerPacket::syncpoint) && pPacket->rtStart < m_rtMaxStart)
		{
			pPacket->flags &= ~MuxerPacket::syncpoint;
			pPacket->flags |= MuxerPacket::bogus;
		}

		m_rtMaxStart = max(m_rtMaxStart,  pPacket->rtStart);
	}
	else if(pPacket->flags & MuxerPacket::syncpoint)
	{
		pPacket->flags &= ~MuxerPacket::syncpoint;
		pPacket->flags |= MuxerPacket::bogus;
	}

	if(S_OK == pSample->IsDiscontinuity())
	{
		pPacket->flags |= MuxerPacket::discontinuity;
	}

	pPacket->index = m_iPacketIndex++;

	PushPacket(pPacket);

	return S_OK;
}
示例#5
0
void CZone::SetWeather(WEATHER weather)
{
    DSP_DEBUG_BREAK_IF(weather >= MAX_WEATHER_ID);

	if (m_Weather == weather)
		return;

    static uint8 Element[] =
    {
        0,  //WEATHER_NONE
	    0,  //WEATHER_SUNSHINE
	    0,  //WEATHER_CLOUDS
	    0,  //WEATHER_FOG
	    1,  //WEATHER_HOT_SPELL
	    1,  //WEATHER_HEAT_WAVE
	    6,  //WEATHER_RAIN
	    6,  //WEATHER_SQUALL
	    4,  //WEATHER_DUST_STORM
	    4,  //WEATHER_SAND_STORM
	    3,  //WEATHER_WIND
	    3,  //WEATHER_GALES
	    2,  //WEATHER_SNOW
	    2,  //WEATHER_BLIZZARDS
	    5,  //WEATHER_THUNDER
	    5,  //WEATHER_THUNDERSTORMS
	    7,  //WEATHER_AURORAS
	    7,  //WEATHER_STELLAR_GLARE
	    8,  //WEATHER_GLOOM
	    8,  //WEATHER_DARKNESS
    };

	for (EntityList_t::const_iterator it = m_mobList.begin(); it != m_mobList.end(); ++it)
	{
		CMobEntity* PCurrentMob = (CMobEntity*)it->second;

        PCurrentMob->PBattleAI->WeatherChange(weather, Element[weather]);
	}

    for (EntityList_t::const_iterator it = m_charList.begin(); it != m_charList.end(); ++it)
    {
        CCharEntity* PChar = (CCharEntity*)it->second;
        
        PChar->PLatentEffectContainer->CheckLatentsZone();
    }

    m_Weather = weather;
    m_WeatherChangeTime = CVanaTime::getInstance()->getVanaTime();

    PushPacket(NULL, CHAR_INZONE, new CWeatherPacket(m_WeatherChangeTime, m_Weather));
}
示例#6
0
bool TFtp::Session::ProcessTask(const Packet::BlockId block_id) {
  if (_task.type != Task::kUploading || 
      not _task.file ||
      not _task.file->is_open() ||
      not _task.file->good()) {
    std::cout << std::endl;
    return false;
  }
  static const size_t kSize = Packet::kMaxSize - 4;
  Byte data[kSize];
  _task.file->read((char*)&data, kSize);
  const size_t kBlockSz = _task.file->gcount();
  _task.PrintState();
  PushPacket(Packet::Ptr(new PacketData(block_id, data, kBlockSz)));
  return true;
}
示例#7
0
STDMETHODIMP CBaseMuxerInputPin::EndOfStream()
{
	CAutoLock cAutoLock(&m_csReceive);

	HRESULT hr = __super::EndOfStream();
	if(FAILED(hr)) return hr;

	ASSERT(!m_fEOS);

	CAutoPtr<MuxerPacket> pPacket(new MuxerPacket(this));
	pPacket->flags |= MuxerPacket::eos;
	PushPacket(pPacket);

	m_fEOS = true;

	return hr;
}
示例#8
0
void CParty::DisbandParty()
{
	DisableSync();
	SetQuaterMaster(NULL);

	m_PLeader = NULL;
	m_PAlliance	= NULL;

    if (m_PartyType == PARTY_PCS)
    {
        PushPacket(NULL, 0, new CPartyDefinePacket(NULL));

	    for (uint8 i = 0; i < members.size(); ++i)
	    {
		    CCharEntity* PChar = (CCharEntity*)members.at(i);

		    PChar->PParty = NULL;
			PChar->PLatentEffectContainer->CheckLatentsPartyJobs();
			PChar->PLatentEffectContainer->CheckLatentsPartyMembers(members.size());
			PChar->PLatentEffectContainer->CheckLatentsPartyAvatar();
		    PChar->pushPacket(new CPartyMemberUpdatePacket(PChar, 0, PChar->getZone()));

		    // TODO: TreasurePool должен оставаться у последнего персонажа, но сейчас это не критично

            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);
		    }
            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);
            }
	    }
        Sql_Query(SqlHandle,"UPDATE accounts_sessions SET partyid = %u WHERE partyid = %u", 0, m_PartyID);
    }
	delete this;
}
示例#9
0
int Connections::PushPacket(void* pData, int nSize)
{
    Packet* packet = new Packet((unsigned char*)pData, nSize);
    return PushPacket(packet);
}