diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp index 94153e2f..385bac17 100644 --- a/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp +++ b/Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp @@ -14,7 +14,7 @@ #endif #include "../../Minecraft.h" #include "../4JLibs/inc/4J_Profile.h" -#include "../Windows64_Launcher.h" +#include "../../../Minecraft.Server/Windows64/ServerAuth.h" #include "json.hpp" #include @@ -80,12 +80,7 @@ DisconnectPacket::eDisconnectReason WinsockNetLayer::s_joinRejectReason = Discon bool g_Win64MultiplayerHost = false; bool g_Win64MultiplayerJoin = false; -int g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT; -char g_Win64MultiplayerIP[256] = "127.0.0.1"; bool g_Win64DedicatedServer = false; -int g_Win64DedicatedServerPort = WIN64_NET_DEFAULT_PORT; -char g_Win64DedicatedServerBindIP[256] = ""; -bool g_Win64DedicatedServerLanAdvertise = true; char g_Win64RelayServerIP[256] = "relay.mclegacyedition.xyz"; wchar_t g_Win64RelayServerIP_Wide[256] = L"relay.mclegacyedition.xyz"; @@ -239,7 +234,6 @@ void WinsockNetLayer::Shutdown() bool WinsockNetLayer::HostGame(int port, const char* bindIp) { - if (Windows64Launcher::IsInOfflineMode()) return true; if (!s_initialized && !Initialize()) return false; s_isHost = true; @@ -295,7 +289,7 @@ bool WinsockNetLayer::HostGame(int port, const char* bindIp) return false; } - std::string authToken = Windows64Launcher::GetAuthenticationToken(); + std::string authToken = ServerAuth::GetAuthenticationToken(); std::string isDedicatedServer = (g_Win64DedicatedServer ? "1" : "0"); std::string req = "HOST " + authToken + " " + isDedicatedServer + "\n"; send(s_listenSocket, req.c_str(), (int)req.length(), 0); @@ -311,7 +305,6 @@ bool WinsockNetLayer::HostGame(int port, const char* bindIp) bool WinsockNetLayer::JoinGame(const char* ip, int port) { - if (Windows64Launcher::IsInOfflineMode()) return true; if (!s_initialized && !Initialize()) return false; s_isHost = false; @@ -373,7 +366,7 @@ bool WinsockNetLayer::JoinGame(const char* ip, int port) return false; } - std::string authToken = Windows64Launcher::GetAuthenticationToken(); + std::string authToken = ServerAuth::GetAuthenticationToken(); std::string hostname(ip); std::string req = "JOIN " + authToken + " 0 " + hostname + "\n"; send(s_hostConnectionSocket, req.c_str(), (int)req.length(), 0); @@ -423,7 +416,6 @@ bool WinsockNetLayer::JoinGame(const char* ip, int port) bool WinsockNetLayer::BeginJoinGame(const char* ip, int port) { - if (Windows64Launcher::IsInOfflineMode()) return true; if (!s_initialized && !Initialize()) return false; CancelJoinGame(); @@ -526,7 +518,7 @@ DWORD WINAPI WinsockNetLayer::JoinThreadProc(LPVOID param) continue; } - std::string authToken = Windows64Launcher::GetAuthenticationToken(); + std::string authToken = ServerAuth::GetAuthenticationToken(); std::string hostname(s_joinIP); std::string req = "JOIN " + authToken + " 0 " + hostname + "\n"; send(sock, req.c_str(), (int)req.length(), 0); @@ -838,7 +830,7 @@ DWORD WINAPI WinsockNetLayer::AcceptThreadProc(LPVOID param) continue; } - std::string authToken = Windows64Launcher::GetAuthenticationToken(); + std::string authToken = ServerAuth::GetAuthenticationToken(); std::string isDedicatedServer = (g_Win64DedicatedServer ? "1" : "0"); std::string acc = "ACCEPT " + authToken + " " + isDedicatedServer + " " + clientId + "\n"; send(clientSocket, acc.c_str(), (int)acc.length(), 0); @@ -1154,7 +1146,7 @@ bool WinsockNetLayer::JoinSplitScreen(int padIndex, BYTE* outSmallId) freeaddrinfo(result); // Send JOIN for the split-screen pad using the same session ID as the primary pad. - std::string authToken = Windows64Launcher::GetAuthenticationToken(); + std::string authToken = ServerAuth::GetAuthenticationToken(); std::string hostname(g_Win64MultiplayerIP); std::string req = "JOIN " + authToken + " 0 " + hostname + "\n"; send(sock, req.c_str(), (int)req.length(), 0); @@ -1307,8 +1299,6 @@ DWORD WINAPI WinsockNetLayer::ClientRecvThreadProc(LPVOID param) bool WinsockNetLayer::StartAdvertising(int gamePort, const wchar_t* hostName, unsigned int gameSettings, unsigned int texPackId, unsigned char subTexId, unsigned short netVer) { - if (Windows64Launcher::IsInOfflineMode()) return true; - if (s_advertising) return true; if (!s_initialized) return false; @@ -1417,7 +1407,7 @@ DWORD WINAPI WinsockNetLayer::AdvertiseThreadProc(LPVOID param) continue; } - std::string authToken = Windows64Launcher::GetAuthenticationToken(); + std::string authToken = ServerAuth::GetAuthenticationToken(); std::string isDedicatedServer = (g_Win64DedicatedServer ? "1" : "0"); std::string req = "ADVERTISE " + authToken + " " + isDedicatedServer; req += " " + std::to_string(data.playerCount); @@ -1441,7 +1431,6 @@ DWORD WINAPI WinsockNetLayer::AdvertiseThreadProc(LPVOID param) bool WinsockNetLayer::StartDiscovery() { - if (Windows64Launcher::IsInOfflineMode()) return true; if (s_discovering) return true; if (!s_initialized) return false; @@ -1524,7 +1513,7 @@ DWORD WINAPI WinsockNetLayer::DiscoveryThreadProc(LPVOID param) continue; } - std::string authToken = Windows64Launcher::GetAuthenticationToken(); + std::string authToken = ServerAuth::GetAuthenticationToken(); std::string req = "LIST " + authToken + " 0 dedicated " + g_GameVersion + "\n"; send(sock, req.c_str(), (int)req.length(), 0);