Index: trunk/src/game/Object.cpp
===================================================================
--- trunk/src/game/Object.cpp (revision 12)
+++ trunk/src/game/Object.cpp (revision 19)
@@ -41,6 +41,4 @@
 #include "GridNotifiers.h"
 #include "GridNotifiersImpl.h"
-
-#include "ObjectPosSelector.h"
 
 #include "TemporarySummon.h"
@@ -1431,82 +1429,4 @@
 }
 
-namespace MaNGOS
-{
-    class NearUsedPosDo
-    {
-        public:
-            NearUsedPosDo(WorldObject const& obj, WorldObject const* searcher, float angle, ObjectPosSelector& selector)
-                : i_object(obj), i_searcher(searcher), i_angle(angle), i_selector(selector) {}
-
-            void operator()(Corpse*) const {}
-            void operator()(DynamicObject*) const {}
-
-            void operator()(Creature* c) const
-            {
-                // skip self or target
-                if(c==i_searcher || c==&i_object)
-                    return;
-
-                float x,y,z;
-
-                if( !c->isAlive() || c->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNDED | UNIT_STAT_DISTRACTED) ||
-                    !c->GetMotionMaster()->GetDestination(x,y,z) )
-                {
-                    x = c->GetPositionX();
-                    y = c->GetPositionY();
-                }
-
-                add(c,x,y);
-            }
-
-            template<class T>
-                void operator()(T* u) const
-            {
-                // skip self or target
-                if(u==i_searcher || u==&i_object)
-                    return;
-
-                float x,y;
-
-                x = u->GetPositionX();
-                y = u->GetPositionY();
-
-                add(u,x,y);
-            }
-
-            // we must add used pos that can fill places around center
-            void add(WorldObject* u, float x, float y) const
-            {
-                // dist include size of u
-                float dist2d = i_object.GetDistance2d(x,y);
-
-                // u is too nearest to i_object
-                if(dist2d + i_object.GetObjectSize() + u->GetObjectSize() < i_selector.m_dist - i_selector.m_size)
-                    return;
-
-                // u is too far away from i_object
-                if(dist2d + i_object.GetObjectSize() - u->GetObjectSize() > i_selector.m_dist + i_selector.m_size)
-                    return;
-
-                float angle = i_object.GetAngle(u)-i_angle;
-
-                // move angle to range -pi ... +pi
-                while( angle > M_PI)
-                    angle -= 2.0f * M_PI;
-                while(angle < -M_PI)
-                    angle += 2.0f * M_PI;
-
-                i_selector.AddUsedPos(u->GetObjectSize(),angle,dist2d + i_object.GetObjectSize());
-            }
-        private:
-            WorldObject const& i_object;
-            WorldObject const* i_searcher;
-            float              i_angle;
-            ObjectPosSelector& i_selector;
-    };
-}                                                           // namespace MaNGOS
-
-//===================================================================================================
-
 void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle ) const
 {
@@ -1521,121 +1441,7 @@
 {
     GetNearPoint2D(x,y,distance2d+searcher_size,absAngle);
+    
     z = GetPositionZ();
-
-    // if detection disabled, return first point
-    if(!sWorld.getConfig(CONFIG_DETECT_POS_COLLISION))
-    {
-        UpdateGroundPositionZ(x,y,z);                       // update to LOS height if available
-        return;
-    }
-
-    // or remember first point
-    float first_x = x;
-    float first_y = y;
-    bool first_los_conflict = false;                        // first point LOS problems
-
-    // prepare selector for work
-    ObjectPosSelector selector(GetPositionX(),GetPositionY(),GetObjectSize(),distance2d+searcher_size);
-
-    // adding used positions around object
-    {
-        CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
-        Cell cell(p);
-        cell.data.Part.reserved = ALL_DISTRICT;
-        cell.SetNoCreate();
-
-        MaNGOS::NearUsedPosDo u_do(*this,searcher,absAngle,selector);
-        MaNGOS::WorldObjectWorker<MaNGOS::NearUsedPosDo> worker(u_do);
-
-        TypeContainerVisitor<MaNGOS::WorldObjectWorker<MaNGOS::NearUsedPosDo>, GridTypeMapContainer  > grid_obj_worker(worker);
-        TypeContainerVisitor<MaNGOS::WorldObjectWorker<MaNGOS::NearUsedPosDo>, WorldTypeMapContainer > world_obj_worker(worker);
-
-        CellLock<GridReadGuard> cell_lock(cell, p);
-        cell_lock->Visit(cell_lock, grid_obj_worker,  *MapManager::Instance().GetMap(GetMapId(), this));
-        cell_lock->Visit(cell_lock, world_obj_worker, *MapManager::Instance().GetMap(GetMapId(), this));
-    }
-
-    // maybe can just place in primary position
-    if( selector.CheckOriginal() )
-    {
-        UpdateGroundPositionZ(x,y,z);                       // update to LOS height if available
-
-        if(IsWithinLOS(x,y,z))
-            return;
-
-        first_los_conflict = true;                          // first point have LOS problems
-    }
-
-    float angle;                                            // candidate of angle for free pos
-
-    // special case when one from list empty and then empty side preferred
-    if(selector.FirstAngle(angle))
-    {
-        GetNearPoint2D(x,y,distance2d,absAngle+angle);
-        z = GetPositionZ();
-        UpdateGroundPositionZ(x,y,z);                       // update to LOS height if available
-
-        if(IsWithinLOS(x,y,z))
-            return;
-    }
-
-    // set first used pos in lists
-    selector.InitializeAngle();
-
-    // select in positions after current nodes (selection one by one)
-    while(selector.NextAngle(angle))                        // angle for free pos
-    {
-        GetNearPoint2D(x,y,distance2d,absAngle+angle);
-        z = GetPositionZ();
-        UpdateGroundPositionZ(x,y,z);                       // update to LOS height if available
-
-        if(IsWithinLOS(x,y,z))
-            return;
-    }
-
-    // BAD NEWS: not free pos (or used or have LOS problems)
-    // Attempt find _used_ pos without LOS problem
-
-    if(!first_los_conflict)
-    {
-        x = first_x;
-        y = first_y;
-
-        UpdateGroundPositionZ(x,y,z);                       // update to LOS height if available
-        return;
-    }
-
-    // special case when one from list empty and then empty side preferred
-    if( selector.IsNonBalanced() )
-    {
-        if(!selector.FirstAngle(angle))                     // _used_ pos
-        {
-            GetNearPoint2D(x,y,distance2d,absAngle+angle);
-            z = GetPositionZ();
-            UpdateGroundPositionZ(x,y,z);                   // update to LOS height if available
-
-            if(IsWithinLOS(x,y,z))
-                return;
-        }
-    }
-
-    // set first used pos in lists
-    selector.InitializeAngle();
-
-    // select in positions after current nodes (selection one by one)
-    while(selector.NextUsedAngle(angle))                    // angle for used pos but maybe without LOS problem
-    {
-        GetNearPoint2D(x,y,distance2d,absAngle+angle);
-        z = GetPositionZ();
-        UpdateGroundPositionZ(x,y,z);                       // update to LOS height if available
-
-        if(IsWithinLOS(x,y,z))
-            return;
-    }
-
-    // BAD BAD NEWS: all found pos (free and used) have LOS problem :(
-    x = first_x;
-    y = first_y;
-
-    UpdateGroundPositionZ(x,y,z);                           // update to LOS height if available
-}
+    
+    UpdateGroundPositionZ(x,y,z);
+}
Index: trunk/src/game/Makefile.am
===================================================================
--- trunk/src/game/Makefile.am (revision 17)
+++ trunk/src/game/Makefile.am (revision 19)
@@ -183,6 +183,4 @@
 $(srcdir)/ObjectMgr.cpp \
 $(srcdir)/ObjectMgr.h \
