Send:
packet << static_cast<sf::Uint32>(list.size());
for (std::list<xxx>::const_iterator it = list.begin(); it != list.end(); ++it)
packet << *it;
Receive:
sf::Uint32 size;
packet >> size;
for (sf::Uint32 i = 0; i < size; ++i)
{
xxx item;
packet >> item;
list.push_back(item);
}
:O that was fast, although another dumb question (Sorry!)
What if the list or vector contains a class, instead of an int?
Same method?
for instance, Enemy class, contains health, sprite, damage, speed, etc. and there's roughly 20 in a list, I can just use that method above and dynamically push back a new Enemy into the new list after receiving the packet?
Again, thanks for the fast reply, and sorry for being ignorant, I'm slow today :x