예제 #1
0
    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);
    }
예제 #2
0
파일: client.cpp 프로젝트: gnaghi/freeablo
    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();
    }