Merge remote-tracking branch 'itsRevela/main'
# Conflicts: # .github/workflows/nightly.yml # .gitignore # Minecraft.Client/ChatScreen.cpp # Minecraft.Client/ClientConnection.cpp # Minecraft.Client/Common/Audio/SoundEngine.cpp # Minecraft.Client/Common/Audio/SoundEngine.h # Minecraft.Client/Common/Media/MediaWindows64.arc # Minecraft.Client/Common/UI/IUIScene_HUD.cpp # Minecraft.Client/Common/UI/UIControl_Base.cpp # Minecraft.Client/Common/UI/UIScene_DeathMenu.cpp # Minecraft.Client/Common/UI/UIScene_JoinMenu.cpp # Minecraft.Client/Common/XUI/XUI_Chat.cpp # Minecraft.Client/Common/XUI/XUI_Death.cpp # Minecraft.Client/Font.cpp # Minecraft.Client/Gui.cpp # Minecraft.Client/PendingConnection.cpp # Minecraft.Client/PlayerConnection.cpp # Minecraft.Client/PlayerConnection.h # Minecraft.Client/PlayerList.cpp # Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp # Minecraft.Client/Windows64/Network/WinsockNetLayer.h # Minecraft.Client/Windows64Media/strings.h # Minecraft.Client/cmake/sources/Common.cmake # Minecraft.Server/Console/ServerCliEngine.cpp # Minecraft.Server/Console/commands/whitelist/CliCommandWhitelist.cpp # Minecraft.Server/Windows64/ServerMain.cpp # Minecraft.World/WitherBoss.h # Minecraft.World/cmake/sources/Common.cmake # README.md
This commit is contained in:
@@ -487,37 +487,52 @@ void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, shared_ptr<ServerPlay
|
||||
}
|
||||
|
||||
// 4J - added - actually create & add player to a playerchunk, if there is one queued for this player.
|
||||
// Processes up to CHUNKS_PER_PLAYER_PER_TICK requests per call to speed up initial chunk loading.
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
static const int CHUNKS_PER_PLAYER_PER_TICK = 16;
|
||||
#else
|
||||
static const int CHUNKS_PER_PLAYER_PER_TICK = 1;
|
||||
#endif
|
||||
|
||||
void PlayerChunkMap::tickAddRequests(shared_ptr<ServerPlayer> player)
|
||||
{
|
||||
if( addRequests.size() )
|
||||
{
|
||||
// Find the nearest chunk request to the player
|
||||
int px = static_cast<int>(player->x);
|
||||
int pz = static_cast<int>(player->z);
|
||||
int minDistSq = -1;
|
||||
|
||||
auto itNearest = addRequests.end();
|
||||
for (auto it = addRequests.begin(); it != addRequests.end(); it++)
|
||||
{
|
||||
if( it->player == player )
|
||||
for (int processed = 0; processed < CHUNKS_PER_PLAYER_PER_TICK; processed++)
|
||||
{
|
||||
// Find the nearest chunk request to the player
|
||||
int minDistSq = -1;
|
||||
auto itNearest = addRequests.end();
|
||||
for (auto it = addRequests.begin(); it != addRequests.end(); it++)
|
||||
{
|
||||
int xm = ( it->x * 16 ) + 8;
|
||||
int zm = ( it->z * 16 ) + 8;
|
||||
int distSq = (xm - px) * (xm - px) +
|
||||
(zm - pz) * (zm - pz);
|
||||
if( ( minDistSq == -1 ) || ( distSq < minDistSq ) )
|
||||
if( it->player == player )
|
||||
{
|
||||
minDistSq = distSq;
|
||||
itNearest = it;
|
||||
int xm = ( it->x * 16 ) + 8;
|
||||
int zm = ( it->z * 16 ) + 8;
|
||||
int distSq = (xm - px) * (xm - px) +
|
||||
(zm - pz) * (zm - pz);
|
||||
if( ( minDistSq == -1 ) || ( distSq < minDistSq ) )
|
||||
{
|
||||
minDistSq = distSq;
|
||||
itNearest = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we found one at all, then do this one
|
||||
if( itNearest != addRequests.end() )
|
||||
{
|
||||
getChunk(itNearest->x, itNearest->z, true)->add(itNearest->player);
|
||||
addRequests.erase(itNearest);
|
||||
// If we found one, process it and continue; otherwise done
|
||||
if( itNearest != addRequests.end() )
|
||||
{
|
||||
getChunk(itNearest->x, itNearest->z, true)->add(itNearest->player);
|
||||
addRequests.erase(itNearest);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -792,6 +807,14 @@ void PlayerChunkMap::setRadius(int newRadius)
|
||||
int xc = static_cast<int>(player->x) >> 4;
|
||||
int zc = static_cast<int>(player->z) >> 4;
|
||||
|
||||
for (auto it = addRequests.begin(); it != addRequests.end(); )
|
||||
{
|
||||
if (it->player == player)
|
||||
it = addRequests.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
for (int x = xc - newRadius; x <= xc + newRadius; x++)
|
||||
for (int z = zc - newRadius; z <= zc + newRadius; z++)
|
||||
{
|
||||
@@ -801,6 +824,18 @@ void PlayerChunkMap::setRadius(int newRadius)
|
||||
getChunkAndAddPlayer(x, z, player);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove chunks that are outside the new radius
|
||||
for (int x = xc - radius; x <= xc + radius; x++)
|
||||
{
|
||||
for (int z = zc - radius; z <= zc + radius; z++)
|
||||
{
|
||||
if (x < xc - newRadius || x > xc + newRadius || z < zc - newRadius || z > zc + newRadius)
|
||||
{
|
||||
getChunkAndRemovePlayer(x, z, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user