Jump to content

[fix][8489] UpdateVisibilityForPlayer


Recommended Posts

Posted

What bug does the patch fix?

This patch fixes incorrect cell calculation: since player has viewPoint we need compute cells using that point.

Who has been writing this patch? Me

diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp
index 79b9d9c..268e07c 100644
--- a/src/game/ObjectAccessor.cpp
+++ b/src/game/ObjectAccessor.cpp
@@ -451,7 +451,8 @@ ObjectAccessor::UpdateObjectVisibility(WorldObject *obj)

void ObjectAccessor::UpdateVisibilityForPlayer( Player* player )
{
-    CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
+    WorldObject* viewPoint = player->GetViewPoint();
+    CellPair p(MaNGOS::ComputeCellPair(viwPoint->GetPositionX(), viwPoint->GetPositionY()));
    Cell cell(p);
    Map* m = player->GetMap();

Posted

You have typos in second line, but anyway in general fix correct :)

I will added it in modified form, for aboid additionl calculations in most often case when viewPoint==player

Also note: player visibility itself must use player point, objects around visibility use view point.

Posted

but why we need compare player and viewPoint, and compute cells twice?

if player's farsight guid is empty veiwpoint its a player.. this mean that their positions are same..

just look at Player::GetViewPoint function

Posted

That why it compared.

UpdateObjectsVisibilityFor expected to be call for view points and your fix targeted correctly to fix this case.

It include also update update players visibility around view point.

BUT

UpdatePlayerVisibility update visibility of player itself and expected to be in player position without deopendencr is viewPoint same to player or not.

So we have 2 cases for UpdateObjectsVisibilityFor (1) player = viewPoint and we can use same cell coordinates as for player already used.

(2) need initilize new cell coordinates for viewPoint (!= player). If-check just avoud like second point creating.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use