Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: don't send queued (un)equip messages #667

Merged
merged 2 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Code/client/Games/Skyrim/EquipManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void* TP_MAKE_THISCALL(EquipHook, EquipManager, Actor* apActor, TESForm* apItem,
// Consumables are "equipped" as well. We don't want this to sync, for several reasons.
// The right hand item on the server would be overridden by the consumable.
// Furthermore, the equip action on the other clients would doubly subtract the consumables.
if (pExtension->IsLocal() && !apItem->IsConsumable())
if (pExtension->IsLocal() && !apItem->IsConsumable() && !apData->bQueueEquip)
{
EquipmentChangeEvent evt{};
evt.ActorId = apActor->formID;
Expand Down Expand Up @@ -189,7 +189,7 @@ void* TP_MAKE_THISCALL(UnEquipHook, EquipManager, Actor* apActor, TESForm* apIte
return nullptr;
}

if (pExtension->IsLocal() && !ScopedUnequipOverride::IsOverriden())
if (pExtension->IsLocal() && !ScopedUnequipOverride::IsOverriden() && !apData->bQueueEquip)
{
EquipmentChangeEvent evt{};
evt.ActorId = apActor->formID;
Expand All @@ -216,7 +216,7 @@ void* TP_MAKE_THISCALL(EquipSpellHook, EquipManager, Actor* apActor, TESForm* ap
if (pExtension->IsRemote() && !ScopedEquipOverride::IsOverriden())
return nullptr;

if (pExtension->IsLocal())
if (pExtension->IsLocal() && !apData->bQueueEquip)
{
EquipmentChangeEvent evt{};
evt.ActorId = apActor->formID;
Expand All @@ -241,7 +241,7 @@ void* TP_MAKE_THISCALL(UnEquipSpellHook, EquipManager, Actor* apActor, TESForm*
if (pExtension->IsRemote() && !ScopedEquipOverride::IsOverriden())
return nullptr;

if (pExtension->IsLocal() && !ScopedUnequipOverride::IsOverriden())
if (pExtension->IsLocal() && !ScopedUnequipOverride::IsOverriden() && !apData->bQueueEquip)
{
EquipmentChangeEvent evt{};
evt.ActorId = apActor->formID;
Expand All @@ -265,6 +265,7 @@ void* TP_MAKE_THISCALL(EquipShoutHook, EquipManager, Actor* apActor, TESForm* ap
if (pExtension->IsRemote() && !ScopedEquipOverride::IsOverriden())
return nullptr;

// TODO: queue check?
if (pExtension->IsLocal())
{
EquipmentChangeEvent evt{};
Expand All @@ -289,6 +290,7 @@ void* TP_MAKE_THISCALL(UnEquipShoutHook, EquipManager, Actor* apActor, TESForm*
if (pExtension->IsRemote() && !ScopedEquipOverride::IsOverriden())
return nullptr;

// TODO: queue check?
if (pExtension->IsLocal() && !ScopedUnequipOverride::IsOverriden())
{
EquipmentChangeEvent evt{};
Expand Down
8 changes: 0 additions & 8 deletions Code/client/Services/Generic/InventoryService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,10 @@ void InventoryService::OnNotifyEquipmentChanges(const NotifyEquipmentChanges& ac
uint32_t equipSlotId = modSystem.GetGameId(acMessage.EquipSlotId);
TESForm* pEquipSlot = TESForm::GetById(equipSlotId);

// TODO: ft, does it have the same problem?
#if TP_SKYRIM64
uint32_t slotId = 0;
if (pEquipSlot == DefaultObjectManager::Get().rightEquipSlot)
slotId = 1;

// There's a bug where double equipping something magically unequips something secretly.
// TODO: should this be done for armor as well?
// Also, find out why the client is sending two equip messages in the first place.
// TODO: this fix makes it so that weapons and spells are sometimes invisible :/
if (!acMessage.Unequip && pActor->GetEquippedWeapon(slotId) == pItem)
return;
#endif

auto* pEquipManager = EquipManager::Get();
Expand Down
Loading