From 2f97e8be601aa2d1d4809d2457f54fb6d28e678a Mon Sep 17 00:00:00 2001 From: jadebenn Date: Sun, 17 Nov 2024 22:37:06 -0600 Subject: [PATCH] update read switch cases --- .editorconfig | 2 +- dCommon/AMFDeserialize.cpp | 71 ++++++++++++++------------------------ 2 files changed, 27 insertions(+), 46 deletions(-) diff --git a/.editorconfig b/.editorconfig index ebdfa7ac1..a63178f1c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -73,4 +73,4 @@ cpp_space_around_assignment_operator=insert cpp_space_pointer_reference_alignment=left cpp_space_around_ternary_operator=insert cpp_wrap_preserve_blocks=one_liners -cpp_indent_comment=fasle +cpp_indent_comment=false diff --git a/dCommon/AMFDeserialize.cpp b/dCommon/AMFDeserialize.cpp index b551dbda6..884a0784f 100644 --- a/dCommon/AMFDeserialize.cpp +++ b/dCommon/AMFDeserialize.cpp @@ -10,72 +10,53 @@ */ std::unique_ptr AMFDeserialize::Read(RakNet::BitStream& inStream) { - std::unique_ptr returnValue = nullptr; // Read in the value type from the bitStream eAmf marker; inStream.Read(marker); // Based on the typing, create the value associated with that and return the base value class switch (marker) { - case eAmf::Undefined: { - returnValue = std::make_unique(); - break; - } - - case eAmf::Null: { - returnValue = std::make_unique(); - break; - } - - case eAmf::False: { - returnValue = std::make_unique(false); - break; - } - - case eAmf::True: { - returnValue = std::make_unique(true); - break; - } - - case eAmf::Integer: { - returnValue = ReadAmfInteger(inStream); - break; - } - - case eAmf::Double: { - returnValue = ReadAmfDouble(inStream); - break; - } - - case eAmf::String: { - returnValue = ReadAmfString(inStream); - break; - } - - case eAmf::Array: { - returnValue = ReadAmfArray(inStream); - break; - } + case eAmf::Undefined: + return std::make_unique(); + case eAmf::Null: + return std::make_unique(); + case eAmf::False: + return std::make_unique(false); + case eAmf::True: + return std::make_unique(true); + case eAmf::Integer: + return ReadAmfInteger(inStream); + case eAmf::Double: + return ReadAmfDouble(inStream); + case eAmf::String: + return ReadAmfString(inStream); + case eAmf::Array: + return ReadAmfArray(inStream); // These values are unimplemented in the live client and will remain unimplemented // unless someone modifies the client to allow serializing of these values. case eAmf::XMLDoc: + [[fallthrough]]; case eAmf::Date: + [[fallthrough]]; case eAmf::Object: + [[fallthrough]]; case eAmf::XML: + [[fallthrough]]; case eAmf::ByteArray: + [[fallthrough]]; case eAmf::VectorInt: + [[fallthrough]]; case eAmf::VectorUInt: + [[fallthrough]]; case eAmf::VectorDouble: + [[fallthrough]]; case eAmf::VectorObject: - case eAmf::Dictionary: { + [[fallthrough]]; + case eAmf::Dictionary: throw marker; - break; - } default: throw std::invalid_argument("Invalid AMF3 marker" + std::to_string(static_cast(marker))); - break; } - return returnValue; } uint32_t AMFDeserialize::ReadU29(RakNet::BitStream& inStream) {