mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-16 12:28:08 +00:00
Changed how the TryParse function works (and also did some general cleanup along the way)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "dCommonVars.h"
|
||||
|
||||
BehaviorMessageBase::BehaviorMessageBase(AMFArrayValue* arguments) {
|
||||
behaviorId = GetBehaviorIdFromArgument(arguments);
|
||||
this->behaviorId = GetBehaviorIdFromArgument(arguments);
|
||||
}
|
||||
|
||||
int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) {
|
||||
@@ -13,12 +13,13 @@ int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments)
|
||||
auto* behaviorIDValue = arguments->Get<std::string>(key);
|
||||
|
||||
if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) {
|
||||
GeneralUtils::TryParse(behaviorIDValue->GetValue(), behaviorId);
|
||||
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 behaviorId;
|
||||
return this->behaviorId;
|
||||
}
|
||||
|
||||
int32_t BehaviorMessageBase::GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName) {
|
||||
|
Reference in New Issue
Block a user