summaryrefslogtreecommitdiffstats
path: root/source/cPlayer.cpp
diff options
context:
space:
mode:
authormtilden@gmail.com <mtilden@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-26 05:06:29 +0100
committermtilden@gmail.com <mtilden@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-26 05:06:29 +0100
commite2acb45d191a401c2b2f93cbb6484be631bed14d (patch)
treec5b57133da85c12cfda3b3de94943fdce2dbc7ca /source/cPlayer.cpp
parent - Default Notchian Ping (static until ping implemented through keepalive send/receive) (diff)
downloadcuberite-e2acb45d191a401c2b2f93cbb6484be631bed14d.tar
cuberite-e2acb45d191a401c2b2f93cbb6484be631bed14d.tar.gz
cuberite-e2acb45d191a401c2b2f93cbb6484be631bed14d.tar.bz2
cuberite-e2acb45d191a401c2b2f93cbb6484be631bed14d.tar.lz
cuberite-e2acb45d191a401c2b2f93cbb6484be631bed14d.tar.xz
cuberite-e2acb45d191a401c2b2f93cbb6484be631bed14d.tar.zst
cuberite-e2acb45d191a401c2b2f93cbb6484be631bed14d.zip
Diffstat (limited to '')
-rw-r--r--source/cPlayer.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index d0dfa8795..41bb24945 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -16,6 +16,7 @@
#include "cTracer.h"
#include "cRoot.h"
#include "cMakeDir.h"
+#include "cTimer.h"
#include "packets/cPacket_NamedEntitySpawn.h"
#include "packets/cPacket_EntityLook.h"
@@ -82,6 +83,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const char* a_PlayerName)
{
m_EntityType = E_PLAYER;
m_Inventory = new cInventory( this );
+ cTimer t1;
+ m_LastPlayerListTime = t1.GetNowTime();
m_TimeLastTeleportPacket = cWorld::GetTime();
m_TimeLastPickupCheck = cWorld::GetTime();
@@ -234,14 +237,18 @@ void cPlayer::Tick(float a_Dt)
InStateBurning(a_Dt);
}
- // Send Player List
- cWorld::PlayerList PlayerList = cRoot::Get()->GetWorld()->GetAllPlayers();
- for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr )
- {
- if ((*itr) && (*itr)->GetClientHandle() && !((*itr)->GetClientHandle()->IsDestroyed())) {
- cPacket_PlayerListItem PlayerList(GetColor() + GetName(), true, (*itr)->GetClientHandle()->GetPing());
- (*itr)->GetClientHandle()->Send( PlayerList );
+ cTimer t1;
+ // Send Player List (Once per m_LastPlayerListTime/1000 second(s))
+ if (m_LastPlayerListTime + cPlayer::E_PLAYER_LIST_TIME <= t1.GetNowTime()) {
+ cWorld::PlayerList PlayerList = cRoot::Get()->GetWorld()->GetAllPlayers();
+ for( cWorld::PlayerList::iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr )
+ {
+ if ((*itr) && (*itr)->GetClientHandle() && !((*itr)->GetClientHandle()->IsDestroyed())) {
+ cPacket_PlayerListItem PlayerList(GetColor() + GetName(), true, (*itr)->GetClientHandle()->GetPing());
+ (*itr)->GetClientHandle()->Send( PlayerList );
+ }
}
+ m_LastPlayerListTime = t1.GetNowTime();
}
}