Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Wrong data in packets.  (Read 3852 times)

0 Members and 1 Guest are viewing this topic.

amited

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Wrong data in packets.
« on: November 05, 2018, 08:18:18 am »
Im sending player ID in packet to client for him players table. Im checking my ID and sending it in Uint16 to client but he dont receive this... or receive a random data ;/ Code:
Server side when client join:

                        if (type == DOLACZENIE) // client send this when join
                        {
                                ++IDS;
                                it->second = IDS;
                                gracze[IDS].gra = true; // player with ID = IDS is now playing
                                Packet paccc;
                                Uint16 cos = IDS;
                                if (paccc << cos)
                                {
                                        WyslijPakiet(POLACZONO, paccc); // sending my paccc to client
                                        cout << "CONNECT: " << cos << endl;
                                }
                        }
Client receive:
                        if (type == POLACZONO) // get ID from serwer
                        {
                                Uint16 cos;
                                if (pac >> cos)
                                {
                                        cout << "ID in connect: " << cos << endl;
                                        packet >> cos;
                                }
                                else
                                {
                                        cout << "error in pac" << endl;
                                }
                        }
Output info in console:

CONNECT: 0
error in pac

amited

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: Wrong data in packets.
« Reply #1 on: November 05, 2018, 05:25:03 pm »
Problem solve :) I cant send packet in packet like i did ;p

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Wrong data in packets.
« Reply #2 on: November 05, 2018, 06:31:32 pm »
Btw. I highly recommend to code in English only.
It's really hard for others to otherwise figure out what the code does. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything