mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
refactor: extract a network service interface for minecraft to depend on
This commit is contained in:
parent
03618ed156
commit
b3d6e7151b
|
|
@ -61,6 +61,13 @@ class INVITE_INFO;
|
||||||
CGameNetworkManager g_NetworkManager;
|
CGameNetworkManager g_NetworkManager;
|
||||||
IPlatformNetwork* CGameNetworkManager::s_pPlatformNetworkManager;
|
IPlatformNetwork* CGameNetworkManager::s_pPlatformNetworkManager;
|
||||||
|
|
||||||
|
// minecraft/-side function accessor for INetworkService.
|
||||||
|
namespace minecraft::network::platform_internal {
|
||||||
|
::minecraft::network::INetworkService& NetworkService_get() {
|
||||||
|
return g_NetworkManager;
|
||||||
|
}
|
||||||
|
} // namespace minecraft::network::platform_internal
|
||||||
|
|
||||||
int64_t CGameNetworkManager::messageQueue[512];
|
int64_t CGameNetworkManager::messageQueue[512];
|
||||||
int64_t CGameNetworkManager::byteQueue[512];
|
int64_t CGameNetworkManager::byteQueue[512];
|
||||||
int CGameNetworkManager::messageQueuePos = 0;
|
int CGameNetworkManager::messageQueuePos = 0;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "platform/PlatformTypes.h"
|
#include "platform/PlatformTypes.h"
|
||||||
#include "app/common/Network/IPlatformNetwork.h"
|
#include "app/common/Network/IPlatformNetwork.h"
|
||||||
#include "platform/NetTypes.h"
|
#include "platform/NetTypes.h"
|
||||||
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "PlatformNetworkManagerStub.h"
|
#include "PlatformNetworkManagerStub.h"
|
||||||
#include "minecraft/network/platform/SessionInfo.h"
|
#include "minecraft/network/platform/SessionInfo.h"
|
||||||
|
|
@ -29,7 +30,7 @@ const int NON_QNET_SENDDATA_ACK_REQUIRED = 1;
|
||||||
// network implementation (eg QNET), rather it should interface with an
|
// network implementation (eg QNET), rather it should interface with an
|
||||||
// implementation of PlatformNetworkManager to provide this functionality.
|
// implementation of PlatformNetworkManager to provide this functionality.
|
||||||
|
|
||||||
class CGameNetworkManager {
|
class CGameNetworkManager : public ::minecraft::network::INetworkService {
|
||||||
friend class IPlatformNetworkStub;
|
friend class IPlatformNetworkStub;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#include "User.h"
|
#include "User.h"
|
||||||
#include "app/common/Audio/SoundEngine.h"
|
#include "app/common/Audio/SoundEngine.h"
|
||||||
#include "app/common/DLC/DLCManager.h"
|
#include "app/common/DLC/DLCManager.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "app/common/Tutorial/Tutorial.h"
|
#include "app/common/Tutorial/Tutorial.h"
|
||||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||||
|
|
@ -806,7 +806,7 @@ bool Minecraft::addLocalPlayer(int idx) {
|
||||||
m_connectionFailed[idx] = false;
|
m_connectionFailed[idx] = false;
|
||||||
m_pendingLocalConnections[idx] = nullptr;
|
m_pendingLocalConnections[idx] = nullptr;
|
||||||
|
|
||||||
bool success = g_NetworkManager.AddLocalPlayerByUserIndex(idx);
|
bool success = NetworkService.AddLocalPlayerByUserIndex(idx);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
Log::info("Adding temp local player on pad %d\n", idx);
|
Log::info("Adding temp local player on pad %d\n", idx);
|
||||||
|
|
@ -827,7 +827,7 @@ bool Minecraft::addLocalPlayer(int idx) {
|
||||||
ui.NavigateToScene(idx, eUIScene_ConnectingProgress, param);
|
ui.NavigateToScene(idx, eUIScene_ConnectingProgress, param);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log::info("g_NetworkManager.AddLocalPlayerByUserIndex failed\n");
|
Log::info("NetworkService.AddLocalPlayerByUserIndex failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|
@ -957,7 +957,7 @@ void Minecraft::removeLocalPlayerIdx(int idx) {
|
||||||
->removeClientConnection(mplp->connection, true);
|
->removeClientConnection(mplp->connection, true);
|
||||||
delete mplp->connection;
|
delete mplp->connection;
|
||||||
mplp->connection = nullptr;
|
mplp->connection = nullptr;
|
||||||
g_NetworkManager.RemoveLocalPlayerByUserIndex(idx);
|
NetworkService.RemoveLocalPlayerByUserIndex(idx);
|
||||||
}
|
}
|
||||||
getLevel(localplayers[idx]->dimension)->removeEntity(localplayers[idx]);
|
getLevel(localplayers[idx]->dimension)->removeEntity(localplayers[idx]);
|
||||||
|
|
||||||
|
|
@ -975,7 +975,7 @@ void Minecraft::removeLocalPlayerIdx(int idx) {
|
||||||
;
|
;
|
||||||
delete m_pendingLocalConnections[idx];
|
delete m_pendingLocalConnections[idx];
|
||||||
m_pendingLocalConnections[idx] = nullptr;
|
m_pendingLocalConnections[idx] = nullptr;
|
||||||
g_NetworkManager.RemoveLocalPlayerByUserIndex(idx);
|
NetworkService.RemoveLocalPlayerByUserIndex(idx);
|
||||||
} else {
|
} else {
|
||||||
// Not sure how this works on qnet, but for other platforms, calling
|
// Not sure how this works on qnet, but for other platforms, calling
|
||||||
// RemoveLocalPlayerByUserIndex won't do anything if there isn't a local
|
// RemoveLocalPlayerByUserIndex won't do anything if there isn't a local
|
||||||
|
|
@ -1062,7 +1062,7 @@ void Minecraft::run_middle() {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 4J-PB - AUTOSAVE TIMER - if the player is the host
|
// 4J-PB - AUTOSAVE TIMER - if the player is the host
|
||||||
if (level != nullptr && g_NetworkManager.IsHost()) {
|
if (level != nullptr && NetworkService.IsHost()) {
|
||||||
/*if(!bAutosaveTimerSet)
|
/*if(!bAutosaveTimerSet)
|
||||||
{
|
{
|
||||||
// set the timer
|
// set the timer
|
||||||
|
|
@ -1184,7 +1184,7 @@ void Minecraft::run_middle() {
|
||||||
// list get the unique save name and xuid from
|
// list get the unique save name and xuid from
|
||||||
// whoever is the host
|
// whoever is the host
|
||||||
INetworkPlayer* pHostPlayer =
|
INetworkPlayer* pHostPlayer =
|
||||||
g_NetworkManager.GetHostPlayer();
|
NetworkService.GetHostPlayer();
|
||||||
PlayerUID xuid = pHostPlayer->GetUID();
|
PlayerUID xuid = pHostPlayer->GetUID();
|
||||||
|
|
||||||
if (gameServices().isInBannedLevelList(
|
if (gameServices().isInBannedLevelList(
|
||||||
|
|
@ -1216,7 +1216,7 @@ void Minecraft::run_middle() {
|
||||||
// quadrant display to remind them to press start (if the
|
// quadrant display to remind them to press start (if the
|
||||||
// session has space)
|
// session has space)
|
||||||
if (level != nullptr && bFirstTimeIntoGame &&
|
if (level != nullptr && bFirstTimeIntoGame &&
|
||||||
g_NetworkManager.SessionHasSpace()) {
|
NetworkService.SessionHasSpace()) {
|
||||||
// have a short delay before the display
|
// have a short delay before the display
|
||||||
if (iFirstTimeCountdown == 0) {
|
if (iFirstTimeCountdown == 0) {
|
||||||
bFirstTimeIntoGame = false;
|
bFirstTimeIntoGame = false;
|
||||||
|
|
@ -1390,7 +1390,7 @@ void Minecraft::run_middle() {
|
||||||
bool tryJoin = !pause &&
|
bool tryJoin = !pause &&
|
||||||
!ui.IsIgnorePlayerJoinMenuDisplayed(
|
!ui.IsIgnorePlayerJoinMenuDisplayed(
|
||||||
PlatformInput.GetPrimaryPad()) &&
|
PlatformInput.GetPrimaryPad()) &&
|
||||||
g_NetworkManager.SessionHasSpace() &&
|
NetworkService.SessionHasSpace() &&
|
||||||
PlatformRenderer.IsHiDef() &&
|
PlatformRenderer.IsHiDef() &&
|
||||||
PlatformInput.ButtonPressed(i);
|
PlatformInput.ButtonPressed(i);
|
||||||
if (tryJoin) {
|
if (tryJoin) {
|
||||||
|
|
@ -1408,7 +1408,7 @@ void Minecraft::run_middle() {
|
||||||
if (PlatformProfile.IsSignedIn(i)) {
|
if (PlatformProfile.IsSignedIn(i)) {
|
||||||
// if this is a local game, then the
|
// if this is a local game, then the
|
||||||
// player just needs to be signed in
|
// player just needs to be signed in
|
||||||
if (g_NetworkManager.IsLocalGame() ||
|
if (NetworkService.IsLocalGame() ||
|
||||||
(PlatformProfile.IsSignedInLive(
|
(PlatformProfile.IsSignedInLive(
|
||||||
i) &&
|
i) &&
|
||||||
PlatformProfile
|
PlatformProfile
|
||||||
|
|
@ -1425,7 +1425,7 @@ void Minecraft::run_middle() {
|
||||||
"ui\n");
|
"ui\n");
|
||||||
PlatformProfile.RequestSignInUI(
|
PlatformProfile.RequestSignInUI(
|
||||||
false,
|
false,
|
||||||
g_NetworkManager
|
NetworkService
|
||||||
.IsLocalGame(),
|
.IsLocalGame(),
|
||||||
true, false, true,
|
true, false, true,
|
||||||
[this](bool b, int p) {
|
[this](bool b, int p) {
|
||||||
|
|
@ -1497,7 +1497,7 @@ void Minecraft::run_middle() {
|
||||||
"ui\n");
|
"ui\n");
|
||||||
PlatformProfile.RequestSignInUI(
|
PlatformProfile.RequestSignInUI(
|
||||||
false,
|
false,
|
||||||
g_NetworkManager
|
NetworkService
|
||||||
.IsLocalGame(),
|
.IsLocalGame(),
|
||||||
true, false, true,
|
true, false, true,
|
||||||
[this](bool b, int p) {
|
[this](bool b, int p) {
|
||||||
|
|
@ -1513,7 +1513,7 @@ void Minecraft::run_middle() {
|
||||||
"Bringing up the sign in ui\n");
|
"Bringing up the sign in ui\n");
|
||||||
PlatformProfile.RequestSignInUI(
|
PlatformProfile.RequestSignInUI(
|
||||||
false,
|
false,
|
||||||
g_NetworkManager.IsLocalGame(),
|
NetworkService.IsLocalGame(),
|
||||||
true, false, true,
|
true, false, true,
|
||||||
[this](bool b, int p) {
|
[this](bool b, int p) {
|
||||||
return InGame_SignInReturned(
|
return InGame_SignInReturned(
|
||||||
|
|
@ -1739,7 +1739,7 @@ void Minecraft::run_middle() {
|
||||||
Packet::renderAllPacketStats();
|
Packet::renderAllPacketStats();
|
||||||
#else
|
#else
|
||||||
// To show the size of the QNet queue in bytes and messages
|
// To show the size of the QNet queue in bytes and messages
|
||||||
g_NetworkManager.renderQueueMeter();
|
NetworkService.renderQueueMeter();
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
lastTimer = System::nanoTime();
|
lastTimer = System::nanoTime();
|
||||||
|
|
@ -1778,8 +1778,8 @@ void Minecraft::run_middle() {
|
||||||
// pause = !isClientSide() && screen != nullptr &&
|
// pause = !isClientSide() && screen != nullptr &&
|
||||||
// screen->isPauseScreen();
|
// screen->isPauseScreen();
|
||||||
#if defined(ENABLE_JAVA_GUIS)
|
#if defined(ENABLE_JAVA_GUIS)
|
||||||
pause = g_NetworkManager.IsLocalGame() &&
|
pause = NetworkService.IsLocalGame() &&
|
||||||
g_NetworkManager.GetPlayerCount() == 1 &&
|
NetworkService.GetPlayerCount() == 1 &&
|
||||||
screen != nullptr && screen->isPauseScreen();
|
screen != nullptr && screen->isPauseScreen();
|
||||||
#else
|
#else
|
||||||
pause = gameServices().isAppPaused();
|
pause = gameServices().isAppPaused();
|
||||||
|
|
@ -3980,12 +3980,12 @@ std::string Minecraft::gatherStats1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Minecraft::gatherStats2() {
|
std::string Minecraft::gatherStats2() {
|
||||||
return g_NetworkManager.GatherStats();
|
return NetworkService.GatherStats();
|
||||||
// return levelRenderer->gatherStats2();
|
// return levelRenderer->gatherStats2();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Minecraft::gatherStats3() {
|
std::string Minecraft::gatherStats3() {
|
||||||
return g_NetworkManager.GatherRTTStats();
|
return NetworkService.GatherRTTStats();
|
||||||
// return "P: " + particleEngine->countParticles() + ". T: " +
|
// return "P: " + particleEngine->countParticles() + ". T: " +
|
||||||
// level->gatherStats();
|
// level->gatherStats();
|
||||||
}
|
}
|
||||||
|
|
@ -4465,7 +4465,7 @@ void Minecraft::playerLeftTutorial(int iPad) {
|
||||||
int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) {
|
int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) {
|
||||||
Minecraft* pMinecraftClass = (Minecraft*)pParam;
|
Minecraft* pMinecraftClass = (Minecraft*)pParam;
|
||||||
|
|
||||||
if (g_NetworkManager.IsInSession()) {
|
if (NetworkService.IsInSession()) {
|
||||||
// 4J Stu - There seems to be a bug in the signin ui call that enables
|
// 4J Stu - There seems to be a bug in the signin ui call that enables
|
||||||
// guest sign in. We never allow this within game, so make sure that
|
// guest sign in. We never allow this within game, so make sure that
|
||||||
// it's disabled Fix for #66516 - TCR #124: MPS Guest Support ; #001:
|
// it's disabled Fix for #66516 - TCR #124: MPS Guest Support ; #001:
|
||||||
|
|
@ -4477,19 +4477,19 @@ int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) {
|
||||||
|
|
||||||
// If sign in succeded, we're in game and this player isn't already playing,
|
// If sign in succeded, we're in game and this player isn't already playing,
|
||||||
// continue
|
// continue
|
||||||
if (bContinue == true && g_NetworkManager.IsInSession() &&
|
if (bContinue == true && NetworkService.IsInSession() &&
|
||||||
pMinecraftClass->localplayers[iPad] == nullptr) {
|
pMinecraftClass->localplayers[iPad] == nullptr) {
|
||||||
// It's possible that the player has not signed in - they can back out
|
// It's possible that the player has not signed in - they can back out
|
||||||
// or choose no for the converttoguest
|
// or choose no for the converttoguest
|
||||||
if (PlatformProfile.IsSignedIn(iPad)) {
|
if (PlatformProfile.IsSignedIn(iPad)) {
|
||||||
if (!g_NetworkManager.SessionHasSpace()) {
|
if (!NetworkService.SessionHasSpace()) {
|
||||||
unsigned int uiIDA[1];
|
unsigned int uiIDA[1];
|
||||||
uiIDA[0] = IDS_OK;
|
uiIDA[0] = IDS_OK;
|
||||||
ui.RequestErrorMessage(IDS_MULTIPLAYER_FULL_TITLE,
|
ui.RequestErrorMessage(IDS_MULTIPLAYER_FULL_TITLE,
|
||||||
IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1);
|
IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1);
|
||||||
}
|
}
|
||||||
// if this is a local game then profiles just need to be signed in
|
// if this is a local game then profiles just need to be signed in
|
||||||
else if (g_NetworkManager.IsLocalGame() ||
|
else if (NetworkService.IsLocalGame() ||
|
||||||
(PlatformProfile.IsSignedInLive(iPad) &&
|
(PlatformProfile.IsSignedInLive(iPad) &&
|
||||||
PlatformProfile.AllowedToPlayMultiplayer(iPad))) {
|
PlatformProfile.AllowedToPlayMultiplayer(iPad))) {
|
||||||
if (pMinecraftClass->level->isClientSide) {
|
if (pMinecraftClass->level->isClientSide) {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@
|
||||||
#include "EditBox.h"
|
#include "EditBox.h"
|
||||||
#include "MessageScreen.h"
|
#include "MessageScreen.h"
|
||||||
#include "minecraft/GameEnums.h"
|
#include "minecraft/GameEnums.h"
|
||||||
|
#include "minecraft/network/INetworkService.h"
|
||||||
|
// Needed for the &CGameNetworkManager::RunNetworkGameThreadProc address-of
|
||||||
|
// below. Static thread procs can't be virtual; this one consumer keeps the
|
||||||
|
// concrete type include.
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "app/common/Network/GameNetworkManager.h"
|
||||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||||
#include "app/common/UI/All Platforms/UIStructs.h"
|
#include "app/common/UI/All Platforms/UIStructs.h"
|
||||||
|
|
@ -286,10 +290,10 @@ void CreateWorldScreen::buttonClicked(Button* button) {
|
||||||
param->xzSize = LEVEL_MAX_WIDTH;
|
param->xzSize = LEVEL_MAX_WIDTH;
|
||||||
param->hellScale = HELL_LEVEL_MAX_SCALE;
|
param->hellScale = HELL_LEVEL_MAX_SCALE;
|
||||||
|
|
||||||
g_NetworkManager.HostGame(0, false, false, MINECRAFT_NET_MAX_PLAYERS,
|
NetworkService.HostGame(0, false, false, MINECRAFT_NET_MAX_PLAYERS,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
g_NetworkManager.FakeLocalPlayerJoined();
|
NetworkService.FakeLocalPlayerJoined();
|
||||||
|
|
||||||
LoadingInputParams* loadingParams = new LoadingInputParams();
|
LoadingInputParams* loadingParams = new LoadingInputParams();
|
||||||
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
|
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
#include "MessageScreen.h"
|
#include "MessageScreen.h"
|
||||||
#include "minecraft/GameEnums.h"
|
#include "minecraft/GameEnums.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "OptionsScreen.h"
|
#include "OptionsScreen.h"
|
||||||
#include "minecraft/client/Minecraft.h"
|
#include "minecraft/client/Minecraft.h"
|
||||||
#include "minecraft/client/gui/Screen.h"
|
#include "minecraft/client/gui/Screen.h"
|
||||||
|
|
@ -30,13 +30,13 @@ void PauseScreen::init() {
|
||||||
buttons.clear();
|
buttons.clear();
|
||||||
int yo = -16;
|
int yo = -16;
|
||||||
// 4jcraft: solves the issue of client-side only pausing in the java gui
|
// 4jcraft: solves the issue of client-side only pausing in the java gui
|
||||||
if (g_NetworkManager.IsLocalGame() &&
|
if (NetworkService.IsLocalGame() &&
|
||||||
g_NetworkManager.GetPlayerCount() == 1)
|
NetworkService.GetPlayerCount() == 1)
|
||||||
gameServices().setXuiServerAction(PlatformInput.GetPrimaryPad(),
|
gameServices().setXuiServerAction(PlatformInput.GetPrimaryPad(),
|
||||||
eXuiServerAction_PauseServer, true);
|
eXuiServerAction_PauseServer, true);
|
||||||
buttons.push_back(new Button(1, width / 2 - 100, height / 4 + 24 * 5 + yo,
|
buttons.push_back(new Button(1, width / 2 - 100, height / 4 + 24 * 5 + yo,
|
||||||
I18n::get("menu.returnToMenu")));
|
I18n::get("menu.returnToMenu")));
|
||||||
if (!g_NetworkManager.IsHost()) {
|
if (!NetworkService.IsHost()) {
|
||||||
buttons[0]->msg = I18n::get("menu.disconnect");
|
buttons[0]->msg = I18n::get("menu.disconnect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ void PauseScreen::exitWorld(Minecraft* minecraft, bool save) {
|
||||||
MinecraftServer* server = MinecraftServer::getInstance();
|
MinecraftServer* server = MinecraftServer::getInstance();
|
||||||
|
|
||||||
minecraft->setScreen(new MessageScreen("Leaving world"));
|
minecraft->setScreen(new MessageScreen("Leaving world"));
|
||||||
if (g_NetworkManager.IsHost()) {
|
if (NetworkService.IsHost()) {
|
||||||
server->setSaveOnExit(save);
|
server->setSaveOnExit(save);
|
||||||
}
|
}
|
||||||
gameServices().setAction(minecraft->player->GetXboxPad(), eAppAction_ExitWorld);
|
gameServices().setAction(minecraft->player->GetXboxPad(), eAppAction_ExitWorld);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "Button.h"
|
#include "Button.h"
|
||||||
#include "minecraft/GameEnums.h"
|
#include "minecraft/GameEnums.h"
|
||||||
#include "app/common/Audio/SoundEngine.h"
|
#include "app/common/Audio/SoundEngine.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "platform/stubs.h"
|
#include "platform/stubs.h"
|
||||||
#include "minecraft/client/Minecraft.h"
|
#include "minecraft/client/Minecraft.h"
|
||||||
#include "minecraft/client/gui/Screen.h"
|
#include "minecraft/client/gui/Screen.h"
|
||||||
|
|
@ -40,8 +40,8 @@ void Screen::keyPressed(char eventCharacter, int eventKey) {
|
||||||
// minecraft->grabMouse(); // 4J - removed
|
// minecraft->grabMouse(); // 4J - removed
|
||||||
// 4jcraft: moved here from PauseScreen to ensure that serverside
|
// 4jcraft: moved here from PauseScreen to ensure that serverside
|
||||||
// unpausing is done in all scenarios
|
// unpausing is done in all scenarios
|
||||||
if (g_NetworkManager.IsLocalGame() &&
|
if (NetworkService.IsLocalGame() &&
|
||||||
g_NetworkManager.GetPlayerCount() == 1)
|
NetworkService.GetPlayerCount() == 1)
|
||||||
gameServices().setXuiServerAction(PlatformInput.GetPrimaryPad(),
|
gameServices().setXuiServerAction(PlatformInput.GetPrimaryPad(),
|
||||||
eXuiServerAction_PauseServer, false);
|
eXuiServerAction_PauseServer, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "app/common/DLC/DLCPack.h"
|
#include "app/common/DLC/DLCPack.h"
|
||||||
#include "app/common/DLC/DLCSkinFile.h"
|
#include "app/common/DLC/DLCSkinFile.h"
|
||||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "app/common/Network/Socket.h"
|
#include "app/common/Network/Socket.h"
|
||||||
#include "app/common/Tutorial/FullTutorialMode.h"
|
#include "app/common/Tutorial/FullTutorialMode.h"
|
||||||
|
|
@ -273,11 +273,11 @@ void ClientConnection::handleLogin(std::shared_ptr<LoginPacket> packet) {
|
||||||
PlatformProfile.GetXUID(m_userIndex, &OnlineXuid, true); // online xuid
|
PlatformProfile.GetXUID(m_userIndex, &OnlineXuid, true); // online xuid
|
||||||
MOJANG_DATA* pMojangData = nullptr;
|
MOJANG_DATA* pMojangData = nullptr;
|
||||||
|
|
||||||
if (!g_NetworkManager.IsLocalGame()) {
|
if (!NetworkService.IsLocalGame()) {
|
||||||
pMojangData = gameServices().getMojangDataForXuid(OnlineXuid);
|
pMojangData = gameServices().getMojangDataForXuid(OnlineXuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_NetworkManager.IsHost()) {
|
if (!NetworkService.IsHost()) {
|
||||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||||
(eCCLoginReceived * 100) / (eCCConnected));
|
(eCCLoginReceived * 100) / (eCCConnected));
|
||||||
}
|
}
|
||||||
|
|
@ -295,7 +295,7 @@ void ClientConnection::handleLogin(std::shared_ptr<LoginPacket> packet) {
|
||||||
// find the pad number of this local player
|
// find the pad number of this local player
|
||||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||||
INetworkPlayer* networkLocalPlayer =
|
INetworkPlayer* networkLocalPlayer =
|
||||||
g_NetworkManager.GetLocalPlayerByUserIndex(i);
|
NetworkService.GetLocalPlayerByUserIndex(i);
|
||||||
if (networkLocalPlayer == networkPlayer) {
|
if (networkLocalPlayer == networkPlayer) {
|
||||||
iUserID = i;
|
iUserID = i;
|
||||||
}
|
}
|
||||||
|
|
@ -1091,7 +1091,7 @@ void ClientConnection::handleMovePlayer(
|
||||||
packet->yView = player->y;
|
packet->yView = player->y;
|
||||||
connection->send(packet);
|
connection->send(packet);
|
||||||
if (!started) {
|
if (!started) {
|
||||||
if (!g_NetworkManager.IsHost()) {
|
if (!NetworkService.IsHost()) {
|
||||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||||
(eCCConnected * 100) / (eCCConnected));
|
(eCCConnected * 100) / (eCCConnected));
|
||||||
}
|
}
|
||||||
|
|
@ -1274,7 +1274,7 @@ void ClientConnection::handleTileUpdate(
|
||||||
MultiPlayerLevel* dimensionLevel =
|
MultiPlayerLevel* dimensionLevel =
|
||||||
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
|
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
|
||||||
if (dimensionLevel) {
|
if (dimensionLevel) {
|
||||||
if (g_NetworkManager.IsHost()) {
|
if (NetworkService.IsHost()) {
|
||||||
// 4J Stu - Unshare before we make any changes incase the server is
|
// 4J Stu - Unshare before we make any changes incase the server is
|
||||||
// already another step ahead of us Fix for #7904 - Gameplay:
|
// already another step ahead of us Fix for #7904 - Gameplay:
|
||||||
// Players can dupe torches by throwing them repeatedly into water.
|
// Players can dupe torches by throwing them repeatedly into water.
|
||||||
|
|
@ -1357,7 +1357,7 @@ void ClientConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
||||||
// Fix for #13191 - The host of a game can get a message informing them that
|
// Fix for #13191 - The host of a game can get a message informing them that
|
||||||
// the connection to the server has been lost In the (now unlikely) event
|
// the connection to the server has been lost In the (now unlikely) event
|
||||||
// that the host connections times out, allow the player to save their game
|
// that the host connections times out, allow the player to save their game
|
||||||
if (g_NetworkManager.IsHost() &&
|
if (NetworkService.IsHost() &&
|
||||||
(reason == DisconnectPacket::eDisconnect_TimeOut ||
|
(reason == DisconnectPacket::eDisconnect_TimeOut ||
|
||||||
reason == DisconnectPacket::eDisconnect_Overflow) &&
|
reason == DisconnectPacket::eDisconnect_Overflow) &&
|
||||||
m_userIndex == PlatformInput.GetPrimaryPad() &&
|
m_userIndex == PlatformInput.GetPrimaryPad() &&
|
||||||
|
|
@ -1918,16 +1918,16 @@ void ClientConnection::handleEntityActionAtPosition(
|
||||||
void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"[LOGIN-CLI] handlePreLogin entered, isHost=%d, userIdx=%d\n",
|
"[LOGIN-CLI] handlePreLogin entered, isHost=%d, userIdx=%d\n",
|
||||||
(int)g_NetworkManager.IsHost(), m_userIndex);
|
(int)NetworkService.IsHost(), m_userIndex);
|
||||||
// 4J - Check that we can play with all the players already in the game who
|
// 4J - Check that we can play with all the players already in the game who
|
||||||
// have Friends-Only UGC set
|
// have Friends-Only UGC set
|
||||||
bool canPlay = true;
|
bool canPlay = true;
|
||||||
bool canPlayLocal = true;
|
bool canPlayLocal = true;
|
||||||
bool isAtLeastOneFriend = g_NetworkManager.IsHost();
|
bool isAtLeastOneFriend = NetworkService.IsHost();
|
||||||
bool isFriendsWithHost = true;
|
bool isFriendsWithHost = true;
|
||||||
bool cantPlayContentRestricted = false;
|
bool cantPlayContentRestricted = false;
|
||||||
|
|
||||||
if (!g_NetworkManager.IsHost()) {
|
if (!NetworkService.IsHost()) {
|
||||||
// set the game host settings
|
// set the game host settings
|
||||||
gameServices().setGameHostOption(eGameHostOption_All, packet->m_serverSettings);
|
gameServices().setGameHostOption(eGameHostOption_All, packet->m_serverSettings);
|
||||||
|
|
||||||
|
|
@ -2031,7 +2031,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_NetworkManager.IsHost()) {
|
if (!NetworkService.IsHost()) {
|
||||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||||
(eCCPreLoginReceived * 100) / (eCCConnected));
|
(eCCPreLoginReceived * 100) / (eCCConnected));
|
||||||
}
|
}
|
||||||
|
|
@ -2060,7 +2060,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
||||||
"isHost=%d\n",
|
"isHost=%d\n",
|
||||||
minecraft->user->name.c_str(),
|
minecraft->user->name.c_str(),
|
||||||
SharedConstants::NETWORK_PROTOCOL_VERSION, m_userIndex,
|
SharedConstants::NETWORK_PROTOCOL_VERSION, m_userIndex,
|
||||||
(int)g_NetworkManager.IsHost());
|
(int)NetworkService.IsHost());
|
||||||
send(std::make_shared<LoginPacket>(
|
send(std::make_shared<LoginPacket>(
|
||||||
minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION,
|
minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION,
|
||||||
offlineXUID, onlineXUID, (!allAllowed && friendsAllowed),
|
offlineXUID, onlineXUID, (!allAllowed && friendsAllowed),
|
||||||
|
|
@ -2069,7 +2069,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
||||||
PlatformProfile.IsGuest(m_userIndex)));
|
PlatformProfile.IsGuest(m_userIndex)));
|
||||||
fprintf(stderr, "[LOGIN] LoginPacket sent successfully\n");
|
fprintf(stderr, "[LOGIN] LoginPacket sent successfully\n");
|
||||||
|
|
||||||
if (!g_NetworkManager.IsHost()) {
|
if (!NetworkService.IsHost()) {
|
||||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||||
(eCCLoginSent * 100) / (eCCConnected));
|
(eCCLoginSent * 100) / (eCCConnected));
|
||||||
}
|
}
|
||||||
|
|
@ -3014,7 +3014,7 @@ void ClientConnection::handleGameEvent(
|
||||||
ui.NavigateToScene(PlatformInput.GetPrimaryPad(), eUIScene_EndPoem,
|
ui.NavigateToScene(PlatformInput.GetPrimaryPad(), eUIScene_EndPoem,
|
||||||
nullptr, eUILayer_Scene, eUIGroup_Fullscreen);
|
nullptr, eUILayer_Scene, eUIGroup_Fullscreen);
|
||||||
} else if (event == GameEventPacket::START_SAVING) {
|
} else if (event == GameEventPacket::START_SAVING) {
|
||||||
if (!g_NetworkManager.IsHost()) {
|
if (!NetworkService.IsHost()) {
|
||||||
// Move app started to here so that it happens immediately otherwise
|
// Move app started to here so that it happens immediately otherwise
|
||||||
// back-to-back START/STOP packets leave the client stuck in the
|
// back-to-back START/STOP packets leave the client stuck in the
|
||||||
// loading screen
|
// loading screen
|
||||||
|
|
@ -3023,7 +3023,7 @@ void ClientConnection::handleGameEvent(
|
||||||
eAppAction_RemoteServerSave);
|
eAppAction_RemoteServerSave);
|
||||||
}
|
}
|
||||||
} else if (event == GameEventPacket::STOP_SAVING) {
|
} else if (event == GameEventPacket::STOP_SAVING) {
|
||||||
if (!g_NetworkManager.IsHost()) gameServices().setGameStarted(true);
|
if (!NetworkService.IsHost()) gameServices().setGameStarted(true);
|
||||||
} else if (event == GameEventPacket::SUCCESSFUL_BOW_HIT) {
|
} else if (event == GameEventPacket::SUCCESSFUL_BOW_HIT) {
|
||||||
std::shared_ptr<MultiplayerLocalPlayer> player =
|
std::shared_ptr<MultiplayerLocalPlayer> player =
|
||||||
minecraft->localplayers[m_userIndex];
|
minecraft->localplayers[m_userIndex];
|
||||||
|
|
@ -3109,7 +3109,7 @@ void ClientConnection::handlePlayerInfo(
|
||||||
gameServices().getPlayerPrivileges(packet->m_networkSmallId);
|
gameServices().getPlayerPrivileges(packet->m_networkSmallId);
|
||||||
|
|
||||||
INetworkPlayer* networkPlayer =
|
INetworkPlayer* networkPlayer =
|
||||||
g_NetworkManager.GetPlayerBySmallId(packet->m_networkSmallId);
|
NetworkService.GetPlayerBySmallId(packet->m_networkSmallId);
|
||||||
|
|
||||||
if (networkPlayer != nullptr && networkPlayer->IsHost()) {
|
if (networkPlayer != nullptr && networkPlayer->IsHost()) {
|
||||||
// Some settings should always be considered on for the host player
|
// Some settings should always be considered on for the host player
|
||||||
|
|
@ -3393,7 +3393,7 @@ void ClientConnection::handleXZ(std::shared_ptr<XZPacket> packet) {
|
||||||
|
|
||||||
void ClientConnection::handleUpdateProgress(
|
void ClientConnection::handleUpdateProgress(
|
||||||
std::shared_ptr<UpdateProgressPacket> packet) {
|
std::shared_ptr<UpdateProgressPacket> packet) {
|
||||||
if (!g_NetworkManager.IsHost())
|
if (!NetworkService.IsHost())
|
||||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||||
packet->m_percentage);
|
packet->m_percentage);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "app/linux/Stubs/winapi_stubs.h"
|
#include "app/linux/Stubs/winapi_stubs.h"
|
||||||
#include "util/StringHelpers.h"
|
#include "util/StringHelpers.h"
|
||||||
#include "minecraft/server/MinecraftServer.h"
|
#include "minecraft/server/MinecraftServer.h"
|
||||||
|
|
@ -167,7 +167,7 @@ LevelChunk* MultiPlayerChunkCache::create(int x, int z) {
|
||||||
std::unique_lock<std::mutex> lock(m_csLoadCreate);
|
std::unique_lock<std::mutex> lock(m_csLoadCreate);
|
||||||
|
|
||||||
// LevelChunk *chunk;
|
// LevelChunk *chunk;
|
||||||
if (g_NetworkManager
|
if (NetworkService
|
||||||
.IsHost()) // force here to disable sharing of data
|
.IsHost()) // force here to disable sharing of data
|
||||||
{
|
{
|
||||||
// 4J-JEV: We are about to use shared data, abort if the server
|
// 4J-JEV: We are about to use shared data, abort if the server
|
||||||
|
|
@ -223,7 +223,7 @@ LevelChunk* MultiPlayerChunkCache::create(int x, int z) {
|
||||||
// If we're sharing with the server, we'll need to calculate our
|
// If we're sharing with the server, we'll need to calculate our
|
||||||
// heightmap now, which isn't shared. If we aren't sharing with the
|
// heightmap now, which isn't shared. If we aren't sharing with the
|
||||||
// server, then this will be calculated when the chunk data arrives.
|
// server, then this will be calculated when the chunk data arrives.
|
||||||
if (g_NetworkManager.IsHost()) {
|
if (NetworkService.IsHost()) {
|
||||||
chunk->recalcHeightmapOnly();
|
chunk->recalcHeightmapOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "ClientConnection.h"
|
#include "ClientConnection.h"
|
||||||
#include "app/common/Audio/SoundEngine.h"
|
#include "app/common/Audio/SoundEngine.h"
|
||||||
#include "minecraft/Console_Debug_enum.h"
|
#include "minecraft/Console_Debug_enum.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "MultiPlayerChunkCache.h"
|
#include "MultiPlayerChunkCache.h"
|
||||||
#include "MultiPlayerLocalPlayer.h"
|
#include "MultiPlayerLocalPlayer.h"
|
||||||
#include "java/JavaMath.h"
|
#include "java/JavaMath.h"
|
||||||
|
|
@ -104,13 +104,13 @@ MultiPlayerLevel::~MultiPlayerLevel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerLevel::unshareChunkAt(int x, int z) {
|
void MultiPlayerLevel::unshareChunkAt(int x, int z) {
|
||||||
if (g_NetworkManager.IsHost()) {
|
if (NetworkService.IsHost()) {
|
||||||
Level::getChunkAt(x, z)->stopSharingTilesAndData();
|
Level::getChunkAt(x, z)->stopSharingTilesAndData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerLevel::shareChunkAt(int x, int z) {
|
void MultiPlayerLevel::shareChunkAt(int x, int z) {
|
||||||
if (g_NetworkManager.IsHost()) {
|
if (NetworkService.IsHost()) {
|
||||||
Level::getChunkAt(x, z)->startSharingTilesAndData();
|
Level::getChunkAt(x, z)->startSharingTilesAndData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -193,12 +193,12 @@ void MultiPlayerLevel::tick() {
|
||||||
// chunks become unshared over time.
|
// chunks become unshared over time.
|
||||||
|
|
||||||
int ls = dimension->getXZSize();
|
int ls = dimension->getXZSize();
|
||||||
if (g_NetworkManager.IsHost()) {
|
if (NetworkService.IsHost()) {
|
||||||
if (Level::reallyHasChunk(unshareCheckX - (ls / 2),
|
if (Level::reallyHasChunk(unshareCheckX - (ls / 2),
|
||||||
unshareCheckZ - (ls / 2))) {
|
unshareCheckZ - (ls / 2))) {
|
||||||
LevelChunk* lc = Level::getChunk(unshareCheckX - (ls / 2),
|
LevelChunk* lc = Level::getChunk(unshareCheckX - (ls / 2),
|
||||||
unshareCheckZ - (ls / 2));
|
unshareCheckZ - (ls / 2));
|
||||||
if (g_NetworkManager.IsHost()) {
|
if (NetworkService.IsHost()) {
|
||||||
lc->startSharingTilesAndData(1000 * 60 * 2);
|
lc->startSharingTilesAndData(1000 * 60 * 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -611,8 +611,8 @@ bool MultiPlayerLevel::doSetTileAndData(int x, int y, int z, int tile,
|
||||||
// don't change things as the host might have been sharing data and so set
|
// don't change things as the host might have been sharing data and so set
|
||||||
// it already, but the renderer won't know to update
|
// it already, but the renderer won't know to update
|
||||||
if ((Level::setTileAndData(x, y, z, tile, data, Tile::UPDATE_ALL) ||
|
if ((Level::setTileAndData(x, y, z, tile, data, Tile::UPDATE_ALL) ||
|
||||||
g_NetworkManager.IsHost())) {
|
NetworkService.IsHost())) {
|
||||||
if (g_NetworkManager.IsHost() && visuallyImportant) {
|
if (NetworkService.IsHost() && visuallyImportant) {
|
||||||
// 4J Stu - This got removed from the tileUpdated function in TU14.
|
// 4J Stu - This got removed from the tileUpdated function in TU14.
|
||||||
// Adding it back here as we need it to handle the cases where the
|
// Adding it back here as we need it to handle the cases where the
|
||||||
// chunk data is shared so the normal paths never call this
|
// chunk data is shared so the normal paths never call this
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ void MultiplayerLocalPlayer::heal(float heal) {}
|
||||||
void MultiplayerLocalPlayer::tick() {
|
void MultiplayerLocalPlayer::tick() {
|
||||||
// 4J Added
|
// 4J Added
|
||||||
// 4J-PB - changing this to a game host option ot hide gamertags
|
// 4J-PB - changing this to a game host option ot hide gamertags
|
||||||
// bool bIsisPrimaryHost=g_NetworkManager.IsHost() &&
|
// bool bIsisPrimaryHost=NetworkService.IsHost() &&
|
||||||
// (PlatformInput.GetPrimaryPad()==m_iPad);
|
// (PlatformInput.GetPrimaryPad()==m_iPad);
|
||||||
|
|
||||||
/*if((gameServices().getGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) !=
|
/*if((gameServices().getGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) !=
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
#include "platform/renderer/renderer.h"
|
#include "platform/renderer/renderer.h"
|
||||||
#include "app/common/App_structs.h"
|
#include "app/common/App_structs.h"
|
||||||
#include "app/common/Audio/SoundEngine.h"
|
#include "app/common/Audio/SoundEngine.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "app/common/Tutorial/Tutorial.h"
|
#include "app/common/Tutorial/Tutorial.h"
|
||||||
#include "app/common/Tutorial/TutorialMode.h"
|
#include "app/common/Tutorial/TutorialMode.h"
|
||||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||||
|
|
@ -490,9 +490,9 @@ void LocalPlayer::aiStep() {
|
||||||
} else if (m_bIsIdle &&
|
} else if (m_bIsIdle &&
|
||||||
PlatformInput.GetIdleSeconds(m_iPad) < PLAYER_IDLE_TIME) {
|
PlatformInput.GetIdleSeconds(m_iPad) < PLAYER_IDLE_TIME) {
|
||||||
// Are we offline or online, and how many players are there
|
// Are we offline or online, and how many players are there
|
||||||
if (g_NetworkManager.GetPlayerCount() > 1) {
|
if (NetworkService.GetPlayerCount() > 1) {
|
||||||
// only do it for this player here - each player will run this code
|
// only do it for this player here - each player will run this code
|
||||||
if (g_NetworkManager.IsLocalGame()) {
|
if (NetworkService.IsLocalGame()) {
|
||||||
PlatformProfile.SetCurrentGameActivity(
|
PlatformProfile.SetCurrentGameActivity(
|
||||||
m_iPad, CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, false);
|
m_iPad, CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -500,7 +500,7 @@ void LocalPlayer::aiStep() {
|
||||||
m_iPad, CONTEXT_PRESENCE_MULTIPLAYER, false);
|
m_iPad, CONTEXT_PRESENCE_MULTIPLAYER, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (g_NetworkManager.IsLocalGame()) {
|
if (NetworkService.IsLocalGame()) {
|
||||||
PlatformProfile.SetCurrentGameActivity(
|
PlatformProfile.SetCurrentGameActivity(
|
||||||
m_iPad, CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, false);
|
m_iPad, CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, false);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -848,8 +848,8 @@ void LocalPlayer::awardStat(Stat* stat, const std::vector<uint8_t>& param) {
|
||||||
// especially if you are surrounded by mobs! We cannot pause the
|
// especially if you are surrounded by mobs! We cannot pause the
|
||||||
// game unless in offline single player, but lets at least do it
|
// game unless in offline single player, but lets at least do it
|
||||||
// then
|
// then
|
||||||
if (g_NetworkManager.IsLocalGame() &&
|
if (NetworkService.IsLocalGame() &&
|
||||||
g_NetworkManager.GetPlayerCount() == 1 &&
|
NetworkService.GetPlayerCount() == 1 &&
|
||||||
PlatformProfile.GetAwardType(ach->getAchievementID()) !=
|
PlatformProfile.GetAwardType(ach->getAchievementID()) !=
|
||||||
EAwardType::Achievement) {
|
EAwardType::Achievement) {
|
||||||
ui.CloseUIScenes(m_iPad);
|
ui.CloseUIScenes(m_iPad);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "platform/ShutdownManager.h"
|
#include "platform/ShutdownManager.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "app/common/Network/Socket.h"
|
#include "app/common/Network/Socket.h"
|
||||||
#include "util/StringHelpers.h"
|
#include "util/StringHelpers.h"
|
||||||
|
|
@ -471,8 +471,8 @@ void Connection::tick() {
|
||||||
std::vector<std::shared_ptr<Packet> > packetsToHandle;
|
std::vector<std::shared_ptr<Packet> > packetsToHandle;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(incoming_cs);
|
std::lock_guard<std::mutex> lock(incoming_cs);
|
||||||
while (!disconnected && !g_NetworkManager.IsLeavingGame() &&
|
while (!disconnected && !NetworkService.IsLeavingGame() &&
|
||||||
g_NetworkManager.IsInSession() && !incoming.empty() &&
|
NetworkService.IsInSession() && !incoming.empty() &&
|
||||||
max-- >= 0) {
|
max-- >= 0) {
|
||||||
std::shared_ptr<Packet> packet = incoming.front();
|
std::shared_ptr<Packet> packet = incoming.front();
|
||||||
packetsToHandle.push_back(packet);
|
packetsToHandle.push_back(packet);
|
||||||
|
|
|
||||||
73
targets/minecraft/network/INetworkService.h
Normal file
73
targets/minecraft/network/INetworkService.h
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "platform/PlatformTypes.h"
|
||||||
|
|
||||||
|
// Minimal interface that minecraft/ code uses to talk to the network
|
||||||
|
// subsystem. The concrete implementation lives in app/common/Network/
|
||||||
|
// (CGameNetworkManager). Same shape as IGameServices: minecraft/ code
|
||||||
|
// calls the interface; the implementation can sit in a higher layer
|
||||||
|
// without minecraft/ needing to include its header.
|
||||||
|
//
|
||||||
|
// Method names match the existing CGameNetworkManager surface so the
|
||||||
|
// concrete class can implement the interface without rename churn.
|
||||||
|
|
||||||
|
class INetworkPlayer;
|
||||||
|
|
||||||
|
namespace minecraft::network {
|
||||||
|
|
||||||
|
class INetworkService {
|
||||||
|
public:
|
||||||
|
virtual ~INetworkService() = default;
|
||||||
|
|
||||||
|
// Player management
|
||||||
|
[[nodiscard]] virtual int GetPlayerCount() = 0;
|
||||||
|
virtual bool AddLocalPlayerByUserIndex(int userIndex) = 0;
|
||||||
|
virtual bool RemoveLocalPlayerByUserIndex(int userIndex) = 0;
|
||||||
|
[[nodiscard]] virtual INetworkPlayer* GetLocalPlayerByUserIndex(
|
||||||
|
int userIndex) = 0;
|
||||||
|
[[nodiscard]] virtual INetworkPlayer* GetPlayerByIndex(int playerIndex) = 0;
|
||||||
|
[[nodiscard]] virtual INetworkPlayer* GetPlayerBySmallId(
|
||||||
|
unsigned char smallId) = 0;
|
||||||
|
[[nodiscard]] virtual INetworkPlayer* GetHostPlayer() = 0;
|
||||||
|
|
||||||
|
// Hosting / state
|
||||||
|
[[nodiscard]] virtual bool IsHost() = 0;
|
||||||
|
[[nodiscard]] virtual bool IsInSession() = 0;
|
||||||
|
[[nodiscard]] virtual bool IsLeavingGame() = 0;
|
||||||
|
[[nodiscard]] virtual bool IsLocalGame() = 0;
|
||||||
|
[[nodiscard]] virtual bool SessionHasSpace(
|
||||||
|
unsigned int spaceRequired = 1) = 0;
|
||||||
|
virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate,
|
||||||
|
unsigned char publicSlots,
|
||||||
|
unsigned char privateSlots) = 0;
|
||||||
|
virtual void FakeLocalPlayerJoined() = 0;
|
||||||
|
virtual void UpdateAndSetGameSessionData(
|
||||||
|
INetworkPlayer* pNetworkPlayerLeaving = nullptr) = 0;
|
||||||
|
|
||||||
|
// System flags
|
||||||
|
virtual void SystemFlagSet(INetworkPlayer* pNetworkPlayer, int index) = 0;
|
||||||
|
[[nodiscard]] virtual bool SystemFlagGet(INetworkPlayer* pNetworkPlayer,
|
||||||
|
int index) = 0;
|
||||||
|
|
||||||
|
// Server lifecycle events
|
||||||
|
virtual void ServerReady() = 0;
|
||||||
|
virtual void ServerStopped() = 0;
|
||||||
|
|
||||||
|
// Stats / debug
|
||||||
|
[[nodiscard]] virtual std::string GatherStats() = 0;
|
||||||
|
[[nodiscard]] virtual std::string GatherRTTStats() = 0;
|
||||||
|
virtual void renderQueueMeter() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace platform_internal {
|
||||||
|
INetworkService& NetworkService_get();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace minecraft::network
|
||||||
|
|
||||||
|
#define NetworkService \
|
||||||
|
(::minecraft::network::platform_internal:: \
|
||||||
|
NetworkService_get())
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#include "minecraft/GameEnums.h"
|
#include "minecraft/GameEnums.h"
|
||||||
#include "app/common/GameRules/GameRuleManager.h"
|
#include "app/common/GameRules/GameRuleManager.h"
|
||||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "PlayerList.h"
|
#include "PlayerList.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
@ -261,7 +261,7 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData,
|
||||||
initData->saveData->fileSize = 0;
|
initData->saveData->fileSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_NetworkManager.ServerReady(); // 4J added
|
NetworkService.ServerReady(); // 4J added
|
||||||
return m_bLoaded;
|
return m_bLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -446,7 +446,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
||||||
// McRegionLevelStorage *storage = new McRegionLevelStorage(File("."),
|
// McRegionLevelStorage *storage = new McRegionLevelStorage(File("."),
|
||||||
// name, true); // TODO
|
// name, true); // TODO
|
||||||
for (unsigned int i = 0; i < levels.size(); i++) {
|
for (unsigned int i = 0; i < levels.size(); i++) {
|
||||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) {
|
if (s_bServerHalted || !NetworkService.IsInSession()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -516,7 +516,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
||||||
gameServices().setGameHostOption(eGameHostOption_Structures,
|
gameServices().setGameHostOption(eGameHostOption_Structures,
|
||||||
levels[0]->isGenerateMapFeatures());
|
levels[0]->isGenerateMapFeatures());
|
||||||
|
|
||||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false;
|
if (s_bServerHalted || !NetworkService.IsInSession()) return false;
|
||||||
|
|
||||||
// 4J - Make a new thread to do post processing
|
// 4J - Make a new thread to do post processing
|
||||||
|
|
||||||
|
|
@ -590,7 +590,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
||||||
int total = twoRPlusOne * twoRPlusOne;
|
int total = twoRPlusOne * twoRPlusOne;
|
||||||
for (int x = -r; x <= r && running; x += 16) {
|
for (int x = -r; x <= r && running; x += 16) {
|
||||||
for (int z = -r; z <= r && running; z += 16) {
|
for (int z = -r; z <= r && running; z += 16) {
|
||||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) {
|
if (s_bServerHalted || !NetworkService.IsInSession()) {
|
||||||
delete spawnPos;
|
delete spawnPos;
|
||||||
m_postUpdateTerminate = true;
|
m_postUpdateTerminate = true;
|
||||||
postProcessTerminate(mcprogress);
|
postProcessTerminate(mcprogress);
|
||||||
|
|
@ -678,19 +678,19 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
||||||
// printf("Lighting complete at %dms\n",System::currentTimeMillis() -
|
// printf("Lighting complete at %dms\n",System::currentTimeMillis() -
|
||||||
// startTime);
|
// startTime);
|
||||||
|
|
||||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false;
|
if (s_bServerHalted || !NetworkService.IsInSession()) return false;
|
||||||
|
|
||||||
if (levels[1]->isNew) {
|
if (levels[1]->isNew) {
|
||||||
levels[1]->save(true, mcprogress);
|
levels[1]->save(true, mcprogress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false;
|
if (s_bServerHalted || !NetworkService.IsInSession()) return false;
|
||||||
|
|
||||||
if (levels[2]->isNew) {
|
if (levels[2]->isNew) {
|
||||||
levels[2]->save(true, mcprogress);
|
levels[2]->save(true, mcprogress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false;
|
if (s_bServerHalted || !NetworkService.IsInSession()) return false;
|
||||||
|
|
||||||
// 4J - added - immediately save newly created level, like single player
|
// 4J - added - immediately save newly created level, like single player
|
||||||
// game 4J Stu - We also want to immediately save the tutorial
|
// game 4J Stu - We also want to immediately save the tutorial
|
||||||
|
|
@ -700,13 +700,13 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
||||||
levels[0]->save(true, mcprogress);
|
levels[0]->save(true, mcprogress);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false;
|
if (s_bServerHalted || !NetworkService.IsInSession()) return false;
|
||||||
|
|
||||||
if (levels[0]->isNew || levels[1]->isNew || levels[2]->isNew) {
|
if (levels[0]->isNew || levels[1]->isNew || levels[2]->isNew) {
|
||||||
levels[0]->saveToDisc(mcprogress, false);
|
levels[0]->saveToDisc(mcprogress, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false;
|
if (s_bServerHalted || !NetworkService.IsInSession()) return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int r = 24; for (int x = -r; x <= r; x++) {
|
* int r = 24; for (int x = -r; x <= r; x++) {
|
||||||
|
|
@ -960,7 +960,7 @@ void MinecraftServer::stopServer(bool didInit) {
|
||||||
delete settings;
|
delete settings;
|
||||||
settings = nullptr;
|
settings = nullptr;
|
||||||
|
|
||||||
g_NetworkManager.ServerStopped();
|
NetworkService.ServerStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftServer::halt() { running = false; }
|
void MinecraftServer::halt() { running = false; }
|
||||||
|
|
@ -1692,13 +1692,13 @@ void MinecraftServer::chunkPacketManagement_PostTick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftServer::cycleSlowQueueIndex() {
|
void MinecraftServer::cycleSlowQueueIndex() {
|
||||||
if (!g_NetworkManager.IsInSession()) return;
|
if (!NetworkService.IsInSession()) return;
|
||||||
|
|
||||||
int startingIndex = s_slowQueuePlayerIndex;
|
int startingIndex = s_slowQueuePlayerIndex;
|
||||||
INetworkPlayer* currentPlayer = nullptr;
|
INetworkPlayer* currentPlayer = nullptr;
|
||||||
int currentPlayerCount = 0;
|
int currentPlayerCount = 0;
|
||||||
do {
|
do {
|
||||||
currentPlayerCount = g_NetworkManager.GetPlayerCount();
|
currentPlayerCount = NetworkService.GetPlayerCount();
|
||||||
if (startingIndex >= currentPlayerCount) startingIndex = 0;
|
if (startingIndex >= currentPlayerCount) startingIndex = 0;
|
||||||
++s_slowQueuePlayerIndex;
|
++s_slowQueuePlayerIndex;
|
||||||
|
|
||||||
|
|
@ -1709,11 +1709,11 @@ void MinecraftServer::cycleSlowQueueIndex() {
|
||||||
// join. The QNet session might be ending while we do this, so do a
|
// join. The QNet session might be ending while we do this, so do a
|
||||||
// few more checks that the player is real
|
// few more checks that the player is real
|
||||||
currentPlayer =
|
currentPlayer =
|
||||||
g_NetworkManager.GetPlayerByIndex(s_slowQueuePlayerIndex);
|
NetworkService.GetPlayerByIndex(s_slowQueuePlayerIndex);
|
||||||
} else {
|
} else {
|
||||||
s_slowQueuePlayerIndex = 0;
|
s_slowQueuePlayerIndex = 0;
|
||||||
}
|
}
|
||||||
} while (g_NetworkManager.IsInSession() && currentPlayerCount > 0 &&
|
} while (NetworkService.IsInSession() && currentPlayerCount > 0 &&
|
||||||
s_slowQueuePlayerIndex != startingIndex &&
|
s_slowQueuePlayerIndex != startingIndex &&
|
||||||
currentPlayer != nullptr && currentPlayer->IsLocal());
|
currentPlayer != nullptr && currentPlayer->IsLocal());
|
||||||
// Log::info("Cycled slow queue index to %d\n",
|
// Log::info("Cycled slow queue index to %d\n",
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
|
#include "app/common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
|
||||||
#include "minecraft/world/level/GameRules/GameRulesInstance.h"
|
#include "minecraft/world/level/GameRules/GameRulesInstance.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "app/common/Network/Socket.h"
|
#include "app/common/Network/Socket.h"
|
||||||
#include "app/common/Tutorial/Tutorial.h"
|
#include "app/common/Tutorial/Tutorial.h"
|
||||||
|
|
@ -915,7 +915,7 @@ void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player,
|
||||||
player->gameMode->setLevel(newLevel);
|
player->gameMode->setLevel(newLevel);
|
||||||
|
|
||||||
// Resend the teleport if we haven't yet sent the chunk they will land on
|
// Resend the teleport if we haven't yet sent the chunk they will land on
|
||||||
if (!g_NetworkManager.SystemFlagGet(
|
if (!NetworkService.SystemFlagGet(
|
||||||
player->connection->getNetworkPlayer(),
|
player->connection->getNetworkPlayer(),
|
||||||
ServerPlayer::getFlagIndexForChunk(
|
ServerPlayer::getFlagIndexForChunk(
|
||||||
ChunkPos(player->xChunk, player->zChunk),
|
ChunkPos(player->xChunk, player->zChunk),
|
||||||
|
|
@ -1069,7 +1069,7 @@ void PlayerList::tick() {
|
||||||
std::uint8_t smallId = m_smallIdsToKick.front();
|
std::uint8_t smallId = m_smallIdsToKick.front();
|
||||||
m_smallIdsToKick.pop_front();
|
m_smallIdsToKick.pop_front();
|
||||||
INetworkPlayer* selectedPlayer =
|
INetworkPlayer* selectedPlayer =
|
||||||
g_NetworkManager.GetPlayerBySmallId(smallId);
|
NetworkService.GetPlayerBySmallId(smallId);
|
||||||
if (selectedPlayer != nullptr) {
|
if (selectedPlayer != nullptr) {
|
||||||
if (selectedPlayer->IsLocal() != true) {
|
if (selectedPlayer->IsLocal() != true) {
|
||||||
// #if 0
|
// #if 0
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "ServerChunkCache.h"
|
#include "ServerChunkCache.h"
|
||||||
#include "ServerLevel.h"
|
#include "ServerLevel.h"
|
||||||
|
|
@ -264,7 +264,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<Packet> packet) {
|
||||||
ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
||||||
if (player->seenChunks.find(pos) != player->seenChunks.end() &&
|
if (player->seenChunks.find(pos) != player->seenChunks.end() &&
|
||||||
(player->connection->isLocal() ||
|
(player->connection->isLocal() ||
|
||||||
g_NetworkManager.SystemFlagGet(
|
NetworkService.SystemFlagGet(
|
||||||
player->connection->getNetworkPlayer(), flagIndex))) {
|
player->connection->getNetworkPlayer(), flagIndex))) {
|
||||||
player->connection->send(packet);
|
player->connection->send(packet);
|
||||||
sentTo.push_back(player);
|
sentTo.push_back(player);
|
||||||
|
|
@ -298,7 +298,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<Packet> packet) {
|
||||||
// (this flag will be the same for all players on the same system)
|
// (this flag will be the same for all players on the same system)
|
||||||
int flagIndex =
|
int flagIndex =
|
||||||
ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
||||||
if (!g_NetworkManager.SystemFlagGet(
|
if (!NetworkService.SystemFlagGet(
|
||||||
player->connection->getNetworkPlayer(), flagIndex))
|
player->connection->getNetworkPlayer(), flagIndex))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#include "EntityTracker.h"
|
#include "EntityTracker.h"
|
||||||
#include "minecraft/Console_Debug_enum.h"
|
#include "minecraft/Console_Debug_enum.h"
|
||||||
#include "minecraft/world/level/GameRules/GameRulesInstance.h"
|
#include "minecraft/world/level/GameRules/GameRulesInstance.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "ServerLevel.h"
|
#include "ServerLevel.h"
|
||||||
#include "ServerPlayerGameMode.h"
|
#include "ServerPlayerGameMode.h"
|
||||||
|
|
@ -442,7 +442,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
||||||
// connection->getNetworkPlayer()->GetSmallId(),
|
// connection->getNetworkPlayer()->GetSmallId(),
|
||||||
// canSendToPlayer,
|
// canSendToPlayer,
|
||||||
// connection->countDelayedPackets(),
|
// connection->countDelayedPackets(),
|
||||||
// g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages(
|
// NetworkService.GetHostPlayer()->GetSendQueueSizeMessages(
|
||||||
// nullptr, true ),
|
// nullptr, true ),
|
||||||
// connection->done);
|
// connection->done);
|
||||||
// }
|
// }
|
||||||
|
|
@ -450,7 +450,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
||||||
if (dontDelayChunks ||
|
if (dontDelayChunks ||
|
||||||
(canSendToPlayer &&
|
(canSendToPlayer &&
|
||||||
(connection->countDelayedPackets() < 4) &&
|
(connection->countDelayedPackets() < 4) &&
|
||||||
(g_NetworkManager.GetHostPlayer()
|
(NetworkService.GetHostPlayer()
|
||||||
->GetSendQueueSizeMessages(nullptr, true) < 4) &&
|
->GetSendQueueSizeMessages(nullptr, true) < 4) &&
|
||||||
//(tickCount - lastBrupSendTickCount) >
|
//(tickCount - lastBrupSendTickCount) >
|
||||||
//(connection->getNetworkPlayer()->GetCurrentRtt()>>4) &&
|
//(connection->getNetworkPlayer()->GetCurrentRtt()>>4) &&
|
||||||
|
|
@ -504,7 +504,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
||||||
// ever request that chunks be unloaded on the client
|
// ever request that chunks be unloaded on the client
|
||||||
// and so just gradually build up more and more of the
|
// and so just gradually build up more and more of the
|
||||||
// finite set of chunks as the player moves
|
// finite set of chunks as the player moves
|
||||||
if (!g_NetworkManager.SystemFlagGet(
|
if (!NetworkService.SystemFlagGet(
|
||||||
connection->getNetworkPlayer(), flagIndex)) {
|
connection->getNetworkPlayer(), flagIndex)) {
|
||||||
// Log::info("Creating
|
// Log::info("Creating
|
||||||
// BRUP for %d %d\n",nearest.x, nearest.z);
|
// BRUP for %d %d\n",nearest.x, nearest.z);
|
||||||
|
|
@ -530,7 +530,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
||||||
}
|
}
|
||||||
// Set flag to say we have send this block already to
|
// Set flag to say we have send this block already to
|
||||||
// this system
|
// this system
|
||||||
g_NetworkManager.SystemFlagSet(
|
NetworkService.SystemFlagSet(
|
||||||
connection->getNetworkPlayer(), flagIndex);
|
connection->getNetworkPlayer(), flagIndex);
|
||||||
|
|
||||||
chunkDataSent = true;
|
chunkDataSent = true;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "minecraft/Console_Debug_enum.h"
|
#include "minecraft/Console_Debug_enum.h"
|
||||||
#include "app/common/DLC/DLCManager.h"
|
#include "app/common/DLC/DLCManager.h"
|
||||||
#include "app/common/DLC/DLCSkinFile.h"
|
#include "app/common/DLC/DLCSkinFile.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||||
#include "app/common/Network/Socket.h"
|
#include "app/common/Network/Socket.h"
|
||||||
#include "minecraft/client/model/SkinBox.h"
|
#include "minecraft/client/model/SkinBox.h"
|
||||||
|
|
@ -1098,7 +1098,7 @@ void PlayerConnection::handleServerSettingsChanged(
|
||||||
gameServices().getGameHostOption(eGameHostOption_All))));
|
gameServices().getGameHostOption(eGameHostOption_All))));
|
||||||
|
|
||||||
// Update the QoS data
|
// Update the QoS data
|
||||||
g_NetworkManager.UpdateAndSetGameSessionData();
|
NetworkService.UpdateAndSetGameSessionData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#include "minecraft/GameEnums.h"
|
#include "minecraft/GameEnums.h"
|
||||||
#include "minecraft/client/resources/Colours/ColourTable.h"
|
#include "minecraft/client/resources/Colours/ColourTable.h"
|
||||||
#include "minecraft/Console_Debug_enum.h"
|
#include "minecraft/Console_Debug_enum.h"
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "util/FrameProfiler.h"
|
#include "util/FrameProfiler.h"
|
||||||
#include "java/Random.h"
|
#include "java/Random.h"
|
||||||
#include "minecraft/Direction.h"
|
#include "minecraft/Direction.h"
|
||||||
|
|
@ -3830,7 +3830,7 @@ void Level::setBlocksAndData(int x, int y, int z, int xs, int ys, int zs,
|
||||||
// This is quite expensive so only actually do it if we are hosting,
|
// This is quite expensive so only actually do it if we are hosting,
|
||||||
// online, and the update will actually change something
|
// online, and the update will actually change something
|
||||||
bool forceUnshare = false;
|
bool forceUnshare = false;
|
||||||
if (g_NetworkManager.IsHost() && isClientSide) {
|
if (NetworkService.IsHost() && isClientSide) {
|
||||||
forceUnshare =
|
forceUnshare =
|
||||||
lc->testSetBlocksAndData(data, x0, y0, z0, x1, y1, z1, p);
|
lc->testSetBlocksAndData(data, x0, y0, z0, x1, y1, z1, p);
|
||||||
}
|
}
|
||||||
|
|
@ -3844,7 +3844,7 @@ void Level::setBlocksAndData(int x, int y, int z, int xs, int ys, int zs,
|
||||||
setTilesDirty(xc * 16 + x0, y0, zc * 16 + z0, xc * 16 + x1, y1,
|
setTilesDirty(xc * 16 + x0, y0, zc * 16 + z0, xc * 16 + x1, y1,
|
||||||
zc * 16 + z1);
|
zc * 16 + z1);
|
||||||
|
|
||||||
if (g_NetworkManager.IsHost() && isClientSide) {
|
if (NetworkService.IsHost() && isClientSide) {
|
||||||
lc->startSharingTilesAndData();
|
lc->startSharingTilesAndData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "app/common/Network/GameNetworkManager.h"
|
#include "minecraft/network/INetworkService.h"
|
||||||
#include "SparseLightStorage.h"
|
#include "SparseLightStorage.h"
|
||||||
#include "java/Class.h"
|
#include "java/Class.h"
|
||||||
#include "java/Random.h"
|
#include "java/Random.h"
|
||||||
|
|
@ -1832,7 +1832,7 @@ int LevelChunk::setBlocksAndData(std::vector<uint8_t>& data, int x0, int y0,
|
||||||
// server updated them. This will leave the lighting information out of
|
// server updated them. This will leave the lighting information out of
|
||||||
// sync on the client, so resync for this & surrounding chunks that
|
// sync on the client, so resync for this & surrounding chunks that
|
||||||
// might have been affected
|
// might have been affected
|
||||||
if (level->isClientSide && g_NetworkManager.IsHost()) {
|
if (level->isClientSide && NetworkService.IsHost()) {
|
||||||
reSyncLighting();
|
reSyncLighting();
|
||||||
level->getChunk(x - 1, z - 1)->reSyncLighting();
|
level->getChunk(x - 1, z - 1)->reSyncLighting();
|
||||||
level->getChunk(x - 0, z - 1)->reSyncLighting();
|
level->getChunk(x - 0, z - 1)->reSyncLighting();
|
||||||
|
|
@ -2154,7 +2154,7 @@ void LevelChunk::compressBlocks() {
|
||||||
// compress the local client copy of the data if the data is unshared, since
|
// compress the local client copy of the data if the data is unshared, since
|
||||||
// we'll be throwing this data away again anyway once we share with the
|
// we'll be throwing this data away again anyway once we share with the
|
||||||
// server again.
|
// server again.
|
||||||
if (level->isClientSide && g_NetworkManager.IsHost()) {
|
if (level->isClientSide && NetworkService.IsHost()) {
|
||||||
// Note - only the extraction of the pointers needs to be done in the
|
// Note - only the extraction of the pointers needs to be done in the
|
||||||
// lock, since even if the data is unshared whilst we are
|
// lock, since even if the data is unshared whilst we are
|
||||||
// processing this data is still valid (for the server)
|
// processing this data is still valid (for the server)
|
||||||
|
|
@ -2254,7 +2254,7 @@ void LevelChunk::compressData() {
|
||||||
// compress the local client copy of the data if the data is unshared, since
|
// compress the local client copy of the data if the data is unshared, since
|
||||||
// we'll be throwing this data away again anyway once we share with the
|
// we'll be throwing this data away again anyway once we share with the
|
||||||
// server again.
|
// server again.
|
||||||
if (level->isClientSide && g_NetworkManager.IsHost()) {
|
if (level->isClientSide && NetworkService.IsHost()) {
|
||||||
// Note - only the extraction of the pointers needs to be done in the
|
// Note - only the extraction of the pointers needs to be done in the
|
||||||
// lock, since even if the data is unshared whilst we are
|
// lock, since even if the data is unshared whilst we are
|
||||||
// processing this data is still valid (for the server)
|
// processing this data is still valid (for the server)
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ void SignTileEntity::setChanged() {
|
||||||
// 4J-PB - For TU14 we are allowed to not verify strings anymore !
|
// 4J-PB - For TU14 we are allowed to not verify strings anymore !
|
||||||
m_bVerified = true;
|
m_bVerified = true;
|
||||||
/*
|
/*
|
||||||
if(!g_NetworkManager.IsLocalGame() && !m_bVerified)
|
if(!NetworkService.IsLocalGame() && !m_bVerified)
|
||||||
//if (pMinecraft->level->isClientSide)
|
//if (pMinecraft->level->isClientSide)
|
||||||
{
|
{
|
||||||
char *wcMessages[MAX_SIGN_LINES];
|
char *wcMessages[MAX_SIGN_LINES];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue