mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
chore: Remove new
s in Behavior members (#1504)
* Remove news in behavior members Tested that GrowingFlowers still have their SkillEvent fired with the correct parameters, gftikitorch works, sharks eating stinky fish still work * explicitly default move assignment and copy operators/constructors --------- Co-authored-by: jadebenn <jadebenn@users.noreply.github.com>
This commit is contained in:
parent
3a4e554da9
commit
3262bc3a86
@ -335,27 +335,23 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
|||||||
|
|
||||||
const auto typeString = GeneralUtils::UTF16ToWTF8(type);
|
const auto typeString = GeneralUtils::UTF16ToWTF8(type);
|
||||||
|
|
||||||
if (m_effectNames == nullptr) {
|
const auto itr = m_effectNames.find(typeString);
|
||||||
m_effectNames = new std::unordered_map<std::string, std::string>();
|
|
||||||
} else {
|
|
||||||
const auto pair = m_effectNames->find(typeString);
|
|
||||||
|
|
||||||
if (type.empty()) {
|
if (type.empty()) {
|
||||||
type = GeneralUtils::ASCIIToUTF16(*m_effectType);
|
type = GeneralUtils::ASCIIToUTF16(m_effectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pair != m_effectNames->end()) {
|
if (itr != m_effectNames.end()) {
|
||||||
if (renderComponent == nullptr) {
|
if (renderComponent == nullptr) {
|
||||||
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, pair->second, secondary, 1, 1, true);
|
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, itr->second, secondary, 1, 1, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderComponent->PlayEffect(effectId, type, pair->second, secondary);
|
renderComponent->PlayEffect(effectId, type, itr->second, secondary);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// The SQlite result object becomes invalid if the query object leaves scope.
|
// The SQlite result object becomes invalid if the query object leaves scope.
|
||||||
// So both queries are defined before the if statement
|
// So both queries are defined before the if statement
|
||||||
@ -388,12 +384,12 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
|||||||
|
|
||||||
type = GeneralUtils::ASCIIToUTF16(typeResult);
|
type = GeneralUtils::ASCIIToUTF16(typeResult);
|
||||||
|
|
||||||
m_effectType = new std::string(typeResult);
|
m_effectType = typeResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.finalize();
|
result.finalize();
|
||||||
|
|
||||||
m_effectNames->insert_or_assign(typeString, name);
|
m_effectNames.insert_or_assign(typeString, name);
|
||||||
|
|
||||||
if (renderComponent == nullptr) {
|
if (renderComponent == nullptr) {
|
||||||
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, name, secondary, 1, 1, true);
|
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, name, secondary, 1, 1, true);
|
||||||
@ -423,7 +419,6 @@ Behavior::Behavior(const uint32_t behaviorId) {
|
|||||||
|
|
||||||
if (behaviorId == 0) {
|
if (behaviorId == 0) {
|
||||||
this->m_effectId = 0;
|
this->m_effectId = 0;
|
||||||
this->m_effectHandle = nullptr;
|
|
||||||
this->m_templateId = BehaviorTemplates::BEHAVIOR_EMPTY;
|
this->m_templateId = BehaviorTemplates::BEHAVIOR_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +427,6 @@ Behavior::Behavior(const uint32_t behaviorId) {
|
|||||||
LOG("Failed to load behavior with id (%i)!", behaviorId);
|
LOG("Failed to load behavior with id (%i)!", behaviorId);
|
||||||
|
|
||||||
this->m_effectId = 0;
|
this->m_effectId = 0;
|
||||||
this->m_effectHandle = nullptr;
|
|
||||||
this->m_templateId = BehaviorTemplates::BEHAVIOR_EMPTY;
|
this->m_templateId = BehaviorTemplates::BEHAVIOR_EMPTY;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -442,7 +436,7 @@ Behavior::Behavior(const uint32_t behaviorId) {
|
|||||||
|
|
||||||
this->m_effectId = templateInDatabase.effectID;
|
this->m_effectId = templateInDatabase.effectID;
|
||||||
|
|
||||||
this->m_effectHandle = *templateInDatabase.effectHandle != "" ? new std::string(*templateInDatabase.effectHandle) : nullptr;
|
this->m_effectHandle = *templateInDatabase.effectHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -507,9 +501,3 @@ void Behavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream,
|
|||||||
|
|
||||||
void Behavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
void Behavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior::~Behavior() {
|
|
||||||
delete m_effectNames;
|
|
||||||
delete m_effectType;
|
|
||||||
delete m_effectHandle;
|
|
||||||
}
|
|
||||||
|
@ -41,9 +41,9 @@ public:
|
|||||||
uint32_t m_behaviorId;
|
uint32_t m_behaviorId;
|
||||||
BehaviorTemplates m_templateId;
|
BehaviorTemplates m_templateId;
|
||||||
uint32_t m_effectId;
|
uint32_t m_effectId;
|
||||||
std::string* m_effectHandle = nullptr;
|
std::string m_effectHandle;
|
||||||
std::unordered_map<std::string, std::string>* m_effectNames = nullptr;
|
std::unordered_map<std::string, std::string> m_effectNames;
|
||||||
std::string* m_effectType = nullptr;
|
std::string m_effectType;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Behavior parameters
|
* Behavior parameters
|
||||||
@ -88,5 +88,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
explicit Behavior(uint32_t behaviorId);
|
explicit Behavior(uint32_t behaviorId);
|
||||||
virtual ~Behavior();
|
virtual ~Behavior() = default;
|
||||||
|
|
||||||
|
Behavior(const Behavior& other) = default;
|
||||||
|
Behavior(Behavior&& other) = default;
|
||||||
|
|
||||||
|
Behavior& operator=(const Behavior& other) = default;
|
||||||
|
Behavior& operator=(Behavior&& other) = default;
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,16 @@ void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit
|
|||||||
auto* target = Game::entityManager->GetEntity(branch.target);
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
||||||
auto* caster = Game::entityManager->GetEntity(context->originator);
|
auto* caster = Game::entityManager->GetEntity(context->originator);
|
||||||
|
|
||||||
if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) {
|
if (caster != nullptr && target != nullptr && !this->m_effectHandle.empty()) {
|
||||||
target->GetScript()->OnSkillEventFired(target, caster, *this->m_effectHandle);
|
target->GetScript()->OnSkillEventFired(target, caster, this->m_effectHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
||||||
SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
|
||||||
auto* target = Game::entityManager->GetEntity(branch.target);
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
||||||
auto* caster = Game::entityManager->GetEntity(context->originator);
|
auto* caster = Game::entityManager->GetEntity(context->originator);
|
||||||
|
|
||||||
if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) {
|
if (caster != nullptr && target != nullptr && !this->m_effectHandle.empty()) {
|
||||||
target->GetScript()->OnSkillEventFired(target, caster, *this->m_effectHandle);
|
target->GetScript()->OnSkillEventFired(target, caster, this->m_effectHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user