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/DTO/ItemData.h"
|
||||
#include "../Helpers/EnchantHelper.h"
|
||||
#include "Domain/Exceptions.h"
|
||||
|
||||
using namespace L2Bot::Domain;
|
||||
|
||||
@ -23,13 +22,13 @@ namespace Interlude
|
||||
private:
|
||||
struct BaseData
|
||||
{
|
||||
uint32_t objectId;
|
||||
uint32_t itemId;
|
||||
int32_t mana;
|
||||
std::wstring name;
|
||||
std::wstring iconName;
|
||||
std::wstring description;
|
||||
uint16_t weight;
|
||||
uint32_t objectId = 0;
|
||||
uint32_t itemId = 0;
|
||||
int32_t mana = 0;
|
||||
std::wstring name = L"";
|
||||
std::wstring iconName = L"";
|
||||
std::wstring description = L"";
|
||||
uint16_t weight = 0;
|
||||
};
|
||||
|
||||
struct EtcData : public BaseData
|
||||
@ -94,7 +93,7 @@ namespace Interlude
|
||||
//FIXME during first start data may be undefined
|
||||
const auto data = GetItemData(itemInfo.itemId);
|
||||
if (!data) {
|
||||
throw RuntimeException(std::format(L"cannot load ItemData for item {}", itemInfo.itemId));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (data->dataType)
|
||||
@ -113,7 +112,7 @@ namespace Interlude
|
||||
//FIXME during first start data may be undefined
|
||||
const auto data = GetItemData(itemInfo.itemId);
|
||||
if (!data) {
|
||||
throw RuntimeException(std::format(L"cannot load ItemData for item {}", itemInfo.itemId));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (data->dataType)
|
||||
@ -318,7 +317,7 @@ namespace Interlude
|
||||
{
|
||||
const auto data = GetItemData(itemInfo.itemId);
|
||||
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 iconEntry = m_FName.GetEntry(data->iconNameIndex);
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "../GameStructs/FName.h"
|
||||
#include "../../../Common/Common.h"
|
||||
#include "Domain/Entities/Skill.h"
|
||||
#include "Domain/Exceptions.h"
|
||||
|
||||
using namespace L2Bot::Domain;
|
||||
|
||||
@ -18,14 +17,14 @@ namespace Interlude
|
||||
private:
|
||||
struct Data
|
||||
{
|
||||
uint32_t skillId;
|
||||
uint8_t level;
|
||||
bool isActive;
|
||||
uint8_t cost;
|
||||
int16_t range;
|
||||
std::wstring name;
|
||||
std::wstring description;
|
||||
std::wstring iconName;
|
||||
uint32_t skillId = 0;
|
||||
uint8_t level = 0;
|
||||
bool isActive = false;
|
||||
uint8_t cost = 0;
|
||||
int16_t range = 0;
|
||||
std::wstring name = L"";
|
||||
std::wstring description = L"";
|
||||
std::wstring iconName = L"";
|
||||
};
|
||||
|
||||
public:
|
||||
@ -42,6 +41,10 @@ namespace Interlude
|
||||
{
|
||||
const auto& data = GetData(skillId, level, isActive);
|
||||
|
||||
if (data.skillId == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<Entities::Skill>(
|
||||
data.skillId,
|
||||
data.level,
|
||||
@ -58,6 +61,10 @@ namespace Interlude
|
||||
{
|
||||
const auto& data = GetData(skillId, level, isActive);
|
||||
|
||||
if (data.skillId == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
skill->Update(
|
||||
data.level,
|
||||
data.isActive,
|
||||
@ -74,7 +81,7 @@ namespace Interlude
|
||||
{
|
||||
const auto data = m_L2GameData.GetMSData(skillId, level);
|
||||
if (!data) {
|
||||
throw RuntimeException(std::format(L"cannot load MSData for skill {}", skillId));
|
||||
return Data();
|
||||
}
|
||||
|
||||
const auto iconEntry = m_FName.GetEntry(data->iconNameIndex);
|
||||
|
@ -121,7 +121,7 @@ namespace Interlude
|
||||
|
||||
if (m_Items.find(data.objectId) == m_Items.end())
|
||||
{
|
||||
auto item = m_Factory.Create(data);
|
||||
const auto item = m_Factory.Create(data);
|
||||
if (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) {
|
||||
OnEndItemList(evt);
|
||||
});
|
||||
m_NetworkHandler.RequestItemList();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -120,11 +120,14 @@ namespace Interlude
|
||||
|
||||
if (m_Skills.find(skillId) == m_Skills.end())
|
||||
{
|
||||
m_Skills[skillId] = m_Factory.Create(
|
||||
const auto newSkill = m_Factory.Create(
|
||||
skillInfo[2],
|
||||
skillInfo[1],
|
||||
skillInfo[0]
|
||||
);
|
||||
if (newSkill) {
|
||||
m_Skills[skillId] = newSkill;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user