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,7 +64,7 @@ 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
@ -84,20 +84,20 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &/*recv_data*/)
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

@ -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();
@ -84,7 +84,7 @@ class MANGOS_DLL_SPEC ViewPoint
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); }
@ -93,15 +93,15 @@ class MANGOS_DLL_SPEC ViewPoint
{ {
if (!m_cameras.empty()) if (!m_cameras.empty())
{ {
for(CameraList::iterator itr = m_cameras.begin(); itr != m_cameras.end();) for (CameraList::iterator itr = m_cameras.begin(); itr != m_cameras.end();)
{ {
Camera *c = *(itr++); Camera* c = *(itr++);
(c->*handler)(); (c->*handler)();
} }
} }
} }
public: public:
ViewPoint() : m_grid(0) {} ViewPoint() : m_grid(0) {}
~ViewPoint(); ~ViewPoint();
@ -109,7 +109,7 @@ public:
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);
@ -121,7 +121,7 @@ public:
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);

View file

@ -47,25 +47,25 @@ 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; 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; y = data.Part.grid_y*MAX_NUMBER_OF_CELLS + data.Part.cell_y;
} }
bool DiffCell(const Cell &cell) const bool DiffCell(const Cell& cell) const
{ {
return( data.Part.cell_x != cell.data.Part.cell_x || return(data.Part.cell_x != cell.data.Part.cell_x ||
data.Part.cell_y != cell.data.Part.cell_y ); data.Part.cell_y != cell.data.Part.cell_y);
} }
bool DiffGrid(const Cell &cell) const bool DiffGrid(const Cell& cell) const
{ {
return( data.Part.grid_x != cell.data.Part.grid_x || return(data.Part.grid_x != cell.data.Part.grid_x ||
data.Part.grid_y != cell.data.Part.grid_y ); data.Part.grid_y != cell.data.Part.grid_y);
} }
uint32 CellX() const { return data.Part.cell_x; } uint32 CellX() const { return data.Part.cell_x; }
@ -84,14 +84,14 @@ struct MANGOS_DLL_DECL Cell
data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y); data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y);
} }
Cell& operator=(const Cell &cell) Cell& operator=(const Cell& cell)
{ {
data.All = cell.data.All; data.All = cell.data.All;
return *this; return *this;
} }
bool operator==(const Cell &cell) const { return (data.All == cell.data.All); } bool operator==(const Cell& cell) const { return (data.All == cell.data.All); }
bool operator!=(const Cell &cell) const { return !operator==(cell); } bool operator!=(const Cell& cell) const { return !operator==(cell); }
union union
{ {
struct struct
@ -106,21 +106,21 @@ struct MANGOS_DLL_DECL Cell
uint32 All; uint32 All;
} data; } 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, 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; 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); 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 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 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 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 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 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); template<class T> static void VisitAllObjects(float x, float y, Map* map, T& visitor, float radius, bool dont_load = true);
private: private:
template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER> &, Map &, const CellPair& , const CellPair& ) const; template<class T, class CONTAINER> void VisitCircle(TypeContainerVisitor<T, CONTAINER>&, Map&, const CellPair& , const CellPair&) const;
}; };
#endif #endif

View file

@ -51,7 +51,7 @@ inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
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,9 +446,9 @@ 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
@ -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

@ -125,23 +125,23 @@ class Channel
uint8 flags; uint8 flags;
bool HasFlag(uint8 flag) { return flags & flag; } bool HasFlag(uint8 flag) { return flags & flag; }
void SetFlag(uint8 flag) { if(!HasFlag(flag)) flags |= flag; } void SetFlag(uint8 flag) { if (!HasFlag(flag)) flags |= flag; }
bool IsOwner() { return flags & MEMBER_FLAG_OWNER; } bool IsOwner() { return flags & MEMBER_FLAG_OWNER; }
void SetOwner(bool state) void SetOwner(bool state)
{ {
if(state) flags |= MEMBER_FLAG_OWNER; if (state) flags |= MEMBER_FLAG_OWNER;
else flags &= ~MEMBER_FLAG_OWNER; else flags &= ~MEMBER_FLAG_OWNER;
} }
bool IsModerator() { return flags & MEMBER_FLAG_MODERATOR; } bool IsModerator() { return flags & MEMBER_FLAG_MODERATOR; }
void SetModerator(bool state) void SetModerator(bool state)
{ {
if(state) flags |= MEMBER_FLAG_MODERATOR; if (state) flags |= MEMBER_FLAG_MODERATOR;
else flags &= ~MEMBER_FLAG_MODERATOR; else flags &= ~MEMBER_FLAG_MODERATOR;
} }
bool IsMuted() { return flags & MEMBER_FLAG_MUTED; } bool IsMuted() { return flags & MEMBER_FLAG_MUTED; }
void SetMuted(bool state) void SetMuted(bool state)
{ {
if(state) flags |= MEMBER_FLAG_MUTED; if (state) flags |= MEMBER_FLAG_MUTED;
else flags &= ~MEMBER_FLAG_MUTED; else flags &= ~MEMBER_FLAG_MUTED;
} }
}; };
@ -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()

View file

