Various Cleanups (game C-E)

This commit is contained in:
Schmoozerd 2012-07-19 21:45:58 +02:00
parent f80629e307
commit c5c09cee3c
40 changed files with 1826 additions and 1818 deletions

View file

@ -24,7 +24,7 @@
#include "Opcodes.h" #include "Opcodes.h"
#include "MapPersistentStateMgr.h" #include "MapPersistentStateMgr.h"
void WorldSession::HandleCalendarGetCalendar(WorldPacket &/*recv_data*/) void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_CALENDAR"); // empty DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_CALENDAR"); // empty
@ -44,13 +44,13 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &/*recv_data*/)
size_t p_counter = data.wpos(); size_t p_counter = data.wpos();
data << uint32(counter); // instance state count data << uint32(counter); // instance state count
for(int i = 0; i < MAX_DIFFICULTY; ++i) for (int i = 0; i < MAX_DIFFICULTY; ++i)
{ {
for (Player::BoundInstancesMap::const_iterator itr = _player->m_boundInstances[i].begin(); itr != _player->m_boundInstances[i].end(); ++itr) for (Player::BoundInstancesMap::const_iterator itr = _player->m_boundInstances[i].begin(); itr != _player->m_boundInstances[i].end(); ++itr)
{ {
if(itr->second.perm) if (itr->second.perm)
{ {
DungeonPersistentState *state = itr->second.state; DungeonPersistentState* state = itr->second.state;
data << uint32(state->GetMapId()); data << uint32(state->GetMapId());
data << uint32(state->GetDifficulty()); data << uint32(state->GetDifficulty());
data << uint32(state->GetResetTime() - cur_time); data << uint32(state->GetResetTime() - cur_time);
@ -64,40 +64,40 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &/*recv_data*/)
data << (uint32) 1135753200; // base date (28.12.2005 12:00) data << (uint32) 1135753200; // base date (28.12.2005 12:00)
data << (uint32) 0; // raid reset count data << (uint32) 0; // raid reset count
data << (uint32) 0; // holidays count data << (uint32) 0; // holidays count
/* /*
for(uint32 i = 0; i < holidays_count; ++i) for(uint32 i = 0; i < holidays_count; ++i)
{ {
data << uint32(0); // Holidays.dbc ID data << uint32(0); // Holidays.dbc ID
data << uint32(0); // Holidays.dbc region data << uint32(0); // Holidays.dbc region
data << uint32(0); // Holidays.dbc looping data << uint32(0); // Holidays.dbc looping
data << uint32(0); // Holidays.dbc priority data << uint32(0); // Holidays.dbc priority
data << uint32(0); // Holidays.dbc calendarFilterType data << uint32(0); // Holidays.dbc calendarFilterType
for(uint32 j = 0; j < 26; j++) for(uint32 j = 0; j < 26; j++)
data << uint32(0); // Holidays.dbc date data << uint32(0); // Holidays.dbc date
for(uint32 j = 0; j < 10; j++) for(uint32 j = 0; j < 10; j++)
data << uint32(0); // Holidays.dbc duration data << uint32(0); // Holidays.dbc duration
for(uint32 j = 0; j < 10; j++) for(uint32 j = 0; j < 10; j++)
data << uint32(0); // Holidays.dbc calendarFlags data << uint32(0); // Holidays.dbc calendarFlags
data << ""; // Holidays.dbc textureFilename data << ""; // Holidays.dbc textureFilename
} }
*/ */
//DEBUG_LOG("Sending calendar"); //DEBUG_LOG("Sending calendar");
//data.hexlike(); //data.hexlike();
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleCalendarGetEvent(WorldPacket &recv_data) void WorldSession::HandleCalendarGetEvent(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_EVENT"); DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_EVENT");
recv_data.hexlike(); recv_data.hexlike();
recv_data.read_skip<uint64>(); // unk recv_data.read_skip<uint64>(); // unk
} }
void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data) void WorldSession::HandleCalendarGuildFilter(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_GUILD_FILTER"); DEBUG_LOG("WORLD: CMSG_CALENDAR_GUILD_FILTER");
recv_data.hexlike(); recv_data.hexlike();
@ -106,14 +106,14 @@ void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data)
recv_data.read_skip<uint32>(); // unk3 recv_data.read_skip<uint32>(); // unk3
} }
void WorldSession::HandleCalendarArenaTeam(WorldPacket &recv_data) void WorldSession::HandleCalendarArenaTeam(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_ARENA_TEAM"); DEBUG_LOG("WORLD: CMSG_CALENDAR_ARENA_TEAM");
recv_data.hexlike(); recv_data.hexlike();
recv_data.read_skip<uint32>(); // unk recv_data.read_skip<uint32>(); // unk
} }
void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data) void WorldSession::HandleCalendarAddEvent(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_ADD_EVENT"); DEBUG_LOG("WORLD: CMSG_CALENDAR_ADD_EVENT");
recv_data.hexlike(); recv_data.hexlike();
@ -149,7 +149,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data)
//} //}
} }
void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data) void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_UPDATE_EVENT"); DEBUG_LOG("WORLD: CMSG_CALENDAR_UPDATE_EVENT");
recv_data.hexlike(); recv_data.hexlike();
@ -168,7 +168,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data)
//recv_data >> uint32 //recv_data >> uint32
} }
void WorldSession::HandleCalendarRemoveEvent(WorldPacket &recv_data) void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_REMOVE_EVENT"); DEBUG_LOG("WORLD: CMSG_CALENDAR_REMOVE_EVENT");
recv_data.hexlike(); recv_data.hexlike();
@ -180,7 +180,7 @@ void WorldSession::HandleCalendarRemoveEvent(WorldPacket &recv_data)
} }
void WorldSession::HandleCalendarCopyEvent(WorldPacket &recv_data) void WorldSession::HandleCalendarCopyEvent(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_COPY_EVENT"); DEBUG_LOG("WORLD: CMSG_CALENDAR_COPY_EVENT");
recv_data.hexlike(); recv_data.hexlike();
@ -192,7 +192,7 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket &recv_data)
} }
void WorldSession::HandleCalendarEventInvite(WorldPacket &recv_data) void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_INVITE"); DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_INVITE");
recv_data.hexlike(); recv_data.hexlike();
@ -206,7 +206,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket &recv_data)
} }
void WorldSession::HandleCalendarEventRsvp(WorldPacket &recv_data) void WorldSession::HandleCalendarEventRsvp(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_RSVP"); DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_RSVP");
recv_data.hexlike(); recv_data.hexlike();
@ -217,7 +217,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket &recv_data)
//recv_data >> uint32 //recv_data >> uint32
} }
void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data) void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_REMOVE_INVITE"); DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_REMOVE_INVITE");
recv_data.hexlike(); recv_data.hexlike();
@ -229,7 +229,7 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data)
//recv_data >> uint64 //recv_data >> uint64
} }
void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data) void WorldSession::HandleCalendarEventStatus(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_STATUS"); DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_STATUS");
recv_data.hexlike(); recv_data.hexlike();
@ -242,7 +242,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data)
//recv_data >> uint32 //recv_data >> uint32
} }
void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data) void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_MODERATOR_STATUS"); DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_MODERATOR_STATUS");
recv_data.hexlike(); recv_data.hexlike();
@ -255,7 +255,7 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data)
//recv_data >> uint32 //recv_data >> uint32
} }
void WorldSession::HandleCalendarComplain(WorldPacket &recv_data) void WorldSession::HandleCalendarComplain(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_COMPLAIN"); DEBUG_LOG("WORLD: CMSG_CALENDAR_COMPLAIN");
recv_data.hexlike(); recv_data.hexlike();
@ -266,7 +266,7 @@ void WorldSession::HandleCalendarComplain(WorldPacket &recv_data)
//recv_data >> uint64 //recv_data >> uint64
} }
void WorldSession::HandleCalendarGetNumPending(WorldPacket & /*recv_data*/) void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recv_data*/)
{ {
DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); // empty DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); // empty

View file

@ -37,7 +37,7 @@ Camera::~Camera()
m_source->GetViewPoint().Detach(this); m_source->GetViewPoint().Detach(this);
} }
void Camera::ReceivePacket(WorldPacket *data) void Camera::ReceivePacket(WorldPacket* data)
{ {
m_owner.SendDirectMessage(data); m_owner.SendDirectMessage(data);
} }
@ -52,7 +52,7 @@ void Camera::UpdateForCurrentViewPoint()
UpdateVisibilityForOwner(); UpdateVisibilityForOwner();
} }
void Camera::SetView(WorldObject *obj, bool update_far_sight_field /*= true*/) void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
{ {
MANGOS_ASSERT(obj); MANGOS_ASSERT(obj);
@ -132,16 +132,16 @@ void Camera::UpdateVisibilityOf(WorldObject* target)
} }
template<class T> template<class T>
void Camera::UpdateVisibilityOf(T * target, UpdateData &data, std::set<WorldObject*>& vis) void Camera::UpdateVisibilityOf(T* target, UpdateData& data, std::set<WorldObject*>& vis)
{ {
m_owner.template UpdateVisibilityOf<T>(m_source, target,data,vis); m_owner.template UpdateVisibilityOf<T>(m_source, target,data,vis);
} }
template void Camera::UpdateVisibilityOf(Player* , UpdateData& , std::set<WorldObject*>& ); template void Camera::UpdateVisibilityOf(Player* , UpdateData& , std::set<WorldObject*>&);
template void Camera::UpdateVisibilityOf(Creature* , UpdateData& , std::set<WorldObject*>& ); template void Camera::UpdateVisibilityOf(Creature* , UpdateData& , std::set<WorldObject*>&);
template void Camera::UpdateVisibilityOf(Corpse* , UpdateData& , std::set<WorldObject*>& ); template void Camera::UpdateVisibilityOf(Corpse* , UpdateData& , std::set<WorldObject*>&);
template void Camera::UpdateVisibilityOf(GameObject* , UpdateData& , std::set<WorldObject*>& ); template void Camera::UpdateVisibilityOf(GameObject* , UpdateData& , std::set<WorldObject*>&);
template void Camera::UpdateVisibilityOf(DynamicObject* , UpdateData& , std::set<WorldObject*>& ); template void Camera::UpdateVisibilityOf(DynamicObject* , UpdateData& , std::set<WorldObject*>&);
void Camera::UpdateVisibilityForOwner() void Camera::UpdateVisibilityForOwner()
{ {

View file

@ -31,7 +31,7 @@ class Player;
/// Camera - object-receiver. Receives broadcast packets from nearby worldobjects, object visibility changes and sends them to client /// Camera - object-receiver. Receives broadcast packets from nearby worldobjects, object visibility changes and sends them to client
class MANGOS_DLL_SPEC Camera class MANGOS_DLL_SPEC Camera
{ {
friend class ViewPoint; friend class ViewPoint;
public: public:
explicit Camera(Player* pl); explicit Camera(Player* pl);
@ -43,16 +43,16 @@ class MANGOS_DLL_SPEC Camera
// set camera's view to any worldobject // set camera's view to any worldobject
// Note: this worldobject must be in same map, in same phase with camera's owner(player) // Note: this worldobject must be in same map, in same phase with camera's owner(player)
// client supports only unit and dynamic objects as farsight objects // client supports only unit and dynamic objects as farsight objects
void SetView(WorldObject *obj, bool update_far_sight_field = true); void SetView(WorldObject* obj, bool update_far_sight_field = true);
// set view to camera's owner // set view to camera's owner
void ResetView(bool update_far_sight_field = true); void ResetView(bool update_far_sight_field = true);
template<class T> template<class T>
void UpdateVisibilityOf(T * obj, UpdateData &d, std::set<WorldObject*>& vis); void UpdateVisibilityOf(T* obj, UpdateData& d, std::set<WorldObject*>& vis);
void UpdateVisibilityOf(WorldObject* obj); void UpdateVisibilityOf(WorldObject* obj);
void ReceivePacket(WorldPacket *data); void ReceivePacket(WorldPacket* data);
// updates visibility of worldobjects around viewpoint for camera's owner // updates visibility of worldobjects around viewpoint for camera's owner
void UpdateVisibilityForOwner(); void UpdateVisibilityForOwner();
@ -79,63 +79,63 @@ class MANGOS_DLL_SPEC Camera
/// Object-observer, notifies farsight object state to cameras that attached to it /// Object-observer, notifies farsight object state to cameras that attached to it
class MANGOS_DLL_SPEC ViewPoint class MANGOS_DLL_SPEC ViewPoint
{ {
friend class Camera; friend class Camera;
typedef std::list<Camera*> CameraList; typedef std::list<Camera*> CameraList;
CameraList m_cameras; CameraList m_cameras;
GridType * m_grid; GridType* m_grid;
void Attach(Camera* c) { m_cameras.push_back(c); } void Attach(Camera* c) { m_cameras.push_back(c); }
void Detach(Camera* c) { m_cameras.remove(c); } void Detach(Camera* c) { m_cameras.remove(c); }
void CameraCall(void (Camera::*handler)()) void CameraCall(void (Camera::*handler)())
{
if (!m_cameras.empty())
{ {
for(CameraList::iterator itr = m_cameras.begin(); itr != m_cameras.end();) if (!m_cameras.empty())
{ {
Camera *c = *(itr++); for (CameraList::iterator itr = m_cameras.begin(); itr != m_cameras.end();)
(c->*handler)(); {
Camera* c = *(itr++);
(c->*handler)();
}
} }
} }
}
public: public:
ViewPoint() : m_grid(0) {} ViewPoint() : m_grid(0) {}
~ViewPoint(); ~ViewPoint();
bool hasViewers() const { return !m_cameras.empty(); } bool hasViewers() const { return !m_cameras.empty(); }
// these events are called when viewpoint changes visibility state // these events are called when viewpoint changes visibility state
void Event_AddedToWorld(GridType *grid) void Event_AddedToWorld(GridType* grid)
{ {
m_grid = grid; m_grid = grid;
CameraCall(&Camera::Event_AddedToWorld); CameraCall(&Camera::Event_AddedToWorld);
} }
void Event_RemovedFromWorld() void Event_RemovedFromWorld()
{ {
m_grid = NULL; m_grid = NULL;
CameraCall(&Camera::Event_RemovedFromWorld); CameraCall(&Camera::Event_RemovedFromWorld);
} }
void Event_GridChanged(GridType *grid) void Event_GridChanged(GridType* grid)
{ {
m_grid = grid; m_grid = grid;
CameraCall(&Camera::Event_Moved); CameraCall(&Camera::Event_Moved);
} }
void Event_ViewPointVisibilityChanged() void Event_ViewPointVisibilityChanged()
{ {
CameraCall(&Camera::Event_ViewPointVisibilityChanged); CameraCall(&Camera::Event_ViewPointVisibilityChanged);
} }
void Call_UpdateVisibilityForOwner() void Call_UpdateVisibilityForOwner()
{ {
CameraCall(&Camera::UpdateVisibilityForOwner); CameraCall(&Camera::UpdateVisibilityForOwner);
} }
}; };
#endif #endif

View file

@ -46,81 +46,81 @@ struct MANGOS_DLL_DECL CellArea
struct MANGOS_DLL_DECL Cell struct MANGOS_DLL_DECL Cell
{ {
Cell() { data.All = 0; } Cell() { data.All = 0; }
Cell(const Cell &cell) { data.All = cell.data.All; } Cell(const Cell& cell) { data.All = cell.data.All; }
explicit Cell(CellPair const& p); explicit Cell(CellPair const& p);
void Compute(uint32 &x, uint32 &y) const void Compute(uint32& x, uint32& y) const
{
x = data.Part.grid_x*MAX_NUMBER_OF_CELLS + data.Part.cell_x;
y = data.Part.grid_y*MAX_NUMBER_OF_CELLS + data.Part.cell_y;
}
bool DiffCell(const Cell &cell) const
{
return( data.Part.cell_x != cell.data.Part.cell_x ||
data.Part.cell_y != cell.data.Part.cell_y );
}
bool DiffGrid(const Cell &cell) const
{
return( data.Part.grid_x != cell.data.Part.grid_x ||
data.Part.grid_y != cell.data.Part.grid_y );
}
uint32 CellX() const { return data.Part.cell_x; }
uint32 CellY() const { return data.Part.cell_y; }
uint32 GridX() const { return data.Part.grid_x; }
uint32 GridY() const { return data.Part.grid_y; }
bool NoCreate() const { return data.Part.nocreate; }
void SetNoCreate() { data.Part.nocreate = 1; }
GridPair gridPair() const { return GridPair(GridX(),GridY()); }
CellPair cellPair() const
{
return CellPair(
data.Part.grid_x*MAX_NUMBER_OF_CELLS+data.Part.cell_x,
data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y);
}
Cell& operator=(const Cell &cell)
{
data.All = cell.data.All;
return *this;
}
bool operator==(const Cell &cell) const { return (data.All == cell.data.All); }
bool operator!=(const Cell &cell) const { return !operator==(cell); }
union
{
struct
{ {
unsigned grid_x : 6; x = data.Part.grid_x*MAX_NUMBER_OF_CELLS + data.Part.cell_x;
unsigned grid_y : 6; y = data.Part.grid_y*MAX_NUMBER_OF_CELLS + data.Part.cell_y;
unsigned cell_x : 6; }
unsigned cell_y : 6;
unsigned nocreate : 1;
unsigned reserved : 7;
} Part;
uint32 All;
} data;
template<class T, class CONTAINER> void Visit(const CellPair &cellPair, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float x, float y, float radius) const; bool DiffCell(const Cell& cell) const
template<class T, class CONTAINER> void Visit(const CellPair &cellPair, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject& obj, float radius) const; {
return(data.Part.cell_x != cell.data.Part.cell_x ||
data.Part.cell_y != cell.data.Part.cell_y);
}
static CellArea CalculateCellArea(float x, float y, float radius); bool DiffGrid(const Cell& cell) const
{
return(data.Part.grid_x != cell.data.Part.grid_x ||
data.Part.grid_y != cell.data.Part.grid_y);
}
template<class T> static void VisitGridObjects(const WorldObject *obj, T &visitor, float radius, bool dont_load = true); uint32 CellX() const { return data.Part.cell_x; }
template<class T> static void VisitWorldObjects(const WorldObject *obj, T &visitor, float radius, bool dont_load = true); uint32 CellY() const { return data.Part.cell_y; }
template<class T> static void VisitAllObjects(const WorldObject *obj, T &visitor, float radius, bool dont_load = true); uint32 GridX() const { return data.Part.grid_x; }
uint32 GridY() const { return data.Part.grid_y; }
bool NoCreate() const { return data.Part.nocreate; }
void SetNoCreate() { data.Part.nocreate = 1; }
template<class T> static void VisitGridObjects(float x, float y, Map *map, T &visitor, float radius, bool dont_load = true); GridPair gridPair() const { return GridPair(GridX(),GridY()); }
template<class T> static void VisitWorldObjects(float x, float y, Map *map, T &visitor, float radius, bool dont_load = true);
template<class T> static void VisitAllObjects(float x, float y, Map *map, T &visitor, float radius, bool dont_load = true);
private: CellPair cellPair() const
template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, const CellPair& , const CellPair& ) const; {
return CellPair(
data.Part.grid_x*MAX_NUMBER_OF_CELLS+data.Part.cell_x,
data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y);
}
Cell& operator=(const Cell& cell)
{
data.All = cell.data.All;
return *this;
}
bool operator==(const Cell& cell) const { return (data.All == cell.data.All); }
bool operator!=(const Cell& cell) const { return !operator==(cell); }
union
{
struct
{
unsigned grid_x : 6;
unsigned grid_y : 6;
unsigned cell_x : 6;
unsigned cell_y : 6;
unsigned nocreate : 1;
unsigned reserved : 7;
} Part;
uint32 All;
} data;
template<class T, class CONTAINER> void Visit(const CellPair& cellPair, TypeContainerVisitor<T, CONTAINER>& visitor, Map& m, float x, float y, float radius) const;
template<class T, class CONTAINER> void Visit(const CellPair& cellPair, TypeContainerVisitor<T, CONTAINER>& visitor, Map& m, const WorldObject& obj, float radius) const;
static CellArea CalculateCellArea(float x, float y, float radius);
template<class T> static void VisitGridObjects(const WorldObject* obj, T& visitor, float radius, bool dont_load = true);
template<class T> static void VisitWorldObjects(const WorldObject* obj, T& visitor, float radius, bool dont_load = true);
template<class T> static void VisitAllObjects(const WorldObject* obj, T& visitor, float radius, bool dont_load = true);
template<class T> static void VisitGridObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true);
template<class T> static void VisitWorldObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true);
template<class T> static void VisitAllObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true);
private:
template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER>&, Map&, const CellPair& , const CellPair&) const;
}; };
#endif #endif

View file

