本文整理汇总了C++中pkt函数的典型用法代码示例。如果您正苦于以下问题:C++ pkt函数的具体用法?C++ pkt怎么用?C++ pkt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pkt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
}
示例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);
}
示例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);
}