1
Network / Re: 8 bit bools in packets instead of 1 bit
« on: July 20, 2014, 03:47:34 pm »
Thanks again! You've helped me think a few ideas through
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Packet& Packet::operator <<(bool data)
{
*this << static_cast<Uint8>(data);
return *this;
}
// the first packet
sf::Packet packet1;
packet1 << std::string("eat") << std::string("IceCream");
// the second packet
sf::Packet packet2;
packet2 << std::string("run") << FORWARD_RUN;
// the two above packets appended would be read like
sf::Packet packet1plus2;
std::string cmd1, cmd2, item;
int runDir;
packet1plus2 >> cmd1 >> item >> cmd2 >> runDir;