chore/fix: clean up NetworkSocketLayer, fix console compile errors

This commit is contained in:
2026-09-13 14:10:24 +01:00
parent 0405a47bd1
commit a2dad85bb1
16 changed files with 781 additions and 296 deletions
+8
View File
@@ -88,6 +88,7 @@ bool MinecraftServer::s_slowQueuePacketSent = false;
unordered_map<wstring, int> MinecraftServer::ironTimers;
#ifdef MINECRAFT_SERVER_BUILD
static bool ShouldUseDedicatedServerProperties()
{
#if defined(MINECRAFT_SERVER_BUILD)
@@ -543,6 +544,7 @@ static bool ExecuteConsoleCommand(MinecraftServer *server, const wstring &rawCom
server->warn(L"Unknown command: " + command);
return false;
}
#endif
MinecraftServer::MinecraftServer()
{
@@ -616,10 +618,12 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
logger.info("Loading properties");
#endif
settings = new Settings(new File(L"server.properties"));
#ifdef MINECRAFT_SERVER_BUILD
// Dedicated-only: spawn-protection radius in blocks; 0 disables protection.
m_spawnProtectionRadius = GetDedicatedServerInt(settings, L"spawn-protection", 0);
if (m_spawnProtectionRadius < 0) m_spawnProtectionRadius = 0;
if (m_spawnProtectionRadius > 256) m_spawnProtectionRadius = 256;
#endif
app.DebugPrintf("\n*** SERVER SETTINGS ***\n");
app.DebugPrintf("ServerSettings: host-friends-only is %s\n",(app.GetGameHostOption(eGameHostOption_FriendsOfFriends)>0)?"on":"off");
@@ -1647,9 +1651,13 @@ Level *MinecraftServer::getCommandSenderWorld()
int MinecraftServer::getSpawnProtectionRadius()
{
#ifdef MINECRAFT_SERVER_BUILD
// Client-host mode must never apply dedicated-server spawn protection settings.
if (!ShouldUseDedicatedServerProperties()) return 0;
return m_spawnProtectionRadius;
#else
return 16;
#endif
}
bool MinecraftServer::isUnderSpawnProtection(Level *level, int x, int y, int z, shared_ptr<Player> player)