Skip to content

Commit

Permalink
fix(skymp5-server): handle non-object self in callPapyrusFunction (#1752
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Pospelove authored Nov 30, 2023
1 parent 37003c6 commit c947f26
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit c947f26

Please sign in to comment.