Merge remote-tracking branch 'origin/main' into feat/multiplayer-fix
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include "..\..\Windows64\Network\WinsockNetLayer.h"
|
#include "..\..\Windows64\Network\WinsockNetLayer.h"
|
||||||
#include "..\..\Minecraft.h"
|
#include "..\..\Minecraft.h"
|
||||||
#include "..\..\User.h"
|
#include "..\..\User.h"
|
||||||
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||||
@@ -700,6 +701,7 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
|||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
std::vector<Win64LANSession> lanSessions = WinsockNetLayer::GetDiscoveredSessions();
|
std::vector<Win64LANSession> lanSessions = WinsockNetLayer::GetDiscoveredSessions();
|
||||||
|
|
||||||
|
//THEY GET DELETED HERE DAMMIT
|
||||||
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||||
delete friendsSessions[0][i];
|
delete friendsSessions[0][i];
|
||||||
friendsSessions[0].clear();
|
friendsSessions[0].clear();
|
||||||
@@ -730,6 +732,53 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
|||||||
friendsSessions[0].push_back(info);
|
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<uint64_t>(inet_addr(ip.c_str())) | (static_cast<uint64_t>(stoi(port)) << 32));
|
||||||
|
friendsSessions[0].push_back(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
||||||
|
|
||||||
if (m_SessionsUpdatedCallback != NULL)
|
if (m_SessionsUpdatedCallback != NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user