diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-24 09:58:26 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-24 09:58:26 +0200 |
commit | e92b9e7ecbdf2918aab59d4eeb7bb5966430b264 (patch) | |
tree | 1a998d44e5faab91c54ea8517dd9fa02b3732ef7 /source/cPlayer.cpp | |
parent | Added plugin name to deprecation messages (diff) | |
download | cuberite-e92b9e7ecbdf2918aab59d4eeb7bb5966430b264.tar cuberite-e92b9e7ecbdf2918aab59d4eeb7bb5966430b264.tar.gz cuberite-e92b9e7ecbdf2918aab59d4eeb7bb5966430b264.tar.bz2 cuberite-e92b9e7ecbdf2918aab59d4eeb7bb5966430b264.tar.lz cuberite-e92b9e7ecbdf2918aab59d4eeb7bb5966430b264.tar.xz cuberite-e92b9e7ecbdf2918aab59d4eeb7bb5966430b264.tar.zst cuberite-e92b9e7ecbdf2918aab59d4eeb7bb5966430b264.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cPlayer.cpp | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp index 14163a798..2a52d7da8 100644 --- a/source/cPlayer.cpp +++ b/source/cPlayer.cpp @@ -21,8 +21,6 @@ #include "cTimer.h" #include "MersenneTwister.h" -#include "packets/cPacket_NamedEntitySpawn.h" - #include "Vector3d.h" #include "Vector3f.h" @@ -102,16 +100,6 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) -void cPlayer::Initialize( cWorld* a_World ) -{ - cPawn::Initialize( a_World ); - GetWorld()->AddPlayer( this ); -} - - - - - cPlayer::~cPlayer(void) { LOG("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID()); @@ -134,6 +122,16 @@ cPlayer::~cPlayer(void) +void cPlayer::Initialize( cWorld* a_World ) +{ + cPawn::Initialize( a_World ); + GetWorld()->AddPlayer( this ); +} + + + + + void cPlayer::Destroyed() { CloseWindow(-1); @@ -144,28 +142,18 @@ void cPlayer::Destroyed() -cPacket * cPlayer::GetSpawnPacket(void) const +void cPlayer::SpawnOn(cClientHandle & a_Client) { - LOGD("cPlayer::GetSpawnPacket for \"%s\" at pos {%.2f, %.2f, %.2f}", - m_PlayerName.c_str(), m_Pos.x, m_Pos.y, m_Pos.z + /* + LOGD("cPlayer::SpawnOn(%s) for \"%s\" at pos {%.2f, %.2f, %.2f}", + a_Client.GetUsername().c_str(), m_PlayerName.c_str(), m_Pos.x, m_Pos.y, m_Pos.z ); - - if (!m_bVisible ) + */ + + if (m_bVisible) { - return NULL; + a_Client.SendPlayerSpawn(*this); } - - cPacket_NamedEntitySpawn * SpawnPacket = new cPacket_NamedEntitySpawn; - SpawnPacket->m_UniqueID = m_UniqueID; - SpawnPacket->m_PlayerName = m_PlayerName; - SpawnPacket->m_PosX = (int)(m_Pos.x * 32); - SpawnPacket->m_PosY = (int)(m_Pos.y * 32); - SpawnPacket->m_PosZ = (int)(m_Pos.z * 32); - SpawnPacket->m_Rotation = (char)((m_Rot.x / 360.f) * 256); - SpawnPacket->m_Pitch = (char)((m_Rot.y / 360.f) * 256); - short ItemID = (short)m_Inventory->GetEquippedItem().m_ItemID; - SpawnPacket->m_CurrentItem = (ItemID > 0) ? ItemID : 0; // Unlike -1 in inventory, the named entity packet uses 0 for "none" - return SpawnPacket; } @@ -603,7 +591,7 @@ void cPlayer::SetVisible(bool a_bVisible) if (a_bVisible && !m_bVisible) // Make visible { m_bVisible = true; - SpawnOn(NULL); // Spawn on all clients + m_World->BroadcastSpawn(*this); } if (!a_bVisible && m_bVisible) { @@ -620,7 +608,7 @@ void cPlayer::AddToGroup( const char* a_GroupName ) { cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName ); m_Groups.push_back( Group ); - LOG("Added %s to group %s", m_PlayerName.c_str(), a_GroupName ); + LOGD("Added %s to group %s", m_PlayerName.c_str(), a_GroupName ); ResolveGroups(); ResolvePermissions(); } |