mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
Make ControlBehavior messages far more modular (#991)
* Make case consistent * How modular can you go? Holy modular * Add comments * Initialize values
This commit is contained in:
@@ -1,39 +1,13 @@
|
||||
#include "AddActionMessage.h"
|
||||
|
||||
AddActionMessage::AddActionMessage(AMFArrayValue* arguments) {
|
||||
auto* actionIndexAmf = arguments->FindValue<AMFDoubleValue>("actionIndex");
|
||||
if (!actionIndexAmf) return;
|
||||
AddActionMessage::AddActionMessage(AMFArrayValue* arguments) : BehaviorMessageBase(arguments) {
|
||||
actionContext = ActionContext(arguments);
|
||||
actionIndex = GetActionIndexFromArgument(arguments);
|
||||
|
||||
actionIndex = static_cast<uint32_t>(actionIndexAmf->GetDoubleValue());
|
||||
auto* actionValue = arguments->FindValue<AMFArrayValue>("action");
|
||||
if (!actionValue) return;
|
||||
|
||||
stripId = GetStripIDFromArgument(arguments);
|
||||
action = Action(actionValue);
|
||||
|
||||
stateId = GetBehaviorStateFromArgument(arguments);
|
||||
|
||||
type = "";
|
||||
valueParameterName = "";
|
||||
valueParameterString = "";
|
||||
valueParameterDouble = 0.0;
|
||||
auto* action = arguments->FindValue<AMFArrayValue>("action");
|
||||
if (!action) return;
|
||||
|
||||
for (auto& typeValueMap : action->GetAssociativeMap()) {
|
||||
if (typeValueMap.first == "Type") {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue;
|
||||
type = static_cast<AMFStringValue*>(typeValueMap.second)->GetStringValue();
|
||||
} else {
|
||||
valueParameterName = typeValueMap.first;
|
||||
// Message is the only known string parameter
|
||||
if (valueParameterName == "Message") {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFString) continue;
|
||||
valueParameterString = static_cast<AMFStringValue*>(typeValueMap.second)->GetStringValue();
|
||||
} else {
|
||||
if (typeValueMap.second->GetValueType() != AMFValueType::AMFDouble) continue;
|
||||
valueParameterDouble = static_cast<AMFDoubleValue*>(typeValueMap.second)->GetDoubleValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
behaviorId = GetBehaviorIDFromArgument(arguments);
|
||||
Game::logger->LogDebug("AddActionMessage", "acnNdx %i stpId %i sttId %i t %s vpn %s vps %s vpd %f bhId %i", actionIndex, stripId, stateId, type.c_str(), valueParameterName.c_str(), valueParameterString.c_str(), valueParameterDouble, behaviorId);
|
||||
Game::logger->LogDebug("AddActionMessage", "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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user