@ -43,15 +43,15 @@ inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
} }
return CellArea return CellArea
( (
MaNGOS::ComputeCellPair(x - radius, y - radius).normalize(), MaNGOS::ComputeCellPair(x - radius, y - radius).normalize(),
MaNGOS::ComputeCellPair(x + radius, y + radius).normalize() MaNGOS::ComputeCellPair(x + radius, y + radius).normalize()
); );
} }
template<class T, class CONTAINER> template<class T, class CONTAINER>
inline void inline void
Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const WorldObject& obj, float radius) const Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& m, const WorldObject& obj, float radius) const
{ {
Cell::Visit(standing_cell, visitor, m, obj.GetPositionX(), obj.GetPositionY(), radius + obj.GetObjectBoundingRadius()); Cell::Visit(standing_cell, visitor, m, obj.GetPositionX(), obj.GetPositionY(), radius + obj.GetObjectBoundingRadius());
} }
@ -59,7 +59,7 @@ Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &v
template<class T, class CONTAINER> template<class T, class CONTAINER>
inline void inline void
Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float x, float y, float radius) const Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor<T, CONTAINER>& visitor, Map& m, float x, float y, float radius) const
{ {
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
return; return;
@ -67,31 +67,31 @@ Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &v
//no jokes here... Actually placing ASSERT() here was good idea, but //no jokes here... Actually placing ASSERT() here was good idea, but
//we had some problems with DynamicObjects, which pass radius = 0.0f (DB issue?) //we had some problems with DynamicObjects, which pass radius = 0.0f (DB issue?)
//maybe it is better to just return when radius <= 0.0f? //maybe it is better to just return when radius <= 0.0f?
if(radius <= 0.0f) if (radius <= 0.0f)
{ {
m.Visit(*this, visitor); m.Visit(*this, visitor);
return; return;
} }
//lets limit the upper value for search radius //lets limit the upper value for search radius
if(radius > 333.0f) if (radius > 333.0f)
radius = 333.0f; radius = 333.0f;
//lets calculate object coord offsets from cell borders. //lets calculate object coord offsets from cell borders.
CellArea area = Cell::CalculateCellArea(x, y, radius); CellArea area = Cell::CalculateCellArea(x, y, radius);
//if radius fits inside standing cell //if radius fits inside standing cell
if(!area) if (!area)
{ {
m.Visit(*this, visitor); m.Visit(*this, visitor);
return; return;
} }
CellPair &begin_cell = area.low_bound; CellPair& begin_cell = area.low_bound;
CellPair &end_cell = area.high_bound; CellPair& end_cell = area.high_bound;
//visit all cells, found in CalculateCellArea() //visit all cells, found in CalculateCellArea()
//if radius is known to reach cell area more than 4x4 then we should call optimized VisitCircle //if radius is known to reach cell area more than 4x4 then we should call optimized VisitCircle
//currently this technique works with MAX_NUMBER_OF_CELLS 16 and higher, with lower values //currently this technique works with MAX_NUMBER_OF_CELLS 16 and higher, with lower values
//there are nothing to optimize because SIZE_OF_GRID_CELL is too big... //there are nothing to optimize because SIZE_OF_GRID_CELL is too big...
if(((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4)) if (((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4))
{ {
VisitCircle(visitor, m, begin_cell, end_cell); VisitCircle(visitor, m, begin_cell, end_cell);
return; return;
@ -102,13 +102,13 @@ Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &v
m.Visit(*this, visitor); m.Visit(*this, visitor);
// loop the cell range // loop the cell range
for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++) for (uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
{ {
for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++) for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
{ {
CellPair cell_pair(x,y); CellPair cell_pair(x,y);
//lets skip standing cell since we already visited it //lets skip standing cell since we already visited it
if(cell_pair != standing_cell) if (cell_pair != standing_cell)
{ {
Cell r_zone(cell_pair); Cell r_zone(cell_pair);
r_zone.data.Part.nocreate = data.Part.nocreate; r_zone.data.Part.nocreate = data.Part.nocreate;
@ -120,7 +120,7 @@ Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &v
template<class T, class CONTAINER> template<class T, class CONTAINER>
inline void inline void
Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER>& visitor, Map& m, const CellPair& begin_cell, const CellPair& end_cell) const
{ {
//here is an algorithm for 'filling' circum-squared octagon //here is an algorithm for 'filling' circum-squared octagon
uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f); uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f);
@ -129,9 +129,9 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
const uint32 x_end = end_cell.x_coord - x_shift; const uint32 x_end = end_cell.x_coord - x_shift;
//visit central strip with constant width... //visit central strip with constant width...
for(uint32 x = x_start; x <= x_end; ++x) for (uint32 x = x_start; x <= x_end; ++x)
{ {
for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
{ {
CellPair cell_pair(x,y); CellPair cell_pair(x,y);
Cell r_zone(cell_pair); Cell r_zone(cell_pair);
@ -142,7 +142,7 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
//if x_shift == 0 then we have too small cell area, which were already //if x_shift == 0 then we have too small cell area, which were already
//visited at previous step, so just return from procedure... //visited at previous step, so just return from procedure...
if(x_shift == 0) if (x_shift == 0)
return; return;
uint32 y_start = end_cell.y_coord; uint32 y_start = end_cell.y_coord;
@ -172,7 +172,7 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
} }
template<class T> template<class T>
inline void Cell::VisitGridObjects(const WorldObject *center_obj, T &visitor, float radius, bool dont_load) inline void Cell::VisitGridObjects(const WorldObject* center_obj, T& visitor, float radius, bool dont_load)
{ {
CellPair p(MaNGOS::ComputeCellPair(center_obj->GetPositionX(), center_obj->GetPositionY())); CellPair p(MaNGOS::ComputeCellPair(center_obj->GetPositionX(), center_obj->GetPositionY()));
Cell cell(p); Cell cell(p);
@ -183,7 +183,7 @@ inline void Cell::VisitGridObjects(const WorldObject *center_obj, T &visitor, fl
} }
template<class T> template<class T>
inline void Cell::VisitWorldObjects(const WorldObject *center_obj, T &visitor, float radius, bool dont_load) inline void Cell::VisitWorldObjects(const WorldObject* center_obj, T& visitor, float radius, bool dont_load)
{ {
CellPair p(MaNGOS::ComputeCellPair(center_obj->GetPositionX(), center_obj->GetPositionY())); CellPair p(MaNGOS::ComputeCellPair(center_obj->GetPositionX(), center_obj->GetPositionY()));
Cell cell(p); Cell cell(p);
@ -194,7 +194,7 @@ inline void Cell::VisitWorldObjects(const WorldObject *center_obj, T &visitor, f
} }
template<class T> template<class T>
inline void Cell::VisitAllObjects(const WorldObject *center_obj, T &visitor, float radius, bool dont_load) inline void Cell::VisitAllObjects(const WorldObject* center_obj, T& visitor, float radius, bool dont_load)
{ {
CellPair p(MaNGOS::ComputeCellPair(center_obj->GetPositionX(), center_obj->GetPositionY())); CellPair p(MaNGOS::ComputeCellPair(center_obj->GetPositionX(), center_obj->GetPositionY()));
Cell cell(p); Cell cell(p);
@ -207,7 +207,7 @@ inline void Cell::VisitAllObjects(const WorldObject *center_obj, T &visitor, flo
} }
template<class T> template<class T>
inline void Cell::VisitGridObjects(float x, float y, Map *map, T &visitor, float radius, bool dont_load) inline void Cell::VisitGridObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load)
{ {
CellPair p(MaNGOS::ComputeCellPair(x, y)); CellPair p(MaNGOS::ComputeCellPair(x, y));
Cell cell(p); Cell cell(p);
@ -218,7 +218,7 @@ inline void Cell::VisitGridObjects(float x, float y, Map *map, T &visitor, float
} }
template<class T> template<class T>
inline void Cell::VisitWorldObjects(float x, float y, Map *map, T &visitor, float radius, bool dont_load) inline void Cell::VisitWorldObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load)
{ {
CellPair p(MaNGOS::ComputeCellPair(x, y)); CellPair p(MaNGOS::ComputeCellPair(x, y));
Cell cell(p); Cell cell(p);
@ -229,7 +229,7 @@ inline void Cell::VisitWorldObjects(float x, float y, Map *map, T &visitor, floa
} }
template<class T> template<class T>
inline void Cell::VisitAllObjects(float x, float y, Map *map, T &visitor, float radius, bool dont_load) inline void Cell::VisitAllObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load)
{ {
CellPair p(MaNGOS::ComputeCellPair(x, y)); CellPair p(MaNGOS::ComputeCellPair(x, y));
Cell cell(p); Cell cell(p);

View file

@ -22,24 +22,24 @@
#include "SocialMgr.h" #include "SocialMgr.h"
Channel::Channel(const std::string& name, uint32 channel_id) Channel::Channel(const std::string& name, uint32 channel_id)
: m_announce(true), m_moderate(false), m_name(name), m_flags(0), m_channelId(channel_id) : m_announce(true), m_moderate(false), m_name(name), m_flags(0), m_channelId(channel_id)
{ {
// set special flags if built-in channel // set special flags if built-in channel
ChatChannelsEntry const* ch = GetChannelEntryFor(channel_id); ChatChannelsEntry const* ch = GetChannelEntryFor(channel_id);
if(ch) // it's built-in channel if (ch) // it's built-in channel
{ {
channel_id = ch->ChannelID; // built-in channel channel_id = ch->ChannelID; // built-in channel
m_announce = false; // no join/leave announces m_announce = false; // no join/leave announces
m_flags |= CHANNEL_FLAG_GENERAL; // for all built-in channels m_flags |= CHANNEL_FLAG_GENERAL; // for all built-in channels
if(ch->flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel if (ch->flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel
m_flags |= CHANNEL_FLAG_TRADE; m_flags |= CHANNEL_FLAG_TRADE;
if(ch->flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels if (ch->flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels
m_flags |= CHANNEL_FLAG_CITY; m_flags |= CHANNEL_FLAG_CITY;
if(ch->flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel if (ch->flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel
m_flags |= CHANNEL_FLAG_LFG; m_flags |= CHANNEL_FLAG_LFG;
else // for all other channels else // for all other channels
m_flags |= CHANNEL_FLAG_NOT_LFG; m_flags |= CHANNEL_FLAG_NOT_LFG;
@ -50,12 +50,12 @@ Channel::Channel(const std::string& name, uint32 channel_id)
} }
} }
void Channel::Join(ObjectGuid p, const char *pass) void Channel::Join(ObjectGuid p, const char* pass)
{ {
WorldPacket data; WorldPacket data;
if (IsOn(p)) if (IsOn(p))
{ {
if(!IsConstant()) // non send error message for built-in channels if (!IsConstant()) // non send error message for built-in channels
{ {
MakePlayerAlreadyMember(&data, p); MakePlayerAlreadyMember(&data, p);
SendToOne(&data, p); SendToOne(&data, p);
@ -70,31 +70,31 @@ void Channel::Join(ObjectGuid p, const char *pass)
return; return;
} }
if(m_password.length() > 0 && strcmp(pass, m_password.c_str())) if (m_password.length() > 0 && strcmp(pass, m_password.c_str()))
{ {
MakeWrongPassword(&data); MakeWrongPassword(&data);
SendToOne(&data, p); SendToOne(&data, p);
return; return;
} }
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if(plr) if (plr)
{ {
if(HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER ) if (HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER)
{ {
MakeNotInLfg(&data); MakeNotInLfg(&data);
SendToOne(&data, p); SendToOne(&data, p);
return; return;
} }
if(plr->GetGuildId() && (GetFlags() == 0x38)) if (plr->GetGuildId() && (GetFlags() == 0x38))
return; return;
plr->JoinedChannel(this); plr->JoinedChannel(this);
} }
if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL) )) if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL)))
{ {
MakeJoined(&data, p); MakeJoined(&data, p);
SendToAll(&data); SendToAll(&data);
@ -112,7 +112,7 @@ void Channel::Join(ObjectGuid p, const char *pass)
JoinNotify(p); JoinNotify(p);
// if no owner first logged will become // if no owner first logged will become
if(!IsConstant() && !m_ownerGuid) if (!IsConstant() && !m_ownerGuid)
{ {
SetOwner(p, (m_players.size() > 1 ? true : false)); SetOwner(p, (m_players.size() > 1 ? true : false));
m_players[p].SetModerator(true); m_players[p].SetModerator(true);
@ -123,7 +123,7 @@ void Channel::Leave(ObjectGuid p, bool send)
{ {
if (!IsOn(p)) if (!IsOn(p))
{ {
if(send) if (send)
{ {
WorldPacket data; WorldPacket data;
MakeNotMember(&data); MakeNotMember(&data);
@ -132,14 +132,14 @@ void Channel::Leave(ObjectGuid p, bool send)
} }
else else
{ {
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if(send) if (send)
{ {
WorldPacket data; WorldPacket data;
MakeYouLeft(&data); MakeYouLeft(&data);
SendToOne(&data, p); SendToOne(&data, p);
if(plr) if (plr)
plr->LeftChannel(this); plr->LeftChannel(this);
data.clear(); data.clear();
} }
@ -147,7 +147,7 @@ void Channel::Leave(ObjectGuid p, bool send)
bool changeowner = m_players[p].IsOwner(); bool changeowner = m_players[p].IsOwner();
m_players.erase(p); m_players.erase(p);
if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL) )) if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL)))
{ {
WorldPacket data; WorldPacket data;
MakeLeft(&data, p); MakeLeft(&data, p);
@ -156,7 +156,7 @@ void Channel::Leave(ObjectGuid p, bool send)
LeaveNotify(p); LeaveNotify(p);
if(changeowner) if (changeowner)
{ {
ObjectGuid newowner = !m_players.empty() ? m_players.begin()->second.player : ObjectGuid(); ObjectGuid newowner = !m_players.empty() ? m_players.begin()->second.player : ObjectGuid();
SetOwner(newowner); SetOwner(newowner);
@ -164,10 +164,10 @@ void Channel::Leave(ObjectGuid p, bool send)
} }
} }
void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban) void Channel::KickOrBan(ObjectGuid good, const char* badname, bool ban)
{ {
AccountTypes sec = SEC_PLAYER; AccountTypes sec = SEC_PLAYER;
Player *gplr = sObjectMgr.GetPlayer(good); Player* gplr = sObjectMgr.GetPlayer(good);
if (gplr) if (gplr)
sec = gplr->GetSession()->GetSecurity(); sec = gplr->GetSession()->GetSecurity();
@ -185,7 +185,7 @@ void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban)
} }
else else
{ {
Player *bad = sObjectMgr.GetPlayer(badname); Player* bad = sObjectMgr.GetPlayer(badname);
if (bad == NULL || !IsOn(bad->GetObjectGuid())) if (bad == NULL || !IsOn(bad->GetObjectGuid()))
{ {
WorldPacket data; WorldPacket data;
@ -204,7 +204,7 @@ void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban)
WorldPacket data; WorldPacket data;
if(ban && !IsBanned(bad->GetObjectGuid())) if (ban && !IsBanned(bad->GetObjectGuid()))
{ {
m_banned.insert(bad->GetObjectGuid()); m_banned.insert(bad->GetObjectGuid());
MakePlayerBanned(&data, bad->GetObjectGuid(), good); MakePlayerBanned(&data, bad->GetObjectGuid(), good);
@ -216,7 +216,7 @@ void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban)
m_players.erase(bad->GetObjectGuid()); m_players.erase(bad->GetObjectGuid());
bad->LeftChannel(this); bad->LeftChannel(this);
if(changeowner) if (changeowner)
{ {
ObjectGuid newowner = !m_players.empty() ? good : ObjectGuid(); ObjectGuid newowner = !m_players.empty() ? good : ObjectGuid();
SetOwner(newowner); SetOwner(newowner);
@ -225,11 +225,11 @@ void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban)
} }
} }
void Channel::UnBan(ObjectGuid good, const char *badname) void Channel::UnBan(ObjectGuid good, const char* badname)
{ {
uint32 sec = 0; uint32 sec = 0;
Player *gplr = sObjectMgr.GetPlayer(good); Player* gplr = sObjectMgr.GetPlayer(good);
if(gplr) if (gplr)
sec = gplr->GetSession()->GetSecurity(); sec = gplr->GetSession()->GetSecurity();
if (!IsOn(good)) if (!IsOn(good))
@ -238,7 +238,7 @@ void Channel::UnBan(ObjectGuid good, const char *badname)
MakeNotMember(&data); MakeNotMember(&data);
SendToOne(&data, good); SendToOne(&data, good);
} }
else if(!m_players[good].IsModerator() && sec < SEC_GAMEMASTER) else if (!m_players[good].IsModerator() && sec < SEC_GAMEMASTER)
{ {
WorldPacket data; WorldPacket data;
MakeNotModerator(&data); MakeNotModerator(&data);
@ -246,8 +246,8 @@ void Channel::UnBan(ObjectGuid good, const char *badname)
} }
else else
{ {
Player *bad = sObjectMgr.GetPlayer(badname); Player* bad = sObjectMgr.GetPlayer(badname);
if(bad == NULL || !IsBanned(bad->GetObjectGuid())) if (bad == NULL || !IsBanned(bad->GetObjectGuid()))
{ {
WorldPacket data; WorldPacket data;
MakePlayerNotFound(&data, badname); MakePlayerNotFound(&data, badname);
@ -264,10 +264,10 @@ void Channel::UnBan(ObjectGuid good, const char *badname)
} }
} }
void Channel::Password(ObjectGuid p, const char *pass) void Channel::Password(ObjectGuid p, const char* pass)
{ {
uint32 sec = 0; uint32 sec = 0;
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if (plr) if (plr)
sec = plr->GetSession()->GetSecurity(); sec = plr->GetSession()->GetSecurity();
@ -277,7 +277,7 @@ void Channel::Password(ObjectGuid p, const char *pass)
MakeNotMember(&data); MakeNotMember(&data);
SendToOne(&data, p); SendToOne(&data, p);
} }
else if(!m_players[p].IsModerator() && sec < SEC_GAMEMASTER) else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
{ {
WorldPacket data; WorldPacket data;
MakeNotModerator(&data); MakeNotModerator(&data);
@ -293,9 +293,9 @@ void Channel::Password(ObjectGuid p, const char *pass)
} }
} }
void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set) void Channel::SetMode(ObjectGuid p, const char* p2n, bool mod, bool set)
{ {
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if (!plr) if (!plr)
return; return;
@ -307,7 +307,7 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
MakeNotMember(&data); MakeNotMember(&data);
SendToOne(&data, p); SendToOne(&data, p);
} }
else if(!m_players[p].IsModerator() && sec < SEC_GAMEMASTER) else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
{ {
WorldPacket data; WorldPacket data;
MakeNotModerator(&data); MakeNotModerator(&data);
@ -315,8 +315,8 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
} }
else else
{ {
Player *newp = sObjectMgr.GetPlayer(p2n); Player* newp = sObjectMgr.GetPlayer(p2n);
if(!newp) if (!newp)
{ {
WorldPacket data; WorldPacket data;
MakePlayerNotFound(&data, p2n); MakePlayerNotFound(&data, p2n);
@ -325,7 +325,7 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
} }
PlayerInfo inf = m_players[newp->GetObjectGuid()]; PlayerInfo inf = m_players[newp->GetObjectGuid()];
if(p == m_ownerGuid && newp->GetObjectGuid() == m_ownerGuid && mod) if (p == m_ownerGuid && newp->GetObjectGuid() == m_ownerGuid && mod)
return; return;
if (!IsOn(newp->GetObjectGuid())) if (!IsOn(newp->GetObjectGuid()))
@ -338,8 +338,8 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
// allow make moderator from another team only if both is GMs // allow make moderator from another team only if both is GMs
// at this moment this only way to show channel post for GM from another team // at this moment this only way to show channel post for GM from another team
if( (plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) && if ((plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) &&
plr->GetTeam() != newp->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL) ) plr->GetTeam() != newp->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
{ {
WorldPacket data; WorldPacket data;
MakePlayerNotFound(&data, p2n); MakePlayerNotFound(&data, p2n);
@ -347,7 +347,7 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
return; return;
} }
if(m_ownerGuid == newp->GetObjectGuid() && m_ownerGuid != p) if (m_ownerGuid == newp->GetObjectGuid() && m_ownerGuid != p)
{ {
WorldPacket data; WorldPacket data;
MakeNotOwner(&data); MakeNotOwner(&data);
@ -355,16 +355,16 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
return; return;
} }
if(mod) if (mod)
SetModerator(newp->GetObjectGuid(), set); SetModerator(newp->GetObjectGuid(), set);
else else
SetMute(newp->GetObjectGuid(), set); SetMute(newp->GetObjectGuid(), set);
} }
} }
void Channel::SetOwner(ObjectGuid p, const char *newname) void Channel::SetOwner(ObjectGuid p, const char* newname)
{ {
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if (!plr) if (!plr)
return; return;
@ -378,7 +378,7 @@ void Channel::SetOwner(ObjectGuid p, const char *newname)
return; return;
} }
if(sec < SEC_GAMEMASTER && p != m_ownerGuid) if (sec < SEC_GAMEMASTER && p != m_ownerGuid)
{ {
WorldPacket data; WorldPacket data;
MakeNotOwner(&data); MakeNotOwner(&data);
@ -386,7 +386,7 @@ void Channel::SetOwner(ObjectGuid p, const char *newname)
return; return;
} }
Player *newp = sObjectMgr.GetPlayer(newname); Player* newp = sObjectMgr.GetPlayer(newname);
if (newp == NULL || !IsOn(newp->GetObjectGuid())) if (newp == NULL || !IsOn(newp->GetObjectGuid()))
{ {
WorldPacket data; WorldPacket data;
@ -395,7 +395,7 @@ void Channel::SetOwner(ObjectGuid p, const char *newname)
return; return;
} }
if(newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) if (newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
{ {
WorldPacket data; WorldPacket data;
MakePlayerNotFound(&data, newname); MakePlayerNotFound(&data, newname);
@ -446,14 +446,14 @@ void Channel::List(Player* player)
AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST); AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST);
uint32 count = 0; uint32 count = 0;
for(PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i) for (PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i)
{ {
Player *plr = sObjectMgr.GetPlayer(i->first); Player* plr = sObjectMgr.GetPlayer(i->first);
// PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all // MODERATOR, GAME MASTER, ADMINISTRATOR can see all
if (plr && (player->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) && if (plr && (player->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) &&
plr->IsVisibleGloballyFor(player)) plr->IsVisibleGloballyFor(player))
{ {
data << ObjectGuid(i->first); data << ObjectGuid(i->first);
data << uint8(i->second.flags); // flags seems to be changed... data << uint8(i->second.flags); // flags seems to be changed...
@ -470,8 +470,8 @@ void Channel::List(Player* player)
void Channel::Announce(ObjectGuid p) void Channel::Announce(ObjectGuid p)
{ {
uint32 sec = 0; uint32 sec = 0;
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if(plr) if (plr)
sec = plr->GetSession()->GetSecurity(); sec = plr->GetSession()->GetSecurity();
if (!IsOn(p)) if (!IsOn(p))
@ -491,7 +491,7 @@ void Channel::Announce(ObjectGuid p)
m_announce = !m_announce; m_announce = !m_announce;
WorldPacket data; WorldPacket data;
if(m_announce) if (m_announce)
MakeAnnouncementsOn(&data, p); MakeAnnouncementsOn(&data, p);
else else
MakeAnnouncementsOff(&data, p); MakeAnnouncementsOff(&data, p);
@ -502,8 +502,8 @@ void Channel::Announce(ObjectGuid p)
void Channel::Moderate(ObjectGuid p) void Channel::Moderate(ObjectGuid p)
{ {
uint32 sec = 0; uint32 sec = 0;
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if(plr) if (plr)
sec = plr->GetSession()->GetSecurity(); sec = plr->GetSession()->GetSecurity();
if (!IsOn(p)) if (!IsOn(p))
@ -523,7 +523,7 @@ void Channel::Moderate(ObjectGuid p)
m_moderate = !m_moderate; m_moderate = !m_moderate;
WorldPacket data; WorldPacket data;
if(m_moderate) if (m_moderate)
MakeModerationOn(&data, p); MakeModerationOn(&data, p);
else else
MakeModerationOff(&data, p); MakeModerationOff(&data, p);
@ -531,7 +531,7 @@ void Channel::Moderate(ObjectGuid p)
} }
} }
void Channel::Say(ObjectGuid p, const char *what, uint32 lang) void Channel::Say(ObjectGuid p, const char* what, uint32 lang)
{ {
if (!what) if (!what)
return; return;
@ -539,8 +539,8 @@ void Channel::Say(ObjectGuid p, const char *what, uint32 lang)
lang = LANG_UNIVERSAL; lang = LANG_UNIVERSAL;
uint32 sec = 0; uint32 sec = 0;
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if(plr) if (plr)
sec = plr->GetSession()->GetSecurity(); sec = plr->GetSession()->GetSecurity();
if (!IsOn(p)) if (!IsOn(p))
@ -580,7 +580,7 @@ void Channel::Say(ObjectGuid p, const char *what, uint32 lang)
} }
} }
void Channel::Invite(ObjectGuid p, const char *newname) void Channel::Invite(ObjectGuid p, const char* newname)
{ {
if (!IsOn(p)) if (!IsOn(p))
{ {
@ -590,8 +590,8 @@ void Channel::Invite(ObjectGuid p, const char *newname)
return; return;
} }
Player *newp = sObjectMgr.GetPlayer(newname); Player* newp = sObjectMgr.GetPlayer(newname);
if(!newp) if (!newp)
{ {
WorldPacket data; WorldPacket data;
MakePlayerNotFound(&data, newname); MakePlayerNotFound(&data, newname);
@ -599,7 +599,7 @@ void Channel::Invite(ObjectGuid p, const char *newname)
return; return;
} }
Player *plr = sObjectMgr.GetPlayer(p); Player* plr = sObjectMgr.GetPlayer(p);
if (!plr) if (!plr)
return; return;
@ -651,7 +651,7 @@ void Channel::SetOwner(ObjectGuid guid, bool exclaim)
MakeModeChange(&data, m_ownerGuid, oldFlag); MakeModeChange(&data, m_ownerGuid, oldFlag);
SendToAll(&data); SendToAll(&data);
if(exclaim) if (exclaim)
{ {
MakeOwnerChanged(&data, m_ownerGuid); MakeOwnerChanged(&data, m_ownerGuid);
SendToAll(&data); SendToAll(&data);
@ -659,17 +659,17 @@ void Channel::SetOwner(ObjectGuid guid, bool exclaim)
} }
} }
void Channel::SendToAll(WorldPacket *data, ObjectGuid p) void Channel::SendToAll(WorldPacket* data, ObjectGuid p)
{ {
for(PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i) for (PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i)
if (Player *plr = sObjectMgr.GetPlayer(i->first)) if (Player* plr = sObjectMgr.GetPlayer(i->first))
if (!p || !plr->GetSocial()->HasIgnore(p)) if (!p || !plr->GetSocial()->HasIgnore(p))
plr->GetSession()->SendPacket(data); plr->GetSession()->SendPacket(data);
} }
void Channel::SendToOne(WorldPacket *data, ObjectGuid who) void Channel::SendToOne(WorldPacket* data, ObjectGuid who)
{ {
if (Player *plr = ObjectMgr::GetPlayer(who)) if (Player* plr = ObjectMgr::GetPlayer(who))
plr->GetSession()->SendPacket(data); plr->GetSession()->SendPacket(data);
} }
@ -684,7 +684,7 @@ void Channel::DeVoice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/)
} }
// done // done
void Channel::MakeNotifyPacket(WorldPacket *data, uint8 notify_type) void Channel::MakeNotifyPacket(WorldPacket* data, uint8 notify_type)
{ {
data->Initialize(SMSG_CHANNEL_NOTIFY, 1+m_name.size()+1); data->Initialize(SMSG_CHANNEL_NOTIFY, 1+m_name.size()+1);
*data << uint8(notify_type); *data << uint8(notify_type);
@ -692,21 +692,21 @@ void Channel::MakeNotifyPacket(WorldPacket *data, uint8 notify_type)
} }
// done 0x00 // done 0x00
void Channel::MakeJoined(WorldPacket *data, ObjectGuid guid) void Channel::MakeJoined(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_JOINED_NOTICE); MakeNotifyPacket(data, CHAT_JOINED_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x01 // done 0x01
void Channel::MakeLeft(WorldPacket *data, ObjectGuid guid) void Channel::MakeLeft(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_LEFT_NOTICE); MakeNotifyPacket(data, CHAT_LEFT_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x02 // done 0x02
void Channel::MakeYouJoined(WorldPacket *data) void Channel::MakeYouJoined(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_YOU_JOINED_NOTICE); MakeNotifyPacket(data, CHAT_YOU_JOINED_NOTICE);
*data << uint8(GetFlags()); *data << uint8(GetFlags());
@ -715,7 +715,7 @@ void Channel::MakeYouJoined(WorldPacket *data)
} }
// done 0x03 // done 0x03
void Channel::MakeYouLeft(WorldPacket *data) void Channel::MakeYouLeft(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE); MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE);
*data << uint32(GetChannelId()); *data << uint32(GetChannelId());
@ -723,52 +723,52 @@ void Channel::MakeYouLeft(WorldPacket *data)
} }
// done 0x04 // done 0x04
void Channel::MakeWrongPassword(WorldPacket *data) void Channel::MakeWrongPassword(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_WRONG_PASSWORD_NOTICE); MakeNotifyPacket(data, CHAT_WRONG_PASSWORD_NOTICE);
} }
// done 0x05 // done 0x05
void Channel::MakeNotMember(WorldPacket *data) void Channel::MakeNotMember(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE); MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE);
} }
// done 0x06 // done 0x06
void Channel::MakeNotModerator(WorldPacket *data) void Channel::MakeNotModerator(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE); MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE);
} }
// done 0x07 // done 0x07
void Channel::MakePasswordChanged(WorldPacket *data, ObjectGuid guid) void Channel::MakePasswordChanged(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE); MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x08 // done 0x08
void Channel::MakeOwnerChanged(WorldPacket *data, ObjectGuid guid) void Channel::MakeOwnerChanged(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE); MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x09 // done 0x09
void Channel::MakePlayerNotFound(WorldPacket *data, const std::string& name) void Channel::MakePlayerNotFound(WorldPacket* data, const std::string& name)
{ {
MakeNotifyPacket(data, CHAT_PLAYER_NOT_FOUND_NOTICE); MakeNotifyPacket(data, CHAT_PLAYER_NOT_FOUND_NOTICE);
*data << name; *data << name;
} }
// done 0x0A // done 0x0A
void Channel::MakeNotOwner(WorldPacket *data) void Channel::MakeNotOwner(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_NOT_OWNER_NOTICE); MakeNotifyPacket(data, CHAT_NOT_OWNER_NOTICE);
} }
// done 0x0B // done 0x0B
void Channel::MakeChannelOwner(WorldPacket *data) void Channel::MakeChannelOwner(WorldPacket* data)
{ {
std::string name = ""; std::string name = "";
@ -780,7 +780,7 @@ void Channel::MakeChannelOwner(WorldPacket *data)
} }
// done 0x0C // done 0x0C
void Channel::MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags) void Channel::MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags)
{ {
MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE); MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
@ -789,41 +789,41 @@ void Channel::MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags)
} }
// done 0x0D // done 0x0D
void Channel::MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid) void Channel::MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE); MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x0E // done 0x0E
void Channel::MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid) void Channel::MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE); MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x0F // done 0x0F
void Channel::MakeModerationOn(WorldPacket *data, ObjectGuid guid) void Channel::MakeModerationOn(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE); MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x10 // done 0x10
void Channel::MakeModerationOff(WorldPacket *data, ObjectGuid guid) void Channel::MakeModerationOff(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE); MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x11 // done 0x11
void Channel::MakeMuted(WorldPacket *data) void Channel::MakeMuted(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_MUTED_NOTICE); MakeNotifyPacket(data, CHAT_MUTED_NOTICE);
} }
// done 0x12 // done 0x12
void Channel::MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid good) void Channel::MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good)
{ {
MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE); MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE);
*data << ObjectGuid(bad); *data << ObjectGuid(bad);
@ -831,13 +831,13 @@ void Channel::MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid goo
} }
// done 0x13 // done 0x13
void Channel::MakeBanned(WorldPacket *data) void Channel::MakeBanned(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_BANNED_NOTICE); MakeNotifyPacket(data, CHAT_BANNED_NOTICE);
} }
// done 0x14 // done 0x14
void Channel::MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good) void Channel::MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good)
{ {
MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE); MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE);
*data << ObjectGuid(bad); *data << ObjectGuid(bad);
@ -845,7 +845,7 @@ void Channel::MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid goo
} }
// done 0x15 // done 0x15
void Channel::MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good) void Channel::MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good)
{ {
MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE); MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE);
*data << ObjectGuid(bad); *data << ObjectGuid(bad);
@ -853,91 +853,91 @@ void Channel::MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid g
} }
// done 0x16 // done 0x16
void Channel::MakePlayerNotBanned(WorldPacket *data, ObjectGuid guid) void Channel::MakePlayerNotBanned(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE); MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE);
*data << ObjectGuid(guid); // should be string!! *data << ObjectGuid(guid); // should be string!!
} }
// done 0x17 // done 0x17
void Channel::MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid) void Channel::MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE); MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x18 // done 0x18
void Channel::MakeInvite(WorldPacket *data, ObjectGuid guid) void Channel::MakeInvite(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_INVITE_NOTICE); MakeNotifyPacket(data, CHAT_INVITE_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x19 // done 0x19
void Channel::MakeInviteWrongFaction(WorldPacket *data) void Channel::MakeInviteWrongFaction(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_INVITE_WRONG_FACTION_NOTICE); MakeNotifyPacket(data, CHAT_INVITE_WRONG_FACTION_NOTICE);
} }
// done 0x1A // done 0x1A
void Channel::MakeWrongFaction(WorldPacket *data) void Channel::MakeWrongFaction(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_WRONG_FACTION_NOTICE); MakeNotifyPacket(data, CHAT_WRONG_FACTION_NOTICE);
} }
// done 0x1B // done 0x1B
void Channel::MakeInvalidName(WorldPacket *data) void Channel::MakeInvalidName(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_INVALID_NAME_NOTICE); MakeNotifyPacket(data, CHAT_INVALID_NAME_NOTICE);
} }
// done 0x1C // done 0x1C
void Channel::MakeNotModerated(WorldPacket *data) void Channel::MakeNotModerated(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_NOT_MODERATED_NOTICE); MakeNotifyPacket(data, CHAT_NOT_MODERATED_NOTICE);
} }
// done 0x1D // done 0x1D
void Channel::MakePlayerInvited(WorldPacket *data, const std::string& name) void Channel::MakePlayerInvited(WorldPacket* data, const std::string& name)
{ {
MakeNotifyPacket(data, CHAT_PLAYER_INVITED_NOTICE); MakeNotifyPacket(data, CHAT_PLAYER_INVITED_NOTICE);
*data << name; *data << name;
} }
// done 0x1E // done 0x1E
void Channel::MakePlayerInviteBanned(WorldPacket *data, ObjectGuid guid) void Channel::MakePlayerInviteBanned(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE); MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE);
*data << ObjectGuid(guid); // should be string!! *data << ObjectGuid(guid); // should be string!!
} }
// done 0x1F // done 0x1F
void Channel::MakeThrottled(WorldPacket *data) void Channel::MakeThrottled(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_THROTTLED_NOTICE); MakeNotifyPacket(data, CHAT_THROTTLED_NOTICE);
} }
// done 0x20 // done 0x20
void Channel::MakeNotInArea(WorldPacket *data) void Channel::MakeNotInArea(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_NOT_IN_AREA_NOTICE); MakeNotifyPacket(data, CHAT_NOT_IN_AREA_NOTICE);
} }
// done 0x21 // done 0x21
void Channel::MakeNotInLfg(WorldPacket *data) void Channel::MakeNotInLfg(WorldPacket* data)
{ {
MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE); MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE);
} }
// done 0x22 // done 0x22
void Channel::MakeVoiceOn(WorldPacket *data, ObjectGuid guid) void Channel::MakeVoiceOn(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE); MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);
} }
// done 0x23 // done 0x23
void Channel::MakeVoiceOff(WorldPacket *data, ObjectGuid guid) void Channel::MakeVoiceOff(WorldPacket* data, ObjectGuid guid)
{ {
MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE); MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE);
*data << ObjectGuid(guid); *data << ObjectGuid(guid);

View file

@ -69,82 +69,82 @@ enum ChatNotify
CHAT_NOT_IN_LFG_NOTICE = 0x21, //+ "[%s] You must be queued in looking for group before joining this channel."; -- The user must be in the looking for group system to join LFG chat channels. CHAT_NOT_IN_LFG_NOTICE = 0x21, //+ "[%s] You must be queued in looking for group before joining this channel."; -- The user must be in the looking for group system to join LFG chat channels.
CHAT_VOICE_ON_NOTICE = 0x22, //+ "[%s] Channel voice enabled by %s."; CHAT_VOICE_ON_NOTICE = 0x22, //+ "[%s] Channel voice enabled by %s.";
CHAT_VOICE_OFF_NOTICE = 0x23 //+ "[%s] Channel voice disabled by %s."; CHAT_VOICE_OFF_NOTICE = 0x23 //+ "[%s] Channel voice disabled by %s.";
// 0x24 enable voice? // 0x24 enable voice?
}; };
class Channel class Channel
{ {
enum ChannelFlags enum ChannelFlags
{
CHANNEL_FLAG_NONE = 0x00,
CHANNEL_FLAG_CUSTOM = 0x01,
// 0x02
CHANNEL_FLAG_TRADE = 0x04,
CHANNEL_FLAG_NOT_LFG = 0x08,
CHANNEL_FLAG_GENERAL = 0x10,
CHANNEL_FLAG_CITY = 0x20,
CHANNEL_FLAG_LFG = 0x40,
CHANNEL_FLAG_VOICE = 0x80
// General 0x18 = 0x10 | 0x08
// Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04
// LocalDefence 0x18 = 0x10 | 0x08
// GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08
// LookingForGroup 0x50 = 0x40 | 0x10
};
enum ChannelDBCFlags
{
CHANNEL_DBC_FLAG_NONE = 0x00000,
CHANNEL_DBC_FLAG_INITIAL = 0x00001, // General, Trade, LocalDefense, LFG
CHANNEL_DBC_FLAG_ZONE_DEP = 0x00002, // General, Trade, LocalDefense, GuildRecruitment
CHANNEL_DBC_FLAG_GLOBAL = 0x00004, // WorldDefense
CHANNEL_DBC_FLAG_TRADE = 0x00008, // Trade
CHANNEL_DBC_FLAG_CITY_ONLY = 0x00010, // Trade, GuildRecruitment
CHANNEL_DBC_FLAG_CITY_ONLY2 = 0x00020, // Trade, GuildRecruitment
CHANNEL_DBC_FLAG_DEFENSE = 0x10000, // LocalDefense, WorldDefense
CHANNEL_DBC_FLAG_GUILD_REQ = 0x20000, // GuildRecruitment
CHANNEL_DBC_FLAG_LFG = 0x40000 // LookingForGroup
};
enum ChannelMemberFlags
{
MEMBER_FLAG_NONE = 0x00,
MEMBER_FLAG_OWNER = 0x01,
MEMBER_FLAG_MODERATOR = 0x02,
MEMBER_FLAG_VOICED = 0x04,
MEMBER_FLAG_MUTED = 0x08,
MEMBER_FLAG_CUSTOM = 0x10,
MEMBER_FLAG_MIC_MUTED = 0x20,
// 0x40
// 0x80
};
struct PlayerInfo
{
ObjectGuid player;
uint8 flags;
bool HasFlag(uint8 flag) { return flags & flag; }
void SetFlag(uint8 flag) { if(!HasFlag(flag)) flags |= flag; }
bool IsOwner() { return flags & MEMBER_FLAG_OWNER; }
void SetOwner(bool state)
{ {
if(state) flags |= MEMBER_FLAG_OWNER; CHANNEL_FLAG_NONE = 0x00,
else flags &= ~MEMBER_FLAG_OWNER; CHANNEL_FLAG_CUSTOM = 0x01,
} // 0x02
bool IsModerator() { return flags & MEMBER_FLAG_MODERATOR; } CHANNEL_FLAG_TRADE = 0x04,
void SetModerator(bool state) CHANNEL_FLAG_NOT_LFG = 0x08,
CHANNEL_FLAG_GENERAL = 0x10,
CHANNEL_FLAG_CITY = 0x20,
CHANNEL_FLAG_LFG = 0x40,
CHANNEL_FLAG_VOICE = 0x80
// General 0x18 = 0x10 | 0x08
// Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04
// LocalDefence 0x18 = 0x10 | 0x08
// GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08
// LookingForGroup 0x50 = 0x40 | 0x10
};
enum ChannelDBCFlags
{ {
if(state) flags |= MEMBER_FLAG_MODERATOR; CHANNEL_DBC_FLAG_NONE = 0x00000,
else flags &= ~MEMBER_FLAG_MODERATOR; CHANNEL_DBC_FLAG_INITIAL = 0x00001, // General, Trade, LocalDefense, LFG
} CHANNEL_DBC_FLAG_ZONE_DEP = 0x00002, // General, Trade, LocalDefense, GuildRecruitment
bool IsMuted() { return flags & MEMBER_FLAG_MUTED; } CHANNEL_DBC_FLAG_GLOBAL = 0x00004, // WorldDefense
void SetMuted(bool state) CHANNEL_DBC_FLAG_TRADE = 0x00008, // Trade
CHANNEL_DBC_FLAG_CITY_ONLY = 0x00010, // Trade, GuildRecruitment
CHANNEL_DBC_FLAG_CITY_ONLY2 = 0x00020, // Trade, GuildRecruitment
CHANNEL_DBC_FLAG_DEFENSE = 0x10000, // LocalDefense, WorldDefense
CHANNEL_DBC_FLAG_GUILD_REQ = 0x20000, // GuildRecruitment
CHANNEL_DBC_FLAG_LFG = 0x40000 // LookingForGroup
};
enum ChannelMemberFlags
{ {
if(state) flags |= MEMBER_FLAG_MUTED; MEMBER_FLAG_NONE = 0x00,
else flags &= ~MEMBER_FLAG_MUTED; MEMBER_FLAG_OWNER = 0x01,
} MEMBER_FLAG_MODERATOR = 0x02,
}; MEMBER_FLAG_VOICED = 0x04,
MEMBER_FLAG_MUTED = 0x08,
MEMBER_FLAG_CUSTOM = 0x10,
MEMBER_FLAG_MIC_MUTED = 0x20,
// 0x40
// 0x80
};
struct PlayerInfo
{
ObjectGuid player;
uint8 flags;
bool HasFlag(uint8 flag) { return flags & flag; }
void SetFlag(uint8 flag) { if (!HasFlag(flag)) flags |= flag; }
bool IsOwner() { return flags & MEMBER_FLAG_OWNER; }
void SetOwner(bool state)
{
if (state) flags |= MEMBER_FLAG_OWNER;
else flags &= ~MEMBER_FLAG_OWNER;
}
bool IsModerator() { return flags & MEMBER_FLAG_MODERATOR; }
void SetModerator(bool state)
{
if (state) flags |= MEMBER_FLAG_MODERATOR;
else flags &= ~MEMBER_FLAG_MODERATOR;
}
bool IsMuted() { return flags & MEMBER_FLAG_MUTED; }
void SetMuted(bool state)
{
if (state) flags |= MEMBER_FLAG_MUTED;
else flags &= ~MEMBER_FLAG_MUTED;
}
};
public: public:
Channel(const std::string& name, uint32 channel_id); Channel(const std::string& name, uint32 channel_id);
@ -160,26 +160,26 @@ class Channel
uint8 GetFlags() const { return m_flags; } uint8 GetFlags() const { return m_flags; }
bool HasFlag(uint8 flag) { return m_flags & flag; } bool HasFlag(uint8 flag) { return m_flags & flag; }
void Join(ObjectGuid p, const char *pass); void Join(ObjectGuid p, const char* pass);
void Leave(ObjectGuid p, bool send = true); void Leave(ObjectGuid p, bool send = true);
void KickOrBan(ObjectGuid good, const char *badname, bool ban); void KickOrBan(ObjectGuid good, const char* badname, bool ban);
void Kick(ObjectGuid good, const char *badname) { KickOrBan(good, badname, false); } void Kick(ObjectGuid good, const char* badname) { KickOrBan(good, badname, false); }
void Ban(ObjectGuid good, const char *badname) { KickOrBan(good, badname, true); } void Ban(ObjectGuid good, const char* badname) { KickOrBan(good, badname, true); }
void UnBan(ObjectGuid good, const char *badname); void UnBan(ObjectGuid good, const char* badname);
void Password(ObjectGuid p, const char *pass); void Password(ObjectGuid p, const char* pass);
void SetMode(ObjectGuid p, const char *p2n, bool mod, bool set); void SetMode(ObjectGuid p, const char* p2n, bool mod, bool set);
void SetOwner(ObjectGuid p, bool exclaim = true); void SetOwner(ObjectGuid p, bool exclaim = true);
void SetOwner(ObjectGuid p, const char *newname); void SetOwner(ObjectGuid p, const char* newname);
void SendWhoOwner(ObjectGuid p); void SendWhoOwner(ObjectGuid p);
void SetModerator(ObjectGuid p, const char *newname) { SetMode(p, newname, true, true); } void SetModerator(ObjectGuid p, const char* newname) { SetMode(p, newname, true, true); }
void UnsetModerator(ObjectGuid p, const char *newname) { SetMode(p, newname, true, false); } void UnsetModerator(ObjectGuid p, const char* newname) { SetMode(p, newname, true, false); }
void SetMute(ObjectGuid p, const char *newname) { SetMode(p, newname, false, true); } void SetMute(ObjectGuid p, const char* newname) { SetMode(p, newname, false, true); }
void UnsetMute(ObjectGuid p, const char *newname) { SetMode(p, newname, false, false); } void UnsetMute(ObjectGuid p, const char* newname) { SetMode(p, newname, false, false); }
void List(Player* p); void List(Player* p);
void Announce(ObjectGuid p); void Announce(ObjectGuid p);
void Moderate(ObjectGuid p); void Moderate(ObjectGuid p);
void Say(ObjectGuid p, const char *what, uint32 lang); void Say(ObjectGuid p, const char* what, uint32 lang);
void Invite(ObjectGuid p, const char *newp); void Invite(ObjectGuid p, const char* newp);
void Voice(ObjectGuid guid1, ObjectGuid guid2); void Voice(ObjectGuid guid1, ObjectGuid guid2);
void DeVoice(ObjectGuid guid1, ObjectGuid guid2); void DeVoice(ObjectGuid guid1, ObjectGuid guid2);
void JoinNotify(ObjectGuid guid); // invisible notify void JoinNotify(ObjectGuid guid); // invisible notify
@ -187,47 +187,47 @@ class Channel
private: private:
// initial packet data (notify type and channel name) // initial packet data (notify type and channel name)
void MakeNotifyPacket(WorldPacket *data, uint8 notify_type); void MakeNotifyPacket(WorldPacket* data, uint8 notify_type);
// type specific packet data // type specific packet data
void MakeJoined(WorldPacket *data, ObjectGuid guid); //+ 0x00 void MakeJoined(WorldPacket* data, ObjectGuid guid); //+ 0x00
void MakeLeft(WorldPacket *data, ObjectGuid guid); //+ 0x01 void MakeLeft(WorldPacket* data, ObjectGuid guid); //+ 0x01
void MakeYouJoined(WorldPacket *data); //+ 0x02 void MakeYouJoined(WorldPacket* data); //+ 0x02
void MakeYouLeft(WorldPacket *data); //+ 0x03 void MakeYouLeft(WorldPacket* data); //+ 0x03
void MakeWrongPassword(WorldPacket *data); //? 0x04 void MakeWrongPassword(WorldPacket* data); //? 0x04
void MakeNotMember(WorldPacket *data); //? 0x05 void MakeNotMember(WorldPacket* data); //? 0x05
void MakeNotModerator(WorldPacket *data); //? 0x06 void MakeNotModerator(WorldPacket* data); //? 0x06
void MakePasswordChanged(WorldPacket *data, ObjectGuid guid); //+ 0x07 void MakePasswordChanged(WorldPacket* data, ObjectGuid guid); //+ 0x07
void MakeOwnerChanged(WorldPacket *data, ObjectGuid guid); //? 0x08 void MakeOwnerChanged(WorldPacket* data, ObjectGuid guid); //? 0x08
void MakePlayerNotFound(WorldPacket *data, const std::string& name); //+ 0x09 void MakePlayerNotFound(WorldPacket* data, const std::string& name); //+ 0x09
void MakeNotOwner(WorldPacket *data); //? 0x0A void MakeNotOwner(WorldPacket* data); //? 0x0A
void MakeChannelOwner(WorldPacket *data); //? 0x0B void MakeChannelOwner(WorldPacket* data); //? 0x0B
void MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags);//+ 0x0C void MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags);//+ 0x0C
void MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid); //+ 0x0D void MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid); //+ 0x0D
void MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid); //+ 0x0E void MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid); //+ 0x0E
void MakeModerationOn(WorldPacket *data, ObjectGuid guid); //+ 0x0F void MakeModerationOn(WorldPacket* data, ObjectGuid guid); //+ 0x0F
void MakeModerationOff(WorldPacket *data, ObjectGuid guid); //+ 0x10 void MakeModerationOff(WorldPacket* data, ObjectGuid guid); //+ 0x10
void MakeMuted(WorldPacket *data); //? 0x11 void MakeMuted(WorldPacket* data); //? 0x11
void MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x12 void MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x12
void MakeBanned(WorldPacket *data); //? 0x13 void MakeBanned(WorldPacket* data); //? 0x13
void MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x14 void MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x14
void MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x15 void MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x15
void MakePlayerNotBanned(WorldPacket *data, ObjectGuid guid); //? 0x16 void MakePlayerNotBanned(WorldPacket* data, ObjectGuid guid); //? 0x16
void MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid); //+ 0x17 void MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid); //+ 0x17
void MakeInvite(WorldPacket *data, ObjectGuid guid); //? 0x18 void MakeInvite(WorldPacket* data, ObjectGuid guid); //? 0x18
void MakeInviteWrongFaction(WorldPacket *data); //? 0x19 void MakeInviteWrongFaction(WorldPacket* data); //? 0x19
void MakeWrongFaction(WorldPacket *data); //? 0x1A void MakeWrongFaction(WorldPacket* data); //? 0x1A
void MakeInvalidName(WorldPacket *data); //? 0x1B void MakeInvalidName(WorldPacket* data); //? 0x1B
void MakeNotModerated(WorldPacket *data); //? 0x1C void MakeNotModerated(WorldPacket* data); //? 0x1C
void MakePlayerInvited(WorldPacket *data, const std::string& name); //+ 0x1D void MakePlayerInvited(WorldPacket* data, const std::string& name); //+ 0x1D
void MakePlayerInviteBanned(WorldPacket *data, ObjectGuid guid); //? 0x1E void MakePlayerInviteBanned(WorldPacket* data, ObjectGuid guid); //? 0x1E
void MakeThrottled(WorldPacket *data); //? 0x1F void MakeThrottled(WorldPacket* data); //? 0x1F
void MakeNotInArea(WorldPacket *data); //? 0x20 void MakeNotInArea(WorldPacket* data); //? 0x20
void MakeNotInLfg(WorldPacket *data); //? 0x21 void MakeNotInLfg(WorldPacket* data); //? 0x21
void MakeVoiceOn(WorldPacket *data, ObjectGuid guid); //+ 0x22 void MakeVoiceOn(WorldPacket* data, ObjectGuid guid); //+ 0x22
void MakeVoiceOff(WorldPacket *data, ObjectGuid guid); //+ 0x23 void MakeVoiceOff(WorldPacket* data, ObjectGuid guid); //+ 0x23
void SendToAll(WorldPacket *data, ObjectGuid p = ObjectGuid()); void SendToAll(WorldPacket* data, ObjectGuid p = ObjectGuid());
void SendToOne(WorldPacket *data, ObjectGuid who); void SendToOne(WorldPacket* data, ObjectGuid who);
bool IsOn(ObjectGuid who) const { return m_players.find(who) != m_players.end(); } bool IsOn(ObjectGuid who) const { return m_players.find(who) != m_players.end(); }
bool IsBanned(ObjectGuid guid) const { return m_banned.find(guid) != m_banned.end(); } bool IsBanned(ObjectGuid guid) const { return m_banned.find(guid) != m_banned.end(); }

View file

