Skip to content

Commit

Permalink
[10616] Simplified trade distance checks, GROUP_UPDATE_FLAG_POSITION …
Browse files Browse the repository at this point in the history
…flag handling moved out of Map

note: need avoid Map::PlayerRelocation calls now and use Player::SetPosition instead
  • Loading branch information
SilverIce committed Oct 17, 2010
1 parent 69c1008 commit 28d9aba
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 26 deletions.
2 changes: 0 additions & 2 deletions src/game/GridNotifiers.h
Expand Up @@ -150,7 +150,6 @@ namespace MaNGOS
Player &i_player;
PlayerRelocationNotifier(Player &pl) : i_player(pl) {}
template<class T> void Visit(GridRefManager<T> &) {}
void Visit(PlayerMapType &);
void Visit(CreatureMapType &);
};

Expand Down Expand Up @@ -1170,7 +1169,6 @@ namespace MaNGOS

#ifndef WIN32
template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &);
template<> void PlayerRelocationNotifier::Visit<Player>(PlayerMapType &);
template<> void CreatureRelocationNotifier::Visit<Player>(PlayerMapType &);
template<> void CreatureRelocationNotifier::Visit<Creature>(CreatureMapType &);
template<> inline void DynamicObjectUpdater::Visit<Creature>(CreatureMapType &);
Expand Down
17 changes: 0 additions & 17 deletions src/game/GridNotifiersImpl.h
Expand Up @@ -44,23 +44,6 @@ inline void MaNGOS::ObjectUpdater::Visit(CreatureMapType &m)
iter->getSource()->Update(i_timeDiff);
}

inline void MaNGOS::PlayerRelocationNotifier::Visit(PlayerMapType &m)
{
for(PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
if (&i_player==iter->getSource())
continue;

// visibility for players updated by ObjectAccessor::UpdateVisibilityFor calls in appropriate places

// Cancel Trade
if (i_player.GetTrader()==iter->getSource())
// iteraction distance
if (!i_player.IsWithinDistInMap(iter->getSource(), INTERACTION_DISTANCE))
i_player.GetSession()->SendCancelTrade(); // will clode both side trade windows
}
}

inline void PlayerCreatureRelocationWorker(Player* pl, WorldObject const* viewPoint, Creature* c)
{
// update creature visibility at player/creature move
Expand Down
4 changes: 0 additions & 4 deletions src/game/Map.cpp
Expand Up @@ -755,10 +755,6 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati
{
DEBUG_FILTER_LOG(LOG_FILTER_PLAYER_MOVES, "Player %s relocation grid[%u,%u]cell[%u,%u]->grid[%u,%u]cell[%u,%u]", player->GetName(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());

// update player position for group at taxi flight
if(player->GetGroup() && player->IsTaxiFlying())
player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);

NGridType* oldGrid = getNGrid(old_cell.GridX(), old_cell.GridY());
RemoveFromGrid(player, oldGrid,old_cell);
if( !old_cell.DiffGrid(new_cell) )
Expand Down
5 changes: 4 additions & 1 deletion src/game/Player.cpp
Expand Up @@ -6055,8 +6055,11 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele
z = GetPositionZ();

// group update
if(GetGroup() && (old_x != x || old_y != y))
if (GetGroup() && (old_x != x || old_y != y))
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);

if (GetTrader() && !IsWithinDistInMap(GetTrader(), INTERACTION_DISTANCE))
GetSession()->SendCancelTrade(); // will clode both side trade windows

This comment has been minimized.

Copy link
@Schmoozerd

Schmoozerd Oct 17, 2010

Contributor

tiny typo: "clode" <- "close"

This comment has been minimized.

Copy link
@SilverIce

SilverIce Oct 17, 2010

Author

it was copy-pasted from the old code :
thanks

}

// code block for underwater state update
Expand Down
2 changes: 1 addition & 1 deletion src/game/Traveller.h
Expand Up @@ -141,7 +141,7 @@ inline float Traveller<Player>::GetMoveDestinationTo(float x, float y, float z)
template<>
inline void Traveller<Player>::Relocation(float x, float y, float z, float orientation)
{
i_traveller.GetMap()->PlayerRelocation(&i_traveller, x, y, z, orientation);
i_traveller.SetPosition(x, y, z, orientation);
}

template<>
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10615"
#define REVISION_NR "10616"
#endif // __REVISION_NR_H__

0 comments on commit 28d9aba

Please sign in to comment.