diff --git a/client/src/helpers/NativeInvoker.cpp b/client/src/helpers/NativeInvoker.cpp index eb47e6517..b7f1cb0be 100644 --- a/client/src/helpers/NativeInvoker.cpp +++ b/client/src/helpers/NativeInvoker.cpp @@ -5,9 +5,7 @@ bool js::NativeInvoker::PushArgs(js::FunctionContext& ctx, alt::INative* native) { using Type = alt::INative::Type; - CJavaScriptResource* resource = ctx.GetResource(); std::vector nativeArgs = native->GetArgTypes(); - int args = ctx.GetArgCount(); for(size_t i = 0; i < nativeArgs.size(); i++) { @@ -103,7 +101,7 @@ v8::Local js::NativeInvoker::GetPointerReturnValue(alt::INative::Type return resource->CreateVector3({ vector->x, vector->y, vector->z }); } } - js::Logger::Warn("[JS] Unknown native pointer return type:", magic_enum::enum_name(type), (int)type); + // js::Logger::Warn("[JS] Unknown native pointer return type:", magic_enum::enum_name(type), (int)type); return v8::Undefined(resource->GetIsolate()); } @@ -170,10 +168,17 @@ bool js::NativeInvoker::Invoke(js::FunctionContext& ctx, alt::INative* native) // todo: maybe v2 should move away from this array shit js::Array arr{ invoker.returnsCount }; + invoker.pointersCount = 0; + // First element is always the return value arr.Push(invoker.GetReturnValue()); + // Then push the pointer arguments into the array - for(size_t i = 0; i < args.size(); i++) arr.Push(invoker.GetPointerReturnValue(args[i])); + for (auto& arg : args) + { + if (auto val = invoker.GetPointerReturnValue(arg); !val->IsUndefined()) + arr.Push(val); + } ctx.Return(arr); }