• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pkt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pkt函数的典型用法代码示例。如果您正苦于以下问题:C++ pkt函数的具体用法?C++ pkt怎么用?C++ pkt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pkt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pkt

void Client::sendDeletedBlocks(std::vector<v3s16> &blocks)
{
	NetworkPacket pkt(TOSERVER_DELETEDBLOCKS, 1 + sizeof(v3s16) * blocks.size());

	pkt << (u8) blocks.size();

	u32 k = 0;
	for(std::vector<v3s16>::iterator
			j = blocks.begin();
			j != blocks.end(); ++j) {
		pkt << *j;
		k++;
	}

	Send(&pkt);
}
开发者ID:BlockMen,项目名称:minetest,代码行数:16,代码来源:client.cpp


示例2: memcpy

void WardenMac::RequestHash()
{
    sLog.outDebug("Request hash");

    // Create packet structure
    WardenHashRequest Request;
    Request.Command = WARDEN_SMSG_HASH_REQUEST;
    memcpy(Request.Seed, Seed, 16);

    // Encrypt with warden RC4 key.
    EncryptData((uint8*)&Request, sizeof(WardenHashRequest));

    WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenHashRequest));
    pkt.append((uint8*)&Request, sizeof(WardenHashRequest));
    Client->SendPacket(&pkt);
}
开发者ID:Regolan,项目名称:mangos-tbc,代码行数:16,代码来源:WardenMac.cpp


示例3: memcpy

void WardenWin::RequestHash()
{
    sLog->outDebug(LOG_FILTER_WARDEN, "Request hash");

    // Create packet structure
    WardenHashRequest Request;
    Request.Command = WARDEN_SMSG_HASH_REQUEST;
    memcpy(Request.Seed, _seed, 16);

    // Encrypt with warden RC4 key.
    EncryptData((uint8*)&Request, sizeof(WardenHashRequest));

    WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenHashRequest));
    pkt.append((uint8*)&Request, sizeof(WardenHashRequest));
    _session->SendPacket(&pkt);
}
开发者ID:Tithand,项目名称:TER-Server,代码行数:16,代码来源:WardenWin.cpp


示例4: pkt

void PacketHandlers::HandleDialogueDecision(Session* sess, SmartPacket& packet)
{
    uint64_t guid = packet.ReadUInt64();
    uint32_t decision = packet.ReadUInt32();

    WorldObject* obj = sObjectAccessor->FindWorldObject(guid);
    // if the object is not found, or is not creature, send dialogue close packet
    if (!obj || obj->GetType() != OTYPE_CREATURE)
    {
        SmartPacket pkt(SP_DIALOGUE_CLOSE);
        sess->SendPacket(pkt);
        return;
    }

    obj->ToCreature()->DialogueDecision(sess->GetPlayer(), decision);
}
开发者ID:MartinUbl,项目名称:BubbleWorldServer,代码行数:16,代码来源:PacketHandlers.cpp


示例5: pkt

void Client::sendInit(const std::string &playerName)
{
	NetworkPacket pkt(TOSERVER_INIT, 1 + 2 + 2 + (1 + playerName.size()));

	// we don't support network compression yet
	u16 supp_comp_modes = NETPROTO_COMPRESSION_NONE;

	u16 proto_version_min = g_settings->getFlag("send_pre_v25_init") ?
		CLIENT_PROTOCOL_VERSION_MIN_LEGACY : CLIENT_PROTOCOL_VERSION_MIN;

	pkt << (u8) SER_FMT_VER_HIGHEST_READ << (u16) supp_comp_modes;
	pkt << (u16) proto_version_min << (u16) CLIENT_PROTOCOL_VERSION_MAX;
	pkt << playerName;

	Send(&pkt);
}
开发者ID:DarkDracoon,项目名称:minetest,代码行数:16,代码来源:client.cpp


示例6: pkt

int StateLobby::OnValidateCharacterName (IPacket &packet)
{
    std::string name = packet.Read();

    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    if (IsNameValid(name))
    {
        boost::shared_ptr<OPacket> pkt(new OPacket);
        srv_pkt::Lobby(pkt,srv_pkt::LOBBY_ACTION_VALIDATE_NAME);
        m_connection->Send(pkt);
    }

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:16,代码来源:server_state_lobby.cpp


示例7: TC_LOG_DEBUG

void WardenMac::RequestHash()
{
    TC_LOG_DEBUG("warden", "Request hash");

    // Create packet structure
    WardenHashRequest Request;
    Request.Command = WARDEN_SMSG_HASH_REQUEST;
    memcpy(Request.Seed, _seed, 16);

    // Encrypt with warden RC4 key.
    EncryptData((uint8*)&Request, sizeof(WardenHashRequest));

    WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenHashRequest)+4);
    pkt << uint32(sizeof(WardenHashRequest));
    pkt.append((uint8*)&Request, sizeof(WardenHashRequest));
    _session->SendPacket(&pkt);
}
开发者ID:redlaine,项目名称:InfinityCore-Ark,代码行数:17,代码来源:WardenMac.cpp


