Skip to content

Commit

Permalink
feat: armor equip sync
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Apr 7, 2022
1 parent e59d47f commit 24d255b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion Code/client/Games/Skyrim/TESObjectREFR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ Inventory TESObjectREFR::GetInventory(std::function<bool(TESForm&)> aFilter) con

spdlog::debug("Inventory count before: {}", inventory.Entries.size());

// TODO: filter out quest items
inventory.RemoveByFilter([](const auto& entry) { return entry.Count == 0; });

spdlog::debug("Inventory count after: {}", inventory.Entries.size());
Expand Down
10 changes: 5 additions & 5 deletions Code/client/Services/Generic/InventoryService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void InventoryService::OnEquipmentChangeEvent(const EquipmentChangeEvent& acEven
request.IsSpell = acEvent.IsSpell;
request.IsShout = acEvent.IsShout;
request.IsAmmo = acEvent.IsAmmo;
request.CurrentInventory = pActor->GetActorInventory();
request.CurrentInventory = pActor->GetEquippedItems();

m_transport.Send(request);
}
Expand Down Expand Up @@ -202,9 +202,9 @@ void InventoryService::OnNotifyEquipmentChanges(const NotifyEquipmentChanges& ac
for (const auto& armor : wornArmor.Entries)
{
uint32_t armorId = modSystem.GetGameId(armor.BaseId);
TESForm* pArmor = TESForm::GetById(itemId);
TESForm* pArmor = TESForm::GetById(armorId);
if (pArmor)
pEquipManager->UnEquip(pActor, pItem, nullptr, 1, pEquipSlot, false, true, false, false, nullptr);
pEquipManager->UnEquip(pActor, pArmor, nullptr, 1, pEquipSlot, false, true, false, false, nullptr);
}
}

Expand All @@ -213,9 +213,9 @@ void InventoryService::OnNotifyEquipmentChanges(const NotifyEquipmentChanges& ac
for (const auto& armor : wornArmor.Entries)
{
uint32_t armorId = modSystem.GetGameId(armor.BaseId);
TESForm* pArmor = TESForm::GetById(itemId);
TESForm* pArmor = TESForm::GetById(armorId);
if (pArmor)
pEquipManager->Equip(pActor, pItem, nullptr, 1, pEquipSlot, false, true, false, false);
pEquipManager->Equip(pActor, pArmor, nullptr, 1, pEquipSlot, false, true, false, false);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Code/encoding/Messages/RequestEquipmentChanges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void RequestEquipmentChanges::SerializeRaw(TiltedPhoques::Buffer::Writer& aWrite
Serialization::WriteBool(aWriter, IsSpell);
Serialization::WriteBool(aWriter, IsShout);
Serialization::WriteBool(aWriter, IsAmmo);
CurrentInventory.Serialize(aWriter);
}

void RequestEquipmentChanges::DeserializeRaw(TiltedPhoques::Buffer::Reader& aReader) noexcept
Expand All @@ -25,4 +26,5 @@ void RequestEquipmentChanges::DeserializeRaw(TiltedPhoques::Buffer::Reader& aRea
IsSpell = Serialization::ReadBool(aReader);
IsShout = Serialization::ReadBool(aReader);
IsAmmo = Serialization::ReadBool(aReader);
CurrentInventory.Deserialize(aReader);
}
3 changes: 2 additions & 1 deletion Code/encoding/Messages/RequestEquipmentChanges.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ struct RequestEquipmentChanges final : ClientMessage
Unequip == acRhs.Unequip &&
IsSpell == acRhs.IsSpell &&
IsShout == acRhs.IsShout &&
IsAmmo == acRhs.IsAmmo;
IsAmmo == acRhs.IsAmmo &&
CurrentInventory == acRhs.CurrentInventory;
}

uint32_t ServerId{};
Expand Down

0 comments on commit 24d255b

Please sign in to comment.