-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out BehaviorMessage class changes from PR #1452
- Loading branch information
Showing
46 changed files
with
366 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 13 additions & 25 deletions
38
dGame/dPropertyBehaviors/ControlBehaviorMessages/Action.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,34 @@ | ||
#include "Action.h" | ||
#include "Amf3.h" | ||
|
||
Action::Action() { | ||
type = ""; | ||
valueParameterName = ""; | ||
valueParameterString = ""; | ||
valueParameterDouble = 0.0; | ||
} | ||
|
||
Action::Action(AMFArrayValue* arguments) { | ||
type = ""; | ||
valueParameterName = ""; | ||
valueParameterString = ""; | ||
valueParameterDouble = 0.0; | ||
for (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; | ||
type = static_cast<AMFStringValue*>(paramValue)->GetValue(); | ||
m_Type = static_cast<AMFStringValue*>(paramValue)->GetValue(); | ||
} else { | ||
valueParameterName = paramName; | ||
m_ValueParameterName = paramName; | ||
// Message is the only known string parameter | ||
if (valueParameterName == "Message") { | ||
if (m_ValueParameterName == "Message") { | ||
if (paramValue->GetValueType() != eAmf::String) continue; | ||
valueParameterString = static_cast<AMFStringValue*>(paramValue)->GetValue(); | ||
m_ValueParameterString = static_cast<AMFStringValue*>(paramValue)->GetValue(); | ||
} else { | ||
if (paramValue->GetValueType() != eAmf::Double) continue; | ||
valueParameterDouble = static_cast<AMFDoubleValue*>(paramValue)->GetValue(); | ||
m_ValueParameterDouble = static_cast<AMFDoubleValue*>(paramValue)->GetValue(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void Action::SendBehaviorBlocksToClient(AMFArrayValue& args) const { | ||
auto* actionArgs = args.PushArray(); | ||
actionArgs->Insert("Type", type); | ||
auto* const actionArgs = args.PushArray(); | ||
actionArgs->Insert("Type", m_Type); | ||
|
||
auto valueParameterName = GetValueParameterName(); | ||
if (valueParameterName.empty()) return; | ||
if (m_ValueParameterName.empty()) return; | ||
|
||
if (valueParameterName == "Message") { | ||
actionArgs->Insert(valueParameterName, valueParameterString); | ||
if (m_ValueParameterName == "Message") { | ||
actionArgs->Insert(m_ValueParameterName, m_ValueParameterString); | ||
} else { | ||
actionArgs->Insert(valueParameterName, valueParameterDouble); | ||
actionArgs->Insert(m_ValueParameterName, m_ValueParameterDouble); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletions
13
dGame/dPropertyBehaviors/ControlBehaviorMessages/AddActionMessage.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
#include "AddActionMessage.h" | ||
|
||
AddActionMessage::AddActionMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { | ||
actionContext = ActionContext(arguments); | ||
actionIndex = GetActionIndexFromArgument(arguments); | ||
AddActionMessage::AddActionMessage(const AMFArrayValue* arguments) | ||
: BehaviorMessageBase{ arguments } | ||
, m_ActionIndex{ GetActionIndexFromArgument(arguments) } | ||
, m_ActionContext{ arguments } { | ||
|
||
auto* actionValue = arguments->GetArray("action"); | ||
const auto* const actionValue = arguments->GetArray("action"); | ||
if (!actionValue) return; | ||
|
||
action = Action(actionValue); | ||
m_Action = Action{ actionValue }; | ||
|
||
LOG_DEBUG("actionIndex %i stripId %i stateId %i type %s valueParameterName %s valueParameterString %s valueParameterDouble %f behaviorId %i", actionIndex, actionContext.GetStripId(), actionContext.GetStateId(), action.GetType().c_str(), action.GetValueParameterName().c_str(), action.GetValueParameterString().c_str(), action.GetValueParameterDouble(), behaviorId); | ||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
dGame/dPropertyBehaviors/ControlBehaviorMessages/AddMessage.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
#include "AddMessage.h" | ||
|
||
AddMessage::AddMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) { | ||
behaviorIndex = 0; | ||
auto* behaviorIndexValue = arguments->Get<double>("BehaviorIndex"); | ||
|
||
AddMessage::AddMessage(const AMFArrayValue* arguments) : BehaviorMessageBase{ arguments } { | ||
const auto* const behaviorIndexValue = arguments->Get<double>("BehaviorIndex"); | ||
if (!behaviorIndexValue) return; | ||
|
||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetValue()); | ||
LOG_DEBUG("behaviorId %i index %i", behaviorId, behaviorIndex); | ||
m_BehaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetValue()); | ||
LOG_DEBUG("behaviorId %i index %i", m_BehaviorId, m_BehaviorIndex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.