More work on exceptions.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
9c93ca6995
commit
bd7ecb6b33
|
@ -155,7 +155,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto& hit = hitIterator[hitIndex];
|
auto& hit = hitIterator[hitIndex];
|
||||||
uint8_t hitType = hit.GetType();
|
uint8_t hitType = attack->GetAttack()->GetAttack()->GetType();
|
||||||
HOOK(ChangeAttackType, targetSource, attack, target.GetRaw(), hitIndex, &hitType);
|
HOOK(ChangeAttackType, targetSource, attack, target.GetRaw(), hitIndex, &hitType);
|
||||||
hit.SetType(hitType);
|
hit.SetType(hitType);
|
||||||
auto effectiveness = library->GetTypeLibrary()->GetEffectiveness(hitType, target->GetTypes());
|
auto effectiveness = library->GetTypeLibrary()->GetEffectiveness(hitType, target->GetTypes());
|
||||||
|
|
|
@ -5,7 +5,11 @@
|
||||||
auto next = aggregator.GetNext(); \
|
auto next = aggregator.GetNext(); \
|
||||||
if (next == nullptr) \
|
if (next == nullptr) \
|
||||||
continue; \
|
continue; \
|
||||||
|
try { \
|
||||||
next->hookName(__VA_ARGS__); \
|
next->hookName(__VA_ARGS__); \
|
||||||
|
} catch (const std::exception& e) { \
|
||||||
|
THROW_CREATURE("Exception running script hook '" #hookName "': " << e.what()) \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +20,10 @@
|
||||||
auto next = aggregator.GetNext(); \
|
auto next = aggregator.GetNext(); \
|
||||||
if (next == nullptr) \
|
if (next == nullptr) \
|
||||||
continue; \
|
continue; \
|
||||||
|
try { \
|
||||||
next->hookName(__VA_ARGS__); \
|
next->hookName(__VA_ARGS__); \
|
||||||
|
} catch (const std::exception& e) { \
|
||||||
|
THROW_CREATURE("Exception running script hook '" #hookName "': " << e.what()) \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "Exceptions/CreatureException.hpp"
|
||||||
|
|
||||||
namespace CreatureLib::Library {
|
namespace CreatureLib::Library {
|
||||||
class TypeLibrary {
|
class TypeLibrary {
|
||||||
|
@ -19,7 +20,12 @@ namespace CreatureLib::Library {
|
||||||
inline uint8_t GetTypeId(const ArbUt::BasicStringView& key) const { return _types.Get(key); }
|
inline uint8_t GetTypeId(const ArbUt::BasicStringView& key) const { return _types.Get(key); }
|
||||||
inline uint8_t GetTypeId(uint32_t s) const { return _types.Get(s); }
|
inline uint8_t GetTypeId(uint32_t s) const { return _types.Get(s); }
|
||||||
[[nodiscard]] inline float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const {
|
[[nodiscard]] inline float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const {
|
||||||
|
try {
|
||||||
return _effectiveness[attacking][defensive];
|
return _effectiveness[attacking][defensive];
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
THROW_CREATURE("Unknown type indices were requested for effectiveness: "
|
||||||
|
<< (uint32_t)attacking << " and " << (uint32_t)defensive);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[[nodiscard]] inline float GetEffectiveness(uint8_t attacking,
|
[[nodiscard]] inline float GetEffectiveness(uint8_t attacking,
|
||||||
const std::unordered_set<uint8_t>& defensive) const {
|
const std::unordered_set<uint8_t>& defensive) const {
|
||||||
|
|
Loading…
Reference in New Issue