mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 01:38:20 +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,26 +335,22 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
||||
|
||||
const auto typeString = GeneralUtils::UTF16ToWTF8(type);
|
||||
|
||||
if (m_effectNames == nullptr) {
|
||||
m_effectNames = new std::unordered_map<std::string, std::string>();
|
||||
} else {
|
||||
const auto pair = m_effectNames->find(typeString);
|
||||
const auto itr = m_effectNames.find(typeString);
|
||||
|
||||
if (type.empty()) {
|
||||
type = GeneralUtils::ASCIIToUTF16(*m_effectType);
|
||||
}
|
||||
if (type.empty()) {
|
||||
type = GeneralUtils::ASCIIToUTF16(m_effectType);
|
||||
}
|
||||
|
||||
if (pair != m_effectNames->end()) {
|
||||
if (renderComponent == nullptr) {
|
||||
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, pair->second, secondary, 1, 1, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
renderComponent->PlayEffect(effectId, type, pair->second, secondary);
|
||||
if (itr != m_effectNames.end()) {
|
||||
if (renderComponent == nullptr) {
|
||||
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, itr->second, secondary, 1, 1, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
renderComponent->PlayEffect(effectId, type, itr->second, secondary);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// The SQlite result object becomes invalid if the query object leaves scope.
|
||||
@ -388,12 +384,12 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
||||
|
||||
type = GeneralUtils::ASCIIToUTF16(typeResult);
|
||||
|
||||
m_effectType = new std::string(typeResult);
|
||||
m_effectType = typeResult;
|
||||
}
|
||||
|
||||
result.finalize();
|
||||
|
||||
m_effectNames->insert_or_assign(typeString, name);
|
||||
m_effectNames.insert_or_assign(typeString, name);
|
||||
|
||||
if (renderComponent == nullptr) {
|
||||
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, name, secondary, 1, 1, true);
|
||||
@ -423,7 +419,6 @@ Behavior::Behavior(const uint32_t behaviorId) {
|
||||
|
||||
if (behaviorId == 0) {
|
||||
this->m_effectId = 0;
|
||||
this->m_effectHandle = nullptr;
|
||||
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);
|
||||
|
||||
this->m_effectId = 0;
|
||||
this->m_effectHandle = nullptr;
|
||||
this->m_templateId = BehaviorTemplates::BEHAVIOR_EMPTY;
|
||||
|
||||
return;
|
||||
@ -442,7 +436,7 @@ Behavior::Behavior(const uint32_t behaviorId) {
|
||||
|
||||
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) {
|
||||
}
|
||||
|
||||
Behavior::~Behavior() {
|
||||
delete m_effectNames;
|
||||
delete m_effectType;
|
||||
delete m_effectHandle;
|
||||
}
|
||||
|
@ -41,9 +41,9 @@ public:
|
||||
uint32_t m_behaviorId;
|
||||
BehaviorTemplates m_templateId;
|
||||
uint32_t m_effectId;
|
||||
std::string* m_effectHandle = nullptr;
|
||||
std::unordered_map<std::string, std::string>* m_effectNames = nullptr;
|
||||
std::string* m_effectType = nullptr;
|
||||
std::string m_effectHandle;
|
||||
std::unordered_map<std::string, std::string> m_effectNames;
|
||||
std::string m_effectType;
|
||||
|
||||
/*
|
||||
* Behavior parameters
|
||||
@ -88,5 +88,11 @@ public:
|
||||
*/
|
||||
|
||||
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* caster = Game::entityManager->GetEntity(context->originator);
|
||||
|
||||
if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) {
|
||||
target->GetScript()->OnSkillEventFired(target, caster, *this->m_effectHandle);
|
||||
if (caster != nullptr && target != nullptr && !this->m_effectHandle.empty()) {
|
||||
target->GetScript()->OnSkillEventFired(target, caster, this->m_effectHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
||||
void SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
||||
auto* target = Game::entityManager->GetEntity(branch.target);
|
||||
auto* caster = Game::entityManager->GetEntity(context->originator);
|
||||
|
||||
if (caster != nullptr && target != nullptr && this->m_effectHandle != nullptr && !this->m_effectHandle->empty()) {
|
||||
target->GetScript()->OnSkillEventFired(target, caster, *this->m_effectHandle);
|
||||
if (caster != nullptr && target != nullptr && !this->m_effectHandle.empty()) {
|
||||
target->GetScript()->OnSkillEventFired(target, caster, this->m_effectHandle);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user