ajout d'adresse de serveur

This commit is contained in:
MarcEricMartel 2023-10-23 15:41:07 -04:00
parent 0e7b8973e7
commit 590220bc92
3 changed files with 8 additions and 4 deletions

View File

@ -42,7 +42,7 @@ int Connector::Init() {
return 0;
}
int Connector::Connect(char* srv_addr, std::string name) {
int Connector::Connect(const char* srv_addr, std::string name) {
sockaddr_in add;
m_srvsockaddr.sin_family = AF_INET;
m_srvsockaddr.sin_port = htons(SRV_PORT);

View File

@ -11,7 +11,7 @@ public:
~Connector();
int Init();
int Connect(char* srv_addr, std::string name);
int Connect(const char* srv_addr, std::string name);
uint64_t getId() const;
unsigned int getSeed() const;

View File

@ -230,7 +230,7 @@ void Engine::Init() {
}
uint64_t seed = SEED;
std::string playname = "";
std::string playname = "", srvname = "";
char ch;
glDisable(GL_FRAMEBUFFER_SRGB);
@ -275,8 +275,12 @@ void Engine::Init() {
std::cin >> playname;
std::cout << std::endl;
std::cout << "Veuillez entrer une adresse de serveur: ";
std::cin >> srvname;
std::cout << std::endl;
if (!m_conn.Init()) {
if (!m_conn.Connect(SRV_ADDR, playname)) {
if (!m_conn.Connect(srvname.c_str(), playname)) {
// setup jeu en reseau.
std::cout << "ID recu du serveur: " << std::to_string(m_conn.getId()) << "!" << std::endl;
std::cout << "Seed recu du serveur: " << std::to_string(m_conn.getSeed()) << "!" << std::endl;