1
0

Don't send ping updates one packet at a time

* Use the batch update feature of the packet.
* Lengthen interval between time and ping update packets (ref. http://github.com/cuberite/cuberite/issues/4082#issuecomment-348675321).
This commit is contained in:
Tiger Wang
2021-03-17 23:18:02 +00:00
parent e3fe9e5e93
commit 55ba39ca0e
12 changed files with 61 additions and 43 deletions

View File

@@ -34,9 +34,6 @@
// 6000 ticks or 5 minutes
#define PLAYER_INVENTORY_SAVE_INTERVAL 6000
// 1000 = once per second
#define PLAYER_LIST_TIME_MS std::chrono::milliseconds(1000)
namespace
{
@@ -131,8 +128,6 @@ cPlayer::cPlayer(const cClientHandlePtr & a_Client) :
SetMaxHealth(MAX_HEALTH);
m_Health = MAX_HEALTH;
m_LastPlayerListTime = std::chrono::steady_clock::now();
cWorld * World = nullptr;
if (!LoadFromDisk(World))
{
@@ -3205,13 +3200,6 @@ void cPlayer::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// Update items (e.g. Maps)
m_Inventory.UpdateItems();
// Send Player List (Once per m_LastPlayerListTime/1000 ms)
if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= std::chrono::steady_clock::now())
{
m_World->BroadcastPlayerListUpdatePing(*this);
m_LastPlayerListTime = std::chrono::steady_clock::now();
}
if (m_TicksUntilNextSave == 0)
{
SaveToDisk();