@ -89,7 +89,7 @@ bool LoginQueryHolder::Initialize()
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSOCIALLIST, "SELECT friend,flags,note FROM character_social WHERE guid = '%u' LIMIT 255", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSOCIALLIST, "SELECT friend,flags,note FROM character_social WHERE guid = '%u' LIMIT 255", m_guid.GetCounter());
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHOMEBIND, "SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADHOMEBIND, "SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", m_guid.GetCounter());
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS, "SELECT spell,item,time FROM character_spell_cooldown WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLCOOLDOWNS, "SELECT spell,item,time FROM character_spell_cooldown WHERE guid = '%u'", m_guid.GetCounter());
if(sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED)) if (sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED))
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = '%u'", m_guid.GetCounter());
// in other case still be dummy query // in other case still be dummy query
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGUILD, "SELECT guildid,rank FROM guild_member WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGUILD, "SELECT guildid,rank FROM guild_member WHERE guid = '%u'", m_guid.GetCounter());
@ -114,21 +114,21 @@ bool LoginQueryHolder::Initialize()
class CharacterHandler class CharacterHandler
{ {
public: public:
void HandleCharEnumCallback(QueryResult * result, uint32 account) void HandleCharEnumCallback(QueryResult* result, uint32 account)
{ {
WorldSession * session = sWorld.FindSession(account); WorldSession* session = sWorld.FindSession(account);
if(!session) if (!session)
{ {
delete result; delete result;
return; return;
} }
session->HandleCharEnum(result); session->HandleCharEnum(result);
} }
void HandlePlayerLoginCallback(QueryResult * /*dummy*/, SqlQueryHolder * holder) void HandlePlayerLoginCallback(QueryResult* /*dummy*/, SqlQueryHolder* holder)
{ {
if (!holder) return; if (!holder) return;
WorldSession *session = sWorld.FindSession(((LoginQueryHolder*)holder)->GetAccountId()); WorldSession* session = sWorld.FindSession(((LoginQueryHolder*)holder)->GetAccountId());
if(!session) if (!session)
{ {
delete holder; delete holder;
return; return;
@ -137,7 +137,7 @@ class CharacterHandler
} }
} chrHandler; } chrHandler;
void WorldSession::HandleCharEnum(QueryResult * result) void WorldSession::HandleCharEnum(QueryResult* result)
{ {
WorldPacket data(SMSG_CHAR_ENUM, 100); // we guess size WorldPacket data(SMSG_CHAR_ENUM, 100); // we guess size
@ -145,26 +145,26 @@ void WorldSession::HandleCharEnum(QueryResult * result)
data << num; data << num;
if( result ) if (result)
{ {
do do
{ {
uint32 guidlow = (*result)[0].GetUInt32(); uint32 guidlow = (*result)[0].GetUInt32();
DETAIL_LOG("Build enum data for char guid %u from account %u.", guidlow, GetAccountId()); DETAIL_LOG("Build enum data for char guid %u from account %u.", guidlow, GetAccountId());
if(Player::BuildEnumData(result, &data)) if (Player::BuildEnumData(result, &data))
++num; ++num;
} }
while( result->NextRow() ); while (result->NextRow());
delete result; delete result;
} }
data.put<uint8>(0, num); data.put<uint8>(0, num);
SendPacket( &data ); SendPacket(&data);
} }
void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleCharEnumOpcode(WorldPacket& /*recv_data*/)
{ {
/// get all the data necessary for loading all characters (along with their pets) on the account /// get all the data necessary for loading all characters (along with their pets) on the account
CharacterDatabase.AsyncPQuery(&chrHandler, &CharacterHandler::HandleCharEnumCallback, GetAccountId(), CharacterDatabase.AsyncPQuery(&chrHandler, &CharacterHandler::HandleCharEnumCallback, GetAccountId(),
@ -194,7 +194,7 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
PET_SAVE_AS_CURRENT, GetAccountId()); PET_SAVE_AS_CURRENT, GetAccountId());
} }
void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data ) void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data)
{ {
std::string name; std::string name;
uint8 race_, class_; uint8 race_, class_;
@ -211,23 +211,23 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
WorldPacket data(SMSG_CHAR_CREATE, 1); // returned with diff.values in all cases WorldPacket data(SMSG_CHAR_CREATE, 1); // returned with diff.values in all cases
if(GetSecurity() == SEC_PLAYER) if (GetSecurity() == SEC_PLAYER)
{ {
if(uint32 mask = sWorld.getConfig(CONFIG_UINT32_CHARACTERS_CREATING_DISABLED)) if (uint32 mask = sWorld.getConfig(CONFIG_UINT32_CHARACTERS_CREATING_DISABLED))
{ {
bool disabled = false; bool disabled = false;
Team team = Player::TeamForRace(race_); Team team = Player::TeamForRace(race_);
switch(team) switch (team)
{ {
case ALLIANCE: disabled = mask & (1 << 0); break; case ALLIANCE: disabled = mask & (1 << 0); break;
case HORDE: disabled = mask & (1 << 1); break; case HORDE: disabled = mask & (1 << 1); break;
} }
if(disabled) if (disabled)
{ {
data << (uint8)CHAR_CREATE_DISABLED; data << (uint8)CHAR_CREATE_DISABLED;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
} }
@ -236,10 +236,10 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_); ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_);
ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_); ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_);
if( !classEntry || !raceEntry ) if (!classEntry || !raceEntry)
{ {
data << (uint8)CHAR_CREATE_FAILED; data << (uint8)CHAR_CREATE_FAILED;
SendPacket( &data ); SendPacket(&data);
sLog.outError("Class: %u or Race %u not found in DBC (Wrong DBC files?) or Cheater?", class_, race_); sLog.outError("Class: %u or Race %u not found in DBC (Wrong DBC files?) or Cheater?", class_, race_);
return; return;
} }
@ -249,7 +249,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
{ {
data << (uint8)CHAR_CREATE_EXPANSION; data << (uint8)CHAR_CREATE_EXPANSION;
sLog.outError("Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", Expansion(), GetAccountId(), raceEntry->expansion, race_); sLog.outError("Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", Expansion(), GetAccountId(), raceEntry->expansion, race_);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -258,7 +258,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
{ {
data << (uint8)CHAR_CREATE_EXPANSION_CLASS; data << (uint8)CHAR_CREATE_EXPANSION_CLASS;
sLog.outError("Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", Expansion(), GetAccountId(), classEntry->expansion, class_); sLog.outError("Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", Expansion(), GetAccountId(), classEntry->expansion, class_);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -266,7 +266,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if (!normalizePlayerName(name)) if (!normalizePlayerName(name))
{ {
data << (uint8)CHAR_NAME_NO_NAME; data << (uint8)CHAR_NAME_NO_NAME;
SendPacket( &data ); SendPacket(&data);
sLog.outError("Account:[%d] but tried to Create character with empty [name]", GetAccountId()); sLog.outError("Account:[%d] but tried to Create character with empty [name]", GetAccountId());
return; return;
} }
@ -276,70 +276,70 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if (res != CHAR_NAME_SUCCESS) if (res != CHAR_NAME_SUCCESS)
{ {
data << uint8(res); data << uint8(res);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
if (GetSecurity() == SEC_PLAYER && sObjectMgr.IsReservedName(name)) if (GetSecurity() == SEC_PLAYER && sObjectMgr.IsReservedName(name))
{ {
data << (uint8)CHAR_NAME_RESERVED; data << (uint8)CHAR_NAME_RESERVED;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
if (sObjectMgr.GetPlayerGuidByName(name)) if (sObjectMgr.GetPlayerGuidByName(name))
{ {
data << (uint8)CHAR_CREATE_NAME_IN_USE; data << (uint8)CHAR_CREATE_NAME_IN_USE;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
QueryResult *resultacct = LoginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%u'", GetAccountId()); QueryResult* resultacct = LoginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%u'", GetAccountId());
if (resultacct) if (resultacct)
{ {
Field *fields=resultacct->Fetch(); Field* fields=resultacct->Fetch();
uint32 acctcharcount = fields[0].GetUInt32(); uint32 acctcharcount = fields[0].GetUInt32();
delete resultacct; delete resultacct;
if (acctcharcount >= sWorld.getConfig(CONFIG_UINT32_CHARACTERS_PER_ACCOUNT)) if (acctcharcount >= sWorld.getConfig(CONFIG_UINT32_CHARACTERS_PER_ACCOUNT))
{ {
data << (uint8)CHAR_CREATE_ACCOUNT_LIMIT; data << (uint8)CHAR_CREATE_ACCOUNT_LIMIT;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
} }
QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%u'", GetAccountId()); QueryResult* result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%u'", GetAccountId());
uint8 charcount = 0; uint8 charcount = 0;
if ( result ) if (result)
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
charcount = fields[0].GetUInt8(); charcount = fields[0].GetUInt8();
delete result; delete result;
if (charcount >= sWorld.getConfig(CONFIG_UINT32_CHARACTERS_PER_REALM)) if (charcount >= sWorld.getConfig(CONFIG_UINT32_CHARACTERS_PER_REALM))
{ {
data << (uint8)CHAR_CREATE_SERVER_LIMIT; data << (uint8)CHAR_CREATE_SERVER_LIMIT;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
} }
// speedup check for heroic class disabled case // speedup check for heroic class disabled case
uint32 heroic_free_slots = sWorld.getConfig(CONFIG_UINT32_HEROIC_CHARACTERS_PER_REALM); uint32 heroic_free_slots = sWorld.getConfig(CONFIG_UINT32_HEROIC_CHARACTERS_PER_REALM);
if(heroic_free_slots == 0 && GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT) if (heroic_free_slots == 0 && GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
{ {
data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT; data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
// speedup check for heroic class disabled case // speedup check for heroic class disabled case
uint32 req_level_for_heroic = sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING); uint32 req_level_for_heroic = sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING);
if(GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && req_level_for_heroic > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) if (GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && req_level_for_heroic > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
{ {
data << (uint8)CHAR_CREATE_LEVEL_REQUIREMENT; data << (uint8)CHAR_CREATE_LEVEL_REQUIREMENT;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -351,38 +351,38 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
// if 0 then allowed creating without any characters // if 0 then allowed creating without any characters
bool have_req_level_for_heroic = (req_level_for_heroic==0); bool have_req_level_for_heroic = (req_level_for_heroic==0);
if(!AllowTwoSideAccounts || skipCinematics == CINEMATICS_SKIP_SAME_RACE || class_ == CLASS_DEATH_KNIGHT) if (!AllowTwoSideAccounts || skipCinematics == CINEMATICS_SKIP_SAME_RACE || class_ == CLASS_DEATH_KNIGHT)
{ {
QueryResult *result2 = CharacterDatabase.PQuery("SELECT level,race,class FROM characters WHERE account = '%u' %s", QueryResult* result2 = CharacterDatabase.PQuery("SELECT level,race,class FROM characters WHERE account = '%u' %s",
GetAccountId(), (skipCinematics == CINEMATICS_SKIP_SAME_RACE || class_ == CLASS_DEATH_KNIGHT) ? "" : "LIMIT 1"); GetAccountId(), (skipCinematics == CINEMATICS_SKIP_SAME_RACE || class_ == CLASS_DEATH_KNIGHT) ? "" : "LIMIT 1");
if(result2) if (result2)
{ {
Team team_= Player::TeamForRace(race_); Team team_= Player::TeamForRace(race_);
Field* field = result2->Fetch(); Field* field = result2->Fetch();
uint8 acc_race = field[1].GetUInt32(); uint8 acc_race = field[1].GetUInt32();
if(GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT) if (GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
{ {
uint8 acc_class = field[2].GetUInt32(); uint8 acc_class = field[2].GetUInt32();
if(acc_class == CLASS_DEATH_KNIGHT) if (acc_class == CLASS_DEATH_KNIGHT)
{ {
if(heroic_free_slots > 0) if (heroic_free_slots > 0)
--heroic_free_slots; --heroic_free_slots;
if(heroic_free_slots == 0) if (heroic_free_slots == 0)
{ {
data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT; data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
SendPacket( &data ); SendPacket(&data);
delete result2; delete result2;
return; return;
} }
} }
if(!have_req_level_for_heroic) if (!have_req_level_for_heroic)
{ {
uint32 acc_level = field[0].GetUInt32(); uint32 acc_level = field[0].GetUInt32();
if(acc_level >= req_level_for_heroic) if (acc_level >= req_level_for_heroic)
have_req_level_for_heroic = true; have_req_level_for_heroic = true;
} }
} }
@ -394,7 +394,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if (acc_race == 0 || Player::TeamForRace(acc_race) != team_) if (acc_race == 0 || Player::TeamForRace(acc_race) != team_)
{ {
data << (uint8)CHAR_CREATE_PVP_TEAMS_VIOLATION; data << (uint8)CHAR_CREATE_PVP_TEAMS_VIOLATION;
SendPacket( &data ); SendPacket(&data);
delete result2; delete result2;
return; return;
} }
@ -404,36 +404,36 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
// TODO: check if cinematic already shown? (already logged in?; cinematic field) // TODO: check if cinematic already shown? (already logged in?; cinematic field)
while ((skipCinematics == CINEMATICS_SKIP_SAME_RACE && !have_same_race) || class_ == CLASS_DEATH_KNIGHT) while ((skipCinematics == CINEMATICS_SKIP_SAME_RACE && !have_same_race) || class_ == CLASS_DEATH_KNIGHT)
{ {
if(!result2->NextRow()) if (!result2->NextRow())
break; break;
field = result2->Fetch(); field = result2->Fetch();
acc_race = field[1].GetUInt32(); acc_race = field[1].GetUInt32();
if(!have_same_race) if (!have_same_race)
have_same_race = race_ == acc_race; have_same_race = race_ == acc_race;
if(GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT) if (GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT)
{ {
uint8 acc_class = field[2].GetUInt32(); uint8 acc_class = field[2].GetUInt32();
if(acc_class == CLASS_DEATH_KNIGHT) if (acc_class == CLASS_DEATH_KNIGHT)
{ {
if(heroic_free_slots > 0) if (heroic_free_slots > 0)
--heroic_free_slots; --heroic_free_slots;
if(heroic_free_slots == 0) if (heroic_free_slots == 0)
{ {
data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT; data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
SendPacket( &data ); SendPacket(&data);
delete result2; delete result2;
return; return;
} }
} }
if(!have_req_level_for_heroic) if (!have_req_level_for_heroic)
{ {
uint32 acc_level = field[0].GetUInt32(); uint32 acc_level = field[0].GetUInt32();
if(acc_level >= req_level_for_heroic) if (acc_level >= req_level_for_heroic)
have_req_level_for_heroic = true; have_req_level_for_heroic = true;
} }
} }
@ -442,21 +442,21 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
} }
} }
if(GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && !have_req_level_for_heroic) if (GetSecurity() == SEC_PLAYER && class_ == CLASS_DEATH_KNIGHT && !have_req_level_for_heroic)
{ {
data << (uint8)CHAR_CREATE_LEVEL_REQUIREMENT; data << (uint8)CHAR_CREATE_LEVEL_REQUIREMENT;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
Player *pNewChar = new Player(this); Player* pNewChar = new Player(this);
if (!pNewChar->Create(sObjectMgr.GeneratePlayerLowGuid(), name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId)) if (!pNewChar->Create(sObjectMgr.GeneratePlayerLowGuid(), name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId))
{ {
// Player not create (race/class problem?) // Player not create (race/class problem?)
delete pNewChar; delete pNewChar;
data << (uint8)CHAR_CREATE_ERROR; data << (uint8)CHAR_CREATE_ERROR;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -474,7 +474,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charcount, GetAccountId(), realmID); LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charcount, GetAccountId(), realmID);
data << (uint8)CHAR_CREATE_SUCCESS; data << (uint8)CHAR_CREATE_SUCCESS;
SendPacket( &data ); SendPacket(&data);
std::string IP_str = GetRemoteAddress(); std::string IP_str = GetRemoteAddress();
BASIC_LOG("Account: %d (IP: %s) Create Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), pNewChar->GetGUIDLow()); BASIC_LOG("Account: %d (IP: %s) Create Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), pNewChar->GetGUIDLow());
@ -483,13 +483,13 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
delete pNewChar; // created only to call SaveToDB() delete pNewChar; // created only to call SaveToDB()
} }
void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data ) void WorldSession::HandleCharDeleteOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
// can't delete loaded character // can't delete loaded character
if(sObjectMgr.GetPlayer(guid)) if (sObjectMgr.GetPlayer(guid))
return; return;
uint32 accountId = 0; uint32 accountId = 0;
@ -500,39 +500,39 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
{ {
WorldPacket data(SMSG_CHAR_DELETE, 1); WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_FAILED_GUILD_LEADER; data << (uint8)CHAR_DELETE_FAILED_GUILD_LEADER;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
// is arena team captain // is arena team captain
if(sObjectMgr.GetArenaTeamByCaptain(guid)) if (sObjectMgr.GetArenaTeamByCaptain(guid))
{ {
WorldPacket data(SMSG_CHAR_DELETE, 1); WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_FAILED_ARENA_CAPTAIN; data << (uint8)CHAR_DELETE_FAILED_ARENA_CAPTAIN;
SendPacket( &data ); SendPacket(&data);
return; return;
} }
uint32 lowguid = guid.GetCounter(); uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT account,name FROM characters WHERE guid='%u'", lowguid); QueryResult* result = CharacterDatabase.PQuery("SELECT account,name FROM characters WHERE guid='%u'", lowguid);
if(result) if (result)
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
accountId = fields[0].GetUInt32(); accountId = fields[0].GetUInt32();
name = fields[1].GetCppString(); name = fields[1].GetCppString();
delete result; delete result;
} }
// prevent deleting other players' characters using cheating tools // prevent deleting other players' characters using cheating tools
if(accountId != GetAccountId()) if (accountId != GetAccountId())
return; return;
std::string IP_str = GetRemoteAddress(); std::string IP_str = GetRemoteAddress();
BASIC_LOG("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid); BASIC_LOG("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid);
sLog.outChar("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid); sLog.outChar("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid);
if(sLog.IsOutCharDump()) // optimize GetPlayerDump call if (sLog.IsOutCharDump()) // optimize GetPlayerDump call
{ {
std::string dump = PlayerDumpWriter().GetDump(lowguid); std::string dump = PlayerDumpWriter().GetDump(lowguid);
sLog.outCharDump(dump.c_str(), GetAccountId(), lowguid, name.c_str()); sLog.outCharDump(dump.c_str(), GetAccountId(), lowguid, name.c_str());
@ -542,15 +542,15 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
WorldPacket data(SMSG_CHAR_DELETE, 1); WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_SUCCESS; data << (uint8)CHAR_DELETE_SUCCESS;
SendPacket( &data ); SendPacket(&data);
} }
void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data ) void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recv_data)
{ {
ObjectGuid playerGuid; ObjectGuid playerGuid;
recv_data >> playerGuid; recv_data >> playerGuid;
if(PlayerLoading() || GetPlayer() != NULL) if (PlayerLoading() || GetPlayer() != NULL)
{ {
sLog.outError("Player tryes to login again, AccountId = %d", GetAccountId()); sLog.outError("Player tryes to login again, AccountId = %d", GetAccountId());
return; return;
@ -558,9 +558,9 @@ void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
m_playerLoading = true; m_playerLoading = true;
DEBUG_LOG( "WORLD: Recvd Player Logon Message" ); DEBUG_LOG("WORLD: Recvd Player Logon Message");
LoginQueryHolder *holder = new LoginQueryHolder(GetAccountId(), playerGuid); LoginQueryHolder* holder = new LoginQueryHolder(GetAccountId(), playerGuid);
if (!holder->Initialize()) if (!holder->Initialize())
{ {
delete holder; // delete all unprocessed queries delete holder; // delete all unprocessed queries
@ -571,15 +571,15 @@ void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
CharacterDatabase.DelayQueryHolder(&chrHandler, &CharacterHandler::HandlePlayerLoginCallback, holder); CharacterDatabase.DelayQueryHolder(&chrHandler, &CharacterHandler::HandlePlayerLoginCallback, holder);
} }
void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
{ {
ObjectGuid playerGuid = holder->GetGuid(); ObjectGuid playerGuid = holder->GetGuid();
Player *pCurrChar = new Player(this); Player* pCurrChar = new Player(this);
pCurrChar->GetMotionMaster()->Initialize(); pCurrChar->GetMotionMaster()->Initialize();
// "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools) // "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
if(!pCurrChar->LoadFromDB(playerGuid, holder)) if (!pCurrChar->LoadFromDB(playerGuid, holder))
{ {
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
delete pCurrChar; // delete it manually delete pCurrChar; // delete it manually
@ -592,7 +592,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
pCurrChar->SendDungeonDifficulty(false); pCurrChar->SendDungeonDifficulty(false);
WorldPacket data( SMSG_LOGIN_VERIFY_WORLD, 20 ); WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
data << pCurrChar->GetMapId(); data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX(); data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY(); data << pCurrChar->GetPositionY();
@ -619,7 +619,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
std::string::size_type pos, nextpos; std::string::size_type pos, nextpos;
pos = 0; pos = 0;
while ( (nextpos= str_motd.find('@',pos)) != std::string::npos ) while ((nextpos= str_motd.find('@',pos)) != std::string::npos)
{ {
if (nextpos != pos) if (nextpos != pos)
{ {
@ -637,37 +637,37 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
data.put(0, linecount); data.put(0, linecount);
SendPacket( &data ); SendPacket(&data);
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" ); DEBUG_LOG("WORLD: Sent motd (SMSG_MOTD)");
} }
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow()); //QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD); QueryResult* resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
if(resultGuild) if (resultGuild)
{ {
Field *fields = resultGuild->Fetch(); Field* fields = resultGuild->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32()); pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32()); pCurrChar->SetRank(fields[1].GetUInt32());
delete resultGuild; delete resultGuild;
} }
else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about nonexistent membership else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about nonexistent membership
{ {
pCurrChar->SetInGuild(0); pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0); pCurrChar->SetRank(0);
} }
if(pCurrChar->GetGuildId() != 0) if (pCurrChar->GetGuildId() != 0)
{ {
Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId()); Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId());
if(guild) if (guild)
{ {
data.Initialize(SMSG_GUILD_EVENT, (1+1+guild->GetMOTD().size()+1)); data.Initialize(SMSG_GUILD_EVENT, (1+1+guild->GetMOTD().size()+1));
data << uint8(GE_MOTD); data << uint8(GE_MOTD);
data << uint8(1); data << uint8(1);
data << guild->GetMOTD(); data << guild->GetMOTD();
SendPacket(&data); SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" ); DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)");
guild->DisplayGuildBankTabsInfo(this); guild->DisplayGuildBankTabsInfo(this);
@ -689,11 +689,11 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
pCurrChar->SendInitialPacketsBeforeAddToMap(); pCurrChar->SendInitialPacketsBeforeAddToMap();
//Show cinematic at the first time that player login //Show cinematic at the first time that player login
if( !pCurrChar->getCinematic() ) if (!pCurrChar->getCinematic())
{ {
pCurrChar->setCinematic(1); pCurrChar->setCinematic(1);
if(ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass())) if (ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass()))
{ {
if (cEntry->CinematicSequence) if (cEntry->CinematicSequence)
pCurrChar->SendCinematicStart(cEntry->CinematicSequence); pCurrChar->SendCinematicStart(cEntry->CinematicSequence);
@ -706,7 +706,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
{ {
// normal delayed teleport protection not applied (and this correct) for this case (Player object just created) // normal delayed teleport protection not applied (and this correct) for this case (Player object just created)
AreaTrigger const* at = sObjectMgr.GetGoBackTrigger(pCurrChar->GetMapId()); AreaTrigger const* at = sObjectMgr.GetGoBackTrigger(pCurrChar->GetMapId());
if(at) if (at)
pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation()); pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation());
else else
pCurrChar->TeleportToHomebind(); pCurrChar->TeleportToHomebind();
@ -726,10 +726,10 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
stmt = LoginDatabase.CreateStatement(updAccount, "UPDATE account SET active_realm_id = ? WHERE id = ?"); stmt = LoginDatabase.CreateStatement(updAccount, "UPDATE account SET active_realm_id = ? WHERE id = ?");
stmt.PExecute(realmID, GetAccountId()); stmt.PExecute(realmID, GetAccountId());
pCurrChar->SetInGameTime( WorldTimer::getMSTime() ); pCurrChar->SetInGameTime(WorldTimer::getMSTime());
// announce group about member online (must be after add to player list to receive announce to self) // announce group about member online (must be after add to player list to receive announce to self)
if (Group *group = pCurrChar->GetGroup()) if (Group* group = pCurrChar->GetGroup())
group->SendUpdate(); group->SendUpdate();
// friend status // friend status
@ -742,7 +742,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
if (pCurrChar->m_deathState != ALIVE) if (pCurrChar->m_deathState != ALIVE)
{ {
// not blizz like, we must correctly save and load player instead... // not blizz like, we must correctly save and load player instead...
if(pCurrChar->getRace() == RACE_NIGHTELF) if (pCurrChar->getRace() == RACE_NIGHTELF)
pCurrChar->CastSpell(pCurrChar, 20584, true); // auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) pCurrChar->CastSpell(pCurrChar, 20584, true); // auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form)
pCurrChar->CastSpell(pCurrChar, 8326, true); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) pCurrChar->CastSpell(pCurrChar, 8326, true); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?)
@ -752,27 +752,27 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
pCurrChar->ContinueTaxiFlight(); pCurrChar->ContinueTaxiFlight();
// reset for all pets before pet loading // reset for all pets before pet loading
if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
Pet::resetTalentsForAllPetsOf(pCurrChar); Pet::resetTalentsForAllPetsOf(pCurrChar);
// Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned) // Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned)
pCurrChar->LoadPet(); pCurrChar->LoadPet();
// Set FFA PvP for non GM in non-rest mode // Set FFA PvP for non GM in non-rest mode
if(sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING) ) if (sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING))
pCurrChar->SetFFAPvP(true); pCurrChar->SetFFAPvP(true);
if(pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
pCurrChar->SetContestedPvP(); pCurrChar->SetContestedPvP();
// Apply at_login requests // Apply at_login requests
if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
{ {
pCurrChar->resetSpells(); pCurrChar->resetSpells();
SendNotification(LANG_RESET_SPELLS); SendNotification(LANG_RESET_SPELLS);
} }
if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
{ {
pCurrChar->resetTalents(true,true); pCurrChar->resetTalents(true,true);
pCurrChar->SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state pCurrChar->SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state
@ -804,7 +804,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid: %u)", sLog.outChar("Account: %d (IP: %s) Login Character:[%s] (guid: %u)",
GetAccountId(), IP_str.c_str(), pCurrChar->GetName(), pCurrChar->GetGUIDLow()); GetAccountId(), IP_str.c_str(), pCurrChar->GetName(), pCurrChar->GetGUIDLow());
if(!pCurrChar->IsStandState() && !pCurrChar->hasUnitState(UNIT_STAT_STUNNED)) if (!pCurrChar->IsStandState() && !pCurrChar->hasUnitState(UNIT_STAT_STUNNED))
pCurrChar->SetStandState(UNIT_STAND_STATE_STAND); pCurrChar->SetStandState(UNIT_STAND_STATE_STAND);
m_playerLoading = false; m_playerLoading = false;
@ -815,9 +815,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
delete holder; delete holder;
} }
void WorldSession::HandleSetFactionAtWarOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetFactionAtWarOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG( "WORLD: Received CMSG_SET_FACTION_ATWAR" ); DEBUG_LOG("WORLD: Received CMSG_SET_FACTION_ATWAR");
uint32 repListID; uint32 repListID;
uint8 flag; uint8 flag;
@ -828,7 +828,7 @@ void WorldSession::HandleSetFactionAtWarOpcode( WorldPacket & recv_data )
GetPlayer()->GetReputationMgr().SetAtWar(repListID, flag); GetPlayer()->GetReputationMgr().SetAtWar(repListID, flag);
} }
void WorldSession::HandleTutorialFlagOpcode( WorldPacket & recv_data ) void WorldSession::HandleTutorialFlagOpcode(WorldPacket& recv_data)
{ {
uint32 iFlag; uint32 iFlag;
recv_data >> iFlag; recv_data >> iFlag;
@ -841,26 +841,26 @@ void WorldSession::HandleTutorialFlagOpcode( WorldPacket & recv_data )
} }
uint32 rInt = (iFlag % 32); uint32 rInt = (iFlag % 32);
uint32 tutflag = GetTutorialInt( wInt ); uint32 tutflag = GetTutorialInt(wInt);
tutflag |= (1 << rInt); tutflag |= (1 << rInt);
SetTutorialInt( wInt, tutflag ); SetTutorialInt(wInt, tutflag);
//DEBUG_LOG("Received Tutorial Flag Set {%u}.", iFlag); //DEBUG_LOG("Received Tutorial Flag Set {%u}.", iFlag);
} }
void WorldSession::HandleTutorialClearOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleTutorialClearOpcode(WorldPacket& /*recv_data*/)
{ {
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
SetTutorialInt( i, 0xFFFFFFFF ); SetTutorialInt(i, 0xFFFFFFFF);
} }
void WorldSession::HandleTutorialResetOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleTutorialResetOpcode(WorldPacket& /*recv_data*/)
{ {
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
SetTutorialInt( i, 0x00000000 ); SetTutorialInt(i, 0x00000000);
} }
void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data) void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received CMSG_SET_WATCHED_FACTION"); DEBUG_LOG("WORLD: Received CMSG_SET_WATCHED_FACTION");
int32 repId; int32 repId;
@ -868,7 +868,7 @@ void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data)
GetPlayer()->SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, repId); GetPlayer()->SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, repId);
} }
void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data) void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received CMSG_SET_FACTION_INACTIVE"); DEBUG_LOG("WORLD: Received CMSG_SET_FACTION_INACTIVE");
uint32 replistid; uint32 replistid;
@ -878,13 +878,13 @@ void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data)
_player->GetReputationMgr().SetInactive(replistid, inactive); _player->GetReputationMgr().SetInactive(replistid, inactive);
} }
void WorldSession::HandleShowingHelmOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleShowingHelmOpcode(WorldPacket& /*recv_data*/)
{ {
DEBUG_LOG("CMSG_SHOWING_HELM for %s", _player->GetName()); DEBUG_LOG("CMSG_SHOWING_HELM for %s", _player->GetName());
_player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM); _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);
} }
void WorldSession::HandleShowingCloakOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleShowingCloakOpcode(WorldPacket& /*recv_data*/)
{ {
DEBUG_LOG("CMSG_SHOWING_CLOAK for %s", _player->GetName()); DEBUG_LOG("CMSG_SHOWING_CLOAK for %s", _player->GetName());
_player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK); _player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK);
@ -903,7 +903,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
{ {
WorldPacket data(SMSG_CHAR_RENAME, 1); WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(CHAR_NAME_NO_NAME); data << uint8(CHAR_NAME_NO_NAME);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -912,7 +912,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
{ {
WorldPacket data(SMSG_CHAR_RENAME, 1); WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(res); data << uint8(res);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -921,7 +921,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
{ {
WorldPacket data(SMSG_CHAR_RENAME, 1); WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(CHAR_NAME_RESERVED); data << uint8(CHAR_NAME_RESERVED);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -937,12 +937,12 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
); );
} }
void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uint32 accountId, std::string newname) void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult* result, uint32 accountId, std::string newname)
{ {
WorldSession * session = sWorld.FindSession(accountId); WorldSession* session = sWorld.FindSession(accountId);
if(!session) if (!session)
{ {
if(result) delete result; if (result) delete result;
return; return;
} }
@ -950,7 +950,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin
{ {
WorldPacket data(SMSG_CHAR_RENAME, 1); WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(CHAR_CREATE_ERROR); data << uint8(CHAR_CREATE_ERROR);
session->SendPacket( &data ); session->SendPacket(&data);
return; return;
} }
@ -982,7 +982,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
// not accept declined names for unsupported languages // not accept declined names for unsupported languages
std::string name; std::string name;
if(!sObjectMgr.GetPlayerNameByGUID(guid, name)) if (!sObjectMgr.GetPlayerNameByGUID(guid, name))
{ {
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1); data << uint32(1);
@ -992,7 +992,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
} }
std::wstring wname; std::wstring wname;
if(!Utf8toWStr(name, wname)) if (!Utf8toWStr(name, wname))
{ {
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1); data << uint32(1);
@ -1001,7 +1001,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
return; return;
} }
if(!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using if (!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using
{ {
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1); data << uint32(1);
@ -1015,7 +1015,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
recv_data >> name2; recv_data >> name2;
if(name2 != name) // character have different name if (name2 != name) // character have different name
{ {
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1); data << uint32(1);
@ -1024,10 +1024,10 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
return; return;
} }
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{ {
recv_data >> declinedname.name[i]; recv_data >> declinedname.name[i];
if(!normalizePlayerName(declinedname.name[i])) if (!normalizePlayerName(declinedname.name[i]))
{ {
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1); data << uint32(1);
@ -1037,7 +1037,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
} }
} }
if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname)) if (!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname))
{ {
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1); data << uint32(1);
@ -1046,7 +1046,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
return; return;
} }
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
CharacterDatabase.escape_string(declinedname.name[i]); CharacterDatabase.escape_string(declinedname.name[i]);
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
@ -1061,7 +1061,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleAlterAppearanceOpcode( WorldPacket & recv_data ) void WorldSession::HandleAlterAppearanceOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_ALTER_APPEARANCE"); DEBUG_LOG("CMSG_ALTER_APPEARANCE");
@ -1079,12 +1079,12 @@ void WorldSession::HandleAlterAppearanceOpcode( WorldPacket & recv_data )
BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair); BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair);
if(!bs_hair || bs_hair->type != 0 || bs_hair->race != _player->getRace() || bs_hair->gender != _player->getGender()) if (!bs_hair || bs_hair->type != 0 || bs_hair->race != _player->getRace() || bs_hair->gender != _player->getGender())
return; return;
BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(FacialHair); BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(FacialHair);
if(!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender()) if (!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender())
return; return;
uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, skinTone_id); uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, skinTone_id);
@ -1092,7 +1092,7 @@ void WorldSession::HandleAlterAppearanceOpcode( WorldPacket & recv_data )
// 0 - ok // 0 - ok
// 1,3 - not enough money // 1,3 - not enough money
// 2 - you have to seat on barber chair // 2 - you have to seat on barber chair
if(_player->GetMoney() < Cost) if (_player->GetMoney() < Cost)
{ {
WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4); WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4);
data << uint32(1); // no money data << uint32(1); // no money
@ -1120,18 +1120,18 @@ void WorldSession::HandleAlterAppearanceOpcode( WorldPacket & recv_data )
_player->SetStandState(0); // stand up _player->SetStandState(0); // stand up
} }
void WorldSession::HandleRemoveGlyphOpcode( WorldPacket & recv_data ) void WorldSession::HandleRemoveGlyphOpcode(WorldPacket& recv_data)
{ {
uint32 slot; uint32 slot;
recv_data >> slot; recv_data >> slot;
if(slot >= MAX_GLYPH_SLOT_INDEX) if (slot >= MAX_GLYPH_SLOT_INDEX)
{ {
DEBUG_LOG("Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot); DEBUG_LOG("Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot);
return; return;
} }
if(_player->GetGlyph(slot)) if (_player->GetGlyph(slot))
{ {
_player->ApplyGlyph(slot, false); _player->ApplyGlyph(slot, false);
_player->SetGlyph(slot, 0); _player->SetGlyph(slot, 0);
@ -1150,16 +1150,16 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
uint8 gender, skin, face, hairStyle, hairColor, facialHair; uint8 gender, skin, face, hairStyle, hairColor, facialHair;
recv_data >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face; recv_data >> gender >> skin >> hairColor >> hairStyle >> facialHair >> face;
QueryResult *result = CharacterDatabase.PQuery("SELECT at_login FROM characters WHERE guid ='%u'", guid.GetCounter()); QueryResult* result = CharacterDatabase.PQuery("SELECT at_login FROM characters WHERE guid ='%u'", guid.GetCounter());
if (!result) if (!result)
{ {
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(CHAR_CREATE_ERROR); data << uint8(CHAR_CREATE_ERROR);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 at_loginFlags = fields[0].GetUInt32(); uint32 at_loginFlags = fields[0].GetUInt32();
delete result; delete result;
@ -1167,7 +1167,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
{ {
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(CHAR_CREATE_ERROR); data << uint8(CHAR_CREATE_ERROR);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -1176,7 +1176,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
{ {
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(CHAR_NAME_NO_NAME); data << uint8(CHAR_NAME_NO_NAME);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -1185,7 +1185,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
{ {
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(res); data << uint8(res);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -1194,7 +1194,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
{ {
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(CHAR_NAME_RESERVED); data << uint8(CHAR_NAME_RESERVED);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -1229,7 +1229,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data) void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_EQUIPMENT_SET_SAVE"); DEBUG_LOG("CMSG_EQUIPMENT_SET_SAVE");
@ -1243,7 +1243,7 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
recv_data >> name; recv_data >> name;
recv_data >> iconName; recv_data >> iconName;
if(index >= MAX_EQUIPMENT_SET_INDEX) // client set slots amount if (index >= MAX_EQUIPMENT_SET_INDEX) // client set slots amount
return; return;
EquipmentSet eqSet; EquipmentSet eqSet;
@ -1253,7 +1253,7 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
eqSet.IconName = iconName; eqSet.IconName = iconName;
eqSet.state = EQUIPMENT_SET_NEW; eqSet.state = EQUIPMENT_SET_NEW;
for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
{ {
ObjectGuid itemGuid; ObjectGuid itemGuid;
@ -1267,12 +1267,12 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
continue; continue;
} }
Item *item = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); Item* item = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if(!item && itemGuid) // cheating check 1 if (!item && itemGuid) // cheating check 1
return; return;
if(item && item->GetObjectGuid() != itemGuid) // cheating check 2 if (item && item->GetObjectGuid() != itemGuid) // cheating check 2
return; return;
eqSet.Items[i] = itemGuid.GetCounter(); eqSet.Items[i] = itemGuid.GetCounter();
@ -1281,7 +1281,7 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
_player->SetEquipmentSet(index, eqSet); _player->SetEquipmentSet(index, eqSet);
} }
void WorldSession::HandleEquipmentSetDeleteOpcode(WorldPacket &recv_data) void WorldSession::HandleEquipmentSetDeleteOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_EQUIPMENT_SET_DELETE"); DEBUG_LOG("CMSG_EQUIPMENT_SET_DELETE");
@ -1292,12 +1292,12 @@ void WorldSession::HandleEquipmentSetDeleteOpcode(WorldPacket &recv_data)
_player->DeleteEquipmentSet(setGuid.GetRawValue()); _player->DeleteEquipmentSet(setGuid.GetRawValue());
} }
void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket &recv_data) void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("CMSG_EQUIPMENT_SET_USE"); DEBUG_LOG("CMSG_EQUIPMENT_SET_USE");
recv_data.hexlike(); recv_data.hexlike();
for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
{ {
ObjectGuid itemGuid; ObjectGuid itemGuid;
uint8 srcbag, srcslot; uint8 srcbag, srcslot;
@ -1311,22 +1311,22 @@ void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket &recv_data)
if (itemGuid.GetRawValue() == 1) if (itemGuid.GetRawValue() == 1)
continue; continue;
Item *item = _player->GetItemByGuid(itemGuid); Item* item = _player->GetItemByGuid(itemGuid);
uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8); uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);
if(!item) if (!item)
{ {
Item *uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if(!uItem) if (!uItem)
continue; continue;
ItemPosCountVec sDest; ItemPosCountVec sDest;
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, sDest, uItem, false ); InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sDest, uItem, false);
if(msg == EQUIP_ERR_OK) if (msg == EQUIP_ERR_OK)
{ {
_player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true); _player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
_player->StoreItem( sDest, uItem, true ); _player->StoreItem(sDest, uItem, true);
} }
else else
_player->SendEquipError(msg, uItem, NULL); _player->SendEquipError(msg, uItem, NULL);
@ -1334,7 +1334,7 @@ void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket &recv_data)
continue; continue;
} }
if(item->GetPos() == dstpos) if (item->GetPos() == dstpos)
continue; continue;
_player->SwapItem(item->GetPos(), dstpos); _player->SwapItem(item->GetPos(), dstpos);

View file

@ -66,7 +66,7 @@
bool ChatHandler::load_command_table = true; bool ChatHandler::load_command_table = true;
ChatCommand * ChatHandler::getCommandTable() ChatCommand* ChatHandler::getCommandTable()
{ {
static ChatCommand accountSetCommandTable[] = static ChatCommand accountSetCommandTable[] =
{ {
@ -829,24 +829,25 @@ ChatCommand * ChatHandler::getCommandTable()
{ NULL, 0, false, NULL, "", NULL } { NULL, 0, false, NULL, "", NULL }
}; };
if(load_command_table) if (load_command_table)
{ {
load_command_table = false; load_command_table = false;
// check hardcoded part integrity // check hardcoded part integrity
CheckIntegrity(commandTable, NULL); CheckIntegrity(commandTable, NULL);
QueryResult *result = WorldDatabase.Query("SELECT name,security,help FROM command"); QueryResult* result = WorldDatabase.Query("SELECT name,security,help FROM command");
if (result) if (result)
{ {
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
std::string name = fields[0].GetCppString(); std::string name = fields[0].GetCppString();
SetDataForCommandInTable(commandTable, name.c_str(), fields[1].GetUInt16(), fields[2].GetCppString()); SetDataForCommandInTable(commandTable, name.c_str(), fields[1].GetUInt16(), fields[2].GetCppString());
} while(result->NextRow()); }
while (result->NextRow());
delete result; delete result;
} }
} }
@ -860,12 +861,12 @@ ChatHandler::ChatHandler(Player* player) : m_session(player->GetSession()) {}
ChatHandler::~ChatHandler() {} ChatHandler::~ChatHandler() {}
const char *ChatHandler::GetMangosString(int32 entry) const const char* ChatHandler::GetMangosString(int32 entry) const
{ {
return m_session->GetMangosString(entry); return m_session->GetMangosString(entry);
} }
const char *ChatHandler::GetOnOffStr(bool value) const const char* ChatHandler::GetOnOffStr(bool value) const
{ {
return value ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF); return value ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF);
} }
@ -901,7 +902,7 @@ bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
else else
target_account = sObjectMgr.GetPlayerAccountIdByGUID(guid); target_account = sObjectMgr.GetPlayerAccountIdByGUID(guid);
if(!target_session && !target_account) if (!target_session && !target_account)
{ {
SendSysMessage(LANG_PLAYER_NOT_FOUND); SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -939,19 +940,19 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
bool ChatHandler::hasStringAbbr(const char* name, const char* part) bool ChatHandler::hasStringAbbr(const char* name, const char* part)
{ {
// non "" command // non "" command
if( *name ) if (*name)
{ {
// "" part from non-"" command // "" part from non-"" command
if( !*part ) if (!*part)
return false; return false;
for(;;) for (;;)
{ {
if( !*part ) if (!*part)
return true; return true;
else if( !*name ) else if (!*name)
return false; return false;
else if( tolower( *name ) != tolower( *part ) ) else if (tolower(*name) != tolower(*part))
return false; return false;
++name; ++part; ++name; ++part;
} }
@ -961,7 +962,7 @@ bool ChatHandler::hasStringAbbr(const char* name, const char* part)
return true; return true;
} }
void ChatHandler::SendSysMessage(const char *str) void ChatHandler::SendSysMessage(const char* str)
{ {
WorldPacket data; WorldPacket data;
@ -969,7 +970,7 @@ void ChatHandler::SendSysMessage(const char *str)
char* buf = mangos_strdup(str); char* buf = mangos_strdup(str);
char* pos = buf; char* pos = buf;
while(char* line = LineFromMessage(pos)) while (char* line = LineFromMessage(pos))
{ {
FillSystemMessageData(&data, line); FillSystemMessageData(&data, line);
m_session->SendPacket(&data); m_session->SendPacket(&data);
@ -978,7 +979,7 @@ void ChatHandler::SendSysMessage(const char *str)
delete [] buf; delete [] buf;
} }
void ChatHandler::SendGlobalSysMessage(const char *str) void ChatHandler::SendGlobalSysMessage(const char* str)
{ {
// Chat output // Chat output
WorldPacket data; WorldPacket data;
@ -987,7 +988,7 @@ void ChatHandler::SendGlobalSysMessage(const char *str)
char* buf = mangos_strdup(str); char* buf = mangos_strdup(str);
char* pos = buf; char* pos = buf;
while(char* line = LineFromMessage(pos)) while (char* line = LineFromMessage(pos))
{ {
FillSystemMessageData(&data, line); FillSystemMessageData(&data, line);
sWorld.SendGlobalMessage(&data); sWorld.SendGlobalMessage(&data);
@ -1003,7 +1004,7 @@ void ChatHandler::SendSysMessage(int32 entry)
void ChatHandler::PSendSysMessage(int32 entry, ...) void ChatHandler::PSendSysMessage(int32 entry, ...)
{ {
const char *format = GetMangosString(entry); const char* format = GetMangosString(entry);
va_list ap; va_list ap;
char str [2048]; char str [2048];
va_start(ap, entry); va_start(ap, entry);
@ -1012,7 +1013,7 @@ void ChatHandler::PSendSysMessage(int32 entry, ...)
SendSysMessage(str); SendSysMessage(str);
} }
void ChatHandler::PSendSysMessage(const char *format, ...) void ChatHandler::PSendSysMessage(const char* format, ...)
{ {
va_list ap; va_list ap;
char str [2048]; char str [2048];
@ -1022,9 +1023,9 @@ void ChatHandler::PSendSysMessage(const char *format, ...)
SendSysMessage(str); SendSysMessage(str);
} }
void ChatHandler::CheckIntegrity( ChatCommand *table, ChatCommand *parentCommand ) void ChatHandler::CheckIntegrity(ChatCommand* table, ChatCommand* parentCommand)
{ {
for(uint32 i = 0; table[i].Name != NULL; ++i) for (uint32 i = 0; table[i].Name != NULL; ++i)
{ {
ChatCommand* command = &table[i]; ChatCommand* command = &table[i];
@ -1109,7 +1110,7 @@ ChatCommand const* ChatHandler::FindCommand(char const* text)
* parentCommand have parent of command in command arg or NULL * parentCommand have parent of command in command arg or NULL
* cmdNamePtr store command name that not found as it extracted from command line * cmdNamePtr store command name that not found as it extracted from command line
*/ */
ChatCommandSearchResult ChatHandler::FindCommand(ChatCommand* table, char const* &text, ChatCommand*& command, ChatCommand** parentCommand /*= NULL*/, std::string* cmdNamePtr /*= NULL*/, bool allAvailable /*= false*/, bool exactlyName /*= false*/) ChatCommandSearchResult ChatHandler::FindCommand(ChatCommand* table, char const*& text, ChatCommand*& command, ChatCommand** parentCommand /*= NULL*/, std::string* cmdNamePtr /*= NULL*/, bool allAvailable /*= false*/, bool exactlyName /*= false*/)
{ {
std::string cmd = ""; std::string cmd = "";
@ -1123,7 +1124,7 @@ ChatCommandSearchResult ChatHandler::FindCommand(ChatCommand* table, char const*
while (*text == ' ') ++text; while (*text == ' ') ++text;
// search first level command in table // search first level command in table
for(uint32 i = 0; table[i].Name != NULL; ++i) for (uint32 i = 0; table[i].Name != NULL; ++i)
{ {
if (exactlyName) if (exactlyName)
{ {
@ -1143,7 +1144,7 @@ ChatCommandSearchResult ChatHandler::FindCommand(ChatCommand* table, char const*
ChatCommand* parentSubcommand = NULL; ChatCommand* parentSubcommand = NULL;
ChatCommandSearchResult res = FindCommand(table[i].ChildCommands, text, command, &parentSubcommand, cmdNamePtr, allAvailable, exactlyName); ChatCommandSearchResult res = FindCommand(table[i].ChildCommands, text, command, &parentSubcommand, cmdNamePtr, allAvailable, exactlyName);
switch(res) switch (res)
{ {
case CHAT_COMMAND_OK: case CHAT_COMMAND_OK:
{ {
@ -1228,7 +1229,7 @@ void ChatHandler::ExecuteCommand(const char* text)
ChatCommandSearchResult res = FindCommand(getCommandTable(), text, command, &parentCommand); ChatCommandSearchResult res = FindCommand(getCommandTable(), text, command, &parentCommand);
switch(res) switch (res)
{ {
case CHAT_COMMAND_OK: case CHAT_COMMAND_OK:
{ {
@ -1282,7 +1283,7 @@ void ChatHandler::ExecuteCommand(const char* text)
* *
* All problems found while command search and updated output as to DB errors log * All problems found while command search and updated output as to DB errors log
*/ */
bool ChatHandler::SetDataForCommandInTable(ChatCommand *commandTable, const char* text, uint32 security, std::string const& help) bool ChatHandler::SetDataForCommandInTable(ChatCommand* commandTable, const char* text, uint32 security, std::string const& help)
{ {
std::string fullcommand = text; // original `text` can't be used. It content destroyed in command code processing. std::string fullcommand = text; // original `text` can't be used. It content destroyed in command code processing.
@ -1291,7 +1292,7 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand *commandTable, const char
ChatCommandSearchResult res = FindCommand(commandTable, text, command, NULL, &cmdName, true, true); ChatCommandSearchResult res = FindCommand(commandTable, text, command, NULL, &cmdName, true, true);
switch(res) switch (res)
{ {
case CHAT_COMMAND_OK: case CHAT_COMMAND_OK:
{ {
@ -1333,7 +1334,7 @@ bool ChatHandler::ParseCommands(const char* text)
/// chat case (.command or !command format) /// chat case (.command or !command format)
if (m_session) if (m_session)
{ {
if(text[0] != '!' && text[0] != '.') if (text[0] != '!' && text[0] != '.')
return false; return false;
/// ignore single . and ! in line /// ignore single . and ! in line
@ -1354,7 +1355,7 @@ bool ChatHandler::ParseCommands(const char* text)
return true; return true;
} }
bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd) bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd)
{ {
std::string list; std::string list;
for (uint32 i = 0; table[i].Name != NULL; ++i) for (uint32 i = 0; table[i].Name != NULL; ++i)
@ -1390,7 +1391,7 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd)
return true; return true;
} }
bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd) bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd)
{ {
char const* oldCmd = cmd; char const* oldCmd = cmd;
ChatCommand* command = NULL; ChatCommand* command = NULL;
@ -1401,7 +1402,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
ChatCommandSearchResult res = FindCommand(table, cmd, command, &parentCommand); ChatCommandSearchResult res = FindCommand(table, cmd, command, &parentCommand);
switch(res) switch (res)
{ {
case CHAT_COMMAND_OK: case CHAT_COMMAND_OK:
{ {
@ -1443,22 +1444,22 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, const char* cmd)
bool ChatHandler::isValidChatMessage(const char* message) bool ChatHandler::isValidChatMessage(const char* message)
{ {
/* /*
valid examples: valid examples:
|cffa335ee|Hitem:812:0:0:0:0:0:0:0:70|h[Glowing Brightwood Staff]|h|r |cffa335ee|Hitem:812:0:0:0:0:0:0:0:70|h[Glowing Brightwood Staff]|h|r
|cff808080|Hquest:2278:47|h[The Platinum Discs]|h|r |cff808080|Hquest:2278:47|h[The Platinum Discs]|h|r
|cffffd000|Htrade:4037:1:150:1:6AAAAAAAAAAAAAAAAAAAAAAOAADAAAAAAAAAAAAAAAAIAAAAAAAAA|h[Engineering]|h|r |cffffd000|Htrade:4037:1:150:1:6AAAAAAAAAAAAAAAAAAAAAAOAADAAAAAAAAAAAAAAAAIAAAAAAAAA|h[Engineering]|h|r
|cff4e96f7|Htalent:2232:-1|h[Taste for Blood]|h|r |cff4e96f7|Htalent:2232:-1|h[Taste for Blood]|h|r
|cff71d5ff|Hspell:21563|h[Command]|h|r |cff71d5ff|Hspell:21563|h[Command]|h|r
|cffffd000|Henchant:3919|h[Engineering: Rough Dynamite]|h|r |cffffd000|Henchant:3919|h[Engineering: Rough Dynamite]|h|r
|cffffff00|Hachievement:546:0000000000000001:0:0:0:-1:0:0:0:0|h[Safe Deposit]|h|r |cffffff00|Hachievement:546:0000000000000001:0:0:0:-1:0:0:0:0|h[Safe Deposit]|h|r
|cff66bbff|Hglyph:21:762|h[Glyph of Bladestorm]|h|r |cff66bbff|Hglyph:21:762|h[Glyph of Bladestorm]|h|r
| will be escaped to || | will be escaped to ||
*/ */
if(strlen(message) > 255) if (strlen(message) > 255)
return false; return false;
const char validSequence[6] = "cHhhr"; const char validSequence[6] = "cHhhr";
@ -1469,31 +1470,31 @@ valid examples:
{ {
const std::string validCommands = "cHhr|"; const std::string validCommands = "cHhr|";
while(*message) while (*message)
{ {
// find next pipe command // find next pipe command
message = strchr(message, '|'); message = strchr(message, '|');
if(!message) if (!message)
return true; return true;
++message; ++message;
char commandChar = *message; char commandChar = *message;
if(validCommands.find(commandChar) == std::string::npos) if (validCommands.find(commandChar) == std::string::npos)
return false; return false;
++message; ++message;
// validate sequence // validate sequence
if(sWorld.getConfig(CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_SEVERITY) == 2) if (sWorld.getConfig(CONFIG_UINT32_CHAT_STRICT_LINK_CHECKING_SEVERITY) == 2)
{ {
if(commandChar == *validSequenceIterator) if (commandChar == *validSequenceIterator)
{ {
if (validSequenceIterator == validSequence+4) if (validSequenceIterator == validSequence+4)
validSequenceIterator = validSequence; validSequenceIterator = validSequence;
else else
++validSequenceIterator; ++validSequenceIterator;
} }
else if(commandChar != '|') else if (commandChar != '|')
return false; return false;
} }
} }
@ -1507,12 +1508,12 @@ valid examples:
ItemPrototype const* linkedItem = NULL; ItemPrototype const* linkedItem = NULL;
Quest const* linkedQuest = NULL; Quest const* linkedQuest = NULL;
SpellEntry const *linkedSpell= NULL; SpellEntry const* linkedSpell= NULL;
AchievementEntry const* linkedAchievement = NULL; AchievementEntry const* linkedAchievement = NULL;
ItemRandomPropertiesEntry const* itemProperty = NULL; ItemRandomPropertiesEntry const* itemProperty = NULL;
ItemRandomSuffixEntry const* itemSuffix = NULL; ItemRandomSuffixEntry const* itemSuffix = NULL;
while(!reader.eof()) while (!reader.eof())
{ {
if (validSequence == validSequenceIterator) if (validSequence == validSequenceIterator)
{ {
@ -1525,14 +1526,14 @@ valid examples:
reader.ignore(255, '|'); reader.ignore(255, '|');
} }
else if(reader.get() != '|') else if (reader.get() != '|')
{ {
DEBUG_LOG("ChatHandler::isValidChatMessage sequence aborted unexpectedly"); DEBUG_LOG("ChatHandler::isValidChatMessage sequence aborted unexpectedly");
return false; return false;
} }
// pipe has always to be followed by at least one char // pipe has always to be followed by at least one char
if ( reader.peek() == '\0') if (reader.peek() == '\0')
{ {
DEBUG_LOG("ChatHandler::isValidChatMessage pipe followed by \\0"); DEBUG_LOG("ChatHandler::isValidChatMessage pipe followed by \\0");
return false; return false;
@ -1548,7 +1549,7 @@ valid examples:
// | in normal messages is escaped by || // | in normal messages is escaped by ||
if (commandChar != '|') if (commandChar != '|')
{ {
if(commandChar == *validSequenceIterator) if (commandChar == *validSequenceIterator)
{ {
if (validSequenceIterator == validSequence+4) if (validSequenceIterator == validSequence+4)
validSequenceIterator = validSequence; validSequenceIterator = validSequence;
@ -1561,7 +1562,7 @@ valid examples:
return false; return false;
} }
} }
else if(validSequence != validSequenceIterator) else if (validSequence != validSequenceIterator)
{ {
// no escaped pipes in sequences // no escaped pipes in sequences
DEBUG_LOG("ChatHandler::isValidChatMessage got escaped pipe in sequence"); DEBUG_LOG("ChatHandler::isValidChatMessage got escaped pipe in sequence");
@ -1573,7 +1574,7 @@ valid examples:
case 'c': case 'c':
color = 0; color = 0;
// validate color, expect 8 hex chars // validate color, expect 8 hex chars
for(int i=0; i<8; i++) for (int i=0; i<8; i++)
{ {
char c; char c;
reader >> c; reader >> c;
@ -1613,7 +1614,7 @@ valid examples:
return false; return false;
linkedItem = ObjectMgr::GetItemPrototype(atoi(buffer)); linkedItem = ObjectMgr::GetItemPrototype(atoi(buffer));
if(!linkedItem) if (!linkedItem)
{ {
DEBUG_LOG("ChatHandler::isValidChatMessage got invalid itemID %u in |item command", atoi(buffer)); DEBUG_LOG("ChatHandler::isValidChatMessage got invalid itemID %u in |item command", atoi(buffer));
return false; return false;
@ -1634,17 +1635,18 @@ valid examples:
int32 propertyId = 0; int32 propertyId = 0;
bool negativeNumber = false; bool negativeNumber = false;
char c; char c;
for(uint8 i=0; i < randomPropertyPosition; ++i) for (uint8 i=0; i < randomPropertyPosition; ++i)
{ {
propertyId = 0; propertyId = 0;
negativeNumber = false; negativeNumber = false;
while((c = reader.get()) != ':') while ((c = reader.get()) != ':')
{ {
if (c >='0' && c<='9') if (c >='0' && c<='9')
{ {
propertyId*=10; propertyId*=10;
propertyId += c-'0'; propertyId += c-'0';
} else if(c == '-') }
else if (c == '-')
negativeNumber = true; negativeNumber = true;
else else
return false; return false;
@ -1679,7 +1681,7 @@ valid examples:
uint32 questid= 0; uint32 questid= 0;
// read questid // read questid
char c = reader.peek(); char c = reader.peek();
while(c >='0' && c<='9') while (c >='0' && c<='9')
{ {
reader.ignore(1); reader.ignore(1);
questid *= 10; questid *= 10;
@ -1705,7 +1707,7 @@ valid examples:
c = reader.peek(); c = reader.peek();
// level // level
uint32 questlevel = 0; uint32 questlevel = 0;
while(c >='0' && c<='9') while (c >='0' && c<='9')
{ {
reader.ignore(1); reader.ignore(1);
questlevel *= 10; questlevel *= 10;
@ -1725,9 +1727,9 @@ valid examples:
return false; return false;
} }
} }
else if(strcmp(buffer, "trade") == 0) else if (strcmp(buffer, "trade") == 0)
{ {
if(color != CHAT_LINK_COLOR_TRADE) if (color != CHAT_LINK_COLOR_TRADE)
return false; return false;
// read spell entry // read spell entry
@ -1741,16 +1743,16 @@ valid examples:
char c = reader.peek(); char c = reader.peek();
// base64 encoded stuff // base64 encoded stuff
while(c !='|' && c!='\0') while (c !='|' && c!='\0')
{ {
reader.ignore(1); reader.ignore(1);
c = reader.peek(); c = reader.peek();
} }
} }
else if(strcmp(buffer, "talent") == 0) else if (strcmp(buffer, "talent") == 0)
{ {
// talent links are always supposed to be blue // talent links are always supposed to be blue
if(color != CHAT_LINK_COLOR_TALENT) if (color != CHAT_LINK_COLOR_TALENT)
return false; return false;
// read talent entry // read talent entry
@ -1758,7 +1760,7 @@ valid examples:
if (reader.eof()) // : must be if (reader.eof()) // : must be
return false; return false;
TalentEntry const *talentInfo = sTalentStore.LookupEntry(atoi(buffer)); TalentEntry const* talentInfo = sTalentStore.LookupEntry(atoi(buffer));
if (!talentInfo) if (!talentInfo)
return false; return false;
@ -1768,13 +1770,13 @@ valid examples:
char c = reader.peek(); char c = reader.peek();
// skillpoints? whatever, drop it // skillpoints? whatever, drop it
while(c !='|' && c!='\0') while (c !='|' && c!='\0')
{ {
reader.ignore(1); reader.ignore(1);
c = reader.peek(); c = reader.peek();
} }
} }
else if(strcmp(buffer, "spell") == 0) else if (strcmp(buffer, "spell") == 0)
{ {
if (color != CHAT_LINK_COLOR_SPELL) if (color != CHAT_LINK_COLOR_SPELL)
return false; return false;
@ -1782,7 +1784,7 @@ valid examples:
uint32 spellid = 0; uint32 spellid = 0;
// read spell entry // read spell entry
char c = reader.peek(); char c = reader.peek();
while(c >='0' && c<='9') while (c >='0' && c<='9')
{ {
reader.ignore(1); reader.ignore(1);
spellid *= 10; spellid *= 10;
@ -1793,7 +1795,7 @@ valid examples:
if (!linkedSpell) if (!linkedSpell)
return false; return false;
} }
else if(strcmp(buffer, "enchant") == 0) else if (strcmp(buffer, "enchant") == 0)
{ {
if (color != CHAT_LINK_COLOR_ENCHANT) if (color != CHAT_LINK_COLOR_ENCHANT)
return false; return false;
@ -1801,7 +1803,7 @@ valid examples:
uint32 spellid = 0; uint32 spellid = 0;
// read spell entry // read spell entry
char c = reader.peek(); char c = reader.peek();
while(c >='0' && c<='9') while (c >='0' && c<='9')
{ {
reader.ignore(1); reader.ignore(1);
spellid *= 10; spellid *= 10;
@ -1812,7 +1814,7 @@ valid examples:
if (!linkedSpell) if (!linkedSpell)
return false; return false;
} }
else if(strcmp(buffer, "achievement") == 0) else if (strcmp(buffer, "achievement") == 0)
{ {
if (color != CHAT_LINK_COLOR_ACHIEVEMENT) if (color != CHAT_LINK_COLOR_ACHIEVEMENT)
return false; return false;
@ -1829,15 +1831,15 @@ valid examples:
char c = reader.peek(); char c = reader.peek();
// skip progress // skip progress
while(c !='|' && c != '\0') while (c !='|' && c != '\0')
{ {
reader.ignore(1); reader.ignore(1);
c = reader.peek(); c = reader.peek();
} }
} }
else if(strcmp(buffer, "glyph") == 0) else if (strcmp(buffer, "glyph") == 0)
{ {
if(color != CHAT_LINK_COLOR_GLYPH) if (color != CHAT_LINK_COLOR_GLYPH)
return false; return false;
// first id is slot, drop it // first id is slot, drop it
@ -1847,7 +1849,7 @@ valid examples:
uint32 glyphId = 0; uint32 glyphId = 0;
char c = reader.peek(); char c = reader.peek();
while(c>='0' && c <='9') while (c>='0' && c <='9')
{ {
glyphId *= 10; glyphId *= 10;
glyphId += c-'0'; glyphId += c-'0';
@ -1896,20 +1898,20 @@ valid examples:
return false; return false;
} }
SkillLineAbilityEntry const *skillInfo = bounds.first->second; SkillLineAbilityEntry const* skillInfo = bounds.first->second;
if (!skillInfo) if (!skillInfo)
{ {
return false; return false;
} }
SkillLineEntry const *skillLine = sSkillLineStore.LookupEntry(skillInfo->skillId); SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skillInfo->skillId);
if (!skillLine) if (!skillLine)
{ {
return false; return false;
} }
for(uint8 i=0; i < MAX_LOCALE; ++i) for (uint8 i=0; i < MAX_LOCALE; ++i)
{ {
uint32 skillLineNameLength = strlen(skillLine->name[i]); uint32 skillLineNameLength = strlen(skillLine->name[i]);
if (skillLineNameLength > 0 && strncmp(skillLine->name[i], buffer, skillLineNameLength) == 0) if (skillLineNameLength > 0 && strncmp(skillLine->name[i], buffer, skillLineNameLength) == 0)
@ -1922,7 +1924,7 @@ valid examples:
} }
} }
bool foundName = false; bool foundName = false;
for(uint8 i=0; i<MAX_LOCALE; ++i) for (uint8 i=0; i<MAX_LOCALE; ++i)
{ {
if (*linkedSpell->SpellName[i] && strcmp(linkedSpell->SpellName[i], buffer) == 0) if (*linkedSpell->SpellName[i] && strcmp(linkedSpell->SpellName[i], buffer) == 0)
{ {
@ -1937,7 +1939,7 @@ valid examples:
{ {
if (linkedQuest->GetTitle() != buffer) if (linkedQuest->GetTitle() != buffer)
{ {
QuestLocale const *ql = sObjectMgr.GetQuestLocale(linkedQuest->GetQuestId()); QuestLocale const* ql = sObjectMgr.GetQuestLocale(linkedQuest->GetQuestId());
if (!ql) if (!ql)
{ {
@ -1946,7 +1948,7 @@ valid examples:
} }
bool foundName = false; bool foundName = false;
for(uint8 i=0; i < ql->Title.size(); ++i) for (uint8 i=0; i < ql->Title.size(); ++i)
{ {
if (ql->Title[i] == buffer) if (ql->Title[i] == buffer)
{ {
@ -1961,7 +1963,7 @@ valid examples:
} }
} }
} }
else if(linkedItem) else if (linkedItem)
{ {
char* const* suffix = itemSuffix?itemSuffix->nameSuffix:(itemProperty?itemProperty->nameSuffix:NULL); char* const* suffix = itemSuffix?itemSuffix->nameSuffix:(itemProperty?itemProperty->nameSuffix:NULL);
@ -1974,10 +1976,10 @@ valid examples:
if (expectedName != buffer) if (expectedName != buffer)
{ {
ItemLocale const *il = sObjectMgr.GetItemLocale(linkedItem->ItemId); ItemLocale const* il = sObjectMgr.GetItemLocale(linkedItem->ItemId);
bool foundName = false; bool foundName = false;
for(uint8 i=LOCALE_koKR; i<MAX_LOCALE; ++i) for (uint8 i=LOCALE_koKR; i<MAX_LOCALE; ++i)
{ {
int8 dbIndex = sObjectMgr.GetIndexForLocale(LocaleConstant(i)); int8 dbIndex = sObjectMgr.GetIndexForLocale(LocaleConstant(i));
if (dbIndex == -1 || il == NULL || (size_t)dbIndex >= il->Name.size()) if (dbIndex == -1 || il == NULL || (size_t)dbIndex >= il->Name.size())
@ -1990,7 +1992,7 @@ valid examples:
expectedName += " "; expectedName += " ";
expectedName += suffix[i]; expectedName += suffix[i];
} }
if ( expectedName == buffer) if (expectedName == buffer)
{ {
foundName = true; foundName = true;
break; break;
@ -2006,7 +2008,7 @@ valid examples:
else if (linkedAchievement) else if (linkedAchievement)
{ {
bool foundName = false; bool foundName = false;
for(uint8 i=0; i<MAX_LOCALE; ++i) for (uint8 i=0; i<MAX_LOCALE; ++i)
{ {
if (*linkedAchievement->name[i] && strcmp(linkedAchievement->name[i], buffer) == 0) if (*linkedAchievement->name[i] && strcmp(linkedAchievement->name[i], buffer) == 0)
{ {
@ -2034,14 +2036,14 @@ valid examples:
} }
// check if every opened sequence was also closed properly // check if every opened sequence was also closed properly
if(validSequence != validSequenceIterator) if (validSequence != validSequenceIterator)
DEBUG_LOG("ChatHandler::isValidChatMessage EOF in active sequence"); DEBUG_LOG("ChatHandler::isValidChatMessage EOF in active sequence");
return validSequence == validSequenceIterator; return validSequence == validSequenceIterator;
} }
//Note: target_guid used only in CHAT_MSG_WHISPER_INFORM mode (in this case channelName ignored) //Note: target_guid used only in CHAT_MSG_WHISPER_INFORM mode (in this case channelName ignored)
void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uint8 type, uint32 language, const char *channelName, ObjectGuid targetGuid, const char *message, Unit *speaker) void ChatHandler::FillMessageData(WorldPacket* data, WorldSession* session, uint8 type, uint32 language, const char* channelName, ObjectGuid targetGuid, const char* message, Unit* speaker)
{ {
uint32 messageLength = (message ? strlen(message) : 0) + 1; uint32 messageLength = (message ? strlen(message) : 0) + 1;
@ -2052,7 +2054,7 @@ void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uin
else else
*data << uint32(LANG_UNIVERSAL); *data << uint32(LANG_UNIVERSAL);
switch(type) switch (type)
{ {
case CHAT_MSG_SAY: case CHAT_MSG_SAY:
case CHAT_MSG_PARTY: case CHAT_MSG_PARTY:
@ -2115,15 +2117,15 @@ void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uin
*data << ObjectGuid(targetGuid); *data << ObjectGuid(targetGuid);
*data << uint32(messageLength); *data << uint32(messageLength);
*data << message; *data << message;
if(session != 0 && type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_DND && type != CHAT_MSG_AFK) if (session != 0 && type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_DND && type != CHAT_MSG_AFK)
*data << uint8(session->GetPlayer()->GetChatTag()); *data << uint8(session->GetPlayer()->GetChatTag());
else else
*data << uint8(0); *data << uint8(0);
} }
Player * ChatHandler::getSelectedPlayer() Player* ChatHandler::getSelectedPlayer()
{ {
if(!m_session) if (!m_session)
return NULL; return NULL;
ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid(); ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid();
@ -2136,7 +2138,7 @@ Player * ChatHandler::getSelectedPlayer()
Unit* ChatHandler::getSelectedUnit() Unit* ChatHandler::getSelectedUnit()
{ {
if(!m_session) if (!m_session)
return NULL; return NULL;
ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid(); ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid();
@ -2150,7 +2152,7 @@ Unit* ChatHandler::getSelectedUnit()
Creature* ChatHandler::getSelectedCreature() Creature* ChatHandler::getSelectedCreature()
{ {
if(!m_session) if (!m_session)
return NULL; return NULL;
return m_session->GetPlayer()->GetMap()->GetAnyTypeCreature(m_session->GetPlayer()->GetSelectionGuid()); return m_session->GetPlayer()->GetMap()->GetAnyTypeCreature(m_session->GetPlayer()->GetSelectionGuid());
@ -2164,10 +2166,10 @@ Creature* ChatHandler::getSelectedCreature()
*/ */
void ChatHandler::SkipWhiteSpaces(char** args) void ChatHandler::SkipWhiteSpaces(char** args)
{ {
if(!*args) if (!*args)
return; return;
while(isWhiteSpace(**args)) while (isWhiteSpace(**args))
++(*args); ++(*args);
} }
@ -2180,7 +2182,7 @@ void ChatHandler::SkipWhiteSpaces(char** args)
*/ */
bool ChatHandler::ExtractInt32(char** args, int32& val) bool ChatHandler::ExtractInt32(char** args, int32& val)
{ {
if (!*args || !**args) if (!*args || !** args)
return false; return false;
char* tail = *args; char* tail = *args;
@ -2211,7 +2213,7 @@ bool ChatHandler::ExtractInt32(char** args, int32& val)
*/ */
bool ChatHandler::ExtractOptInt32(char** args, int32& val, int32 defVal) bool ChatHandler::ExtractOptInt32(char** args, int32& val, int32 defVal)
{ {
if (!*args || !**args) if (!*args || !** args)
{ {
val = defVal; val = defVal;
return true; return true;
@ -2230,7 +2232,7 @@ bool ChatHandler::ExtractOptInt32(char** args, int32& val, int32 defVal)
*/ */
bool ChatHandler::ExtractUInt32Base(char** args, uint32& val, uint32 base) bool ChatHandler::ExtractUInt32Base(char** args, uint32& val, uint32 base)
{ {
if (!*args || !**args) if (!*args || !** args)
return false; return false;
char* tail = *args; char* tail = *args;
@ -2263,7 +2265,7 @@ bool ChatHandler::ExtractUInt32Base(char** args, uint32& val, uint32 base)
*/ */
bool ChatHandler::ExtractOptUInt32(char** args, uint32& val, uint32 defVal) bool ChatHandler::ExtractOptUInt32(char** args, uint32& val, uint32 defVal)
{ {
if (!*args || !**args) if (!*args || !** args)
{ {
val = defVal; val = defVal;
return true; return true;
@ -2281,7 +2283,7 @@ bool ChatHandler::ExtractOptUInt32(char** args, uint32& val, uint32 defVal)
*/ */
bool ChatHandler::ExtractFloat(char** args, float& val) bool ChatHandler::ExtractFloat(char** args, float& val)
{ {
if (!*args || !**args) if (!*args || !** args)
return false; return false;
char* tail = *args; char* tail = *args;
@ -2311,7 +2313,7 @@ bool ChatHandler::ExtractFloat(char** args, float& val)
*/ */
bool ChatHandler::ExtractOptFloat(char** args, float& val, float defVal) bool ChatHandler::ExtractOptFloat(char** args, float& val, float defVal)
{ {
if (!*args || !**args) if (!*args || !** args)
{ {
val = defVal; val = defVal;
return true; return true;
@ -2330,7 +2332,7 @@ bool ChatHandler::ExtractOptFloat(char** args, float& val, float defVal)
*/ */
char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/) char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/)
{ {
if (!*args || !**args) if (!*args || !** args)
return NULL; return NULL;
char* head = *args; char* head = *args;
@ -2356,7 +2358,7 @@ char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/)
int l = strlen(lit); int l = strlen(lit);
int largs = 0; int largs = 0;
while(head[largs] && !isWhiteSpace(head[largs])) while (head[largs] && !isWhiteSpace(head[largs]))
++largs; ++largs;
if (largs < l) if (largs < l)
@ -2405,12 +2407,12 @@ char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/)
* @param asis control save quote string wrappers * @param asis control save quote string wrappers
* @return quote-like string, or NULL if args empty or not appropriate content. * @return quote-like string, or NULL if args empty or not appropriate content.
*/ */
char* ChatHandler::ExtractQuotedArg( char** args, bool asis /*= false*/ ) char* ChatHandler::ExtractQuotedArg(char** args, bool asis /*= false*/)
{ {
if (!*args || !**args) if (!*args || !** args)
return NULL; return NULL;
if (**args != '\'' && **args != '"' && **args != '[') if (**args != '\'' &&** args != '"' &&** args != '[')
return NULL; return NULL;
char guard = (*args)[0]; char guard = (*args)[0];
@ -2456,7 +2458,7 @@ char* ChatHandler::ExtractQuotedArg( char** args, bool asis /*= false*/ )
*/ */
char* ChatHandler::ExtractQuotedOrLiteralArg(char** args, bool asis /*= false*/) char* ChatHandler::ExtractQuotedOrLiteralArg(char** args, bool asis /*= false*/)
{ {
char *arg = ExtractQuotedArg(args, asis); char* arg = ExtractQuotedArg(args, asis);
if (!arg) if (!arg)
arg = ExtractLiteralArg(args); arg = ExtractLiteralArg(args);
return arg; return arg;
@ -2504,7 +2506,7 @@ bool ChatHandler::ExtractOnOff(char** args, bool& value)
*/ */
char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= NULL*/, int* foundIdx /*= NULL*/, char** keyPair /*= NULL*/, char** somethingPair /*= NULL*/) char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= NULL*/, int* foundIdx /*= NULL*/, char** keyPair /*= NULL*/, char** somethingPair /*= NULL*/)
{ {
if (!*args || !**args) if (!*args || !** args)
return NULL; return NULL;
// skip if not linked started or encoded single | (doubled by client) // skip if not linked started or encoded single | (doubled by client)
@ -2681,9 +2683,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*=
* @param asis control save quote string wrappers * @param asis control save quote string wrappers
* @return extracted arg string, or NULL if args empty or not appropriate content. * @return extracted arg string, or NULL if args empty or not appropriate content.
*/ */
char* ChatHandler::ExtractArg( char** args, bool asis /*= false*/ ) char* ChatHandler::ExtractArg(char** args, bool asis /*= false*/)
{ {
if (!*args || !**args) if (!*args || !** args)
return NULL; return NULL;
char* arg = ExtractQuotedOrLiteralArg(args, asis); char* arg = ExtractQuotedOrLiteralArg(args, asis);
@ -2705,7 +2707,7 @@ char* ChatHandler::ExtractOptNotLastArg(char** args)
char* arg = ExtractArg(args, true); char* arg = ExtractArg(args, true);
// have more data // have more data
if (*args && **args) if (*args &&** args)
return arg; return arg;
// optional name not found // optional name not found
@ -2759,7 +2761,7 @@ char* ChatHandler::ExtractKeyFromLink(char** text, char const* linkType, char**
char* ChatHandler::ExtractKeyFromLink(char** text, char const* const* linkTypes, int* found_idx, char** something1 /*= NULL*/) char* ChatHandler::ExtractKeyFromLink(char** text, char const* const* linkTypes, int* found_idx, char** something1 /*= NULL*/)
{ {
// skip empty // skip empty
if (!*text || !**text) if (!*text || !** text)
return NULL; return NULL;
// return non link case // return non link case
@ -2859,7 +2861,7 @@ uint32 ChatHandler::ExtractSpellIdFromLink(char** text)
if (!ExtractUInt32(&idS, id)) if (!ExtractUInt32(&idS, id))
return 0; return 0;
switch(type) switch (type)
{ {
case SPELL_LINK_RAW: case SPELL_LINK_RAW:
case SPELL_LINK_SPELL: case SPELL_LINK_SPELL:
@ -2870,7 +2872,7 @@ uint32 ChatHandler::ExtractSpellIdFromLink(char** text)
{ {
// talent // talent
TalentEntry const* talentEntry = sTalentStore.LookupEntry(id); TalentEntry const* talentEntry = sTalentStore.LookupEntry(id);
if(!talentEntry) if (!talentEntry)
return 0; return 0;
int32 rank; int32 rank;
@ -2940,7 +2942,7 @@ ObjectGuid ChatHandler::ExtractGuidFromLink(char** text)
if (!idS) if (!idS)
return ObjectGuid(); return ObjectGuid();
switch(type) switch (type)
{ {
case GUID_LINK_RAW: case GUID_LINK_RAW:
case GUID_LINK_PLAYER: case GUID_LINK_PLAYER:
@ -2971,7 +2973,7 @@ ObjectGuid ChatHandler::ExtractGuidFromLink(char** text)
if (!ExtractUInt32(&idS, lowguid)) if (!ExtractUInt32(&idS, lowguid))
return ObjectGuid(); return ObjectGuid();
if(GameObjectData const* data = sObjectMgr.GetGOData(lowguid) ) if (GameObjectData const* data = sObjectMgr.GetGOData(lowguid))
return ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, lowguid); return ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, lowguid);
else else
return ObjectGuid(); return ObjectGuid();
@ -3027,7 +3029,7 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x,
if (!idS) if (!idS)
return false; return false;
switch(type) switch (type)
{ {
case LOCATION_LINK_RAW: case LOCATION_LINK_RAW:
case LOCATION_LINK_PLAYER: case LOCATION_LINK_PLAYER:
@ -3091,7 +3093,7 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x,
if (!ExtractUInt32(&idS, lowguid)) if (!ExtractUInt32(&idS, lowguid))
return false; return false;
if(CreatureData const* data = sObjectMgr.GetCreatureData(lowguid) ) if (CreatureData const* data = sObjectMgr.GetCreatureData(lowguid))
{ {
mapid = data->mapid; mapid = data->mapid;
x = data->posX; x = data->posX;
@ -3108,7 +3110,7 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x,
if (!ExtractUInt32(&idS, lowguid)) if (!ExtractUInt32(&idS, lowguid))
return false; return false;
if(GameObjectData const* data = sObjectMgr.GetGOData(lowguid) ) if (GameObjectData const* data = sObjectMgr.GetGOData(lowguid))
{ {
mapid = data->mapid; mapid = data->mapid;
x = data->posX; x = data->posX;
@ -3205,7 +3207,7 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x,
} }
AreaTrigger const* at = sObjectMgr.GetAreaTrigger(id); AreaTrigger const* at = sObjectMgr.GetAreaTrigger(id);
if(!at) if (!at)
{ {
PSendSysMessage(LANG_AREATRIGER_NOT_HAS_TARGET, id); PSendSysMessage(LANG_AREATRIGER_NOT_HAS_TARGET, id);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -3228,11 +3230,11 @@ std::string ChatHandler::ExtractPlayerNameFromLink(char** text)
{ {
// |color|Hplayer:name|h[name]|h|r // |color|Hplayer:name|h[name]|h|r
char* name_str = ExtractKeyFromLink(text, "Hplayer"); char* name_str = ExtractKeyFromLink(text, "Hplayer");
if(!name_str) if (!name_str)
return ""; return "";
std::string name = name_str; std::string name = name_str;
if(!normalizePlayerName(name)) if (!normalizePlayerName(name))
return ""; return "";
return name; return name;
@ -3253,7 +3255,7 @@ std::string ChatHandler::ExtractPlayerNameFromLink(char** text)
*/ */
bool ChatHandler::ExtractPlayerTarget(char** args, Player** player /*= NULL*/, ObjectGuid* player_guid /*= NULL*/,std::string* player_name /*= NULL*/) bool ChatHandler::ExtractPlayerTarget(char** args, Player** player /*= NULL*/, ObjectGuid* player_guid /*= NULL*/,std::string* player_name /*= NULL*/)
{ {
if (*args && **args) if (*args &&** args)
{ {
std::string name = ExtractPlayerNameFromLink(args); std::string name = ExtractPlayerNameFromLink(args);
if (name.empty()) if (name.empty())
@ -3266,35 +3268,35 @@ bool ChatHandler::ExtractPlayerTarget(char** args, Player** player /*= NULL*/, O
Player* pl = sObjectMgr.GetPlayer(name.c_str()); Player* pl = sObjectMgr.GetPlayer(name.c_str());
// if allowed player pointer // if allowed player pointer
if(player) if (player)
*player = pl; *player = pl;
// if need guid value from DB (in name case for check player existence) // if need guid value from DB (in name case for check player existence)
ObjectGuid guid = !pl && (player_guid || player_name) ? sObjectMgr.GetPlayerGuidByName(name) : ObjectGuid(); ObjectGuid guid = !pl && (player_guid || player_name) ? sObjectMgr.GetPlayerGuidByName(name) : ObjectGuid();
// if allowed player guid (if no then only online players allowed) // if allowed player guid (if no then only online players allowed)
if(player_guid) if (player_guid)
*player_guid = pl ? pl->GetObjectGuid() : guid; *player_guid = pl ? pl->GetObjectGuid() : guid;
if(player_name) if (player_name)
*player_name = pl || guid ? name : ""; *player_name = pl || guid ? name : "";
} }
else else
{ {
Player* pl = getSelectedPlayer(); Player* pl = getSelectedPlayer();
// if allowed player pointer // if allowed player pointer
if(player) if (player)
*player = pl; *player = pl;
// if allowed player guid (if no then only online players allowed) // if allowed player guid (if no then only online players allowed)
if(player_guid) if (player_guid)
*player_guid = pl ? pl->GetObjectGuid() : ObjectGuid(); *player_guid = pl ? pl->GetObjectGuid() : ObjectGuid();
if(player_name) if (player_name)
*player_name = pl ? pl->GetName() : ""; *player_name = pl ? pl->GetName() : "";
} }
// some from req. data must be provided (note: name is empty if player not exist) // some from req. data must be provided (note: name is empty if player not exist)
if((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty())) if ((!player || !*player) && (!player_guid || !*player_guid) && (!player_name || player_name->empty()))
{ {
SendSysMessage(LANG_PLAYER_NOT_FOUND); SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -3449,7 +3451,7 @@ int ChatHandler::GetSessionDbLocaleIndex() const
return m_session->GetSessionDbLocaleIndex(); return m_session->GetSessionDbLocaleIndex();
} }
const char *CliHandler::GetMangosString(int32 entry) const const char* CliHandler::GetMangosString(int32 entry) const
{ {
return sObjectMgr.GetMangosStringForDBCLocale(entry); return sObjectMgr.GetMangosStringForDBCLocale(entry);
} }
@ -3474,7 +3476,7 @@ bool CliHandler::isAvailable(ChatCommand const& cmd) const
return GetAccessLevel() >= (AccountTypes)cmd.SecurityLevel; return GetAccessLevel() >= (AccountTypes)cmd.SecurityLevel;
} }
void CliHandler::SendSysMessage(const char *str) void CliHandler::SendSysMessage(const char* str)
{ {
m_print(m_callbackArg, str); m_print(m_callbackArg, str);
m_print(m_callbackArg, "\r\n"); m_print(m_callbackArg, "\r\n");

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);
@ -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,7 +41,7 @@ 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
@ -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,10 +377,10 @@ 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;
@ -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,7 +82,7 @@ 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());
@ -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,7 +241,7 @@ 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());
@ -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:

View file

@ -51,7 +51,6 @@
// apply implementation of the singletons // apply implementation of the singletons
#include "Policies/SingletonImp.h" #include "Policies/SingletonImp.h"
ObjectGuid CreatureData::GetObjectGuid(uint32 lowguid) const ObjectGuid CreatureData::GetObjectGuid(uint32 lowguid) const
{ {
// info existence checked at loading // info existence checked at loading
@ -67,13 +66,13 @@ TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
return NULL; return NULL;
} }
bool VendorItemData::RemoveItem( uint32 item_id ) bool VendorItemData::RemoveItem(uint32 item_id)
{ {
bool found = false; bool found = false;
for(VendorItemList::iterator i = m_items.begin(); i != m_items.end(); ) for (VendorItemList::iterator i = m_items.begin(); i != m_items.end();)
{ {
// can have many examples // can have many examples
if((*i)->item == item_id) if ((*i)->item == item_id)
{ {
i = m_items.erase(i); i = m_items.erase(i);
found = true; found = true;
@ -87,8 +86,8 @@ bool VendorItemData::RemoveItem( uint32 item_id )
VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extendedCost) const VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extendedCost) const
{ {
for(VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i ) for (VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i)
if((*i)->item == item_id && (*i)->ExtendedCost == extendedCost) if ((*i)->item == item_id && (*i)->ExtendedCost == extendedCost)
return *i; return *i;
return NULL; return NULL;
} }
@ -105,7 +104,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
if (assistant && assistant->CanAssistTo(&m_owner, victim)) if (assistant && assistant->CanAssistTo(&m_owner, victim))
{ {
assistant->SetNoCallAssistance(true); assistant->SetNoCallAssistance(true);
if(assistant->AI()) if (assistant->AI())
assistant->AI()->AttackStart(victim); assistant->AI()->AttackStart(victim);
} }
} }
@ -113,7 +112,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
return true; return true;
} }
AssistDelayEvent::AssistDelayEvent( ObjectGuid victim, Unit& owner, std::list<Creature*> const& assistants ) : BasicEvent(), m_victimGuid(victim), m_owner(owner) AssistDelayEvent::AssistDelayEvent(ObjectGuid victim, Unit& owner, std::list<Creature*> const& assistants) : BasicEvent(), m_victimGuid(victim), m_owner(owner)
{ {
// Pushing guids because in delay can happen some creature gets despawned => invalid pointer // Pushing guids because in delay can happen some creature gets despawned => invalid pointer
m_assistantGuids.reserve(assistants.size()); m_assistantGuids.reserve(assistants.size());
@ -157,20 +156,20 @@ bool CreatureCreatePos::Relocate(Creature* cr) const
} }
Creature::Creature(CreatureSubtype subtype) : Creature::Creature(CreatureSubtype subtype) :
Unit(), i_AI(NULL), Unit(), i_AI(NULL),
lootForPickPocketed(false), lootForBody(false), lootForSkin(false), m_groupLootTimer(0), m_groupLootId(0), lootForPickPocketed(false), lootForBody(false), lootForSkin(false), m_groupLootTimer(0), m_groupLootId(0),
m_lootMoney(0), m_lootGroupRecipientId(0), m_lootMoney(0), m_lootGroupRecipientId(0),
m_corpseDecayTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(5.0f), m_corpseDecayTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(5.0f),
m_subtype(subtype), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0), m_subtype(subtype), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false),
m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_temporaryFactionFlags(TEMPFACTION_NONE), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_temporaryFactionFlags(TEMPFACTION_NONE),
m_creatureInfo(NULL) m_creatureInfo(NULL)
{ {
m_regenTimer = 200; m_regenTimer = 200;
m_valuesCount = UNIT_END; m_valuesCount = UNIT_END;
for(int i = 0; i < CREATURE_MAX_SPELLS; ++i) for (int i = 0; i < CREATURE_MAX_SPELLS; ++i)
m_spells[i] = 0; m_spells[i] = 0;
m_CreatureSpellCooldowns.clear(); m_CreatureSpellCooldowns.clear();
@ -237,20 +236,20 @@ void Creature::RemoveCorpse()
/** /**
* change the entry of creature until respawn * change the entry of creature until respawn
*/ */
bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/ ) bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/)
{ {
// use game event entry if any instead default suggested // use game event entry if any instead default suggested
if (eventData && eventData->entry_id) if (eventData && eventData->entry_id)
Entry = eventData->entry_id; Entry = eventData->entry_id;
CreatureInfo const *normalInfo = ObjectMgr::GetCreatureTemplate(Entry); CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(Entry);
if(!normalInfo) if (!normalInfo)
{ {
sLog.outErrorDb("Creature::UpdateEntry creature entry %u does not exist.", Entry); sLog.outErrorDb("Creature::UpdateEntry creature entry %u does not exist.", Entry);
return false; return false;
} }
CreatureInfo const *cinfo = normalInfo; CreatureInfo const* cinfo = normalInfo;
for (Difficulty diff = GetMap()->GetDifficulty(); diff > REGULAR_DIFFICULTY; diff = GetPrevDifficulty(diff, GetMap()->IsRaid())) for (Difficulty diff = GetMap()->GetDifficulty(); diff > REGULAR_DIFFICULTY; diff = GetPrevDifficulty(diff, GetMap()->IsRaid()))
{ {
// we already have valid Map pointer for current creature! // we already have valid Map pointer for current creature!
@ -283,7 +282,7 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
return false; return false;
} }
CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id); CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
if (!minfo) // Cancel load if no model defined if (!minfo) // Cancel load if no model defined
{ {
sLog.outErrorDb("Creature (Entry: %u) has no model info defined in table `creature_model_info`, can't load.", Entry); sLog.outErrorDb("Creature (Entry: %u) has no model info defined in table `creature_model_info`, can't load.", Entry);
@ -312,7 +311,8 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
LoadEquipment(cinfo->equipmentId); // else use from diff template LoadEquipment(cinfo->equipmentId); // else use from diff template
} }
else if (data && data->equipmentId != -1) else if (data && data->equipmentId != -1)
{ // override, -1 means no equipment {
// override, -1 means no equipment
LoadEquipment(data->equipmentId); LoadEquipment(data->equipmentId);
} }
@ -332,7 +332,7 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
return true; return true;
} }
bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData *data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/, bool preserveHPAndPower /*=true*/) bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/, bool preserveHPAndPower /*=true*/)
{ {
if (!InitEntry(Entry, data, eventData)) if (!InitEntry(Entry, data, eventData))
return false; return false;
@ -389,7 +389,7 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData *data /*=
SetPvP(false); SetPvP(false);
} }
for(int i = 0; i < CREATURE_MAX_SPELLS; ++i) for (int i = 0; i < CREATURE_MAX_SPELLS; ++i)
m_spells[i] = GetCreatureInfo()->spells[i]; m_spells[i] = GetCreatureInfo()->spells[i];
SetVehicleId(GetCreatureInfo()->vehicleId); SetVehicleId(GetCreatureInfo()->vehicleId);
@ -401,7 +401,7 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData *data /*=
return true; return true;
} }
uint32 Creature::ChooseDisplayId(const CreatureInfo *cinfo, const CreatureData *data /*= NULL*/, GameEventCreatureData const* eventData /*=NULL*/) uint32 Creature::ChooseDisplayId(const CreatureInfo* cinfo, const CreatureData* data /*= NULL*/, GameEventCreatureData const* eventData /*=NULL*/)
{ {
// Use creature event model explicit, override any other static models // Use creature event model explicit, override any other static models
if (eventData && eventData->modelid) if (eventData && eventData->modelid)
@ -449,7 +449,7 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo *cinfo, const CreatureData *
{ {
sLog.outErrorDb("Call customer support, ChooseDisplayId can not select native model for creature entry %u, model from creature entry 1 will be used instead.", cinfo->Entry); sLog.outErrorDb("Call customer support, ChooseDisplayId can not select native model for creature entry %u, model from creature entry 1 will be used instead.", cinfo->Entry);
if (const CreatureInfo *creatureDefault = ObjectMgr::GetCreatureTemplate(1)) if (const CreatureInfo* creatureDefault = ObjectMgr::GetCreatureTemplate(1))
display_id = creatureDefault->ModelId[0]; display_id = creatureDefault->ModelId[0];
} }
@ -458,7 +458,7 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo *cinfo, const CreatureData *
void Creature::Update(uint32 update_diff, uint32 diff) void Creature::Update(uint32 update_diff, uint32 diff)
{ {
switch( m_deathState ) switch (m_deathState)
{ {
case JUST_ALIVED: case JUST_ALIVED:
// Don't must be called, see Creature::SetDeathState JUST_ALIVED -> ALIVE promoting. // Don't must be called, see Creature::SetDeathState JUST_ALIVED -> ALIVE promoting.
@ -481,14 +481,14 @@ void Creature::Update(uint32 update_diff, uint32 diff)
// Clear possible auras having IsDeathPersistent() attribute // Clear possible auras having IsDeathPersistent() attribute
RemoveAllAuras(); RemoveAllAuras();
if(m_originalEntry != GetEntry()) if (m_originalEntry != GetEntry())
{ {
// need preserver gameevent state // need preserver gameevent state
GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(GetGUIDLow()); GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(GetGUIDLow());
UpdateEntry(m_originalEntry, TEAM_NONE, NULL, eventData); UpdateEntry(m_originalEntry, TEAM_NONE, NULL, eventData);
} }
CreatureInfo const *cinfo = GetCreatureInfo(); CreatureInfo const* cinfo = GetCreatureInfo();
SelectLevel(cinfo); SelectLevel(cinfo);
SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE); SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
@ -501,7 +501,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
LoadCreatureAddon(true); LoadCreatureAddon(true);
} }
else else
SetDeathState( JUST_ALIVED ); SetDeathState(JUST_ALIVED);
//Call AI respawn virtual function //Call AI respawn virtual function
if (AI()) if (AI())
@ -571,14 +571,14 @@ void Creature::Update(uint32 update_diff, uint32 diff)
} }
} }
Unit::Update( update_diff, diff ); Unit::Update(update_diff, diff);
// creature can be dead after Unit::Update call // creature can be dead after Unit::Update call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if(!isAlive()) if (!isAlive())
break; break;
if(!IsInEvadeMode()) if (!IsInEvadeMode())
{ {
if (AI()) if (AI())
{ {
@ -591,7 +591,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
// creature can be dead after UpdateAI call // creature can be dead after UpdateAI call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if(!isAlive()) if (!isAlive())
break; break;
RegenerateAll(update_diff); RegenerateAll(update_diff);
break; break;
@ -601,7 +601,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
} }
} }
void Creature::StartGroupLoot( Group* group, uint32 timer ) void Creature::StartGroupLoot(Group* group, uint32 timer)
{ {
m_groupLootId = group->GetId(); m_groupLootId = group->GetId();
m_groupLootTimer = timer; m_groupLootTimer = timer;
@ -623,7 +623,7 @@ void Creature::RegenerateAll(uint32 update_diff)
{ {
if (m_regenTimer > 0) if (m_regenTimer > 0)
{ {
if(update_diff >= m_regenTimer) if (update_diff >= m_regenTimer)
m_regenTimer = 0; m_regenTimer = 0;
else else
m_regenTimer -= update_diff; m_regenTimer -= update_diff;
@ -652,7 +652,7 @@ void Creature::RegenerateMana()
// Combat and any controlled creature // Combat and any controlled creature
if (isInCombat() || GetCharmerOrOwnerGuid()) if (isInCombat() || GetCharmerOrOwnerGuid())
{ {
if(!IsUnderLastManaUseEffect()) if (!IsUnderLastManaUseEffect())
{ {
float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA); float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA);
float Spirit = GetStat(STAT_SPIRIT); float Spirit = GetStat(STAT_SPIRIT);
@ -685,7 +685,7 @@ void Creature::RegenerateHealth()
float HealthIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_HEALTH); float HealthIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_HEALTH);
float Spirit = GetStat(STAT_SPIRIT); float Spirit = GetStat(STAT_SPIRIT);
if( GetPower(POWER_MANA) > 0 ) if (GetPower(POWER_MANA) > 0)
addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate); addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate);
else else
addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate);
@ -713,7 +713,7 @@ void Creature::DoFleeToGetAssistance()
SetNoSearchAssistance(true); SetNoSearchAssistance(true);
UpdateSpeed(MOVE_RUN, false); UpdateSpeed(MOVE_RUN, false);
if(!pCreature) if (!pCreature)
SetFeared(true, getVictim()->GetObjectGuid(), 0 ,sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_FLEE_DELAY)); SetFeared(true, getVictim()->GetObjectGuid(), 0 ,sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_FLEE_DELAY));
else else
GetMotionMaster()->MoveSeekAssistance(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ()); GetMotionMaster()->MoveSeekAssistance(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ());
@ -723,13 +723,13 @@ void Creature::DoFleeToGetAssistance()
bool Creature::AIM_Initialize() bool Creature::AIM_Initialize()
{ {
// make sure nothing can change the AI during AI update // make sure nothing can change the AI during AI update
if(m_AI_locked) if (m_AI_locked)
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "AIM_Initialize: failed to init, locked."); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "AIM_Initialize: failed to init, locked.");
return false; return false;
} }
CreatureAI * oldAI = i_AI; CreatureAI* oldAI = i_AI;
i_motionMaster.Initialize(); i_motionMaster.Initialize();
i_AI = FactorySelector::selectAI(this); i_AI = FactorySelector::selectAI(this);
if (oldAI) if (oldAI)
@ -737,7 +737,7 @@ bool Creature::AIM_Initialize()
return true; return true;
} }
bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, Team team /*= TEAM_NONE*/, const CreatureData *data /*= NULL*/, GameEventCreatureData const* eventData /*= NULL*/) bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, Team team /*= TEAM_NONE*/, const CreatureData* data /*= NULL*/, GameEventCreatureData const* eventData /*= NULL*/)
{ {
SetMap(cPos.GetMap()); SetMap(cPos.GetMap());
SetPhaseMask(cPos.GetPhaseMask(), false); SetPhaseMask(cPos.GetPhaseMask(), false);
@ -809,7 +809,7 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
} }
} }
switch(GetCreatureInfo()->trainer_type) switch (GetCreatureInfo()->trainer_type)
{ {
case TRAINER_TYPE_CLASS: case TRAINER_TYPE_CLASS:
if (pPlayer->getClass() != GetCreatureInfo()->trainer_class) if (pPlayer->getClass() != GetCreatureInfo()->trainer_class)
@ -817,17 +817,17 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
if (msg) if (msg)
{ {
pPlayer->PlayerTalkClass->ClearMenus(); pPlayer->PlayerTalkClass->ClearMenus();
switch(GetCreatureInfo()->trainer_class) switch (GetCreatureInfo()->trainer_class)
{ {
case CLASS_DRUID: pPlayer->PlayerTalkClass->SendGossipMenu( 4913, GetObjectGuid()); break; case CLASS_DRUID: pPlayer->PlayerTalkClass->SendGossipMenu(4913, GetObjectGuid()); break;
case CLASS_HUNTER: pPlayer->PlayerTalkClass->SendGossipMenu(10090, GetObjectGuid()); break; case CLASS_HUNTER: pPlayer->PlayerTalkClass->SendGossipMenu(10090, GetObjectGuid()); break;
case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu( 328, GetObjectGuid()); break; case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu(328, GetObjectGuid()); break;
case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu( 1635, GetObjectGuid()); break; case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu(1635, GetObjectGuid()); break;
case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu( 4436, GetObjectGuid()); break; case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu(4436, GetObjectGuid()); break;
case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu( 4797, GetObjectGuid()); break; case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu(4797, GetObjectGuid()); break;
case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu( 5003, GetObjectGuid()); break; case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu(5003, GetObjectGuid()); break;
case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu( 5836, GetObjectGuid()); break; case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu(5836, GetObjectGuid()); break;
case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu( 4985, GetObjectGuid()); break; case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu(4985, GetObjectGuid()); break;
} }
} }
return false; return false;
@ -857,7 +857,7 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
if (msg) if (msg)
{ {
pPlayer->PlayerTalkClass->ClearMenus(); pPlayer->PlayerTalkClass->ClearMenus();
switch(GetCreatureInfo()->trainer_class) switch (GetCreatureInfo()->trainer_class)
{ {
case RACE_DWARF: pPlayer->PlayerTalkClass->SendGossipMenu(5865, GetObjectGuid()); break; case RACE_DWARF: pPlayer->PlayerTalkClass->SendGossipMenu(5865, GetObjectGuid()); break;
case RACE_GNOME: pPlayer->PlayerTalkClass->SendGossipMenu(4881, GetObjectGuid()); break; case RACE_GNOME: pPlayer->PlayerTalkClass->SendGossipMenu(4881, GetObjectGuid()); break;
@ -866,7 +866,7 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
case RACE_ORC: pPlayer->PlayerTalkClass->SendGossipMenu(5863, GetObjectGuid()); break; case RACE_ORC: pPlayer->PlayerTalkClass->SendGossipMenu(5863, GetObjectGuid()); break;
case RACE_TAUREN: pPlayer->PlayerTalkClass->SendGossipMenu(5864, GetObjectGuid()); break; case RACE_TAUREN: pPlayer->PlayerTalkClass->SendGossipMenu(5864, GetObjectGuid()); break;
case RACE_TROLL: pPlayer->PlayerTalkClass->SendGossipMenu(5816, GetObjectGuid()); break; case RACE_TROLL: pPlayer->PlayerTalkClass->SendGossipMenu(5816, GetObjectGuid()); break;
case RACE_UNDEAD: pPlayer->PlayerTalkClass->SendGossipMenu( 624, GetObjectGuid()); break; case RACE_UNDEAD: pPlayer->PlayerTalkClass->SendGossipMenu(624, GetObjectGuid()); break;
case RACE_BLOODELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862, GetObjectGuid()); break; case RACE_BLOODELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862, GetObjectGuid()); break;
case RACE_DRAENEI: pPlayer->PlayerTalkClass->SendGossipMenu(5864, GetObjectGuid()); break; case RACE_DRAENEI: pPlayer->PlayerTalkClass->SendGossipMenu(5864, GetObjectGuid()); break;
} }
@ -893,20 +893,20 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
bool Creature::CanInteractWithBattleMaster(Player* pPlayer, bool msg) const bool Creature::CanInteractWithBattleMaster(Player* pPlayer, bool msg) const
{ {
if(!isBattleMaster()) if (!isBattleMaster())
return false; return false;
BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry());
if (bgTypeId == BATTLEGROUND_TYPE_NONE) if (bgTypeId == BATTLEGROUND_TYPE_NONE)
return false; return false;
if(!msg) if (!msg)
return pPlayer->GetBGAccessByLevel(bgTypeId); return pPlayer->GetBGAccessByLevel(bgTypeId);
if(!pPlayer->GetBGAccessByLevel(bgTypeId)) if (!pPlayer->GetBGAccessByLevel(bgTypeId))
{ {
pPlayer->PlayerTalkClass->ClearMenus(); pPlayer->PlayerTalkClass->ClearMenus();
switch(bgTypeId) switch (bgTypeId)
{ {
case BATTLEGROUND_AV: pPlayer->PlayerTalkClass->SendGossipMenu(7616, GetObjectGuid()); break; case BATTLEGROUND_AV: pPlayer->PlayerTalkClass->SendGossipMenu(7616, GetObjectGuid()); break;
case BATTLEGROUND_WS: pPlayer->PlayerTalkClass->SendGossipMenu(7599, GetObjectGuid()); break; case BATTLEGROUND_WS: pPlayer->PlayerTalkClass->SendGossipMenu(7599, GetObjectGuid()); break;
@ -1011,8 +1011,8 @@ Player* Creature::GetLootRecipient() const
return player; return player;
// find any in group // find any in group
for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player *p = itr->getSource()) if (Player* p = itr->getSource())
return p; return p;
return NULL; return NULL;
@ -1021,7 +1021,7 @@ Player* Creature::GetLootRecipient() const
/** /**
* Set player and group (if player group member) who tap creature * Set player and group (if player group member) who tap creature
*/ */
void Creature::SetLootRecipient(Unit *unit) void Creature::SetLootRecipient(Unit* unit)
{ {
// set the player whose group should receive the right // set the player whose group should receive the right
// to loot the creature after it dies // to loot the creature after it dies
@ -1037,7 +1037,7 @@ void Creature::SetLootRecipient(Unit *unit)
} }
Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself(); Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself();
if(!player) // normal creature, no player involved if (!player) // normal creature, no player involved
return; return;
// set player for non group case or if group will disbanded // set player for non group case or if group will disbanded
@ -1055,8 +1055,8 @@ void Creature::SaveToDB()
{ {
// this should only be used when the creature has already been loaded // this should only be used when the creature has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise // preferably after adding to map, because mapid may not be valid otherwise
CreatureData const *data = sObjectMgr.GetCreatureData(GetGUIDLow()); CreatureData const* data = sObjectMgr.GetCreatureData(GetGUIDLow());
if(!data) if (!data)
{ {
sLog.outError("Creature::SaveToDB failed, cannot get creature data!"); sLog.outError("Creature::SaveToDB failed, cannot get creature data!");
return; return;
@ -1073,15 +1073,15 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
uint32 displayId = GetNativeDisplayId(); uint32 displayId = GetNativeDisplayId();
// check if it's a custom model and if not, use 0 for displayId // check if it's a custom model and if not, use 0 for displayId
CreatureInfo const *cinfo = GetCreatureInfo(); CreatureInfo const* cinfo = GetCreatureInfo();
if (cinfo) if (cinfo)
{ {
if (displayId != cinfo->ModelId[0] && displayId != cinfo->ModelId[1] && if (displayId != cinfo->ModelId[0] && displayId != cinfo->ModelId[1] &&
displayId != cinfo->ModelId[2] && displayId != cinfo->ModelId[3]) displayId != cinfo->ModelId[2] && displayId != cinfo->ModelId[3])
{ {
for(int i = 0; i < MAX_CREATURE_MODEL && displayId; ++i) for (int i = 0; i < MAX_CREATURE_MODEL && displayId; ++i)
if (cinfo->ModelId[i]) if (cinfo->ModelId[i])
if (CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelInfo(cinfo->ModelId[i])) if (CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelInfo(cinfo->ModelId[i]))
if (displayId == minfo->modelid_other_gender) if (displayId == minfo->modelid_other_gender)
displayId = 0; displayId = 0;
} }
@ -1142,7 +1142,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
WorldDatabase.CommitTransaction(); WorldDatabase.CommitTransaction();
} }
void Creature::SelectLevel(const CreatureInfo *cinfo, float percentHealth, float percentMana) void Creature::SelectLevel(const CreatureInfo* cinfo, float percentHealth, float percentMana)
{ {
uint32 rank = IsPet()? 0 : cinfo->rank; uint32 rank = IsPet()? 0 : cinfo->rank;
@ -1255,7 +1255,7 @@ float Creature::GetSpellDamageMod(int32 Rank)
} }
} }
bool Creature::CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team team, const CreatureData *data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/) bool Creature::CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team team, const CreatureData* data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/)
{ {
m_originalEntry = cinfo->Entry; m_originalEntry = cinfo->Entry;
@ -1267,18 +1267,18 @@ bool Creature::CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team t
return true; return true;
} }
bool Creature::LoadFromDB(uint32 guidlow, Map *map) bool Creature::LoadFromDB(uint32 guidlow, Map* map)
{ {
CreatureData const* data = sObjectMgr.GetCreatureData(guidlow); CreatureData const* data = sObjectMgr.GetCreatureData(guidlow);
if(!data) if (!data)
{ {
sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ", guidlow); sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ", guidlow);
return false; return false;
} }
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(data->id); CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(data->id);
if(!cinfo) if (!cinfo)
{ {
sLog.outErrorDb("Creature (Entry: %u) not found in table `creature_template`, can't load. ", data->id); sLog.outErrorDb("Creature (Entry: %u) not found in table `creature_template`, can't load. ", data->id);
return false; return false;
@ -1303,17 +1303,17 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
m_respawnTime = map->GetPersistentState()->GetCreatureRespawnTime(GetGUIDLow()); m_respawnTime = map->GetPersistentState()->GetCreatureRespawnTime(GetGUIDLow());
if(m_respawnTime > time(NULL)) // not ready to respawn if (m_respawnTime > time(NULL)) // not ready to respawn
{ {
m_deathState = DEAD; m_deathState = DEAD;
if(CanFly()) if (CanFly())
{ {
float tz = GetTerrain()->GetHeight(data->posX, data->posY, data->posZ, false); float tz = GetTerrain()->GetHeight(data->posX, data->posY, data->posZ, false);
if(data->posZ - tz > 0.1) if (data->posZ - tz > 0.1)
Relocate(data->posX, data->posY, tz); Relocate(data->posX, data->posY, tz);
} }
} }
else if(m_respawnTime) // respawn time set but expired else if (m_respawnTime) // respawn time set but expired
{ {
m_respawnTime = 0; m_respawnTime = 0;
@ -1324,7 +1324,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
if (curhealth) if (curhealth)
{ {
curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank)); curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank));
if(curhealth < 1) if (curhealth < 1)
curhealth = 1; curhealth = 1;
} }
@ -1364,7 +1364,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
void Creature::LoadEquipment(uint32 equip_entry, bool force) void Creature::LoadEquipment(uint32 equip_entry, bool force)
{ {
if(equip_entry == 0) if (equip_entry == 0)
{ {
if (force) if (force)
{ {
@ -1375,7 +1375,7 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force)
return; return;
} }
EquipmentInfo const *einfo = sObjectMgr.GetEquipmentInfo(equip_entry); EquipmentInfo const* einfo = sObjectMgr.GetEquipmentInfo(equip_entry);
if (!einfo) if (!einfo)
return; return;
@ -1387,7 +1387,7 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force)
bool Creature::HasQuest(uint32 quest_id) const bool Creature::HasQuest(uint32 quest_id) const
{ {
QuestRelationsMapBounds bounds = sObjectMgr.GetCreatureQuestRelationsMapBounds(GetEntry()); QuestRelationsMapBounds bounds = sObjectMgr.GetCreatureQuestRelationsMapBounds(GetEntry());
for(QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
{ {
if (itr->second == quest_id) if (itr->second == quest_id)
return true; return true;
@ -1398,7 +1398,7 @@ bool Creature::HasQuest(uint32 quest_id) const
bool Creature::HasInvolvedQuest(uint32 quest_id) const bool Creature::HasInvolvedQuest(uint32 quest_id) const
{ {
QuestRelationsMapBounds bounds = sObjectMgr.GetCreatureQuestInvolvedRelationsMapBounds(GetEntry()); QuestRelationsMapBounds bounds = sObjectMgr.GetCreatureQuestInvolvedRelationsMapBounds(GetEntry());
for(QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
{ {
if (itr->second == quest_id) if (itr->second == quest_id)
return true; return true;
@ -1411,7 +1411,7 @@ struct CreatureRespawnDeleteWorker
{ {
explicit CreatureRespawnDeleteWorker(uint32 guid) : i_guid(guid) {} explicit CreatureRespawnDeleteWorker(uint32 guid) : i_guid(guid) {}
void operator() (MapPersistentState* state) void operator()(MapPersistentState* state)
{ {
state->SaveCreatureRespawnTime(i_guid, 0); state->SaveCreatureRespawnTime(i_guid, 0);
} }
@ -1433,7 +1433,7 @@ void Creature::DeleteFromDB()
void Creature::DeleteFromDB(uint32 lowguid, CreatureData const* data) void Creature::DeleteFromDB(uint32 lowguid, CreatureData const* data)
{ {
CreatureRespawnDeleteWorker worker (lowguid); CreatureRespawnDeleteWorker worker(lowguid);
sMapPersistentStateMgr.DoForAllStatesWithMapId(data->mapid, worker); sMapPersistentStateMgr.DoForAllStatesWithMapId(data->mapid, worker);
sObjectMgr.DeleteCreatureData(lowguid); sObjectMgr.DeleteCreatureData(lowguid);
@ -1451,7 +1451,7 @@ void Creature::DeleteFromDB(uint32 lowguid, CreatureData const* data)
float Creature::GetAttackDistance(Unit const* pl) const float Creature::GetAttackDistance(Unit const* pl) const
{ {
float aggroRate = sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); float aggroRate = sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO);
if(aggroRate == 0) if (aggroRate == 0)
return 0.0f; return 0.0f;
uint32 playerlevel = pl->GetLevelForTarget(this); uint32 playerlevel = pl->GetLevelForTarget(this);
@ -1460,7 +1460,7 @@ float Creature::GetAttackDistance(Unit const* pl) const
int32 leveldif = int32(playerlevel) - int32(creaturelevel); int32 leveldif = int32(playerlevel) - int32(creaturelevel);
// "The maximum Aggro Radius has a cap of 25 levels under. Example: A level 30 char has the same Aggro Radius of a level 5 char on a level 60 mob." // "The maximum Aggro Radius has a cap of 25 levels under. Example: A level 30 char has the same Aggro Radius of a level 5 char on a level 60 mob."
if ( leveldif < - 25) if (leveldif < - 25)
leveldif = -25; leveldif = -25;
// "The aggro radius of a mob having the same level as the player is roughly 20 yards" // "The aggro radius of a mob having the same level as the player is roughly 20 yards"
@ -1470,7 +1470,7 @@ float Creature::GetAttackDistance(Unit const* pl) const
// radius grow if playlevel < creaturelevel // radius grow if playlevel < creaturelevel
RetDistance -= (float)leveldif; RetDistance -= (float)leveldif;
if(creaturelevel+5 <= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) if (creaturelevel+5 <= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
{ {
// detect range auras // detect range auras
RetDistance += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE); RetDistance += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE);
@ -1480,7 +1480,7 @@ float Creature::GetAttackDistance(Unit const* pl) const
} }
// "Minimum Aggro Radius for a mob seems to be combat range (5 yards)" // "Minimum Aggro Radius for a mob seems to be combat range (5 yards)"
if(RetDistance < 5) if (RetDistance < 5)
RetDistance = 5; RetDistance = 5;
return (RetDistance*aggroRate); return (RetDistance*aggroRate);
@ -1519,7 +1519,7 @@ void Creature::SetDeathState(DeathState s)
if (s == JUST_ALIVED) if (s == JUST_ALIVED)
{ {
CreatureInfo const *cinfo = GetCreatureInfo(); CreatureInfo const* cinfo = GetCreatureInfo();
SetHealth(GetMaxHealth()); SetHealth(GetMaxHealth());
SetLootRecipient(NULL); SetLootRecipient(NULL);
@ -1570,7 +1570,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn)
{ {
if (timeMSToDespawn) if (timeMSToDespawn)
{ {
ForcedDespawnDelayEvent *pEvent = new ForcedDespawnDelayEvent(*this); ForcedDespawnDelayEvent* pEvent = new ForcedDespawnDelayEvent(*this);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn)); m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn));
return; return;
@ -1616,38 +1616,38 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd
return Unit::IsImmuneToSpellEffect(spellInfo, index); return Unit::IsImmuneToSpellEffect(spellInfo, index);
} }
SpellEntry const *Creature::ReachWithSpellAttack(Unit *pVictim) SpellEntry const* Creature::ReachWithSpellAttack(Unit* pVictim)
{ {
if(!pVictim) if (!pVictim)
return NULL; return NULL;
for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
{ {
if(!m_spells[i]) if (!m_spells[i])
continue; continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] ); SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]);
if(!spellInfo) if (!spellInfo)
{ {
sLog.outError("WORLD: unknown spell id %i", m_spells[i]); sLog.outError("WORLD: unknown spell id %i", m_spells[i]);
continue; continue;
} }
bool bcontinue = true; bool bcontinue = true;
for(int j = 0; j < MAX_EFFECT_INDEX; ++j) for (int j = 0; j < MAX_EFFECT_INDEX; ++j)
{ {
if( (spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE ) || if ((spellInfo->Effect[j] == SPELL_EFFECT_SCHOOL_DAMAGE) ||
(spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) || (spellInfo->Effect[j] == SPELL_EFFECT_INSTAKILL) ||
(spellInfo->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) || (spellInfo->Effect[j] == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) ||
(spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH ) (spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH)
) )
{ {
bcontinue = false; bcontinue = false;
break; break;
} }
} }
if(bcontinue) continue; if (bcontinue) continue;
if(spellInfo->manaCost > GetPower(POWER_MANA)) if (spellInfo->manaCost > GetPower(POWER_MANA))
continue; continue;
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
float range = GetSpellMaxRange(srange); float range = GetSpellMaxRange(srange);
@ -1657,46 +1657,46 @@ SpellEntry const *Creature::ReachWithSpellAttack(Unit *pVictim)
//if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx )
// continue; // continue;
if( dist > range || dist < minrange ) if (dist > range || dist < minrange)
continue; continue;
if(spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
continue; continue;
if(spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
continue; continue;
return spellInfo; return spellInfo;
} }
return NULL; return NULL;
} }
SpellEntry const *Creature::ReachWithSpellCure(Unit *pVictim) SpellEntry const* Creature::ReachWithSpellCure(Unit* pVictim)
{ {
if(!pVictim) if (!pVictim)
return NULL; return NULL;
for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
{ {
if(!m_spells[i]) if (!m_spells[i])
continue; continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] ); SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]);
if(!spellInfo) if (!spellInfo)
{ {
sLog.outError("WORLD: unknown spell id %i", m_spells[i]); sLog.outError("WORLD: unknown spell id %i", m_spells[i]);
continue; continue;
} }
bool bcontinue = true; bool bcontinue = true;
for(int j = 0; j < MAX_EFFECT_INDEX; ++j) for (int j = 0; j < MAX_EFFECT_INDEX; ++j)
{ {
if( (spellInfo->Effect[j] == SPELL_EFFECT_HEAL ) ) if ((spellInfo->Effect[j] == SPELL_EFFECT_HEAL))
{ {
bcontinue = false; bcontinue = false;
break; break;
} }
} }
if(bcontinue) if (bcontinue)
continue; continue;
if(spellInfo->manaCost > GetPower(POWER_MANA)) if (spellInfo->manaCost > GetPower(POWER_MANA))
continue; continue;
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
float range = GetSpellMaxRange(srange); float range = GetSpellMaxRange(srange);
@ -1706,11 +1706,11 @@ SpellEntry const *Creature::ReachWithSpellCure(Unit *pVictim)
//if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) //if(!isInFront( pVictim, range ) && spellInfo->AttributesEx )
// continue; // continue;
if( dist > range || dist < minrange ) if (dist > range || dist < minrange)
continue; continue;
if(spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
continue; continue;
if(spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) if (spellInfo->PreventionType == SPELL_PREVENTION_TYPE_PACIFY && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
continue; continue;
return spellInfo; return spellInfo;
} }
@ -1720,26 +1720,26 @@ SpellEntry const *Creature::ReachWithSpellCure(Unit *pVictim)
bool Creature::IsVisibleInGridForPlayer(Player* pl) const bool Creature::IsVisibleInGridForPlayer(Player* pl) const
{ {
// gamemaster in GM mode see all, including ghosts // gamemaster in GM mode see all, including ghosts
if(pl->isGameMaster()) if (pl->isGameMaster())
return true; return true;
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INVISIBLE) if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INVISIBLE)
return false; return false;
// Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0 // Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0
if(pl->isAlive() || pl->GetDeathTimer() > 0) if (pl->isAlive() || pl->GetDeathTimer() > 0)
{ {
return (isAlive() || m_corpseDecayTimer > 0 || (m_isDeadByDefault && m_deathState == CORPSE)); return (isAlive() || m_corpseDecayTimer > 0 || (m_isDeadByDefault && m_deathState == CORPSE));
} }
// Dead player see live creatures near own corpse // Dead player see live creatures near own corpse
if(isAlive()) if (isAlive())
{ {
Corpse *corpse = pl->GetCorpse(); Corpse* corpse = pl->GetCorpse();
if(corpse) if (corpse)
{ {
// 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level
if(corpse->IsWithinDistInMap(this,(20+25)*sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO))) if (corpse->IsWithinDistInMap(this,(20+25)*sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)))
return true; return true;
} }
} }
@ -1772,7 +1772,7 @@ void Creature::CallAssistance()
SetNoCallAssistance(true); SetNoCallAssistance(true);
float radius = sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS); float radius = sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS);
if(radius > 0) if (radius > 0)
{ {
std::list<Creature*> assistList; std::list<Creature*> assistList;
@ -1784,7 +1784,7 @@ void Creature::CallAssistance()
if (!assistList.empty()) if (!assistList.empty())
{ {
AssistDelayEvent *e = new AssistDelayEvent(getVictim()->GetObjectGuid(), *this, assistList); AssistDelayEvent* e = new AssistDelayEvent(getVictim()->GetObjectGuid(), *this, assistList);
m_Events.AddEvent(e, m_Events.CalculateTime(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY))); m_Events.AddEvent(e, m_Events.CalculateTime(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY)));
} }
} }
@ -1857,10 +1857,10 @@ bool Creature::CanInitiateAttack()
void Creature::SaveRespawnTime() void Creature::SaveRespawnTime()
{ {
if(IsPet() || !HasStaticDBSpawnData()) if (IsPet() || !HasStaticDBSpawnData())
return; return;
if(m_respawnTime > time(NULL)) // dead (no corpse) if (m_respawnTime > time(NULL)) // dead (no corpse)
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), m_respawnTime); GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), m_respawnTime);
else if (m_corpseDecayTimer > 0) // dead (corpse) else if (m_corpseDecayTimer > 0) // dead (corpse)
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), time(NULL) + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS); GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), time(NULL) + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS);
@ -1883,7 +1883,7 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const
if (!pVictim->isVisibleForOrDetect(this,this,false)) if (!pVictim->isVisibleForOrDetect(this,this,false))
return true; return true;
if(sMapStore.LookupEntry(GetMapId())->IsDungeon()) if (sMapStore.LookupEntry(GetMapId())->IsDungeon())
return false; return false;
float AttackDist = GetAttackDistance(pVictim); float AttackDist = GetAttackDistance(pVictim);
@ -1914,8 +1914,8 @@ CreatureDataAddon const* Creature::GetCreatureAddon() const
//creature_addon table //creature_addon table
bool Creature::LoadCreatureAddon(bool reload) bool Creature::LoadCreatureAddon(bool reload)
{ {
CreatureDataAddon const *cainfo = GetCreatureAddon(); CreatureDataAddon const* cainfo = GetCreatureAddon();
if(!cainfo) if (!cainfo)
return false; return false;
if (cainfo->mount != 0) if (cainfo->mount != 0)
@ -2005,12 +2005,12 @@ void Creature::SetInCombatWithZone()
return; return;
} }
Map::PlayerList const &PlList = pMap->GetPlayers(); Map::PlayerList const& PlList = pMap->GetPlayers();
if (PlList.isEmpty()) if (PlList.isEmpty())
return; return;
for(Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
{ {
if (Player* pPlayer = i->getSource()) if (Player* pPlayer = i->getSource())
{ {
@ -2140,22 +2140,22 @@ void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t apply_time)
void Creature::AddCreatureSpellCooldown(uint32 spellid) void Creature::AddCreatureSpellCooldown(uint32 spellid)
{ {
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid);
if(!spellInfo) if (!spellInfo)
return; return;
uint32 cooldown = GetSpellRecoveryTime(spellInfo); uint32 cooldown = GetSpellRecoveryTime(spellInfo);
if(cooldown) if (cooldown)
_AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/IN_MILLISECONDS); _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/IN_MILLISECONDS);
if(spellInfo->Category) if (spellInfo->Category)
_AddCreatureCategoryCooldown(spellInfo->Category, time(NULL)); _AddCreatureCategoryCooldown(spellInfo->Category, time(NULL));
} }
bool Creature::HasCategoryCooldown(uint32 spell_id) const bool Creature::HasCategoryCooldown(uint32 spell_id) const
{ {
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
if(!spellInfo) if (!spellInfo)
return false; return false;
CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category); CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category);
@ -2182,8 +2182,8 @@ bool Creature::IsInEvadeMode() const
bool Creature::HasSpell(uint32 spellID) const bool Creature::HasSpell(uint32 spellID) const
{ {
uint8 i; uint8 i;
for(i = 0; i < CREATURE_MAX_SPELLS; ++i) for (i = 0; i < CREATURE_MAX_SPELLS; ++i)
if(spellID == m_spells[i]) if (spellID == m_spells[i])
break; break;
return i < CREATURE_MAX_SPELLS; // break before end of iteration of known spells return i < CREATURE_MAX_SPELLS; // break before end of iteration of known spells
} }
@ -2191,7 +2191,7 @@ bool Creature::HasSpell(uint32 spellID) const
time_t Creature::GetRespawnTimeEx() const time_t Creature::GetRespawnTimeEx() const
{ {
time_t now = time(NULL); time_t now = time(NULL);
if(m_respawnTime > now) // dead (no corpse) if (m_respawnTime > now) // dead (no corpse)
return m_respawnTime; return m_respawnTime;
else if (m_corpseDecayTimer > 0) // dead (corpse) else if (m_corpseDecayTimer > 0) // dead (corpse)
return now + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS; return now + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS;
@ -2199,7 +2199,7 @@ time_t Creature::GetRespawnTimeEx() const
return now; return now;
} }
void Creature::GetRespawnCoord( float &x, float &y, float &z, float* ori, float* dist ) const void Creature::GetRespawnCoord(float& x, float& y, float& z, float* ori, float* dist) const
{ {
if (CreatureData const* data = sObjectMgr.GetCreatureData(GetGUIDLow())) if (CreatureData const* data = sObjectMgr.GetCreatureData(GetGUIDLow()))
{ {
@ -2276,15 +2276,15 @@ void Creature::AllLootRemovedFromCorpse()
} }
} }
uint32 Creature::GetLevelForTarget( Unit const* target ) const uint32 Creature::GetLevelForTarget(Unit const* target) const
{ {
if(!IsWorldBoss()) if (!IsWorldBoss())
return Unit::GetLevelForTarget(target); return Unit::GetLevelForTarget(target);
uint32 level = target->getLevel()+sWorld.getConfig(CONFIG_UINT32_WORLD_BOSS_LEVEL_DIFF); uint32 level = target->getLevel()+sWorld.getConfig(CONFIG_UINT32_WORLD_BOSS_LEVEL_DIFF);
if(level < 1) if (level < 1)
return 1; return 1;
if(level > 255) if (level > 255)
return 255; return 255;
return level; return level;
} }
@ -2317,27 +2317,27 @@ VendorItemData const* Creature::GetVendorTemplateItems() const
uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
{ {
if(!vItem->maxcount) if (!vItem->maxcount)
return vItem->maxcount; return vItem->maxcount;
VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
for(; itr != m_vendorItemCounts.end(); ++itr) for (; itr != m_vendorItemCounts.end(); ++itr)
if(itr->itemId==vItem->item) if (itr->itemId==vItem->item)
break; break;
if(itr == m_vendorItemCounts.end()) if (itr == m_vendorItemCounts.end())
return vItem->maxcount; return vItem->maxcount;
VendorItemCount* vCount = &*itr; VendorItemCount* vCount = &*itr;
time_t ptime = time(NULL); time_t ptime = time(NULL);
if( vCount->lastIncrementTime + vItem->incrtime <= ptime ) if (vCount->lastIncrementTime + vItem->incrtime <= ptime)
{ {
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item); ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item);
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
if((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount ) if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount)
{ {
m_vendorItemCounts.erase(itr); m_vendorItemCounts.erase(itr);
return vItem->maxcount; return vItem->maxcount;
@ -2352,15 +2352,15 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count) uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count)
{ {
if(!vItem->maxcount) if (!vItem->maxcount)
return 0; return 0;
VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
for(; itr != m_vendorItemCounts.end(); ++itr) for (; itr != m_vendorItemCounts.end(); ++itr)
if(itr->itemId==vItem->item) if (itr->itemId==vItem->item)
break; break;
if(itr == m_vendorItemCounts.end()) if (itr == m_vendorItemCounts.end())
{ {
uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0; uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0;
m_vendorItemCounts.push_back(VendorItemCount(vItem->item,new_count)); m_vendorItemCounts.push_back(VendorItemCount(vItem->item,new_count));
@ -2371,12 +2371,12 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us
time_t ptime = time(NULL); time_t ptime = time(NULL);
if( vCount->lastIncrementTime + vItem->incrtime <= ptime ) if (vCount->lastIncrementTime + vItem->incrtime <= ptime)
{ {
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item); ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item);
uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime);
if((vCount->count + diff * pProto->BuyCount) < vItem->maxcount ) if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount)
vCount->count += diff * pProto->BuyCount; vCount->count += diff * pProto->BuyCount;
else else
vCount->count = vItem->maxcount; vCount->count = vItem->maxcount;
@ -2424,7 +2424,7 @@ void Creature::ClearTemporaryFaction()
setFaction(GetCreatureInfo()->faction_A); setFaction(GetCreatureInfo()->faction_A);
} }
void Creature::SendAreaSpiritHealerQueryOpcode(Player *pl) void Creature::SendAreaSpiritHealerQueryOpcode(Player* pl)
{ {
uint32 next_resurrect = 0; uint32 next_resurrect = 0;
if (Spell* pcurSpell = GetCurrentSpell(CURRENT_CHANNELED_SPELL)) if (Spell* pcurSpell = GetCurrentSpell(CURRENT_CHANNELED_SPELL))
@ -2468,7 +2468,7 @@ struct AddCreatureToRemoveListInMapsWorker
{ {
AddCreatureToRemoveListInMapsWorker(ObjectGuid guid) : i_guid(guid) {} AddCreatureToRemoveListInMapsWorker(ObjectGuid guid) : i_guid(guid) {}
void operator() (Map* map) void operator()(Map* map)
{ {
if (Creature* pCreature = map->GetCreature(i_guid)) if (Creature* pCreature = map->GetCreature(i_guid))
pCreature->AddObjectToRemoveList(); pCreature->AddObjectToRemoveList();
@ -2488,7 +2488,7 @@ struct SpawnCreatureInMapsWorker
SpawnCreatureInMapsWorker(uint32 guid, CreatureData const* data) SpawnCreatureInMapsWorker(uint32 guid, CreatureData const* data)
: i_guid(guid), i_data(data) {} : i_guid(guid), i_data(data) {}
void operator() (Map* map) void operator()(Map* map)
{ {
// We use spawn coords to spawn // We use spawn coords to spawn
if (map->IsLoaded(i_data->posX, i_data->posY)) if (map->IsLoaded(i_data->posX, i_data->posY))

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();
} }
}; };
@ -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; }
@ -508,7 +508,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
// 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,7 +588,7 @@ 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);
@ -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,22 +30,22 @@ 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");
@ -54,7 +54,7 @@ namespace FactorySelector
// 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,15 +82,15 @@ 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
@ -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;
@ -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;
@ -1206,7 +1206,7 @@ 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);
@ -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)
@ -1378,7 +1378,7 @@ bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Trigge
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,7 +248,7 @@ 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, "
@ -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

@ -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());
@ -685,7 +685,7 @@ void LoadDBCStores(const std::string& dataPath)
!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;
@ -748,7 +748,7 @@ 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;
@ -757,18 +757,18 @@ WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid
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

View file

@ -44,7 +44,7 @@ struct AchievementEntry
uint32 factionFlag; // 1 m_faction -1=all, 0=horde, 1=alliance uint32 factionFlag; // 1 m_faction -1=all, 0=horde, 1=alliance
uint32 mapID; // 2 m_instance_id -1=none uint32 mapID; // 2 m_instance_id -1=none
//uint32 parentAchievement; // 3 m_supercedes its Achievement parent (can`t start while parent uncomplete, use its Criteria if don`t have own, use its progress on begin) //uint32 parentAchievement; // 3 m_supercedes its Achievement parent (can`t start while parent uncomplete, use its Criteria if don`t have own, use its progress on begin)
char *name[16]; // 4-19 m_title_lang char* name[16]; // 4-19 m_title_lang
//uint32 name_flags; // 20 string flags //uint32 name_flags; // 20 string flags
//char *description[16]; // 21-36 m_description_lang //char *description[16]; // 21-36 m_description_lang
//uint32 desc_flags; // 37 string flags //uint32 desc_flags; // 37 string flags
@ -889,12 +889,12 @@ struct FactionTemplateEntry
// helpers // helpers
bool IsFriendlyTo(FactionTemplateEntry const& entry) const bool IsFriendlyTo(FactionTemplateEntry const& entry) const
{ {
if(entry.faction) if (entry.faction)
{ {
for(int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
if (enemyFaction[i] == entry.faction) if (enemyFaction[i] == entry.faction)
return false; return false;
for(int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
if (friendFaction[i] == entry.faction) if (friendFaction[i] == entry.faction)
return true; return true;
} }
@ -902,12 +902,12 @@ struct FactionTemplateEntry
} }
bool IsHostileTo(FactionTemplateEntry const& entry) const bool IsHostileTo(FactionTemplateEntry const& entry) const
{ {
if(entry.faction) if (entry.faction)
{ {
for(int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
if (enemyFaction[i] == entry.faction) if (enemyFaction[i] == entry.faction)
return true; return true;
for(int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
if (friendFaction[i] == entry.faction) if (friendFaction[i] == entry.faction)
return false; return false;
} }
@ -916,7 +916,7 @@ struct FactionTemplateEntry
bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) !=0; } bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) !=0; }
bool IsNeutralToAll() const bool IsNeutralToAll() const
{ {
for(int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
if (enemyFaction[i] != 0) if (enemyFaction[i] != 0)
return false; return false;
return hostileMask == 0 && friendlyMask == 0; return hostileMask == 0 && friendlyMask == 0;
@ -1361,8 +1361,8 @@ struct ScalingStatValuesEntry
//uint32 unk2; // 19 unk, probably also Armor for level (flag 0x80000?) //uint32 unk2; // 19 unk, probably also Armor for level (flag 0x80000?)
uint32 armorMod2[4]; // 20-23 Armor for level uint32 armorMod2[4]; // 20-23 Armor for level
/*struct ScalingStatValuesEntry /*struct ScalingStatValuesEntry
{ {
m_ID m_ID
m_charlevel m_charlevel
m_shoulderBudget m_shoulderBudget
@ -1387,17 +1387,17 @@ struct ScalingStatValuesEntry
m_leatherChestArmor m_leatherChestArmor
m_mailChestArmor m_mailChestArmor
m_plateChestArmor m_plateChestArmor
};*/ };*/
uint32 getssdMultiplier(uint32 mask) const uint32 getssdMultiplier(uint32 mask) const
{ {
if (mask & 0x4001F) if (mask & 0x4001F)
{ {
if(mask & 0x00000001) return ssdMultiplier[0]; if (mask & 0x00000001) return ssdMultiplier[0];
if(mask & 0x00000002) return ssdMultiplier[1]; if (mask & 0x00000002) return ssdMultiplier[1];
if(mask & 0x00000004) return ssdMultiplier[2]; if (mask & 0x00000004) return ssdMultiplier[2];
if(mask & 0x00000008) return ssdMultiplier2; if (mask & 0x00000008) return ssdMultiplier2;
if(mask & 0x00000010) return ssdMultiplier[3]; if (mask & 0x00000010) return ssdMultiplier[3];
if(mask & 0x00040000) return ssdMultiplier3; if (mask & 0x00040000) return ssdMultiplier3;
} }
return 0; return 0;
} }
@ -1406,15 +1406,15 @@ struct ScalingStatValuesEntry
{ {
if (mask & 0x00F001E0) if (mask & 0x00F001E0)
{ {
if(mask & 0x00000020) return armorMod[0]; if (mask & 0x00000020) return armorMod[0];
if(mask & 0x00000040) return armorMod[1]; if (mask & 0x00000040) return armorMod[1];
if(mask & 0x00000080) return armorMod[2]; if (mask & 0x00000080) return armorMod[2];
if(mask & 0x00000100) return armorMod[3]; if (mask & 0x00000100) return armorMod[3];
if(mask & 0x00100000) return armorMod2[0]; // cloth if (mask & 0x00100000) return armorMod2[0]; // cloth
if(mask & 0x00200000) return armorMod2[1]; // leather if (mask & 0x00200000) return armorMod2[1]; // leather
if(mask & 0x00400000) return armorMod2[2]; // mail if (mask & 0x00400000) return armorMod2[2]; // mail
if(mask & 0x00800000) return armorMod2[3]; // plate if (mask & 0x00800000) return armorMod2[3]; // plate
} }
return 0; return 0;
} }
@ -1423,12 +1423,12 @@ struct ScalingStatValuesEntry
{ {
if (mask & 0x7E00) if (mask & 0x7E00)
{ {
if(mask & 0x00000200) return dpsMod[0]; if (mask & 0x00000200) return dpsMod[0];
if(mask & 0x00000400) return dpsMod[1]; if (mask & 0x00000400) return dpsMod[1];
if(mask & 0x00000800) return dpsMod[2]; if (mask & 0x00000800) return dpsMod[2];
if(mask & 0x00001000) return dpsMod[3]; if (mask & 0x00001000) return dpsMod[3];
if(mask & 0x00002000) return dpsMod[4]; if (mask & 0x00002000) return dpsMod[4];
if(mask & 0x00004000) return dpsMod[5]; // not used? if (mask & 0x00004000) return dpsMod[5]; // not used?
} }
return 0; return 0;
} }
@ -1531,7 +1531,7 @@ struct ClassFamilyMask
explicit ClassFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) : Flags(familyFlags), Flags2(familyFlags2) {} explicit ClassFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) : Flags(familyFlags), Flags2(familyFlags2) {}
bool Empty() const { return Flags == 0 && Flags2 == 0; } bool Empty() const { return Flags == 0 && Flags2 == 0; }
bool operator! () const { return Empty(); } bool operator!() const { return Empty(); }
operator void const* () const { return Empty() ? NULL : this; }// for allow normal use in if(mask) operator void const* () const { return Empty() ? NULL : this; }// for allow normal use in if(mask)
bool IsFitToFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) const bool IsFitToFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) const

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;