diff --git a/jscore.cpp b/jscore.cpp index f9710c0..d0a1e6b 100644 --- a/jscore.cpp +++ b/jscore.cpp @@ -1,10 +1,15 @@ #include "jscore.h" #include +#include +#include #include -#include -//#include -//#include -//#include +#ifdef WIN32 + #include +#else + #include + #include + #include +#endif #include #include #include @@ -23,12 +28,15 @@ namespace jscore { struct sockaddr_in client; int PORT = 9911; const char *HOST = "jaildoctor.duckdns.org"; +#ifdef WIN32 WSADATA WsaData; +#endif std::string sendRequest(const std::string request) { +#ifdef WIN32 int ret = WSAStartup(0x101,&WsaData); if (ret != 0) return 0; - +#endif struct hostent * host = gethostbyname(HOST); if ( (host == NULL) || (host->h_addr == NULL) ) { @@ -72,7 +80,9 @@ namespace jscore { buffer[pos] = cur; pos++; } +#ifdef WIN32 WSACleanup(); +#endif buffer[pos]=0; return buffer; } @@ -106,8 +116,7 @@ namespace jscore { } const bool updateUserPoints(std::string game, std::string user, const int points) { - char dst[255]; - std::string strbuff = sendRequest("GET /score-update.php?game=" + game + "&user=" + user + "&points=" + itoa(points, dst, 10)); + std::string strbuff = sendRequest("GET /score-update.php?game=" + game + "&user=" + user + "&points=" + to_string(points)); initOnlineScore(game); }