示例8: pkt

void Client::sendLegacyInit(const std::string &playerName, const std::string &playerPassword)
{
	NetworkPacket pkt(TOSERVER_INIT_LEGACY,
			1 + PLAYERNAME_SIZE + PASSWORD_SIZE + 2 + 2);

	pkt << (u8) SER_FMT_VER_HIGHEST_READ;
	
	std::string tmp = playerName;
	tmp.resize(tmp.size()+PLAYERNAME_SIZE);
	pkt.putRawString(tmp.c_str(),PLAYERNAME_SIZE);
	tmp = playerPassword;
	tmp.resize(tmp.size()+PASSWORD_SIZE);
	pkt.putRawString(tmp.c_str(), PASSWORD_SIZE);
	pkt << (u16) CLIENT_PROTOCOL_VERSION_MIN << (u16) CLIENT_PROTOCOL_VERSION_MAX;

	Send(&pkt);
}
开发者ID:cyisfor,项目名称:freeminer,代码行数:17,代码来源:client.cpp


示例9: pkt

void Unit::StartMoving(MoveDirectionElement dir)
{
    if ((m_moveMask & dir) != 0)
        return;

    SmartPacket pkt(SP_MOVE_START_DIRECTION);
    pkt.WriteUInt64(GetGUID());
    pkt.WriteUInt8(dir);
    SendPacketToSorroundings(pkt);

    // if started movement, set timers for movement update
    if (m_moveMask == 0)
        m_lastMovementUpdate = getMSTime();

    m_moveMask |= dir;
    UpdateMovementVector();
}
开发者ID:MartinUbl,项目名称:BubbleWorldServer,代码行数:17,代码来源:Unit.cpp


示例10: LoadCharacters

int StateLobby::OnListCharacter (IPacket &packet)
{
    if (!packet.EndOfStream())
        return MSG_ERROR_SIZE;

    if (!m_loaded)
    {
        LoadCharacters();
        m_loaded = true;
    }

    boost::shared_ptr<OPacket> pkt(new OPacket);
    srv_pkt::Lobby(pkt,m_player_list);
    m_connection->Send(pkt);

    return MSG_SUCCESS;
}
开发者ID:ghostuser846,项目名称:eSRO,代码行数:17,代码来源:server_state_lobby.cpp


示例11: defined

void WardenWin::InitializeModule()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
    sLog->outDebug(LOG_FILTER_WARDEN, "Initialize module");
#endif

    // Create packet structure
    WardenInitModuleRequest Request;
    Request.Command1 = WARDEN_SMSG_MODULE_INITIALIZE;
    Request.Size1 = 20;
    Request.Unk1 = 1;
    Request.Unk2 = 0;
    Request.Type = 1;
    Request.String_library1 = 0;
    Request.Function1[0] = 0x00024F80;                      // 0x00400000 + 0x00024F80 SFileOpenFile
    Request.Function1[1] = 0x000218C0;                      // 0x00400000 + 0x000218C0 SFileGetFileSize
    Request.Function1[2] = 0x00022530;                      // 0x00400000 + 0x00022530 SFileReadFile
    Request.Function1[3] = 0x00022910;                      // 0x00400000 + 0x00022910 SFileCloseFile
    Request.CheckSumm1 = BuildChecksum(&Request.Unk1, 20);

    Request.Command2 = WARDEN_SMSG_MODULE_INITIALIZE;
    Request.Size2 = 8;
    Request.Unk3 = 4;
    Request.Unk4 = 0;
    Request.String_library2 = 0;
    Request.Function2 = 0x00419D40;                         // 0x00400000 + 0x00419D40 FrameScript::GetText
    Request.Function2_set = 1;
    Request.CheckSumm2 = BuildChecksum(&Request.Unk2, 8);

    Request.Command3 = WARDEN_SMSG_MODULE_INITIALIZE;
    Request.Size3 = 8;
    Request.Unk5 = 1;
    Request.Unk6 = 1;
    Request.String_library3 = 0;
    Request.Function3 = 0x0046AE20;                         // 0x00400000 + 0x0046AE20 PerformanceCounter
    Request.Function3_set = 1;
    Request.CheckSumm3 = BuildChecksum(&Request.Unk5, 8);

    // Encrypt with warden RC4 key.
    EncryptData((uint8*)&Request, sizeof(WardenInitModuleRequest));

    WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenInitModuleRequest));
    pkt.append((uint8*)&Request, sizeof(WardenInitModuleRequest));
    _session->SendPacket(&pkt);
}
开发者ID:Helias,项目名称:azerothcore-wotlk,代码行数:45,代码来源:WardenWin.cpp


