mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
Further implement Property Behavior parsing (#936)
Further implements the ControlBehavior processing and adds preparations for cheat detection
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#include "AddActionMessage.h"
|
||||
|
||||
AddActionMessage::AddActionMessage(AMFArrayValue* arguments) {
|
||||
auto* actionIndexAmf = arguments->FindValue<AMFDoubleValue>("actionIndex");
|
||||
if (!actionIndexAmf) return;
|
||||
|
||||
actionIndex = static_cast<uint32_t>(actionIndexAmf->GetDoubleValue());
|
||||
|
||||
stripId = GetStripIDFromArgument(arguments);
|
||||
|
||||
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);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
#ifndef __ADDACTIONMESSAGE__H__
|
||||
#define __ADDACTIONMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class AddActionMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
AddActionMessage(AMFArrayValue* arguments);
|
||||
const uint32_t GetActionIndex() { return actionIndex; };
|
||||
const StripId GetStripId() { return stripId; };
|
||||
const BehaviorState GetStateId() { return stateId; };
|
||||
const std::string& GetType() { return type; };
|
||||
const std::string& GetValueParameterName() { return valueParameterName; };
|
||||
const std::string& GetValueParameterString() { return valueParameterString; };
|
||||
const double GetValueParameterDouble() { return valueParameterDouble; };
|
||||
const uint32_t GetBehaviorId() { return behaviorId; };
|
||||
private:
|
||||
uint32_t actionIndex;
|
||||
StripId stripId;
|
||||
BehaviorState stateId;
|
||||
std::string type;
|
||||
std::string valueParameterName;
|
||||
std::string valueParameterString;
|
||||
double valueParameterDouble;
|
||||
uint32_t behaviorId;
|
||||
};
|
||||
|
||||
#endif //!__ADDACTIONMESSAGE__H__
|
@@ -0,0 +1,13 @@
|
||||
#include "AddMessage.h"
|
||||
|
||||
AddMessage::AddMessage(AMFArrayValue* arguments) {
|
||||
behaviorId = GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
behaviorIndex = 0;
|
||||
auto* behaviorIndexValue = arguments->FindValue<AMFDoubleValue>("BehaviorIndex");
|
||||
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetDoubleValue());
|
||||
Game::logger->LogDebug("AddMessage", "bhId %i ndx %i", behaviorId, behaviorIndex);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
#ifndef __ADDMESSAGE__H__
|
||||
#define __ADDMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AddMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
AddMessage(AMFArrayValue* arguments);
|
||||
const uint32_t GetBehaviorIndex() { return behaviorIndex; };
|
||||
const uint32_t GetBehaviorId() { return behaviorId; };
|
||||
private:
|
||||
uint32_t behaviorId;
|
||||
uint32_t behaviorIndex;
|
||||
};
|
||||
|
||||
#endif //!__ADDMESSAGE__H__
|
@@ -0,0 +1,56 @@
|
||||
#include "AddStripMessage.h"
|
||||
|
||||
AddStripMessage::AddStripMessage(AMFArrayValue* arguments) {
|
||||
auto* strip = arguments->FindValue<AMFArrayValue>("strip");
|
||||
if (!strip) return;
|
||||
|
||||
auto* actions = strip->FindValue<AMFArrayValue>("actions");
|
||||
if (!actions) return;
|
||||
|
||||
auto* uiArray = arguments->FindValue<AMFArrayValue>("ui");
|
||||
if (!uiArray) return;
|
||||
|
||||
auto* xPositionValue = uiArray->FindValue<AMFDoubleValue>("x");
|
||||
if (!xPositionValue) return;
|
||||
|
||||
xPosition = xPositionValue->GetDoubleValue();
|
||||
|
||||
auto* yPositionValue = uiArray->FindValue<AMFDoubleValue>("y");
|
||||
if (!yPositionValue) return;
|
||||
|
||||
yPosition = yPositionValue->GetDoubleValue();
|
||||
|
||||
stripId = GetStripIDFromArgument(arguments);
|
||||
|
||||
stateId = GetBehaviorStateFromArgument(arguments);
|
||||
|
||||
behaviorId = GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
type = "";
|
||||
valueParameterName = "";
|
||||
valueParameterString = "";
|
||||
valueParameterDouble = 0.0;
|
||||
for (uint32_t position = 0; position < actions->GetDenseValueSize(); position++) {
|
||||
auto* actionAsArray = actions->GetValueAt<AMFArrayValue>(position);
|
||||
if (!actionAsArray) continue;
|
||||
|
||||
for (auto& typeValueMap : actionAsArray->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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Game::logger->LogDebug("AddStripMessage", "x %f y %f stpId %i sttId %i bhId %i t %s vpn %s vps %s vpd %f", xPosition, yPosition, stripId, stateId, behaviorId, type.c_str(), valueParameterName.c_str(), valueParameterString.c_str(), valueParameterDouble);
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
#ifndef __ADDSTRIPMESSAGE__H__
|
||||
#define __ADDSTRIPMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class AddStripMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
AddStripMessage(AMFArrayValue* arguments);
|
||||
const StripId GetStripId() { return stripId; };
|
||||
const BehaviorState GetStateId() { return stateId; };
|
||||
const std::string& GetType() { return type; };
|
||||
const std::string& GetValueParameterName() { return valueParameterName; };
|
||||
const std::string& GetValueParameterString() { return valueParameterString; };
|
||||
const double GetXPosition() { return xPosition; };
|
||||
const double GetYPosition() { return yPosition; };
|
||||
const double GetValueParameterDouble() { return valueParameterDouble; };
|
||||
const uint32_t GetBehaviorId() { return behaviorId; };
|
||||
private:
|
||||
double xPosition;
|
||||
double yPosition;
|
||||
StripId stripId;
|
||||
BehaviorState stateId;
|
||||
uint32_t behaviorId;
|
||||
std::string type;
|
||||
std::string valueParameterName;
|
||||
std::string valueParameterString;
|
||||
double valueParameterDouble;
|
||||
};
|
||||
|
||||
#endif //!__ADDSTRIPMESSAGE__H__
|
@@ -0,0 +1,48 @@
|
||||
#ifndef __BEHAVIORMESSAGEBASE__H__
|
||||
#define __BEHAVIORMESSAGEBASE__H__
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "BehaviorStates.h"
|
||||
#include "dCommonVars.h"
|
||||
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
class BehaviorMessageBase {
|
||||
public:
|
||||
uint32_t GetBehaviorIDFromArgument(AMFArrayValue* arguments, const std::string& key = "BehaviorID") {
|
||||
auto* behaviorIDValue = arguments->FindValue<AMFStringValue>(key);
|
||||
uint32_t behaviorID = -1;
|
||||
|
||||
if (behaviorIDValue) {
|
||||
behaviorID = std::stoul(behaviorIDValue->GetStringValue());
|
||||
} else if (arguments->FindValue<AMFUndefinedValue>(key) == nullptr) {
|
||||
throw std::invalid_argument("Unable to find behavior ID from argument \"" + key + "\"");
|
||||
}
|
||||
|
||||
return behaviorID;
|
||||
}
|
||||
|
||||
BehaviorState GetBehaviorStateFromArgument(AMFArrayValue* arguments, const std::string& key = "stateID") {
|
||||
auto* stateIDValue = arguments->FindValue<AMFDoubleValue>(key);
|
||||
if (!stateIDValue) throw std::invalid_argument("Unable to find behavior state from argument \"" + key + "\"");
|
||||
|
||||
BehaviorState stateID = static_cast<BehaviorState>(stateIDValue->GetDoubleValue());
|
||||
|
||||
return stateID;
|
||||
}
|
||||
|
||||
StripId GetStripIDFromArgument(AMFArrayValue* arguments, const std::string& key = "stripID") {
|
||||
auto* stripIDValue = arguments->FindValue<AMFDoubleValue>(key);
|
||||
if (!stripIDValue) throw std::invalid_argument("Unable to find strip ID from argument \"" + key + "\"");
|
||||
|
||||
StripId stripID = static_cast<StripId>(stripIDValue->GetDoubleValue());
|
||||
|
||||
return stripID;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //!__BEHAVIORMESSAGEBASE__H__
|
@@ -0,0 +1,16 @@
|
||||
set(DGAME_DPROPERTYBEHAVIORS_CONTROLBEHAVIORMESSAGES
|
||||
"AddActionMessage.cpp"
|
||||
"AddMessage.cpp"
|
||||
"AddStripMessage.cpp"
|
||||
"MergeStripsMessage.cpp"
|
||||
"MigrateActionsMessage.cpp"
|
||||
"MoveToInventoryMessage.cpp"
|
||||
"RearrangeStripMessage.cpp"
|
||||
"RemoveActionsMessage.cpp"
|
||||
"RemoveStripMessage.cpp"
|
||||
"RenameMessage.cpp"
|
||||
"SplitStripMessage.cpp"
|
||||
"UpdateActionMessage.cpp"
|
||||
"UpdateStripUiMessage.cpp"
|
||||
PARENT_SCOPE
|
||||
)
|
@@ -0,0 +1,20 @@
|
||||
#include "MergeStripsMessage.h"
|
||||
|
||||
MergeStripsMessage::MergeStripsMessage(AMFArrayValue* arguments) {
|
||||
srcStripID = GetStripIDFromArgument(arguments, "srcStripID");
|
||||
|
||||
dstStateID = GetBehaviorStateFromArgument(arguments, "dstStateID");
|
||||
|
||||
srcStateID = GetBehaviorStateFromArgument(arguments, "srcStateID");
|
||||
|
||||
auto* dstActionIndexValue = arguments->FindValue<AMFDoubleValue>("dstActionIndex");
|
||||
if (!dstActionIndexValue) return;
|
||||
|
||||
dstActionIndex = static_cast<uint32_t>(dstActionIndexValue->GetDoubleValue());
|
||||
|
||||
dstStripID = GetStripIDFromArgument(arguments, "dstStripID");
|
||||
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
Game::logger->LogDebug("MergeStripsMessage", "srcStpId %i dstStpId %i srcSttId %i dstSttId %i dstAcnNdx %i bhId %i", srcStripID, dstStripID, srcStateID, dstStateID, dstActionIndex, behaviorID);
|
||||
}
|
||||
|
@@ -0,0 +1,26 @@
|
||||
#ifndef __MERGESTRIPSMESSAGE__H__
|
||||
#define __MERGESTRIPSMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class MergeStripsMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
MergeStripsMessage(AMFArrayValue* arguments);
|
||||
const StripId GetSrcStripID() { return srcStripID; };
|
||||
const BehaviorState GetDstStateID() { return dstStateID; };
|
||||
const BehaviorState GetSrcStateID() { return srcStateID; };
|
||||
const uint32_t GetDstActionIndex() { return dstActionIndex; };
|
||||
const StripId GetDstStripID() { return dstStripID; };
|
||||
const uint32_t GetBehaviorID() { return behaviorID; };
|
||||
private:
|
||||
StripId srcStripID;
|
||||
BehaviorState dstStateID;
|
||||
BehaviorState srcStateID;
|
||||
uint32_t dstActionIndex;
|
||||
StripId dstStripID;
|
||||
uint32_t behaviorID;
|
||||
};
|
||||
|
||||
#endif //!__MERGESTRIPSMESSAGE__H__
|
@@ -0,0 +1,24 @@
|
||||
#include "MigrateActionsMessage.h"
|
||||
|
||||
MigrateActionsMessage::MigrateActionsMessage(AMFArrayValue* arguments) {
|
||||
auto* srcActionIndexAmf = arguments->FindValue<AMFDoubleValue>("srcActionIndex");
|
||||
if (!srcActionIndexAmf) return;
|
||||
|
||||
srcActionIndex = static_cast<uint32_t>(srcActionIndexAmf->GetDoubleValue());
|
||||
|
||||
srcStripID = GetStripIDFromArgument(arguments, "srcStripID");
|
||||
|
||||
srcStateID = GetBehaviorStateFromArgument(arguments, "srcStateID");
|
||||
|
||||
auto* dstActionIndexAmf = arguments->FindValue<AMFDoubleValue>("dstActionIndex");
|
||||
if (!dstActionIndexAmf) return;
|
||||
|
||||
dstActionIndex = static_cast<uint32_t>(dstActionIndexAmf->GetDoubleValue());
|
||||
|
||||
dstStripID = GetStripIDFromArgument(arguments, "dstStripID");
|
||||
|
||||
dstStateID = GetBehaviorStateFromArgument(arguments, "dstStateID");
|
||||
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
Game::logger->LogDebug("MigrateActionsMessage", "srcAcnNdx %i dstAcnNdx %i srcStpId %i dstStpId %i srcSttId %i dstSttId %i bhid %i", srcActionIndex, dstActionIndex, srcStripID, dstStripID, srcStateID, dstStateID, behaviorID);
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
#ifndef __MIGRATEACTIONSMESSAGE__H__
|
||||
#define __MIGRATEACTIONSMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class MigrateActionsMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
MigrateActionsMessage(AMFArrayValue* arguments);
|
||||
const uint32_t GetSrcActionIndex() { return srcActionIndex; };
|
||||
const StripId GetSrcStripID() { return srcStripID; };
|
||||
const BehaviorState GetSrcStateID() { return srcStateID; };
|
||||
const uint32_t GetDstActionIndex() { return dstActionIndex; };
|
||||
const StripId GetDstStripID() { return dstStripID; };
|
||||
const BehaviorState GetDstStateID() { return dstStateID; };
|
||||
const uint32_t GetBehaviorID() { return behaviorID; };
|
||||
private:
|
||||
uint32_t srcActionIndex;
|
||||
StripId srcStripID;
|
||||
BehaviorState srcStateID;
|
||||
uint32_t dstActionIndex;
|
||||
StripId dstStripID;
|
||||
BehaviorState dstStateID;
|
||||
uint32_t behaviorID;
|
||||
};
|
||||
|
||||
#endif //!__MIGRATEACTIONSMESSAGE__H__
|
@@ -0,0 +1,11 @@
|
||||
#include "MoveToInventoryMessage.h"
|
||||
|
||||
MoveToInventoryMessage::MoveToInventoryMessage(AMFArrayValue* arguments) {
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
auto* behaviorIndexValue = arguments->FindValue<AMFDoubleValue>("BehaviorIndex");
|
||||
if (!behaviorIndexValue) return;
|
||||
|
||||
behaviorIndex = static_cast<uint32_t>(behaviorIndexValue->GetDoubleValue());
|
||||
Game::logger->LogDebug("MoveToInventoryMessage", "bhId %i bhNdx %i", behaviorID, behaviorIndex);
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
#ifndef __MOVETOINVENTORYMESSAGE__H__
|
||||
#define __MOVETOINVENTORYMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
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(AMFArrayValue* arguments);
|
||||
const uint32_t GetBehaviorID() { return behaviorID; };
|
||||
const uint32_t GetBehaviorIndex() { return behaviorIndex; };
|
||||
private:
|
||||
uint32_t behaviorID;
|
||||
uint32_t behaviorIndex;
|
||||
};
|
||||
|
||||
#endif //!__MOVETOINVENTORYMESSAGE__H__
|
@@ -0,0 +1,16 @@
|
||||
#include "RearrangeStripMessage.h"
|
||||
|
||||
RearrangeStripMessage::RearrangeStripMessage(AMFArrayValue* arguments) {
|
||||
auto* srcActionIndexValue = arguments->FindValue<AMFDoubleValue>("srcActionIndex");
|
||||
srcActionIndex = static_cast<uint32_t>(srcActionIndexValue->GetDoubleValue());
|
||||
|
||||
stripID = GetStripIDFromArgument(arguments);
|
||||
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
auto* dstActionIndexValue = arguments->FindValue<AMFDoubleValue>("dstActionIndex");
|
||||
dstActionIndex = static_cast<uint32_t>(dstActionIndexValue->GetDoubleValue());
|
||||
|
||||
stateID = GetBehaviorStateFromArgument(arguments);
|
||||
Game::logger->LogDebug("RearrangeStripMessage", "srcAcnNdx %i dstAcnNdx %i stpId %i bhId %i sttId %i", srcActionIndex, dstActionIndex, stripID, behaviorID, stateID);
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
#ifndef __REARRANGESTRIPMESSAGE__H__
|
||||
#define __REARRANGESTRIPMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class RearrangeStripMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
RearrangeStripMessage(AMFArrayValue* arguments);
|
||||
const uint32_t GetSrcActionIndex() { return srcActionIndex; };
|
||||
const uint32_t GetStripID() { return stripID; };
|
||||
const uint32_t GetBehaviorID() { return behaviorID; };
|
||||
const uint32_t GetDstActionIndex() { return dstActionIndex; };
|
||||
const BehaviorState GetStateID() { return stateID; };
|
||||
private:
|
||||
uint32_t srcActionIndex;
|
||||
uint32_t stripID;
|
||||
uint32_t behaviorID;
|
||||
uint32_t dstActionIndex;
|
||||
BehaviorState stateID;
|
||||
};
|
||||
|
||||
#endif //!__REARRANGESTRIPMESSAGE__H__
|
@@ -0,0 +1,15 @@
|
||||
#include "RemoveActionsMessage.h"
|
||||
|
||||
RemoveActionsMessage::RemoveActionsMessage(AMFArrayValue* arguments) {
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
auto* actionIndexAmf = arguments->FindValue<AMFDoubleValue>("actionIndex");
|
||||
if (!actionIndexAmf) return;
|
||||
|
||||
actionIndex = static_cast<uint32_t>(actionIndexAmf->GetDoubleValue());
|
||||
|
||||
stripID = GetStripIDFromArgument(arguments);
|
||||
|
||||
stateID = GetBehaviorStateFromArgument(arguments);
|
||||
Game::logger->LogDebug("RemoveActionsMessage", "bhId %i acnNdx %i stpId %i sttId %i", behaviorID, actionIndex, stripID, stateID);
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
#ifndef __REMOVEACTIONSMESSAGE__H__
|
||||
#define __REMOVEACTIONSMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class RemoveActionsMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
RemoveActionsMessage(AMFArrayValue* arguments);
|
||||
const uint32_t GetBehaviorID() { return behaviorID; };
|
||||
const uint32_t GetActionIndex() { return actionIndex; };
|
||||
const StripId GetStripID() { return stripID; };
|
||||
const BehaviorState GetStateID() { return stateID; };
|
||||
private:
|
||||
uint32_t behaviorID;
|
||||
uint32_t actionIndex;
|
||||
StripId stripID;
|
||||
BehaviorState stateID;
|
||||
};
|
||||
|
||||
#endif //!__REMOVEACTIONSMESSAGE__H__
|
@@ -0,0 +1,8 @@
|
||||
#include "RemoveStripMessage.h"
|
||||
|
||||
RemoveStripMessage::RemoveStripMessage(AMFArrayValue* arguments) {
|
||||
stripId = GetStripIDFromArgument(arguments);
|
||||
behaviorState = GetBehaviorStateFromArgument(arguments);
|
||||
behaviorId = GetBehaviorIDFromArgument(arguments);
|
||||
Game::logger->LogDebug("RemoveStripMessage", "stpId %i bhStt %i bhId %i", stripId, behaviorState, behaviorId);
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
#ifndef __REMOVESTRIPMESSAGE__H__
|
||||
#define __REMOVESTRIPMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class RemoveStripMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
RemoveStripMessage(AMFArrayValue* arguments);
|
||||
const StripId GetStripId() { return stripId; };
|
||||
const BehaviorState GetBehaviorState() { return behaviorState; };
|
||||
const uint32_t GetBehaviorId() { return behaviorId; };
|
||||
private:
|
||||
StripId stripId;
|
||||
BehaviorState behaviorState;
|
||||
uint32_t behaviorId;
|
||||
};
|
||||
|
||||
#endif //!__REMOVESTRIPMESSAGE__H__
|
@@ -0,0 +1,11 @@
|
||||
#include "RenameMessage.h"
|
||||
|
||||
RenameMessage::RenameMessage(AMFArrayValue* arguments) {
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
auto* nameAmf = arguments->FindValue<AMFStringValue>("Name");
|
||||
if (!nameAmf) return;
|
||||
|
||||
name = nameAmf->GetStringValue();
|
||||
Game::logger->LogDebug("RenameMessage", "bhId %i n %s", behaviorID, name.c_str());
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
#ifndef __RENAMEMESSAGE__H__
|
||||
#define __RENAMEMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class RenameMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
RenameMessage(AMFArrayValue* arguments);
|
||||
const uint32_t GetBehaviorID() { return behaviorID; };
|
||||
const std::string& GetName() { return name; };
|
||||
private:
|
||||
uint32_t behaviorID;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
#endif //!__RENAMEMESSAGE__H__
|
@@ -0,0 +1,29 @@
|
||||
#include "SplitStripMessage.h"
|
||||
|
||||
SplitStripMessage::SplitStripMessage(AMFArrayValue* arguments) {
|
||||
auto* srcActionIndexValue = arguments->FindValue<AMFDoubleValue>("srcActionIndex");
|
||||
if (!srcActionIndexValue) return;
|
||||
|
||||
srcActionIndex = static_cast<uint32_t>(srcActionIndexValue->GetDoubleValue());
|
||||
|
||||
srcStripId = GetStripIDFromArgument(arguments, "srcStripID");
|
||||
|
||||
srcStateId = GetBehaviorStateFromArgument(arguments, "srcStateID");
|
||||
|
||||
dstStripId = GetStripIDFromArgument(arguments, "dstStripID");
|
||||
|
||||
dstStateId = GetBehaviorStateFromArgument(arguments, "dstStateID");
|
||||
|
||||
auto* dstStripUiArray = arguments->FindValue<AMFArrayValue>("dstStripUI");
|
||||
if (!dstStripUiArray) return;
|
||||
|
||||
auto* xPositionValue = dstStripUiArray->FindValue<AMFDoubleValue>("x");
|
||||
auto* yPositionValue = dstStripUiArray->FindValue<AMFDoubleValue>("y");
|
||||
if (!xPositionValue || !yPositionValue) return;
|
||||
|
||||
yPosition = yPositionValue->GetDoubleValue();
|
||||
xPosition = xPositionValue->GetDoubleValue();
|
||||
|
||||
behaviorId = GetBehaviorIDFromArgument(arguments);
|
||||
Game::logger->LogDebug("SplitStripMessage", "bhid %i x %f y %f srcStp %i dstStp %i srcStt %i dstStt %i srcActNdx %i", behaviorId, xPosition, yPosition, srcStripId, dstStripId, srcStateId, dstStateId, srcActionIndex);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
#ifndef __SPLITSTRIPMESSAGE__H__
|
||||
#define __SPLITSTRIPMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class SplitStripMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
SplitStripMessage(AMFArrayValue* arguments);
|
||||
const uint32_t GetSrcActionIndex() { return srcActionIndex; };
|
||||
const StripId GetSrcStripId() { return srcStripId; };
|
||||
const BehaviorState GetSrcStateId() { return srcStateId; };
|
||||
const StripId GetDstStripId() { return dstStripId; };
|
||||
const BehaviorState GetDstStateId() { return dstStateId; };
|
||||
const double GetYPosition() { return yPosition; };
|
||||
const double GetXPosition() { return xPosition; };
|
||||
const uint32_t GetBehaviorId() { return behaviorId; };
|
||||
private:
|
||||
uint32_t srcActionIndex;
|
||||
StripId srcStripId;
|
||||
BehaviorState srcStateId;
|
||||
StripId dstStripId;
|
||||
BehaviorState dstStateId;
|
||||
double yPosition;
|
||||
double xPosition;
|
||||
uint32_t behaviorId;
|
||||
};
|
||||
|
||||
#endif //!__SPLITSTRIPMESSAGE__H__
|
@@ -0,0 +1,38 @@
|
||||
#include "UpdateActionMessage.h"
|
||||
|
||||
UpdateActionMessage::UpdateActionMessage(AMFArrayValue* arguments) {
|
||||
type = "";
|
||||
valueParameterName = "";
|
||||
valueParameterString = "";
|
||||
valueParameterDouble = 0.0;
|
||||
auto* actionAsArray = arguments->FindValue<AMFArrayValue>("action");
|
||||
if (!actionAsArray) return;
|
||||
for (auto& typeValueMap : actionAsArray->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);
|
||||
|
||||
auto* actionIndexValue = arguments->FindValue<AMFDoubleValue>("actionIndex");
|
||||
if (!actionIndexValue) return;
|
||||
|
||||
actionIndex = static_cast<uint32_t>(actionIndexValue->GetDoubleValue());
|
||||
|
||||
stripID = GetStripIDFromArgument(arguments);
|
||||
|
||||
stateID = GetBehaviorStateFromArgument(arguments);
|
||||
Game::logger->LogDebug("UpdateActionMessage", "t %s vpn %s vps %s vpd %f bhId %i acnNdx %i stpId %i sttId %i", type.c_str(), valueParameterName.c_str(), valueParameterString.c_str(), valueParameterDouble, behaviorID, actionIndex, stripID, stateID);
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
#ifndef __UPDATEACTIONMESSAGE__H__
|
||||
#define __UPDATEACTIONMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class UpdateActionMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
UpdateActionMessage(AMFArrayValue* arguments);
|
||||
const std::string& GetType() { return type; };
|
||||
const std::string& GetValueParameterName() { return valueParameterName; };
|
||||
const std::string& GetValueParameterString() { return valueParameterString; };
|
||||
const double GetValueParameterDouble() { return valueParameterDouble; };
|
||||
const uint32_t GetBehaviorID() { return behaviorID; };
|
||||
const uint32_t GetActionIndex() { return actionIndex; };
|
||||
const StripId GetStripID() { return stripID; };
|
||||
const BehaviorState GetStateID() { return stateID; };
|
||||
private:
|
||||
std::string type;
|
||||
std::string valueParameterName;
|
||||
std::string valueParameterString;
|
||||
double valueParameterDouble;
|
||||
uint32_t behaviorID;
|
||||
uint32_t actionIndex;
|
||||
StripId stripID;
|
||||
BehaviorState stateID;
|
||||
};
|
||||
|
||||
#endif //!__UPDATEACTIONMESSAGE__H__
|
@@ -0,0 +1,20 @@
|
||||
#include "UpdateStripUiMessage.h"
|
||||
|
||||
UpdateStripUiMessage::UpdateStripUiMessage(AMFArrayValue* arguments) {
|
||||
auto* uiArray = arguments->FindValue<AMFArrayValue>("ui");
|
||||
if (!uiArray) return;
|
||||
|
||||
auto* xPositionValue = uiArray->FindValue<AMFDoubleValue>("x");
|
||||
auto* yPositionValue = uiArray->FindValue<AMFDoubleValue>("y");
|
||||
if (!xPositionValue || !yPositionValue) return;
|
||||
|
||||
yPosition = yPositionValue->GetDoubleValue();
|
||||
xPosition = xPositionValue->GetDoubleValue();
|
||||
|
||||
stripID = GetStripIDFromArgument(arguments);
|
||||
|
||||
stateID = GetBehaviorStateFromArgument(arguments);
|
||||
|
||||
behaviorID = GetBehaviorIDFromArgument(arguments);
|
||||
Game::logger->LogDebug("UpdateStripUIMessage", "x %f y %f stpId %i sttId %i bhId %i", xPosition, yPosition, stripID, stateID, behaviorID);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
#ifndef __UPDATESTRIPUIMESSAGE__H__
|
||||
#define __UPDATESTRIPUIMESSAGE__H__
|
||||
|
||||
#include "BehaviorMessageBase.h"
|
||||
|
||||
class AMFArrayValue;
|
||||
|
||||
class UpdateStripUiMessage : public BehaviorMessageBase {
|
||||
public:
|
||||
UpdateStripUiMessage(AMFArrayValue* arguments);
|
||||
const double GetYPosition() { return yPosition; };
|
||||
const double GetXPosition() { return xPosition; };
|
||||
const StripId GetStripID() { return stripID; };
|
||||
const BehaviorState GetStateID() { return stateID; };
|
||||
const uint32_t GetBehaviorID() { return behaviorID; };
|
||||
private:
|
||||
double yPosition;
|
||||
double xPosition;
|
||||
StripId stripID;
|
||||
BehaviorState stateID;
|
||||
uint32_t behaviorID;
|
||||
};
|
||||
|
||||
#endif //!__UPDATESTRIPUIMESSAGE__H__
|
Reference in New Issue
Block a user