mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-10 10:18:21 +00:00
0c1ee0513d
* Changed how the TryParse function works (and also did some general cleanup along the way) * Update noexcept attributes (verified these are correct) * Add fp overload for MacOS functionality * resolving some feedback * Split out unrelated changes to CleanupRoundup branch * Update in response to feedback * the consequences of emo's member variable renaming request * Revert "the consequences of emo's member variable renaming request" This reverts commitbf318caeda
. * Fully revert renaming attempt * Revert "the consequences of emo's member variable renaming request" This reverts commitbf318caeda
. Fully revert renaming attempt * Created ClientVersion.h and moved the client version defaults to it * Fix partial parsing and MacOS floating point errors * attempting fix to MacOS compiler error * syntax pass (should be the last commit unless the CI fails) * ah, wait, forgot to uncomment the preprocessor statements for MacOS. THIS should be the last commit pending CI * Okay, one last thing I noticed: We were including C headers here. Now they're C++ headers. Pinky swear this is it! * typo and I am OCD. please let this be the last * hash is usally but not always noexcept, so the specifier should go * Address MOST of the feedback * address the claim codes issue
33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
#include "BehaviorMessageBase.h"
|
|
|
|
#include "Amf3.h"
|
|
#include "BehaviorStates.h"
|
|
#include "dCommonVars.h"
|
|
|
|
BehaviorMessageBase::BehaviorMessageBase(AMFArrayValue* arguments) {
|
|
this->behaviorId = GetBehaviorIdFromArgument(arguments);
|
|
}
|
|
|
|
int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) {
|
|
const auto* key = "BehaviorID";
|
|
auto* behaviorIDValue = arguments->Get<std::string>(key);
|
|
|
|
if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) {
|
|
this->behaviorId =
|
|
GeneralUtils::TryParse<int32_t>(behaviorIDValue->GetValue()).value_or(this->behaviorId);
|
|
} else if (arguments->Get(key) && arguments->Get(key)->GetValueType() != eAmf::Undefined) {
|
|
throw std::invalid_argument("Unable to find behavior ID");
|
|
}
|
|
|
|
return this->behaviorId;
|
|
}
|
|
|
|
int32_t BehaviorMessageBase::GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName) {
|
|
auto* actionIndexAmf = arguments->Get<double>(keyName);
|
|
if (!actionIndexAmf) {
|
|
throw std::invalid_argument("Unable to find actionIndex");
|
|
}
|
|
|
|
return static_cast<int32_t>(actionIndexAmf->GetValue());
|
|
}
|