示例12: pkt

bool Client::sendModChannelMessage(const std::string &channel, const std::string &message)
{
	if (!m_modchannel_mgr->canWriteOnChannel(channel))
		return false;

	if (message.size() > STRING_MAX_LEN) {
		warningstream << "ModChannel message too long, dropping before sending "
				<< " (" << message.size() << " > " << STRING_MAX_LEN << ", channel: "
				<< channel << ")" << std::endl;
		return false;
	}

	// @TODO: do some client rate limiting
	NetworkPacket pkt(TOSERVER_MODCHANNEL_MSG, 2 + channel.size() + 2 + message.size());
	pkt << channel << message;
	Send(&pkt);
	return true;
}
开发者ID:EXio4,项目名称:minetest,代码行数:18,代码来源:client.cpp


示例13: encode_audio_frame

	void encode_audio_frame(core::read_frame& frame)
	{			
		auto c = audio_st_->codec;

		boost::range::push_back(audio_buf_, convert_audio(frame, c));
		
		std::size_t frame_size = c->frame_size;
		auto input_audio_size = frame_size * av_get_bytes_per_sample(c->sample_fmt) * c->channels;
		
		while(audio_buf_.size() >= input_audio_size)
		{
			safe_ptr<AVPacket> pkt(new AVPacket, [](AVPacket* p)
			{
				av_free_packet(p);
				delete p;
			});
			av_init_packet(pkt.get());

			if(frame_size > 1)
			{								
				pkt->size = avcodec_encode_audio(c, audio_outbuf_.data(), audio_outbuf_.size(), reinterpret_cast<short*>(audio_buf_.data()));
				audio_buf_.erase(audio_buf_.begin(), audio_buf_.begin() + input_audio_size);
			}
			else
			{
				audio_outbuf_ = std::move(audio_buf_);		
				audio_buf_.clear();
				pkt->size = audio_outbuf_.size();
				pkt->data = audio_outbuf_.data();
			}
		
			if(pkt->size == 0)
				return;

			if (c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
				pkt->pts = av_rescale_q(c->coded_frame->pts, c->time_base, audio_st_->time_base);

			pkt->flags		 |= AV_PKT_FLAG_KEY;
			pkt->stream_index = audio_st_->index;
			pkt->data		  = reinterpret_cast<uint8_t*>(audio_outbuf_.data());
		
			av_interleaved_write_frame(oc_.get(), pkt.get());
		}
	}
开发者ID:TELE-TWIN,项目名称:Server,代码行数:44,代码来源:ffmpeg_consumer.cpp


示例14: memcpy

void WardenBase::RequestModule()
{
    sLog->outStaticDebug("Request module");

    // Create packet structure
    WardenModuleUse Request;
    Request.Command = WARDEN_SMSG_MODULE_USE;

    memcpy(Request.Module_Id, Module->ID, 16);
    memcpy(Request.Module_Key, Module->Key, 16);
    Request.Size = Module->CompressedSize;

    // Encrypt with warden RC4 key.
    EncryptData((uint8*)&Request, sizeof(WardenModuleUse));

    WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenModuleUse));
    pkt.append((uint8*)&Request, sizeof(WardenModuleUse));
    Client->SendPacket(&pkt);
}
开发者ID:AwkwardDev,项目名称:TrinityCore,代码行数:19,代码来源:WardenBase.cpp


示例15: memcpy

void Warden::RequestModule()
{
    sLog->outDebug(LOG_FILTER_WARDEN, "Request module");

    // Create packet structure
    WardenModuleUse request;
    request.Command = WARDEN_SMSG_MODULE_USE;

    memcpy(request.ModuleId, _module->Id, 16);
    memcpy(request.ModuleKey, _module->Key, 16);
    request.Size = _module->CompressedSize;

    // Encrypt with warden RC4 key.
    EncryptData((uint8*)&request, sizeof(WardenModuleUse));

    WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenModuleUse));
    pkt.append((uint8*)&request, sizeof(WardenModuleUse));
    _session->SendPacket(&pkt);
}
开发者ID:Anubisss,项目名称:ngrealmd,代码行数:19,代码来源:Warden.cpp


示例16: assert

void Client::sendPlayerItem(u16 item)
{
	Player *myplayer = m_env.getLocalPlayer();
	if(myplayer == NULL)
		return;

	u16 our_peer_id = m_con.GetPeerID();

	// Set peer id if not set already
	if(myplayer->peer_id == PEER_ID_INEXISTENT)
		myplayer->peer_id = our_peer_id;
	assert(myplayer->peer_id == our_peer_id);

	NetworkPacket pkt(TOSERVER_PLAYERITEM, 2);

	pkt << item;

	Send(&pkt);
}
开发者ID:BlockMen,项目名称:minetest,代码行数:19,代码来源:client.cpp


