From bf838238e45f4ba96c0653f77cf1bf79e6c13c78 Mon Sep 17 00:00:00 2001 From: "mtilden@gmail.com" Date: Mon, 26 Dec 2011 01:07:35 +0000 Subject: - Make Color was using 2 extra characters which took 2 characters off the 16 max (including color codes) for scoreboard display - Added xC9 PlayerListItem packet and added code for player names to be added and removed from the scoreboard (need a catch-all for client disconnects: crashes, timeouts, etc) - Changed wid wording to a_WindowType git-svn-id: http://mc-server.googlecode.com/svn/trunk@113 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cPlayer.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source/cPlayer.cpp') diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp index d13e1e5aa..fd7a09a6b 100644 --- a/source/cPlayer.cpp +++ b/source/cPlayer.cpp @@ -29,6 +29,7 @@ #include "packets/cPacket_Metadata.h" #include "packets/cPacket_Chat.h" #include "packets/cPacket_NewInvalidState.h" +#include "packets/cPacket_PlayerListItem.h" #include "Vector3d.h" #include "Vector3f.h" @@ -232,6 +233,20 @@ void cPlayer::Tick(float a_Dt) if(e_EPMetaState == BURNING){ 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; + PlayerList.m_PlayerName = GetColor() + GetName(); + PlayerList.m_Online = true; + PlayerList.m_Ping = (short)5; + (*itr)->GetClientHandle()->Send( PlayerList ); + } + } + } void cPlayer::InStateBurning(float a_Dt) { @@ -406,10 +421,10 @@ void cPlayer::OpenWindow( cWindow* a_Window ) m_CurrentWindow = a_Window; } -void cPlayer::CloseWindow(char wID = -1) +void cPlayer::CloseWindow(char a_WindowType) { if( m_CurrentWindow ) m_CurrentWindow->Close( *this ); - if (wID == 0) { + if (a_WindowType == 0) { if(GetInventory().GetWindow()->GetDraggingItem() && GetInventory().GetWindow()->GetDraggingItem()->m_ItemCount > 0) { LOG("Player holds item! Dropping it..."); -- cgit v1.2.3