mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-06 03:43:38 +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;
|
||||
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::byteQueue[512];
|
||||
int CGameNetworkManager::messageQueuePos = 0;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "platform/PlatformTypes.h"
|
||||
#include "app/common/Network/IPlatformNetwork.h"
|
||||
#include "platform/NetTypes.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||
#include "PlatformNetworkManagerStub.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
|
||||
// implementation of PlatformNetworkManager to provide this functionality.
|
||||
|
||||
class CGameNetworkManager {
|
||||
class CGameNetworkManager : public ::minecraft::network::INetworkService {
|
||||
friend class IPlatformNetworkStub;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include "User.h"
|
||||
#include "app/common/Audio/SoundEngine.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 "app/common/Tutorial/Tutorial.h"
|
||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||
|
|
@ -806,7 +806,7 @@ bool Minecraft::addLocalPlayer(int idx) {
|
|||
m_connectionFailed[idx] = false;
|
||||
m_pendingLocalConnections[idx] = nullptr;
|
||||
|
||||
bool success = g_NetworkManager.AddLocalPlayerByUserIndex(idx);
|
||||
bool success = NetworkService.AddLocalPlayerByUserIndex(idx);
|
||||
|
||||
if (success) {
|
||||
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);
|
||||
|
||||
} else {
|
||||
Log::info("g_NetworkManager.AddLocalPlayerByUserIndex failed\n");
|
||||
Log::info("NetworkService.AddLocalPlayerByUserIndex failed\n");
|
||||
}
|
||||
|
||||
return success;
|
||||
|
|
@ -957,7 +957,7 @@ void Minecraft::removeLocalPlayerIdx(int idx) {
|
|||
->removeClientConnection(mplp->connection, true);
|
||||
delete mplp->connection;
|
||||
mplp->connection = nullptr;
|
||||
g_NetworkManager.RemoveLocalPlayerByUserIndex(idx);
|
||||
NetworkService.RemoveLocalPlayerByUserIndex(idx);
|
||||
}
|
||||
getLevel(localplayers[idx]->dimension)->removeEntity(localplayers[idx]);
|
||||
|
||||
|
|
@ -975,7 +975,7 @@ void Minecraft::removeLocalPlayerIdx(int idx) {
|
|||
;
|
||||
delete m_pendingLocalConnections[idx];
|
||||
m_pendingLocalConnections[idx] = nullptr;
|
||||
g_NetworkManager.RemoveLocalPlayerByUserIndex(idx);
|
||||
NetworkService.RemoveLocalPlayerByUserIndex(idx);
|
||||
} else {
|
||||
// Not sure how this works on qnet, but for other platforms, calling
|
||||
// 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
|
||||
if (level != nullptr && g_NetworkManager.IsHost()) {
|
||||
if (level != nullptr && NetworkService.IsHost()) {
|
||||
/*if(!bAutosaveTimerSet)
|
||||
{
|
||||
// set the timer
|
||||
|
|
@ -1184,7 +1184,7 @@ void Minecraft::run_middle() {
|
|||
// list get the unique save name and xuid from
|
||||
// whoever is the host
|
||||
INetworkPlayer* pHostPlayer =
|
||||
g_NetworkManager.GetHostPlayer();
|
||||
NetworkService.GetHostPlayer();
|
||||
PlayerUID xuid = pHostPlayer->GetUID();
|
||||
|
||||
if (gameServices().isInBannedLevelList(
|
||||
|
|
@ -1216,7 +1216,7 @@ void Minecraft::run_middle() {
|
|||
// quadrant display to remind them to press start (if the
|
||||
// session has space)
|
||||
if (level != nullptr && bFirstTimeIntoGame &&
|
||||
g_NetworkManager.SessionHasSpace()) {
|
||||
NetworkService.SessionHasSpace()) {
|
||||
// have a short delay before the display
|
||||
if (iFirstTimeCountdown == 0) {
|
||||
bFirstTimeIntoGame = false;
|
||||
|
|
@ -1390,7 +1390,7 @@ void Minecraft::run_middle() {
|
|||
bool tryJoin = !pause &&
|
||||
!ui.IsIgnorePlayerJoinMenuDisplayed(
|
||||
PlatformInput.GetPrimaryPad()) &&
|
||||
g_NetworkManager.SessionHasSpace() &&
|
||||
NetworkService.SessionHasSpace() &&
|
||||
PlatformRenderer.IsHiDef() &&
|
||||
PlatformInput.ButtonPressed(i);
|
||||
if (tryJoin) {
|
||||
|
|
@ -1408,7 +1408,7 @@ void Minecraft::run_middle() {
|
|||
if (PlatformProfile.IsSignedIn(i)) {
|
||||
// if this is a local game, then the
|
||||
// player just needs to be signed in
|
||||
if (g_NetworkManager.IsLocalGame() ||
|
||||
if (NetworkService.IsLocalGame() ||
|
||||
(PlatformProfile.IsSignedInLive(
|
||||
i) &&
|
||||
PlatformProfile
|
||||
|
|
@ -1425,7 +1425,7 @@ void Minecraft::run_middle() {
|
|||
"ui\n");
|
||||
PlatformProfile.RequestSignInUI(
|
||||
false,
|
||||
g_NetworkManager
|
||||
NetworkService
|
||||
.IsLocalGame(),
|
||||
true, false, true,
|
||||
[this](bool b, int p) {
|
||||
|
|
@ -1497,7 +1497,7 @@ void Minecraft::run_middle() {
|
|||
"ui\n");
|
||||
PlatformProfile.RequestSignInUI(
|
||||
false,
|
||||
g_NetworkManager
|
||||
NetworkService
|
||||
.IsLocalGame(),
|
||||
true, false, true,
|
||||
[this](bool b, int p) {
|
||||
|
|
@ -1513,7 +1513,7 @@ void Minecraft::run_middle() {
|
|||
"Bringing up the sign in ui\n");
|
||||
PlatformProfile.RequestSignInUI(
|
||||
false,
|
||||
g_NetworkManager.IsLocalGame(),
|
||||
NetworkService.IsLocalGame(),
|
||||
true, false, true,
|
||||
[this](bool b, int p) {
|
||||
return InGame_SignInReturned(
|
||||
|
|
@ -1739,7 +1739,7 @@ void Minecraft::run_middle() {
|
|||
Packet::renderAllPacketStats();
|
||||
#else
|
||||
// To show the size of the QNet queue in bytes and messages
|
||||
g_NetworkManager.renderQueueMeter();
|
||||
NetworkService.renderQueueMeter();
|
||||
#endif
|
||||
} else {
|
||||
lastTimer = System::nanoTime();
|
||||
|
|
@ -1778,8 +1778,8 @@ void Minecraft::run_middle() {
|
|||
// pause = !isClientSide() && screen != nullptr &&
|
||||
// screen->isPauseScreen();
|
||||
#if defined(ENABLE_JAVA_GUIS)
|
||||
pause = g_NetworkManager.IsLocalGame() &&
|
||||
g_NetworkManager.GetPlayerCount() == 1 &&
|
||||
pause = NetworkService.IsLocalGame() &&
|
||||
NetworkService.GetPlayerCount() == 1 &&
|
||||
screen != nullptr && screen->isPauseScreen();
|
||||
#else
|
||||
pause = gameServices().isAppPaused();
|
||||
|
|
@ -3980,12 +3980,12 @@ std::string Minecraft::gatherStats1() {
|
|||
}
|
||||
|
||||
std::string Minecraft::gatherStats2() {
|
||||
return g_NetworkManager.GatherStats();
|
||||
return NetworkService.GatherStats();
|
||||
// return levelRenderer->gatherStats2();
|
||||
}
|
||||
|
||||
std::string Minecraft::gatherStats3() {
|
||||
return g_NetworkManager.GatherRTTStats();
|
||||
return NetworkService.GatherRTTStats();
|
||||
// return "P: " + particleEngine->countParticles() + ". T: " +
|
||||
// level->gatherStats();
|
||||
}
|
||||
|
|
@ -4465,7 +4465,7 @@ void Minecraft::playerLeftTutorial(int iPad) {
|
|||
int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) {
|
||||
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
|
||||
// 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:
|
||||
|
|
@ -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,
|
||||
// continue
|
||||
if (bContinue == true && g_NetworkManager.IsInSession() &&
|
||||
if (bContinue == true && NetworkService.IsInSession() &&
|
||||
pMinecraftClass->localplayers[iPad] == nullptr) {
|
||||
// It's possible that the player has not signed in - they can back out
|
||||
// or choose no for the converttoguest
|
||||
if (PlatformProfile.IsSignedIn(iPad)) {
|
||||
if (!g_NetworkManager.SessionHasSpace()) {
|
||||
if (!NetworkService.SessionHasSpace()) {
|
||||
unsigned int uiIDA[1];
|
||||
uiIDA[0] = IDS_OK;
|
||||
ui.RequestErrorMessage(IDS_MULTIPLAYER_FULL_TITLE,
|
||||
IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1);
|
||||
}
|
||||
// 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.AllowedToPlayMultiplayer(iPad))) {
|
||||
if (pMinecraftClass->level->isClientSide) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@
|
|||
#include "EditBox.h"
|
||||
#include "MessageScreen.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/UI/All Platforms/UIEnums.h"
|
||||
#include "app/common/UI/All Platforms/UIStructs.h"
|
||||
|
|
@ -286,10 +290,10 @@ void CreateWorldScreen::buttonClicked(Button* button) {
|
|||
param->xzSize = LEVEL_MAX_WIDTH;
|
||||
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);
|
||||
|
||||
g_NetworkManager.FakeLocalPlayerJoined();
|
||||
NetworkService.FakeLocalPlayerJoined();
|
||||
|
||||
LoadingInputParams* loadingParams = new LoadingInputParams();
|
||||
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "Button.h"
|
||||
#include "MessageScreen.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "OptionsScreen.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/gui/Screen.h"
|
||||
|
|
@ -30,13 +30,13 @@ void PauseScreen::init() {
|
|||
buttons.clear();
|
||||
int yo = -16;
|
||||
// 4jcraft: solves the issue of client-side only pausing in the java gui
|
||||
if (g_NetworkManager.IsLocalGame() &&
|
||||
g_NetworkManager.GetPlayerCount() == 1)
|
||||
if (NetworkService.IsLocalGame() &&
|
||||
NetworkService.GetPlayerCount() == 1)
|
||||
gameServices().setXuiServerAction(PlatformInput.GetPrimaryPad(),
|
||||
eXuiServerAction_PauseServer, true);
|
||||
buttons.push_back(new Button(1, width / 2 - 100, height / 4 + 24 * 5 + yo,
|
||||
I18n::get("menu.returnToMenu")));
|
||||
if (!g_NetworkManager.IsHost()) {
|
||||
if (!NetworkService.IsHost()) {
|
||||
buttons[0]->msg = I18n::get("menu.disconnect");
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ void PauseScreen::exitWorld(Minecraft* minecraft, bool save) {
|
|||
MinecraftServer* server = MinecraftServer::getInstance();
|
||||
|
||||
minecraft->setScreen(new MessageScreen("Leaving world"));
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
if (NetworkService.IsHost()) {
|
||||
server->setSaveOnExit(save);
|
||||
}
|
||||
gameServices().setAction(minecraft->player->GetXboxPad(), eAppAction_ExitWorld);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "Button.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "app/common/Audio/SoundEngine.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "platform/stubs.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/gui/Screen.h"
|
||||
|
|
@ -40,8 +40,8 @@ void Screen::keyPressed(char eventCharacter, int eventKey) {
|
|||
// minecraft->grabMouse(); // 4J - removed
|
||||
// 4jcraft: moved here from PauseScreen to ensure that serverside
|
||||
// unpausing is done in all scenarios
|
||||
if (g_NetworkManager.IsLocalGame() &&
|
||||
g_NetworkManager.GetPlayerCount() == 1)
|
||||
if (NetworkService.IsLocalGame() &&
|
||||
NetworkService.GetPlayerCount() == 1)
|
||||
gameServices().setXuiServerAction(PlatformInput.GetPrimaryPad(),
|
||||
eXuiServerAction_PauseServer, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "app/common/DLC/DLCSkinFile.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 "app/common/Network/Socket.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
|
||||
MOJANG_DATA* pMojangData = nullptr;
|
||||
|
||||
if (!g_NetworkManager.IsLocalGame()) {
|
||||
if (!NetworkService.IsLocalGame()) {
|
||||
pMojangData = gameServices().getMojangDataForXuid(OnlineXuid);
|
||||
}
|
||||
|
||||
if (!g_NetworkManager.IsHost()) {
|
||||
if (!NetworkService.IsHost()) {
|
||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||
(eCCLoginReceived * 100) / (eCCConnected));
|
||||
}
|
||||
|
|
@ -295,7 +295,7 @@ void ClientConnection::handleLogin(std::shared_ptr<LoginPacket> packet) {
|
|||
// find the pad number of this local player
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
INetworkPlayer* networkLocalPlayer =
|
||||
g_NetworkManager.GetLocalPlayerByUserIndex(i);
|
||||
NetworkService.GetLocalPlayerByUserIndex(i);
|
||||
if (networkLocalPlayer == networkPlayer) {
|
||||
iUserID = i;
|
||||
}
|
||||
|
|
@ -1091,7 +1091,7 @@ void ClientConnection::handleMovePlayer(
|
|||
packet->yView = player->y;
|
||||
connection->send(packet);
|
||||
if (!started) {
|
||||
if (!g_NetworkManager.IsHost()) {
|
||||
if (!NetworkService.IsHost()) {
|
||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||
(eCCConnected * 100) / (eCCConnected));
|
||||
}
|
||||
|
|
@ -1274,7 +1274,7 @@ void ClientConnection::handleTileUpdate(
|
|||
MultiPlayerLevel* dimensionLevel =
|
||||
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
|
||||
if (dimensionLevel) {
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
if (NetworkService.IsHost()) {
|
||||
// 4J Stu - Unshare before we make any changes incase the server is
|
||||
// already another step ahead of us Fix for #7904 - Gameplay:
|
||||
// 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
|
||||
// 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
|
||||
if (g_NetworkManager.IsHost() &&
|
||||
if (NetworkService.IsHost() &&
|
||||
(reason == DisconnectPacket::eDisconnect_TimeOut ||
|
||||
reason == DisconnectPacket::eDisconnect_Overflow) &&
|
||||
m_userIndex == PlatformInput.GetPrimaryPad() &&
|
||||
|
|
@ -1918,16 +1918,16 @@ void ClientConnection::handleEntityActionAtPosition(
|
|||
void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
||||
fprintf(stderr,
|
||||
"[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
|
||||
// have Friends-Only UGC set
|
||||
bool canPlay = true;
|
||||
bool canPlayLocal = true;
|
||||
bool isAtLeastOneFriend = g_NetworkManager.IsHost();
|
||||
bool isAtLeastOneFriend = NetworkService.IsHost();
|
||||
bool isFriendsWithHost = true;
|
||||
bool cantPlayContentRestricted = false;
|
||||
|
||||
if (!g_NetworkManager.IsHost()) {
|
||||
if (!NetworkService.IsHost()) {
|
||||
// set the game host settings
|
||||
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(
|
||||
(eCCPreLoginReceived * 100) / (eCCConnected));
|
||||
}
|
||||
|
|
@ -2060,7 +2060,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
|||
"isHost=%d\n",
|
||||
minecraft->user->name.c_str(),
|
||||
SharedConstants::NETWORK_PROTOCOL_VERSION, m_userIndex,
|
||||
(int)g_NetworkManager.IsHost());
|
||||
(int)NetworkService.IsHost());
|
||||
send(std::make_shared<LoginPacket>(
|
||||
minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION,
|
||||
offlineXUID, onlineXUID, (!allAllowed && friendsAllowed),
|
||||
|
|
@ -2069,7 +2069,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
|||
PlatformProfile.IsGuest(m_userIndex)));
|
||||
fprintf(stderr, "[LOGIN] LoginPacket sent successfully\n");
|
||||
|
||||
if (!g_NetworkManager.IsHost()) {
|
||||
if (!NetworkService.IsHost()) {
|
||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||
(eCCLoginSent * 100) / (eCCConnected));
|
||||
}
|
||||
|
|
@ -3014,7 +3014,7 @@ void ClientConnection::handleGameEvent(
|
|||
ui.NavigateToScene(PlatformInput.GetPrimaryPad(), eUIScene_EndPoem,
|
||||
nullptr, eUILayer_Scene, eUIGroup_Fullscreen);
|
||||
} else if (event == GameEventPacket::START_SAVING) {
|
||||
if (!g_NetworkManager.IsHost()) {
|
||||
if (!NetworkService.IsHost()) {
|
||||
// Move app started to here so that it happens immediately otherwise
|
||||
// back-to-back START/STOP packets leave the client stuck in the
|
||||
// loading screen
|
||||
|
|
@ -3023,7 +3023,7 @@ void ClientConnection::handleGameEvent(
|
|||
eAppAction_RemoteServerSave);
|
||||
}
|
||||
} 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) {
|
||||
std::shared_ptr<MultiplayerLocalPlayer> player =
|
||||
minecraft->localplayers[m_userIndex];
|
||||
|
|
@ -3109,7 +3109,7 @@ void ClientConnection::handlePlayerInfo(
|
|||
gameServices().getPlayerPrivileges(packet->m_networkSmallId);
|
||||
|
||||
INetworkPlayer* networkPlayer =
|
||||
g_NetworkManager.GetPlayerBySmallId(packet->m_networkSmallId);
|
||||
NetworkService.GetPlayerBySmallId(packet->m_networkSmallId);
|
||||
|
||||
if (networkPlayer != nullptr && networkPlayer->IsHost()) {
|
||||
// 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(
|
||||
std::shared_ptr<UpdateProgressPacket> packet) {
|
||||
if (!g_NetworkManager.IsHost())
|
||||
if (!NetworkService.IsHost())
|
||||
Minecraft::GetInstance()->progressRenderer->progressStagePercentage(
|
||||
packet->m_percentage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "app/linux/Stubs/winapi_stubs.h"
|
||||
#include "util/StringHelpers.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);
|
||||
|
||||
// LevelChunk *chunk;
|
||||
if (g_NetworkManager
|
||||
if (NetworkService
|
||||
.IsHost()) // force here to disable sharing of data
|
||||
{
|
||||
// 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
|
||||
// heightmap now, which isn't shared. If we aren't sharing with the
|
||||
// server, then this will be calculated when the chunk data arrives.
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
if (NetworkService.IsHost()) {
|
||||
chunk->recalcHeightmapOnly();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include "ClientConnection.h"
|
||||
#include "app/common/Audio/SoundEngine.h"
|
||||
#include "minecraft/Console_Debug_enum.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "MultiPlayerChunkCache.h"
|
||||
#include "MultiPlayerLocalPlayer.h"
|
||||
#include "java/JavaMath.h"
|
||||
|
|
@ -104,13 +104,13 @@ MultiPlayerLevel::~MultiPlayerLevel() {
|
|||
}
|
||||
|
||||
void MultiPlayerLevel::unshareChunkAt(int x, int z) {
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
if (NetworkService.IsHost()) {
|
||||
Level::getChunkAt(x, z)->stopSharingTilesAndData();
|
||||
}
|
||||
}
|
||||
|
||||
void MultiPlayerLevel::shareChunkAt(int x, int z) {
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
if (NetworkService.IsHost()) {
|
||||
Level::getChunkAt(x, z)->startSharingTilesAndData();
|
||||
}
|
||||
}
|
||||
|
|
@ -193,12 +193,12 @@ void MultiPlayerLevel::tick() {
|
|||
// chunks become unshared over time.
|
||||
|
||||
int ls = dimension->getXZSize();
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
if (NetworkService.IsHost()) {
|
||||
if (Level::reallyHasChunk(unshareCheckX - (ls / 2),
|
||||
unshareCheckZ - (ls / 2))) {
|
||||
LevelChunk* lc = Level::getChunk(unshareCheckX - (ls / 2),
|
||||
unshareCheckZ - (ls / 2));
|
||||
if (g_NetworkManager.IsHost()) {
|
||||
if (NetworkService.IsHost()) {
|
||||
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
|
||||
// it already, but the renderer won't know to update
|
||||
if ((Level::setTileAndData(x, y, z, tile, data, Tile::UPDATE_ALL) ||
|
||||
g_NetworkManager.IsHost())) {
|
||||
if (g_NetworkManager.IsHost() && visuallyImportant) {
|
||||
NetworkService.IsHost())) {
|
||||
if (NetworkService.IsHost() && visuallyImportant) {
|
||||
// 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
|
||||
// chunk data is shared so the normal paths never call this
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ void MultiplayerLocalPlayer::heal(float heal) {}
|
|||
void MultiplayerLocalPlayer::tick() {
|
||||
// 4J Added
|
||||
// 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);
|
||||
|
||||
/*if((gameServices().getGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) !=
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include "platform/renderer/renderer.h"
|
||||
#include "app/common/App_structs.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/TutorialMode.h"
|
||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||
|
|
@ -490,9 +490,9 @@ void LocalPlayer::aiStep() {
|
|||
} else if (m_bIsIdle &&
|
||||
PlatformInput.GetIdleSeconds(m_iPad) < PLAYER_IDLE_TIME) {
|
||||
// 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
|
||||
if (g_NetworkManager.IsLocalGame()) {
|
||||
if (NetworkService.IsLocalGame()) {
|
||||
PlatformProfile.SetCurrentGameActivity(
|
||||
m_iPad, CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, false);
|
||||
} else {
|
||||
|
|
@ -500,7 +500,7 @@ void LocalPlayer::aiStep() {
|
|||
m_iPad, CONTEXT_PRESENCE_MULTIPLAYER, false);
|
||||
}
|
||||
} else {
|
||||
if (g_NetworkManager.IsLocalGame()) {
|
||||
if (NetworkService.IsLocalGame()) {
|
||||
PlatformProfile.SetCurrentGameActivity(
|
||||
m_iPad, CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, false);
|
||||
} 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
|
||||
// game unless in offline single player, but lets at least do it
|
||||
// then
|
||||
if (g_NetworkManager.IsLocalGame() &&
|
||||
g_NetworkManager.GetPlayerCount() == 1 &&
|
||||
if (NetworkService.IsLocalGame() &&
|
||||
NetworkService.GetPlayerCount() == 1 &&
|
||||
PlatformProfile.GetAwardType(ach->getAchievementID()) !=
|
||||
EAwardType::Achievement) {
|
||||
ui.CloseUIScenes(m_iPad);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "platform/ShutdownManager.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||
#include "app/common/Network/Socket.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
|
@ -471,8 +471,8 @@ void Connection::tick() {
|
|||
std::vector<std::shared_ptr<Packet> > packetsToHandle;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(incoming_cs);
|
||||
while (!disconnected && !g_NetworkManager.IsLeavingGame() &&
|
||||
g_NetworkManager.IsInSession() && !incoming.empty() &&
|
||||
while (!disconnected && !NetworkService.IsLeavingGame() &&
|
||||
NetworkService.IsInSession() && !incoming.empty() &&
|
||||
max-- >= 0) {
|
||||
std::shared_ptr<Packet> packet = incoming.front();
|
||||
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 "app/common/GameRules/GameRuleManager.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 "PlayerList.h"
|
||||
#include "Settings.h"
|
||||
|
|
@ -261,7 +261,7 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData,
|
|||
initData->saveData->fileSize = 0;
|
||||
}
|
||||
|
||||
g_NetworkManager.ServerReady(); // 4J added
|
||||
NetworkService.ServerReady(); // 4J added
|
||||
return m_bLoaded;
|
||||
}
|
||||
|
||||
|
|
@ -446,7 +446,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
|||
// McRegionLevelStorage *storage = new McRegionLevelStorage(File("."),
|
||||
// name, true); // TODO
|
||||
for (unsigned int i = 0; i < levels.size(); i++) {
|
||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) {
|
||||
if (s_bServerHalted || !NetworkService.IsInSession()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -516,7 +516,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
|||
gameServices().setGameHostOption(eGameHostOption_Structures,
|
||||
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
|
||||
|
||||
|
|
@ -590,7 +590,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
|||
int total = twoRPlusOne * twoRPlusOne;
|
||||
for (int x = -r; x <= r && running; x += 16) {
|
||||
for (int z = -r; z <= r && running; z += 16) {
|
||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) {
|
||||
if (s_bServerHalted || !NetworkService.IsInSession()) {
|
||||
delete spawnPos;
|
||||
m_postUpdateTerminate = true;
|
||||
postProcessTerminate(mcprogress);
|
||||
|
|
@ -678,19 +678,19 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource,
|
|||
// printf("Lighting complete at %dms\n",System::currentTimeMillis() -
|
||||
// startTime);
|
||||
|
||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false;
|
||||
if (s_bServerHalted || !NetworkService.IsInSession()) return false;
|
||||
|
||||
if (levels[1]->isNew) {
|
||||
levels[1]->save(true, mcprogress);
|
||||
}
|
||||
|
||||
if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false;
|
||||
if (s_bServerHalted || !NetworkService.IsInSession()) return false;
|
||||
|
||||
if (levels[2]->isNew) {
|
||||
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
|
||||
// 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);
|
||||
}
|
||||
|
||||
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) {
|
||||
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++) {
|
||||
|
|
@ -960,7 +960,7 @@ void MinecraftServer::stopServer(bool didInit) {
|
|||
delete settings;
|
||||
settings = nullptr;
|
||||
|
||||
g_NetworkManager.ServerStopped();
|
||||
NetworkService.ServerStopped();
|
||||
}
|
||||
|
||||
void MinecraftServer::halt() { running = false; }
|
||||
|
|
@ -1692,13 +1692,13 @@ void MinecraftServer::chunkPacketManagement_PostTick() {
|
|||
}
|
||||
|
||||
void MinecraftServer::cycleSlowQueueIndex() {
|
||||
if (!g_NetworkManager.IsInSession()) return;
|
||||
if (!NetworkService.IsInSession()) return;
|
||||
|
||||
int startingIndex = s_slowQueuePlayerIndex;
|
||||
INetworkPlayer* currentPlayer = nullptr;
|
||||
int currentPlayerCount = 0;
|
||||
do {
|
||||
currentPlayerCount = g_NetworkManager.GetPlayerCount();
|
||||
currentPlayerCount = NetworkService.GetPlayerCount();
|
||||
if (startingIndex >= currentPlayerCount) startingIndex = 0;
|
||||
++s_slowQueuePlayerIndex;
|
||||
|
||||
|
|
@ -1709,11 +1709,11 @@ void MinecraftServer::cycleSlowQueueIndex() {
|
|||
// join. The QNet session might be ending while we do this, so do a
|
||||
// few more checks that the player is real
|
||||
currentPlayer =
|
||||
g_NetworkManager.GetPlayerByIndex(s_slowQueuePlayerIndex);
|
||||
NetworkService.GetPlayerByIndex(s_slowQueuePlayerIndex);
|
||||
} else {
|
||||
s_slowQueuePlayerIndex = 0;
|
||||
}
|
||||
} while (g_NetworkManager.IsInSession() && currentPlayerCount > 0 &&
|
||||
} while (NetworkService.IsInSession() && currentPlayerCount > 0 &&
|
||||
s_slowQueuePlayerIndex != startingIndex &&
|
||||
currentPlayer != nullptr && currentPlayer->IsLocal());
|
||||
// Log::info("Cycled slow queue index to %d\n",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.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 "app/common/Network/Socket.h"
|
||||
#include "app/common/Tutorial/Tutorial.h"
|
||||
|
|
@ -915,7 +915,7 @@ void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player,
|
|||
player->gameMode->setLevel(newLevel);
|
||||
|
||||
// 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(),
|
||||
ServerPlayer::getFlagIndexForChunk(
|
||||
ChunkPos(player->xChunk, player->zChunk),
|
||||
|
|
@ -1069,7 +1069,7 @@ void PlayerList::tick() {
|
|||
std::uint8_t smallId = m_smallIdsToKick.front();
|
||||
m_smallIdsToKick.pop_front();
|
||||
INetworkPlayer* selectedPlayer =
|
||||
g_NetworkManager.GetPlayerBySmallId(smallId);
|
||||
NetworkService.GetPlayerBySmallId(smallId);
|
||||
if (selectedPlayer != nullptr) {
|
||||
if (selectedPlayer->IsLocal() != true) {
|
||||
// #if 0
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "minecraft/network/platform/NetworkPlayerInterface.h"
|
||||
#include "ServerChunkCache.h"
|
||||
#include "ServerLevel.h"
|
||||
|
|
@ -264,7 +264,7 @@ void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<Packet> packet) {
|
|||
ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
||||
if (player->seenChunks.find(pos) != player->seenChunks.end() &&
|
||||
(player->connection->isLocal() ||
|
||||
g_NetworkManager.SystemFlagGet(
|
||||
NetworkService.SystemFlagGet(
|
||||
player->connection->getNetworkPlayer(), flagIndex))) {
|
||||
player->connection->send(packet);
|
||||
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)
|
||||
int flagIndex =
|
||||
ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
||||
if (!g_NetworkManager.SystemFlagGet(
|
||||
if (!NetworkService.SystemFlagGet(
|
||||
player->connection->getNetworkPlayer(), flagIndex))
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#include "EntityTracker.h"
|
||||
#include "minecraft/Console_Debug_enum.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 "ServerLevel.h"
|
||||
#include "ServerPlayerGameMode.h"
|
||||
|
|
@ -442,7 +442,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
|||
// connection->getNetworkPlayer()->GetSmallId(),
|
||||
// canSendToPlayer,
|
||||
// connection->countDelayedPackets(),
|
||||
// g_NetworkManager.GetHostPlayer()->GetSendQueueSizeMessages(
|
||||
// NetworkService.GetHostPlayer()->GetSendQueueSizeMessages(
|
||||
// nullptr, true ),
|
||||
// connection->done);
|
||||
// }
|
||||
|
|
@ -450,7 +450,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
|||
if (dontDelayChunks ||
|
||||
(canSendToPlayer &&
|
||||
(connection->countDelayedPackets() < 4) &&
|
||||
(g_NetworkManager.GetHostPlayer()
|
||||
(NetworkService.GetHostPlayer()
|
||||
->GetSendQueueSizeMessages(nullptr, true) < 4) &&
|
||||
//(tickCount - lastBrupSendTickCount) >
|
||||
//(connection->getNetworkPlayer()->GetCurrentRtt()>>4) &&
|
||||
|
|
@ -504,7 +504,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) {
|
|||
// ever request that chunks be unloaded on the client
|
||||
// and so just gradually build up more and more of the
|
||||
// finite set of chunks as the player moves
|
||||
if (!g_NetworkManager.SystemFlagGet(
|
||||
if (!NetworkService.SystemFlagGet(
|
||||
connection->getNetworkPlayer(), flagIndex)) {
|
||||
// Log::info("Creating
|
||||
// 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
|
||||
// this system
|
||||
g_NetworkManager.SystemFlagSet(
|
||||
NetworkService.SystemFlagSet(
|
||||
connection->getNetworkPlayer(), flagIndex);
|
||||
|
||||
chunkDataSent = true;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include "minecraft/Console_Debug_enum.h"
|
||||
#include "app/common/DLC/DLCManager.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 "app/common/Network/Socket.h"
|
||||
#include "minecraft/client/model/SkinBox.h"
|
||||
|
|
@ -1098,7 +1098,7 @@ void PlayerConnection::handleServerSettingsChanged(
|
|||
gameServices().getGameHostOption(eGameHostOption_All))));
|
||||
|
||||
// Update the QoS data
|
||||
g_NetworkManager.UpdateAndSetGameSessionData();
|
||||
NetworkService.UpdateAndSetGameSessionData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include "minecraft/GameEnums.h"
|
||||
#include "minecraft/client/resources/Colours/ColourTable.h"
|
||||
#include "minecraft/Console_Debug_enum.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "util/FrameProfiler.h"
|
||||
#include "java/Random.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,
|
||||
// online, and the update will actually change something
|
||||
bool forceUnshare = false;
|
||||
if (g_NetworkManager.IsHost() && isClientSide) {
|
||||
if (NetworkService.IsHost() && isClientSide) {
|
||||
forceUnshare =
|
||||
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,
|
||||
zc * 16 + z1);
|
||||
|
||||
if (g_NetworkManager.IsHost() && isClientSide) {
|
||||
if (NetworkService.IsHost() && isClientSide) {
|
||||
lc->startSharingTilesAndData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/network/INetworkService.h"
|
||||
#include "SparseLightStorage.h"
|
||||
#include "java/Class.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
|
||||
// sync on the client, so resync for this & surrounding chunks that
|
||||
// might have been affected
|
||||
if (level->isClientSide && g_NetworkManager.IsHost()) {
|
||||
if (level->isClientSide && NetworkService.IsHost()) {
|
||||
reSyncLighting();
|
||||
level->getChunk(x - 1, 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
|
||||
// we'll be throwing this data away again anyway once we share with the
|
||||
// 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
|
||||
// lock, since even if the data is unshared whilst we are
|
||||
// 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
|
||||
// we'll be throwing this data away again anyway once we share with the
|
||||
// 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
|
||||
// lock, since even if the data is unshared whilst we are
|
||||
// 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 !
|
||||
m_bVerified = true;
|
||||
/*
|
||||
if(!g_NetworkManager.IsLocalGame() && !m_bVerified)
|
||||
if(!NetworkService.IsLocalGame() && !m_bVerified)
|
||||
//if (pMinecraft->level->isClientSide)
|
||||
{
|
||||
char *wcMessages[MAX_SIGN_LINES];
|
||||
|
|
|
|||
Loading…
Reference in a new issue