Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(skymp5-server): handle non-object self in callPapyrusFunction #1752

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions skymp5-server/cpp/addon/ScampServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,14 @@ Napi::Value ScampServer::CallPapyrusFunction(const Napi::CallbackInfo& info)

auto& vm = partOne->worldState.GetPapyrusVm();
if (callType == "method") {
res = vm.CallMethod(static_cast<IGameObject*>(self), functionName.data(),
args);
if (self.GetType() == VarValue::Type::kType_Object) {
res = vm.CallMethod(static_cast<IGameObject*>(self),
functionName.data(), args);
} else {
throw std::runtime_error(
"Can't call Papyrus method on non-object self '" + self.ToString() +
"'");
}
} else if (callType == "global") {
res = vm.CallStatic(className, functionName, args);
} else {
Expand Down
Loading