@ -30,12 +30,12 @@ void WorldSession::HandleJoinChannelOpcode(WorldPacket& recvPacket)
recvPacket >> channel_id >> unknown1 >> unknown2; recvPacket >> channel_id >> unknown1 >> unknown2;
recvPacket >> channelname; recvPacket >> channelname;
if(channelname.empty()) if (channelname.empty())
return; return;
recvPacket >> pass; recvPacket >> pass;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetJoinChannel(channelname, channel_id)) if (Channel* chn = cMgr->GetJoinChannel(channelname, channel_id))
chn->Join(_player->GetObjectGuid(), pass.c_str()); chn->Join(_player->GetObjectGuid(), pass.c_str());
} }
@ -49,12 +49,12 @@ void WorldSession::HandleLeaveChannelOpcode(WorldPacket& recvPacket)
recvPacket >> unk; // channel id? recvPacket >> unk; // channel id?
recvPacket >> channelname; recvPacket >> channelname;
if(channelname.empty()) if (channelname.empty())
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
{ {
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->Leave(_player->GetObjectGuid(), true); chn->Leave(_player->GetObjectGuid(), true);
cMgr->LeftChannel(channelname); cMgr->LeftChannel(channelname);
} }
@ -67,8 +67,8 @@ void WorldSession::HandleChannelListOpcode(WorldPacket& recvPacket)
std::string channelname; std::string channelname;
recvPacket >> channelname; recvPacket >> channelname;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->List(_player); chn->List(_player);
} }
@ -81,8 +81,8 @@ void WorldSession::HandleChannelPasswordOpcode(WorldPacket& recvPacket)
recvPacket >> pass; recvPacket >> pass;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->Password(_player->GetObjectGuid(), pass.c_str()); chn->Password(_player->GetObjectGuid(), pass.c_str());
} }
@ -96,11 +96,11 @@ void WorldSession::HandleChannelSetOwnerOpcode(WorldPacket& recvPacket)
recvPacket >> newp; recvPacket >> newp;
if(!normalizePlayerName(newp)) if (!normalizePlayerName(newp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->SetOwner(_player->GetObjectGuid(), newp.c_str()); chn->SetOwner(_player->GetObjectGuid(), newp.c_str());
} }
@ -110,8 +110,8 @@ void WorldSession::HandleChannelOwnerOpcode(WorldPacket& recvPacket)
//recvPacket.hexlike(); //recvPacket.hexlike();
std::string channelname; std::string channelname;
recvPacket >> channelname; recvPacket >> channelname;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->SendWhoOwner(_player->GetObjectGuid()); chn->SendWhoOwner(_player->GetObjectGuid());
} }
@ -124,11 +124,11 @@ void WorldSession::HandleChannelModeratorOpcode(WorldPacket& recvPacket)
recvPacket >> otp; recvPacket >> otp;
if(!normalizePlayerName(otp)) if (!normalizePlayerName(otp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->SetModerator(_player->GetObjectGuid(), otp.c_str()); chn->SetModerator(_player->GetObjectGuid(), otp.c_str());
} }
@ -141,11 +141,11 @@ void WorldSession::HandleChannelUnmoderatorOpcode(WorldPacket& recvPacket)
recvPacket >> otp; recvPacket >> otp;
if(!normalizePlayerName(otp)) if (!normalizePlayerName(otp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->UnsetModerator(_player->GetObjectGuid(), otp.c_str()); chn->UnsetModerator(_player->GetObjectGuid(), otp.c_str());
} }
@ -158,11 +158,11 @@ void WorldSession::HandleChannelMuteOpcode(WorldPacket& recvPacket)
recvPacket >> otp; recvPacket >> otp;
if(!normalizePlayerName(otp)) if (!normalizePlayerName(otp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->SetMute(_player->GetObjectGuid(), otp.c_str()); chn->SetMute(_player->GetObjectGuid(), otp.c_str());
} }
@ -176,11 +176,11 @@ void WorldSession::HandleChannelUnmuteOpcode(WorldPacket& recvPacket)
recvPacket >> otp; recvPacket >> otp;
if(!normalizePlayerName(otp)) if (!normalizePlayerName(otp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->UnsetMute(_player->GetObjectGuid(), otp.c_str()); chn->UnsetMute(_player->GetObjectGuid(), otp.c_str());
} }
@ -193,11 +193,11 @@ void WorldSession::HandleChannelInviteOpcode(WorldPacket& recvPacket)
recvPacket >> otp; recvPacket >> otp;
if(!normalizePlayerName(otp)) if (!normalizePlayerName(otp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->Invite(_player->GetObjectGuid(), otp.c_str()); chn->Invite(_player->GetObjectGuid(), otp.c_str());
} }
@ -209,11 +209,11 @@ void WorldSession::HandleChannelKickOpcode(WorldPacket& recvPacket)
recvPacket >> channelname; recvPacket >> channelname;
recvPacket >> otp; recvPacket >> otp;
if(!normalizePlayerName(otp)) if (!normalizePlayerName(otp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->Kick(_player->GetObjectGuid(), otp.c_str()); chn->Kick(_player->GetObjectGuid(), otp.c_str());
} }
@ -226,11 +226,11 @@ void WorldSession::HandleChannelBanOpcode(WorldPacket& recvPacket)
recvPacket >> otp; recvPacket >> otp;
if(!normalizePlayerName(otp)) if (!normalizePlayerName(otp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->Ban(_player->GetObjectGuid(), otp.c_str()); chn->Ban(_player->GetObjectGuid(), otp.c_str());
} }
@ -244,11 +244,11 @@ void WorldSession::HandleChannelUnbanOpcode(WorldPacket& recvPacket)
recvPacket >> otp; recvPacket >> otp;
if(!normalizePlayerName(otp)) if (!normalizePlayerName(otp))
return; return;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->UnBan(_player->GetObjectGuid(), otp.c_str()); chn->UnBan(_player->GetObjectGuid(), otp.c_str());
} }
@ -258,8 +258,8 @@ void WorldSession::HandleChannelAnnouncementsOpcode(WorldPacket& recvPacket)
//recvPacket.hexlike(); //recvPacket.hexlike();
std::string channelname; std::string channelname;
recvPacket >> channelname; recvPacket >> channelname;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->Announce(_player->GetObjectGuid()); chn->Announce(_player->GetObjectGuid());
} }
@ -269,31 +269,31 @@ void WorldSession::HandleChannelModerateOpcode(WorldPacket& recvPacket)
//recvPacket.hexlike(); //recvPacket.hexlike();
std::string channelname; std::string channelname;
recvPacket >> channelname; recvPacket >> channelname;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->Moderate(_player->GetObjectGuid()); chn->Moderate(_player->GetObjectGuid());
} }
void WorldSession::HandleChannelDisplayListQueryOpcode(WorldPacket &recvPacket) void WorldSession::HandleChannelDisplayListQueryOpcode(WorldPacket& recvPacket)
{ {
DEBUG_LOG("Opcode %u", recvPacket.GetOpcode()); DEBUG_LOG("Opcode %u", recvPacket.GetOpcode());
//recvPacket.hexlike(); //recvPacket.hexlike();
std::string channelname; std::string channelname;
recvPacket >> channelname; recvPacket >> channelname;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
chn->List(_player); chn->List(_player);
} }
void WorldSession::HandleGetChannelMemberCountOpcode(WorldPacket &recvPacket) void WorldSession::HandleGetChannelMemberCountOpcode(WorldPacket& recvPacket)
{ {
DEBUG_LOG("Opcode %u", recvPacket.GetOpcode()); DEBUG_LOG("Opcode %u", recvPacket.GetOpcode());
//recvPacket.hexlike(); //recvPacket.hexlike();
std::string channelname; std::string channelname;
recvPacket >> channelname; recvPacket >> channelname;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
{ {
if(Channel *chn = cMgr->GetChannel(channelname, _player)) if (Channel* chn = cMgr->GetChannel(channelname, _player))
{ {
WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, chn->GetName().size()+1+1+4); WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, chn->GetName().size()+1+1+4);
data << chn->GetName(); data << chn->GetName();
@ -304,7 +304,7 @@ void WorldSession::HandleGetChannelMemberCountOpcode(WorldPacket &recvPacket)
} }
} }
void WorldSession::HandleSetChannelWatchOpcode(WorldPacket &recvPacket) void WorldSession::HandleSetChannelWatchOpcode(WorldPacket& recvPacket)
{ {
DEBUG_LOG("Opcode %u", recvPacket.GetOpcode()); DEBUG_LOG("Opcode %u", recvPacket.GetOpcode());
//recvPacket.hexlike(); //recvPacket.hexlike();

View file

@ -20,17 +20,17 @@
#include "Policies/SingletonImp.h" #include "Policies/SingletonImp.h"
#include "World.h" #include "World.h"
INSTANTIATE_SINGLETON_1( AllianceChannelMgr ); INSTANTIATE_SINGLETON_1(AllianceChannelMgr);
INSTANTIATE_SINGLETON_1( HordeChannelMgr ); INSTANTIATE_SINGLETON_1(HordeChannelMgr);
ChannelMgr* channelMgr(Team team) ChannelMgr* channelMgr(Team team)
{ {
if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
return &MaNGOS::Singleton<AllianceChannelMgr>::Instance(); // cross-faction return &MaNGOS::Singleton<AllianceChannelMgr>::Instance(); // cross-faction
if(team == ALLIANCE) if (team == ALLIANCE)
return &MaNGOS::Singleton<AllianceChannelMgr>::Instance(); return &MaNGOS::Singleton<AllianceChannelMgr>::Instance();
if(team == HORDE) if (team == HORDE)
return &MaNGOS::Singleton<HordeChannelMgr>::Instance(); return &MaNGOS::Singleton<HordeChannelMgr>::Instance();
return NULL; return NULL;
@ -38,13 +38,13 @@ ChannelMgr* channelMgr(Team team)
ChannelMgr::~ChannelMgr() ChannelMgr::~ChannelMgr()
{ {
for(ChannelMap::iterator itr = channels.begin();itr!=channels.end(); ++itr) for (ChannelMap::iterator itr = channels.begin(); itr!=channels.end(); ++itr)
delete itr->second; delete itr->second;
channels.clear(); channels.clear();
} }
Channel *ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id) Channel* ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id)
{ {
std::wstring wname; std::wstring wname;
Utf8toWStr(name,wname); Utf8toWStr(name,wname);
@ -52,7 +52,7 @@ Channel *ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id)
if (channels.find(wname) == channels.end()) if (channels.find(wname) == channels.end())
{ {
Channel *nchan = new Channel(name,channel_id); Channel* nchan = new Channel(name,channel_id);
channels[wname] = nchan; channels[wname] = nchan;
return nchan; return nchan;
} }
@ -60,7 +60,7 @@ Channel *ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id)
return channels[wname]; return channels[wname];
} }
Channel *ChannelMgr::GetChannel(std::string name, Player *p, bool pkt) Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt)
{ {
std::wstring wname; std::wstring wname;
Utf8toWStr(name,wname); Utf8toWStr(name,wname);
@ -68,9 +68,9 @@ Channel *ChannelMgr::GetChannel(std::string name, Player *p, bool pkt)
ChannelMap::const_iterator i = channels.find(wname); ChannelMap::const_iterator i = channels.find(wname);
if(i == channels.end()) if (i == channels.end())
{ {
if(pkt) if (pkt)
{ {
WorldPacket data; WorldPacket data;
MakeNotOnPacket(&data,name); MakeNotOnPacket(&data,name);
@ -91,19 +91,19 @@ void ChannelMgr::LeftChannel(std::string name)
ChannelMap::const_iterator i = channels.find(wname); ChannelMap::const_iterator i = channels.find(wname);
if(i == channels.end()) if (i == channels.end())
return; return;
Channel* channel = i->second; Channel* channel = i->second;
if(channel->GetNumPlayers() == 0 && !channel->IsConstant()) if (channel->GetNumPlayers() == 0 && !channel->IsConstant())
{ {
channels.erase(wname); channels.erase(wname);
delete channel; delete channel;
} }
} }
void ChannelMgr::MakeNotOnPacket(WorldPacket *data, std::string name) void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string name)
{ {
data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size
(*data) << (uint8)CHAT_NOT_MEMBER_NOTICE << name; (*data) << (uint8)CHAT_NOT_MEMBER_NOTICE << name;

View file

@ -32,12 +32,12 @@ class ChannelMgr
ChannelMgr() {} ChannelMgr() {}
~ChannelMgr(); ~ChannelMgr();
Channel *GetJoinChannel(std::string name, uint32 channel_id); Channel* GetJoinChannel(std::string name, uint32 channel_id);
Channel *GetChannel(std::string name, Player *p, bool pkt = true); Channel* GetChannel(std::string name, Player* p, bool pkt = true);
void LeftChannel(std::string name); void LeftChannel(std::string name);
private: private:
ChannelMap channels; ChannelMap channels;
void MakeNotOnPacket(WorldPacket *data, std::string name); void MakeNotOnPacket(WorldPacket* data, std::string name);
}; };
class AllianceChannelMgr : public ChannelMgr {}; class AllianceChannelMgr : public ChannelMgr {};

View file

@ -26,26 +26,26 @@
void CharacterDatabaseCleaner::CleanDatabase() void CharacterDatabaseCleaner::CleanDatabase()
{ {
// config to disable // config to disable
if(!sWorld.getConfig(CONFIG_BOOL_CLEAN_CHARACTER_DB)) if (!sWorld.getConfig(CONFIG_BOOL_CLEAN_CHARACTER_DB))
return; return;
sLog.outString("Cleaning character database..."); sLog.outString("Cleaning character database...");
// check flags which clean ups are necessary // check flags which clean ups are necessary
QueryResult* result = CharacterDatabase.PQuery("SELECT cleaning_flags FROM saved_variables"); QueryResult* result = CharacterDatabase.PQuery("SELECT cleaning_flags FROM saved_variables");
if(!result) if (!result)
return; return;
uint32 flags = (*result)[0].GetUInt32(); uint32 flags = (*result)[0].GetUInt32();
delete result; delete result;
// clean up // clean up
if(flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS) if (flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS)
CleanCharacterAchievementProgress(); CleanCharacterAchievementProgress();
if(flags & CLEANING_FLAG_SKILLS) if (flags & CLEANING_FLAG_SKILLS)
CleanCharacterSkills(); CleanCharacterSkills();
if(flags & CLEANING_FLAG_SPELLS) if (flags & CLEANING_FLAG_SPELLS)
CleanCharacterSpell(); CleanCharacterSpell();
if(flags & CLEANING_FLAG_TALENTS) if (flags & CLEANING_FLAG_TALENTS)
CleanCharacterTalent(); CleanCharacterTalent();
CharacterDatabase.Execute("UPDATE saved_variables SET cleaning_flags = 0"); CharacterDatabase.Execute("UPDATE saved_variables SET cleaning_flags = 0");
} }
@ -53,9 +53,9 @@ void CharacterDatabaseCleaner::CleanDatabase()
void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table, bool (*check)(uint32)) void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table, bool (*check)(uint32))
{ {
QueryResult* result = CharacterDatabase.PQuery("SELECT DISTINCT %s FROM %s", column, table); QueryResult* result = CharacterDatabase.PQuery("SELECT DISTINCT %s FROM %s", column, table);
if(!result) if (!result)
{ {
sLog.outString( "Table %s is empty.", table ); sLog.outString("Table %s is empty.", table);
return; return;
} }
@ -66,7 +66,7 @@ void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table
{ {
bar.step(); bar.step();
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32(); uint32 id = fields[0].GetUInt32();
@ -88,7 +88,7 @@ void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table
if (found) if (found)
{ {
ss << ")"; ss << ")";
CharacterDatabase.Execute( ss.str().c_str() ); CharacterDatabase.Execute(ss.str().c_str());
} }
} }
@ -124,11 +124,11 @@ void CharacterDatabaseCleaner::CleanCharacterSpell()
bool CharacterDatabaseCleaner::TalentCheck(uint32 talent_id) bool CharacterDatabaseCleaner::TalentCheck(uint32 talent_id)
{ {
TalentEntry const *talentInfo = sTalentStore.LookupEntry( talent_id ); TalentEntry const* talentInfo = sTalentStore.LookupEntry(talent_id);
if(!talentInfo) if (!talentInfo)
return false; return false;
return sTalentTabStore.LookupEntry( talentInfo->TalentTab ); return sTalentTabStore.LookupEntry(talentInfo->TalentTab);
} }
void CharacterDatabaseCleaner::CleanCharacterTalent() void CharacterDatabaseCleaner::CleanCharacterTalent()

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -47,12 +47,12 @@ class Unit;
class ChatCommand class ChatCommand
{ {
public: public:
const char * Name; const char* Name;
uint32 SecurityLevel; // function pointer required correct align (use uint32) uint32 SecurityLevel; // function pointer required correct align (use uint32)
bool AllowConsole; bool AllowConsole;
bool (ChatHandler::*Handler)(char* args); bool (ChatHandler::*Handler)(char* args);
std::string Help; std::string Help;
ChatCommand * ChildCommands; ChatCommand* ChildCommands;
}; };
enum ChatCommandSearchResult enum ChatCommandSearchResult
@ -69,34 +69,34 @@ class MANGOS_DLL_SPEC ChatHandler
explicit ChatHandler(Player* player); explicit ChatHandler(Player* player);
~ChatHandler(); ~ChatHandler();
static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, ObjectGuid targetGuid, const char *message, Unit *speaker); static void FillMessageData(WorldPacket* data, WorldSession* session, uint8 type, uint32 language, const char* channelName, ObjectGuid targetGuid, const char* message, Unit* speaker);
static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, ObjectGuid targetGuid, const char* message) static void FillMessageData(WorldPacket* data, WorldSession* session, uint8 type, uint32 language, ObjectGuid targetGuid, const char* message)
{ {
FillMessageData( data, session, type, language, NULL, targetGuid, message, NULL); FillMessageData(data, session, type, language, NULL, targetGuid, message, NULL);
} }
static void FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char* message) static void FillMessageData(WorldPacket* data, WorldSession* session, uint8 type, uint32 language, const char* message)
{ {
FillMessageData( data, session, type, language, NULL, ObjectGuid(), message, NULL); FillMessageData(data, session, type, language, NULL, ObjectGuid(), message, NULL);
} }
void FillSystemMessageData( WorldPacket *data, const char* message ) void FillSystemMessageData(WorldPacket* data, const char* message)
{ {
FillMessageData( data, m_session, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, ObjectGuid(), message ); FillMessageData(data, m_session, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, ObjectGuid(), message);
} }
static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; } static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; }
// function with different implementation for chat/console // function with different implementation for chat/console
virtual const char *GetMangosString(int32 entry) const; virtual const char* GetMangosString(int32 entry) const;
const char *GetOnOffStr(bool value) const; const char* GetOnOffStr(bool value) const;
virtual void SendSysMessage( const char *str); virtual void SendSysMessage(const char* str);
void SendSysMessage( int32 entry); void SendSysMessage(int32 entry);
void PSendSysMessage( const char *format, ...) ATTR_PRINTF(2,3); void PSendSysMessage(const char* format, ...) ATTR_PRINTF(2,3);
void PSendSysMessage( int32 entry, ... ); void PSendSysMessage(int32 entry, ...);
bool ParseCommands(const char* text); bool ParseCommands(const char* text);
ChatCommand const* FindCommand(char const* text); ChatCommand const* FindCommand(char const* text);
@ -120,17 +120,17 @@ class MANGOS_DLL_SPEC ChatHandler
bool HasLowerSecurity(Player* target, ObjectGuid guid = ObjectGuid(), bool strong = false); bool HasLowerSecurity(Player* target, ObjectGuid guid = ObjectGuid(), bool strong = false);
bool HasLowerSecurityAccount(WorldSession* target, uint32 account, bool strong = false); bool HasLowerSecurityAccount(WorldSession* target, uint32 account, bool strong = false);
void SendGlobalSysMessage(const char *str); void SendGlobalSysMessage(const char* str);
bool SetDataForCommandInTable(ChatCommand *table, const char* text, uint32 security, std::string const& help); bool SetDataForCommandInTable(ChatCommand* table, const char* text, uint32 security, std::string const& help);
void ExecuteCommand(const char* text); void ExecuteCommand(const char* text);
void LogCommand(char const* fullcmd); void LogCommand(char const* fullcmd);
bool ShowHelpForCommand(ChatCommand *table, const char* cmd); bool ShowHelpForCommand(ChatCommand* table, const char* cmd);
bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd); bool ShowHelpForSubCommands(ChatCommand* table, char const* cmd);
ChatCommandSearchResult FindCommand(ChatCommand* table, char const*& text, ChatCommand*& command, ChatCommand** parentCommand = NULL, std::string* cmdNamePtr = NULL, bool allAvailable = false, bool exactlyName = false); ChatCommandSearchResult FindCommand(ChatCommand* table, char const*& text, ChatCommand*& command, ChatCommand** parentCommand = NULL, std::string* cmdNamePtr = NULL, bool allAvailable = false, bool exactlyName = false);
void CheckIntegrity(ChatCommand *table, ChatCommand *parentCommand); void CheckIntegrity(ChatCommand* table, ChatCommand* parentCommand);
ChatCommand* getCommandTable(); ChatCommand* getCommandTable();
bool HandleAccountCommand(char* args); bool HandleAccountCommand(char* args);
@ -622,13 +622,13 @@ class MANGOS_DLL_SPEC ChatHandler
bool ExtractFloat(char** args, float& val); bool ExtractFloat(char** args, float& val);
bool ExtractOptFloat(char** args, float& val, float defVal); bool ExtractOptFloat(char** args, float& val, float defVal);
char* ExtractQuotedArg(char** args, bool asis = false); char* ExtractQuotedArg(char** args, bool asis = false);
// string with " or [] or ' around // string with " or [] or ' around
char* ExtractLiteralArg(char** args, char const* lit = NULL); char* ExtractLiteralArg(char** args, char const* lit = NULL);
// literal string (until whitespace and not started from "['|), any or 'lit' if provided // literal string (until whitespace and not started from "['|), any or 'lit' if provided
char* ExtractQuotedOrLiteralArg(char** args, bool asis = false); char* ExtractQuotedOrLiteralArg(char** args, bool asis = false);
bool ExtractOnOff(char** args, bool& value); bool ExtractOnOff(char** args, bool& value);
char* ExtractLinkArg(char** args, char const* const* linkTypes = NULL, int* foundIdx = NULL, char** keyPair = NULL, char** somethingPair = NULL); char* ExtractLinkArg(char** args, char const* const* linkTypes = NULL, int* foundIdx = NULL, char** keyPair = NULL, char** somethingPair = NULL);
// shift-link like arg (with aditional info if need) // shift-link like arg (with aditional info if need)
char* ExtractArg(char** args, bool asis = false); // any name/number/quote/shift-link strings char* ExtractArg(char** args, bool asis = false); // any name/number/quote/shift-link strings
char* ExtractOptNotLastArg(char** args); // extract name/number/quote/shift-link arg only if more data in args for parse char* ExtractOptNotLastArg(char** args); // extract name/number/quote/shift-link arg only if more data in args for parse
@ -644,7 +644,7 @@ class MANGOS_DLL_SPEC ChatHandler
bool ExtractRaceMask(char** text, uint32& raceMask, char const** maskName = NULL); bool ExtractRaceMask(char** text, uint32& raceMask, char const** maskName = NULL);
std::string ExtractPlayerNameFromLink(char** text); std::string ExtractPlayerNameFromLink(char** text);
bool ExtractPlayerTarget(char** args, Player** player, ObjectGuid* player_guid = NULL, std::string* player_name = NULL); bool ExtractPlayerTarget(char** args, Player** player, ObjectGuid* player_guid = NULL, std::string* player_name = NULL);
// select by arg (name/link) or in-game selection online/offline player // select by arg (name/link) or in-game selection online/offline player
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; } std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
std::string GetNameLink(Player* chr) const; std::string GetNameLink(Player* chr) const;
@ -653,16 +653,16 @@ class MANGOS_DLL_SPEC ChatHandler
// Utility methods for commands // Utility methods for commands
bool ShowAccountListHelper(QueryResult* result, uint32* limit = NULL, bool title = true, bool error = true); bool ShowAccountListHelper(QueryResult* result, uint32* limit = NULL, bool title = true, bool error = true);
void ShowAchievementListHelper(AchievementEntry const * achEntry, LocaleConstant loc, time_t const* date = NULL, Player* target = NULL); void ShowAchievementListHelper(AchievementEntry const* achEntry, LocaleConstant loc, time_t const* date = NULL, Player* target = NULL);
void ShowAchievementCriteriaListHelper(AchievementCriteriaEntry const* criEntry, AchievementEntry const * achEntry, LocaleConstant loc, Player* target = NULL); void ShowAchievementCriteriaListHelper(AchievementCriteriaEntry const* criEntry, AchievementEntry const* achEntry, LocaleConstant loc, Player* target = NULL);
void ShowFactionListHelper(FactionEntry const * factionEntry, LocaleConstant loc, FactionState const* repState = NULL, Player * target = NULL ); void ShowFactionListHelper(FactionEntry const* factionEntry, LocaleConstant loc, FactionState const* repState = NULL, Player* target = NULL);
void ShowItemListHelper(uint32 itemId, int loc_idx, Player* target = NULL); void ShowItemListHelper(uint32 itemId, int loc_idx, Player* target = NULL);
void ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* target = NULL); void ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* target = NULL);
bool ShowPlayerListHelper(QueryResult* result, uint32* limit = NULL, bool title = true, bool error = true); bool ShowPlayerListHelper(QueryResult* result, uint32* limit = NULL, bool title = true, bool error = true);
void ShowSpellListHelper(Player* target, SpellEntry const* spellInfo, LocaleConstant loc); void ShowSpellListHelper(Player* target, SpellEntry const* spellInfo, LocaleConstant loc);
void ShowPoolListHelper(uint16 pool_id); void ShowPoolListHelper(uint16 pool_id);
void ShowTicket(GMTicket const* ticket); void ShowTicket(GMTicket const* ticket);
void ShowTriggerListHelper(AreaTriggerEntry const * atEntry); void ShowTriggerListHelper(AreaTriggerEntry const* atEntry);
void ShowTriggerTargetListHelper(uint32 id, AreaTrigger const* at, bool subpart = false); void ShowTriggerTargetListHelper(uint32 id, AreaTrigger const* at, bool subpart = false);
bool LookupPlayerSearchCommand(QueryResult* result, uint32* limit = NULL); bool LookupPlayerSearchCommand(QueryResult* result, uint32* limit = NULL);
bool HandleBanListHelper(QueryResult* result); bool HandleBanListHelper(QueryResult* result);
@ -703,9 +703,9 @@ class MANGOS_DLL_SPEC ChatHandler
void HandleCharacterDeletedListHelper(DeletedInfoList const& foundList); void HandleCharacterDeletedListHelper(DeletedInfoList const& foundList);
void HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo); void HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo);
void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; void SetSentErrorMessage(bool val) { sentErrorMessage = val;};
private: private:
WorldSession * m_session; // != NULL for chat command call and NULL for CLI command WorldSession* m_session; // != NULL for chat command call and NULL for CLI command
// common global flag // common global flag
static bool load_command_table; static bool load_command_table;
@ -720,11 +720,11 @@ class CliHandler : public ChatHandler
: m_accountId(accountId), m_loginAccessLevel(accessLevel), m_callbackArg(callbackArg), m_print(zprint) {} : m_accountId(accountId), m_loginAccessLevel(accessLevel), m_callbackArg(callbackArg), m_print(zprint) {}
// overwrite functions // overwrite functions
const char *GetMangosString(int32 entry) const; const char* GetMangosString(int32 entry) const;
uint32 GetAccountId() const; uint32 GetAccountId() const;
AccountTypes GetAccessLevel() const; AccountTypes GetAccessLevel() const;
bool isAvailable(ChatCommand const& cmd) const; bool isAvailable(ChatCommand const& cmd) const;
void SendSysMessage(const char *str); void SendSysMessage(const char* str);
std::string GetNameLink() const; std::string GetNameLink() const;
bool needReportToTarget(Player* chr) const; bool needReportToTarget(Player* chr) const;
LocaleConstant GetSessionDbcLocale() const; LocaleConstant GetSessionDbcLocale() const;

View file

