fix(Core/GameObject): clean up stale fishing bobbers (#26453)

Co-authored-by: sudlud <sudlud@users.noreply.github.com>
This commit is contained in:
moostigre
2026-07-24 09:03:00 +02:00
committed by GitHub
parent 38dc96259c
commit 6c104dfba0
4 changed files with 33 additions and 5 deletions

View File

@@ -634,7 +634,7 @@ void GameObject::Update(uint32 diff)
WorldPacket data(SMSG_FISH_ESCAPED, 0);
caster->ToPlayer()->SendDirectMessage(&data);
}
// can be delete
// can be deleted
m_lootState = GO_JUST_DEACTIVATED;
return;
}
@@ -1775,10 +1775,8 @@ void GameObject::Use(Unit* user)
// but you will likely cause junk in areas that require a high fishing skill (not yet implemented)
if (chance >= roll)
{
//TODO: I do not understand this hack. Need some explanation.
// prevent removing GO at spell cancel
RemoveFromOwner();
SetOwnerGUID(player->GetGUID());
// Keep the bobber owned while loot is open, but clear the
// spell id so finishing the fishing channel does not delete it.
SetSpellId(0); // prevent removing unintended auras at Unit::RemoveGameObject
// fishing pool catch

View File

@@ -6640,6 +6640,32 @@ void Unit::RemoveGameObject(uint32 spellid, bool del)
}
}
void Unit::RemoveGameObjectsByType(GameobjectTypes type, bool del)
{
if (m_gameObj.empty())
return;
for (GameObjectList::iterator itr = m_gameObj.begin(); itr != m_gameObj.end();)
{
if (GameObject* go = ObjectAccessor::GetGameObject(*this, *itr))
{
if (go->GetGoType() != type)
{
++itr;
continue;
}
go->SetOwnerGUID(ObjectGuid::Empty);
if (del)
{
go->SetRespawnTime(0);
go->Delete();
}
}
m_gameObj.erase(itr++);
}
}
void Unit::RemoveAllGameObjects()
{
while(!m_gameObj.empty())

View File

@@ -1698,6 +1698,7 @@ public:
void AddGameObject(GameObject* gameObj);
void RemoveGameObject(GameObject* gameObj, bool del);
void RemoveGameObject(uint32 spellid, bool del);
void RemoveGameObjectsByType(GameobjectTypes type, bool del);
void RemoveAllGameObjects();
/*********************************************************/

View File

@@ -5447,6 +5447,9 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex)
{
case GAMEOBJECT_TYPE_FISHINGNODE:
{
if (m_caster->IsPlayer())
m_caster->RemoveGameObjectsByType(GAMEOBJECT_TYPE_FISHINGNODE, true);
m_caster->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, pGameObj->GetGUID());
m_caster->AddGameObject(pGameObj); // will removed at spell cancel