mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
squash commits (#1479)
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user