void NetManager::sendClientPacket() { ENetPacket* packet = enet_packet_create(NULL, sizeof(ClientPacket), 0); auto player = FAWorld::World::get()->getCurrentPlayer(); ClientPacket data; data.destX = player->destination().first; data.destY = player->destination().second; data.levelIndex = mLevelIndexTmp; size_t position = 0; writeToPacket(packet, position, data); enet_peer_send(mServerPeer, UNRELIABLE_CHANNEL_ID, packet); if(mUnknownServerSprites.size()) sendSpriteRequest(mServerPeer); }
void Client::sendClientPacket() { auto packet = getWritePacket(Engine::PacketType::ClientToServerUpdate, 0, false, Engine::WritePacketResizableType::Resizable); auto player = FAWorld::World::get()->getCurrentPlayer(); ClientPacket data; data.destX = player->mMoveHandler.getDestination().first; data.destY = player->mMoveHandler.getDestination().second; data.targetActorId = -1; if (auto actorPtr = boost::get<FAWorld::Actor*> (&player->mTarget)) data.targetActorId = (*actorPtr)->getId(); packet.writer.handleObject(data); sendPacket(packet, mServerPeer); if (mUnknownServerSprites.size()) sendSpriteRequest(); }