-$(srcdir)/ObjectPosSelector.cpp \
-$(srcdir)/ObjectPosSelector.h \
 $(srcdir)/Opcodes.cpp \
 $(srcdir)/Opcodes.h \
Index: trunk/src/game/World.h
===================================================================
--- trunk/src/game/World.h (revision 9)
+++ trunk/src/game/World.h (revision 19)
@@ -138,5 +138,4 @@
     CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF,
     CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF,
-    CONFIG_DETECT_POS_COLLISION,
     CONFIG_RESTRICTED_LFG_CHANNEL,
     CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL,
Index: trunk/src/game/World.cpp
===================================================================
--- trunk/src/game/World.cpp (revision 9)
+++ trunk/src/game/World.cpp (revision 19)
@@ -740,6 +740,4 @@
         m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = 255;
 
-    m_configs[CONFIG_DETECT_POS_COLLISION] = sConfig.GetBoolDefault("DetectPosCollision", true);
-
     m_configs[CONFIG_RESTRICTED_LFG_CHANNEL] = sConfig.GetBoolDefault("Channel.RestrictedLfg", true);
     m_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL] = sConfig.GetBoolDefault("Channel.SilentlyGMJoin", false);
Index: trunk/src/game/ObjectPosSelector.h
===================================================================
--- trunk/src/game/ObjectPosSelector.h (revision 2)
+++  (revision )
@@ -1,155 +1,0 @@
-/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OBJECT_POS_SELECTOR_H
-#define _OBJECT_POS_SELECTOR_H
-
-#include<Common.h>
-
-#include<map>
-
-enum UsedPosType { USED_POS_PLUS, USED_POS_MINUS };
-
-inline UsedPosType operator ~(UsedPosType uptype)
-{
-    return uptype==USED_POS_PLUS ? USED_POS_MINUS : USED_POS_PLUS;
-}
-
-struct ObjectPosSelector
-{
-    struct UsedPos
-    {
-        UsedPos(float sign_, float size_,float dist_) : sign(sign_), size(size_),dist(dist_) {}
-
-        float sign;
-
-        float size;                                         // size of point
-        float dist;                                         // dist to central point (including central point size)
-    };
-
-    typedef std::multimap<float,UsedPos> UsedPosList;       // abs(angle)->Node
-
-    ObjectPosSelector(float x,float y,float size,float dist);
-
-    void AddUsedPos(float size,float angle,float dist);
-    void InitializeAngle();
-
-    bool FirstAngle(float& angle);
-    bool NextAngle(float& angle);
-    bool NextUsedAngle(float& angle);
-
-    bool NextPosibleAngle( float& angle );
-
-    bool CheckAngle(UsedPosList::value_type const& nextUsedPos, float sign, float angle ) const
-    {
-        float angle_step2  = GetAngle(nextUsedPos.second);
-
-        float next_angle = nextUsedPos.first;
-        if(nextUsedPos.second.sign * sign < 0)              // last node from diff. list (-pi+alpha)
-            next_angle = 2*M_PI-next_angle;                 // move to positive
-
-        return fabs(angle)+angle_step2 <= next_angle;
-    }
-
-    bool CheckOriginal() const
-    {
-        return (m_UsedPosLists[USED_POS_PLUS].empty()  || CheckAngle( *m_UsedPosLists[USED_POS_PLUS].begin(),1.0,0)) &&
-            (m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle( *m_UsedPosLists[USED_POS_MINUS].begin(),-1.0,0));
-    }
-
-    bool IsNonBalanced() const { return m_UsedPosLists[USED_POS_PLUS].empty() != m_UsedPosLists[USED_POS_MINUS].empty(); }
-
-    bool NextAngleFor( UsedPosList::value_type const& usedPos, float sign, UsedPosType uptype, float &angle )
-    {
-        float angle_step  = GetAngle(usedPos.second);
-
-        // next possible angle
-        angle  = usedPos.first * usedPos.second.sign + angle_step * sign;
-
-        UsedPosList::value_type const* nextNode = nextUsedPos(uptype);
-        if(nextNode)
-        {
-            // if next node permit use selected angle, then do it
-            if(!CheckAngle(*nextNode, sign, angle))
-            {
-                m_smallStepOk[uptype] = false;
-                return false;
-            }
-        }
-
-        // possible more points
-        m_smallStepOk[uptype] = true;
-        m_smallStepAngle[uptype] = angle;
-        m_smallStepNextUsedPos[uptype] = nextNode;
-
-        return true;
-    }
-
-    bool NextSmallStepAngle( float sign, UsedPosType uptype, float &angle )
-    {
-        // next possible angle
-        angle  = m_smallStepAngle[uptype] + m_anglestep * sign;
-
-        if(fabs(angle) > M_PI)
-        {
-            m_smallStepOk[uptype] = false;
-            return false;
-        }
-
-        if(m_smallStepNextUsedPos[uptype])
-        {
-            if(fabs(angle) >= m_smallStepNextUsedPos[uptype]->first)
-            {
-                m_smallStepOk[uptype] = false;
-                return false;
-            }
-
-            // if next node permit use selected angle, then do it
-            if(!CheckAngle(*m_smallStepNextUsedPos[uptype], sign, angle))
-            {
-                m_smallStepOk[uptype] = false;
-                return false;
-            }
-        }
-
-        // possible more points
-        m_smallStepAngle[uptype] = angle;
-        return true;
-    }
-
-    // next used post for m_nextUsedPos[uptype]
-    UsedPosList::value_type const* nextUsedPos(UsedPosType uptype);
-
-    // angle from used pos to next possible free pos
-    float GetAngle(UsedPos const& usedPos) const { return acos(m_dist/(usedPos.dist+usedPos.size+m_size)); }
-
-    float m_center_x;
-    float m_center_y;
-    float m_size;                                           // size of object in center
-    float m_dist;                                           // distance for searching pos (including central object size)
-    float m_anglestep;
-
-    UsedPosList m_UsedPosLists[2];
-    UsedPosList::const_iterator m_nextUsedPos[2];
-
-    // field for small step from first after next used pos until next pos
-    float m_smallStepAngle[2];
-    bool  m_smallStepOk[2];
-    UsedPosList::value_type const* m_smallStepNextUsedPos[2];
-};
-#endif
Index: trunk/src/game/ObjectPosSelector.cpp
===================================================================
--- trunk/src/game/ObjectPosSelector.cpp (revision 2)
+++  (revision )
@@ -1,157 +1,0 @@
-/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "ObjectPosSelector.h"
-
-ObjectPosSelector::ObjectPosSelector(float x,float y,float size,float dist)
-: m_center_x(x),m_center_y(y),m_size(size),m_dist(dist)
-{
-    m_anglestep = acos(m_dist/(m_dist+2*m_size));
-
-    m_nextUsedPos[USED_POS_PLUS]  = m_UsedPosLists[USED_POS_PLUS].end();
-    m_nextUsedPos[USED_POS_MINUS] = m_UsedPosLists[USED_POS_MINUS].end();
-
-    m_smallStepAngle[USED_POS_PLUS]  = 0;
-    m_smallStepAngle[USED_POS_MINUS] = 0;
-
-    m_smallStepOk[USED_POS_PLUS]  = false;
-    m_smallStepOk[USED_POS_MINUS] = false;
-
-    m_smallStepNextUsedPos[USED_POS_PLUS]  = NULL;
-    m_smallStepNextUsedPos[USED_POS_MINUS] = NULL;
-}
-
-ObjectPosSelector::UsedPosList::value_type const* ObjectPosSelector::nextUsedPos(UsedPosType uptype)
-{
-    UsedPosList::const_iterator itr = m_nextUsedPos[uptype];
-    if(itr!=m_UsedPosLists[uptype].end())
-        ++itr;
-
-    if(itr==m_UsedPosLists[uptype].end())
-    {
-        if(!m_UsedPosLists[~uptype].empty())
-            return &*m_UsedPosLists[~uptype].rbegin();
-        else
-            return NULL;
-    }
-    else
-        return &*itr;
-}
-
-void ObjectPosSelector::AddUsedPos(float size,float angle,float dist)
-{
-    if(angle>=0)
-        m_UsedPosLists[USED_POS_PLUS].insert(UsedPosList::value_type(angle,UsedPos(1.0,size,dist)));
-    else
-        m_UsedPosLists[USED_POS_MINUS].insert(UsedPosList::value_type(-angle,UsedPos(-1.0,size,dist)));
-}
-
-void ObjectPosSelector::InitializeAngle()
-{
-    m_nextUsedPos[USED_POS_PLUS]  = m_UsedPosLists[USED_POS_PLUS].begin();
-    m_nextUsedPos[USED_POS_MINUS] = m_UsedPosLists[USED_POS_MINUS].begin();
-
-    m_smallStepAngle[USED_POS_PLUS]  = 0;
-    m_smallStepAngle[USED_POS_MINUS] = 0;
-
-    m_smallStepOk[USED_POS_PLUS]  = true;
-    m_smallStepOk[USED_POS_MINUS] = true;
-}
-
-bool ObjectPosSelector::FirstAngle(float& angle)
-{
-    if(m_UsedPosLists[USED_POS_PLUS].empty() && !m_UsedPosLists[USED_POS_MINUS].empty() )
-        return NextAngleFor(*m_UsedPosLists[USED_POS_MINUS].begin(),1.0,USED_POS_PLUS,angle);
-    else if(m_UsedPosLists[USED_POS_MINUS].empty() && !m_UsedPosLists[USED_POS_PLUS].empty() )
-        return NextAngleFor(*m_UsedPosLists[USED_POS_PLUS].begin(),-1.0,USED_POS_MINUS,angle);
-
-    return false;
-}
-
-bool ObjectPosSelector::NextAngle(float& angle)
-{
-    while(m_nextUsedPos[USED_POS_PLUS]!=m_UsedPosLists[USED_POS_PLUS].end() ||
-        m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end() ||
-        m_smallStepOk[USED_POS_PLUS] || m_smallStepOk[USED_POS_MINUS] )
-    {
-        // calculate next possible angle
-        if(NextPosibleAngle(angle))
-            return true;
-    }
-
-    return false;
-}
-
-bool ObjectPosSelector::NextUsedAngle(float& angle)
-{
-    while(m_nextUsedPos[USED_POS_PLUS]!=m_UsedPosLists[USED_POS_PLUS].end() ||
-        m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end() )
-    {
-        // calculate next possible angle
-        if(!NextPosibleAngle(angle))
-            return true;
-    }
-
-    return false;
-}
-
-bool ObjectPosSelector::NextPosibleAngle( float& angle )
-{
-    // ++ direction less updated
-    if( m_nextUsedPos[USED_POS_PLUS]!=m_UsedPosLists[USED_POS_PLUS].end() &&
-        (m_nextUsedPos[USED_POS_MINUS]==m_UsedPosLists[USED_POS_MINUS].end() || m_nextUsedPos[USED_POS_PLUS]->first <= m_nextUsedPos[USED_POS_MINUS]->first) )
-    {
-        bool ok;
-        if(m_smallStepOk[USED_POS_PLUS])
-            ok = NextSmallStepAngle(1.0,USED_POS_PLUS,angle);
-        else
-            ok = NextAngleFor(*m_nextUsedPos[USED_POS_PLUS],1.0,USED_POS_PLUS,angle);
-
-        if(!ok)
-            ++m_nextUsedPos[USED_POS_PLUS];                 // increase. only at fail (original or checked)
-        return ok;
-    }
-    // -- direction less updated
-    else if( m_nextUsedPos[USED_POS_MINUS]!=m_UsedPosLists[USED_POS_MINUS].end())
-    {
-        bool ok;
-        if(m_smallStepOk[USED_POS_MINUS])
-            ok = NextSmallStepAngle(-1.0,USED_POS_MINUS,angle);
-        else
-            ok =  NextAngleFor(*m_nextUsedPos[USED_POS_MINUS],-1.0,USED_POS_MINUS,angle);
-
-        if(!ok)
-            ++m_nextUsedPos[USED_POS_MINUS];
-        return ok;
-    }
-    else                                                    // both list empty
-    {
-        if( m_smallStepOk[USED_POS_PLUS] && (!m_smallStepOk[USED_POS_MINUS] || m_smallStepAngle[USED_POS_PLUS] <= m_smallStepAngle[USED_POS_MINUS]) )
-        {
-            return NextSmallStepAngle(1.0,USED_POS_PLUS,angle);
-        }
-        // -- direction less updated
-        else if( m_smallStepOk[USED_POS_MINUS] )
-        {
-            return NextSmallStepAngle(-1.0,USED_POS_MINUS,angle);
-        }
-    }
-
-    // no angles
-    return false;
-}
Index: trunk/src/trinitycore/trinitycore.conf.dist
===================================================================
--- trunk/src/trinitycore/trinitycore.conf.dist (revision 9)
+++ trunk/src/trinitycore/trinitycore.conf.dist (revision 19)
@@ -134,9 +134,4 @@
 #        List of ids with delimiter ','
 #
