fix: remove exception throwing from game threads
This commit is contained in:
parent
ee11faf0ce
commit
604ba8af9b
@ -12,7 +12,6 @@
|
|||||||
#include "Domain/Entities/ShieldItem.h"
|
#include "Domain/Entities/ShieldItem.h"
|
||||||
#include "Domain/DTO/ItemData.h"
|
#include "Domain/DTO/ItemData.h"
|
||||||
#include "../Helpers/EnchantHelper.h"
|
#include "../Helpers/EnchantHelper.h"
|
||||||
#include "Domain/Exceptions.h"
|
|
||||||
|
|
||||||
using namespace L2Bot::Domain;
|
using namespace L2Bot::Domain;
|
||||||
|
|
||||||
@ -23,13 +22,13 @@ namespace Interlude
|
|||||||
private:
|
private:
|
||||||
struct BaseData
|
struct BaseData
|
||||||
{
|
{
|
||||||
uint32_t objectId;
|
uint32_t objectId = 0;
|
||||||
uint32_t itemId;
|
uint32_t itemId = 0;
|
||||||
int32_t mana;
|
int32_t mana = 0;
|
||||||
std::wstring name;
|
std::wstring name = L"";
|
||||||
std::wstring iconName;
|
std::wstring iconName = L"";
|
||||||
std::wstring description;
|
std::wstring description = L"";
|
||||||
uint16_t weight;
|
uint16_t weight = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EtcData : public BaseData
|
struct EtcData : public BaseData
|
||||||
@ -94,7 +93,7 @@ namespace Interlude
|
|||||||
//FIXME during first start data may be undefined
|
//FIXME during first start data may be undefined
|
||||||
const auto data = GetItemData(itemInfo.itemId);
|
const auto data = GetItemData(itemInfo.itemId);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw RuntimeException(std::format(L"cannot load ItemData for item {}", itemInfo.itemId));
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (data->dataType)
|
switch (data->dataType)
|
||||||
@ -113,7 +112,7 @@ namespace Interlude
|
|||||||
//FIXME during first start data may be undefined
|
//FIXME during first start data may be undefined
|
||||||
const auto data = GetItemData(itemInfo.itemId);
|
const auto data = GetItemData(itemInfo.itemId);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw RuntimeException(std::format(L"cannot load ItemData for item {}", itemInfo.itemId));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (data->dataType)
|
switch (data->dataType)
|
||||||
@ -318,7 +317,7 @@ namespace Interlude
|
|||||||
{
|
{
|
||||||
const auto data = GetItemData(itemInfo.itemId);
|
const auto data = GetItemData(itemInfo.itemId);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw RuntimeException(std::format(L"cannot load ItemData for item {}", itemInfo.itemId));
|
return BaseData();
|
||||||
}
|
}
|
||||||
const auto nameEntry = m_FName.GetEntry(data->nameIndex);
|
const auto nameEntry = m_FName.GetEntry(data->nameIndex);
|
||||||
const auto iconEntry = m_FName.GetEntry(data->iconNameIndex);
|
const auto iconEntry = m_FName.GetEntry(data->iconNameIndex);
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "../GameStructs/FName.h"
|
#include "../GameStructs/FName.h"
|
||||||
#include "../../../Common/Common.h"
|
#include "../../../Common/Common.h"
|
||||||
#include "Domain/Entities/Skill.h"
|
#include "Domain/Entities/Skill.h"
|
||||||
#include "Domain/Exceptions.h"
|
|
||||||
|
|
||||||
using namespace L2Bot::Domain;
|
using namespace L2Bot::Domain;
|
||||||
|
|
||||||
@ -18,14 +17,14 @@ namespace Interlude
|
|||||||
private:
|
private:
|
||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
uint32_t skillId;
|
uint32_t skillId = 0;
|
||||||
uint8_t level;
|
uint8_t level = 0;
|
||||||
bool isActive;
|
bool isActive = false;
|
||||||
uint8_t cost;
|
uint8_t cost = 0;
|
||||||
int16_t range;
|
int16_t range = 0;
|
||||||
std::wstring name;
|
std::wstring name = L"";
|
||||||
std::wstring description;
|
std::wstring description = L"";
|
||||||
std::wstring iconName;
|
std::wstring iconName = L"";
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -42,6 +41,10 @@ namespace Interlude
|
|||||||
{
|
{
|
||||||
const auto& data = GetData(skillId, level, isActive);
|
const auto& data = GetData(skillId, level, isActive);
|
||||||
|
|
||||||
|
if (data.skillId == 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return std::make_shared<Entities::Skill>(
|
return std::make_shared<Entities::Skill>(
|
||||||
data.skillId,
|
data.skillId,
|
||||||
data.level,
|
data.level,
|
||||||
@ -51,13 +54,17 @@ namespace Interlude
|
|||||||
data.name,
|
data.name,
|
||||||
data.description,
|
data.description,
|
||||||
data.iconName
|
data.iconName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(std::shared_ptr<Entities::Skill>& skill, const uint32_t skillId, const uint32_t level, const uint32_t isActive) const
|
void Update(std::shared_ptr<Entities::Skill>& skill, const uint32_t skillId, const uint32_t level, const uint32_t isActive) const
|
||||||
{
|
{
|
||||||
const auto& data = GetData(skillId, level, isActive);
|
const auto& data = GetData(skillId, level, isActive);
|
||||||
|
|
||||||
|
if (data.skillId == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
skill->Update(
|
skill->Update(
|
||||||
data.level,
|
data.level,
|
||||||
data.isActive,
|
data.isActive,
|
||||||
@ -74,7 +81,7 @@ namespace Interlude
|
|||||||
{
|
{
|
||||||
const auto data = m_L2GameData.GetMSData(skillId, level);
|
const auto data = m_L2GameData.GetMSData(skillId, level);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
throw RuntimeException(std::format(L"cannot load MSData for skill {}", skillId));
|
return Data();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto iconEntry = m_FName.GetEntry(data->iconNameIndex);
|
const auto iconEntry = m_FName.GetEntry(data->iconNameIndex);
|
||||||
|
@ -121,7 +121,7 @@ namespace Interlude
|
|||||||
|
|
||||||
if (m_Items.find(data.objectId) == m_Items.end())
|
if (m_Items.find(data.objectId) == m_Items.end())
|
||||||
{
|
{
|
||||||
auto item = m_Factory.Create(data);
|
const auto item = m_Factory.Create(data);
|
||||||
if (item) {
|
if (item) {
|
||||||
m_Items[data.objectId] = item;
|
m_Items[data.objectId] = item;
|
||||||
}
|
}
|
||||||
@ -197,6 +197,7 @@ namespace Interlude
|
|||||||
Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::OnEndItemListEvent::name, [this](const Events::Event& evt) {
|
Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::OnEndItemListEvent::name, [this](const Events::Event& evt) {
|
||||||
OnEndItemList(evt);
|
OnEndItemList(evt);
|
||||||
});
|
});
|
||||||
|
m_NetworkHandler.RequestItemList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -120,11 +120,14 @@ namespace Interlude
|
|||||||
|
|
||||||
if (m_Skills.find(skillId) == m_Skills.end())
|
if (m_Skills.find(skillId) == m_Skills.end())
|
||||||
{
|
{
|
||||||
m_Skills[skillId] = m_Factory.Create(
|
const auto newSkill = m_Factory.Create(
|
||||||
skillInfo[2],
|
skillInfo[2],
|
||||||
skillInfo[1],
|
skillInfo[1],
|
||||||
skillInfo[0]
|
skillInfo[0]
|
||||||
);
|
);
|
||||||
|
if (newSkill) {
|
||||||
|
m_Skills[skillId] = newSkill;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user