mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-08 17:28:20 +00:00
squash commits (#1479)
This commit is contained in:
parent
b261e63233
commit
424d54b98c
@ -128,10 +128,10 @@ AMFBaseValue* AMFDeserialize::ReadAmfArray(RakNet::BitStream& inStream) {
|
||||
auto arrayValue = new AMFArrayValue();
|
||||
|
||||
// Read size of dense array
|
||||
auto sizeOfDenseArray = (ReadU29(inStream) >> 1);
|
||||
const auto sizeOfDenseArray = (ReadU29(inStream) >> 1);
|
||||
// Then read associative portion
|
||||
while (true) {
|
||||
auto key = ReadString(inStream);
|
||||
const auto key = ReadString(inStream);
|
||||
// No more associative values when we encounter an empty string key
|
||||
if (key.size() == 0) break;
|
||||
arrayValue->Insert(key, Read(inStream));
|
||||
|
@ -23,7 +23,7 @@ private:
|
||||
* @param inStream bitstream to read data from
|
||||
* @return The number as an unsigned 29 bit integer
|
||||
*/
|
||||
uint32_t ReadU29(RakNet::BitStream& inStream);
|
||||
static uint32_t ReadU29(RakNet::BitStream& inStream);
|
||||
|
||||
/**
|
||||
* @brief Reads a string from a bitstream
|
||||
|
@ -42,6 +42,7 @@ class AMFValue : public AMFBaseValue {
|
||||
public:
|
||||
AMFValue() = default;
|
||||
AMFValue(const ValueType value) : m_Data{ value } {}
|
||||
|
||||
virtual ~AMFValue() override = default;
|
||||
|
||||
[[nodiscard]] constexpr eAmf GetValueType() const noexcept override;
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
* @param args the arguments of the message to be deserialized
|
||||
*/
|
||||
template<typename Msg>
|
||||
void HandleControlBehaviorsMsg(AMFArrayValue* args) {
|
||||
void HandleControlBehaviorsMsg(const AMFArrayValue& args) {
|
||||
static_assert(std::is_base_of_v<BehaviorMessageBase, Msg>, "Msg must be a BehaviorMessageBase");
|
||||
Msg msg(args);
|
||||
for (auto& behavior : m_Behaviors) {
|
||||
|
@ -2489,23 +2489,24 @@ void GameMessages::SendUnSmash(Entity* entity, LWOOBJID builderID, float duratio
|
||||
|
||||
void GameMessages::HandleControlBehaviors(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
AMFDeserialize reader;
|
||||
std::unique_ptr<AMFBaseValue> amfArguments(reader.Read(inStream));
|
||||
std::unique_ptr<AMFArrayValue> amfArguments{ static_cast<AMFArrayValue*>(reader.Read(inStream)) };
|
||||
if (amfArguments->GetValueType() != eAmf::Array) return;
|
||||
|
||||
uint32_t commandLength{};
|
||||
inStream.Read(commandLength);
|
||||
|
||||
std::string command;
|
||||
for (uint32_t i = 0; i < commandLength; i++) {
|
||||
command.reserve(commandLength);
|
||||
for (uint32_t i = 0; i < commandLength; ++i) {
|
||||
unsigned char character;
|
||||
inStream.Read(character);
|
||||
command.push_back(character);
|
||||
}
|
||||
|
||||
auto owner = PropertyManagementComponent::Instance()->GetOwner();
|
||||
auto* const owner = PropertyManagementComponent::Instance()->GetOwner();
|
||||
if (!owner) return;
|
||||
|
||||
ControlBehaviors::Instance().ProcessCommand(entity, static_cast<AMFArrayValue*>(amfArguments.get()), command, owner);
|
||||
ControlBehaviors::Instance().ProcessCommand(entity, *amfArguments, command, owner);
|
||||
}
|
||||
|
||||
void GameMessages::HandleBBBSaveRequest(RakNet::BitStream& inStream, Entity* entity, const SystemAddress& sysAddr) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "Action.h"
|
||||
#include "Amf3.h"
|
||||
|
||||
Action::Action(const AMFArrayValue* arguments) {
|
||||
for (const auto& [paramName, paramValue] : arguments->GetAssociative()) {
|
||||
Action::Action(const AMFArrayValue& arguments) {
|
||||
for (const auto& [paramName, paramValue] : arguments.GetAssociative()) {
|
||||
if (paramName == "Type") {
|
||||
if (paramValue->GetValueType() != eAmf::String) continue;
|
||||
m_Type = static_cast<AMFStringValue*>(paramValue)->GetValue();
|
||||
|
@ -12,7 +12,7 @@ class AMFArrayValue;
|
||||
class Action {
|
||||
public:
|
||||
Action() = default;
|
||||
Action(const AMFArrayValue* arguments);
|
||||
Action(const AMFArrayValue& arguments);
|
||||
[[nodiscard]] const std::string& GetType() const { return m_Type; };
|
||||
[[nodiscard]] const std::string& GetValueParameterName() const { return m_ValueParameterName; };
|
||||
[[nodiscard]] const std::string& GetValueParameterString() const { return m_ValueParameterString; };
|
||||
|
@ -4,20 +4,20 @@
|
||||
|
||||
#include "Amf3.h"
|
||||
|
||||
ActionContext::ActionContext(const AMFArrayValue* arguments, const std::string& customStateKey, const std::string& customStripKey)
|
||||
ActionContext::ActionContext(const AMFArrayValue& arguments, const std::string& customStateKey, const std::string& customStripKey)
|
||||
: m_StripId{ GetStripIdFromArgument(arguments, customStripKey) }
|
||||
, m_StateId{ GetBehaviorStateFromArgument(arguments, customStateKey) } {
|
||||
}
|
||||
|
||||
BehaviorState ActionContext::GetBehaviorStateFromArgument(const AMFArrayValue* arguments, const std::string& key) const {
|
||||
const auto* const stateIDValue = arguments->Get<double>(key);
|
||||
BehaviorState ActionContext::GetBehaviorStateFromArgument(const AMFArrayValue& arguments, const std::string& key) const {
|
||||
const auto* const stateIDValue = arguments.Get<double>(key);
|
||||
if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\"");
|
||||
|
||||
return static_cast<BehaviorState>(stateIDValue->GetValue());
|
||||
}
|
||||
|
||||
StripId ActionContext::GetStripIdFromArgument(const AMFArrayValue* arguments, const std::string& key) const {
|
||||
const auto* const stripIdValue = arguments->Get<double>(key);
|
||||
StripId ActionContext::GetStripIdFromArgument(const AMFArrayValue& arguments, const std::string& key) const {
|
||||
const auto* const stripIdValue = arguments.Get<double>(key);
|
||||
if (!stripIdValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\"");
|
||||
|
||||
return static_cast<StripId>(stripIdValue->GetValue());
|
||||
|
@ -13,13 +13,13 @@ class AMFArrayValue;
|
||||
class ActionContext {
|
||||
public:
|
||||
ActionContext() noexcept = default;
|
||||
ActionContext(const AMFArrayValue* arguments, const std::string& customStateKey = "stateID", const std::string& customStripKey = "stripID");
|
||||
ActionContext(const AMFArrayValue& arguments, const std::string& customStateKey = "stateID", const std::string& customStripKey = "stripID");
|
||||
[[nodiscard]] StripId GetStripId() const noexcept { return m_StripId; };
|
||||
[[nodiscard]] BehaviorState GetStateId() const noexcept { return m_StateId; };
|
||||
|
||||
private:
|
||||
[[nodiscard]] BehaviorState GetBehaviorStateFromArgument(const AMFArrayValue* arguments, const std::string& key) const;
|
||||
[[nodiscard]] StripId GetStripIdFromArgument(const AMFArrayValue* arguments, const std::string& key) const;
|
||||
[[nodiscard]] BehaviorState GetBehaviorStateFromArgument(const AMFArrayValue& arguments, const std::string& key) const;
|
||||
[[nodiscard]] StripId GetStripIdFromArgument(const AMFArrayValue& arguments, const std::string& key) const;
|
||||
StripId m_StripId{ 0 };
|
||||
BehaviorState m_StateId{ BehaviorState::HOME_STATE };
|
||||
};
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "AddActionMessage.h"
|
||||
|
||||
AddActionMessage::AddActionMessage(const AMFArrayValue* arguments)
|
||||
AddActionMessage::AddActionMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_ActionIndex{ GetActionIndexFromArgument(arguments) }
|
||||
, m_ActionContext{ arguments } {
|
||||
|
||||
const auto* const actionValue = arguments->GetArray("action");
|
||||
const auto* const actionValue = arguments.GetArray("action");
|
||||
if (!actionValue) return;
|
||||
|
||||
m_Action = Action{ actionValue };
|
||||
m_Action = Action{ *actionValue };
|
||||
|
||||
LOG_DEBUG("actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f m_BehaviorId %i", m_ActionIndex, m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_Action.GetType().c_str(), m_Action.GetValueParameterName().c_str(), m_Action.GetValueParameterString().c_str(), m_Action.GetValueParameterDouble(), m_BehaviorId);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class AddActionMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
AddActionMessage(const AMFArrayValue* arguments);
|
||||
AddActionMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] int32_t GetActionIndex() const noexcept { return m_ActionIndex; };
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "AddMessage.h"
|
||||
|
||||
AddMessage::AddMessage(const AMFArrayValue* arguments) : BehaviorMessageBase{ arguments } {
|
||||
const auto* const behaviorIndexValue = arguments->Get<double>("BehaviorIndex");
|
||||
AddMessage::AddMessage(const AMFArrayValue& arguments) : BehaviorMessageBase{ arguments } {
|
||||
const auto* const behaviorIndexValue = arguments.Get<double>("BehaviorIndex");
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
m_BehaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetValue());
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
class AddMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
AddMessage(const AMFArrayValue* arguments);
|
||||
AddMessage(const AMFArrayValue& arguments);
|
||||
[[nodiscard]] uint32_t GetBehaviorIndex() const noexcept { return m_BehaviorIndex; };
|
||||
|
||||
private:
|
||||
|
@ -2,22 +2,22 @@
|
||||
|
||||
#include "Action.h"
|
||||
|
||||
AddStripMessage::AddStripMessage(const AMFArrayValue* arguments)
|
||||
AddStripMessage::AddStripMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_Position{ arguments }
|
||||
, m_ActionContext{ arguments } {
|
||||
|
||||
const auto* const strip = arguments->GetArray("strip");
|
||||
const auto* const strip = arguments.GetArray("strip");
|
||||
if (!strip) return;
|
||||
|
||||
const auto* const actions = strip->GetArray("actions");
|
||||
if (!actions) return;
|
||||
|
||||
for (uint32_t actionNumber = 0; actionNumber < actions->GetDense().size(); actionNumber++) {
|
||||
for (size_t actionNumber = 0; actionNumber < actions->GetDense().size(); ++actionNumber) {
|
||||
const auto* const actionValue = actions->GetArray(actionNumber);
|
||||
if (!actionValue) continue;
|
||||
|
||||
m_ActionsToAdd.emplace_back(actionValue);
|
||||
m_ActionsToAdd.emplace_back(*actionValue);
|
||||
|
||||
LOG_DEBUG("xPosition %f yPosition %f stripId %i stateId %i behaviorId %i t %s valueParameterName %s valueParameterString %s valueParameterDouble %f", m_Position.GetX(), m_Position.GetY(), m_ActionContext.GetStripId(), m_ActionContext.GetStateId(), m_BehaviorId, m_ActionsToAdd.back().GetType().c_str(), m_ActionsToAdd.back().GetValueParameterName().c_str(), m_ActionsToAdd.back().GetValueParameterString().c_str(), m_ActionsToAdd.back().GetValueParameterDouble());
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class AddStripMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
AddStripMessage(const AMFArrayValue* arguments);
|
||||
AddStripMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] const StripUiPosition& GetPosition() const noexcept { return m_Position; }
|
||||
|
||||
|
@ -4,23 +4,23 @@
|
||||
#include "BehaviorStates.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(const AMFArrayValue* arguments) {
|
||||
int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(const AMFArrayValue& arguments) {
|
||||
static constexpr const char* key = "BehaviorID";
|
||||
const auto* const behaviorIDValue = arguments->Get<std::string>(key);
|
||||
const auto* const behaviorIDValue = arguments.Get<std::string>(key);
|
||||
int32_t behaviorId = DefaultBehaviorId;
|
||||
|
||||
if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) {
|
||||
behaviorId =
|
||||
GeneralUtils::TryParse<int32_t>(behaviorIDValue->GetValue()).value_or(behaviorId);
|
||||
} else if (arguments->Get(key) && arguments->Get(key)->GetValueType() != eAmf::Undefined) {
|
||||
} else if (arguments.Get(key) && arguments.Get(key)->GetValueType() != eAmf::Undefined) {
|
||||
throw std::invalid_argument("Unable to find behavior ID");
|
||||
}
|
||||
|
||||
return behaviorId;
|
||||
}
|
||||
|
||||
int32_t BehaviorMessageBase::GetActionIndexFromArgument(const AMFArrayValue* arguments, const std::string& keyName) const {
|
||||
const auto* const actionIndexAmf = arguments->Get<double>(keyName);
|
||||
int32_t BehaviorMessageBase::GetActionIndexFromArgument(const AMFArrayValue& arguments, const std::string& keyName) const {
|
||||
const auto* const actionIndexAmf = arguments.Get<double>(keyName);
|
||||
if (!actionIndexAmf) throw std::invalid_argument("Unable to find actionIndex");
|
||||
|
||||
return static_cast<int32_t>(actionIndexAmf->GetValue());
|
||||
|
@ -16,13 +16,13 @@ enum class BehaviorState : uint32_t;
|
||||
class BehaviorMessageBase {
|
||||
public:
|
||||
static constexpr int32_t DefaultBehaviorId{ -1 };
|
||||
BehaviorMessageBase(const AMFArrayValue* arguments) : m_BehaviorId{ GetBehaviorIdFromArgument(arguments) } {}
|
||||
BehaviorMessageBase(const AMFArrayValue& arguments) : m_BehaviorId{ GetBehaviorIdFromArgument(arguments) } {}
|
||||
[[nodiscard]] int32_t GetBehaviorId() const noexcept { return m_BehaviorId; }
|
||||
[[nodiscard]] bool IsDefaultBehaviorId() const noexcept { return m_BehaviorId == DefaultBehaviorId; }
|
||||
|
||||
protected:
|
||||
[[nodiscard]] int32_t GetBehaviorIdFromArgument(const AMFArrayValue* arguments);
|
||||
[[nodiscard]] int32_t GetActionIndexFromArgument(const AMFArrayValue* arguments, const std::string& keyName = "actionIndex") const;
|
||||
[[nodiscard]] int32_t GetBehaviorIdFromArgument(const AMFArrayValue& arguments);
|
||||
[[nodiscard]] int32_t GetActionIndexFromArgument(const AMFArrayValue& arguments, const std::string& keyName = "actionIndex") const;
|
||||
int32_t m_BehaviorId{ DefaultBehaviorId };
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "MergeStripsMessage.h"
|
||||
|
||||
MergeStripsMessage::MergeStripsMessage(const AMFArrayValue* arguments)
|
||||
MergeStripsMessage::MergeStripsMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_DstActionIndex{ GetActionIndexFromArgument(arguments, "dstActionIndex") }
|
||||
, m_SourceActionContext{ arguments, "srcStateID", "srcStripID" }
|
||||
|
@ -13,7 +13,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class MergeStripsMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
MergeStripsMessage(const AMFArrayValue* arguments);
|
||||
MergeStripsMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] int32_t GetDstActionIndex() const noexcept { return m_DstActionIndex; }
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "MigrateActionsMessage.h"
|
||||
|
||||
MigrateActionsMessage::MigrateActionsMessage(const AMFArrayValue* arguments)
|
||||
MigrateActionsMessage::MigrateActionsMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_SrcActionIndex{ GetActionIndexFromArgument(arguments, "srcActionIndex") }
|
||||
, m_DstActionIndex{ GetActionIndexFromArgument(arguments, "dstActionIndex") }
|
||||
|
@ -13,7 +13,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class MigrateActionsMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
MigrateActionsMessage(const AMFArrayValue* arguments);
|
||||
MigrateActionsMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] int32_t GetSrcActionIndex() const noexcept { return m_SrcActionIndex; }
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "MoveToInventoryMessage.h"
|
||||
|
||||
MoveToInventoryMessage::MoveToInventoryMessage(const AMFArrayValue* arguments) : BehaviorMessageBase{ arguments } {
|
||||
const auto* const behaviorIndexValue = arguments->Get<double>("BehaviorIndex");
|
||||
MoveToInventoryMessage::MoveToInventoryMessage(const AMFArrayValue& arguments) : BehaviorMessageBase{ arguments } {
|
||||
const auto* const behaviorIndexValue = arguments.Get<double>("BehaviorIndex");
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
m_BehaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetValue());
|
||||
|
@ -11,7 +11,7 @@ class AMFArrayValue;
|
||||
#pragma warning("This Control Behavior Message does not have a test yet. Non-developers can ignore this warning.")
|
||||
class MoveToInventoryMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
MoveToInventoryMessage(const AMFArrayValue* arguments);
|
||||
MoveToInventoryMessage(const AMFArrayValue& arguments);
|
||||
[[nodiscard]] uint32_t GetBehaviorIndex() const noexcept { return m_BehaviorIndex; };
|
||||
|
||||
private:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "RearrangeStripMessage.h"
|
||||
|
||||
RearrangeStripMessage::RearrangeStripMessage(const AMFArrayValue* arguments)
|
||||
RearrangeStripMessage::RearrangeStripMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_SrcActionIndex{ GetActionIndexFromArgument(arguments, "srcActionIndex") }
|
||||
, m_DstActionIndex{ GetActionIndexFromArgument(arguments, "dstActionIndex") }
|
||||
|
@ -10,7 +10,7 @@
|
||||
*/
|
||||
class RearrangeStripMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
RearrangeStripMessage(const AMFArrayValue* arguments);
|
||||
RearrangeStripMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] int32_t GetSrcActionIndex() const noexcept { return m_SrcActionIndex; }
|
||||
[[nodiscard]] int32_t GetDstActionIndex() const noexcept { return m_DstActionIndex; }
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "RemoveActionsMessage.h"
|
||||
|
||||
RemoveActionsMessage::RemoveActionsMessage(const AMFArrayValue* arguments)
|
||||
RemoveActionsMessage::RemoveActionsMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_ActionIndex{ GetActionIndexFromArgument(arguments) }
|
||||
, m_ActionContext{ arguments } {
|
||||
|
@ -12,7 +12,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class RemoveActionsMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
RemoveActionsMessage(const AMFArrayValue* arguments);
|
||||
RemoveActionsMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] int32_t GetActionIndex() const noexcept { return m_ActionIndex; }
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "RemoveStripMessage.h"
|
||||
|
||||
RemoveStripMessage::RemoveStripMessage(const AMFArrayValue* arguments)
|
||||
RemoveStripMessage::RemoveStripMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_ActionContext{ arguments } {
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
*/
|
||||
class RemoveStripMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
RemoveStripMessage(const AMFArrayValue* arguments);
|
||||
RemoveStripMessage(const AMFArrayValue& arguments);
|
||||
|
||||
const ActionContext& GetActionContext() const noexcept { return m_ActionContext; }
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "RenameMessage.h"
|
||||
|
||||
RenameMessage::RenameMessage(const AMFArrayValue* arguments) : BehaviorMessageBase{ arguments } {
|
||||
const auto* const nameAmf = arguments->Get<std::string>("Name");
|
||||
RenameMessage::RenameMessage(const AMFArrayValue& arguments) : BehaviorMessageBase{ arguments } {
|
||||
const auto* const nameAmf = arguments.Get<std::string>("Name");
|
||||
if (!nameAmf) return;
|
||||
|
||||
m_Name = nameAmf->GetValue();
|
||||
|
@ -10,7 +10,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class RenameMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
RenameMessage(const AMFArrayValue* arguments);
|
||||
RenameMessage(const AMFArrayValue& arguments);
|
||||
[[nodiscard]] const std::string& GetName() const { return m_Name; };
|
||||
|
||||
private:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "SplitStripMessage.h"
|
||||
|
||||
SplitStripMessage::SplitStripMessage(const AMFArrayValue* arguments)
|
||||
SplitStripMessage::SplitStripMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_SrcActionIndex{ GetActionIndexFromArgument(arguments, "srcActionIndex") }
|
||||
, m_SourceActionContext{ arguments, "srcStateID", "srcStripID" }
|
||||
|
@ -14,7 +14,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class SplitStripMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
SplitStripMessage(const AMFArrayValue* arguments);
|
||||
SplitStripMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] int32_t GetSrcActionIndex() const noexcept { return m_SrcActionIndex; }
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
#include "Amf3.h"
|
||||
|
||||
StripUiPosition::StripUiPosition(const AMFArrayValue* arguments, const std::string& uiKeyName) {
|
||||
const auto* const uiArray = arguments->GetArray(uiKeyName);
|
||||
StripUiPosition::StripUiPosition(const AMFArrayValue& arguments, const std::string& uiKeyName) {
|
||||
const auto* const uiArray = arguments.GetArray(uiKeyName);
|
||||
if (!uiArray) return;
|
||||
|
||||
const auto* const xPositionValue = uiArray->Get<double>("x");
|
||||
|
@ -10,7 +10,7 @@ class AMFArrayValue;
|
||||
class StripUiPosition {
|
||||
public:
|
||||
StripUiPosition() noexcept = default;
|
||||
StripUiPosition(const AMFArrayValue* arguments, const std::string& uiKeyName = "ui");
|
||||
StripUiPosition(const AMFArrayValue& arguments, const std::string& uiKeyName = "ui");
|
||||
void SendBehaviorBlocksToClient(AMFArrayValue& args) const;
|
||||
[[nodiscard]] double GetX() const noexcept { return m_XPosition; }
|
||||
[[nodiscard]] double GetY() const noexcept { return m_YPosition; }
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
#include "Action.h"
|
||||
|
||||
UpdateActionMessage::UpdateActionMessage(const AMFArrayValue* arguments)
|
||||
UpdateActionMessage::UpdateActionMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_ActionIndex{ GetActionIndexFromArgument(arguments) }
|
||||
, m_ActionContext{ arguments } {
|
||||
|
||||
const auto* const actionValue = arguments->GetArray("action");
|
||||
const auto* const actionValue = arguments.GetArray("action");
|
||||
if (!actionValue) return;
|
||||
|
||||
m_Action = Action{ actionValue };
|
||||
m_Action = Action{ *actionValue };
|
||||
|
||||
LOG_DEBUG("type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i actionIndex %i stripId %i stateId %i", m_Action.GetType().c_str(), m_Action.GetValueParameterName().c_str(), m_Action.GetValueParameterString().c_str(), m_Action.GetValueParameterDouble(), m_BehaviorId, m_ActionIndex, m_ActionContext.GetStripId(), m_ActionContext.GetStateId());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class UpdateActionMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
UpdateActionMessage(const AMFArrayValue* arguments);
|
||||
UpdateActionMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] int32_t GetActionIndex() const noexcept { return m_ActionIndex; }
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "UpdateStripUiMessage.h"
|
||||
|
||||
UpdateStripUiMessage::UpdateStripUiMessage(const AMFArrayValue* arguments)
|
||||
UpdateStripUiMessage::UpdateStripUiMessage(const AMFArrayValue& arguments)
|
||||
: BehaviorMessageBase{ arguments }
|
||||
, m_Position{ arguments }
|
||||
, m_ActionContext{ arguments } {
|
||||
|
@ -13,7 +13,7 @@ class AMFArrayValue;
|
||||
*/
|
||||
class UpdateStripUiMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
UpdateStripUiMessage(const AMFArrayValue* arguments);
|
||||
UpdateStripUiMessage(const AMFArrayValue& arguments);
|
||||
|
||||
[[nodiscard]] const StripUiPosition& GetPosition() const noexcept { return m_Position; };
|
||||
|
||||
|
@ -71,7 +71,7 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ControlBehaviorContext& contex
|
||||
GameMessages::SendUIMessageServerToSingleClient(context.modelOwner, context.modelOwner->GetSystemAddress(), "UpdateBehaviorBlocks", behavior);
|
||||
}
|
||||
|
||||
void ControlBehaviors::UpdateAction(const AMFArrayValue* arguments) {
|
||||
void ControlBehaviors::UpdateAction(const AMFArrayValue& arguments) {
|
||||
UpdateActionMessage updateActionMessage{ arguments };
|
||||
auto blockDefinition = GetBlockInfo(updateActionMessage.GetAction().GetType());
|
||||
|
||||
@ -95,8 +95,8 @@ void ControlBehaviors::UpdateAction(const AMFArrayValue* arguments) {
|
||||
}
|
||||
}
|
||||
|
||||
void ControlBehaviors::ProcessCommand(Entity* modelEntity, AMFArrayValue* arguments, std::string& command, Entity* modelOwner) {
|
||||
if (!isInitialized || !modelEntity || !modelOwner || !arguments) return;
|
||||
void ControlBehaviors::ProcessCommand(Entity* const modelEntity, const AMFArrayValue& arguments, const std::string& command, Entity* const modelOwner) {
|
||||
if (!isInitialized || !modelEntity || !modelOwner) return;
|
||||
auto* const modelComponent = modelEntity->GetComponent<ModelComponent>();
|
||||
|
||||
if (!modelComponent) return;
|
||||
@ -106,7 +106,7 @@ void ControlBehaviors::ProcessCommand(Entity* modelEntity, AMFArrayValue* argume
|
||||
if (command == "sendBehaviorListToClient") {
|
||||
SendBehaviorListToClient(context);
|
||||
} else if (command == "modelTypeChanged") {
|
||||
auto* const modelType = arguments->Get<double>("ModelType");
|
||||
const auto* const modelType = arguments.Get<double>("ModelType");
|
||||
if (!modelType) return;
|
||||
|
||||
modelEntity->SetVar<int>(u"modelType", modelType->GetValue());
|
||||
|
@ -19,15 +19,15 @@ class SystemAddress;
|
||||
typedef std::string BlockName; //! A block name
|
||||
|
||||
struct ControlBehaviorContext {
|
||||
ControlBehaviorContext(AMFArrayValue* args, ModelComponent* modelComponent, Entity* modelOwner) noexcept
|
||||
ControlBehaviorContext(const AMFArrayValue& args, ModelComponent* modelComponent, Entity* modelOwner) noexcept
|
||||
: arguments{ args }, modelComponent{ modelComponent }, modelOwner{ modelOwner } {
|
||||
};
|
||||
|
||||
operator bool() const {
|
||||
return arguments != nullptr && modelComponent != nullptr && modelOwner != nullptr;
|
||||
return modelComponent != nullptr && modelOwner != nullptr;
|
||||
}
|
||||
|
||||
AMFArrayValue* arguments;
|
||||
std::reference_wrapper<const AMFArrayValue> arguments;
|
||||
ModelComponent* modelComponent;
|
||||
Entity* modelOwner;
|
||||
};
|
||||
@ -43,7 +43,7 @@ public:
|
||||
* @param command The command to perform
|
||||
* @param modelOwner The owner of the model which sent this command
|
||||
*/
|
||||
void ProcessCommand(Entity* modelEntity, AMFArrayValue* arguments, std::string& command, Entity* modelOwner);
|
||||
void ProcessCommand(Entity* const modelEntity, const AMFArrayValue& arguments, const std::string& command, Entity* const modelOwner);
|
||||
|
||||
/**
|
||||
* @brief Gets a blocks parameter values by the name
|
||||
@ -58,7 +58,7 @@ private:
|
||||
void RequestUpdatedID(ControlBehaviorContext& context);
|
||||
void SendBehaviorListToClient(const ControlBehaviorContext& context);
|
||||
void SendBehaviorBlocksToClient(ControlBehaviorContext& context);
|
||||
void UpdateAction(const AMFArrayValue* arguments);
|
||||
void UpdateAction(const AMFArrayValue& arguments);
|
||||
std::map<BlockName, BlockDefinition, std::less<>> blockTypes{};
|
||||
|
||||
// If false, property behaviors will not be able to be edited.
|
||||
|
@ -11,10 +11,10 @@
|
||||
/**
|
||||
* Helper method that all tests use to get their respective AMF.
|
||||
*/
|
||||
AMFBaseValue* ReadFromBitStream(RakNet::BitStream& bitStream) {
|
||||
std::unique_ptr<AMFBaseValue> ReadFromBitStream(RakNet::BitStream& bitStream) {
|
||||
AMFDeserialize deserializer;
|
||||
AMFBaseValue* returnValue(deserializer.Read(bitStream));
|
||||
return returnValue;
|
||||
return std::unique_ptr<AMFBaseValue>{ returnValue };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -23,7 +23,7 @@ AMFBaseValue* ReadFromBitStream(RakNet::BitStream& bitStream) {
|
||||
TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) {
|
||||
CBITSTREAM;
|
||||
bitStream.Write<uint8_t>(0x00);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Undefined);
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ TEST(dCommonTests, AMFDeserializeAMFUndefinedTest) {
|
||||
TEST(dCommonTests, AMFDeserializeAMFNullTest) {
|
||||
CBITSTREAM;
|
||||
bitStream.Write<uint8_t>(0x01);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Null);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ TEST(dCommonTests, AMFDeserializeAMFNullTest) {
|
||||
TEST(dCommonTests, AMFDeserializeAMFFalseTest) {
|
||||
CBITSTREAM;
|
||||
bitStream.Write<uint8_t>(0x02);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::False);
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ TEST(dCommonTests, AMFDeserializeAMFFalseTest) {
|
||||
TEST(dCommonTests, AMFDeserializeAMFTrueTest) {
|
||||
CBITSTREAM;
|
||||
bitStream.Write<uint8_t>(0x03);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::True);
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) {
|
||||
bitStream.Write<uint8_t>(0x04);
|
||||
// 127 == 01111111
|
||||
bitStream.Write<uint8_t>(127);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Integer);
|
||||
// Check that the max value of a byte can be read correctly
|
||||
ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 127);
|
||||
@ -76,7 +76,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) {
|
||||
{
|
||||
bitStream.Write<uint8_t>(0x04);
|
||||
bitStream.Write<uint32_t>(UINT32_MAX);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Integer);
|
||||
// Check that we can read the maximum value correctly
|
||||
ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 536870911);
|
||||
@ -90,7 +90,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) {
|
||||
bitStream.Write<uint8_t>(255);
|
||||
// 127 == 01111111
|
||||
bitStream.Write<uint8_t>(127);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Integer);
|
||||
// Check that short max can be read correctly
|
||||
ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), UINT16_MAX);
|
||||
@ -102,7 +102,7 @@ TEST(dCommonTests, AMFDeserializeAMFIntegerTest) {
|
||||
bitStream.Write<uint8_t>(255);
|
||||
// 127 == 01111111
|
||||
bitStream.Write<uint8_t>(127);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Integer);
|
||||
// Check that 2 byte max can be read correctly
|
||||
ASSERT_EQ(static_cast<AMFIntValue*>(res.get())->GetValue(), 16383);
|
||||
@ -116,7 +116,7 @@ TEST(dCommonTests, AMFDeserializeAMFDoubleTest) {
|
||||
CBITSTREAM;
|
||||
bitStream.Write<uint8_t>(0x05);
|
||||
bitStream.Write<double>(25346.4f);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Double);
|
||||
ASSERT_EQ(static_cast<AMFDoubleValue*>(res.get())->GetValue(), 25346.4f);
|
||||
}
|
||||
@ -130,7 +130,7 @@ TEST(dCommonTests, AMFDeserializeAMFStringTest) {
|
||||
bitStream.Write<uint8_t>(0x0F);
|
||||
std::string toWrite = "stateID";
|
||||
for (auto e : toWrite) bitStream.Write<char>(e);
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::String);
|
||||
ASSERT_EQ(static_cast<AMFStringValue*>(res.get())->GetValue(), "stateID");
|
||||
}
|
||||
@ -145,7 +145,7 @@ TEST(dCommonTests, AMFDeserializeAMFArrayTest) {
|
||||
bitStream.Write<uint8_t>(0x01);
|
||||
bitStream.Write<uint8_t>(0x01);
|
||||
{
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Array);
|
||||
ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetAssociative().size(), 0);
|
||||
ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetDense().size(), 0);
|
||||
@ -164,7 +164,7 @@ TEST(dCommonTests, AMFDeserializeAMFArrayTest) {
|
||||
bitStream.Write<uint8_t>(0x0B);
|
||||
for (auto e : "10447") if (e != '\0') bitStream.Write<char>(e);
|
||||
{
|
||||
std::unique_ptr<AMFBaseValue> res(ReadFromBitStream(bitStream));
|
||||
std::unique_ptr<AMFBaseValue> res{ ReadFromBitStream(bitStream) };
|
||||
ASSERT_EQ(res->GetValueType(), eAmf::Array);
|
||||
ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetAssociative().size(), 1);
|
||||
ASSERT_EQ(static_cast<AMFArrayValue*>(res.get())->GetDense().size(), 1);
|
||||
@ -238,107 +238,107 @@ TEST(dCommonTests, AMFDeserializeLivePacketTest) {
|
||||
|
||||
testFileStream.close();
|
||||
|
||||
std::unique_ptr<AMFBaseValue> resultFromFn(ReadFromBitStream(testBitStream));
|
||||
auto result = static_cast<AMFArrayValue*>(resultFromFn.get());
|
||||
std::unique_ptr<AMFBaseValue> resultFromFn{ ReadFromBitStream(testBitStream) };
|
||||
auto* result = static_cast<AMFArrayValue*>(resultFromFn.get());
|
||||
// Test the outermost array
|
||||
|
||||
ASSERT_EQ(result->Get<std::string>("BehaviorID")->GetValue(), "10447");
|
||||
ASSERT_EQ(result->Get<std::string>("objectID")->GetValue(), "288300744895913279");
|
||||
|
||||
// Test the execution state array
|
||||
auto executionState = result->GetArray("executionState");
|
||||
auto* executionState = result->GetArray("executionState");
|
||||
|
||||
ASSERT_NE(executionState, nullptr);
|
||||
|
||||
auto strips = executionState->GetArray("strips")->GetDense();
|
||||
auto& strips = executionState->GetArray("strips")->GetDense();
|
||||
|
||||
ASSERT_EQ(strips.size(), 1);
|
||||
|
||||
auto stripsPosition0 = dynamic_cast<AMFArrayValue*>(strips[0]);
|
||||
auto* stripsPosition0 = dynamic_cast<AMFArrayValue*>(strips[0]);
|
||||
|
||||
auto actionIndex = stripsPosition0->Get<double>("actionIndex");
|
||||
auto* actionIndex = stripsPosition0->Get<double>("actionIndex");
|
||||
|
||||
ASSERT_EQ(actionIndex->GetValue(), 0.0f);
|
||||
|
||||
auto stripIdExecution = stripsPosition0->Get<double>("id");
|
||||
auto* stripIdExecution = stripsPosition0->Get<double>("id");
|
||||
|
||||
ASSERT_EQ(stripIdExecution->GetValue(), 0.0f);
|
||||
|
||||
auto stateIdExecution = executionState->Get<double>("stateID");
|
||||
auto* stateIdExecution = executionState->Get<double>("stateID");
|
||||
|
||||
ASSERT_EQ(stateIdExecution->GetValue(), 0.0f);
|
||||
|
||||
auto states = result->GetArray("states")->GetDense();
|
||||
auto& states = result->GetArray("states")->GetDense();
|
||||
|
||||
ASSERT_EQ(states.size(), 1);
|
||||
|
||||
auto firstState = dynamic_cast<AMFArrayValue*>(states[0]);
|
||||
auto* firstState = dynamic_cast<AMFArrayValue*>(states[0]);
|
||||
|
||||
auto stateID = firstState->Get<double>("id");
|
||||
auto* stateID = firstState->Get<double>("id");
|
||||
|
||||
ASSERT_EQ(stateID->GetValue(), 0.0f);
|
||||
|
||||
auto stripsInState = firstState->GetArray("strips")->GetDense();
|
||||
auto& stripsInState = firstState->GetArray("strips")->GetDense();
|
||||
|
||||
ASSERT_EQ(stripsInState.size(), 1);
|
||||
|
||||
auto firstStrip = dynamic_cast<AMFArrayValue*>(stripsInState[0]);
|
||||
auto* firstStrip = dynamic_cast<AMFArrayValue*>(stripsInState[0]);
|
||||
|
||||
auto actionsInFirstStrip = firstStrip->GetArray("actions")->GetDense();
|
||||
auto& actionsInFirstStrip = firstStrip->GetArray("actions")->GetDense();
|
||||
|
||||
ASSERT_EQ(actionsInFirstStrip.size(), 3);
|
||||
|
||||
auto actionID = firstStrip->Get<double>("id");
|
||||
auto* actionID = firstStrip->Get<double>("id");
|
||||
|
||||
ASSERT_EQ(actionID->GetValue(), 0.0f);
|
||||
|
||||
auto uiArray = firstStrip->GetArray("ui");
|
||||
auto* uiArray = firstStrip->GetArray("ui");
|
||||
|
||||
auto xPos = uiArray->Get<double>("x");
|
||||
auto yPos = uiArray->Get<double>("y");
|
||||
auto* xPos = uiArray->Get<double>("x");
|
||||
auto* yPos = uiArray->Get<double>("y");
|
||||
|
||||
ASSERT_EQ(xPos->GetValue(), 103.0f);
|
||||
ASSERT_EQ(yPos->GetValue(), 82.0f);
|
||||
|
||||
auto stripId = firstStrip->Get<double>("id");
|
||||
auto* stripId = firstStrip->Get<double>("id");
|
||||
|
||||
ASSERT_EQ(stripId->GetValue(), 0.0f);
|
||||
|
||||
auto firstAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[0]);
|
||||
auto* firstAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[0]);
|
||||
|
||||
auto firstType = firstAction->Get<std::string>("Type");
|
||||
auto* firstType = firstAction->Get<std::string>("Type");
|
||||
|
||||
ASSERT_EQ(firstType->GetValue(), "OnInteract");
|
||||
|
||||
auto firstCallback = firstAction->Get<std::string>("__callbackID__");
|
||||
auto* firstCallback = firstAction->Get<std::string>("__callbackID__");
|
||||
|
||||
ASSERT_EQ(firstCallback->GetValue(), "");
|
||||
|
||||
auto secondAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[1]);
|
||||
auto* secondAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[1]);
|
||||
|
||||
auto secondType = secondAction->Get<std::string>("Type");
|
||||
auto* secondType = secondAction->Get<std::string>("Type");
|
||||
|
||||
ASSERT_EQ(secondType->GetValue(), "FlyUp");
|
||||
|
||||
auto secondCallback = secondAction->Get<std::string>("__callbackID__");
|
||||
auto* secondCallback = secondAction->Get<std::string>("__callbackID__");
|
||||
|
||||
ASSERT_EQ(secondCallback->GetValue(), "");
|
||||
|
||||
auto secondDistance = secondAction->Get<double>("Distance");
|
||||
auto* secondDistance = secondAction->Get<double>("Distance");
|
||||
|
||||
ASSERT_EQ(secondDistance->GetValue(), 25.0f);
|
||||
|
||||
auto thirdAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[2]);
|
||||
auto* thirdAction = dynamic_cast<AMFArrayValue*>(actionsInFirstStrip[2]);
|
||||
|
||||
auto thirdType = thirdAction->Get<std::string>("Type");
|
||||
auto* thirdType = thirdAction->Get<std::string>("Type");
|
||||
|
||||
ASSERT_EQ(thirdType->GetValue(), "FlyDown");
|
||||
|
||||
auto thirdCallback = thirdAction->Get<std::string>("__callbackID__");
|
||||
auto* thirdCallback = thirdAction->Get<std::string>("__callbackID__");
|
||||
|
||||
ASSERT_EQ(thirdCallback->GetValue(), "");
|
||||
|
||||
auto thirdDistance = thirdAction->Get<double>("Distance");
|
||||
auto* thirdDistance = thirdAction->Get<double>("Distance");
|
||||
|
||||
ASSERT_EQ(thirdDistance->GetValue(), 25.0f);
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ protected:
|
||||
}
|
||||
return readFile;
|
||||
}
|
||||
AMFArrayValue* ReadArrayFromBitStream(RakNet::BitStream& inStream) {
|
||||
const AMFArrayValue& ReadArrayFromBitStream(RakNet::BitStream& inStream) {
|
||||
AMFDeserialize des;
|
||||
AMFBaseValue* readArray = des.Read(inStream);
|
||||
EXPECT_EQ(readArray->GetValueType(), eAmf::Array);
|
||||
return static_cast<AMFArrayValue*>(readArray);
|
||||
return static_cast<AMFArrayValue&>(*readArray);
|
||||
}
|
||||
};
|
||||
|
||||
@ -93,7 +93,7 @@ TEST_F(GameMessageTests, ControlBehaviorAddStrip) {
|
||||
ASSERT_FLOAT_EQ(addStrip.GetPosition().GetY(), 178.05);
|
||||
ASSERT_EQ(addStrip.GetActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(addStrip.GetActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(addStrip.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(addStrip.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
ASSERT_EQ(addStrip.GetActionsToAdd().front().GetType(), "DropImagination");
|
||||
ASSERT_EQ(addStrip.GetActionsToAdd().front().GetValueParameterName(), "Amount");
|
||||
ASSERT_EQ(addStrip.GetActionsToAdd().front().GetValueParameterString(), "");
|
||||
@ -106,7 +106,7 @@ TEST_F(GameMessageTests, ControlBehaviorRemoveStrip) {
|
||||
RemoveStripMessage removeStrip(ReadArrayFromBitStream(inStream));
|
||||
ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStripId()), 1);
|
||||
ASSERT_EQ(static_cast<int32_t>(removeStrip.GetActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(removeStrip.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(removeStrip.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
}
|
||||
|
||||
TEST_F(GameMessageTests, ControlBehaviorMergeStrips) {
|
||||
@ -118,7 +118,7 @@ TEST_F(GameMessageTests, ControlBehaviorMergeStrips) {
|
||||
ASSERT_EQ(static_cast<uint32_t>(mergeStrips.GetSourceActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(mergeStrips.GetDestinationActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(mergeStrips.GetDstActionIndex(), 0);
|
||||
ASSERT_EQ(mergeStrips.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(mergeStrips.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
}
|
||||
|
||||
TEST_F(GameMessageTests, ControlBehaviorSplitStrip) {
|
||||
@ -144,7 +144,7 @@ TEST_F(GameMessageTests, ControlBehaviorUpdateStripUI) {
|
||||
ASSERT_FLOAT_EQ(updateStripUi.GetPosition().GetY(), 35.35);
|
||||
ASSERT_EQ(updateStripUi.GetActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(updateStripUi.GetActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(updateStripUi.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(updateStripUi.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
}
|
||||
|
||||
TEST_F(GameMessageTests, ControlBehaviorAddAction) {
|
||||
@ -158,7 +158,7 @@ TEST_F(GameMessageTests, ControlBehaviorAddAction) {
|
||||
ASSERT_EQ(addAction.GetAction().GetValueParameterName(), "");
|
||||
ASSERT_EQ(addAction.GetAction().GetValueParameterString(), "");
|
||||
ASSERT_EQ(addAction.GetAction().GetValueParameterDouble(), 0.0);
|
||||
ASSERT_EQ(addAction.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(addAction.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
}
|
||||
|
||||
TEST_F(GameMessageTests, ControlBehaviorMigrateActions) {
|
||||
@ -171,7 +171,7 @@ TEST_F(GameMessageTests, ControlBehaviorMigrateActions) {
|
||||
ASSERT_EQ(migrateActions.GetDestinationActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(migrateActions.GetSourceActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(migrateActions.GetDestinationActionContext().GetStateId()), 0);
|
||||
ASSERT_EQ(migrateActions.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(migrateActions.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
}
|
||||
|
||||
TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) {
|
||||
@ -181,7 +181,7 @@ TEST_F(GameMessageTests, ControlBehaviorRearrangeStrip) {
|
||||
ASSERT_EQ(rearrangeStrip.GetSrcActionIndex(), 2);
|
||||
ASSERT_EQ(rearrangeStrip.GetDstActionIndex(), 1);
|
||||
ASSERT_EQ(rearrangeStrip.GetActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(rearrangeStrip.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(rearrangeStrip.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
ASSERT_EQ(static_cast<uint32_t>(rearrangeStrip.GetActionContext().GetStateId()), 0);
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ TEST_F(GameMessageTests, ControlBehaviorRename) {
|
||||
RakNet::BitStream inStream((unsigned char*)data.c_str(), data.length(), true);
|
||||
RenameMessage rename(ReadArrayFromBitStream(inStream));
|
||||
ASSERT_EQ(rename.GetName(), "test");
|
||||
ASSERT_EQ(rename.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(rename.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
}
|
||||
|
||||
TEST_F(GameMessageTests, ControlBehaviorUpdateAction) {
|
||||
@ -219,7 +219,7 @@ TEST_F(GameMessageTests, ControlBehaviorUpdateAction) {
|
||||
ASSERT_EQ(updateAction.GetAction().GetValueParameterName(), "Distance");
|
||||
ASSERT_EQ(updateAction.GetAction().GetValueParameterString(), "");
|
||||
ASSERT_EQ(updateAction.GetAction().GetValueParameterDouble(), 50.0);
|
||||
ASSERT_EQ(updateAction.GetBehaviorId(), -1);
|
||||
ASSERT_EQ(updateAction.GetBehaviorId(), BehaviorMessageBase::DefaultBehaviorId);
|
||||
ASSERT_EQ(updateAction.GetActionIndex(), 1);
|
||||
ASSERT_EQ(updateAction.GetActionContext().GetStripId(), 0);
|
||||
ASSERT_EQ(static_cast<uint32_t>(updateAction.GetActionContext().GetStateId()), 0);
|
||||
|
Loading…
Reference in New Issue
Block a user