diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2022-01-13 21:51:47 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2022-01-14 20:43:29 +0100 |
commit | 903bcfc61fd031985e55a604293f85c2597a8320 (patch) | |
tree | a03926be8f4ba7aef37a1e349a26e541b95c3c0c /src/Protocol | |
parent | so much big brain time - it hurts (diff) | |
download | cuberite-903bcfc61fd031985e55a604293f85c2597a8320.tar cuberite-903bcfc61fd031985e55a604293f85c2597a8320.tar.gz cuberite-903bcfc61fd031985e55a604293f85c2597a8320.tar.bz2 cuberite-903bcfc61fd031985e55a604293f85c2597a8320.tar.lz cuberite-903bcfc61fd031985e55a604293f85c2597a8320.tar.xz cuberite-903bcfc61fd031985e55a604293f85c2597a8320.tar.zst cuberite-903bcfc61fd031985e55a604293f85c2597a8320.zip |
Diffstat (limited to 'src/Protocol')
-rw-r--r-- | src/Protocol/Protocol_1_8.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index bf31c084c..71f5b16fe 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -374,7 +374,16 @@ void cProtocol_1_8_0::SendChatRaw(const AString & a_MessageRaw, eChatType a_Type // Send the json string to the client: cPacketizer Pkt(*this, pktChatRaw); Pkt.WriteString(a_MessageRaw); - Pkt.WriteBEInt8(static_cast<signed char>(a_Type)); + Pkt.WriteBEInt8([a_Type]() -> signed char + { + switch (a_Type) + { + case eChatType::ctChatBox: return 0; + case eChatType::ctSystem: return 1; + case eChatType::ctAboveActionBar: return 2; + } + UNREACHABLE("Unsupported chat type"); + }()); } @@ -504,7 +513,7 @@ void cProtocol_1_8_0::SendEntityAnimation(const cEntity & a_Entity, const Entity return; } - if (const auto AnimationID = GetProtocolEntityAnimation(a_Animation); AnimationID != static_cast<unsigned char>(-1)) + if (const auto AnimationID = GetProtocolEntityAnimation(a_Animation); AnimationID != unsigned char(-1)) { cPacketizer Pkt(*this, pktEntityAnimation); Pkt.WriteVarInt32(a_Entity.GetUniqueID()); @@ -1969,7 +1978,7 @@ unsigned char cProtocol_1_8_0::GetProtocolEntityAnimation(const EntityAnimation case EntityAnimation::PlayerLeavesBed: return 2; case EntityAnimation::PlayerMainHandSwings: return 0; case EntityAnimation::PlayerOffHandSwings: return 0; - default: return static_cast<unsigned char>(-1); + default: return unsigned char(-1); } } |