本文整理汇总了C++中Packet::AddFloat32方法的典型用法代码示例。如果您正苦于以下问题:C++ Packet::AddFloat32方法的具体用法?C++ Packet::AddFloat32怎么用?C++ Packet::AddFloat32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet::AddFloat32方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
cell AMX_NATIVE_CALL Dotnet_AddFloat32ToPacket(AMX * amx, cell * params)
{
//logprintf("Dotnet_AddFloat32ToPacket");
cell *pPack;
amx_GetAddr(amx,params[1],&pPack);
float f = amx_ctof(params[2]);
Packet* pack = (Packet*)*pPack;
if (pack == NULL) return NULL;
pack->AddFloat32(f);
return (cell)pack;
}
示例2: ProcessPacket
void PacketProcessor::ProcessPacket(Client* client,Packet* pak)
{
if (!client->IsConnected) return;
//Log::Debug("Packet received");
if (pak->Opcode == Packet::Auth)
{ // authentication request
//Log::Debug("Auth received");
char* auth = (char*)calloc(32,1);
auth = pak->ReadString(auth,32);
//int a = strcmp(auth,Server::Instance->AuthKey);
//logprintf("Auth compare: %s / %s / %d",auth,Server::Instance->AuthKey, a);
if (strcmp(auth,Server::Instance->AuthKey) == 0)
{
client->IsAuthenticated = true;
Server::Instance->PakSender->SendAuthReply(client,true);
Log::Line("Client Authentication Successful");
}
else
{
client->IsAuthenticated = false;
Server::Instance->PakSender->SendAuthReply(client,false);
Log::Warning("Client Authentication Failed");
}
free(auth);
return;
}
if (!client->IsAuthenticated) return;
//Log::Debug("Packet received2");
if (pak->Opcode == Packet::Ping)
{
client->Timeout = 0;
return;
}
if (pak->Opcode == Packet::FunctionRequest)
{
//Log::Debug("FunctionRequest received");
FunctionRequest* function = new FunctionRequest();
function->_Client = client;
function->guid = pak->ReadString(function->guid,FunctionRequest::STRING_SIZE);
function->name = pak->ReadString(function->name,FunctionRequest::STRING_SIZE);
function->response = pak->ReadInt32();
function->params = pak->ReadString(function->params,FunctionRequest::STRING_SIZE);
int datastart = pak->pos;
int datalength = pak->Length - datastart;
function->data->AddData(&(pak->Data[datastart]),datalength);
Server::Instance->FuncProcessor->AddFunctionRequestToQue(function);
//function = _Server->FuncProcessor->ProcessFunctionRequest(function);
//_Server->PakSender->SendFunctionResponse(client,function);
//delete(function);
return;
}
if (pak->Opcode == Packet::Test)
{
Log::Debug("Test packet received");
char* str1 = (char*)calloc(32,1);
str1 = pak->ReadString(str1,32);
int i = pak->ReadInt32();
char b = pak->ReadByte();
float f = pak->ReadFloat32();
char* str2 = (char*)calloc(32,1);
str2 = pak->ReadString(str2,32);
Packet* sp = new Packet();
sp->Opcode = Packet::Test;
sp->AddString(str1);
sp->AddInt32(i);
sp->AddByte(b);
sp->AddFloat32(f);
sp->AddString(str2);
Server::Instance->SendPacket(client,sp);
free(str1);
free(str2);
return;
}
}