1
0

Changed if-else to switch-case

This commit is contained in:
Jan-Fabian Humann 2014-03-08 19:26:32 +01:00
parent 66970fe943
commit 72f9c8b069
3 changed files with 33 additions and 39 deletions

View File

@ -1376,25 +1376,23 @@ int cProtocol125::ParseEntityAction(void)
HANDLE_PACKET_READ(ReadBEInt, int, EntityID); HANDLE_PACKET_READ(ReadBEInt, int, EntityID);
HANDLE_PACKET_READ(ReadChar, char, ActionID); HANDLE_PACKET_READ(ReadChar, char, ActionID);
if (ActionID == 1) // Crouch switch (ActionID)
{ {
case 1: // Crouch
m_Client->HandleEntityCrouch(EntityID, true); m_Client->HandleEntityCrouch(EntityID, true);
} break;
else if (ActionID == 2) // Uncrouch case 2: // Uncrouch
{
m_Client->HandleEntityCrouch(EntityID, false); m_Client->HandleEntityCrouch(EntityID, false);
} break;
else if (ActionID == 3) // Leave Bed case 3: // Leave Bed
{
m_Client->HandleEntityLeaveBed(EntityID); m_Client->HandleEntityLeaveBed(EntityID);
} break;
else if (ActionID == 4) // Start sprinting case 4: // Start sprinting
{
m_Client->HandleEntitySprinting(EntityID, true); m_Client->HandleEntitySprinting(EntityID, true);
} break;
else if (ActionID == 5) // Stop sprinting case 5: // Stop sprinting
{
m_Client->HandleEntitySprinting(EntityID, false); m_Client->HandleEntitySprinting(EntityID, false);
break;
} }
return PARSE_OK; return PARSE_OK;

View File

@ -185,25 +185,23 @@ int cProtocol161::ParseEntityAction(void)
HANDLE_PACKET_READ(ReadChar, char, ActionID); HANDLE_PACKET_READ(ReadChar, char, ActionID);
HANDLE_PACKET_READ(ReadBEInt, int, UnknownHorseVal); HANDLE_PACKET_READ(ReadBEInt, int, UnknownHorseVal);
if (ActionID == 1) // Crouch switch (ActionID)
{ {
case 1: // Crouch
m_Client->HandleEntityCrouch(EntityID, true); m_Client->HandleEntityCrouch(EntityID, true);
} break;
else if (ActionID == 2) // Uncrouch case 2: // Uncrouch
{
m_Client->HandleEntityCrouch(EntityID, false); m_Client->HandleEntityCrouch(EntityID, false);
} break;
else if (ActionID == 3) // Leave Bed case 3: // Leave Bed
{
m_Client->HandleEntityLeaveBed(EntityID); m_Client->HandleEntityLeaveBed(EntityID);
} break;
else if (ActionID == 4) // Start sprinting case 4: // Start sprinting
{
m_Client->HandleEntitySprinting(EntityID, true); m_Client->HandleEntitySprinting(EntityID, true);
} break;
else if (ActionID == 5) // Stop sprinting case 5: // Stop sprinting
{
m_Client->HandleEntitySprinting(EntityID, false); m_Client->HandleEntitySprinting(EntityID, false);
break;
} }
return PARSE_OK; return PARSE_OK;

View File

@ -1733,25 +1733,23 @@ void cProtocol172::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Action); HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Action);
HANDLE_READ(a_ByteBuffer, ReadBEInt, int, JumpBoost); HANDLE_READ(a_ByteBuffer, ReadBEInt, int, JumpBoost);
if (Action == 1) // Crouch switch (Action)
{ {
case 1: // Crouch
m_Client->HandleEntityCrouch(PlayerID, true); m_Client->HandleEntityCrouch(PlayerID, true);
} break;
else if (Action == 2) // Uncrouch case 2: // Unchrouch
{
m_Client->HandleEntityCrouch(PlayerID, false); m_Client->HandleEntityCrouch(PlayerID, false);
} break;
else if (Action == 3) // Leave Bed case 3: // Leave Bed
{
m_Client->HandleEntityLeaveBed(PlayerID); m_Client->HandleEntityLeaveBed(PlayerID);
} break;
else if (Action == 4) // Start sprinting case 4: // Start sprinting
{
m_Client->HandleEntitySprinting(PlayerID, true); m_Client->HandleEntitySprinting(PlayerID, true);
} break;
else if (Action == 5) // Stop sprinting case 5: // Stop sprinting
{
m_Client->HandleEntitySprinting(PlayerID, false); m_Client->HandleEntitySprinting(PlayerID, false);
break;
} }
} }