@ -41,14 +41,14 @@ bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg
if (lang != LANG_ADDON) if (lang != LANG_ADDON)
{ {
// strip invisible characters for non-addon messages // strip invisible characters for non-addon messages
if(sWorld.getConfig(CONFIG_BOOL_CHAT_FAKE_MESSAGE_PREVENTING)) if (sWorld.getConfig(CONFIG_BOOL_CHAT_FAKE_MESSAGE_PREVENTING))
stripLineInvisibleChars(msg); stripLineInvisibleChars(msg);
if (sWorld.getConfig(CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_SEVERITY) && GetSecurity() < SEC_MODERATOR if (sWorld.getConfig(CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_SEVERITY) && GetSecurity() < SEC_MODERATOR
&& !ChatHandler(this).isValidChatMessage(msg.c_str())) && !ChatHandler(this).isValidChatMessage(msg.c_str()))
{ {
sLog.outError("Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName(), sLog.outError("Player %s (GUID: %u) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName(),
GetPlayer()->GetGUIDLow(), msg.c_str()); GetPlayer()->GetGUIDLow(), msg.c_str());
if (sWorld.getConfig(CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_KICK)) if (sWorld.getConfig(CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_KICK))
KickPlayer(); KickPlayer();
return false; return false;
@ -58,7 +58,7 @@ bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg
return true; return true;
} }
void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data ) void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
{ {
uint32 type; uint32 type;
uint32 lang; uint32 lang;
@ -66,45 +66,45 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
recv_data >> type; recv_data >> type;
recv_data >> lang; recv_data >> lang;
if(type >= MAX_CHAT_MSG_TYPE) if (type >= MAX_CHAT_MSG_TYPE)
{ {
sLog.outError("CHAT: Wrong message type received: %u", type); sLog.outError("CHAT: Wrong message type received: %u", type);
return; return;
} }
DEBUG_LOG("CHAT: packet received. type %u, lang %u", type, lang ); DEBUG_LOG("CHAT: packet received. type %u, lang %u", type, lang);
// prevent talking at unknown language (cheating) // prevent talking at unknown language (cheating)
LanguageDesc const* langDesc = GetLanguageDescByID(lang); LanguageDesc const* langDesc = GetLanguageDescByID(lang);
if(!langDesc) if (!langDesc)
{ {
SendNotification(LANG_UNKNOWN_LANGUAGE); SendNotification(LANG_UNKNOWN_LANGUAGE);
return; return;
} }
if(langDesc->skill_id != 0 && !_player->HasSkill(langDesc->skill_id)) if (langDesc->skill_id != 0 && !_player->HasSkill(langDesc->skill_id))
{ {
// also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language) // also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language)
Unit::AuraList const& langAuras = _player->GetAurasByType(SPELL_AURA_COMPREHEND_LANGUAGE); Unit::AuraList const& langAuras = _player->GetAurasByType(SPELL_AURA_COMPREHEND_LANGUAGE);
bool foundAura = false; bool foundAura = false;
for(Unit::AuraList::const_iterator i = langAuras.begin(); i != langAuras.end(); ++i) for (Unit::AuraList::const_iterator i = langAuras.begin(); i != langAuras.end(); ++i)
{ {
if((*i)->GetModifier()->m_miscvalue == int32(lang)) if ((*i)->GetModifier()->m_miscvalue == int32(lang))
{ {
foundAura = true; foundAura = true;
break; break;
} }
} }
if(!foundAura) if (!foundAura)
{ {
SendNotification(LANG_NOT_LEARNED_LANGUAGE); SendNotification(LANG_NOT_LEARNED_LANGUAGE);
return; return;
} }
} }
if(lang == LANG_ADDON) if (lang == LANG_ADDON)
{ {
// Disabled addon channel? // Disabled addon channel?
if(!sWorld.getConfig(CONFIG_BOOL_ADDON_CHANNEL)) if (!sWorld.getConfig(CONFIG_BOOL_ADDON_CHANNEL))
return; return;
} }
// LANG_ADDON should not be changed nor be affected by flood control // LANG_ADDON should not be changed nor be affected by flood control
@ -120,20 +120,20 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
lang = LANG_UNIVERSAL; lang = LANG_UNIVERSAL;
else else
{ {
switch(type) switch (type)
{ {
case CHAT_MSG_PARTY: case CHAT_MSG_PARTY:
case CHAT_MSG_RAID: case CHAT_MSG_RAID:
case CHAT_MSG_RAID_LEADER: case CHAT_MSG_RAID_LEADER:
case CHAT_MSG_RAID_WARNING: case CHAT_MSG_RAID_WARNING:
// allow two side chat at group channel if two side group allowed // allow two side chat at group channel if two side group allowed
if(sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP)) if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP))
lang = LANG_UNIVERSAL; lang = LANG_UNIVERSAL;
break; break;
case CHAT_MSG_GUILD: case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER: case CHAT_MSG_OFFICER:
// allow two side chat at guild channel if two side guild allowed // allow two side chat at guild channel if two side guild allowed
if(sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD)) if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD))
lang = LANG_UNIVERSAL; lang = LANG_UNIVERSAL;
break; break;
} }
@ -141,7 +141,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
// but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used) // but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
Unit::AuraList const& ModLangAuras = _player->GetAurasByType(SPELL_AURA_MOD_LANGUAGE); Unit::AuraList const& ModLangAuras = _player->GetAurasByType(SPELL_AURA_MOD_LANGUAGE);
if(!ModLangAuras.empty()) if (!ModLangAuras.empty())
lang = ModLangAuras.front()->GetModifier()->m_miscvalue; lang = ModLangAuras.front()->GetModifier()->m_miscvalue;
} }
@ -158,7 +158,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
} }
} }
switch(type) switch (type)
{ {
case CHAT_MSG_SAY: case CHAT_MSG_SAY:
case CHAT_MSG_EMOTE: case CHAT_MSG_EMOTE:
@ -167,7 +167,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg; std::string msg;
recv_data >> msg; recv_data >> msg;
if(msg.empty()) if (msg.empty())
break; break;
if (ChatHandler(this).ParseCommands(msg.c_str())) if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -176,14 +176,14 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
if(type == CHAT_MSG_SAY) if (type == CHAT_MSG_SAY)
GetPlayer()->Say(msg, lang); GetPlayer()->Say(msg, lang);
else if(type == CHAT_MSG_EMOTE) else if (type == CHAT_MSG_EMOTE)
GetPlayer()->TextEmote(msg); GetPlayer()->TextEmote(msg);
else if(type == CHAT_MSG_YELL) else if (type == CHAT_MSG_YELL)
GetPlayer()->Yell(msg, lang); GetPlayer()->Yell(msg, lang);
} break; } break;
@ -196,16 +196,16 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
if(!normalizePlayerName(to)) if (!normalizePlayerName(to))
{ {
SendPlayerNotFoundNotice(to); SendPlayerNotFoundNotice(to);
break; break;
} }
Player *player = sObjectMgr.GetPlayer(to.c_str()); Player* player = sObjectMgr.GetPlayer(to.c_str());
uint32 tSecurity = GetSecurity(); uint32 tSecurity = GetSecurity();
uint32 pSecurity = player ? player->GetSession()->GetSecurity() : SEC_PLAYER; uint32 pSecurity = player ? player->GetSession()->GetSecurity() : SEC_PLAYER;
if (!player || (tSecurity == SEC_PLAYER && pSecurity > SEC_PLAYER && !player->isAcceptWhispers())) if (!player || (tSecurity == SEC_PLAYER && pSecurity > SEC_PLAYER && !player->isAcceptWhispers()))
@ -214,7 +214,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
return; return;
} }
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT) && tSecurity == SEC_PLAYER && pSecurity == SEC_PLAYER ) if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT) && tSecurity == SEC_PLAYER && pSecurity == SEC_PLAYER)
{ {
if (GetPlayer()->GetTeam() != player->GetTeam()) if (GetPlayer()->GetTeam() != player->GetTeam())
{ {
@ -232,7 +232,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg; std::string msg;
recv_data >> msg; recv_data >> msg;
if(msg.empty()) if (msg.empty())
break; break;
if (ChatHandler(this).ParseCommands(msg.c_str())) if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -241,15 +241,15 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
// if player is in battleground, he cannot say to battleground members by /p // if player is in battleground, he cannot say to battleground members by /p
Group *group = GetPlayer()->GetOriginalGroup(); Group* group = GetPlayer()->GetOriginalGroup();
if(!group) if (!group)
{ {
group = _player->GetGroup(); group = _player->GetGroup();
if(!group || group->isBGGroup()) if (!group || group->isBGGroup())
return; return;
} }
@ -267,7 +267,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg; std::string msg;
recv_data >> msg; recv_data >> msg;
if(msg.empty()) if (msg.empty())
break; break;
if (ChatHandler(this).ParseCommands(msg.c_str())) if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -276,7 +276,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
if (GetPlayer()->GetGuildId()) if (GetPlayer()->GetGuildId())
@ -290,7 +290,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg; std::string msg;
recv_data >> msg; recv_data >> msg;
if(msg.empty()) if (msg.empty())
break; break;
if (ChatHandler(this).ParseCommands(msg.c_str())) if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -299,7 +299,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
if (GetPlayer()->GetGuildId()) if (GetPlayer()->GetGuildId())
@ -313,7 +313,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg; std::string msg;
recv_data >> msg; recv_data >> msg;
if(msg.empty()) if (msg.empty())
break; break;
if (ChatHandler(this).ParseCommands(msg.c_str())) if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -322,15 +322,15 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
// if player is in battleground, he cannot say to battleground members by /ra // if player is in battleground, he cannot say to battleground members by /ra
Group *group = GetPlayer()->GetOriginalGroup(); Group* group = GetPlayer()->GetOriginalGroup();
if(!group) if (!group)
{ {
group = GetPlayer()->GetGroup(); group = GetPlayer()->GetGroup();
if(!group || group->isBGGroup() || !group->isRaidGroup()) if (!group || group->isBGGroup() || !group->isRaidGroup())
return; return;
} }
@ -343,7 +343,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg; std::string msg;
recv_data >> msg; recv_data >> msg;
if(msg.empty()) if (msg.empty())
break; break;
if (ChatHandler(this).ParseCommands(msg.c_str())) if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -352,11 +352,11 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
// if player is in battleground, he cannot say to battleground members by /ra // if player is in battleground, he cannot say to battleground members by /ra
Group *group = GetPlayer()->GetOriginalGroup(); Group* group = GetPlayer()->GetOriginalGroup();
if (!group) if (!group)
{ {
group = GetPlayer()->GetGroup(); group = GetPlayer()->GetGroup();
@ -377,12 +377,12 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if (!group || !group->isRaidGroup() || if (!group || !group->isRaidGroup() ||
!(group->IsLeader(GetPlayer()->GetObjectGuid()) || group->IsAssistant(GetPlayer()->GetObjectGuid()))) !(group->IsLeader(GetPlayer()->GetObjectGuid()) || group->IsAssistant(GetPlayer()->GetObjectGuid())))
return; return;
WorldPacket data; WorldPacket data;
@ -399,12 +399,12 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
// battleground raid is always in Player->GetGroup(), never in GetOriginalGroup() // battleground raid is always in Player->GetGroup(), never in GetOriginalGroup()
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if(!group || !group->isBGGroup()) if (!group || !group->isBGGroup())
return; return;
WorldPacket data; WorldPacket data;
@ -420,11 +420,11 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
// battleground raid is always in Player->GetGroup(), never in GetOriginalGroup() // battleground raid is always in Player->GetGroup(), never in GetOriginalGroup()
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetObjectGuid())) if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetObjectGuid()))
return; return;
@ -442,11 +442,11 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return; return;
if(msg.empty()) if (msg.empty())
break; break;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channel, _player)) if (Channel* chn = cMgr->GetChannel(channel, _player))
chn->Say(_player->GetObjectGuid(), msg.c_str(), lang); chn->Say(_player->GetObjectGuid(), msg.c_str(), lang);
} break; } break;
@ -506,9 +506,9 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
} }
} }
void WorldSession::HandleEmoteOpcode( WorldPacket & recv_data ) void WorldSession::HandleEmoteOpcode(WorldPacket& recv_data)
{ {
if(!GetPlayer()->isAlive() || GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (!GetPlayer()->isAlive() || GetPlayer()->hasUnitState(UNIT_STAT_DIED))
return; return;
uint32 emote; uint32 emote;
@ -548,9 +548,9 @@ namespace MaNGOS
}; };
} // namespace MaNGOS } // namespace MaNGOS
void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data ) void WorldSession::HandleTextEmoteOpcode(WorldPacket& recv_data)
{ {
if(!GetPlayer()->isAlive()) if (!GetPlayer()->isAlive())
return; return;
if (!GetPlayer()->CanSpeak()) if (!GetPlayer()->CanSpeak())
@ -567,13 +567,13 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
recv_data >> emoteNum; recv_data >> emoteNum;
recv_data >> guid; recv_data >> guid;
EmotesTextEntry const *em = sEmotesTextStore.LookupEntry(text_emote); EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(text_emote);
if (!em) if (!em)
return; return;
uint32 emote_id = em->textid; uint32 emote_id = em->textid;
switch(emote_id) switch (emote_id)
{ {
case EMOTE_STATE_SLEEP: case EMOTE_STATE_SLEEP:
case EMOTE_STATE_SIT: case EMOTE_STATE_SIT:
@ -605,7 +605,7 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(), text_emote); ((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(), text_emote);
} }
void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data ) void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data)
{ {
ObjectGuid iguid; ObjectGuid iguid;
uint8 unk; uint8 unk;
@ -614,8 +614,8 @@ void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data )
recv_data >> iguid; recv_data >> iguid;
recv_data >> unk; // probably related to spam reporting recv_data >> unk; // probably related to spam reporting
Player *player = sObjectMgr.GetPlayer(iguid); Player* player = sObjectMgr.GetPlayer(iguid);
if(!player || !player->GetSession()) if (!player || !player->GetSession())
return; return;
WorldPacket data; WorldPacket data;

View file

@ -24,40 +24,40 @@
#include "ObjectGuid.h" #include "ObjectGuid.h"
#include "Player.h" #include "Player.h"
void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data ) void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: Recvd CMSG_ATTACKSWING Message %s", guid.GetString().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: Recvd CMSG_ATTACKSWING Message %s", guid.GetString().c_str());
if(!guid.IsUnit()) if (!guid.IsUnit())
{ {
sLog.outError("WORLD: %s isn't unit", guid.GetString().c_str()); sLog.outError("WORLD: %s isn't unit", guid.GetString().c_str());
return; return;
} }
Unit *pEnemy = _player->GetMap()->GetUnit(guid); Unit* pEnemy = _player->GetMap()->GetUnit(guid);
if(!pEnemy) if (!pEnemy)
{ {
sLog.outError( "WORLD: Enemy %s not found", guid.GetString().c_str()); sLog.outError("WORLD: Enemy %s not found", guid.GetString().c_str());
// stop attack state at client // stop attack state at client
SendAttackStop(NULL); SendAttackStop(NULL);
return; return;
} }
if(_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) if (_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
{ {
sLog.outError( "WORLD: Enemy %s is friendly",guid.GetString().c_str()); sLog.outError("WORLD: Enemy %s is friendly",guid.GetString().c_str());
// stop attack state at client // stop attack state at client
SendAttackStop(pEnemy); SendAttackStop(pEnemy);
return; return;
} }
if(!pEnemy->isAlive()) if (!pEnemy->isAlive())
{ {
// client can generate swing to known dead target if autoswitch between autoshot and autohit is enabled in client options // client can generate swing to known dead target if autoswitch between autoshot and autohit is enabled in client options
// stop attack state at client // stop attack state at client
@ -68,19 +68,19 @@ void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
_player->Attack(pEnemy,true); _player->Attack(pEnemy,true);
} }
void WorldSession::HandleAttackStopOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleAttackStopOpcode(WorldPacket& /*recv_data*/)
{ {
GetPlayer()->AttackStop(); GetPlayer()->AttackStop();
} }
void WorldSession::HandleSetSheathedOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetSheathedOpcode(WorldPacket& recv_data)
{ {
uint32 sheathed; uint32 sheathed;
recv_data >> sheathed; recv_data >> sheathed;
//DEBUG_LOG( "WORLD: Recvd CMSG_SETSHEATHED Message guidlow:%u value1:%u", GetPlayer()->GetGUIDLow(), sheathed ); //DEBUG_LOG( "WORLD: Recvd CMSG_SETSHEATHED Message guidlow:%u value1:%u", GetPlayer()->GetGUIDLow(), sheathed );
if(sheathed >= MAX_SHEATH_STATE) if (sheathed >= MAX_SHEATH_STATE)
{ {
sLog.outError("Unknown sheath state %u ??",sheathed); sLog.outError("Unknown sheath state %u ??",sheathed);
return; return;
@ -91,7 +91,7 @@ void WorldSession::HandleSetSheathedOpcode( WorldPacket & recv_data )
void WorldSession::SendAttackStop(Unit const* enemy) void WorldSession::SendAttackStop(Unit const* enemy)
{ {
WorldPacket data( SMSG_ATTACKSTOP, (4+20) ); // we guess size WorldPacket data(SMSG_ATTACKSTOP, (4+20)); // we guess size
data << GetPlayer()->GetPackGUID(); data << GetPlayer()->GetPackGUID();
data << (enemy ? enemy->GetPackGUID() : PackedGuid()); // must be packed guid data << (enemy ? enemy->GetPackGUID() : PackedGuid()); // must be packed guid
data << uint32(0); // unk, can be 1 also data << uint32(0); // unk, can be 1 also

View file

@ -25,7 +25,7 @@
#include "PathFinder.h" #include "PathFinder.h"
template<class T> template<class T>
void ConfusedMovementGenerator<T>::Initialize(T &unit) void ConfusedMovementGenerator<T>::Initialize(T& unit)
{ {
// set initial position // set initial position
unit.GetPosition(i_x, i_y, i_z); unit.GetPosition(i_x, i_y, i_z);
@ -35,14 +35,14 @@ void ConfusedMovementGenerator<T>::Initialize(T &unit)
} }
template<class T> template<class T>
void ConfusedMovementGenerator<T>::Interrupt(T &unit) void ConfusedMovementGenerator<T>::Interrupt(T& unit)
{ {
// confused state still applied while movegen disabled // confused state still applied while movegen disabled
unit.clearUnitState(UNIT_STAT_CONFUSED_MOVE); unit.clearUnitState(UNIT_STAT_CONFUSED_MOVE);
} }
template<class T> template<class T>
void ConfusedMovementGenerator<T>::Reset(T &unit) void ConfusedMovementGenerator<T>::Reset(T& unit)
{ {
i_nextMoveTime.Reset(0); i_nextMoveTime.Reset(0);
unit.StopMoving(); unit.StopMoving();
@ -50,7 +50,7 @@ void ConfusedMovementGenerator<T>::Reset(T &unit)
} }
template<class T> template<class T>
bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff) bool ConfusedMovementGenerator<T>::Update(T& unit, const uint32& diff)
{ {
// ignore in case other no reaction state // ignore in case other no reaction state
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_CONFUSED)) if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_CONFUSED))
@ -68,7 +68,7 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
{ {
// waiting for next move // waiting for next move
i_nextMoveTime.Update(diff); i_nextMoveTime.Update(diff);
if(i_nextMoveTime.Passed() ) if (i_nextMoveTime.Passed())
{ {
// start moving // start moving
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE); unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
@ -82,7 +82,7 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
PathFinder path(&unit); PathFinder path(&unit);
path.setPathLengthLimit(30.0f); path.setPathLengthLimit(30.0f);
path.calculate(x, y, z); path.calculate(x, y, z);
if(path.getPathType() & PATHFIND_NOPATH) if (path.getPathType() & PATHFIND_NOPATH)
{ {
i_nextMoveTime.Reset(urand(800, 1000)); i_nextMoveTime.Reset(urand(800, 1000));
return true; return true;
@ -99,23 +99,23 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
} }
template<> template<>
void ConfusedMovementGenerator<Player>::Finalize(Player &unit) void ConfusedMovementGenerator<Player>::Finalize(Player& unit)
{ {
unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
unit.StopMoving(); unit.StopMoving();
} }
template<> template<>
void ConfusedMovementGenerator<Creature>::Finalize(Creature &unit) void ConfusedMovementGenerator<Creature>::Finalize(Creature& unit)
{ {
unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE);
} }
template void ConfusedMovementGenerator<Player>::Initialize(Player &player); template void ConfusedMovementGenerator<Player>::Initialize(Player& player);
template void ConfusedMovementGenerator<Creature>::Initialize(Creature &creature); template void ConfusedMovementGenerator<Creature>::Initialize(Creature& creature);
template void ConfusedMovementGenerator<Player>::Interrupt(Player &player); template void ConfusedMovementGenerator<Player>::Interrupt(Player& player);
template void ConfusedMovementGenerator<Creature>::Interrupt(Creature &creature); template void ConfusedMovementGenerator<Creature>::Interrupt(Creature& creature);
template void ConfusedMovementGenerator<Player>::Reset(Player &player); template void ConfusedMovementGenerator<Player>::Reset(Player& player);
template void ConfusedMovementGenerator<Creature>::Reset(Creature &creature); template void ConfusedMovementGenerator<Creature>::Reset(Creature& creature);
template bool ConfusedMovementGenerator<Player>::Update(Player &player, const uint32 &diff); template bool ConfusedMovementGenerator<Player>::Update(Player& player, const uint32& diff);
template bool ConfusedMovementGenerator<Creature>::Update(Creature &creature, const uint32 &diff); template bool ConfusedMovementGenerator<Creature>::Update(Creature& creature, const uint32& diff);

View file

@ -24,16 +24,16 @@
template<class T> template<class T>
class MANGOS_DLL_SPEC ConfusedMovementGenerator class MANGOS_DLL_SPEC ConfusedMovementGenerator
: public MovementGeneratorMedium< T, ConfusedMovementGenerator<T> > : public MovementGeneratorMedium< T, ConfusedMovementGenerator<T> >
{ {
public: public:
explicit ConfusedMovementGenerator() : i_nextMoveTime(0) {} explicit ConfusedMovementGenerator() : i_nextMoveTime(0) {}
void Initialize(T &); void Initialize(T&);
void Finalize(T &); void Finalize(T&);
void Interrupt(T &); void Interrupt(T&);
void Reset(T &); void Reset(T&);
bool Update(T &, const uint32 &); bool Update(T&, const uint32&);
MovementGeneratorType GetMovementGeneratorType() const { return CONFUSED_MOTION_TYPE; } MovementGeneratorType GetMovementGeneratorType() const { return CONFUSED_MOTION_TYPE; }
private: private:

View file

@ -50,7 +50,7 @@ Corpse::~Corpse()
void Corpse::AddToWorld() void Corpse::AddToWorld()
{ {
///- Register the corpse for guid lookup ///- Register the corpse for guid lookup
if(!IsInWorld()) if (!IsInWorld())
sObjectAccessor.AddObject(this); sObjectAccessor.AddObject(this);
Object::AddToWorld(); Object::AddToWorld();
@ -59,19 +59,19 @@ void Corpse::AddToWorld()
void Corpse::RemoveFromWorld() void Corpse::RemoveFromWorld()
{ {
///- Remove the corpse from the accessor ///- Remove the corpse from the accessor
if(IsInWorld()) if (IsInWorld())
sObjectAccessor.RemoveObject(this); sObjectAccessor.RemoveObject(this);
Object::RemoveFromWorld(); Object::RemoveFromWorld();
} }
bool Corpse::Create( uint32 guidlow ) bool Corpse::Create(uint32 guidlow)
{ {
Object::_Create(guidlow, 0, HIGHGUID_CORPSE); Object::_Create(guidlow, 0, HIGHGUID_CORPSE);
return true; return true;
} }
bool Corpse::Create( uint32 guidlow, Player *owner) bool Corpse::Create(uint32 guidlow, Player* owner)
{ {
MANGOS_ASSERT(owner); MANGOS_ASSERT(owner);
@ -82,10 +82,10 @@ bool Corpse::Create( uint32 guidlow, Player *owner)
//in other way we will get a crash in Corpse::SaveToDB() //in other way we will get a crash in Corpse::SaveToDB()
SetMap(owner->GetMap()); SetMap(owner->GetMap());
if(!IsPositionValid()) if (!IsPositionValid())
{ {
sLog.outError("Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)", sLog.outError("Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
guidlow, owner->GetName(), owner->GetPositionX(), owner->GetPositionY()); guidlow, owner->GetName(), owner->GetPositionX(), owner->GetPositionY());
return false; return false;
} }
@ -119,7 +119,7 @@ void Corpse::SaveToDB()
<< uint32(GetType()) << ", " << uint32(GetType()) << ", "
<< int(GetInstanceId()) << ", " << int(GetInstanceId()) << ", "
<< uint16(GetPhaseMask()) << ")"; // prevent out of range error << uint16(GetPhaseMask()) << ")"; // prevent out of range error
CharacterDatabase.Execute( ss.str().c_str() ); CharacterDatabase.Execute(ss.str().c_str());
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
} }
@ -149,7 +149,7 @@ void Corpse::DeleteFromDB()
stmt.PExecute(GetOwnerGuid().GetCounter()); stmt.PExecute(GetOwnerGuid().GetCounter());
} }
bool Corpse::LoadFromDB(uint32 lowguid, Field *fields) bool Corpse::LoadFromDB(uint32 lowguid, Field* fields)
{ {
//// 0 1 2 3 4 5 6 //// 0 1 2 3 4 5 6
//QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map," //QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map,"
@ -167,7 +167,7 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
m_time = time_t(fields[7].GetUInt64()); m_time = time_t(fields[7].GetUInt64());
m_type = CorpseType(fields[8].GetUInt32()); m_type = CorpseType(fields[8].GetUInt32());
if(m_type >= MAX_CORPSE_TYPE) if (m_type >= MAX_CORPSE_TYPE)
{ {
sLog.outError("%s Owner %s have wrong corpse type (%i), not load.", GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), m_type); sLog.outError("%s Owner %s have wrong corpse type (%i), not load.", GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), m_type);
return false; return false;
@ -192,8 +192,8 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
SetObjectScale(DEFAULT_OBJECT_SCALE); SetObjectScale(DEFAULT_OBJECT_SCALE);
PlayerInfo const *info = sObjectMgr.GetPlayerInfo(race, _class); PlayerInfo const* info = sObjectMgr.GetPlayerInfo(race, _class);
if(!info) if (!info)
{ {
sLog.outError("Player %u has incorrect race/class pair.", GetGUIDLow()); sLog.outError("Player %u has incorrect race/class pair.", GetGUIDLow());
return false; return false;
@ -206,8 +206,8 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
{ {
uint32 visualbase = slot * 2; uint32 visualbase = slot * 2;
uint32 item_id = GetUInt32ValueFromArray(data, visualbase); uint32 item_id = GetUInt32ValueFromArray(data, visualbase);
const ItemPrototype * proto = ObjectMgr::GetItemPrototype(item_id); const ItemPrototype* proto = ObjectMgr::GetItemPrototype(item_id);
if(!proto) if (!proto)
{ {
SetUInt32Value(CORPSE_FIELD_ITEM + slot, 0); SetUInt32Value(CORPSE_FIELD_ITEM + slot, 0);
continue; continue;
@ -221,17 +221,17 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
uint8 hairstyle = (uint8)(playerBytes >> 16); uint8 hairstyle = (uint8)(playerBytes >> 16);
uint8 haircolor = (uint8)(playerBytes >> 24); uint8 haircolor = (uint8)(playerBytes >> 24);
uint8 facialhair = (uint8)(playerBytes2); uint8 facialhair = (uint8)(playerBytes2);
SetUInt32Value( CORPSE_FIELD_BYTES_1, ((0x00) | (race << 8) | (gender << 16) | (skin << 24)) ); SetUInt32Value(CORPSE_FIELD_BYTES_1, ((0x00) | (race << 8) | (gender << 16) | (skin << 24)));
SetUInt32Value( CORPSE_FIELD_BYTES_2, ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)) ); SetUInt32Value(CORPSE_FIELD_BYTES_2, ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)));
SetUInt32Value(CORPSE_FIELD_GUILD, guildId); SetUInt32Value(CORPSE_FIELD_GUILD, guildId);
uint32 flags = CORPSE_FLAG_UNK2; uint32 flags = CORPSE_FLAG_UNK2;
if(playerFlags & PLAYER_FLAGS_HIDE_HELM) if (playerFlags & PLAYER_FLAGS_HIDE_HELM)
flags |= CORPSE_FLAG_HIDE_HELM; flags |= CORPSE_FLAG_HIDE_HELM;
if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK) if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
flags |= CORPSE_FLAG_HIDE_CLOAK; flags |= CORPSE_FLAG_HIDE_CLOAK;
SetUInt32Value( CORPSE_FIELD_FLAGS, flags ); SetUInt32Value(CORPSE_FIELD_FLAGS, flags);
// no need to mark corpse as lootable, because corpses are not saved in battle grounds // no need to mark corpse as lootable, because corpses are not saved in battle grounds
@ -241,10 +241,10 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
SetPhaseMask(phaseMask, false); SetPhaseMask(phaseMask, false);
Relocate(positionX, positionY, positionZ, orientation); Relocate(positionX, positionY, positionZ, orientation);
if(!IsPositionValid()) if (!IsPositionValid())
{ {
sLog.outError("%s Owner %s not created. Suggested coordinates isn't valid (X: %f Y: %f)", sLog.outError("%s Owner %s not created. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), GetPositionX(), GetPositionY()); GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), GetPositionX(), GetPositionY());
return false; return false;
} }
@ -258,7 +258,7 @@ bool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint,
return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); return IsInWorld() && u->IsInWorld() && IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
} }
bool Corpse::IsHostileTo( Unit const* unit ) const bool Corpse::IsHostileTo(Unit const* unit) const
{ {
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid())) if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
return owner->IsHostileTo(unit); return owner->IsHostileTo(unit);
@ -266,7 +266,7 @@ bool Corpse::IsHostileTo( Unit const* unit ) const
return false; return false;
} }
bool Corpse::IsFriendlyTo( Unit const* unit ) const bool Corpse::IsFriendlyTo(Unit const* unit) const
{ {
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid())) if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
return owner->IsFriendlyTo(unit); return owner->IsFriendlyTo(unit);
@ -276,7 +276,7 @@ bool Corpse::IsFriendlyTo( Unit const* unit ) const
bool Corpse::IsExpired(time_t t) const bool Corpse::IsExpired(time_t t) const
{ {
if(m_type == CORPSE_BONES) if (m_type == CORPSE_BONES)
return m_time < t - 60*MINUTE; return m_time < t - 60*MINUTE;
else else
return m_time < t - 3*DAY; return m_time < t - 3*DAY;

View file

@ -50,17 +50,17 @@ enum CorpseFlags
class Corpse : public WorldObject class Corpse : public WorldObject
{ {
public: public:
explicit Corpse( CorpseType type = CORPSE_BONES ); explicit Corpse(CorpseType type = CORPSE_BONES);
~Corpse( ); ~Corpse();
void AddToWorld(); void AddToWorld();
void RemoveFromWorld(); void RemoveFromWorld();
bool Create( uint32 guidlow ); bool Create(uint32 guidlow);
bool Create( uint32 guidlow, Player *owner ); bool Create(uint32 guidlow, Player* owner);
void SaveToDB(); void SaveToDB();
bool LoadFromDB(uint32 guid, Field *fields); bool LoadFromDB(uint32 guid, Field* fields);
void DeleteBonesFromWorld(); void DeleteBonesFromWorld();
void DeleteFromDB(); void DeleteFromDB();
@ -83,7 +83,7 @@ class Corpse : public WorldObject
Player* lootRecipient; Player* lootRecipient;
bool lootForBody; bool lootForBody;
GridReference<Corpse> &GetGridRef() { return m_gridRef; } GridReference<Corpse>& GetGridRef() { return m_gridRef; }
bool IsExpired(time_t t) const; bool IsExpired(time_t t) const;
private: private:

File diff suppressed because it is too large Load diff

View file

@ -152,11 +152,11 @@ struct CreatureInfo
SkillType GetRequiredLootSkill() const SkillType GetRequiredLootSkill() const
{ {
if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT) if (type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
return SKILL_HERBALISM; return SKILL_HERBALISM;
else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT) else if (type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
return SKILL_MINING; return SKILL_MINING;
else if(type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT) else if (type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
return SKILL_ENGINEERING; return SKILL_ENGINEERING;
else else
return SKILL_SKINNING; // normal case return SKILL_SKINNING; // normal case
@ -169,7 +169,7 @@ struct CreatureInfo
bool isTameable(bool exotic) const bool isTameable(bool exotic) const
{ {
if(type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE) == 0) if (type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
return false; return false;
// if can tame exotic then can tame any temable // if can tame exotic then can tame any temable
@ -328,22 +328,22 @@ struct VendorItemData
VendorItem* GetItem(uint32 slot) const VendorItem* GetItem(uint32 slot) const
{ {
if(slot>=m_items.size()) return NULL; if (slot>=m_items.size()) return NULL;
return m_items[slot]; return m_items[slot];
} }
bool Empty() const { return m_items.empty(); } bool Empty() const { return m_items.empty(); }
uint8 GetItemCount() const { return m_items.size(); } uint8 GetItemCount() const { return m_items.size(); }
void AddItem( uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost) void AddItem(uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost)
{ {
m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost)); m_items.push_back(new VendorItem(item, maxcount, ptime, ExtendedCost));
} }
bool RemoveItem( uint32 item_id ); bool RemoveItem(uint32 item_id);
VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const; VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const;
void Clear() void Clear()
{ {
for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr) for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
delete (*itr); delete(*itr);
m_items.clear(); m_items.clear();
} }
}; };
@ -388,7 +388,7 @@ struct TrainerSpellData
TrainerSpellMap spellList; TrainerSpellMap spellList;
uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value. uint32 trainerType; // trainer type based at trainer spells, can be different from creature_template value.
// req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2. // req. for correct show non-prof. trainers like weaponmaster, allowed values 0 and 2.
TrainerSpell const* Find(uint32 spell_id) const; TrainerSpell const* Find(uint32 spell_id) const;
void Clear() { spellList.clear(); } void Clear() { spellList.clear(); }
}; };
@ -418,7 +418,7 @@ struct CreatureCreatePos
// if dist == 0.0f -> exactly object coordinates used, in other case close point to object (CONTACT_DIST can be used as minimal distances) // if dist == 0.0f -> exactly object coordinates used, in other case close point to object (CONTACT_DIST can be used as minimal distances)
CreatureCreatePos(WorldObject* closeObject, float ori, float dist = 0.0f, float angle = 0.0f) CreatureCreatePos(WorldObject* closeObject, float ori, float dist = 0.0f, float angle = 0.0f)
: m_map(closeObject->GetMap()), m_phaseMask(closeObject->GetPhaseMask()), : m_map(closeObject->GetMap()), m_phaseMask(closeObject->GetPhaseMask()),
m_closeObject(closeObject), m_angle(angle), m_dist(dist) { m_pos.o = ori; } m_closeObject(closeObject), m_angle(angle), m_dist(dist) { m_pos.o = ori; }
public: public:
Map* GetMap() const { return m_map; } Map* GetMap() const { return m_map; }
uint32 GetPhaseMask() const { return m_phaseMask; } uint32 GetPhaseMask() const { return m_phaseMask; }
@ -454,7 +454,7 @@ enum TemporaryFactionFlags // Used at real fact
class MANGOS_DLL_SPEC Creature : public Unit class MANGOS_DLL_SPEC Creature : public Unit
{ {
CreatureAI *i_AI; CreatureAI* i_AI;
public: public:
@ -464,9 +464,9 @@ class MANGOS_DLL_SPEC Creature : public Unit
void AddToWorld(); void AddToWorld();
void RemoveFromWorld(); void RemoveFromWorld();
bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, Team team = TEAM_NONE, const CreatureData *data = NULL, GameEventCreatureData const* eventData = NULL); bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, Team team = TEAM_NONE, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL);
bool LoadCreatureAddon(bool reload); bool LoadCreatureAddon(bool reload);
void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f); void SelectLevel(const CreatureInfo* cinfo, float percentHealth = 100.0f, float percentMana = 100.0f);
void LoadEquipment(uint32 equip_entry, bool force=false); void LoadEquipment(uint32 equip_entry, bool force=false);
bool HasStaticDBSpawnData() const; // listed in `creature` table and have fixed in DB guid bool HasStaticDBSpawnData() const; // listed in `creature` table and have fixed in DB guid
@ -476,7 +476,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
void Update(uint32 update_diff, uint32 time) override; // overwrite Unit::Update void Update(uint32 update_diff, uint32 time) override; // overwrite Unit::Update
virtual void RegenerateAll(uint32 update_diff); virtual void RegenerateAll(uint32 update_diff);
void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const; void GetRespawnCoord(float& x, float& y, float& z, float* ori = NULL, float* dist =NULL) const;
uint32 GetEquipmentId() const { return m_equipmentId; } uint32 GetEquipmentId() const { return m_equipmentId; }
CreatureSubtype GetSubtype() const { return m_subtype; } CreatureSubtype GetSubtype() const { return m_subtype; }
@ -503,12 +503,12 @@ class MANGOS_DLL_SPEC Creature : public Unit
void FillGuidsListFromThreatList(GuidVector& guids, uint32 maxamount = 0); void FillGuidsListFromThreatList(GuidVector& guids, uint32 maxamount = 0);
bool IsImmuneToSpell(SpellEntry const* spellInfo); bool IsImmuneToSpell(SpellEntry const* spellInfo);
// redefine Unit::IsImmuneToSpell // redefine Unit::IsImmuneToSpell
bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; bool IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const;
// redefine Unit::IsImmuneToSpellEffect // redefine Unit::IsImmuneToSpellEffect
bool IsElite() const bool IsElite() const
{ {
if(IsPet()) if (IsPet())
return false; return false;
uint32 rank = GetCreatureInfo()->rank; uint32 rank = GetCreatureInfo()->rank;
@ -517,7 +517,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
bool IsWorldBoss() const bool IsWorldBoss() const
{ {
if(IsPet()) if (IsPet())
return false; return false;
return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS; return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
@ -574,10 +574,10 @@ class MANGOS_DLL_SPEC Creature : public Unit
TrainerSpellData const* GetTrainerTemplateSpells() const; TrainerSpellData const* GetTrainerTemplateSpells() const;
TrainerSpellData const* GetTrainerSpells() const; TrainerSpellData const* GetTrainerSpells() const;
CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; } CreatureInfo const* GetCreatureInfo() const { return m_creatureInfo; }
CreatureDataAddon const* GetCreatureAddon() const; CreatureDataAddon const* GetCreatureAddon() const;
static uint32 ChooseDisplayId(const CreatureInfo *cinfo, const CreatureData *data = NULL, GameEventCreatureData const* eventData = NULL); static uint32 ChooseDisplayId(const CreatureInfo* cinfo, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL);
std::string GetAIName() const; std::string GetAIName() const;
std::string GetScriptName() const; std::string GetScriptName() const;
@ -588,9 +588,9 @@ class MANGOS_DLL_SPEC Creature : public Unit
void SetDeathState(DeathState s); // overwrite virtual Unit::SetDeathState void SetDeathState(DeathState s); // overwrite virtual Unit::SetDeathState
bool LoadFromDB(uint32 guid, Map *map); bool LoadFromDB(uint32 guid, Map* map);
void SaveToDB(); void SaveToDB();
// overwrited in Pet // overwrited in Pet
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
virtual void DeleteFromDB(); // overwrited in Pet virtual void DeleteFromDB(); // overwrited in Pet
static void DeleteFromDB(uint32 lowguid, CreatureData const* data); static void DeleteFromDB(uint32 lowguid, CreatureData const* data);
@ -611,8 +611,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
void AllLootRemovedFromCorpse(); void AllLootRemovedFromCorpse();
Player* GetOriginalLootRecipient() const; // ignore group changes/etc, not for looting Player* GetOriginalLootRecipient() const; // ignore group changes/etc, not for looting
SpellEntry const *ReachWithSpellAttack(Unit *pVictim); SpellEntry const* ReachWithSpellAttack(Unit* pVictim);
SpellEntry const *ReachWithSpellCure(Unit *pVictim); SpellEntry const* ReachWithSpellCure(Unit* pVictim);
uint32 m_spells[CREATURE_MAX_SPELLS]; uint32 m_spells[CREATURE_MAX_SPELLS];
CreatureSpellCooldowns m_CreatureSpellCooldowns; CreatureSpellCooldowns m_CreatureSpellCooldowns;
@ -673,7 +673,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
bool HasQuest(uint32 quest_id) const; bool HasQuest(uint32 quest_id) const;
bool HasInvolvedQuest(uint32 quest_id) const; bool HasInvolvedQuest(uint32 quest_id) const;
GridReference<Creature> &GetGridRef() { return m_gridRef; } GridReference<Creature>& GetGridRef() { return m_gridRef; }
bool IsRegeneratingHealth() { return m_regenHealth; } bool IsRegeneratingHealth() { return m_regenHealth; }
virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; } virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
@ -685,25 +685,25 @@ class MANGOS_DLL_SPEC Creature : public Unit
} }
void SetCombatStartPosition(float x, float y, float z) { m_combatStartX = x; m_combatStartY = y; m_combatStartZ = z; } void SetCombatStartPosition(float x, float y, float z) { m_combatStartX = x; m_combatStartY = y; m_combatStartZ = z; }
void GetCombatStartPosition(float &x, float &y, float &z) { x = m_combatStartX; y = m_combatStartY; z = m_combatStartZ; } void GetCombatStartPosition(float& x, float& y, float& z) { x = m_combatStartX; y = m_combatStartY; z = m_combatStartZ; }
void SetSummonPoint(CreatureCreatePos const& pos) { m_summonPos = pos.m_pos; } void SetSummonPoint(CreatureCreatePos const& pos) { m_summonPos = pos.m_pos; }
void GetSummonPoint(float &fX, float &fY, float &fZ, float &fOrient) const { fX = m_summonPos.x; fY = m_summonPos.y; fZ = m_summonPos.z; fOrient = m_summonPos.o; } void GetSummonPoint(float& fX, float& fY, float& fZ, float& fOrient) const { fX = m_summonPos.x; fY = m_summonPos.y; fZ = m_summonPos.z; fOrient = m_summonPos.o; }
void SetDeadByDefault (bool death_state) { m_isDeadByDefault = death_state; } void SetDeadByDefault(bool death_state) { m_isDeadByDefault = death_state; }
void SetFactionTemporary(uint32 factionId, uint32 tempFactionFlags = TEMPFACTION_ALL); void SetFactionTemporary(uint32 factionId, uint32 tempFactionFlags = TEMPFACTION_ALL);
void ClearTemporaryFaction(); void ClearTemporaryFaction();
uint32 GetTemporaryFactionFlags() { return m_temporaryFactionFlags; } uint32 GetTemporaryFactionFlags() { return m_temporaryFactionFlags; }
void SendAreaSpiritHealerQueryOpcode(Player *pl); void SendAreaSpiritHealerQueryOpcode(Player* pl);
void SetVirtualItem(VirtualItemSlot slot, uint32 item_id) { SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot, item_id); } void SetVirtualItem(VirtualItemSlot slot, uint32 item_id) { SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot, item_id); }
protected: protected:
bool MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const* pSpellInfo, uint32 selectFlags) const; bool MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const* pSpellInfo, uint32 selectFlags) const;
bool CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team team, const CreatureData *data = NULL, GameEventCreatureData const* eventData =NULL); bool CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team team, const CreatureData* data = NULL, GameEventCreatureData const* eventData =NULL);
bool InitEntry(uint32 entry, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL); bool InitEntry(uint32 entry, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL);
uint32 m_groupLootTimer; // (msecs)timer used for group loot uint32 m_groupLootTimer; // (msecs)timer used for group loot

View file

@ -25,13 +25,13 @@ CreatureAI::~CreatureAI()
{ {
} }
void CreatureAI::AttackedBy( Unit* attacker ) void CreatureAI::AttackedBy(Unit* attacker)
{ {
if(!m_creature->getVictim()) if (!m_creature->getVictim())
AttackStart(attacker); AttackStart(attacker);
} }
CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry *pSpell, bool isTriggered) CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell, bool isTriggered)
{ {
// If not triggered, we check // If not triggered, we check
if (!isTriggered) if (!isTriggered)
@ -51,7 +51,7 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry *pSpell,
return CAST_FAIL_POWER; return CAST_FAIL_POWER;
} }
if (const SpellRangeEntry *pSpellRange = sSpellRangeStore.LookupEntry(pSpell->rangeIndex)) if (const SpellRangeEntry* pSpellRange = sSpellRangeStore.LookupEntry(pSpell->rangeIndex))
{ {
if (pTarget != m_creature) if (pTarget != m_creature)
{ {

View file

@ -272,17 +272,17 @@ class MANGOS_DLL_SPEC CreatureAI
struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature> struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature>
{ {
SelectableAI(const char *id) : FactoryHolder<CreatureAI>(id) {} SelectableAI(const char* id) : FactoryHolder<CreatureAI>(id) {}
}; };
template<class REAL_AI> template<class REAL_AI>
struct CreatureAIFactory : public SelectableAI struct CreatureAIFactory : public SelectableAI
{ {
CreatureAIFactory(const char *name) : SelectableAI(name) {} CreatureAIFactory(const char* name) : SelectableAI(name) {}
CreatureAI* Create(void *) const; CreatureAI* Create(void*) const;
int Permit(const Creature *c) const { return REAL_AI::Permissible(c); } int Permit(const Creature* c) const { return REAL_AI::Permissible(c); }
}; };
enum Permitions enum Permitions

View file

@ -22,9 +22,9 @@
template<class REAL_AI> template<class REAL_AI>
inline CreatureAI* inline CreatureAI*
CreatureAIFactory<REAL_AI>::Create(void *data) const CreatureAIFactory<REAL_AI>::Create(void* data) const
{ {
Creature* creature = reinterpret_cast<Creature *>(data); Creature* creature = reinterpret_cast<Creature*>(data);
return (new REAL_AI(creature)); return (new REAL_AI(creature));
} }
#endif #endif

View file

@ -30,31 +30,31 @@ INSTANTIATE_SINGLETON_1(MovementGeneratorRegistry);
namespace FactorySelector namespace FactorySelector
{ {
CreatureAI* selectAI(Creature *creature) CreatureAI* selectAI(Creature* creature)
{ {
// Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets) // Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets)
if ((!creature->IsPet() || !((Pet*)creature)->isControlled()) && !creature->isCharmed()) if ((!creature->IsPet() || !((Pet*)creature)->isControlled()) && !creature->isCharmed())
if (CreatureAI* scriptedAI = sScriptMgr.GetCreatureAI(creature)) if (CreatureAI* scriptedAI = sScriptMgr.GetCreatureAI(creature))
return scriptedAI; return scriptedAI;
CreatureAIRegistry &ai_registry(CreatureAIRepository::Instance()); CreatureAIRegistry& ai_registry(CreatureAIRepository::Instance());
const CreatureAICreator *ai_factory = NULL; const CreatureAICreator* ai_factory = NULL;
std::string ainame=creature->GetAIName(); std::string ainame=creature->GetAIName();
// select by NPC flags _first_ - otherwise EventAI might be choosen for pets/totems // select by NPC flags _first_ - otherwise EventAI might be choosen for pets/totems
// excplicit check for isControlled() and owner type to allow guardian, mini-pets and pets controlled by NPCs to be scripted by EventAI // excplicit check for isControlled() and owner type to allow guardian, mini-pets and pets controlled by NPCs to be scripted by EventAI
Unit *owner=NULL; Unit* owner=NULL;
if ((creature->IsPet() && ((Pet*)creature)->isControlled() && if ((creature->IsPet() && ((Pet*)creature)->isControlled() &&
((owner=creature->GetOwner()) && owner->GetTypeId()==TYPEID_PLAYER)) || creature->isCharmed()) ((owner=creature->GetOwner()) && owner->GetTypeId()==TYPEID_PLAYER)) || creature->isCharmed())
ai_factory = ai_registry.GetRegistryItem("PetAI"); ai_factory = ai_registry.GetRegistryItem("PetAI");
else if (creature->IsTotem()) else if (creature->IsTotem())
ai_factory = ai_registry.GetRegistryItem("TotemAI"); ai_factory = ai_registry.GetRegistryItem("TotemAI");
// select by script name // select by script name
if (!ai_factory && !ainame.empty()) if (!ai_factory && !ainame.empty())
ai_factory = ai_registry.GetRegistryItem( ainame.c_str() ); ai_factory = ai_registry.GetRegistryItem(ainame.c_str());
if (!ai_factory && creature->IsGuard()) if (!ai_factory && creature->IsGuard())
ai_factory = ai_registry.GetRegistryItem("GuardAI"); ai_factory = ai_registry.GetRegistryItem("GuardAI");
@ -64,14 +64,14 @@ namespace FactorySelector
{ {
int best_val = PERMIT_BASE_NO; int best_val = PERMIT_BASE_NO;
typedef CreatureAIRegistry::RegistryMapType RMT; typedef CreatureAIRegistry::RegistryMapType RMT;
RMT const &l = ai_registry.GetRegisteredItems(); RMT const& l = ai_registry.GetRegisteredItems();
for( RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter) for (RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter)
{ {
const CreatureAICreator *factory = iter->second; const CreatureAICreator* factory = iter->second;
const SelectableAI *p = dynamic_cast<const SelectableAI *>(factory); const SelectableAI* p = dynamic_cast<const SelectableAI*>(factory);
MANGOS_ASSERT( p != NULL ); MANGOS_ASSERT(p != NULL);
int val = p->Permit(creature); int val = p->Permit(creature);
if( val > best_val ) if (val > best_val)
{ {
best_val = val; best_val = val;
ai_factory = p; ai_factory = p;
@ -82,16 +82,16 @@ namespace FactorySelector
// select NullCreatureAI if not another cases // select NullCreatureAI if not another cases
ainame = (ai_factory == NULL) ? "NullCreatureAI" : ai_factory->key(); ainame = (ai_factory == NULL) ? "NullCreatureAI" : ai_factory->key();
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature %u used AI is %s.", creature->GetGUIDLow(), ainame.c_str() ); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature %u used AI is %s.", creature->GetGUIDLow(), ainame.c_str());
return ( ai_factory == NULL ? new NullCreatureAI(creature) : ai_factory->Create(creature) ); return (ai_factory == NULL ? new NullCreatureAI(creature) : ai_factory->Create(creature));
} }
MovementGenerator* selectMovementGenerator(Creature *creature) MovementGenerator* selectMovementGenerator(Creature* creature)
{ {
MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance()); MovementGeneratorRegistry& mv_registry(MovementGeneratorRepository::Instance());
MANGOS_ASSERT( creature->GetCreatureInfo() != NULL ); MANGOS_ASSERT(creature->GetCreatureInfo() != NULL);
MovementGeneratorCreator const * mv_factory = mv_registry.GetRegistryItem( MovementGeneratorCreator const* mv_factory = mv_registry.GetRegistryItem(
creature->GetOwnerGuid().IsPlayer() ? FOLLOW_MOTION_TYPE : creature->GetDefaultMovementType()); creature->GetOwnerGuid().IsPlayer() ? FOLLOW_MOTION_TYPE : creature->GetDefaultMovementType());
/* if( mv_factory == NULL ) /* if( mv_factory == NULL )
{ {
@ -112,7 +112,7 @@ namespace FactorySelector
} }
}*/ }*/
return ( mv_factory == NULL ? NULL : mv_factory->Create(creature) ); return (mv_factory == NULL ? NULL : mv_factory->Create(creature));
} }
} }

View file

@ -25,7 +25,7 @@ class MovementGenerator;
namespace FactorySelector namespace FactorySelector
{ {
CreatureAI* selectAI(Creature *); CreatureAI* selectAI(Creature*);
MovementGenerator* selectMovementGenerator(Creature *); MovementGenerator* selectMovementGenerator(Creature*);
} }
#endif #endif

View file

@ -31,7 +31,7 @@
#include "Chat.h" #include "Chat.h"
#include "Language.h" #include "Language.h"
bool CreatureEventAIHolder::UpdateRepeatTimer( Creature* creature, uint32 repeatMin, uint32 repeatMax ) bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax)
{ {
if (repeatMin == repeatMax) if (repeatMin == repeatMax)
Time = repeatMin; Time = repeatMin;
@ -47,9 +47,9 @@ bool CreatureEventAIHolder::UpdateRepeatTimer( Creature* creature, uint32 repeat
return true; return true;
} }
int CreatureEventAI::Permissible(const Creature *creature) int CreatureEventAI::Permissible(const Creature* creature)
{ {
if( creature->GetAIName() == "EventAI" ) if (creature->GetAIName() == "EventAI")
return PERMIT_BASE_SPECIAL; return PERMIT_BASE_SPECIAL;
return PERMIT_BASE_NO; return PERMIT_BASE_NO;
} }
@ -61,7 +61,7 @@ void CreatureEventAI::GetAIInformation(ChatHandler& reader)
reader.PSendSysMessage(LANG_NPC_EVENTAI_COMBAT, reader.GetOnOffStr(m_MeleeEnabled)); reader.PSendSysMessage(LANG_NPC_EVENTAI_COMBAT, reader.GetOnOffStr(m_MeleeEnabled));
} }
CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c) CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c)
{ {
// Need make copy for filter unneeded steps and safe in case table reload // Need make copy for filter unneeded steps and safe in case table reload
CreatureEventAI_Event_Map::const_iterator creatureEventsItr = sEventAIMgr.GetCreatureEventAIMap().find(m_creature->GetEntry()); CreatureEventAI_Event_Map::const_iterator creatureEventsItr = sEventAIMgr.GetCreatureEventAIMap().find(m_creature->GetEntry());
@ -71,10 +71,10 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
for (CreatureEventAI_Event_Vec::const_iterator i = (*creatureEventsItr).second.begin(); i != (*creatureEventsItr).second.end(); ++i) for (CreatureEventAI_Event_Vec::const_iterator i = (*creatureEventsItr).second.begin(); i != (*creatureEventsItr).second.end(); ++i)
{ {
//Debug check //Debug check
#ifndef MANGOS_DEBUG #ifndef MANGOS_DEBUG
if ((*i).event_flags & EFLAG_DEBUG_ONLY) if ((*i).event_flags & EFLAG_DEBUG_ONLY)
continue; continue;
#endif #endif
if (m_creature->GetMap()->IsDungeon()) if (m_creature->GetMap()->IsDungeon())
{ {
if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags) if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags)
@ -95,10 +95,10 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
{ {
//Debug check //Debug check
#ifndef MANGOS_DEBUG #ifndef MANGOS_DEBUG
if ((*i).event_flags & EFLAG_DEBUG_ONLY) if ((*i).event_flags & EFLAG_DEBUG_ONLY)
continue; continue;
#endif #endif
if (m_creature->GetMap()->IsDungeon()) if (m_creature->GetMap()->IsDungeon())
{ {
if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags) if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags)
@ -335,7 +335,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
return false; return false;
SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId); SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId);
if(!holder || holder->GetStackAmount() < event.buffed.amount) if (!holder || holder->GetStackAmount() < event.buffed.amount)
return false; return false;
//Repeat Timers //Repeat Timers
@ -525,7 +525,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
CanCastResult castResult = DoCastSpellIfCan(target, action.cast.spellId, action.cast.castFlags); CanCastResult castResult = DoCastSpellIfCan(target, action.cast.spellId, action.cast.castFlags);
switch(castResult) switch (castResult)
{ {
case CAST_FAIL_POWER: case CAST_FAIL_POWER:
case CAST_FAIL_TOO_FAR: case CAST_FAIL_TOO_FAR:
@ -533,7 +533,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
// Melee current victim if flag not set // Melee current victim if flag not set
if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM)) if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM))
{ {
switch(m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType()) switch (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType())
{ {
case CHASE_MOTION_TYPE: case CHASE_MOTION_TYPE:
case FOLLOW_MOTION_TYPE: case FOLLOW_MOTION_TYPE:
@ -567,7 +567,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
if (!pCreature) if (!pCreature)
sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry()); sLog.outErrorDb("CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry());
else if (action.summon.target != TARGET_T_SELF && target) else if (action.summon.target != TARGET_T_SELF && target)
pCreature->AI()->AttackStart(target); pCreature->AI()->AttackStart(target);
break; break;
@ -580,7 +580,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ {
ThreatList const& threatList = m_creature->getThreatManager().getThreatList(); ThreatList const& threatList = m_creature->getThreatManager().getThreatList();
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i) for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
if(Unit* Temp = m_creature->GetMap()->GetUnit((*i)->getUnitGuid())) if (Unit* Temp = m_creature->GetMap()->GetUnit((*i)->getUnitGuid()))
m_creature->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); m_creature->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent);
break; break;
} }
@ -620,7 +620,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break; break;
case ACTION_T_COMBAT_MOVEMENT: case ACTION_T_COMBAT_MOVEMENT:
// ignore no affect case // ignore no affect case
if(m_CombatMovementEnabled==(action.combat_movement.state!=0)) if (m_CombatMovementEnabled==(action.combat_movement.state!=0))
return; return;
m_CombatMovementEnabled = action.combat_movement.state != 0; m_CombatMovementEnabled = action.combat_movement.state != 0;
@ -628,8 +628,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
//Allow movement (create new targeted movement gen only if idle) //Allow movement (create new targeted movement gen only if idle)
if (m_CombatMovementEnabled) if (m_CombatMovementEnabled)
{ {
if(action.combat_movement.melee && m_creature->isInCombat()) if (action.combat_movement.melee && m_creature->isInCombat())
if(Unit* victim = m_creature->getVictim()) if (Unit* victim = m_creature->getVictim())
m_creature->SendMeleeAttackStart(victim); m_creature->SendMeleeAttackStart(victim);
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE) if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE)
@ -640,8 +640,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
} }
else else
{ {
if(action.combat_movement.melee && m_creature->isInCombat()) if (action.combat_movement.melee && m_creature->isInCombat())
if(Unit* victim = m_creature->getVictim()) if (Unit* victim = m_creature->getVictim())
m_creature->SendMeleeAttackStop(victim); m_creature->SendMeleeAttackStop(victim);
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
@ -660,12 +660,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
int32 new_phase = int32(m_Phase)+action.set_inc_phase.step; int32 new_phase = int32(m_Phase)+action.set_inc_phase.step;
if (new_phase < 0) if (new_phase < 0)
{ {
sLog.outErrorDb( "CreatureEventAI: Event %d decrease Phase under 0. CreatureEntry = %d", EventId, m_creature->GetEntry()); sLog.outErrorDb("CreatureEventAI: Event %d decrease Phase under 0. CreatureEntry = %d", EventId, m_creature->GetEntry());
m_Phase = 0; m_Phase = 0;
} }
else if (new_phase >= MAX_PHASE) else if (new_phase >= MAX_PHASE)
{ {
sLog.outErrorDb( "CreatureEventAI: Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE-1, MAX_PHASE-1, m_creature->GetEntry()); sLog.outErrorDb("CreatureEventAI: Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE-1, MAX_PHASE-1, m_creature->GetEntry());
m_Phase = MAX_PHASE-1; m_Phase = MAX_PHASE-1;
} }
else else
@ -688,7 +688,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
ThreatList const& threatList = m_creature->getThreatManager().getThreatList(); ThreatList const& threatList = m_creature->getThreatManager().getThreatList();
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i) for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
if (Player* temp = m_creature->GetMap()->GetPlayer((*i)->getUnitGuid())) if (Player* temp = m_creature->GetMap()->GetPlayer((*i)->getUnitGuid()))
temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId);
break; break;
} }
case ACTION_T_REMOVEAURASFROMSPELL: case ACTION_T_REMOVEAURASFROMSPELL:
@ -716,7 +716,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (action.random_phase_range.phaseMax > action.random_phase_range.phaseMin) if (action.random_phase_range.phaseMax > action.random_phase_range.phaseMin)
m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin)); m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin));
else else
sLog.outErrorDb( "CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); sLog.outErrorDb("CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry());
break; break;
case ACTION_T_SUMMON_ID: case ACTION_T_SUMMON_ID:
{ {
@ -725,7 +725,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId); CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId);
if (i == sEventAIMgr.GetCreatureEventAISummonMap().end()) if (i == sEventAIMgr.GetCreatureEventAISummonMap().end())
{ {
sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, EventId, m_creature->GetEntry()); sLog.outErrorDb("CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, EventId, m_creature->GetEntry());
return; return;
} }
@ -736,7 +736,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
pCreature = m_creature->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); pCreature = m_creature->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
if (!pCreature) if (!pCreature)
sLog.outErrorDb( "CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry()); sLog.outErrorDb("CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry());
else if (action.summon_id.target != TARGET_T_SELF && target) else if (action.summon_id.target != TARGET_T_SELF && target)
pCreature->AI()->AttackStart(target); pCreature->AI()->AttackStart(target);
@ -826,7 +826,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
} }
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
{ {
if(action.invincibility_hp_level.is_percent) if (action.invincibility_hp_level.is_percent)
m_InvinceabilityHpLevel = m_creature->GetMaxHealth()*action.invincibility_hp_level.hp_level/100; m_InvinceabilityHpLevel = m_creature->GetMaxHealth()*action.invincibility_hp_level.hp_level/100;
else else
m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level;
@ -884,7 +884,7 @@ void CreatureEventAI::Reset()
CreatureEventAI_Event const& event = (*i).Event; CreatureEventAI_Event const& event = (*i).Event;
switch (event.event_type) switch (event.event_type)
{ {
//Reset all out of combat timers //Reset all out of combat timers
case EVENT_T_TIMER_OOC: case EVENT_T_TIMER_OOC:
{ {
if ((*i).UpdateRepeatTimer(m_creature,event.timer.initialMin,event.timer.initialMax)) if ((*i).UpdateRepeatTimer(m_creature,event.timer.initialMin,event.timer.initialMax))
@ -1009,7 +1009,7 @@ void CreatureEventAI::SummonedCreatureDespawn(Creature* pUnit)
} }
} }
void CreatureEventAI::EnterCombat(Unit *enemy) void CreatureEventAI::EnterCombat(Unit* enemy)
{ {
//Check for on combat start events //Check for on combat start events
if (!m_bEmptyList) if (!m_bEmptyList)
@ -1041,7 +1041,7 @@ void CreatureEventAI::EnterCombat(Unit *enemy)
m_EventDiff = 0; m_EventDiff = 0;
} }
void CreatureEventAI::AttackStart(Unit *who) void CreatureEventAI::AttackStart(Unit* who)
{ {
if (!who) if (!who)
return; return;
@ -1064,7 +1064,7 @@ void CreatureEventAI::AttackStart(Unit *who)
} }
} }
void CreatureEventAI::MoveInLineOfSight(Unit *who) void CreatureEventAI::MoveInLineOfSight(Unit* who)
{ {
if (!who) if (!who)
return; return;
@ -1084,7 +1084,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
{ {
//if friendly event&&who is not hostile OR hostile event&&who is hostile //if friendly event&&who is not hostile OR hostile event&&who is hostile
if (((*itr).Event.ooc_los.noHostile && !m_creature->IsHostileTo(who)) || if (((*itr).Event.ooc_los.noHostile && !m_creature->IsHostileTo(who)) ||
((!(*itr).Event.ooc_los.noHostile) && m_creature->IsHostileTo(who))) ((!(*itr).Event.ooc_los.noHostile) && m_creature->IsHostileTo(who)))
ProcessEvent(*itr, who); ProcessEvent(*itr, who);
} }
} }
@ -1095,7 +1095,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
return; return;
if (m_creature->CanInitiateAttack() && who->isTargetableForAttack() && if (m_creature->CanInitiateAttack() && who->isTargetableForAttack() &&
m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature)) m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature))
{ {
if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return; return;
@ -1206,10 +1206,10 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
bool CreatureEventAI::IsVisible(Unit *pl) const bool CreatureEventAI::IsVisible(Unit* pl) const
{ {
return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_MONSTER)) return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_MONSTER))
&& pl->isVisibleForOrDetect(m_creature,m_creature,true); && pl->isVisibleForOrDetect(m_creature,m_creature,true);
} }
inline uint32 CreatureEventAI::GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3) inline uint32 CreatureEventAI::GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3)
@ -1313,7 +1313,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "CreatureEventAI: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",textEntry,(*i).second.SoundId,(*i).second.Type,(*i).second.Language,(*i).second.Emote); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "CreatureEventAI: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",textEntry,(*i).second.SoundId,(*i).second.Type,(*i).second.Language,(*i).second.Emote);
if((*i).second.SoundId) if ((*i).second.SoundId)
{ {
if (GetSoundEntriesStore()->LookupEntry((*i).second.SoundId)) if (GetSoundEntriesStore()->LookupEntry((*i).second.SoundId))
pSource->PlayDirectSound((*i).second.SoundId); pSource->PlayDirectSound((*i).second.SoundId);
@ -1321,7 +1321,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.",textEntry,(*i).second.SoundId); sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.",textEntry,(*i).second.SoundId);
} }
if((*i).second.Emote) if ((*i).second.Emote)
{ {
if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER) if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER)
{ {
@ -1331,7 +1331,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).",textEntry,pSource->GetTypeId()); sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).",textEntry,pSource->GetTypeId());
} }
switch((*i).second.Type) switch ((*i).second.Type)
{ {
case CHAT_TYPE_SAY: case CHAT_TYPE_SAY:
pSource->MonsterSay(textEntry, (*i).second.Language, target); pSource->MonsterSay(textEntry, (*i).second.Language, target);
@ -1350,20 +1350,20 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
if (target && target->GetTypeId() == TYPEID_PLAYER) if (target && target->GetTypeId() == TYPEID_PLAYER)
pSource->MonsterWhisper(textEntry, target); pSource->MonsterWhisper(textEntry, target);
else sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); else sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
}break; } break;
case CHAT_TYPE_BOSS_WHISPER: case CHAT_TYPE_BOSS_WHISPER:
{ {
if (target && target->GetTypeId() == TYPEID_PLAYER) if (target && target->GetTypeId() == TYPEID_PLAYER)
pSource->MonsterWhisper(textEntry, target, true); pSource->MonsterWhisper(textEntry, target, true);
else sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); else sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
}break; } break;
case CHAT_TYPE_ZONE_YELL: case CHAT_TYPE_ZONE_YELL:
pSource->MonsterYellToZone(textEntry, (*i).second.Language, target); pSource->MonsterYellToZone(textEntry, (*i).second.Language, target);
break; break;
} }
} }
bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered) bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const* Spell, bool Triggered)
{ {
//No target so we can't cast //No target so we can't cast
if (!Target || !Spell) if (!Target || !Spell)
@ -1371,14 +1371,14 @@ bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Trigge
//Silenced so we can't cast //Silenced so we can't cast
if (!Triggered && (m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL) || if (!Triggered && (m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL) ||
m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))) m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)))
return false; return false;
//Check for power //Check for power
if (!Triggered && m_creature->GetPower((Powers)Spell->powerType) < Spell::CalculatePowerCost(Spell, m_creature)) if (!Triggered && m_creature->GetPower((Powers)Spell->powerType) < Spell::CalculatePowerCost(Spell, m_creature))
return false; return false;
SpellRangeEntry const *TempRange = NULL; SpellRangeEntry const* TempRange = NULL;
TempRange = GetSpellRangeStore()->LookupEntry(Spell->rangeIndex); TempRange = GetSpellRangeStore()->LookupEntry(Spell->rangeIndex);
@ -1415,11 +1415,11 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
} }
} }
void CreatureEventAI::DamageTaken( Unit* /*done_by*/, uint32& damage ) void CreatureEventAI::DamageTaken(Unit* /*done_by*/, uint32& damage)
{ {
if(m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel+damage) if (m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel+damage)
{ {
if(m_creature->GetHealth() <= m_InvinceabilityHpLevel) if (m_creature->GetHealth() <= m_InvinceabilityHpLevel)
damage = 0; damage = 0;
else else
damage = m_creature->GetHealth() - m_InvinceabilityHpLevel; damage = m_creature->GetHealth() - m_InvinceabilityHpLevel;
@ -1428,7 +1428,7 @@ void CreatureEventAI::DamageTaken( Unit* /*done_by*/, uint32& damage )
bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event) bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event)
{ {
if(event.event_type != EVENT_T_SPAWNED) if (event.event_type != EVENT_T_SPAWNED)
return false; return false;
switch (event.spawned.condition) switch (event.spawned.condition)

View file

@ -563,7 +563,7 @@ typedef UNORDERED_MAP<uint32, CreatureEventAI_Summon> CreatureEventAI_Summon_Map
struct CreatureEventAIHolder struct CreatureEventAIHolder
{ {
CreatureEventAIHolder(CreatureEventAI_Event p) : Event(p), Time(0), Enabled(true){} CreatureEventAIHolder(CreatureEventAI_Event p) : Event(p), Time(0), Enabled(true) {}
CreatureEventAI_Event Event; CreatureEventAI_Event Event;
uint32 Time; uint32 Time;
@ -576,7 +576,7 @@ struct CreatureEventAIHolder
class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
{ {
public: public:
explicit CreatureEventAI(Creature *c); explicit CreatureEventAI(Creature* c);
~CreatureEventAI() ~CreatureEventAI()
{ {
m_CreatureEventAIList.clear(); m_CreatureEventAIList.clear();
@ -587,22 +587,22 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
void JustRespawned(); void JustRespawned();
void Reset(); void Reset();
void JustReachedHome(); void JustReachedHome();
void EnterCombat(Unit *enemy); void EnterCombat(Unit* enemy);
void EnterEvadeMode(); void EnterEvadeMode();
void JustDied(Unit* killer); void JustDied(Unit* killer);
void KilledUnit(Unit* victim); void KilledUnit(Unit* victim);
void JustSummoned(Creature* pUnit); void JustSummoned(Creature* pUnit);
void AttackStart(Unit *who); void AttackStart(Unit* who);
void MoveInLineOfSight(Unit *who); void MoveInLineOfSight(Unit* who);
void SpellHit(Unit* pUnit, const SpellEntry* pSpell); void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
void DamageTaken(Unit* done_by, uint32& damage); void DamageTaken(Unit* done_by, uint32& damage);
void UpdateAI(const uint32 diff); void UpdateAI(const uint32 diff);
bool IsVisible(Unit *) const; bool IsVisible(Unit*) const;
void ReceiveEmote(Player* pPlayer, uint32 text_emote); void ReceiveEmote(Player* pPlayer, uint32 text_emote);
void SummonedCreatureJustDied(Creature* unit); void SummonedCreatureJustDied(Creature* unit);
void SummonedCreatureDespawn(Creature* unit); void SummonedCreatureDespawn(Creature* unit);
static int Permissible(const Creature *); static int Permissible(const Creature*);
bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL); bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL);
void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker); void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker);
@ -611,7 +611,7 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker); inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker);
void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target); void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target);
bool CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered); bool CanCast(Unit* Target, SpellEntry const* Spell, bool Triggered);
bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event); bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event);

