mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
*Fix Linux build. Patch by panaut0lordv.
--HG-- branch : trunk
This commit is contained in:
@@ -361,7 +361,7 @@ AC_CONFIG_FILES([
|
||||
src/mangosd/Makefile
|
||||
src/mangosd/mangosd.conf.dist
|
||||
src/bindings/Makefile
|
||||
src/bindings/interface/Makefile
|
||||
src/bindings/scripts/Makefile
|
||||
])
|
||||
|
||||
## Configure ACE, if needed
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
# interface folder is disabled for now
|
||||
|
||||
if USE_TSCRIPTS
|
||||
#if USE_TSCRIPTS
|
||||
SUBDIRS = scripts
|
||||
else
|
||||
SUBDIRS = interface
|
||||
endif
|
||||
#else
|
||||
#SUBDIRS = interface
|
||||
#endif
|
||||
|
||||
@@ -92,6 +92,8 @@ libmangosgame_a_SOURCES = \
|
||||
CreatureAIRegistry.h \
|
||||
CreatureAISelector.cpp \
|
||||
CreatureAISelector.h \
|
||||
CreatureGroups.cpp \
|
||||
CreatureGroups.h \
|
||||
Creature.cpp \
|
||||
Creature.h \
|
||||
debugcmds.cpp \
|
||||
@@ -110,9 +112,6 @@ libmangosgame_a_SOURCES = \
|
||||
GameObject.h \
|
||||
GlobalEvents.cpp \
|
||||
GlobalEvents.h \
|
||||
GMTicketHandler.cpp \
|
||||
GMTicketMgr.cpp \
|
||||
GMTicketMgr.h \
|
||||
GossipDef.cpp \
|
||||
GossipDef.h \
|
||||
GridDefines.h \
|
||||
@@ -188,6 +187,24 @@ libmangosgame_a_SOURCES = \
|
||||
ObjectPosSelector.h \
|
||||
Opcodes.cpp \
|
||||
Opcodes.h \
|
||||
OutdoorPvP.cpp \
|
||||
OutdoorPvP.h \
|
||||
OutdoorPvPEP.cpp \
|
||||
OutdoorPvPEP.h \
|
||||
OutdoorPvPHP.cpp \
|
||||
OutdoorPvPHP.h \
|
||||
OutdoorPvPMgr.cpp \
|
||||
OutdoorPvPMgr.h \
|
||||
OutdoorPvPNA.cpp \
|
||||
OutdoorPvPNA.h \
|
||||
OutdoorPvPObjectiveAI.cpp \
|
||||
OutdoorPvPObjectiveAI.h \
|
||||
OutdoorPvPSI.cpp \
|
||||
OutdoorPvPSI.h \
|
||||
OutdoorPvPTF.cpp \
|
||||
OutdoorPvPTF.h \
|
||||
OutdoorPvPZM.cpp \
|
||||
OutdoorPvPZM.h \
|
||||
Path.h \
|
||||
PetAI.cpp \
|
||||
PetAI.h \
|
||||
@@ -199,6 +216,8 @@ libmangosgame_a_SOURCES = \
|
||||
Player.h \
|
||||
PlayerDump.cpp \
|
||||
PlayerDump.h \
|
||||
PossessedAI.cpp \
|
||||
PossessedAI.h \
|
||||
PointMovementGenerator.cpp \
|
||||
PointMovementGenerator.h \
|
||||
QueryHandler.cpp \
|
||||
@@ -243,6 +262,9 @@ libmangosgame_a_SOURCES = \
|
||||
Transports.h \
|
||||
ThreatManager.cpp \
|
||||
ThreatManager.h \
|
||||
TicketHandler.cpp \
|
||||
TicketMgr.cpp \
|
||||
TicketMgr.h \
|
||||
Traveller.h \
|
||||
Unit.cpp \
|
||||
Unit.h \
|
||||
|
||||
157
src/game/ObjectPosSelector.cpp
Normal file
157
src/game/ObjectPosSelector.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
155
src/game/ObjectPosSelector.h
Normal file
155
src/game/ObjectPosSelector.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* 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
|
||||
@@ -35,8 +35,8 @@ trinity_worldd_SOURCES = \
|
||||
WorldRunnable.h
|
||||
|
||||
## Link world daemon against the shared library
|
||||
trinity_worldd_LDADD = ../bindings/universal/libmangosscript.la ../game/libmangosgame.a ../shared/Database/libmangosdatabase.a ../shared/Config/libmangosconfig.a ../shared/Auth/libmangosauth.a ../shared/libmangosshared.a ../shared/vmap/libmangosvmaps.a ../framework/libmangosframework.a ../../dep/src/sockets/libmangossockets.a ../../dep/src/zthread/libZThread.la ../../dep/src/g3dlite/libg3dlite.a
|
||||
trinity_worldd_LDFLAGS = -L../../dep/src/sockets -L../../dep/src/zthread -L../../dep/src/g3dlite -L../bindings/universal/ -L$(libdir) $(TRINI_LIBS) -export-dynamic
|
||||
trinity_worldd_LDADD = ../bindings/scripts/libtrinityscript.la ../game/libmangosgame.a ../shared/Database/libmangosdatabase.a ../shared/Config/libmangosconfig.a ../shared/Auth/libmangosauth.a ../shared/libmangosshared.a ../shared/vmap/libmangosvmaps.a ../framework/libmangosframework.a ../../dep/src/sockets/libmangossockets.a ../../dep/src/zthread/libZThread.la ../../dep/src/g3dlite/libg3dlite.a
|
||||
trinity_worldd_LDFLAGS = -L../../dep/src/sockets -L../../dep/src/zthread -L../../dep/src/g3dlite -L../bindings/scripts/ -L$(libdir) $(TRINI_LIBS) -export-dynamic
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
# Include world daemon configuration
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
# define _REALMD_CONFIG SYSCONFDIR"realmd.conf"
|
||||
#endif
|
||||
|
||||
#define _FULLVERSION(REVD,REVT,REVN,REVH) _PACKAGENAME "/" _VERSION(REVD,REVT,REVN,REVH) " for " _ENDIAN_PLATFORM
|
||||
#define _FULLVERSION "Trinity"
|
||||
|
||||
#define DEFAULT_PLAYER_LIMIT 100
|
||||
#define DEFAULT_WORLDSERVER_PORT 8085 //8129
|
||||
|
||||
Reference in New Issue
Block a user