mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
refactor: Rewrite AMF and property behavior logic to use smart pointers, references, and string_views over raw pointers and std::string& (#1452)
* Rewrite AMF and behavior logic to use smart pointers, references, and string_views over raw pointers and std::string& * fix m_BehaviorID initialization * Fix BlockDefinition member naming * remove redundant reset()s * Replace UB forward template declarations with header include * remove unneeded comment * remove non-const ref getters * simplify default behavior id initialization * Fix invalidated use of Getter to set a value * Update AddStripMessage.cpp - change push_back to emplace_back * fix pointer to ref conversion mistake (should not have directly grabbed from the other branch commit) * deref * VERY experimental testing of forward declaration of templates - probably will revert * Revert changes (as expected) * Update BlockDefinition.h - remove extraneous semicolons * Update BlockDefinition.h - remove linebreak * Update Amf3.h member naming scheme * fix duplicated code * const iterators * const pointers * reviving this branch * update read switch cases
This commit is contained in:
@@ -13,8 +13,7 @@
|
||||
*/
|
||||
std::unique_ptr<AMFBaseValue> ReadFromBitStream(RakNet::BitStream& bitStream) {
|
||||
AMFDeserialize deserializer;
|
||||
AMFBaseValue* returnValue(deserializer.Read(bitStream));
|
||||
return std::unique_ptr<AMFBaseValue>{ returnValue };
|
||||
return deserializer.Read(bitStream);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,7 +253,7 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
|
||||
ASSERT_EQ(strips.size(), 1);
|
||||
|
||||
auto* stripsPosition0 = dynamic_cast<AMFArrayValue*>(strips[0]);
|
||||
auto* stripsPosition0 = dynamic_cast<AMFArrayValue*>(strips[0].get());
|
||||
|
||||
auto* actionIndex = stripsPosition0->Get<double>("actionIndex");
|
||||
|
||||
@@ -272,7 +271,7 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
|
||||
ASSERT_EQ(states.size(), 1);
|
||||
|
||||
auto* firstState = dynamic_cast<AMFArrayValue*>(states[0]);
|
||||
auto* firstState = dynamic_cast<AMFArrayValue*>(states[0].get());
|
||||
|
||||
auto* stateID = firstState->Get<double>("id");
|
||||
|
||||
@@ -282,7 +281,7 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
|
||||
ASSERT_EQ(stripsInState.size(), 1);
|
||||
|
||||
auto* firstStrip = dynamic_cast<AMFArrayValue*>(stripsInState[0]);
|
||||
auto* firstStrip = dynamic_cast<AMFArrayValue*>(stripsInState[0].get());
|
||||
|
||||
auto& actionsInFirstStrip = firstStrip->GetArray("actions")->GetDense();
|
||||
|
||||
@@ -304,7 +303,7 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
|
||||
ASSERT_EQ(stripId->GetValue(), 0.0f);
|
||||
|
||||
auto* firstAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[0]);
|
||||
auto* firstAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[0].get());
|
||||
|
||||
auto* firstType = firstAction->Get<std::string>("Type");
|
||||
|
||||
@@ -314,7 +313,7 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
|
||||
ASSERT_EQ(firstCallback->GetValue(), "");
|
||||
|
||||
auto* secondAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[1]);
|
||||
auto* secondAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[1].get());
|
||||
|
||||
auto* secondType = secondAction->Get<std::string>("Type");
|
||||
|
||||
@@ -328,7 +327,7 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
|
||||
ASSERT_EQ(secondDistance->GetValue(), 25.0f);
|
||||
|
||||
auto* thirdAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[2]);
|
||||
auto* thirdAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[2].get());
|
||||
|
||||
auto* thirdType = thirdAction->Get<std::string>("Type");
|
||||
|
||||
|
Reference in New Issue
Block a user