View file

@ -39,7 +39,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use)
sObjectMgr.LoadMangosStrings(WorldDatabase,"creature_ai_texts",MIN_CREATURE_AI_TEXT_STRING_ID,MAX_CREATURE_AI_TEXT_STRING_ID); sObjectMgr.LoadMangosStrings(WorldDatabase,"creature_ai_texts",MIN_CREATURE_AI_TEXT_STRING_ID,MAX_CREATURE_AI_TEXT_STRING_ID);
// Gather Additional data from EventAI Texts // Gather Additional data from EventAI Texts
QueryResult *result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM creature_ai_texts"); QueryResult* result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM creature_ai_texts");
sLog.outString("Loading EventAI Texts additional data..."); sLog.outString("Loading EventAI Texts additional data...");
if (result) if (result)
@ -93,11 +93,12 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use)
m_CreatureEventAI_TextMap[i] = temp; m_CreatureEventAI_TextMap[i] = temp;
++count; ++count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
if(check_entry_use) if (check_entry_use)
CheckUnusedAITexts(); CheckUnusedAITexts();
sLog.outString(); sLog.outString();
@ -116,23 +117,23 @@ void CreatureEventAIMgr::CheckUnusedAITexts()
{ {
std::set<int32> idx_set; std::set<int32> idx_set;
// check not used strings this is negative range // check not used strings this is negative range
for(CreatureEventAI_TextMap::const_iterator itr = m_CreatureEventAI_TextMap.begin(); itr != m_CreatureEventAI_TextMap.end(); ++itr) for (CreatureEventAI_TextMap::const_iterator itr = m_CreatureEventAI_TextMap.begin(); itr != m_CreatureEventAI_TextMap.end(); ++itr)
idx_set.insert(itr->first); idx_set.insert(itr->first);
for(CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr) for (CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr)
{ {
for(size_t i = 0; i < itr->second.size(); ++i) for (size_t i = 0; i < itr->second.size(); ++i)
{ {
CreatureEventAI_Event const& event = itr->second[i]; CreatureEventAI_Event const& event = itr->second[i];
for(int j = 0; j < MAX_ACTIONS; ++j) for (int j = 0; j < MAX_ACTIONS; ++j)
{ {
CreatureEventAI_Action const& action = event.action[j]; CreatureEventAI_Action const& action = event.action[j];
switch(action.type) switch (action.type)
{ {
case ACTION_T_TEXT: case ACTION_T_TEXT:
{ {
for(int k = 0; k < 3; ++k) for (int k = 0; k < 3; ++k)
if (action.text.TextId[k]) if (action.text.TextId[k])
idx_set.erase(action.text.TextId[k]); idx_set.erase(action.text.TextId[k]);
break; break;
@ -144,7 +145,7 @@ void CreatureEventAIMgr::CheckUnusedAITexts()
} }
} }
for(std::set<int32>::const_iterator itr = idx_set.begin(); itr != idx_set.end(); ++itr) for (std::set<int32>::const_iterator itr = idx_set.begin(); itr != idx_set.end(); ++itr)
sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` but not used in EventAI scripts.",*itr); sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` but not used in EventAI scripts.",*itr);
} }
@ -165,7 +166,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons(bool check_entry_use)
do do
{ {
bar.step(); bar.step();
Field *fields = result->Fetch(); Field* fields = result->Fetch();
CreatureEventAI_Summon temp; CreatureEventAI_Summon temp;
@ -185,16 +186,18 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons(bool check_entry_use)
//Add to map //Add to map
m_CreatureEventAI_Summon_Map[temp.id] = temp; m_CreatureEventAI_Summon_Map[temp.id] = temp;
++Count; ++Count;
}while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
if(check_entry_use) if (check_entry_use)
CheckUnusedAISummons(); CheckUnusedAISummons();
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u CreatureEventAI summon definitions", Count); sLog.outString(">> Loaded %u CreatureEventAI summon definitions", Count);
}else }
else
{ {
BarGoLink bar(1); BarGoLink bar(1);
bar.step(); bar.step();
@ -207,19 +210,19 @@ void CreatureEventAIMgr::CheckUnusedAISummons()
{ {
std::set<int32> idx_set; std::set<int32> idx_set;
// check not used strings this is negative range // check not used strings this is negative range
for(CreatureEventAI_Summon_Map::const_iterator itr = m_CreatureEventAI_Summon_Map.begin(); itr != m_CreatureEventAI_Summon_Map.end(); ++itr) for (CreatureEventAI_Summon_Map::const_iterator itr = m_CreatureEventAI_Summon_Map.begin(); itr != m_CreatureEventAI_Summon_Map.end(); ++itr)
idx_set.insert(itr->first); idx_set.insert(itr->first);
for(CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr) for (CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr)
{ {
for(size_t i = 0; i < itr->second.size(); ++i) for (size_t i = 0; i < itr->second.size(); ++i)
{ {
CreatureEventAI_Event const& event = itr->second[i]; CreatureEventAI_Event const& event = itr->second[i];
for(int j = 0; j < MAX_ACTIONS; ++j) for (int j = 0; j < MAX_ACTIONS; ++j)
{ {
CreatureEventAI_Action const& action = event.action[j]; CreatureEventAI_Action const& action = event.action[j];
switch(action.type) switch (action.type)
{ {
case ACTION_T_SUMMON_ID: case ACTION_T_SUMMON_ID:
{ {
@ -234,7 +237,7 @@ void CreatureEventAIMgr::CheckUnusedAISummons()
} }
} }
for(std::set<int32>::const_iterator itr = idx_set.begin(); itr != idx_set.end(); ++itr) for (std::set<int32>::const_iterator itr = idx_set.begin(); itr != idx_set.end(); ++itr)
sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_summons` but not used in EventAI scripts.",*itr); sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_summons` but not used in EventAI scripts.",*itr);
} }
@ -245,12 +248,12 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
m_CreatureEventAI_Event_Map.clear(); m_CreatureEventAI_Event_Map.clear();
// Gather event data // Gather event data
QueryResult *result = WorldDatabase.Query("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, " QueryResult* result = WorldDatabase.Query("SELECT id, creature_id, event_type, event_inverse_phase_mask, event_chance, event_flags, "
"event_param1, event_param2, event_param3, event_param4, " "event_param1, event_param2, event_param3, event_param4, "
"action1_type, action1_param1, action1_param2, action1_param3, " "action1_type, action1_param1, action1_param2, action1_param3, "
"action2_type, action2_param1, action2_param2, action2_param3, " "action2_type, action2_param1, action2_param2, action2_param3, "
"action3_type, action3_param1, action3_param2, action3_param3 " "action3_type, action3_param1, action3_param2, action3_param3 "
"FROM creature_ai_scripts"); "FROM creature_ai_scripts");
if (result) if (result)
{ {
BarGoLink bar(result->GetRowCount()); BarGoLink bar(result->GetRowCount());
@ -259,7 +262,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
do do
{ {
bar.step(); bar.step();
Field *fields = result->Fetch(); Field* fields = result->Fetch();
CreatureEventAI_Event temp; CreatureEventAI_Event temp;
temp.event_id = EventAI_Type(fields[0].GetUInt32()); temp.event_id = EventAI_Type(fields[0].GetUInt32());
@ -359,16 +362,16 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); sLog.outErrorDb("CreatureEventAI: Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
break; break;
case EVENT_T_SPAWNED: case EVENT_T_SPAWNED:
switch(temp.spawned.condition) switch (temp.spawned.condition)
{ {
case SPAWNED_EVENT_ALWAY: case SPAWNED_EVENT_ALWAY:
break; break;
case SPAWNED_EVENT_MAP: case SPAWNED_EVENT_MAP:
if(!sMapStore.LookupEntry(temp.spawned.conditionValue1)) if (!sMapStore.LookupEntry(temp.spawned.conditionValue1))
sLog.outErrorDb("CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); sLog.outErrorDb("CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
break; break;
case SPAWNED_EVENT_ZONE: case SPAWNED_EVENT_ZONE:
if(!GetAreaEntryByAreaID(temp.spawned.conditionValue1)) if (!GetAreaEntryByAreaID(temp.spawned.conditionValue1))
sLog.outErrorDb("CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); sLog.outErrorDb("CreatureEventAI: Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
default: default:
sLog.outErrorDb("CreatureEventAI: Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition); sLog.outErrorDb("CreatureEventAI: Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition);
@ -511,17 +514,17 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case ACTION_T_TEXT: case ACTION_T_TEXT:
{ {
bool not_set = false; bool not_set = false;
for(int k = 0; k < 3; ++k) for (int k = 0; k < 3; ++k)
{ {
if (action.text.TextId[k]) if (action.text.TextId[k])
{ {
if (k > 0 && not_set) if (k > 0 && not_set)
sLog.outErrorDb("CreatureEventAI: Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j+1, k+1); sLog.outErrorDb("CreatureEventAI: Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j+1, k+1);
if(!action.text.TextId[k]) if (!action.text.TextId[k])
not_set = true; not_set = true;
// range negative // range negative
else if(action.text.TextId[k] > MIN_CREATURE_AI_TEXT_STRING_ID || action.text.TextId[k] <= MAX_CREATURE_AI_TEXT_STRING_ID) else if (action.text.TextId[k] > MIN_CREATURE_AI_TEXT_STRING_ID || action.text.TextId[k] <= MAX_CREATURE_AI_TEXT_STRING_ID)
{ {
sLog.outErrorDb("CreatureEventAI: Event %u Action %u param%d references out-of-range entry (%i) in texts table.", i, j+1, k+1, action.text.TextId[k]); sLog.outErrorDb("CreatureEventAI: Event %u Action %u param%d references out-of-range entry (%i) in texts table.", i, j+1, k+1, action.text.TextId[k]);
action.text.TextId[k] = 0; action.text.TextId[k] = 0;
@ -592,7 +595,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break; break;
case ACTION_T_CAST: case ACTION_T_CAST:
{ {
const SpellEntry *spell = sSpellStore.LookupEntry(action.cast.spellId); const SpellEntry* spell = sSpellStore.LookupEntry(action.cast.spellId);
if (!spell) if (!spell)
sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SpellID %u.", i, j+1, action.cast.spellId); sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SpellID %u.", i, j+1, action.cast.spellId);
/* FIXME: temp.raw.param3 not have event tipes with recovery time in it.... /* FIXME: temp.raw.param3 not have event tipes with recovery time in it....
@ -753,9 +756,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
} }
break; break;
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
if(action.invincibility_hp_level.is_percent) if (action.invincibility_hp_level.is_percent)
{ {
if(action.invincibility_hp_level.hp_level > 100) if (action.invincibility_hp_level.hp_level > 100)
{ {
sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses wrong percent value %u.", i, j+1, action.invincibility_hp_level.hp_level); sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses wrong percent value %u.", i, j+1, action.invincibility_hp_level.hp_level);
action.invincibility_hp_level.hp_level = 100; action.invincibility_hp_level.hp_level = 100;
@ -811,7 +814,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
//Add to list //Add to list
m_CreatureEventAI_Event_Map[creature_id].push_back(temp); m_CreatureEventAI_Event_Map[creature_id].push_back(temp);
++Count; ++Count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
@ -834,7 +838,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u CreatureEventAI scripts", Count); sLog.outString(">> Loaded %u CreatureEventAI scripts", Count);
}else }
else
{ {
BarGoLink bar(1); BarGoLink bar(1);
bar.step(); bar.step();

View file

@ -25,8 +25,8 @@
class CreatureEventAIMgr class CreatureEventAIMgr
{ {
public: public:
CreatureEventAIMgr(){}; CreatureEventAIMgr() {};
~CreatureEventAIMgr(){}; ~CreatureEventAIMgr() {};
void LoadCreatureEventAI_Texts(bool check_entry_use); void LoadCreatureEventAI_Texts(bool check_entry_use);
void LoadCreatureEventAI_Summons(bool check_entry_use); void LoadCreatureEventAI_Summons(bool check_entry_use);

View file

@ -242,7 +242,7 @@ bool CreatureLinkingMgr::IsLinkingEntryValid(uint32 slaveEntry, CreatureLinkingI
if (pTmp->searchRange == 0 && pTmp->linkingFlag & (FLAG_FOLLOW | FLAG_CANT_SPAWN_IF_BOSS_DEAD | FLAG_CANT_SPAWN_IF_BOSS_ALIVE)) if (pTmp->searchRange == 0 && pTmp->linkingFlag & (FLAG_FOLLOW | FLAG_CANT_SPAWN_IF_BOSS_DEAD | FLAG_CANT_SPAWN_IF_BOSS_ALIVE))
{ {
// Painfully slow, needs better idea // Painfully slow, needs better idea
QueryResult *result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id=%u AND map=%u", pTmp->masterId, pTmp->mapId); QueryResult* result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id=%u AND map=%u", pTmp->masterId, pTmp->mapId);
if (result) if (result)
{ {
if ((*result)[0].GetUInt32() > 1) if ((*result)[0].GetUInt32() > 1)

View file

@ -296,7 +296,7 @@ enum FactionMasks
FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team
FACTION_MASK_HORDE = 4, // player or creature from horde team FACTION_MASK_HORDE = 4, // player or creature from horde team
FACTION_MASK_MONSTER = 8 // aggressive creature from monster team FACTION_MASK_MONSTER = 8 // aggressive creature from monster team
// if none flags set then non-aggressive creature // if none flags set then non-aggressive creature
}; };
enum MapTypes // Lua_IsInInstance enum MapTypes // Lua_IsInInstance

View file

@ -47,7 +47,7 @@ struct WMOAreaTableTripple
int32 adtId; int32 adtId;
}; };
typedef std::map<WMOAreaTableTripple, WMOAreaTableEntry const *> WMOAreaInfoByTripple; typedef std::map<WMOAreaTableTripple, WMOAreaTableEntry const*> WMOAreaInfoByTripple;
DBCStorage <AreaTableEntry> sAreaStore(AreaTableEntryfmt); DBCStorage <AreaTableEntry> sAreaStore(AreaTableEntryfmt);
DBCStorage <AreaGroupEntry> sAreaGroupStore(AreaGroupEntryfmt); DBCStorage <AreaGroupEntry> sAreaGroupStore(AreaGroupEntryfmt);
@ -195,8 +195,8 @@ typedef std::list<std::string> StoreProblemList;
bool IsAcceptableClientBuild(uint32 build) bool IsAcceptableClientBuild(uint32 build)
{ {
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD; int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD;
for(int i = 0; accepted_versions[i]; ++i) for (int i = 0; accepted_versions[i]; ++i)
if(int(build) == accepted_versions[i]) if (int(build) == accepted_versions[i])
return true; return true;
return false; return false;
@ -206,7 +206,7 @@ std::string AcceptableClientBuildsListStr()
{ {
std::ostringstream data; std::ostringstream data;
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD; int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD;
for(int i = 0; accepted_versions[i]; ++i) for (int i = 0; accepted_versions[i]; ++i)
data << accepted_versions[i] << " "; data << accepted_versions[i] << " ";
return data.str(); return data.str();
} }
@ -215,7 +215,7 @@ static bool ReadDBCBuildFileText(const std::string& dbc_path, char const* locale
{ {
std::string filename = dbc_path + "component.wow-" + localeName + ".txt"; std::string filename = dbc_path + "component.wow-" + localeName + ".txt";
if(FILE* file = fopen(filename.c_str(),"rb")) if (FILE* file = fopen(filename.c_str(),"rb"))
{ {
char buf[100]; char buf[100];
fread(buf,1,100-1,file); fread(buf,1,100-1,file);
@ -234,7 +234,7 @@ static uint32 ReadDBCBuild(const std::string& dbc_path, LocaleNameStr const* loc
if (!localeNameStr) if (!localeNameStr)
{ {
for(LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr) for (LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr)
{ {
if (ReadDBCBuildFileText(dbc_path,itr->name,text)) if (ReadDBCBuildFileText(dbc_path,itr->name,text))
{ {
@ -291,10 +291,10 @@ inline void LoadDBC(LocalData& localeData, BarGoLink& bar, StoreProblemList& err
MANGOS_ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename)); MANGOS_ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename));
std::string dbc_filename = dbc_path + filename; std::string dbc_filename = dbc_path + filename;
if(storage.Load(dbc_filename.c_str())) if (storage.Load(dbc_filename.c_str()))
{ {
bar.step(); bar.step();
for(uint8 i = 0; fullLocaleNameList[i].name; ++i) for (uint8 i = 0; fullLocaleNameList[i].name; ++i)
{ {
if (!(localeData.availableDbcLocales & (1 << i))) if (!(localeData.availableDbcLocales & (1 << i)))
continue; continue;
@ -309,7 +309,7 @@ inline void LoadDBC(LocalData& localeData, BarGoLink& bar, StoreProblemList& err
uint32 build_loc = ReadDBCBuild(dbc_dir_loc,localStr); uint32 build_loc = ReadDBCBuild(dbc_dir_loc,localStr);
if(localeData.main_build != build_loc) if (localeData.main_build != build_loc)
{ {
localeData.availableDbcLocales &= ~(1<<i); // mark as not available for speedup next checks localeData.availableDbcLocales &= ~(1<<i); // mark as not available for speedup next checks
@ -327,15 +327,15 @@ inline void LoadDBC(LocalData& localeData, BarGoLink& bar, StoreProblemList& err
} }
std::string dbc_filename_loc = dbc_path + localStr->name + "/" + filename; std::string dbc_filename_loc = dbc_path + localStr->name + "/" + filename;
if(!storage.LoadStringsFrom(dbc_filename_loc.c_str())) if (!storage.LoadStringsFrom(dbc_filename_loc.c_str()))
localeData.availableDbcLocales &= ~(1<<i); // mark as not available for speedup next checks localeData.availableDbcLocales &= ~(1<<i); // mark as not available for speedup next checks
} }
} }
else else
{ {
// sort problematic dbc to (1) non compatible and (2) nonexistent // sort problematic dbc to (1) non compatible and (2) nonexistent
FILE * f=fopen(dbc_filename.c_str(),"rb"); FILE* f=fopen(dbc_filename.c_str(),"rb");
if(f) if (f)
{ {
char buf[100]; char buf[100];
snprintf(buf, 100, " (exist, but have %u fields instead " SIZEFMTD ") Wrong client version DBC file?", storage.GetFieldCount(), strlen(storage.GetFormat())); snprintf(buf, 100, " (exist, but have %u fields instead " SIZEFMTD ") Wrong client version DBC file?", storage.GetFieldCount(), strlen(storage.GetFormat()));
@ -383,7 +383,7 @@ void LoadDBCStores(const std::string& dataPath)
sAreaFlagByAreaID.insert(AreaFlagByAreaID::value_type(uint16(area->ID),area->exploreFlag)); sAreaFlagByAreaID.insert(AreaFlagByAreaID::value_type(uint16(area->ID),area->exploreFlag));
// fill MapId->DBC records ( skip sub zones and continents ) // fill MapId->DBC records ( skip sub zones and continents )
if(area->zone==0 && area->mapid != 0 && area->mapid != 1 && area->mapid != 530 && area->mapid != 571 ) if (area->zone==0 && area->mapid != 0 && area->mapid != 1 && area->mapid != 530 && area->mapid != 571)
sAreaFlagByMapID.insert(AreaFlagByMapID::value_type(area->mapid,area->exploreFlag)); sAreaFlagByMapID.insert(AreaFlagByMapID::value_type(area->mapid,area->exploreFlag));
} }
} }
@ -414,12 +414,12 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sEmotesStore, dbcPath,"Emotes.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sEmotesStore, dbcPath,"Emotes.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sEmotesTextStore, dbcPath,"EmotesText.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sEmotesTextStore, dbcPath,"EmotesText.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionStore, dbcPath,"Faction.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionStore, dbcPath,"Faction.dbc");
for (uint32 i=0;i<sFactionStore.GetNumRows(); ++i) for (uint32 i=0; i<sFactionStore.GetNumRows(); ++i)
{ {
FactionEntry const * faction = sFactionStore.LookupEntry(i); FactionEntry const* faction = sFactionStore.LookupEntry(i);
if (faction && faction->team) if (faction && faction->team)
{ {
SimpleFactionsList &flist = sFactionTeamMap[faction->team]; SimpleFactionsList& flist = sFactionTeamMap[faction->team];
flist.push_back(i); flist.push_back(i);
} }
} }
@ -461,8 +461,8 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMapDifficultyStore, dbcPath,"MapDifficulty.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMapDifficultyStore, dbcPath,"MapDifficulty.dbc");
// fill data // fill data
for(uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++i) for (uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++i)
if(MapDifficultyEntry const* entry = sMapDifficultyStore.LookupEntry(i)) if (MapDifficultyEntry const* entry = sMapDifficultyStore.LookupEntry(i))
sMapDifficultyMap[MAKE_PAIR32(entry->MapId,entry->Difficulty)] = MapDifficulty(entry->resetTime,entry->maxPlayers); sMapDifficultyMap[MAKE_PAIR32(entry->MapId,entry->Difficulty)] = MapDifficulty(entry->resetTime,entry->maxPlayers);
sMapDifficultyStore.Clear(); sMapDifficultyStore.Clear();
@ -472,7 +472,7 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sQuestSortStore, dbcPath,"QuestSort.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sQuestSortStore, dbcPath,"QuestSort.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sQuestXPLevelStore, dbcPath,"QuestXP.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sQuestXPLevelStore, dbcPath,"QuestXP.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sPvPDifficultyStore, dbcPath,"PvpDifficulty.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sPvPDifficultyStore, dbcPath,"PvpDifficulty.dbc");
for(uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i) for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i)
if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i)) if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i))
if (entry->bracketId > MAX_BATTLEGROUND_BRACKETS) if (entry->bracketId > MAX_BATTLEGROUND_BRACKETS)
MANGOS_ASSERT(false && "Need update MAX_BATTLEGROUND_BRACKETS by DBC data"); MANGOS_ASSERT(false && "Need update MAX_BATTLEGROUND_BRACKETS by DBC data");
@ -485,24 +485,24 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillRaceClassInfoStore, dbcPath,"SkillRaceClassInfo.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillRaceClassInfoStore, dbcPath,"SkillRaceClassInfo.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSoundEntriesStore, dbcPath,"SoundEntries.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSoundEntriesStore, dbcPath,"SoundEntries.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellStore, dbcPath,"Spell.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellStore, dbcPath,"Spell.dbc");
for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
{ {
SpellEntry const * spell = sSpellStore.LookupEntry(i); SpellEntry const* spell = sSpellStore.LookupEntry(i);
if(spell && spell->Category) if (spell && spell->Category)
sSpellCategoryStore[spell->Category].insert(i); sSpellCategoryStore[spell->Category].insert(i);
// DBC not support uint64 fields but SpellEntry have SpellFamilyFlags mapped at 2 uint32 fields // DBC not support uint64 fields but SpellEntry have SpellFamilyFlags mapped at 2 uint32 fields
// uint32 field already converted to bigendian if need, but must be swapped for correct uint64 bigendian view // uint32 field already converted to bigendian if need, but must be swapped for correct uint64 bigendian view
#if MANGOS_ENDIAN == MANGOS_BIGENDIAN #if MANGOS_ENDIAN == MANGOS_BIGENDIAN
std::swap(*((uint32*)(&spell->SpellFamilyFlags)),*(((uint32*)(&spell->SpellFamilyFlags))+1)); std::swap(*((uint32*)(&spell->SpellFamilyFlags)),*(((uint32*)(&spell->SpellFamilyFlags))+1));
#endif #endif
} }
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
{ {
SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j);
if(!skillLine) if (!skillLine)
continue; continue;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId);
@ -511,10 +511,10 @@ void LoadDBCStores(const std::string& dataPath)
for (unsigned int i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i) for (unsigned int i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i)
{ {
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i); CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i);
if(!cFamily) if (!cFamily)
continue; continue;
if(skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1]) if (skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
continue; continue;
sPetFamilySpellsStore[i].insert(spellInfo->Id); sPetFamilySpellsStore[i].insert(spellInfo->Id);
@ -539,10 +539,10 @@ void LoadDBCStores(const std::string& dataPath)
// create talent spells set // create talent spells set
for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i) for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i)
{ {
TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
if (!talentInfo) continue; if (!talentInfo) continue;
for (int j = 0; j < MAX_TALENT_RANK; j++) for (int j = 0; j < MAX_TALENT_RANK; j++)
if(talentInfo->RankID[j]) if (talentInfo->RankID[j])
sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i,j); sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i,j);
} }
@ -551,10 +551,10 @@ void LoadDBCStores(const std::string& dataPath)
// prepare fast data access to bit pos of talent ranks for use at inspecting // prepare fast data access to bit pos of talent ranks for use at inspecting
{ {
// now have all max ranks (and then bit amount used for store talent ranks in inspect) // now have all max ranks (and then bit amount used for store talent ranks in inspect)
for(uint32 talentTabId = 1; talentTabId < sTalentTabStore.GetNumRows(); ++talentTabId) for (uint32 talentTabId = 1; talentTabId < sTalentTabStore.GetNumRows(); ++talentTabId)
{ {
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentTabId ); TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentTabId);
if(!talentTabInfo) if (!talentTabInfo)
continue; continue;
// prevent memory corruption; otherwise cls will become 12 below // prevent memory corruption; otherwise cls will become 12 below
@ -563,7 +563,7 @@ void LoadDBCStores(const std::string& dataPath)
// store class talent tab pages // store class talent tab pages
uint32 cls = 1; uint32 cls = 1;
for(uint32 m=1;!(m & talentTabInfo->ClassMask) && cls < MAX_CLASSES;m <<=1, ++cls) {} for (uint32 m=1; !(m & talentTabInfo->ClassMask) && cls < MAX_CLASSES; m <<=1, ++cls) {}
sTalentTabPages[cls][talentTabInfo->tabpage]=talentTabId; sTalentTabPages[cls][talentTabInfo->tabpage]=talentTabId;
} }
@ -572,8 +572,8 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiNodesStore, dbcPath,"TaxiNodes.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiNodesStore, dbcPath,"TaxiNodes.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathStore, dbcPath,"TaxiPath.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathStore, dbcPath,"TaxiPath.dbc");
for(uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i) for (uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i)
if(TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i)) if (TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i))
sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID,entry->price); sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID,entry->price);
uint32 pathCount = sTaxiPathStore.GetNumRows(); uint32 pathCount = sTaxiPathStore.GetNumRows();
@ -582,54 +582,54 @@ void LoadDBCStores(const std::string& dataPath)
// Calculate path nodes count // Calculate path nodes count
std::vector<uint32> pathLength; std::vector<uint32> pathLength;
pathLength.resize(pathCount); // 0 and some other indexes not used pathLength.resize(pathCount); // 0 and some other indexes not used
for(uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i) for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
if(TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i)) if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
{ {
if (pathLength[entry->path] < entry->index + 1) if (pathLength[entry->path] < entry->index + 1)
pathLength[entry->path] = entry->index + 1; pathLength[entry->path] = entry->index + 1;
} }
// Set path length // Set path length
sTaxiPathNodesByPath.resize(pathCount); // 0 and some other indexes not used sTaxiPathNodesByPath.resize(pathCount); // 0 and some other indexes not used
for(uint32 i = 1; i < sTaxiPathNodesByPath.size(); ++i) for (uint32 i = 1; i < sTaxiPathNodesByPath.size(); ++i)
sTaxiPathNodesByPath[i].resize(pathLength[i]); sTaxiPathNodesByPath[i].resize(pathLength[i]);
// fill data (pointers to sTaxiPathNodeStore elements // fill data (pointers to sTaxiPathNodeStore elements
for(uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i) for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
if(TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i)) if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
sTaxiPathNodesByPath[entry->path].set(entry->index, entry); sTaxiPathNodesByPath[entry->path].set(entry->index, entry);
// Initialize global taxinodes mask // Initialize global taxinodes mask
// include existing nodes that have at least single not spell base (scripted) path // include existing nodes that have at least single not spell base (scripted) path
{ {
std::set<uint32> spellPaths; std::set<uint32> spellPaths;
for(uint32 i = 1; i < sSpellStore.GetNumRows (); ++i) for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
if(SpellEntry const* sInfo = sSpellStore.LookupEntry (i)) if (SpellEntry const* sInfo = sSpellStore.LookupEntry(i))
for(int j=0; j < MAX_EFFECT_INDEX; ++j) for (int j=0; j < MAX_EFFECT_INDEX; ++j)
if(sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/) if (sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/)
spellPaths.insert(sInfo->EffectMiscValue[j]); spellPaths.insert(sInfo->EffectMiscValue[j]);
memset(sTaxiNodesMask,0,sizeof(sTaxiNodesMask)); memset(sTaxiNodesMask,0,sizeof(sTaxiNodesMask));
memset(sOldContinentsNodesMask,0,sizeof(sTaxiNodesMask)); memset(sOldContinentsNodesMask,0,sizeof(sTaxiNodesMask));
for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
{ {
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i); TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
if(!node) if (!node)
continue; continue;
TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(i); TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(i);
if(src_i!=sTaxiPathSetBySource.end() && !src_i->second.empty()) if (src_i!=sTaxiPathSetBySource.end() && !src_i->second.empty())
{ {
bool ok = false; bool ok = false;
for(TaxiPathSetForSource::const_iterator dest_i = src_i->second.begin();dest_i != src_i->second.end(); ++dest_i) for (TaxiPathSetForSource::const_iterator dest_i = src_i->second.begin(); dest_i != src_i->second.end(); ++dest_i)
{ {
// not spell path // not spell path
if(spellPaths.find(dest_i->second.ID)==spellPaths.end()) if (spellPaths.find(dest_i->second.ID)==spellPaths.end())
{ {
ok = true; ok = true;
break; break;
} }
} }
if(!ok) if (!ok)
continue; continue;
} }
@ -650,9 +650,9 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore, dbcPath,"WorldMapArea.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore, dbcPath,"WorldMapArea.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWMOAreaTableStore, dbcPath,"WMOAreaTable.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWMOAreaTableStore, dbcPath,"WMOAreaTable.dbc");
for(uint32 i = 0; i < sWMOAreaTableStore.GetNumRows(); ++i) for (uint32 i = 0; i < sWMOAreaTableStore.GetNumRows(); ++i)
{ {
if(WMOAreaTableEntry const* entry = sWMOAreaTableStore.LookupEntry(i)) if (WMOAreaTableEntry const* entry = sWMOAreaTableStore.LookupEntry(i))
{ {
sWMOAreaInfoByTripple.insert(WMOAreaInfoByTripple::value_type(WMOAreaTableTripple(entry->rootId, entry->adtId, entry->groupId), entry)); sWMOAreaInfoByTripple.insert(WMOAreaInfoByTripple::value_type(WMOAreaTableTripple(entry->rootId, entry->adtId, entry->groupId), entry));
} }
@ -661,16 +661,16 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc");
// error checks // error checks
if (bad_dbc_files.size() >= DBCFilesCount ) if (bad_dbc_files.size() >= DBCFilesCount)
{ {
sLog.outError("\nIncorrect DataDir value in mangosd.conf or ALL required *.dbc files (%d) not found by path: %sdbc",DBCFilesCount,dataPath.c_str()); sLog.outError("\nIncorrect DataDir value in mangosd.conf or ALL required *.dbc files (%d) not found by path: %sdbc",DBCFilesCount,dataPath.c_str());
Log::WaitBeforeContinueIfNeed(); Log::WaitBeforeContinueIfNeed();
exit(1); exit(1);
} }
else if (!bad_dbc_files.empty() ) else if (!bad_dbc_files.empty())
{ {
std::string str; std::string str;
for(std::list<std::string>::iterator i = bad_dbc_files.begin(); i != bad_dbc_files.end(); ++i) for (std::list<std::string>::iterator i = bad_dbc_files.begin(); i != bad_dbc_files.end(); ++i)
str += *i + "\n"; str += *i + "\n";
sLog.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s",(uint32)bad_dbc_files.size(),DBCFilesCount,str.c_str()); sLog.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s",(uint32)bad_dbc_files.size(),DBCFilesCount,str.c_str());
@ -680,12 +680,12 @@ void LoadDBCStores(const std::string& dataPath)
// Check loaded DBC files proper version // Check loaded DBC files proper version
if (!sAreaStore.LookupEntry(3617) || // last area (areaflag) added in 3.3.5a if (!sAreaStore.LookupEntry(3617) || // last area (areaflag) added in 3.3.5a
!sCharTitlesStore.LookupEntry(177) || // last char title added in 3.3.5a !sCharTitlesStore.LookupEntry(177) || // last char title added in 3.3.5a
!sGemPropertiesStore.LookupEntry(1629) || // last gem property added in 3.3.5a !sGemPropertiesStore.LookupEntry(1629) || // last gem property added in 3.3.5a
!sItemStore.LookupEntry(56806) || // last client known item added in 3.3.5a !sItemStore.LookupEntry(56806) || // last client known item added in 3.3.5a
!sItemExtendedCostStore.LookupEntry(2997) || // last item extended cost added in 3.3.5a !sItemExtendedCostStore.LookupEntry(2997) || // last item extended cost added in 3.3.5a
!sMapStore.LookupEntry(724) || // last map added in 3.3.5a !sMapStore.LookupEntry(724) || // last map added in 3.3.5a
!sSpellStore.LookupEntry(80864) ) // last added spell in 3.3.5a !sSpellStore.LookupEntry(80864)) // last added spell in 3.3.5a
{ {
sLog.outError("\nYou have mixed version DBC files. Please re-extract DBC files for one from client build: %s",AcceptableClientBuildsListStr().c_str()); sLog.outError("\nYou have mixed version DBC files. Please re-extract DBC files for one from client build: %s",AcceptableClientBuildsListStr().c_str());
Log::WaitBeforeContinueIfNeed(); Log::WaitBeforeContinueIfNeed();
@ -693,23 +693,23 @@ void LoadDBCStores(const std::string& dataPath)
} }
sLog.outString(); sLog.outString();
sLog.outString( ">> Initialized %d data stores", DBCFilesCount ); sLog.outString(">> Initialized %d data stores", DBCFilesCount);
} }
SimpleFactionsList const* GetFactionTeamList(uint32 faction) SimpleFactionsList const* GetFactionTeamList(uint32 faction)
{ {
FactionTeamMap::const_iterator itr = sFactionTeamMap.find(faction); FactionTeamMap::const_iterator itr = sFactionTeamMap.find(faction);
if(itr==sFactionTeamMap.end()) if (itr==sFactionTeamMap.end())
return NULL; return NULL;
return &itr->second; return &itr->second;
} }
char const* GetPetName(uint32 petfamily, uint32 dbclang) char const* GetPetName(uint32 petfamily, uint32 dbclang)
{ {
if(!petfamily) if (!petfamily)
return NULL; return NULL;
CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(petfamily); CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(petfamily);
if(!pet_family) if (!pet_family)
return NULL; return NULL;
return pet_family->Name[dbclang]?pet_family->Name[dbclang]:NULL; return pet_family->Name[dbclang]?pet_family->Name[dbclang]:NULL;
} }
@ -717,7 +717,7 @@ char const* GetPetName(uint32 petfamily, uint32 dbclang)
TalentSpellPos const* GetTalentSpellPos(uint32 spellId) TalentSpellPos const* GetTalentSpellPos(uint32 spellId)
{ {
TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId); TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId);
if(itr==sTalentSpellPosMap.end()) if (itr==sTalentSpellPosMap.end())
return NULL; return NULL;
return &itr->second; return &itr->second;
@ -739,7 +739,7 @@ uint32 GetTalentSpellCost(uint32 spellId)
int32 GetAreaFlagByAreaID(uint32 area_id) int32 GetAreaFlagByAreaID(uint32 area_id)
{ {
AreaFlagByAreaID::iterator i = sAreaFlagByAreaID.find(area_id); AreaFlagByAreaID::iterator i = sAreaFlagByAreaID.find(area_id);
if(i == sAreaFlagByAreaID.end()) if (i == sAreaFlagByAreaID.end())
return -1; return -1;
return i->second; return i->second;
@ -747,28 +747,28 @@ int32 GetAreaFlagByAreaID(uint32 area_id)
WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid) WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
{ {
WMOAreaInfoByTripple::iterator i = sWMOAreaInfoByTripple.find(WMOAreaTableTripple(rootid, adtid, groupid)); WMOAreaInfoByTripple::iterator i = sWMOAreaInfoByTripple.find(WMOAreaTableTripple(rootid, adtid, groupid));
if(i == sWMOAreaInfoByTripple.end()) if (i == sWMOAreaInfoByTripple.end())
return NULL; return NULL;
return i->second; return i->second;
} }
AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id) AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id)
{ {
int32 areaflag = GetAreaFlagByAreaID(area_id); int32 areaflag = GetAreaFlagByAreaID(area_id);
if(areaflag < 0) if (areaflag < 0)
return NULL; return NULL;
return sAreaStore.LookupEntry(areaflag ); return sAreaStore.LookupEntry(areaflag);
} }
AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id) AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id)
{ {
if(area_flag) if (area_flag)
return sAreaStore.LookupEntry(area_flag); return sAreaStore.LookupEntry(area_flag);
if(MapEntry const* mapEntry = sMapStore.LookupEntry(map_id)) if (MapEntry const* mapEntry = sMapStore.LookupEntry(map_id))
return GetAreaEntryByAreaID(mapEntry->linked_zone); return GetAreaEntryByAreaID(mapEntry->linked_zone);
return NULL; return NULL;
@ -777,7 +777,7 @@ AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_i
uint32 GetAreaFlagByMapId(uint32 mapid) uint32 GetAreaFlagByMapId(uint32 mapid)
{ {
AreaFlagByMapID::iterator i = sAreaFlagByMapID.find(mapid); AreaFlagByMapID::iterator i = sAreaFlagByMapID.find(mapid);
if(i == sAreaFlagByMapID.end()) if (i == sAreaFlagByMapID.end())
return 0; return 0;
else else
return i->second; return i->second;
@ -785,10 +785,10 @@ uint32 GetAreaFlagByMapId(uint32 mapid)
uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId) uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId)
{ {
if(mapid != 530 && mapid != 571) // speed for most cases if (mapid != 530 && mapid != 571) // speed for most cases
return mapid; return mapid;
if(WorldMapAreaEntry const* wma = sWorldMapAreaStore.LookupEntry(zoneId)) if (WorldMapAreaEntry const* wma = sWorldMapAreaStore.LookupEntry(zoneId))
return wma->virtual_map_id >= 0 ? wma->virtual_map_id : wma->map_id; return wma->virtual_map_id >= 0 ? wma->virtual_map_id : wma->map_id;
return mapid; return mapid;
@ -797,14 +797,14 @@ uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId)
ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId) ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId)
{ {
mapid = GetVirtualMapForMapAndZone(mapid,zoneId); mapid = GetVirtualMapForMapAndZone(mapid,zoneId);
if(mapid < 2) if (mapid < 2)
return CONTENT_1_60; return CONTENT_1_60;
MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); MapEntry const* mapEntry = sMapStore.LookupEntry(mapid);
if(!mapEntry) if (!mapEntry)
return CONTENT_1_60; return CONTENT_1_60;
switch(mapEntry->Expansion()) switch (mapEntry->Expansion())
{ {
default: return CONTENT_1_60; default: return CONTENT_1_60;
case 1: return CONTENT_61_70; case 1: return CONTENT_61_70;
@ -815,10 +815,10 @@ ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId)
ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id) ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
{ {
// not sorted, numbering index from 0 // not sorted, numbering index from 0
for(uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i) for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i)
{ {
ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(i); ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(i);
if(ch && ch->ChannelID == channel_id) if (ch && ch->ChannelID == channel_id)
return ch; return ch;
} }
return NULL; return NULL;
@ -826,19 +826,19 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId) bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
{ {
if(requiredTotemCategoryId==0) if (requiredTotemCategoryId==0)
return true; return true;
if(itemTotemCategoryId==0) if (itemTotemCategoryId==0)
return false; return false;
TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId); TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId);
if(!itemEntry) if (!itemEntry)
return false; return false;
TotemCategoryEntry const* reqEntry = sTotemCategoryStore.LookupEntry(requiredTotemCategoryId); TotemCategoryEntry const* reqEntry = sTotemCategoryStore.LookupEntry(requiredTotemCategoryId);
if(!reqEntry) if (!reqEntry)
return false; return false;
if(itemEntry->categoryType!=reqEntry->categoryType) if (itemEntry->categoryType!=reqEntry->categoryType)
return false; return false;
return (itemEntry->categoryMask & reqEntry->categoryMask)==reqEntry->categoryMask; return (itemEntry->categoryMask & reqEntry->categoryMask)==reqEntry->categoryMask;
@ -880,10 +880,10 @@ MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
return itr != sMapDifficultyMap.end() ? &itr->second : NULL; return itr != sMapDifficultyMap.end() ? &itr->second : NULL;
} }
PvPDifficultyEntry const* GetBattlegroundBracketByLevel( uint32 mapid, uint32 level ) PvPDifficultyEntry const* GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
{ {
PvPDifficultyEntry const* maxEntry = NULL; // used for level > max listed level case PvPDifficultyEntry const* maxEntry = NULL; // used for level > max listed level case
for(uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i) for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i)
{ {
if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i)) if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i))
{ {
@ -906,7 +906,7 @@ PvPDifficultyEntry const* GetBattlegroundBracketByLevel( uint32 mapid, uint32 le
PvPDifficultyEntry const* GetBattlegroundBracketById(uint32 mapid, BattleGroundBracketId id) PvPDifficultyEntry const* GetBattlegroundBracketById(uint32 mapid, BattleGroundBracketId id)
{ {
for(uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i) for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i)
if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i)) if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i))
if (entry->mapId == mapid && entry->GetBracketId() == id) if (entry->mapId == mapid && entry->GetBracketId() == id)
return entry; return entry;
@ -928,7 +928,7 @@ bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, flo
{ {
// if we have radius check it // if we have radius check it
float dist2 = (x-atEntry->x)*(x-atEntry->x) + (y-atEntry->y)*(y-atEntry->y) + (z-atEntry->z)*(z-atEntry->z); float dist2 = (x-atEntry->x)*(x-atEntry->x) + (y-atEntry->y)*(y-atEntry->y) + (z-atEntry->z)*(z-atEntry->z);
if(dist2 > (atEntry->radius + delta)*(atEntry->radius + delta)) if (dist2 > (atEntry->radius + delta)*(atEntry->radius + delta))
return false; return false;
} }
else else
@ -953,9 +953,9 @@ bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, flo
float dz = z - atEntry->z; float dz = z - atEntry->z;
float dx = rotPlayerX - atEntry->x; float dx = rotPlayerX - atEntry->x;
float dy = rotPlayerY - atEntry->y; float dy = rotPlayerY - atEntry->y;
if( (fabs(dx) > atEntry->box_x/2 + delta) || if ((fabs(dx) > atEntry->box_x/2 + delta) ||
(fabs(dy) > atEntry->box_y/2 + delta) || (fabs(dy) > atEntry->box_y/2 + delta) ||
(fabs(dz) > atEntry->box_z/2 + delta) ) (fabs(dz) > atEntry->box_z/2 + delta))
{ {
return false; return false;
} }

View file

@ -210,4 +210,5 @@ MANGOS_DLL_SPEC DBCStorage <ItemEntry> const* GetItemDisplaySto
MANGOS_DLL_SPEC DBCStorage <CreatureDisplayInfoEntry> const* GetCreatureDisplayStore(); MANGOS_DLL_SPEC DBCStorage <CreatureDisplayInfoEntry> const* GetCreatureDisplayStore();
MANGOS_DLL_SPEC DBCStorage <EmotesEntry> const* GetEmotesStore(); MANGOS_DLL_SPEC DBCStorage <EmotesEntry> const* GetEmotesStore();
MANGOS_DLL_SPEC DBCStorage <EmotesTextEntry> const* GetEmotesTextStore(); MANGOS_DLL_SPEC DBCStorage <EmotesTextEntry> const* GetEmotesTextStore();
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -31,7 +31,7 @@ const char BattlemasterListEntryfmt[]="niiiiiiiiixssssssssssssssssxiiii";
const char CharStartOutfitEntryfmt[]="diiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char CharStartOutfitEntryfmt[]="diiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const char CharTitlesEntryfmt[]="nxssssssssssssssssxxxxxxxxxxxxxxxxxxi"; const char CharTitlesEntryfmt[]="nxssssssssssssssssxxxxxxxxxxxxxxxxxxi";
const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx"; const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx";
// ChatChannelsEntryfmt, index not used (more compact store) // ChatChannelsEntryfmt, index not used (more compact store)
const char ChrClassesEntryfmt[]="nxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii"; const char ChrClassesEntryfmt[]="nxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii";
const char ChrRacesEntryfmt[]="nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi"; const char ChrRacesEntryfmt[]="nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi";
const char CinematicSequencesEntryfmt[]="nxxxxxxxxx"; const char CinematicSequencesEntryfmt[]="nxxxxxxxxx";

View file

@ -29,16 +29,16 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
ObjectGuid guid; ObjectGuid guid;
recvPacket >> guid; recvPacket >> guid;
if(!GetPlayer()->duel) // ignore accept from duel-sender if (!GetPlayer()->duel) // ignore accept from duel-sender
return; return;
Player *pl = GetPlayer(); Player* pl = GetPlayer();
Player *plTarget = pl->duel->opponent; Player* plTarget = pl->duel->opponent;
if(pl == pl->duel->initiator || !plTarget || pl == plTarget || pl->duel->startTime != 0 || plTarget->duel->startTime != 0) if (pl == pl->duel->initiator || !plTarget || pl == plTarget || pl->duel->startTime != 0 || plTarget->duel->startTime != 0)
return; return;
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: received CMSG_DUEL_ACCEPTED" ); DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: received CMSG_DUEL_ACCEPTED");
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "Player 1 is: %u (%s)", pl->GetGUIDLow(), pl->GetName()); DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "Player 1 is: %u (%s)", pl->GetGUIDLow(), pl->GetName());
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName()); DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName());
@ -55,14 +55,14 @@ void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket)
//DEBUG_LOG( "WORLD: received CMSG_DUEL_CANCELLED" ); //DEBUG_LOG( "WORLD: received CMSG_DUEL_CANCELLED" );
// no duel requested // no duel requested
if(!GetPlayer()->duel) if (!GetPlayer()->duel)
return; return;
// player surrendered in a duel using /forfeit // player surrendered in a duel using /forfeit
if(GetPlayer()->duel->startTime != 0) if (GetPlayer()->duel->startTime != 0)
{ {
GetPlayer()->CombatStopWithPets(true); GetPlayer()->CombatStopWithPets(true);
if(GetPlayer()->duel->opponent) if (GetPlayer()->duel->opponent)
GetPlayer()->duel->opponent->CombatStopWithPets(true); GetPlayer()->duel->opponent->CombatStopWithPets(true);
GetPlayer()->CastSpell(GetPlayer(), 7267, true); // beg GetPlayer()->CastSpell(GetPlayer(), 7267, true); // beg

View file

@ -41,7 +41,7 @@ DynamicObject::DynamicObject() : WorldObject()
void DynamicObject::AddToWorld() void DynamicObject::AddToWorld()
{ {
///- Register the dynamicObject for guid lookup ///- Register the dynamicObject for guid lookup
if(!IsInWorld()) if (!IsInWorld())
GetMap()->GetObjectsStore().insert<DynamicObject>(GetObjectGuid(), (DynamicObject*)this); GetMap()->GetObjectsStore().insert<DynamicObject>(GetObjectGuid(), (DynamicObject*)this);
Object::AddToWorld(); Object::AddToWorld();
@ -50,7 +50,7 @@ void DynamicObject::AddToWorld()
void DynamicObject::RemoveFromWorld() void DynamicObject::RemoveFromWorld()
{ {
///- Remove the dynamicObject from the accessor ///- Remove the dynamicObject from the accessor
if(IsInWorld()) if (IsInWorld())
{ {
GetMap()->GetObjectsStore().erase<DynamicObject>(GetObjectGuid(), (DynamicObject*)NULL); GetMap()->GetObjectsStore().erase<DynamicObject>(GetObjectGuid(), (DynamicObject*)NULL);
GetViewPoint().Event_RemovedFromWorld(); GetViewPoint().Event_RemovedFromWorld();
@ -59,13 +59,13 @@ void DynamicObject::RemoveFromWorld()
Object::RemoveFromWorld(); Object::RemoveFromWorld();
} }
bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius, DynamicObjectType type) bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius, DynamicObjectType type)
{ {
WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask()); WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());
SetMap(caster->GetMap()); SetMap(caster->GetMap());
Relocate(x, y, z, 0); Relocate(x, y, z, 0);
if(!IsPositionValid()) if (!IsPositionValid())
{ {
sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY()); sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY());
return false; return false;
@ -119,7 +119,7 @@ void DynamicObject::Update(uint32 update_diff, uint32 p_time)
{ {
// caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor // caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if(!caster) if (!caster)
{ {
Delete(); Delete();
return; return;
@ -127,20 +127,20 @@ void DynamicObject::Update(uint32 update_diff, uint32 p_time)
bool deleteThis = false; bool deleteThis = false;
if(m_aliveDuration > int32(p_time)) if (m_aliveDuration > int32(p_time))
m_aliveDuration -= p_time; m_aliveDuration -= p_time;
else else
deleteThis = true; deleteThis = true;
// have radius and work as persistent effect // have radius and work as persistent effect
if(m_radius) if (m_radius)
{ {
// TODO: make a timer and update this in larger intervals // TODO: make a timer and update this in larger intervals
MaNGOS::DynamicObjectUpdater notifier(*this, caster, m_positive); MaNGOS::DynamicObjectUpdater notifier(*this, caster, m_positive);
Cell::VisitAllObjects(this, notifier, m_radius); Cell::VisitAllObjects(this, notifier, m_radius);
} }
if(deleteThis) if (deleteThis)
{ {
caster->RemoveDynObjectWithGUID(GetObjectGuid()); caster->RemoveDynObjectWithGUID(GetObjectGuid());
Delete(); Delete();
@ -156,12 +156,12 @@ void DynamicObject::Delete()
void DynamicObject::Delay(int32 delaytime) void DynamicObject::Delay(int32 delaytime)
{ {
m_aliveDuration -= delaytime; m_aliveDuration -= delaytime;
for (GuidSet::iterator iter = m_affected.begin(); iter != m_affected.end(); ) for (GuidSet::iterator iter = m_affected.begin(); iter != m_affected.end();)
{ {
Unit *target = GetMap()->GetUnit((*iter)); Unit* target = GetMap()->GetUnit((*iter));
if (target) if (target)
{ {
SpellAuraHolder *holder = target->GetSpellAuraHolder(m_spellId, GetCasterGuid()); SpellAuraHolder* holder = target->GetSpellAuraHolder(m_spellId, GetCasterGuid());
if (!holder) if (!holder)
{ {
++iter; ++iter;
@ -205,7 +205,7 @@ bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* view
return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
} }
bool DynamicObject::IsHostileTo( Unit const* unit ) const bool DynamicObject::IsHostileTo(Unit const* unit) const
{ {
if (Unit* owner = GetCaster()) if (Unit* owner = GetCaster())
return owner->IsHostileTo(unit); return owner->IsHostileTo(unit);
@ -213,7 +213,7 @@ bool DynamicObject::IsHostileTo( Unit const* unit ) const
return false; return false;
} }
bool DynamicObject::IsFriendlyTo( Unit const* unit ) const bool DynamicObject::IsFriendlyTo(Unit const* unit) const
{ {
if (Unit* owner = GetCaster()) if (Unit* owner = GetCaster())
return owner->IsFriendlyTo(unit); return owner->IsFriendlyTo(unit);

View file

@ -40,7 +40,7 @@ class DynamicObject : public WorldObject
void AddToWorld(); void AddToWorld();
void RemoveFromWorld(); void RemoveFromWorld();
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius, DynamicObjectType type); bool Create(uint32 guidlow, Unit* caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius, DynamicObjectType type);
void Update(uint32 update_diff, uint32 p_time) override; void Update(uint32 update_diff, uint32 p_time) override;
void Delete(); void Delete();
uint32 GetSpellId() const { return m_spellId; } uint32 GetSpellId() const { return m_spellId; }
@ -50,9 +50,9 @@ class DynamicObject : public WorldObject
Unit* GetCaster() const; Unit* GetCaster() const;
float GetRadius() const { return m_radius; } float GetRadius() const { return m_radius; }
DynamicObjectType GetType() const { return (DynamicObjectType)GetByteValue(DYNAMICOBJECT_BYTES,0); } DynamicObjectType GetType() const { return (DynamicObjectType)GetByteValue(DYNAMICOBJECT_BYTES,0); }
bool IsAffecting(Unit *unit) const { return m_affected.find(unit->GetObjectGuid()) != m_affected.end(); } bool IsAffecting(Unit* unit) const { return m_affected.find(unit->GetObjectGuid()) != m_affected.end(); }
void AddAffected(Unit *unit) { m_affected.insert(unit->GetObjectGuid()); } void AddAffected(Unit* unit) { m_affected.insert(unit->GetObjectGuid()); }
void RemoveAffected(Unit *unit) { m_affected.erase(unit->GetObjectGuid()); } void RemoveAffected(Unit* unit) { m_affected.erase(unit->GetObjectGuid()); }
void Delay(int32 delaytime); void Delay(int32 delaytime);
bool IsHostileTo(Unit const* unit) const; bool IsHostileTo(Unit const* unit) const;
@ -65,7 +65,7 @@ class DynamicObject : public WorldObject
bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const; bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
GridReference<DynamicObject> &GetGridRef() { return m_gridRef; } GridReference<DynamicObject>& GetGridRef() { return m_gridRef; }
protected: protected:
uint32 m_spellId; uint32 m_spellId;