Initial support for item use scripts in angelscript.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,46 +1,14 @@
|
||||
#include "AngelScriptScript.hpp"
|
||||
#include "AngelScriptFunctionCall.hpp"
|
||||
#include "AngelScriptResolver.hpp"
|
||||
|
||||
#define CALL_HOOK(name, setup) \
|
||||
auto s = _type->Get##name(); \
|
||||
if (!s.Exists) \
|
||||
return; \
|
||||
auto ctx = asGetActiveContext(); \
|
||||
bool newContext = false; \
|
||||
if (ctx == nullptr) { \
|
||||
ctx = _ctxPool->RequestContext(); \
|
||||
newContext = true; \
|
||||
} else { \
|
||||
ctx->PushState(); \
|
||||
} \
|
||||
ctx->Prepare(s.Function); \
|
||||
ctx->SetObject(_obj); \
|
||||
setup; \
|
||||
auto scriptResult = ctx->Execute(); \
|
||||
if (scriptResult != asEXECUTION_FINISHED) { \
|
||||
if (scriptResult == asEXECUTION_EXCEPTION) { \
|
||||
std::stringstream err; \
|
||||
err << "Script exception in script '" << GetName().c_str() << "', line " << ctx->GetExceptionLineNumber() \
|
||||
<< ". Message: '" << ctx->GetExceptionString() << "'."; \
|
||||
if (newContext) { \
|
||||
_ctxPool->ReturnContextToPool(ctx); \
|
||||
} else { \
|
||||
ctx->PopState(); \
|
||||
} \
|
||||
throw ArbUt::Exception(err.str()); \
|
||||
} \
|
||||
if (newContext) { \
|
||||
_ctxPool->ReturnContextToPool(ctx); \
|
||||
} else { \
|
||||
ctx->PopState(); \
|
||||
} \
|
||||
THROW("Script didn't finish properly; message " << scriptResult); \
|
||||
} \
|
||||
if (newContext) { \
|
||||
_ctxPool->ReturnContextToPool(ctx); \
|
||||
} else { \
|
||||
ctx->PopState(); \
|
||||
}
|
||||
AngelScriptUtils::AngelscriptFunctionCall( \
|
||||
s.Function, _ctxPool, _obj, GetName(), [&]([[maybe_unused]] asIScriptContext* ctx) { setup }, \
|
||||
[&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||
|
||||
CScriptArray* AngelScriptScript::GetEffectParameters(const ArbUt::List<CreatureLib::Library::EffectParameter*>& ls) {
|
||||
asITypeInfo* t = _resolver->GetBaseType("array<EffectParameter@>"_cnc);
|
||||
|
||||
Reference in New Issue
Block a user