From 58fa467abc5cac6191c72a110ad710ae85a2311b Mon Sep 17 00:00:00 2001 From: Leonid Pospelov Date: Mon, 15 Apr 2024 01:55:07 +0500 Subject: [PATCH] fix(skymp5-server): fix setDisplayName not cleared from db (#1920) --- .../cpp/server_guest_lib/MpObjectReference.cpp | 12 ++++++++---- .../script_classes/PapyrusObjectReference.cpp | 6 +----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp b/skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp index 9855e00d03..cf652b7c09 100644 --- a/skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp +++ b/skymp5-server/cpp/server_guest_lib/MpObjectReference.cpp @@ -29,6 +29,8 @@ #include "OpenContainerMessage.h" #include "TeleportMessage.h" +#include "script_classes/PapyrusObjectReference.h" // kOriginalNameExpression + constexpr uint32_t kPlayerCharacterLevel = 1; UpdatePropertyMessage MpObjectReference::CreatePropertyMessage( @@ -335,10 +337,12 @@ void MpObjectReference::VisitProperties(const PropertiesVisitor& visitor, } if (ChangeForm().displayName.has_value()) { - std::string raw = *ChangeForm().displayName; - nlohmann::json j = raw; - std::string displayNameAsJson = j.dump(); - visitor("displayName", displayNameAsJson.data()); + const std::string& raw = *ChangeForm().displayName; + if (raw != PapyrusObjectReference::kOriginalNameExpression) { + nlohmann::json j = raw; + std::string displayNameAsJson = j.dump(); + visitor("displayName", displayNameAsJson.data()); + } } // Property flags (isVisibleByOwner, isVisibleByNeighbor) should be checked diff --git a/skymp5-server/cpp/server_guest_lib/script_classes/PapyrusObjectReference.cpp b/skymp5-server/cpp/server_guest_lib/script_classes/PapyrusObjectReference.cpp index 115dcbe045..ccf9959064 100644 --- a/skymp5-server/cpp/server_guest_lib/script_classes/PapyrusObjectReference.cpp +++ b/skymp5-server/cpp/server_guest_lib/script_classes/PapyrusObjectReference.cpp @@ -857,11 +857,7 @@ VarValue PapyrusObjectReference::SetDisplayName( } const char* displayName = static_cast(arguments[0]); - if (!strcmp(displayName, kOriginalNameExpression)) { - selfRefr->SetDisplayName(std::nullopt); - } else { - selfRefr->SetDisplayName(displayName); - } + selfRefr->SetDisplayName(displayName); bool force = static_cast(arguments[1]); std::ignore = force;