- Added timer to cPlayer PlayerListItem because sending the packets like minecraft does (every tick per player) is 20 pps per client to each client and was causing Kicks for having too high of a packet queue
git-svn-id: http://mc-server.googlecode.com/svn/trunk@120 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
f029b905d5
commit
e2acb45d19
@ -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,7 +237,9 @@ void cPlayer::Tick(float a_Dt)
|
||||
InStateBurning(a_Dt);
|
||||
}
|
||||
|
||||
// Send Player List
|
||||
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 )
|
||||
{
|
||||
@ -243,6 +248,8 @@ void cPlayer::Tick(float a_Dt)
|
||||
(*itr)->GetClientHandle()->Send( PlayerList );
|
||||
}
|
||||
}
|
||||
m_LastPlayerListTime = t1.GetNowTime();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -112,5 +112,8 @@ protected:
|
||||
int m_GameMode;
|
||||
std::string m_IP;
|
||||
|
||||
long long m_LastPlayerListTime;
|
||||
static const unsigned short E_PLAYER_LIST_TIME = 1000; // 1000 = once per second
|
||||
|
||||
cClientHandle* m_ClientHandle;
|
||||
}; //tolua_export
|
||||
|
Loading…
Reference in New Issue
Block a user