summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan-Fabian Humann <j.f.humann@gmail.com>2014-03-08 19:26:32 +0100
committerJan-Fabian Humann <j.f.humann@gmail.com>2014-03-08 19:26:32 +0100
commit72f9c8b06970cb351121ad1e02cccc268db8c56d (patch)
treee0f007678a3ff65ae252cadc6e752bf36bcf9998 /src
parentSplit cClientHandle::HandleEntityAction() into three seperate functions HandleEntityCrouch, HandleEntityLeaveBed and HandleEntitySprinting. (diff)
downloadcuberite-72f9c8b06970cb351121ad1e02cccc268db8c56d.tar
cuberite-72f9c8b06970cb351121ad1e02cccc268db8c56d.tar.gz
cuberite-72f9c8b06970cb351121ad1e02cccc268db8c56d.tar.bz2
cuberite-72f9c8b06970cb351121ad1e02cccc268db8c56d.tar.lz
cuberite-72f9c8b06970cb351121ad1e02cccc268db8c56d.tar.xz
cuberite-72f9c8b06970cb351121ad1e02cccc268db8c56d.tar.zst
cuberite-72f9c8b06970cb351121ad1e02cccc268db8c56d.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/Protocol125.cpp24
-rw-r--r--src/Protocol/Protocol16x.cpp24
-rw-r--r--src/Protocol/Protocol17x.cpp24
3 files changed, 33 insertions, 39 deletions
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index 556ed1d08..169ab0c85 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -1376,25 +1376,23 @@ int cProtocol125::ParseEntityAction(void)
HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
HANDLE_PACKET_READ(ReadChar, char, ActionID);
- if (ActionID == 1) // Crouch
+ switch (ActionID)
{
+ case 1: // Crouch
m_Client->HandleEntityCrouch(EntityID, true);
- }
- else if (ActionID == 2) // Uncrouch
- {
+ break;
+ case 2: // Uncrouch
m_Client->HandleEntityCrouch(EntityID, false);
- }
- else if (ActionID == 3) // Leave Bed
- {
+ break;
+ case 3: // Leave Bed
m_Client->HandleEntityLeaveBed(EntityID);
- }
- else if (ActionID == 4) // Start sprinting
- {
+ break;
+ case 4: // Start sprinting
m_Client->HandleEntitySprinting(EntityID, true);
- }
- else if (ActionID == 5) // Stop sprinting
- {
+ break;
+ case 5: // Stop sprinting
m_Client->HandleEntitySprinting(EntityID, false);
+ break;
}
return PARSE_OK;
diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp
index 6a41a577f..4b1b4f408 100644
--- a/src/Protocol/Protocol16x.cpp
+++ b/src/Protocol/Protocol16x.cpp
@@ -185,25 +185,23 @@ int cProtocol161::ParseEntityAction(void)
HANDLE_PACKET_READ(ReadChar, char, ActionID);
HANDLE_PACKET_READ(ReadBEInt, int, UnknownHorseVal);
- if (ActionID == 1) // Crouch
+ switch (ActionID)
{
+ case 1: // Crouch
m_Client->HandleEntityCrouch(EntityID, true);
- }
- else if (ActionID == 2) // Uncrouch
- {
+ break;
+ case 2: // Uncrouch
m_Client->HandleEntityCrouch(EntityID, false);
- }
- else if (ActionID == 3) // Leave Bed
- {
+ break;
+ case 3: // Leave Bed
m_Client->HandleEntityLeaveBed(EntityID);
- }
- else if (ActionID == 4) // Start sprinting
- {
+ break;
+ case 4: // Start sprinting
m_Client->HandleEntitySprinting(EntityID, true);
- }
- else if (ActionID == 5) // Stop sprinting
- {
+ break;
+ case 5: // Stop sprinting
m_Client->HandleEntitySprinting(EntityID, false);
+ break;
}
return PARSE_OK;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 19998a483..b0ec72a7d 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -1733,25 +1733,23 @@ void cProtocol172::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Action);
HANDLE_READ(a_ByteBuffer, ReadBEInt, int, JumpBoost);
- if (Action == 1) // Crouch
+ switch (Action)
{
+ case 1: // Crouch
m_Client->HandleEntityCrouch(PlayerID, true);
- }
- else if (Action == 2) // Uncrouch
- {
+ break;
+ case 2: // Unchrouch
m_Client->HandleEntityCrouch(PlayerID, false);
- }
- else if (Action == 3) // Leave Bed
- {
+ break;
+ case 3: // Leave Bed
m_Client->HandleEntityLeaveBed(PlayerID);
- }
- else if (Action == 4) // Start sprinting
- {
+ break;
+ case 4: // Start sprinting
m_Client->HandleEntitySprinting(PlayerID, true);
- }
- else if (Action == 5) // Stop sprinting
- {
+ break;
+ case 5: // Stop sprinting
m_Client->HandleEntitySprinting(PlayerID, false);
+ break;
}
}