Skip to content

Commit

Permalink
Fixed: Possessed NPCs sometimes would not be where the client sees th…
Browse files Browse the repository at this point in the history
…em, after unpossessing, because the AI sends monster move packet before the client gets the object creation update.
  • Loading branch information
dfighter1985 committed Jul 9, 2023
1 parent c757034 commit d1627e5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/world/Game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13248,7 +13248,11 @@ void Player::bindSight( Object *target )
for( std::set< uint64 >::iterator itr = m_visibleObjects.begin(); itr != m_visibleObjects.end(); ++itr )
{
uint64 guid = *itr;
PushOutOfRange( guid );

if( guid != GetGUID() )
{
Messenger::SendDestroyObject( this, guid );
}
}
m_visibleObjects.clear();

Expand All @@ -13273,7 +13277,7 @@ void Player::bindSight( Object *target )
uint64 guid = *itr;
if( guid != target->GetGUID() )
{
PushOutOfRange( guid );
Messenger::SendDestroyObject( this, guid );
}
}

Expand All @@ -13286,7 +13290,7 @@ void Player::bindSight( Object *target )
for( std::set< Object* >::iterator itr = objects.begin(); itr != objects.end(); ++itr )
{
Object *object = (*itr);
if( CanSee( object ) )
if( ( object->GetGUID() != this->GetGUID() ) && CanSee( object ) )
{
createForPlayer( object );
AddVisibleObject( object->GetGUID() );
Expand All @@ -13295,4 +13299,6 @@ void Player::bindSight( Object *target )

target->setFarsightViewer( this );
}

ProcessPendingUpdates();
}
9 changes: 9 additions & 0 deletions src/world/Messenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ void Messenger::SendDestroyObject(Player *player, Object *object)
PlayerMessenger::sendMessage( player, data );
}

void Messenger::SendDestroyObject(Player *player, uint64 guid)
{
WorldPacket data( SMSG_DESTROY_OBJECT, 9 );
data << uint64( guid );
data << uint8( 0 );

PlayerMessenger::sendMessage( player, data );
}

void Messenger::SendGameObjectCustomAnim( GameObject *go, uint32 anim, Player *player )
{
WorldPacket data(12);
Expand Down
3 changes: 3 additions & 0 deletions src/world/Messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class SERVER_DECL Messenger
/// Destroys this Object for the player's client
static void SendDestroyObject( Player* player, Object* object );

/// Destroys this Object for the player's client
static void SendDestroyObject( Player* player, uint64 guid );

/// Sends a gameobject animation to the player
static void SendGameObjectCustomAnim( GameObject* go, uint32 anim, Player* player );

Expand Down

0 comments on commit d1627e5

Please sign in to comment.