mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Code to read servers.txt
This commit is contained in:
parent
4108ed142b
commit
086dfc8773
|
|
@ -7,6 +7,8 @@
|
||||||
#include "..\..\Windows64\Network\WinsockNetLayer.h"
|
#include "..\..\Windows64\Network\WinsockNetLayer.h"
|
||||||
#include "..\..\Minecraft.h"
|
#include "..\..\Minecraft.h"
|
||||||
#include "..\..\User.h"
|
#include "..\..\User.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
CPlatformNetworkManagerStub *g_pPlatformNetworkManager;
|
||||||
|
|
@ -730,6 +732,51 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
||||||
friendsSessions[0].push_back(info);
|
friendsSessions[0].push_back(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: add file checking for servers.txt
|
||||||
|
#ifdef _WINDOWS64 //Should we have this windows64 only? idk i havent tested so...
|
||||||
|
ifstream ServersTxt("servers.txt");
|
||||||
|
if (ServersTxt) {
|
||||||
|
string line;
|
||||||
|
wstring wline;
|
||||||
|
int phase = 0;
|
||||||
|
string ip;
|
||||||
|
wstring port;
|
||||||
|
wstring name;
|
||||||
|
while (getline(ServersTxt, line)) {
|
||||||
|
wline = convStringToWstring(line);
|
||||||
|
if (phase == 0) {
|
||||||
|
ip = line;
|
||||||
|
phase = 1;
|
||||||
|
}
|
||||||
|
else if (phase == 1) {
|
||||||
|
port = wline;
|
||||||
|
phase = 2;
|
||||||
|
}
|
||||||
|
else if (phase == 2) {
|
||||||
|
name = wline;
|
||||||
|
phase = 0;
|
||||||
|
|
||||||
|
//Add server to the list!
|
||||||
|
FriendSessionInfo* info = new FriendSessionInfo();
|
||||||
|
wchar_t label[128];
|
||||||
|
swprintf(label, L"%S", name);
|
||||||
|
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)((unsigned __int64)inet_addr(ip.c_str()) | ((unsigned __int64)stoi(port) << 32));
|
||||||
|
friendsSessions[0].push_back(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ServersTxt.close();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
m_searchResultsCount[0] = (int)friendsSessions[0].size();
|
||||||
|
|
||||||
if (m_SessionsUpdatedCallback != NULL)
|
if (m_SessionsUpdatedCallback != NULL)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue