mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
refactor: Rewrite BehaviorMessage classes to use member initialization, preferred member naming conventions, and const-ref getters (#1456)
* Split out BehaviorMessage class changes from PR #1452 * remove <string_view> inclusion in ActionContext.h * add the arguments nullptr check back in * remove redundant std::string constructor calls * Update AddStripMessage.cpp - change push_back to emplace_back
This commit is contained in:
@@ -2,27 +2,22 @@
|
||||
|
||||
#include "Amf3.h"
|
||||
|
||||
StripUiPosition::StripUiPosition() {
|
||||
xPosition = 0.0;
|
||||
yPosition = 0.0;
|
||||
}
|
||||
|
||||
StripUiPosition::StripUiPosition(AMFArrayValue* arguments, std::string uiKeyName) {
|
||||
xPosition = 0.0;
|
||||
yPosition = 0.0;
|
||||
auto* uiArray = arguments->GetArray(uiKeyName);
|
||||
StripUiPosition::StripUiPosition(const AMFArrayValue* arguments, const std::string& uiKeyName) {
|
||||
const auto* const uiArray = arguments->GetArray(uiKeyName);
|
||||
if (!uiArray) return;
|
||||
|
||||
auto* xPositionValue = uiArray->Get<double>("x");
|
||||
auto* yPositionValue = uiArray->Get<double>("y");
|
||||
if (!xPositionValue || !yPositionValue) return;
|
||||
const auto* const xPositionValue = uiArray->Get<double>("x");
|
||||
if (!xPositionValue) return;
|
||||
|
||||
yPosition = yPositionValue->GetValue();
|
||||
xPosition = xPositionValue->GetValue();
|
||||
const auto* const yPositionValue = uiArray->Get<double>("y");
|
||||
if (!yPositionValue) return;
|
||||
|
||||
m_YPosition = yPositionValue->GetValue();
|
||||
m_XPosition = xPositionValue->GetValue();
|
||||
}
|
||||
|
||||
void StripUiPosition::SendBehaviorBlocksToClient(AMFArrayValue& args) const {
|
||||
auto* uiArgs = args.InsertArray("ui");
|
||||
uiArgs->Insert("x", xPosition);
|
||||
uiArgs->Insert("y", yPosition);
|
||||
auto* const uiArgs = args.InsertArray("ui");
|
||||
uiArgs->Insert("x", m_XPosition);
|
||||
uiArgs->Insert("y", m_YPosition);
|
||||
}
|
||||
|
Reference in New Issue
Block a user