CreatureLib/src/Battling/ScriptHandling/ScriptMacros.hpp

30 lines
3.1 KiB
C++
Raw Normal View History

#define HOOK(hookName, source, ...) \
{ \
auto aggregator = source->GetScriptIterator(); \
while (aggregator.HasNext()) { \
auto next = aggregator.GetNext(); \
if (next == nullptr) \
continue; \
2020-07-31 12:17:38 +00:00
try { \
next->hookName(__VA_ARGS__); \
} catch (const std::exception& e) { \
THROW_CREATURE("Exception running script hook '" #hookName "': " << e.what()) \
} \
} \
}
#define HOOK_LOCAL(hookName, source, ...) \
{ \
auto aggregator = source.GetScriptIterator(); \
while (aggregator.HasNext()) { \
auto next = aggregator.GetNext(); \
if (next == nullptr) \
continue; \
2020-07-31 12:17:38 +00:00
try { \
next->hookName(__VA_ARGS__); \
} catch (const std::exception& e) { \
THROW_CREATURE("Exception running script hook '" #hookName "': " << e.what()) \
} \
} \
}