fix: remove exception throwing from game threads
This commit is contained in:
@@ -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,
|
||||
@@ -51,13 +54,17 @@ namespace Interlude
|
||||
data.name,
|
||||
data.description,
|
||||
data.iconName
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user