Skip to content

Commit

Permalink
fix(skymp5-server): fix ObjectReference.Disable/Enable Papyrus natives (
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove authored Feb 3, 2024
1 parent 9abee52 commit ccc4e02
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void MpObjectReference::Disable()
EditChangeForm(
[&](MpChangeFormREFR& changeForm) { changeForm.isDisabled = true; });

if (!IsEspmForm()) {
if (!IsEspmForm() || dynamic_cast<MpActor*>(this)) {
RemoveFromGridAndUnsubscribeAll();
}
}
Expand All @@ -403,7 +403,7 @@ void MpObjectReference::Enable()
EditChangeForm(
[&](MpChangeFormREFR& changeForm) { changeForm.isDisabled = false; });

if (!IsEspmForm()) {
if (!IsEspmForm() || dynamic_cast<MpActor*>(this)) {
ForceSubscriptionsUpdate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,20 @@ VarValue PapyrusObjectReference::Enable(VarValue self,
if (selfRefr) {
selfRefr->Enable();
}

if (selfRefr->IsEspmForm() && !dynamic_cast<MpActor*>(selfRefr)) {
auto funcName = "Enable";
auto serializedArgs = SpSnippetFunctionGen::SerializeArguments(arguments);
for (auto listener : selfRefr->GetListeners()) {
auto targetRefr = dynamic_cast<MpActor*>(listener);
if (targetRefr) {
SpSnippet(GetName(), funcName, serializedArgs.data(),
selfRefr->GetFormId())
.Execute(targetRefr);
}
}
}

return VarValue::None();
}

Expand All @@ -415,6 +429,20 @@ VarValue PapyrusObjectReference::Disable(
if (selfRefr) {
selfRefr->Disable();
}

if (selfRefr->IsEspmForm() && !dynamic_cast<MpActor*>(selfRefr)) {
auto funcName = "Disable";
auto serializedArgs = SpSnippetFunctionGen::SerializeArguments(arguments);
for (auto listener : selfRefr->GetListeners()) {
auto targetRefr = dynamic_cast<MpActor*>(listener);
if (targetRefr) {
SpSnippet(GetName(), funcName, serializedArgs.data(),
selfRefr->GetFormId())
.Execute(targetRefr);
}
}
}

return VarValue::None();
}

Expand Down

0 comments on commit ccc4e02

Please sign in to comment.