diff --git a/CMakeLists.txt b/CMakeLists.txt index 596c6ed..d687573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.10) project(Server) set(CMAKE_CXX_STANDARD 17) +if (WIN32) + message(STATUS "MSVC -> forcing use of statically-linked runtime.") + STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) + STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) + #-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static +endif () # this has to happen before -DDEBUG since it wont compile properly with -DDEBUG include_directories("asio/asio/include") @@ -20,12 +26,7 @@ if (UNIX) message(STATUS "sanitize is ON") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined,thread") endif (SANITIZE) -elseif (WIN32) - message(STATUS "MSVC -> forcing use of statically-linked runtime.") - STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - #-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -endif () +endif() find_package(Boost REQUIRED COMPONENTS system thread) diff --git a/include/Compat.h b/include/Compat.h index 6c3953d..8f66409 100644 --- a/include/Compat.h +++ b/include/Compat.h @@ -23,7 +23,7 @@ inline void CloseSocketProper(int socket) { #ifdef WIN32 #include #include -inline void CloseSocketProper(int socket) { +inline void CloseSocketProper(u_int64 socket) { shutdown(socket, SD_BOTH); closesocket(socket); } diff --git a/src/Client.cpp b/src/Client.cpp index 7459855..a404aa1 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -79,5 +79,5 @@ int TClient::SecondsSinceLastPing() { auto seconds = std::chrono::duration_cast( std::chrono::high_resolution_clock::now() - mLastPingTime) .count(); - return seconds; + return int(seconds); } diff --git a/src/TUDPServer.cpp b/src/TUDPServer.cpp index 4407c41..791ac5f 100644 --- a/src/TUDPServer.cpp +++ b/src/TUDPServer.cpp @@ -133,7 +133,7 @@ void TUDPServer::UDPSend(TClient& Client, std::string Data) const { size_t len = Data.size(); #endif // WIN32 - sendOk = sendto(mUDPSock, Data.c_str(), len, 0, (sockaddr*)&Addr, AddrSize); + sendOk = sendto(mUDPSock, Data.c_str(), len, 0, (sockaddr*)&Addr, int(AddrSize)); #ifdef WIN32 if (sendOk == -1) { debug(("(UDP) Send Failed Code : ") + std::to_string(WSAGetLastError())); @@ -161,7 +161,7 @@ std::string TUDPServer::UDPRcvFromClient(sockaddr_in& client) const { size_t clientLength = sizeof(client); std::array Ret {}; #ifdef WIN32 - int64_t Rcv = recvfrom(mUDPSock, Ret.data(), Ret.size(), 0, (sockaddr*)&client, (int*)&clientLength); + int64_t Rcv = recvfrom(mUDPSock, Ret.data(), int(Ret.size()), 0, (sockaddr*)&client, (int*)&clientLength); #else // unix int64_t Rcv = recvfrom(mUDPSock, Ret.data(), Ret.size(), 0, (sockaddr*)&client, (socklen_t*)&clientLength); #endif // WIN32