-#    DetectPosCollision
-#        Check final move position, summon position, etc for visible collision with other objects or 
-#        wall (wall only if vmaps are enabled)
-#        Default: 1 (enable, required more CPU power usage)
-#                 0 (disable, less nice position selection but will less CPU power usage)
 #
 #    TargetPosRecalculateRange
@@ -180,5 +175,4 @@
 vmap.ignoreMapIds = "369"
 vmap.ignoreSpellIds = "7720"
-DetectPosCollision = 1
 TargetPosRecalculateRange = 1.5
 UpdateUptimeInterval = 10
@@ -1054,2 +1048,29 @@
 
 BattleGround.PrematureFinishTimer = 0
+
+###################################################################################################################
+# 
+# Network config 
+#
+# Threads: number of threads for network ,recommend 1 thread per 1000 players.
+#         Default: 1
+#
+# OutKBuff: the output kernel buffer used ( SO_SNDBUF socket option ) , -1 means use system default. Refer to tcp manual for explanation.
+#         Default: -1
+#
+# OutUBuff: userspace buffer for output
+#         Default: 65536
+#
+# TcpNodelay: enable ( 1 ) , disable ( 0 ) ,TCP_NODELAY socket option. Refer to tcp manual for explanation.
+#         Default: 1
+#
+#     
+#
+###################################################################################################################
+
+Network.Threads = 1
+Network.OutKBuff = -1
+Network.OutUBuff = 65536
+Network.TcpNodelay = 1
+
+
