From 823241ef32795ab5a538259254f60610a88dec85 Mon Sep 17 00:00:00 2001 From: k0t9i Date: Wed, 1 Feb 2023 00:15:20 +0400 Subject: [PATCH] fix: update all skill on skill created event --- L2BotCore/Domain/Entities/Skill.h | 18 ++++++++++++------ .../Interlude/Repositories/SkillRepository.h | 13 ++++++------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/L2BotCore/Domain/Entities/Skill.h b/L2BotCore/Domain/Entities/Skill.h index f09d89c..bdf1d3c 100644 --- a/L2BotCore/Domain/Entities/Skill.h +++ b/L2BotCore/Domain/Entities/Skill.h @@ -34,10 +34,6 @@ namespace L2Bot::Domain::Entities { m_IsToggled = isToggled; } - void UpdateLevel(const uint8_t level) - { - m_Level = level; - } void Update(const EntityInterface* other) override { @@ -60,6 +56,8 @@ namespace L2Bot::Domain::Entities { m_PrevState = { + m_Name, + m_IconName, m_Cost, m_Range, m_Description, @@ -96,10 +94,16 @@ namespace L2Bot::Domain::Entities if (m_PrevState.isNewState) { result.push_back({ L"isActive", std::to_wstring(m_IsActive) }); - result.push_back({ L"name", m_Name }); - result.push_back({ L"iconName", m_IconName }); } + if (m_PrevState.isNewState || m_Name != m_PrevState.name) + { + result.push_back({ L"name", m_Name }); + } + if (m_PrevState.isNewState || m_IconName != m_PrevState.iconName) + { + result.push_back({ L"iconName", m_IconName }); + } if (m_PrevState.isNewState || m_Description != m_PrevState.description) { result.push_back({ L"description", m_Description }); @@ -181,6 +185,8 @@ namespace L2Bot::Domain::Entities private: struct GetState { + std::wstring name = L""; + std::wstring iconName = L""; uint8_t cost = 0; int16_t range = 0; std::wstring description = L""; diff --git a/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h b/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h index 09a18f3..1bfed65 100644 --- a/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h @@ -134,19 +134,18 @@ namespace Interlude const auto skillInfo = casted.GetSkillInfo(); const auto skillId = skillInfo[2]; + auto skill = m_Factory.Create( + skillInfo[2], + skillInfo[1], + skillInfo[0] + ); if (m_Skills.find(skillId) == m_Skills.end()) { - auto skill = m_Factory.Create( - skillInfo[2], - skillInfo[1], - skillInfo[0] - ); - m_Skills.emplace(skill->GetId(), std::move(skill)); } else { - m_Skills[skillId]->UpdateLevel(skillInfo[1]); + m_Skills[skillId] = std::move(skill); } m_NewSkills[skillId] = skillId; }