diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp index c2466fe3..e5824bd4 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp @@ -7,6 +7,7 @@ #include "..\..\Windows64\Network\WinsockNetLayer.h" #include "..\..\Minecraft.h" #include "..\..\User.h" +#include #endif CPlatformNetworkManagerStub *g_pPlatformNetworkManager; @@ -700,6 +701,7 @@ void CPlatformNetworkManagerStub::SearchForGames() #ifdef _WINDOWS64 std::vector lanSessions = WinsockNetLayer::GetDiscoveredSessions(); + //THEY GET DELETED HERE DAMMIT for (size_t i = 0; i < friendsSessions[0].size(); i++) delete friendsSessions[0][i]; friendsSessions[0].clear(); @@ -730,6 +732,53 @@ void CPlatformNetworkManagerStub::SearchForGames() friendsSessions[0].push_back(info); } + std::FILE* file = std::fopen("servers.txt", "r"); + + if (file) { + wstring wline; + int phase = 0; + + string ip; + wstring port; + wstring name; + + char buffer[512]; + while (std::fgets(buffer, sizeof(buffer), file)) { + if (phase == 0) { + ip = buffer; + phase = 1; + } + else if (phase == 1) { + wline = convStringToWstring(buffer); + port = wline; + phase = 2; + } + else if (phase == 2) { + wline = convStringToWstring(buffer); + name = wline; + phase = 0; + + //THEY GET DELETED AFTER USE LIKE 30 LINES UP!! + FriendSessionInfo* info = new FriendSessionInfo(); + wchar_t label[128]; + wcsncpy_s(label, sizeof(label)/sizeof(wchar_t), name.c_str(), _TRUNCATE); + size_t nameLen = wcslen(label); + info->displayLabel = new wchar_t[nameLen+1]; + wcscpy_s(info->displayLabel, nameLen + 1, label); + info->displayLabelLength = (unsigned char)nameLen; + info->displayLabelViewableStartIndex = 0; + info->data.isReadyToJoin = true; + info->data.isJoinable = true; + strncpy_s(info->data.hostIP, sizeof(info->data.hostIP), ip.c_str(), _TRUNCATE); + info->data.hostPort = stoi(port); + info->sessionId = (SessionID)(static_cast(inet_addr(ip.c_str())) | (static_cast(stoi(port)) << 32)); + friendsSessions[0].push_back(info); + } + } + + std::fclose(file); + } + m_searchResultsCount[0] = (int)friendsSessions[0].size(); if (m_SessionsUpdatedCallback != NULL)