Skip to content

Commit

Permalink
fix(skymp5-server): temporary restrict drop & fix spawnpoint issue (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove authored Dec 11, 2023
1 parent a84adca commit 5d7b980
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
25 changes: 24 additions & 1 deletion skymp5-server/cpp/server_guest_lib/MpActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,9 @@ LocationalData MpActor::GetSpawnPoint() const
auto formId = GetFormId();

if (!IsCreatedAsPlayer()) {
return GetEditorLocationalData();
if (formId < 0xff000000) {
return GetEditorLocationalData();
}
}
return ChangeForm().spawnPoint;
}
Expand Down Expand Up @@ -1023,6 +1025,27 @@ void MpActor::DropItem(const uint32_t baseId, const Inventory::Entry& entry)
std::string editorId =
lookupRes.rec->GetEditorId(worldState->GetEspmCache());

// TODO: remove this when we will be sure that none of armors crashes clients
if (lookupRes.rec->GetType().ToString() == "ARMO") {
spdlog::warn("MpActor::DropItem - Attempt to drop ARMO by actor {:x}",
GetFormId());
return;
}

// TODO: remove this with the next client update
if (lookupRes.rec->GetType().ToString() == "INGR") {
spdlog::warn("MpActor::DropItem - Attempt to drop INGR by actor {:x}",
GetFormId());
return;
}

// TODO: remove this with the next client update
if (lookupRes.rec->GetType().ToString() == "ALCH") {
spdlog::warn("MpActor::DropItem - Attempt to drop ALCH by actor {:x}",
GetFormId());
return;
}

spdlog::trace("MpActor::DropItem - dropping {}", editorId);
RemoveItems({ entry });

Expand Down
8 changes: 4 additions & 4 deletions unit/DropItemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TEST_CASE("Dropping an item", "[DropItemTest]")
auto& partOne = GetPartOne();
// an iron dagger
constexpr uint32_t ironDagger = 0x0001397E;
constexpr uint32_t healingPotion = 0x0003EADD;
constexpr uint32_t ironSword = 0x00012EB7;
DoConnect(partOne, 0);

partOne.CreateActor(0xff000000, { 1, 2, 3 }, 0, 0x3c);
Expand Down Expand Up @@ -40,14 +40,14 @@ TEST_CASE("Dropping an item", "[DropItemTest]")
REQUIRE(refr.GetPos().x == 1.f);
REQUIRE(refr.GetPos().y == 2.f);
REQUIRE(refr.GetPos().z == 3.f);
ac.AddItem(healingPotion, 5);
ac.AddItem(ironSword, 5);
partOne.Messages().clear();
REQUIRE(partOne.Messages().size() == 0);
DoMessage(partOne, 0,
nlohmann::json{ { "t", MsgType::DropItem },
{ "baseId", healingPotion },
{ "baseId", ironSword },
{ "count", 5 } });
partOne.Tick();
REQUIRE(partOne.Messages().size() == 2);
REQUIRE(ac.GetInventory().GetItemCount(healingPotion) == 0);
REQUIRE(ac.GetInventory().GetItemCount(ironSword) == 0);
}

0 comments on commit 5d7b980

Please sign in to comment.