1
0
Fork 0

Implemented proper player crouching.

Fixes FS #365

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1553 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-06-04 14:18:03 +00:00
parent 5fe0c3d375
commit dff77e8e56
6 changed files with 48 additions and 8 deletions

View File

@ -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[]
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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)

View File

@ -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);