diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Makefile.am | 2 | ||||
-rw-r--r-- | src/game/Object.cpp | 200 | ||||
-rw-r--r-- | src/game/ObjectPosSelector.cpp | 157 | ||||
-rw-r--r-- | src/game/ObjectPosSelector.h | 155 | ||||
-rw-r--r-- | src/game/World.cpp | 2 | ||||
-rw-r--r-- | src/game/World.h | 1 | ||||
-rw-r--r-- | src/trinitycore/trinitycore.conf.dist | 33 |
7 files changed, 30 insertions, 520 deletions
diff --git a/src/game/Makefile.am b/src/game/Makefile.am index 7d0180931b8..277f424d938 100644 --- a/src/game/Makefile.am +++ b/src/game/Makefile.am @@ -182,8 +182,6 @@ $(srcdir)/ObjectGridLoader.h \ $(srcdir)/Object.h \ $(srcdir)/ObjectMgr.cpp \ $(srcdir)/ObjectMgr.h \ -$(srcdir)/ObjectPosSelector.cpp \ -$(srcdir)/ObjectPosSelector.h \ $(srcdir)/Opcodes.cpp \ $(srcdir)/Opcodes.h \ $(srcdir)/Path.h \ diff --git a/src/game/Object.cpp b/src/game/Object.cpp index fd6411afc07..7266d5612e7 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -41,8 +41,6 @@ #include "GridNotifiers.h" #include "GridNotifiersImpl.h" -#include "ObjectPosSelector.h" - #include "TemporarySummon.h" uint32 GuidHigh2TypeId(uint32 guid_hi) @@ -1430,84 +1428,6 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa return pCreature; } -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 { x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle); @@ -1520,122 +1440,8 @@ void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float abs void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle ) const { 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); } diff --git a/src/game/ObjectPosSelector.cpp b/src/game/ObjectPosSelector.cpp deleted file mode 100644 index 5936152f9be..00000000000 --- a/src/game/ObjectPosSelector.cpp +++ /dev/null @@ -1,157 +0,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; -} diff --git a/src/game/ObjectPosSelector.h b/src/game/ObjectPosSelector.h deleted file mode 100644 index 7423c0a741c..00000000000 --- a/src/game/ObjectPosSelector.h +++ /dev/null @@ -1,155 +0,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 diff --git a/src/game/World.cpp b/src/game/World.cpp index caf64405310..9ce6888a08a 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -739,8 +739,6 @@ void World::LoadConfigSettings(bool reload) if(m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > 255)
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);
diff --git a/src/game/World.h b/src/game/World.h index c42779be4bb..fd15391405a 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -137,7 +137,6 @@ enum WorldConfigs CONFIG_WORLD_BOSS_LEVEL_DIFF, 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, CONFIG_TALENTS_INSPECTING, diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist index 45002de76aa..2c94b21b3ed 100644 --- a/src/trinitycore/trinitycore.conf.dist +++ b/src/trinitycore/trinitycore.conf.dist @@ -133,11 +133,6 @@ BindIP = "0.0.0.0" # These spells are ignored for LoS calculation # 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 # Max distance from movement target point (+moving unit size) and targeted object (+size) @@ -179,7 +174,6 @@ vmap.enableLOS = 0 vmap.enableHeight = 0 vmap.ignoreMapIds = "369" vmap.ignoreSpellIds = "7720" -DetectPosCollision = 1 TargetPosRecalculateRange = 1.5 UpdateUptimeInterval = 10 MaxCoreStuckTime = 0 @@ -1053,3 +1047,30 @@ Arena.AutoDistributeInterval = 7 ################################################################################################################### 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 + + |