1
Network / Packets : Vector Transfers and sf::objects
« on: April 29, 2020, 03:54:26 pm »
Hello,
I feel like I'm kind alone on this forum but I still try
I have two question :
1- Is it possible to send a structure (or whatever) with vectors in it by packet >> ?
Like this :
This doesn't work of course, and when I try to send the size of the vector then every element in it with a for(i=0; i < myVector.size() ; i++) , it gives me an error as well .
2- Is it possible to send sf::objects in packet ?
I'd like to send a lot of sf::RectangleShape , or CircleShape, but this :
Thanks for your help,
Cya
I feel like I'm kind alone on this forum but I still try
I have two question :
1- Is it possible to send a structure (or whatever) with vectors in it by packet >> ?
Like this :
typedef struct BMMaps BMMap;
struct BMMaps
{
std::string nom = "Map par défaut" ;
int background = 0;
std::vector<Plateforme> plateformes;
};
inline sf::Packet& operator <<(sf::Packet& packet, const BMMap& m)
{
return packet << m.nom << m.background << m.plateformes ;
}
inline sf::Packet& operator >>(sf::Packet& packet, BMMap& m)
{
return packet >> m.nom >> m.background >> m.plateformes ;
}
struct BMMaps
{
std::string nom = "Map par défaut" ;
int background = 0;
std::vector<Plateforme> plateformes;
};
inline sf::Packet& operator <<(sf::Packet& packet, const BMMap& m)
{
return packet << m.nom << m.background << m.plateformes ;
}
inline sf::Packet& operator >>(sf::Packet& packet, BMMap& m)
{
return packet >> m.nom >> m.background >> m.plateformes ;
}
This doesn't work of course, and when I try to send the size of the vector then every element in it with a for(i=0; i < myVector.size() ; i++) , it gives me an error as well .
2- Is it possible to send sf::objects in packet ?
I'd like to send a lot of sf::RectangleShape , or CircleShape, but this :
sf::RectangleShape r;
sf::Packet p << r;
doesn't work. I mean, I guess sfml made its own packet object compatible with its own others objetcs ?sf::Packet p << r;
Thanks for your help,
Cya