This is a part of my code,
void GlobalWorld::SendPlayers(sf::TcpSocket * client) {
if(this->Players!=NULL){
sf::Packet SentPacket;
SentPacket << this->numPlayers;
for(int index=0;index<this->maxPlayers;index++){
if(this->Players[index].Connected){
//the current player is connected, add the data to the packet
SentPacket << Players[index].Position.x << Players[index].Position.y << Players[index].Rotation << Players[index].Health << Players[index].Name;
}
}
int x;
float z;
SentPacket >> x >> z;
std::cout << x << z;
client->send(SentPacket);
}
}
The x,z part is used for debugging so every time I call that function z will result as undefined float, however if I print the value which z should be (Players[index].Position.x, Position is vector2f) it prints the real result.
But the x matches with the numPlayers member of the GlobalWorld.
What's wrong?