示例17: item

void Client::interact(u8 action, const PointedThing& pointed)
{
	if(m_state != LC_Ready) {
		errorstream << "Client::interact() "
				"Canceled (not connected)"
				<< std::endl;
		return;
	}

	LocalPlayer *myplayer = m_env.getLocalPlayer();
	if (myplayer == NULL)
		return;

	/*
		[0] u16 command
		[2] u8 action
		[3] u16 item
		[5] u32 length of the next item (plen)
		[9] serialized PointedThing
		[9 + plen] player position information
		actions:
		0: start digging (from undersurface) or use
		1: stop digging (all parameters ignored)
		2: digging completed
		3: place block or item (to abovesurface)
		4: use item
		5: perform secondary action of item
	*/

	NetworkPacket pkt(TOSERVER_INTERACT, 1 + 2 + 0);

	pkt << action;
	pkt << (u16)getPlayerItem();

	std::ostringstream tmp_os(std::ios::binary);
	pointed.serialize(tmp_os);

	pkt.putLongString(tmp_os.str());

	writePlayerPos(myplayer, &m_env.getClientMap(), &pkt);

	Send(&pkt);
}
开发者ID:EXio4,项目名称:minetest,代码行数:43,代码来源:client.cpp


示例18: FATAL_ERROR_IF

void Client::sendInventoryFields(const std::string &formname,
		const StringMap &fields)
{
	size_t fields_size = fields.size();
	FATAL_ERROR_IF(fields_size > 0xFFFF, "Unsupported number of inventory fields");

	NetworkPacket pkt(TOSERVER_INVENTORY_FIELDS, 0);
	pkt << formname << (u16) (fields_size & 0xFFFF);

	StringMap::const_iterator it;
	for (it = fields.begin(); it != fields.end(); ++it) {
		const std::string &name  = it->first;
		const std::string &value = it->second;
		pkt << name;
		pkt.putLongString(value);
	}

	Send(&pkt);
}
开发者ID:BlockMen,项目名称:minetest,代码行数:19,代码来源:client.cpp


示例19: QByteArray

void PlayerSubtitle::tryReload(int flag)
{
    if (!m_player)
        return;
    if (!m_player->isPlaying())
        return;
    const int kReloadInternal = 1;
    const int kReloadExternal = 1<<1;
    if (flag & kReloadExternal) {
        if (!m_file.isEmpty() && m_enabled) { //engine changed
            m_sub->processHeader(QByteArray(), QByteArray()); // reset
            m_sub->loadAsync();
            return;
        }
    }
    if (!(flag & kReloadInternal)) { // if internal flag is set, try internal first, then fallback to external if internal is failed
        if (!m_enabled)
            return;
        if (flag & kReloadExternal) {
            m_sub->processHeader(QByteArray(), QByteArray()); // reset
            m_sub->loadAsync();
        }
        return;
    }

    const int n = m_player->currentSubtitleStream();
    if (n < 0 || m_tracks.isEmpty() || m_tracks.size() <= n) {
        m_sub->processHeader(QByteArray(), QByteArray()); // reset, null processor
        //try to fallback to external sub if an invalid internal sub track is set
        if ((flag & kReloadExternal) && m_enabled)
            m_sub->loadAsync();
        return;
    }
    QVariantMap track = m_tracks[n].toMap();
    QByteArray codec(track.value("codec").toByteArray());
    QByteArray data(track.value("extra").toByteArray());
    m_sub->processHeader(codec, data);
    Packet pkt(m_current_pkt[n]);
    if (pkt.isValid()) {
        processInternalSubtitlePacket(n, pkt);
    }
}
开发者ID:elearning2015,项目名称:QtAV,代码行数:42,代码来源:PlayerSubtitle.cpp


示例20: FATAL_ERROR_IF

void Client::sendNodemetaFields(v3s16 p, const std::string &formname,
		const std::map<std::string, std::string> &fields)
{
	size_t fields_size = fields.size();

	FATAL_ERROR_IF(fields_size > 0xFFFF, "Unsupported number of nodemeta fields");

	NetworkPacket pkt(TOSERVER_NODEMETA_FIELDS, 0);

	pkt << p << formname << (u16) (fields_size & 0xFFFF);

	for(std::map<std::string, std::string>::const_iterator
			i = fields.begin(); i != fields.end(); i++) {
		const std::string &name = i->first;
		const std::string &value = i->second;
		pkt << name;
		pkt.putLongString(value);
	}

	Send(&pkt);
}
开发者ID:LeMagnesium,项目名称:minetest,代码行数:21,代码来源:client.cpp



注:本文中的pkt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pl函数代码示例发布时间:2022-05-30
下一篇:
C++ pkix_CheckType函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap