mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-04-23 07:24:14 +00:00
feat: add missing commandline implementations
This commit is contained in:
parent
a765c08d56
commit
8a48e6dcc3
|
|
@ -705,6 +705,33 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
|||
#ifdef _WINDOWS64
|
||||
std::vector<Win64LANSession> lanSessions = WinsockNetLayer::GetDiscoveredSessions();
|
||||
|
||||
if (g_Win64MultiplayerJoin)
|
||||
{
|
||||
bool alreadyPresent = false;
|
||||
for (size_t i = 0; i < lanSessions.size(); i++)
|
||||
{
|
||||
if (strcmp(lanSessions[i].hostIP, g_Win64MultiplayerIP) == 0 &&
|
||||
lanSessions[i].hostPort == g_Win64MultiplayerPort)
|
||||
{
|
||||
alreadyPresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyPresent)
|
||||
{
|
||||
Win64LANSession manual;
|
||||
memset(&manual, 0, sizeof(manual));
|
||||
strncpy_s(manual.hostIP, sizeof(manual.hostIP), g_Win64MultiplayerIP, _TRUNCATE);
|
||||
manual.hostPort = g_Win64MultiplayerPort;
|
||||
swprintf_s(manual.hostName, 32, L"%hs:%d", g_Win64MultiplayerIP, g_Win64MultiplayerPort);
|
||||
manual.playerCount = 0;
|
||||
manual.maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
|
||||
manual.isJoinable = true;
|
||||
manual.lastSeenTick = GetTickCount();
|
||||
lanSessions.push_back(manual);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < friendsSessions[0].size(); i++)
|
||||
delete friendsSessions[0][i];
|
||||
friendsSessions[0].clear();
|
||||
|
|
|
|||
|
|
@ -807,6 +807,32 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
|||
nameBuf[n] = 0;
|
||||
strncpy_s(g_Win64Username, 17, nameBuf, _TRUNCATE);
|
||||
}
|
||||
|
||||
char *ipArg = strstr(cmdLineA, "-ip ");
|
||||
if (ipArg)
|
||||
{
|
||||
ipArg += 4;
|
||||
while (*ipArg == ' ') ipArg++;
|
||||
char ipBuf[256];
|
||||
int n = 0;
|
||||
while (ipArg[n] && ipArg[n] != ' ' && n < 255) { ipBuf[n] = ipArg[n]; n++; }
|
||||
ipBuf[n] = 0;
|
||||
strncpy_s(g_Win64MultiplayerIP, 256, ipBuf, _TRUNCATE);
|
||||
g_Win64MultiplayerJoin = true;
|
||||
}
|
||||
|
||||
char *portArg = strstr(cmdLineA, "-port ");
|
||||
if (portArg)
|
||||
{
|
||||
portArg += 6;
|
||||
while (*portArg == ' ') portArg++;
|
||||
char portBuf[16];
|
||||
int n = 0;
|
||||
while (portArg[n] && portArg[n] != ' ' && n < 15) { portBuf[n] = portArg[n]; n++; }
|
||||
portBuf[n] = 0;
|
||||
g_Win64MultiplayerPort = atoi(portBuf);
|
||||
if (g_Win64MultiplayerPort <= 0) g_Win64MultiplayerPort = WIN64_NET_DEFAULT_PORT;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_Win64Username[0] == 0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue