From 590220bc924c7892a7c94ee1e41ea31d643511f9 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Mon, 23 Oct 2023 15:41:07 -0400 Subject: [PATCH] ajout d'adresse de serveur --- SQCSim2021/connector.cpp | 2 +- SQCSim2021/connector.h | 2 +- SQCSim2021/engine.cpp | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SQCSim2021/connector.cpp b/SQCSim2021/connector.cpp index 13c4cdc..0583b30 100644 --- a/SQCSim2021/connector.cpp +++ b/SQCSim2021/connector.cpp @@ -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); diff --git a/SQCSim2021/connector.h b/SQCSim2021/connector.h index 297be6f..81e2262 100644 --- a/SQCSim2021/connector.h +++ b/SQCSim2021/connector.h @@ -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; diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index b36496f..12e6e2e 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -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;