summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-04 16:18:03 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-06-04 16:18:03 +0200
commitdff77e8e5690b7834652884aadf6c3d5e1ceafd9 (patch)
tree36e6ae622b45712b521683666c13661544c28733 /source
parentProtoProxy: Added PACKET_SPAWN_NAMED_ENTITY and PACKET_PLAYER_ANIMATION parsing (diff)
downloadcuberite-dff77e8e5690b7834652884aadf6c3d5e1ceafd9.tar
cuberite-dff77e8e5690b7834652884aadf6c3d5e1ceafd9.tar.gz
cuberite-dff77e8e5690b7834652884aadf6c3d5e1ceafd9.tar.bz2
cuberite-dff77e8e5690b7834652884aadf6c3d5e1ceafd9.tar.lz
cuberite-dff77e8e5690b7834652884aadf6c3d5e1ceafd9.tar.xz
cuberite-dff77e8e5690b7834652884aadf6c3d5e1ceafd9.tar.zst
cuberite-dff77e8e5690b7834652884aadf6c3d5e1ceafd9.zip
Diffstat (limited to 'source')
-rw-r--r--source/Chunk.cpp4
-rw-r--r--source/Chunk.h2
-rw-r--r--source/ClientHandle.cpp22
-rw-r--r--source/ClientHandle.h2
-rw-r--r--source/Player.cpp18
-rw-r--r--source/Player.h8
6 files changed, 48 insertions, 8 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index c33ba3608..60ec273be 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -2592,7 +2592,7 @@ void cChunk::BroadcastEntityStatus(const cEntity & a_Entity, char a_Status, cons
-void cChunk::BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_Exclude)
+void cChunk::BroadcastMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
{
for (cClientHandleList::const_iterator itr = m_LoadedByClient.begin(); itr != m_LoadedByClient.end(); ++itr )
{
@@ -2600,7 +2600,7 @@ void cChunk::BroadcastMetadata(const cPawn & a_Pawn, const cClientHandle * a_Exc
{
continue;
}
- (*itr)->SendMetadata(a_Pawn);
+ (*itr)->SendMetadata(a_Entity);
} // for itr - LoadedByClient[]
}
diff --git a/source/Chunk.h b/source/Chunk.h
index a1a6bc1d7..a96d96ef3 100644
--- a/source/Chunk.h
+++ b/source/Chunk.h
@@ -241,7 +241,7 @@ public:
void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL);
void BroadcastDestroyEntity (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = NULL);
- void BroadcastMetadata (const cPawn & a_Pawn, const cClientHandle * a_Exclude = NULL);
+ void BroadcastMetadata (const cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastSpawn (cEntity & a_Entity, const cClientHandle * a_Exclude = NULL);
void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL);
void BroadcastCollectPickup (const cPickup & a_Pickup, const cPlayer & a_Player, const cClientHandle * a_Exclude = NULL);
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index a57e71374..0eb24e9e9 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -1170,9 +1170,23 @@ void cClientHandle::HandleEntityAction(int a_EntityID, char a_ActionID)
return;
}
- if( a_ActionID == 3 ) // Leave bed
+ switch (a_ActionID)
{
- m_Player->GetWorld()->BroadcastPlayerAnimation( *m_Player, 3 );
+ case 1: // crouch
+ {
+ m_Player->SetCrouch(true);
+ break;
+ }
+ case 2: // uncrouch
+ {
+ m_Player->SetCrouch(false);
+ break;
+ }
+ case 3: // Leave bed
+ {
+ m_Player->GetWorld()->BroadcastPlayerAnimation(*m_Player, 3);
+ break;
+ }
}
}
@@ -1560,9 +1574,9 @@ void cClientHandle::SendExplosion(double a_BlockX, double a_BlockY, double a_Blo
-void cClientHandle::SendMetadata(const cPawn & a_Pawn)
+void cClientHandle::SendMetadata(const cEntity & a_Entity)
{
- m_Protocol->SendMetadata(a_Pawn);
+ m_Protocol->SendMetadata(a_Entity);
}
diff --git a/source/ClientHandle.h b/source/ClientHandle.h
index 50389584b..69c0fddf2 100644
--- a/source/ClientHandle.h
+++ b/source/ClientHandle.h
@@ -103,7 +103,7 @@ public:
void SendHealth (void);
void SendInventoryProgress (char a_WindowID, short a_Progressbar, short a_Value);
void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item);
- void SendMetadata (const cPawn & a_Entity);
+ void SendMetadata (const cEntity & a_Entity);
void SendPickupSpawn (const cPickup & a_Pickup);
void SendPlayerAnimation (const cPlayer & a_Player, char a_Animation);
void SendPlayerListItem (const cPlayer & a_Player, bool a_IsOnline);
diff --git a/source/Player.cpp b/source/Player.cpp
index dd71ca834..16255c003 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -50,6 +50,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_ClientHandle( a_Client )
, m_FoodExhaustionLevel(0.f)
, m_FoodTickTimer(0)
+ , m_IsCrouched(false)
{
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
@@ -355,6 +356,23 @@ const cSlotNums & cPlayer::GetInventoryPaintSlots(void) const
+void cPlayer::SetCrouch(bool a_IsCrouched)
+{
+ // Set the crouch status, broadcast to all visible players
+
+ if (a_IsCrouched == m_IsCrouched)
+ {
+ // No change
+ return;
+ }
+ m_IsCrouched = a_IsCrouched;
+ m_World->BroadcastMetadata(*this);
+}
+
+
+
+
+
void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (m_GameMode == eGameMode_Creative)
diff --git a/source/Player.h b/source/Player.h
index c582c1802..f2eb2320d 100644
--- a/source/Player.h
+++ b/source/Player.h
@@ -170,6 +170,12 @@ public:
/// Returns the list of slots currently stored for inventory painting. To be used by cWindow only
const cSlotNums & GetInventoryPaintSlots(void) const;
+
+ /// Sets the crouch status, broadcasts to all visible players
+ void SetCrouch(bool a_IsCrouched);
+
+ // cEntity overrides:
+ virtual bool IsCrouched(void) const { return m_IsCrouched; }
protected:
typedef std::map< std::string, bool > PermissionMap;
@@ -219,6 +225,8 @@ protected:
cClientHandle * m_ClientHandle;
cSlotNums m_InventoryPaintSlots;
+
+ bool m_IsCrouched;
virtual void Destroyed(void);