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

Author Topic: Packets and Arrays  (Read 3785 times)

0 Members and 1 Guest are viewing this topic.

DarkNemesis

  • Newbie
  • *
  • Posts: 11
    • View Profile
Packets and Arrays
« on: August 13, 2013, 09:39:50 pm »
I know this question have been asked and answered several times, but since I wasn't satisfied with those, I decided to make a new thread. I have a 2D map array, which I want my server to send to the client. So other than arranging the packet manually like this
{
DataPacket << data[0] << data[1] << data[2]....
}
is there a better and quicker way to store the complete 2D array into the packet and send it to the client?

Ivan

  • Newbie
  • *
  • Posts: 32
  • IT geek
    • View Profile
Re: Packets and Arrays
« Reply #1 on: August 13, 2013, 09:56:35 pm »
You can use a For loop to fill the packet or just overload the operators >> and << as its explained in the tutorials Extending Packets

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Packets and Arrays
« Reply #2 on: August 13, 2013, 09:56:46 pm »
A loop? ???
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ivan

  • Newbie
  • *
  • Posts: 32
  • IT geek
    • View Profile
Re: Packets and Arrays
« Reply #3 on: August 13, 2013, 10:07:22 pm »
A loop? ???

I mean:

sf::Packet DataPacket;
for (int i = 0; i < sizeData; i++)
{
      DataPacket << data[i];
}
 

 ::)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Packets and Arrays
« Reply #4 on: August 13, 2013, 10:08:15 pm »
Was directed to DarkNemesis, you and I meant the same :D
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Ivan

  • Newbie
  • *
  • Posts: 32
  • IT geek
    • View Profile
Re: Packets and Arrays
« Reply #5 on: August 13, 2013, 10:10:53 pm »
Ouuch, sorry  ;D

 

anything