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; }
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; } }