From 46666155350e0d154ee32344df8436c1ed3a7d43 Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Wed, 16 Nov 2022 13:38:01 +0100 Subject: [PATCH] =?UTF-8?q?-=20Afegida=20la=20funci=C3=B3=20"init(host,=20?= =?UTF-8?q?port)"=20per=20a=20donar=20la=20opci=C3=B3=20de=20pasar=20per?= =?UTF-8?q?=20par=C3=A0metre=20el=20servidor=20que=20ara=20JDes=20ho=20te?= =?UTF-8?q?=20hard=20coded.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jscore.cpp | 12 +++++++++--- jscore.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/jscore.cpp b/jscore.cpp index 2b2676a..bb9e7cd 100644 --- a/jscore.cpp +++ b/jscore.cpp @@ -3,7 +3,7 @@ #include #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #else #include @@ -26,8 +26,9 @@ namespace jscore { #define bzero(b,len) (memset((b), '\0', (len)), (void) 0) int sock; struct sockaddr_in client; + int PORT = 9911; - const char *HOST = "jaildoctor.duckdns.org"; + string HOST = "jaildoctor.duckdns.org"; #ifdef WIN32 WSADATA WsaData; @@ -36,6 +37,11 @@ namespace jscore { bool jscore_error = false; string error_message; + void init(std::string host, const int port) { + PORT = port; + HOST = host; + } + void setErrorMessage(string message) { jscore_error = true; error_message = message; @@ -46,7 +52,7 @@ namespace jscore { int ret = WSAStartup(0x101,&WsaData); if (ret != 0) return 0; #endif - struct hostent * host = gethostbyname(HOST); + struct hostent * host = gethostbyname(HOST.c_str()); if ( (host == NULL) || (host->h_addr == NULL) ) { setErrorMessage("Error retrieving DNS information.\n"); diff --git a/jscore.h b/jscore.h index 43feb9b..8378a4a 100644 --- a/jscore.h +++ b/jscore.h @@ -2,6 +2,7 @@ #include namespace jscore { + void init(std::string host, const int port); const bool initOnlineScore(std::string game); const int getNumUsers(); std::string getUserName(const int index);