mirror of
https://github.com/LCEMP/LCEMP.git
synced 2026-08-20 09:57:09 +00:00
qol: add dedicated server check to sessioninfo
This commit is contained in:
parent
0e48021acd
commit
c1a9648bf4
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,6 +2,8 @@
|
||||||
# Build outputs
|
# Build outputs
|
||||||
# ===========================================
|
# ===========================================
|
||||||
x64/
|
x64/
|
||||||
|
x64_Server_Release/
|
||||||
|
x64_Server_Debug/
|
||||||
Minecraft.Client/x64/
|
Minecraft.Client/x64/
|
||||||
Minecraft.World/x64_Debug/
|
Minecraft.World/x64_Debug/
|
||||||
Minecraft.World/x64_Release/
|
Minecraft.World/x64_Release/
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,9 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost)
|
||||||
|
|
||||||
m_bLeavingGame = true;
|
m_bLeavingGame = true;
|
||||||
|
|
||||||
|
extern bool g_connectedToDedicatedServer;
|
||||||
|
g_connectedToDedicatedServer = false;
|
||||||
|
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
WinsockNetLayer::StopAdvertising();
|
WinsockNetLayer::StopAdvertising();
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -407,8 +410,10 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame,
|
||||||
IQNet::m_player[0].m_isRemote = false;
|
IQNet::m_player[0].m_isRemote = false;
|
||||||
IQNet::m_player[0].m_isHostPlayer = true;
|
IQNet::m_player[0].m_isHostPlayer = true;
|
||||||
IQNet::s_playerCount = 1;
|
IQNet::s_playerCount = 1;
|
||||||
|
#ifndef WITH_SERVER_CODE
|
||||||
extern wchar_t g_Win64UsernameW[17];
|
extern wchar_t g_Win64UsernameW[17];
|
||||||
wcscpy_s(IQNet::m_player[0].m_gamertag, 32, g_Win64UsernameW);
|
wcscpy_s(IQNet::m_player[0].m_gamertag, 32, g_Win64UsernameW);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_HostGame( localUsersMask, publicSlots, privateSlots );
|
_HostGame( localUsersMask, publicSlots, privateSlots );
|
||||||
|
|
@ -454,6 +459,9 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo *searchResult, int l
|
||||||
IQNet::m_player[0].m_isHostPlayer = true;
|
IQNet::m_player[0].m_isHostPlayer = true;
|
||||||
wcsncpy_s(IQNet::m_player[0].m_gamertag, 32, searchResult->data.hostName, _TRUNCATE);
|
wcsncpy_s(IQNet::m_player[0].m_gamertag, 32, searchResult->data.hostName, _TRUNCATE);
|
||||||
|
|
||||||
|
extern bool g_connectedToDedicatedServer;
|
||||||
|
g_connectedToDedicatedServer = searchResult->data.isDedicatedServer;
|
||||||
|
|
||||||
WinsockNetLayer::StopDiscovery();
|
WinsockNetLayer::StopDiscovery();
|
||||||
|
|
||||||
if (!WinsockNetLayer::JoinGame(hostIP, hostPort))
|
if (!WinsockNetLayer::JoinGame(hostIP, hostPort))
|
||||||
|
|
@ -793,6 +801,7 @@ void CPlatformNetworkManagerStub::SearchForGames()
|
||||||
info->data.subTexturePackId = lanSessions[i].subTexturePackId;
|
info->data.subTexturePackId = lanSessions[i].subTexturePackId;
|
||||||
info->data.isReadyToJoin = lanSessions[i].isJoinable;
|
info->data.isReadyToJoin = lanSessions[i].isJoinable;
|
||||||
info->data.isJoinable = lanSessions[i].isJoinable;
|
info->data.isJoinable = lanSessions[i].isJoinable;
|
||||||
|
info->data.isDedicatedServer = lanSessions[i].isDedicatedServer;
|
||||||
strncpy_s(info->data.hostIP, sizeof(info->data.hostIP), lanSessions[i].hostIP, _TRUNCATE);
|
strncpy_s(info->data.hostIP, sizeof(info->data.hostIP), lanSessions[i].hostIP, _TRUNCATE);
|
||||||
info->data.hostPort = lanSessions[i].hostPort;
|
info->data.hostPort = lanSessions[i].hostPort;
|
||||||
wcsncpy_s(info->data.hostName, XUSER_NAME_SIZE, lanSessions[i].hostName, _TRUNCATE);
|
wcsncpy_s(info->data.hostName, XUSER_NAME_SIZE, lanSessions[i].hostName, _TRUNCATE);
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ typedef struct _GameSessionData
|
||||||
|
|
||||||
bool isReadyToJoin;
|
bool isReadyToJoin;
|
||||||
bool isJoinable;
|
bool isJoinable;
|
||||||
|
bool isDedicatedServer;
|
||||||
|
|
||||||
char hostIP[64];
|
char hostIP[64];
|
||||||
int hostPort;
|
int hostPort;
|
||||||
|
|
@ -88,6 +89,7 @@ typedef struct _GameSessionData
|
||||||
subTexturePackId = 0;
|
subTexturePackId = 0;
|
||||||
isReadyToJoin = false;
|
isReadyToJoin = false;
|
||||||
isJoinable = true;
|
isJoinable = true;
|
||||||
|
isDedicatedServer = false;
|
||||||
memset(hostIP, 0, sizeof(hostIP));
|
memset(hostIP, 0, sizeof(hostIP));
|
||||||
hostPort = 0;
|
hostPort = 0;
|
||||||
memset(hostName, 0, sizeof(hostName));
|
memset(hostName, 0, sizeof(hostName));
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,8 @@ bool IQNet::s_isHosting = true;
|
||||||
|
|
||||||
QNET_STATE _iQNetStubState = QNET_STATE_IDLE;
|
QNET_STATE _iQNetStubState = QNET_STATE_IDLE;
|
||||||
|
|
||||||
|
bool g_connectedToDedicatedServer = false;
|
||||||
|
|
||||||
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal)
|
void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal)
|
||||||
{
|
{
|
||||||
player->m_smallId = smallId;
|
player->m_smallId = smallId;
|
||||||
|
|
@ -354,7 +356,13 @@ IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex)
|
||||||
}
|
}
|
||||||
static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index)
|
static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index)
|
||||||
{
|
{
|
||||||
if (index == 0) return true;
|
if (index == 0)
|
||||||
|
{
|
||||||
|
extern bool g_connectedToDedicatedServer;
|
||||||
|
if (g_connectedToDedicatedServer && !IQNet::s_isHosting)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (p->GetCustomDataValue() != 0) return true;
|
if (p->GetCustomDataValue() != 0) return true;
|
||||||
return (p->m_isRemote && p->m_gamertag[0] != 0);
|
return (p->m_isRemote && p->m_gamertag[0] != 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -893,12 +893,16 @@ void MinecraftServer::stopServer()
|
||||||
// 4J-PB - If the primary player has signed out, then don't attempt to save anything
|
// 4J-PB - If the primary player has signed out, then don't attempt to save anything
|
||||||
|
|
||||||
// also need to check for a profile switch here - primary player signs out, and another player signs in before dismissing the dash
|
// also need to check for a profile switch here - primary player signs out, and another player signs in before dismissing the dash
|
||||||
#ifdef _DURANGO
|
#ifdef WITH_SERVER_CODE
|
||||||
|
{
|
||||||
|
{
|
||||||
|
#elif defined(_DURANGO)
|
||||||
// On Durango check if the primary user is signed in OR mid-sign-out
|
// On Durango check if the primary user is signed in OR mid-sign-out
|
||||||
if(ProfileManager.GetUser(0, true) != nullptr)
|
if(ProfileManager.GetUser(0, true) != nullptr)
|
||||||
#else
|
#else
|
||||||
if((m_bPrimaryPlayerSignedOut==false) && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()))
|
if((m_bPrimaryPlayerSignedOut==false) && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad()))
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef WITH_SERVER_CODE
|
||||||
{
|
{
|
||||||
#if defined(_XBOX_ONE) || defined(__ORBIS__)
|
#if defined(_XBOX_ONE) || defined(__ORBIS__)
|
||||||
// Always save on exit! Except if saves are disabled.
|
// Always save on exit! Except if saves are disabled.
|
||||||
|
|
@ -907,6 +911,7 @@ void MinecraftServer::stopServer()
|
||||||
// if trial version or saving is disabled, then don't save anything
|
// if trial version or saving is disabled, then don't save anything
|
||||||
if(m_saveOnExit && ProfileManager.IsFullVersion() && (!StorageManager.GetSaveDisabled()))
|
if(m_saveOnExit && ProfileManager.IsFullVersion() && (!StorageManager.GetSaveDisabled()))
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
if (players != NULL)
|
if (players != NULL)
|
||||||
{
|
{
|
||||||
players->saveAll(Minecraft::GetInstance()->progressRenderer, true);
|
players->saveAll(Minecraft::GetInstance()->progressRenderer, true);
|
||||||
|
|
|
||||||
|
|
@ -796,6 +796,11 @@ bool WinsockNetLayer::StartAdvertising(int gamePort, const wchar_t *hostName, un
|
||||||
s_advertiseData.texturePackParentId = texPackId;
|
s_advertiseData.texturePackParentId = texPackId;
|
||||||
s_advertiseData.subTexturePackId = subTexId;
|
s_advertiseData.subTexturePackId = subTexId;
|
||||||
s_advertiseData.isJoinable = 0;
|
s_advertiseData.isJoinable = 0;
|
||||||
|
#ifdef WITH_SERVER_CODE
|
||||||
|
s_advertiseData.isDedicatedServer = 1;
|
||||||
|
#else
|
||||||
|
s_advertiseData.isDedicatedServer = 0;
|
||||||
|
#endif
|
||||||
s_hostGamePort = gamePort;
|
s_hostGamePort = gamePort;
|
||||||
LeaveCriticalSection(&s_advertiseLock);
|
LeaveCriticalSection(&s_advertiseLock);
|
||||||
|
|
||||||
|
|
@ -1009,6 +1014,7 @@ DWORD WINAPI WinsockNetLayer::DiscoveryThreadProc(LPVOID param)
|
||||||
s_discoveredSessions[i].texturePackParentId = broadcast->texturePackParentId;
|
s_discoveredSessions[i].texturePackParentId = broadcast->texturePackParentId;
|
||||||
s_discoveredSessions[i].subTexturePackId = broadcast->subTexturePackId;
|
s_discoveredSessions[i].subTexturePackId = broadcast->subTexturePackId;
|
||||||
s_discoveredSessions[i].isJoinable = (broadcast->isJoinable != 0);
|
s_discoveredSessions[i].isJoinable = (broadcast->isJoinable != 0);
|
||||||
|
s_discoveredSessions[i].isDedicatedServer = (broadcast->isDedicatedServer != 0);
|
||||||
s_discoveredSessions[i].lastSeenTick = now;
|
s_discoveredSessions[i].lastSeenTick = now;
|
||||||
memcpy(s_discoveredSessions[i].playerNames, broadcast->playerNames, sizeof(broadcast->playerNames));
|
memcpy(s_discoveredSessions[i].playerNames, broadcast->playerNames, sizeof(broadcast->playerNames));
|
||||||
found = true;
|
found = true;
|
||||||
|
|
@ -1036,6 +1042,7 @@ DWORD WINAPI WinsockNetLayer::DiscoveryThreadProc(LPVOID param)
|
||||||
session.texturePackParentId = broadcast->texturePackParentId;
|
session.texturePackParentId = broadcast->texturePackParentId;
|
||||||
session.subTexturePackId = broadcast->subTexturePackId;
|
session.subTexturePackId = broadcast->subTexturePackId;
|
||||||
session.isJoinable = (broadcast->isJoinable != 0);
|
session.isJoinable = (broadcast->isJoinable != 0);
|
||||||
|
session.isDedicatedServer = (broadcast->isDedicatedServer != 0);
|
||||||
session.lastSeenTick = now;
|
session.lastSeenTick = now;
|
||||||
memcpy(session.playerNames, broadcast->playerNames, sizeof(broadcast->playerNames));
|
memcpy(session.playerNames, broadcast->playerNames, sizeof(broadcast->playerNames));
|
||||||
s_discoveredSessions.push_back(session);
|
s_discoveredSessions.push_back(session);
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ struct Win64LANBroadcast
|
||||||
DWORD texturePackParentId;
|
DWORD texturePackParentId;
|
||||||
BYTE subTexturePackId;
|
BYTE subTexturePackId;
|
||||||
BYTE isJoinable;
|
BYTE isJoinable;
|
||||||
|
BYTE isDedicatedServer;
|
||||||
char playerNames[WIN64_LAN_BROADCAST_PLAYERS][XUSER_NAME_SIZE];
|
char playerNames[WIN64_LAN_BROADCAST_PLAYERS][XUSER_NAME_SIZE];
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
@ -48,6 +49,7 @@ struct Win64LANSession
|
||||||
unsigned int texturePackParentId;
|
unsigned int texturePackParentId;
|
||||||
unsigned char subTexturePackId;
|
unsigned char subTexturePackId;
|
||||||
bool isJoinable;
|
bool isJoinable;
|
||||||
|
bool isDedicatedServer;
|
||||||
DWORD lastSeenTick;
|
DWORD lastSeenTick;
|
||||||
char playerNames[WIN64_LAN_BROADCAST_PLAYERS][XUSER_NAME_SIZE];
|
char playerNames[WIN64_LAN_BROADCAST_PLAYERS][XUSER_NAME_SIZE];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue