aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/Network/GameNetworkManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.Client/Common/Network/GameNetworkManager.cpp')
-rw-r--r--Minecraft.Client/Common/Network/GameNetworkManager.cpp53
1 files changed, 34 insertions, 19 deletions
diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp
index a502dbfb..50aeae68 100644
--- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp
+++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp
@@ -200,10 +200,12 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
#endif
int64_t seed = 0;
+ bool dedicatedNoLocalHostPlayer = false;
if (lpParameter != nullptr)
{
NetworkGameInitData *param = static_cast<NetworkGameInitData *>(lpParameter);
seed = param->seed;
+ dedicatedNoLocalHostPlayer = param->dedicatedNoLocalHostPlayer;
app.setLevelGenerationOptions(param->levelGen);
if(param->levelGen != nullptr)
@@ -359,9 +361,19 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
// PRIMARY PLAYER
vector<ClientConnection *> createdConnections;
- ClientConnection *connection;
+ ClientConnection *connection = nullptr;
- if( g_NetworkManager.IsHost() )
+ if( g_NetworkManager.IsHost() && dedicatedNoLocalHostPlayer )
+ {
+ app.DebugPrintf("Dedicated server mode: skipping local host client connection\n");
+
+ // Keep telemetry behavior consistent with the host path.
+ INT multiplayerInstanceId = TelemetryManager->GenerateMultiplayerInstanceId();
+ TelemetryManager->SetMultiplayerInstanceId(multiplayerInstanceId);
+
+ app.SetGameMode( eMode_Multiplayer );
+ }
+ else if( g_NetworkManager.IsHost() )
{
connection = new ClientConnection(minecraft, nullptr);
}
@@ -390,16 +402,18 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
connection = new ClientConnection(minecraft, socket);
}
- if( !connection->createdOk )
+ if (connection != nullptr)
{
- assert(false);
- delete connection;
- connection = nullptr;
- MinecraftServer::HaltServer();
- return false;
- }
+ if( !connection->createdOk )
+ {
+ assert(false);
+ delete connection;
+ connection = nullptr;
+ MinecraftServer::HaltServer();
+ return false;
+ }
- connection->send(std::make_shared<PreLoginPacket>(minecraft->user->name));
+ connection->send(std::make_shared<PreLoginPacket>(minecraft->user->name));
// Tick connection until we're ready to go. The stages involved in this are:
// (1) Creating the ClientConnection sends a prelogin packet to the server
@@ -434,9 +448,9 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
connection->close();
}
- if( connection->isStarted() && !connection->isClosed() )
- {
- createdConnections.push_back( connection );
+ if( connection->isStarted() && !connection->isClosed() )
+ {
+ createdConnections.push_back( connection );
int primaryPad = ProfileManager.GetPrimaryPad();
app.SetRichPresenceContext(primaryPad,CONTEXT_GAME_STATE_BLANK);
@@ -533,13 +547,14 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
}
}
- app.SetGameMode( eMode_Multiplayer );
- }
- else if ( connection->isClosed() || !IsInSession())
- {
+ app.SetGameMode( eMode_Multiplayer );
+ }
+ else if ( connection->isClosed() || !IsInSession())
+ {
// assert(false);
- MinecraftServer::HaltServer();
- return false;
+ MinecraftServer::HaltServer();
+ return false;
+ }
}