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 "MapPersistentStateMgr.h"
void WorldSession::HandleCalendarGetCalendar(WorldPacket &/*recv_data*/)
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
{
DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_CALENDAR"); // empty
@ -44,13 +44,13 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &/*recv_data*/)
size_t p_counter = data.wpos();
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)
{
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->GetDifficulty());
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) 0; // raid reset count
data << (uint32) 0; // holidays count
/*
/*
for(uint32 i = 0; i < holidays_count; ++i)
{
data << uint32(0); // Holidays.dbc ID
@ -84,20 +84,20 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket &/*recv_data*/)
data << ""; // Holidays.dbc textureFilename
}
*/
*/
//DEBUG_LOG("Sending calendar");
//data.hexlike();
SendPacket(&data);
}
void WorldSession::HandleCalendarGetEvent(WorldPacket &recv_data)
void WorldSession::HandleCalendarGetEvent(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_EVENT");
recv_data.hexlike();
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");
recv_data.hexlike();
@ -106,14 +106,14 @@ void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data)
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");
recv_data.hexlike();
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");
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");
recv_data.hexlike();
@ -168,7 +168,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket &recv_data)
//recv_data >> uint32
}
void WorldSession::HandleCalendarRemoveEvent(WorldPacket &recv_data)
void WorldSession::HandleCalendarRemoveEvent(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_CALENDAR_REMOVE_EVENT");
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");
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");
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");
recv_data.hexlike();
@ -217,7 +217,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket &recv_data)
//recv_data >> uint32
}
void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data)
void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_REMOVE_INVITE");
recv_data.hexlike();
@ -229,7 +229,7 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket &recv_data)
//recv_data >> uint64
}
void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data)
void WorldSession::HandleCalendarEventStatus(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_STATUS");
recv_data.hexlike();
@ -242,7 +242,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket &recv_data)
//recv_data >> uint32
}
void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data)
void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_CALENDAR_EVENT_MODERATOR_STATUS");
recv_data.hexlike();
@ -255,7 +255,7 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket &recv_data)
//recv_data >> uint32
}
void WorldSession::HandleCalendarComplain(WorldPacket &recv_data)
void WorldSession::HandleCalendarComplain(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_CALENDAR_COMPLAIN");
recv_data.hexlike();
@ -266,7 +266,7 @@ void WorldSession::HandleCalendarComplain(WorldPacket &recv_data)
//recv_data >> uint64
}
void WorldSession::HandleCalendarGetNumPending(WorldPacket & /*recv_data*/)
void WorldSession::HandleCalendarGetNumPending(WorldPacket& /*recv_data*/)
{
DEBUG_LOG("WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); // empty

View file

@ -37,7 +37,7 @@ Camera::~Camera()
m_source->GetViewPoint().Detach(this);
}
void Camera::ReceivePacket(WorldPacket *data)
void Camera::ReceivePacket(WorldPacket* data)
{
m_owner.SendDirectMessage(data);
}
@ -52,7 +52,7 @@ void Camera::UpdateForCurrentViewPoint()
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);
@ -132,16 +132,16 @@ void Camera::UpdateVisibilityOf(WorldObject* target)
}
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);
}
template void Camera::UpdateVisibilityOf(Player* , 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(GameObject* , UpdateData& , std::set<WorldObject*>& );
template void Camera::UpdateVisibilityOf(DynamicObject* , 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(Corpse* , UpdateData& , std::set<WorldObject*>&);
template void Camera::UpdateVisibilityOf(GameObject* , UpdateData& , std::set<WorldObject*>&);
template void Camera::UpdateVisibilityOf(DynamicObject* , UpdateData& , std::set<WorldObject*>&);
void Camera::UpdateVisibilityForOwner()
{

View file

@ -43,16 +43,16 @@ class MANGOS_DLL_SPEC Camera
// set camera's view to any worldobject
// 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
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
void ResetView(bool update_far_sight_field = true);
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 ReceivePacket(WorldPacket *data);
void ReceivePacket(WorldPacket* data);
// updates visibility of worldobjects around viewpoint for camera's owner
void UpdateVisibilityForOwner();
@ -84,7 +84,7 @@ class MANGOS_DLL_SPEC ViewPoint
typedef std::list<Camera*> CameraList;
CameraList m_cameras;
GridType * m_grid;
GridType* m_grid;
void Attach(Camera* c) { m_cameras.push_back(c); }
void Detach(Camera* c) { m_cameras.remove(c); }
@ -93,15 +93,15 @@ class MANGOS_DLL_SPEC ViewPoint
{
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)();
}
}
}
public:
public:
ViewPoint() : m_grid(0) {}
~ViewPoint();
@ -109,7 +109,7 @@ public:
bool hasViewers() const { return !m_cameras.empty(); }
// these events are called when viewpoint changes visibility state
void Event_AddedToWorld(GridType *grid)
void Event_AddedToWorld(GridType* grid)
{
m_grid = grid;
CameraCall(&Camera::Event_AddedToWorld);
@ -121,7 +121,7 @@ public:
CameraCall(&Camera::Event_RemovedFromWorld);
}
void Event_GridChanged(GridType *grid)
void Event_GridChanged(GridType* grid)
{
m_grid = grid;
CameraCall(&Camera::Event_Moved);

View file

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

View file

@ -51,7 +51,7 @@ inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
template<class T, class CONTAINER>
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());
}
@ -59,7 +59,7 @@ Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &v
template<class T, class CONTAINER>
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)
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
//we had some problems with DynamicObjects, which pass radius = 0.0f (DB issue?)
//maybe it is better to just return when radius <= 0.0f?
if(radius <= 0.0f)
if (radius <= 0.0f)
{
m.Visit(*this, visitor);
return;
}
//lets limit the upper value for search radius
if(radius > 333.0f)
if (radius > 333.0f)
radius = 333.0f;
//lets calculate object coord offsets from cell borders.
CellArea area = Cell::CalculateCellArea(x, y, radius);
//if radius fits inside standing cell
if(!area)
if (!area)
{
m.Visit(*this, visitor);
return;
}
CellPair &begin_cell = area.low_bound;
CellPair &end_cell = area.high_bound;
CellPair& begin_cell = area.low_bound;
CellPair& end_cell = area.high_bound;
//visit all cells, found in CalculateCellArea()
//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
//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);
return;
@ -102,13 +102,13 @@ Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor<T, CONTAINER> &v
m.Visit(*this, visitor);
// 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);
//lets skip standing cell since we already visited it
if(cell_pair != standing_cell)
if (cell_pair != standing_cell)
{
Cell r_zone(cell_pair);
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>
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
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;
//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);
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
//visited at previous step, so just return from procedure...
if(x_shift == 0)
if (x_shift == 0)
return;
uint32 y_start = end_cell.y_coord;
@ -172,7 +172,7 @@ Cell::VisitCircle(TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, const Cel
}
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()));
Cell cell(p);
@ -183,7 +183,7 @@ inline void Cell::VisitGridObjects(const WorldObject *center_obj, T &visitor, fl
}
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()));
Cell cell(p);
@ -194,7 +194,7 @@ inline void Cell::VisitWorldObjects(const WorldObject *center_obj, T &visitor, f
}
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()));
Cell cell(p);
@ -207,7 +207,7 @@ inline void Cell::VisitAllObjects(const WorldObject *center_obj, T &visitor, flo
}
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));
Cell cell(p);
@ -218,7 +218,7 @@ inline void Cell::VisitGridObjects(float x, float y, Map *map, T &visitor, float
}
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));
Cell cell(p);
@ -229,7 +229,7 @@ inline void Cell::VisitWorldObjects(float x, float y, Map *map, T &visitor, floa
}
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));
Cell cell(p);

View file

@ -22,24 +22,24 @@
#include "SocialMgr.h"
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
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
m_announce = false; // no join/leave announces
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;
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;
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;
else // for all other channels
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;
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);
SendToOne(&data, p);
@ -70,31 +70,31 @@ void Channel::Join(ObjectGuid p, const char *pass)
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);
SendToOne(&data, p);
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);
SendToOne(&data, p);
return;
}
if(plr->GetGuildId() && (GetFlags() == 0x38))
if (plr->GetGuildId() && (GetFlags() == 0x38))
return;
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);
SendToAll(&data);
@ -112,7 +112,7 @@ void Channel::Join(ObjectGuid p, const char *pass)
JoinNotify(p);
// if no owner first logged will become
if(!IsConstant() && !m_ownerGuid)
if (!IsConstant() && !m_ownerGuid)
{
SetOwner(p, (m_players.size() > 1 ? true : false));
m_players[p].SetModerator(true);
@ -123,7 +123,7 @@ void Channel::Leave(ObjectGuid p, bool send)
{
if (!IsOn(p))
{
if(send)
if (send)
{
WorldPacket data;
MakeNotMember(&data);
@ -132,14 +132,14 @@ void Channel::Leave(ObjectGuid p, bool send)
}
else
{
Player *plr = sObjectMgr.GetPlayer(p);
Player* plr = sObjectMgr.GetPlayer(p);
if(send)
if (send)
{
WorldPacket data;
MakeYouLeft(&data);
SendToOne(&data, p);
if(plr)
if (plr)
plr->LeftChannel(this);
data.clear();
}
@ -147,7 +147,7 @@ void Channel::Leave(ObjectGuid p, bool send)
bool changeowner = m_players[p].IsOwner();
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;
MakeLeft(&data, p);
@ -156,7 +156,7 @@ void Channel::Leave(ObjectGuid p, bool send)
LeaveNotify(p);
if(changeowner)
if (changeowner)
{
ObjectGuid newowner = !m_players.empty() ? m_players.begin()->second.player : ObjectGuid();
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;
Player *gplr = sObjectMgr.GetPlayer(good);
Player* gplr = sObjectMgr.GetPlayer(good);
if (gplr)
sec = gplr->GetSession()->GetSecurity();
@ -185,7 +185,7 @@ void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban)
}
else
{
Player *bad = sObjectMgr.GetPlayer(badname);
Player* bad = sObjectMgr.GetPlayer(badname);
if (bad == NULL || !IsOn(bad->GetObjectGuid()))
{
WorldPacket data;
@ -204,7 +204,7 @@ void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban)
WorldPacket data;
if(ban && !IsBanned(bad->GetObjectGuid()))
if (ban && !IsBanned(bad->GetObjectGuid()))
{
m_banned.insert(bad->GetObjectGuid());
MakePlayerBanned(&data, bad->GetObjectGuid(), good);
@ -216,7 +216,7 @@ void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban)
m_players.erase(bad->GetObjectGuid());
bad->LeftChannel(this);
if(changeowner)
if (changeowner)
{
ObjectGuid newowner = !m_players.empty() ? good : ObjectGuid();
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;
Player *gplr = sObjectMgr.GetPlayer(good);
if(gplr)
Player* gplr = sObjectMgr.GetPlayer(good);
if (gplr)
sec = gplr->GetSession()->GetSecurity();
if (!IsOn(good))
@ -238,7 +238,7 @@ void Channel::UnBan(ObjectGuid good, const char *badname)
MakeNotMember(&data);
SendToOne(&data, good);
}
else if(!m_players[good].IsModerator() && sec < SEC_GAMEMASTER)
else if (!m_players[good].IsModerator() && sec < SEC_GAMEMASTER)
{
WorldPacket data;
MakeNotModerator(&data);
@ -246,8 +246,8 @@ void Channel::UnBan(ObjectGuid good, const char *badname)
}
else
{
Player *bad = sObjectMgr.GetPlayer(badname);
if(bad == NULL || !IsBanned(bad->GetObjectGuid()))
Player* bad = sObjectMgr.GetPlayer(badname);
if (bad == NULL || !IsBanned(bad->GetObjectGuid()))
{
WorldPacket data;
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;
Player *plr = sObjectMgr.GetPlayer(p);
Player* plr = sObjectMgr.GetPlayer(p);
if (plr)
sec = plr->GetSession()->GetSecurity();
@ -277,7 +277,7 @@ void Channel::Password(ObjectGuid p, const char *pass)
MakeNotMember(&data);
SendToOne(&data, p);
}
else if(!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
{
WorldPacket 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)
return;
@ -307,7 +307,7 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
MakeNotMember(&data);
SendToOne(&data, p);
}
else if(!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
{
WorldPacket data;
MakeNotModerator(&data);
@ -315,8 +315,8 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
}
else
{
Player *newp = sObjectMgr.GetPlayer(p2n);
if(!newp)
Player* newp = sObjectMgr.GetPlayer(p2n);
if (!newp)
{
WorldPacket data;
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()];
if(p == m_ownerGuid && newp->GetObjectGuid() == m_ownerGuid && mod)
if (p == m_ownerGuid && newp->GetObjectGuid() == m_ownerGuid && mod)
return;
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
// 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) &&
plr->GetTeam() != newp->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL) )
if ((plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) &&
plr->GetTeam() != newp->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
{
WorldPacket data;
MakePlayerNotFound(&data, p2n);
@ -347,7 +347,7 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
return;
}
if(m_ownerGuid == newp->GetObjectGuid() && m_ownerGuid != p)
if (m_ownerGuid == newp->GetObjectGuid() && m_ownerGuid != p)
{
WorldPacket data;
MakeNotOwner(&data);
@ -355,16 +355,16 @@ void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
return;
}
if(mod)
if (mod)
SetModerator(newp->GetObjectGuid(), set);
else
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)
return;
@ -378,7 +378,7 @@ void Channel::SetOwner(ObjectGuid p, const char *newname)
return;
}
if(sec < SEC_GAMEMASTER && p != m_ownerGuid)
if (sec < SEC_GAMEMASTER && p != m_ownerGuid)
{
WorldPacket data;
MakeNotOwner(&data);
@ -386,7 +386,7 @@ void Channel::SetOwner(ObjectGuid p, const char *newname)
return;
}
Player *newp = sObjectMgr.GetPlayer(newname);
Player* newp = sObjectMgr.GetPlayer(newname);
if (newp == NULL || !IsOn(newp->GetObjectGuid()))
{
WorldPacket data;
@ -395,7 +395,7 @@ void Channel::SetOwner(ObjectGuid p, const char *newname)
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;
MakePlayerNotFound(&data, newname);
@ -446,9 +446,9 @@ void Channel::List(Player* player)
AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST);
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
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all
@ -470,8 +470,8 @@ void Channel::List(Player* player)
void Channel::Announce(ObjectGuid p)
{
uint32 sec = 0;
Player *plr = sObjectMgr.GetPlayer(p);
if(plr)
Player* plr = sObjectMgr.GetPlayer(p);
if (plr)
sec = plr->GetSession()->GetSecurity();
if (!IsOn(p))
@ -491,7 +491,7 @@ void Channel::Announce(ObjectGuid p)
m_announce = !m_announce;
WorldPacket data;
if(m_announce)
if (m_announce)
MakeAnnouncementsOn(&data, p);
else
MakeAnnouncementsOff(&data, p);
@ -502,8 +502,8 @@ void Channel::Announce(ObjectGuid p)
void Channel::Moderate(ObjectGuid p)
{
uint32 sec = 0;
Player *plr = sObjectMgr.GetPlayer(p);
if(plr)
Player* plr = sObjectMgr.GetPlayer(p);
if (plr)
sec = plr->GetSession()->GetSecurity();
if (!IsOn(p))
@ -523,7 +523,7 @@ void Channel::Moderate(ObjectGuid p)
m_moderate = !m_moderate;
WorldPacket data;
if(m_moderate)
if (m_moderate)
MakeModerationOn(&data, p);
else
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)
return;
@ -539,8 +539,8 @@ void Channel::Say(ObjectGuid p, const char *what, uint32 lang)
lang = LANG_UNIVERSAL;
uint32 sec = 0;
Player *plr = sObjectMgr.GetPlayer(p);
if(plr)
Player* plr = sObjectMgr.GetPlayer(p);
if (plr)
sec = plr->GetSession()->GetSecurity();
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))
{
@ -590,8 +590,8 @@ void Channel::Invite(ObjectGuid p, const char *newname)
return;
}
Player *newp = sObjectMgr.GetPlayer(newname);
if(!newp)
Player* newp = sObjectMgr.GetPlayer(newname);
if (!newp)
{
WorldPacket data;
MakePlayerNotFound(&data, newname);
@ -599,7 +599,7 @@ void Channel::Invite(ObjectGuid p, const char *newname)
return;
}
Player *plr = sObjectMgr.GetPlayer(p);
Player* plr = sObjectMgr.GetPlayer(p);
if (!plr)
return;
@ -651,7 +651,7 @@ void Channel::SetOwner(ObjectGuid guid, bool exclaim)
MakeModeChange(&data, m_ownerGuid, oldFlag);
SendToAll(&data);
if(exclaim)
if (exclaim)
{
MakeOwnerChanged(&data, m_ownerGuid);
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)
if (Player *plr = sObjectMgr.GetPlayer(i->first))
for (PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i)
if (Player* plr = sObjectMgr.GetPlayer(i->first))
if (!p || !plr->GetSocial()->HasIgnore(p))
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);
}
@ -684,7 +684,7 @@ void Channel::DeVoice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/)
}
// 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 << uint8(notify_type);
@ -692,21 +692,21 @@ void Channel::MakeNotifyPacket(WorldPacket *data, uint8 notify_type)
}
// done 0x00
void Channel::MakeJoined(WorldPacket *data, ObjectGuid guid)
void Channel::MakeJoined(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_JOINED_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x01
void Channel::MakeLeft(WorldPacket *data, ObjectGuid guid)
void Channel::MakeLeft(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_LEFT_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x02
void Channel::MakeYouJoined(WorldPacket *data)
void Channel::MakeYouJoined(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_YOU_JOINED_NOTICE);
*data << uint8(GetFlags());
@ -715,7 +715,7 @@ void Channel::MakeYouJoined(WorldPacket *data)
}
// done 0x03
void Channel::MakeYouLeft(WorldPacket *data)
void Channel::MakeYouLeft(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE);
*data << uint32(GetChannelId());
@ -723,52 +723,52 @@ void Channel::MakeYouLeft(WorldPacket *data)
}
// done 0x04
void Channel::MakeWrongPassword(WorldPacket *data)
void Channel::MakeWrongPassword(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_WRONG_PASSWORD_NOTICE);
}
// done 0x05
void Channel::MakeNotMember(WorldPacket *data)
void Channel::MakeNotMember(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE);
}
// done 0x06
void Channel::MakeNotModerator(WorldPacket *data)
void Channel::MakeNotModerator(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE);
}
// done 0x07
void Channel::MakePasswordChanged(WorldPacket *data, ObjectGuid guid)
void Channel::MakePasswordChanged(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x08
void Channel::MakeOwnerChanged(WorldPacket *data, ObjectGuid guid)
void Channel::MakeOwnerChanged(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE);
*data << ObjectGuid(guid);
}
// 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);
*data << name;
}
// done 0x0A
void Channel::MakeNotOwner(WorldPacket *data)
void Channel::MakeNotOwner(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_NOT_OWNER_NOTICE);
}
// done 0x0B
void Channel::MakeChannelOwner(WorldPacket *data)
void Channel::MakeChannelOwner(WorldPacket* data)
{
std::string name = "";
@ -780,7 +780,7 @@ void Channel::MakeChannelOwner(WorldPacket *data)
}
// 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);
*data << ObjectGuid(guid);
@ -789,41 +789,41 @@ void Channel::MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags)
}
// done 0x0D
void Channel::MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid)
void Channel::MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x0E
void Channel::MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid)
void Channel::MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x0F
void Channel::MakeModerationOn(WorldPacket *data, ObjectGuid guid)
void Channel::MakeModerationOn(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x10
void Channel::MakeModerationOff(WorldPacket *data, ObjectGuid guid)
void Channel::MakeModerationOff(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x11
void Channel::MakeMuted(WorldPacket *data)
void Channel::MakeMuted(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_MUTED_NOTICE);
}
// 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);
*data << ObjectGuid(bad);
@ -831,13 +831,13 @@ void Channel::MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid goo
}
// done 0x13
void Channel::MakeBanned(WorldPacket *data)
void Channel::MakeBanned(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_BANNED_NOTICE);
}
// 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);
*data << ObjectGuid(bad);
@ -845,7 +845,7 @@ void Channel::MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid goo
}
// 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);
*data << ObjectGuid(bad);
@ -853,91 +853,91 @@ void Channel::MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid g
}
// done 0x16
void Channel::MakePlayerNotBanned(WorldPacket *data, ObjectGuid guid)
void Channel::MakePlayerNotBanned(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE);
*data << ObjectGuid(guid); // should be string!!
}
// done 0x17
void Channel::MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid)
void Channel::MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x18
void Channel::MakeInvite(WorldPacket *data, ObjectGuid guid)
void Channel::MakeInvite(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_INVITE_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x19
void Channel::MakeInviteWrongFaction(WorldPacket *data)
void Channel::MakeInviteWrongFaction(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_INVITE_WRONG_FACTION_NOTICE);
}
// done 0x1A
void Channel::MakeWrongFaction(WorldPacket *data)
void Channel::MakeWrongFaction(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_WRONG_FACTION_NOTICE);
}
// done 0x1B
void Channel::MakeInvalidName(WorldPacket *data)
void Channel::MakeInvalidName(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_INVALID_NAME_NOTICE);
}
// done 0x1C
void Channel::MakeNotModerated(WorldPacket *data)
void Channel::MakeNotModerated(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_NOT_MODERATED_NOTICE);
}
// 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);
*data << name;
}
// done 0x1E
void Channel::MakePlayerInviteBanned(WorldPacket *data, ObjectGuid guid)
void Channel::MakePlayerInviteBanned(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE);
*data << ObjectGuid(guid); // should be string!!
}
// done 0x1F
void Channel::MakeThrottled(WorldPacket *data)
void Channel::MakeThrottled(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_THROTTLED_NOTICE);
}
// done 0x20
void Channel::MakeNotInArea(WorldPacket *data)
void Channel::MakeNotInArea(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_NOT_IN_AREA_NOTICE);
}
// done 0x21
void Channel::MakeNotInLfg(WorldPacket *data)
void Channel::MakeNotInLfg(WorldPacket* data)
{
MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE);
}
// done 0x22
void Channel::MakeVoiceOn(WorldPacket *data, ObjectGuid guid)
void Channel::MakeVoiceOn(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE);
*data << ObjectGuid(guid);
}
// done 0x23
void Channel::MakeVoiceOff(WorldPacket *data, ObjectGuid guid)
void Channel::MakeVoiceOff(WorldPacket* data, ObjectGuid guid)
{
MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE);
*data << ObjectGuid(guid);

View file

@ -125,23 +125,23 @@ class Channel
uint8 flags;
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; }
void SetOwner(bool state)
{
if(state) flags |= MEMBER_FLAG_OWNER;
if (state) flags |= MEMBER_FLAG_OWNER;
else flags &= ~MEMBER_FLAG_OWNER;
}
bool IsModerator() { return flags & MEMBER_FLAG_MODERATOR; }
void SetModerator(bool state)
{
if(state) flags |= MEMBER_FLAG_MODERATOR;
if (state) flags |= MEMBER_FLAG_MODERATOR;
else flags &= ~MEMBER_FLAG_MODERATOR;
}
bool IsMuted() { return flags & MEMBER_FLAG_MUTED; }
void SetMuted(bool state)
{
if(state) flags |= MEMBER_FLAG_MUTED;
if (state) flags |= MEMBER_FLAG_MUTED;
else flags &= ~MEMBER_FLAG_MUTED;
}
};
@ -160,26 +160,26 @@ class Channel
uint8 GetFlags() const { return m_flags; }
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 KickOrBan(ObjectGuid good, const char *badname, bool ban);
void Kick(ObjectGuid good, const char *badname) { KickOrBan(good, badname, false); }
void Ban(ObjectGuid good, const char *badname) { KickOrBan(good, badname, true); }
void UnBan(ObjectGuid good, const char *badname);
void Password(ObjectGuid p, const char *pass);
void SetMode(ObjectGuid p, const char *p2n, bool mod, bool set);
void KickOrBan(ObjectGuid good, const char* badname, bool ban);
void Kick(ObjectGuid good, const char* badname) { KickOrBan(good, badname, false); }
void Ban(ObjectGuid good, const char* badname) { KickOrBan(good, badname, true); }
void UnBan(ObjectGuid good, const char* badname);
void Password(ObjectGuid p, const char* pass);
void SetMode(ObjectGuid p, const char* p2n, bool mod, bool set);
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 SetModerator(ObjectGuid p, const char *newname) { SetMode(p, newname, true, true); }
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 UnsetMute(ObjectGuid p, const char *newname) { SetMode(p, newname, false, false); }
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 SetMute(ObjectGuid p, const char* newname) { SetMode(p, newname, false, true); }
void UnsetMute(ObjectGuid p, const char* newname) { SetMode(p, newname, false, false); }
void List(Player* p);
void Announce(ObjectGuid p);
void Moderate(ObjectGuid p);
void Say(ObjectGuid p, const char *what, uint32 lang);
void Invite(ObjectGuid p, const char *newp);
void Say(ObjectGuid p, const char* what, uint32 lang);
void Invite(ObjectGuid p, const char* newp);
void Voice(ObjectGuid guid1, ObjectGuid guid2);
void DeVoice(ObjectGuid guid1, ObjectGuid guid2);
void JoinNotify(ObjectGuid guid); // invisible notify
@ -187,47 +187,47 @@ class Channel
private:
// 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
void MakeJoined(WorldPacket *data, ObjectGuid guid); //+ 0x00
void MakeLeft(WorldPacket *data, ObjectGuid guid); //+ 0x01
void MakeYouJoined(WorldPacket *data); //+ 0x02
void MakeYouLeft(WorldPacket *data); //+ 0x03
void MakeWrongPassword(WorldPacket *data); //? 0x04
void MakeNotMember(WorldPacket *data); //? 0x05
void MakeNotModerator(WorldPacket *data); //? 0x06
void MakePasswordChanged(WorldPacket *data, ObjectGuid guid); //+ 0x07
void MakeOwnerChanged(WorldPacket *data, ObjectGuid guid); //? 0x08
void MakePlayerNotFound(WorldPacket *data, const std::string& name); //+ 0x09
void MakeNotOwner(WorldPacket *data); //? 0x0A
void MakeChannelOwner(WorldPacket *data); //? 0x0B
void MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags);//+ 0x0C
void MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid); //+ 0x0D
void MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid); //+ 0x0E
void MakeModerationOn(WorldPacket *data, ObjectGuid guid); //+ 0x0F
void MakeModerationOff(WorldPacket *data, ObjectGuid guid); //+ 0x10
void MakeMuted(WorldPacket *data); //? 0x11
void MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x12
void MakeBanned(WorldPacket *data); //? 0x13
void MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x14
void MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good);//? 0x15
void MakePlayerNotBanned(WorldPacket *data, ObjectGuid guid); //? 0x16
void MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid); //+ 0x17
void MakeInvite(WorldPacket *data, ObjectGuid guid); //? 0x18
void MakeInviteWrongFaction(WorldPacket *data); //? 0x19
void MakeWrongFaction(WorldPacket *data); //? 0x1A
void MakeInvalidName(WorldPacket *data); //? 0x1B
void MakeNotModerated(WorldPacket *data); //? 0x1C
void MakePlayerInvited(WorldPacket *data, const std::string& name); //+ 0x1D
void MakePlayerInviteBanned(WorldPacket *data, ObjectGuid guid); //? 0x1E
void MakeThrottled(WorldPacket *data); //? 0x1F
void MakeNotInArea(WorldPacket *data); //? 0x20
void MakeNotInLfg(WorldPacket *data); //? 0x21
void MakeVoiceOn(WorldPacket *data, ObjectGuid guid); //+ 0x22
void MakeVoiceOff(WorldPacket *data, ObjectGuid guid); //+ 0x23
void MakeJoined(WorldPacket* data, ObjectGuid guid); //+ 0x00
void MakeLeft(WorldPacket* data, ObjectGuid guid); //+ 0x01
void MakeYouJoined(WorldPacket* data); //+ 0x02
void MakeYouLeft(WorldPacket* data); //+ 0x03
void MakeWrongPassword(WorldPacket* data); //? 0x04
void MakeNotMember(WorldPacket* data); //? 0x05
void MakeNotModerator(WorldPacket* data); //? 0x06
void MakePasswordChanged(WorldPacket* data, ObjectGuid guid); //+ 0x07
void MakeOwnerChanged(WorldPacket* data, ObjectGuid guid); //? 0x08
void MakePlayerNotFound(WorldPacket* data, const std::string& name); //+ 0x09
void MakeNotOwner(WorldPacket* data); //? 0x0A
void MakeChannelOwner(WorldPacket* data); //? 0x0B
void MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags);//+ 0x0C
void MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid); //+ 0x0D
void MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid); //+ 0x0E
void MakeModerationOn(WorldPacket* data, ObjectGuid guid); //+ 0x0F
void MakeModerationOff(WorldPacket* data, ObjectGuid guid); //+ 0x10
void MakeMuted(WorldPacket* data); //? 0x11
void MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x12
void MakeBanned(WorldPacket* data); //? 0x13
void MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x14
void MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good);//? 0x15
void MakePlayerNotBanned(WorldPacket* data, ObjectGuid guid); //? 0x16
void MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid); //+ 0x17
void MakeInvite(WorldPacket* data, ObjectGuid guid); //? 0x18
void MakeInviteWrongFaction(WorldPacket* data); //? 0x19
void MakeWrongFaction(WorldPacket* data); //? 0x1A
void MakeInvalidName(WorldPacket* data); //? 0x1B
void MakeNotModerated(WorldPacket* data); //? 0x1C
void MakePlayerInvited(WorldPacket* data, const std::string& name); //+ 0x1D
void MakePlayerInviteBanned(WorldPacket* data, ObjectGuid guid); //? 0x1E
void MakeThrottled(WorldPacket* data); //? 0x1F
void MakeNotInArea(WorldPacket* data); //? 0x20
void MakeNotInLfg(WorldPacket* data); //? 0x21
void MakeVoiceOn(WorldPacket* data, ObjectGuid guid); //+ 0x22
void MakeVoiceOff(WorldPacket* data, ObjectGuid guid); //+ 0x23
void SendToAll(WorldPacket *data, ObjectGuid p = ObjectGuid());
void SendToOne(WorldPacket *data, ObjectGuid who);
void SendToAll(WorldPacket* data, ObjectGuid p = ObjectGuid());
void SendToOne(WorldPacket* data, ObjectGuid who);
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(); }

View file

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

View file

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

View file

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

View file

@ -26,26 +26,26 @@
void CharacterDatabaseCleaner::CleanDatabase()
{
// config to disable
if(!sWorld.getConfig(CONFIG_BOOL_CLEAN_CHARACTER_DB))
if (!sWorld.getConfig(CONFIG_BOOL_CLEAN_CHARACTER_DB))
return;
sLog.outString("Cleaning character database...");
// check flags which clean ups are necessary
QueryResult* result = CharacterDatabase.PQuery("SELECT cleaning_flags FROM saved_variables");
if(!result)
if (!result)
return;
uint32 flags = (*result)[0].GetUInt32();
delete result;
// clean up
if(flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS)
if (flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS)
CleanCharacterAchievementProgress();
if(flags & CLEANING_FLAG_SKILLS)
if (flags & CLEANING_FLAG_SKILLS)
CleanCharacterSkills();
if(flags & CLEANING_FLAG_SPELLS)
if (flags & CLEANING_FLAG_SPELLS)
CleanCharacterSpell();
if(flags & CLEANING_FLAG_TALENTS)
if (flags & CLEANING_FLAG_TALENTS)
CleanCharacterTalent();
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))
{
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;
}
@ -66,7 +66,7 @@ void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table
{
bar.step();
Field *fields = result->Fetch();
Field* fields = result->Fetch();
uint32 id = fields[0].GetUInt32();
@ -88,7 +88,7 @@ void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table
if (found)
{
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)
{
TalentEntry const *talentInfo = sTalentStore.LookupEntry( talent_id );
if(!talentInfo)
TalentEntry const* talentInfo = sTalentStore.LookupEntry(talent_id);
if (!talentInfo)
return false;
return sTalentTabStore.LookupEntry( talentInfo->TalentTab );
return sTalentTabStore.LookupEntry(talentInfo->TalentTab);
}
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_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());
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());
// 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());
@ -114,21 +114,21 @@ bool LoginQueryHolder::Initialize()
class CharacterHandler
{
public:
void HandleCharEnumCallback(QueryResult * result, uint32 account)
void HandleCharEnumCallback(QueryResult* result, uint32 account)
{
WorldSession * session = sWorld.FindSession(account);
if(!session)
WorldSession* session = sWorld.FindSession(account);
if (!session)
{
delete result;
return;
}
session->HandleCharEnum(result);
}
void HandlePlayerLoginCallback(QueryResult * /*dummy*/, SqlQueryHolder * holder)
void HandlePlayerLoginCallback(QueryResult* /*dummy*/, SqlQueryHolder* holder)
{
if (!holder) return;
WorldSession *session = sWorld.FindSession(((LoginQueryHolder*)holder)->GetAccountId());
if(!session)
WorldSession* session = sWorld.FindSession(((LoginQueryHolder*)holder)->GetAccountId());
if (!session)
{
delete holder;
return;
@ -137,7 +137,7 @@ class CharacterHandler
}
} chrHandler;
void WorldSession::HandleCharEnum(QueryResult * result)
void WorldSession::HandleCharEnum(QueryResult* result)
{
WorldPacket data(SMSG_CHAR_ENUM, 100); // we guess size
@ -145,26 +145,26 @@ void WorldSession::HandleCharEnum(QueryResult * result)
data << num;
if( result )
if (result)
{
do
{
uint32 guidlow = (*result)[0].GetUInt32();
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;
}
while( result->NextRow() );
while (result->NextRow());
delete result;
}
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
CharacterDatabase.AsyncPQuery(&chrHandler, &CharacterHandler::HandleCharEnumCallback, GetAccountId(),
@ -194,7 +194,7 @@ void WorldSession::HandleCharEnumOpcode( WorldPacket & /*recv_data*/ )
PET_SAVE_AS_CURRENT, GetAccountId());
}
void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data)
{
std::string name;
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
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;
Team team = Player::TeamForRace(race_);
switch(team)
switch (team)
{
case ALLIANCE: disabled = mask & (1 << 0); break;
case HORDE: disabled = mask & (1 << 1); break;
}
if(disabled)
if (disabled)
{
data << (uint8)CHAR_CREATE_DISABLED;
SendPacket( &data );
SendPacket(&data);
return;
}
}
@ -236,10 +236,10 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_);
ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_);
if( !classEntry || !raceEntry )
if (!classEntry || !raceEntry)
{
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_);
return;
}
@ -249,7 +249,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
{
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_);
SendPacket( &data );
SendPacket(&data);
return;
}
@ -258,7 +258,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
{
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_);
SendPacket( &data );
SendPacket(&data);
return;
}
@ -266,7 +266,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if (!normalizePlayerName(name))
{
data << (uint8)CHAR_NAME_NO_NAME;
SendPacket( &data );
SendPacket(&data);
sLog.outError("Account:[%d] but tried to Create character with empty [name]", GetAccountId());
return;
}
@ -276,70 +276,70 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if (res != CHAR_NAME_SUCCESS)
{
data << uint8(res);
SendPacket( &data );
SendPacket(&data);
return;
}
if (GetSecurity() == SEC_PLAYER && sObjectMgr.IsReservedName(name))
{
data << (uint8)CHAR_NAME_RESERVED;
SendPacket( &data );
SendPacket(&data);
return;
}
if (sObjectMgr.GetPlayerGuidByName(name))
{
data << (uint8)CHAR_CREATE_NAME_IN_USE;
SendPacket( &data );
SendPacket(&data);
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)
{
Field *fields=resultacct->Fetch();
Field* fields=resultacct->Fetch();
uint32 acctcharcount = fields[0].GetUInt32();
delete resultacct;
if (acctcharcount >= sWorld.getConfig(CONFIG_UINT32_CHARACTERS_PER_ACCOUNT))
{
data << (uint8)CHAR_CREATE_ACCOUNT_LIMIT;
SendPacket( &data );
SendPacket(&data);
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;
if ( result )
if (result)
{
Field *fields = result->Fetch();
Field* fields = result->Fetch();
charcount = fields[0].GetUInt8();
delete result;
if (charcount >= sWorld.getConfig(CONFIG_UINT32_CHARACTERS_PER_REALM))
{
data << (uint8)CHAR_CREATE_SERVER_LIMIT;
SendPacket( &data );
SendPacket(&data);
return;
}
}
// speedup check for heroic class disabled case
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;
SendPacket( &data );
SendPacket(&data);
return;
}
// speedup check for heroic class disabled case
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;
SendPacket( &data );
SendPacket(&data);
return;
}
@ -351,38 +351,38 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
// if 0 then allowed creating without any characters
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");
if(result2)
if (result2)
{
Team team_= Player::TeamForRace(race_);
Field* field = result2->Fetch();
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();
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;
if(heroic_free_slots == 0)
if (heroic_free_slots == 0)
{
data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
SendPacket( &data );
SendPacket(&data);
delete result2;
return;
}
}
if(!have_req_level_for_heroic)
if (!have_req_level_for_heroic)
{
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;
}
}
@ -394,7 +394,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
if (acc_race == 0 || Player::TeamForRace(acc_race) != team_)
{
data << (uint8)CHAR_CREATE_PVP_TEAMS_VIOLATION;
SendPacket( &data );
SendPacket(&data);
delete result2;
return;
}
@ -404,36 +404,36 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
// TODO: check if cinematic already shown? (already logged in?; cinematic field)
while ((skipCinematics == CINEMATICS_SKIP_SAME_RACE && !have_same_race) || class_ == CLASS_DEATH_KNIGHT)
{
if(!result2->NextRow())
if (!result2->NextRow())
break;
field = result2->Fetch();
acc_race = field[1].GetUInt32();
if(!have_same_race)
if (!have_same_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();
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;
if(heroic_free_slots == 0)
if (heroic_free_slots == 0)
{
data << (uint8)CHAR_CREATE_UNIQUE_CLASS_LIMIT;
SendPacket( &data );
SendPacket(&data);
delete result2;
return;
}
}
if(!have_req_level_for_heroic)
if (!have_req_level_for_heroic)
{
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;
}
}
@ -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;
SendPacket( &data );
SendPacket(&data);
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))
{
// Player not create (race/class problem?)
delete pNewChar;
data << (uint8)CHAR_CREATE_ERROR;
SendPacket( &data );
SendPacket(&data);
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);
data << (uint8)CHAR_CREATE_SUCCESS;
SendPacket( &data );
SendPacket(&data);
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());
@ -483,13 +483,13 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
delete pNewChar; // created only to call SaveToDB()
}
void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
void WorldSession::HandleCharDeleteOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
// can't delete loaded character
if(sObjectMgr.GetPlayer(guid))
if (sObjectMgr.GetPlayer(guid))
return;
uint32 accountId = 0;
@ -500,39 +500,39 @@ void WorldSession::HandleCharDeleteOpcode( WorldPacket & recv_data )
{
WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_FAILED_GUILD_LEADER;
SendPacket( &data );
SendPacket(&data);
return;
}
// is arena team captain
if(sObjectMgr.GetArenaTeamByCaptain(guid))
if (sObjectMgr.GetArenaTeamByCaptain(guid))
{
WorldPacket data(SMSG_CHAR_DELETE, 1);
data << (uint8)CHAR_DELETE_FAILED_ARENA_CAPTAIN;
SendPacket( &data );
SendPacket(&data);
return;
}
uint32 lowguid = guid.GetCounter();
QueryResult *result = CharacterDatabase.PQuery("SELECT account,name FROM characters WHERE guid='%u'", lowguid);
if(result)
QueryResult* result = CharacterDatabase.PQuery("SELECT account,name FROM characters WHERE guid='%u'", lowguid);
if (result)
{
Field *fields = result->Fetch();
Field* fields = result->Fetch();
accountId = fields[0].GetUInt32();
name = fields[1].GetCppString();
delete result;
}
// prevent deleting other players' characters using cheating tools
if(accountId != GetAccountId())
if (accountId != GetAccountId())
return;
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);
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);
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);
data << (uint8)CHAR_DELETE_SUCCESS;
SendPacket( &data );
SendPacket(&data);
}
void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recv_data)
{
ObjectGuid playerGuid;
recv_data >> playerGuid;
if(PlayerLoading() || GetPlayer() != NULL)
if (PlayerLoading() || GetPlayer() != NULL)
{
sLog.outError("Player tryes to login again, AccountId = %d", GetAccountId());
return;
@ -558,9 +558,9 @@ void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
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())
{
delete holder; // delete all unprocessed queries
@ -571,15 +571,15 @@ void WorldSession::HandlePlayerLoginOpcode( WorldPacket & recv_data )
CharacterDatabase.DelayQueryHolder(&chrHandler, &CharacterHandler::HandlePlayerLoginCallback, holder);
}
void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
{
ObjectGuid playerGuid = holder->GetGuid();
Player *pCurrChar = new Player(this);
Player* pCurrChar = new Player(this);
pCurrChar->GetMotionMaster()->Initialize();
// "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
delete pCurrChar; // delete it manually
@ -592,7 +592,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
pCurrChar->SendDungeonDifficulty(false);
WorldPacket data( SMSG_LOGIN_VERIFY_WORLD, 20 );
WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20);
data << pCurrChar->GetMapId();
data << pCurrChar->GetPositionX();
data << pCurrChar->GetPositionY();
@ -619,7 +619,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
std::string::size_type pos, nextpos;
pos = 0;
while ( (nextpos= str_motd.find('@',pos)) != std::string::npos )
while ((nextpos= str_motd.find('@',pos)) != std::string::npos)
{
if (nextpos != pos)
{
@ -637,37 +637,37 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
data.put(0, linecount);
SendPacket( &data );
DEBUG_LOG( "WORLD: Sent motd (SMSG_MOTD)" );
SendPacket(&data);
DEBUG_LOG("WORLD: Sent motd (SMSG_MOTD)");
}
//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->SetRank(fields[1].GetUInt32());
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->SetRank(0);
}
if(pCurrChar->GetGuildId() != 0)
if (pCurrChar->GetGuildId() != 0)
{
Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId());
if(guild)
if (guild)
{
data.Initialize(SMSG_GUILD_EVENT, (1+1+guild->GetMOTD().size()+1));
data << uint8(GE_MOTD);
data << uint8(1);
data << guild->GetMOTD();
SendPacket(&data);
DEBUG_LOG( "WORLD: Sent guild-motd (SMSG_GUILD_EVENT)" );
DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)");
guild->DisplayGuildBankTabsInfo(this);
@ -689,11 +689,11 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
pCurrChar->SendInitialPacketsBeforeAddToMap();
//Show cinematic at the first time that player login
if( !pCurrChar->getCinematic() )
if (!pCurrChar->getCinematic())
{
pCurrChar->setCinematic(1);
if(ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass()))
if (ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass()))
{
if (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)
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());
else
pCurrChar->TeleportToHomebind();
@ -726,10 +726,10 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
stmt = LoginDatabase.CreateStatement(updAccount, "UPDATE account SET active_realm_id = ? WHERE id = ?");
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)
if (Group *group = pCurrChar->GetGroup())
if (Group* group = pCurrChar->GetGroup())
group->SendUpdate();
// friend status
@ -742,7 +742,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
if (pCurrChar->m_deathState != ALIVE)
{
// 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, 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();
// 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);
// Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned)
pCurrChar->LoadPet();
// 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);
if(pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
pCurrChar->SetContestedPvP();
// Apply at_login requests
if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
{
pCurrChar->resetSpells();
SendNotification(LANG_RESET_SPELLS);
}
if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
{
pCurrChar->resetTalents(true,true);
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)",
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);
m_playerLoading = false;
@ -815,9 +815,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *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;
uint8 flag;
@ -828,7 +828,7 @@ void WorldSession::HandleSetFactionAtWarOpcode( WorldPacket & recv_data )
GetPlayer()->GetReputationMgr().SetAtWar(repListID, flag);
}
void WorldSession::HandleTutorialFlagOpcode( WorldPacket & recv_data )
void WorldSession::HandleTutorialFlagOpcode(WorldPacket& recv_data)
{
uint32 iFlag;
recv_data >> iFlag;
@ -841,26 +841,26 @@ void WorldSession::HandleTutorialFlagOpcode( WorldPacket & recv_data )
}
uint32 rInt = (iFlag % 32);
uint32 tutflag = GetTutorialInt( wInt );
uint32 tutflag = GetTutorialInt(wInt);
tutflag |= (1 << rInt);
SetTutorialInt( wInt, tutflag );
SetTutorialInt(wInt, tutflag);
//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)
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)
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");
int32 repId;
@ -868,7 +868,7 @@ void WorldSession::HandleSetWatchedFactionOpcode(WorldPacket & recv_data)
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");
uint32 replistid;
@ -878,13 +878,13 @@ void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket & recv_data)
_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());
_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());
_player->ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK);
@ -903,7 +903,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
{
WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(CHAR_NAME_NO_NAME);
SendPacket( &data );
SendPacket(&data);
return;
}
@ -912,7 +912,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
{
WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(res);
SendPacket( &data );
SendPacket(&data);
return;
}
@ -921,7 +921,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data)
{
WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(CHAR_NAME_RESERVED);
SendPacket( &data );
SendPacket(&data);
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);
if(!session)
WorldSession* session = sWorld.FindSession(accountId);
if (!session)
{
if(result) delete result;
if (result) delete result;
return;
}
@ -950,7 +950,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin
{
WorldPacket data(SMSG_CHAR_RENAME, 1);
data << uint8(CHAR_CREATE_ERROR);
session->SendPacket( &data );
session->SendPacket(&data);
return;
}
@ -982,7 +982,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
// not accept declined names for unsupported languages
std::string name;
if(!sObjectMgr.GetPlayerNameByGUID(guid, name))
if (!sObjectMgr.GetPlayerNameByGUID(guid, name))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
@ -992,7 +992,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
}
std::wstring wname;
if(!Utf8toWStr(name, wname))
if (!Utf8toWStr(name, wname))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
@ -1001,7 +1001,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
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);
data << uint32(1);
@ -1015,7 +1015,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
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);
data << uint32(1);
@ -1024,10 +1024,10 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
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];
if(!normalizePlayerName(declinedname.name[i]))
if (!normalizePlayerName(declinedname.name[i]))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
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);
data << uint32(1);
@ -1046,7 +1046,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
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.BeginTransaction();
@ -1061,7 +1061,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data)
SendPacket(&data);
}
void WorldSession::HandleAlterAppearanceOpcode( WorldPacket & recv_data )
void WorldSession::HandleAlterAppearanceOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("CMSG_ALTER_APPEARANCE");
@ -1079,12 +1079,12 @@ void WorldSession::HandleAlterAppearanceOpcode( WorldPacket & recv_data )
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;
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;
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
// 1,3 - not enough money
// 2 - you have to seat on barber chair
if(_player->GetMoney() < Cost)
if (_player->GetMoney() < Cost)
{
WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4);
data << uint32(1); // no money
@ -1120,18 +1120,18 @@ void WorldSession::HandleAlterAppearanceOpcode( WorldPacket & recv_data )
_player->SetStandState(0); // stand up
}
void WorldSession::HandleRemoveGlyphOpcode( WorldPacket & recv_data )
void WorldSession::HandleRemoveGlyphOpcode(WorldPacket& recv_data)
{
uint32 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);
return;
}
if(_player->GetGlyph(slot))
if (_player->GetGlyph(slot))
{
_player->ApplyGlyph(slot, false);
_player->SetGlyph(slot, 0);
@ -1150,16 +1150,16 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
uint8 gender, skin, face, hairStyle, hairColor, facialHair;
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)
{
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(CHAR_CREATE_ERROR);
SendPacket( &data );
SendPacket(&data);
return;
}
Field *fields = result->Fetch();
Field* fields = result->Fetch();
uint32 at_loginFlags = fields[0].GetUInt32();
delete result;
@ -1167,7 +1167,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
{
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(CHAR_CREATE_ERROR);
SendPacket( &data );
SendPacket(&data);
return;
}
@ -1176,7 +1176,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
{
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(CHAR_NAME_NO_NAME);
SendPacket( &data );
SendPacket(&data);
return;
}
@ -1185,7 +1185,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
{
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(res);
SendPacket( &data );
SendPacket(&data);
return;
}
@ -1194,7 +1194,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
{
WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1);
data << uint8(CHAR_NAME_RESERVED);
SendPacket( &data );
SendPacket(&data);
return;
}
@ -1229,7 +1229,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data)
SendPacket(&data);
}
void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("CMSG_EQUIPMENT_SET_SAVE");
@ -1243,7 +1243,7 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
recv_data >> name;
recv_data >> iconName;
if(index >= MAX_EQUIPMENT_SET_INDEX) // client set slots amount
if (index >= MAX_EQUIPMENT_SET_INDEX) // client set slots amount
return;
EquipmentSet eqSet;
@ -1253,7 +1253,7 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
eqSet.IconName = iconName;
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;
@ -1267,12 +1267,12 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
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;
if(item && item->GetObjectGuid() != itemGuid) // cheating check 2
if (item && item->GetObjectGuid() != itemGuid) // cheating check 2
return;
eqSet.Items[i] = itemGuid.GetCounter();
@ -1281,7 +1281,7 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket &recv_data)
_player->SetEquipmentSet(index, eqSet);
}
void WorldSession::HandleEquipmentSetDeleteOpcode(WorldPacket &recv_data)
void WorldSession::HandleEquipmentSetDeleteOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("CMSG_EQUIPMENT_SET_DELETE");
@ -1292,12 +1292,12 @@ void WorldSession::HandleEquipmentSetDeleteOpcode(WorldPacket &recv_data)
_player->DeleteEquipmentSet(setGuid.GetRawValue());
}
void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket &recv_data)
void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket& recv_data)
{
DEBUG_LOG("CMSG_EQUIPMENT_SET_USE");
recv_data.hexlike();
for(uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
{
ObjectGuid itemGuid;
uint8 srcbag, srcslot;
@ -1311,22 +1311,22 @@ void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket &recv_data)
if (itemGuid.GetRawValue() == 1)
continue;
Item *item = _player->GetItemByGuid(itemGuid);
Item* item = _player->GetItemByGuid(itemGuid);
uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);
if(!item)
if (!item)
{
Item *uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if(!uItem)
Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!uItem)
continue;
ItemPosCountVec sDest;
InventoryResult msg = _player->CanStoreItem( NULL_BAG, NULL_SLOT, sDest, uItem, false );
if(msg == EQUIP_ERR_OK)
InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sDest, uItem, false);
if (msg == EQUIP_ERR_OK)
{
_player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
_player->StoreItem( sDest, uItem, true );
_player->StoreItem(sDest, uItem, true);
}
else
_player->SendEquipError(msg, uItem, NULL);
@ -1334,7 +1334,7 @@ void WorldSession::HandleEquipmentSetUseOpcode(WorldPacket &recv_data)
continue;
}
if(item->GetPos() == dstpos)
if (item->GetPos() == dstpos)
continue;
_player->SwapItem(item->GetPos(), dstpos);

View file

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

View file

@ -47,12 +47,12 @@ class Unit;
class ChatCommand
{
public:
const char * Name;
const char* Name;
uint32 SecurityLevel; // function pointer required correct align (use uint32)
bool AllowConsole;
bool (ChatHandler::*Handler)(char* args);
std::string Help;
ChatCommand * ChildCommands;
ChatCommand* ChildCommands;
};
enum ChatCommandSearchResult
@ -69,34 +69,34 @@ class MANGOS_DLL_SPEC ChatHandler
explicit ChatHandler(Player* player);
~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; }
// function with different implementation for chat/console
virtual const char *GetMangosString(int32 entry) const;
const char *GetOnOffStr(bool value) const;
virtual const char* GetMangosString(int32 entry) const;
const char* GetOnOffStr(bool value) const;
virtual void SendSysMessage( const char *str);
virtual void SendSysMessage(const char* str);
void SendSysMessage( int32 entry);
void PSendSysMessage( const char *format, ...) ATTR_PRINTF(2,3);
void PSendSysMessage( int32 entry, ... );
void SendSysMessage(int32 entry);
void PSendSysMessage(const char* format, ...) ATTR_PRINTF(2,3);
void PSendSysMessage(int32 entry, ...);
bool ParseCommands(const char* 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 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 LogCommand(char const* fullcmd);
bool ShowHelpForCommand(ChatCommand *table, const char* cmd);
bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd);
bool ShowHelpForCommand(ChatCommand* table, const char* 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);
void CheckIntegrity(ChatCommand *table, ChatCommand *parentCommand);
void CheckIntegrity(ChatCommand* table, ChatCommand* parentCommand);
ChatCommand* getCommandTable();
bool HandleAccountCommand(char* args);
@ -653,16 +653,16 @@ class MANGOS_DLL_SPEC ChatHandler
// Utility methods for commands
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 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 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 ShowFactionListHelper(FactionEntry const* factionEntry, LocaleConstant loc, FactionState const* repState = NULL, Player* target = NULL);
void ShowItemListHelper(uint32 itemId, int 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);
void ShowSpellListHelper(Player* target, SpellEntry const* spellInfo, LocaleConstant loc);
void ShowPoolListHelper(uint16 pool_id);
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);
bool LookupPlayerSearchCommand(QueryResult* result, uint32* limit = NULL);
bool HandleBanListHelper(QueryResult* result);
@ -703,9 +703,9 @@ class MANGOS_DLL_SPEC ChatHandler
void HandleCharacterDeletedListHelper(DeletedInfoList const& foundList);
void HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo);
void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
void SetSentErrorMessage(bool val) { sentErrorMessage = val;};
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
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) {}
// overwrite functions
const char *GetMangosString(int32 entry) const;
const char* GetMangosString(int32 entry) const;
uint32 GetAccountId() const;
AccountTypes GetAccessLevel() const;
bool isAvailable(ChatCommand const& cmd) const;
void SendSysMessage(const char *str);
void SendSysMessage(const char* str);
std::string GetNameLink() const;
bool needReportToTarget(Player* chr) const;
LocaleConstant GetSessionDbcLocale() const;

View file

@ -41,7 +41,7 @@ bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg
if (lang != LANG_ADDON)
{
// 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);
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;
}
void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
{
uint32 type;
uint32 lang;
@ -66,45 +66,45 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
recv_data >> type;
recv_data >> lang;
if(type >= MAX_CHAT_MSG_TYPE)
if (type >= MAX_CHAT_MSG_TYPE)
{
sLog.outError("CHAT: Wrong message type received: %u", type);
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)
LanguageDesc const* langDesc = GetLanguageDescByID(lang);
if(!langDesc)
if (!langDesc)
{
SendNotification(LANG_UNKNOWN_LANGUAGE);
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)
Unit::AuraList const& langAuras = _player->GetAurasByType(SPELL_AURA_COMPREHEND_LANGUAGE);
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;
break;
}
}
if(!foundAura)
if (!foundAura)
{
SendNotification(LANG_NOT_LEARNED_LANGUAGE);
return;
}
}
if(lang == LANG_ADDON)
if (lang == LANG_ADDON)
{
// Disabled addon channel?
if(!sWorld.getConfig(CONFIG_BOOL_ADDON_CHANNEL))
if (!sWorld.getConfig(CONFIG_BOOL_ADDON_CHANNEL))
return;
}
// 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;
else
{
switch(type)
switch (type)
{
case CHAT_MSG_PARTY:
case CHAT_MSG_RAID:
case CHAT_MSG_RAID_LEADER:
case CHAT_MSG_RAID_WARNING:
// 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;
break;
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
// 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;
break;
}
@ -141,7 +141,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
// but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
Unit::AuraList const& ModLangAuras = _player->GetAurasByType(SPELL_AURA_MOD_LANGUAGE);
if(!ModLangAuras.empty())
if (!ModLangAuras.empty())
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_EMOTE:
@ -167,7 +167,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg;
recv_data >> msg;
if(msg.empty())
if (msg.empty())
break;
if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -176,14 +176,14 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
if(type == CHAT_MSG_SAY)
if (type == CHAT_MSG_SAY)
GetPlayer()->Say(msg, lang);
else if(type == CHAT_MSG_EMOTE)
else if (type == CHAT_MSG_EMOTE)
GetPlayer()->TextEmote(msg);
else if(type == CHAT_MSG_YELL)
else if (type == CHAT_MSG_YELL)
GetPlayer()->Yell(msg, lang);
} break;
@ -196,16 +196,16 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
if(!normalizePlayerName(to))
if (!normalizePlayerName(to))
{
SendPlayerNotFoundNotice(to);
break;
}
Player *player = sObjectMgr.GetPlayer(to.c_str());
Player* player = sObjectMgr.GetPlayer(to.c_str());
uint32 tSecurity = GetSecurity();
uint32 pSecurity = player ? player->GetSession()->GetSecurity() : SEC_PLAYER;
if (!player || (tSecurity == SEC_PLAYER && pSecurity > SEC_PLAYER && !player->isAcceptWhispers()))
@ -214,7 +214,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
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())
{
@ -232,7 +232,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg;
recv_data >> msg;
if(msg.empty())
if (msg.empty())
break;
if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -241,15 +241,15 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
// if player is in battleground, he cannot say to battleground members by /p
Group *group = GetPlayer()->GetOriginalGroup();
if(!group)
Group* group = GetPlayer()->GetOriginalGroup();
if (!group)
{
group = _player->GetGroup();
if(!group || group->isBGGroup())
if (!group || group->isBGGroup())
return;
}
@ -267,7 +267,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg;
recv_data >> msg;
if(msg.empty())
if (msg.empty())
break;
if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -276,7 +276,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
if (GetPlayer()->GetGuildId())
@ -290,7 +290,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg;
recv_data >> msg;
if(msg.empty())
if (msg.empty())
break;
if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -299,7 +299,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
if (GetPlayer()->GetGuildId())
@ -313,7 +313,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg;
recv_data >> msg;
if(msg.empty())
if (msg.empty())
break;
if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -322,15 +322,15 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
// if player is in battleground, he cannot say to battleground members by /ra
Group *group = GetPlayer()->GetOriginalGroup();
if(!group)
Group* group = GetPlayer()->GetOriginalGroup();
if (!group)
{
group = GetPlayer()->GetGroup();
if(!group || group->isBGGroup() || !group->isRaidGroup())
if (!group || group->isBGGroup() || !group->isRaidGroup())
return;
}
@ -343,7 +343,7 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
std::string msg;
recv_data >> msg;
if(msg.empty())
if (msg.empty())
break;
if (ChatHandler(this).ParseCommands(msg.c_str()))
@ -352,11 +352,11 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
// if player is in battleground, he cannot say to battleground members by /ra
Group *group = GetPlayer()->GetOriginalGroup();
Group* group = GetPlayer()->GetOriginalGroup();
if (!group)
{
group = GetPlayer()->GetGroup();
@ -377,10 +377,10 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
Group *group = GetPlayer()->GetGroup();
Group* group = GetPlayer()->GetGroup();
if (!group || !group->isRaidGroup() ||
!(group->IsLeader(GetPlayer()->GetObjectGuid()) || group->IsAssistant(GetPlayer()->GetObjectGuid())))
return;
@ -399,12 +399,12 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
// battleground raid is always in Player->GetGroup(), never in GetOriginalGroup()
Group *group = GetPlayer()->GetGroup();
if(!group || !group->isBGGroup())
Group* group = GetPlayer()->GetGroup();
if (!group || !group->isBGGroup())
return;
WorldPacket data;
@ -420,11 +420,11 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
// 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()))
return;
@ -442,11 +442,11 @@ void WorldSession::HandleMessagechatOpcode( WorldPacket & recv_data )
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
return;
if(msg.empty())
if (msg.empty())
break;
if(ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if(Channel *chn = cMgr->GetChannel(channel, _player))
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
if (Channel* chn = cMgr->GetChannel(channel, _player))
chn->Say(_player->GetObjectGuid(), msg.c_str(), lang);
} 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;
uint32 emote;
@ -548,9 +548,9 @@ namespace MaNGOS
};
} // namespace MaNGOS
void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
void WorldSession::HandleTextEmoteOpcode(WorldPacket& recv_data)
{
if(!GetPlayer()->isAlive())
if (!GetPlayer()->isAlive())
return;
if (!GetPlayer()->CanSpeak())
@ -567,13 +567,13 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
recv_data >> emoteNum;
recv_data >> guid;
EmotesTextEntry const *em = sEmotesTextStore.LookupEntry(text_emote);
EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(text_emote);
if (!em)
return;
uint32 emote_id = em->textid;
switch(emote_id)
switch (emote_id)
{
case EMOTE_STATE_SLEEP:
case EMOTE_STATE_SIT:
@ -605,7 +605,7 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data )
((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(), text_emote);
}
void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data )
void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data)
{
ObjectGuid iguid;
uint8 unk;
@ -614,8 +614,8 @@ void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data )
recv_data >> iguid;
recv_data >> unk; // probably related to spam reporting
Player *player = sObjectMgr.GetPlayer(iguid);
if(!player || !player->GetSession())
Player* player = sObjectMgr.GetPlayer(iguid);
if (!player || !player->GetSession())
return;
WorldPacket data;

View file

@ -24,40 +24,40 @@
#include "ObjectGuid.h"
#include "Player.h"
void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data)
{
ObjectGuid guid;
recv_data >> guid;
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());
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
SendAttackStop(NULL);
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
SendAttackStop(pEnemy);
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
// stop attack state at client
@ -68,19 +68,19 @@ void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
_player->Attack(pEnemy,true);
}
void WorldSession::HandleAttackStopOpcode( WorldPacket & /*recv_data*/ )
void WorldSession::HandleAttackStopOpcode(WorldPacket& /*recv_data*/)
{
GetPlayer()->AttackStop();
}
void WorldSession::HandleSetSheathedOpcode( WorldPacket & recv_data )
void WorldSession::HandleSetSheathedOpcode(WorldPacket& recv_data)
{
uint32 sheathed;
recv_data >> 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);
return;
@ -91,7 +91,7 @@ void WorldSession::HandleSetSheathedOpcode( WorldPacket & recv_data )
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 << (enemy ? enemy->GetPackGUID() : PackedGuid()); // must be packed guid
data << uint32(0); // unk, can be 1 also

View file

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

View file

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

View file

@ -50,7 +50,7 @@ Corpse::~Corpse()
void Corpse::AddToWorld()
{
///- Register the corpse for guid lookup
if(!IsInWorld())
if (!IsInWorld())
sObjectAccessor.AddObject(this);
Object::AddToWorld();
@ -59,19 +59,19 @@ void Corpse::AddToWorld()
void Corpse::RemoveFromWorld()
{
///- Remove the corpse from the accessor
if(IsInWorld())
if (IsInWorld())
sObjectAccessor.RemoveObject(this);
Object::RemoveFromWorld();
}
bool Corpse::Create( uint32 guidlow )
bool Corpse::Create(uint32 guidlow)
{
Object::_Create(guidlow, 0, HIGHGUID_CORPSE);
return true;
}
bool Corpse::Create( uint32 guidlow, Player *owner)
bool Corpse::Create(uint32 guidlow, Player* 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()
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)",
guidlow, owner->GetName(), owner->GetPositionX(), owner->GetPositionY());
@ -119,7 +119,7 @@ void Corpse::SaveToDB()
<< uint32(GetType()) << ", "
<< int(GetInstanceId()) << ", "
<< uint16(GetPhaseMask()) << ")"; // prevent out of range error
CharacterDatabase.Execute( ss.str().c_str() );
CharacterDatabase.Execute(ss.str().c_str());
CharacterDatabase.CommitTransaction();
}
@ -149,7 +149,7 @@ void Corpse::DeleteFromDB()
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
//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_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);
return false;
@ -192,8 +192,8 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
SetObjectScale(DEFAULT_OBJECT_SCALE);
PlayerInfo const *info = sObjectMgr.GetPlayerInfo(race, _class);
if(!info)
PlayerInfo const* info = sObjectMgr.GetPlayerInfo(race, _class);
if (!info)
{
sLog.outError("Player %u has incorrect race/class pair.", GetGUIDLow());
return false;
@ -206,8 +206,8 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
{
uint32 visualbase = slot * 2;
uint32 item_id = GetUInt32ValueFromArray(data, visualbase);
const ItemPrototype * proto = ObjectMgr::GetItemPrototype(item_id);
if(!proto)
const ItemPrototype* proto = ObjectMgr::GetItemPrototype(item_id);
if (!proto)
{
SetUInt32Value(CORPSE_FIELD_ITEM + slot, 0);
continue;
@ -221,17 +221,17 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
uint8 hairstyle = (uint8)(playerBytes >> 16);
uint8 haircolor = (uint8)(playerBytes >> 24);
uint8 facialhair = (uint8)(playerBytes2);
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_1, ((0x00) | (race << 8) | (gender << 16) | (skin << 24)));
SetUInt32Value(CORPSE_FIELD_BYTES_2, ((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)));
SetUInt32Value(CORPSE_FIELD_GUILD, guildId);
uint32 flags = CORPSE_FLAG_UNK2;
if(playerFlags & PLAYER_FLAGS_HIDE_HELM)
if (playerFlags & PLAYER_FLAGS_HIDE_HELM)
flags |= CORPSE_FLAG_HIDE_HELM;
if(playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
if (playerFlags & PLAYER_FLAGS_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
@ -241,7 +241,7 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
SetPhaseMask(phaseMask, false);
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)",
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);
}
bool Corpse::IsHostileTo( Unit const* unit ) const
bool Corpse::IsHostileTo(Unit const* unit) const
{
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
return owner->IsHostileTo(unit);
@ -266,7 +266,7 @@ bool Corpse::IsHostileTo( Unit const* unit ) const
return false;
}
bool Corpse::IsFriendlyTo( Unit const* unit ) const
bool Corpse::IsFriendlyTo(Unit const* unit) const
{
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
return owner->IsFriendlyTo(unit);
@ -276,7 +276,7 @@ bool Corpse::IsFriendlyTo( Unit const* unit ) const
bool Corpse::IsExpired(time_t t) const
{
if(m_type == CORPSE_BONES)
if (m_type == CORPSE_BONES)
return m_time < t - 60*MINUTE;
else
return m_time < t - 3*DAY;

View file

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

View file

@ -51,7 +51,6 @@
// apply implementation of the singletons
#include "Policies/SingletonImp.h"
ObjectGuid CreatureData::GetObjectGuid(uint32 lowguid) const
{
// info existence checked at loading
@ -67,13 +66,13 @@ TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
return NULL;
}
bool VendorItemData::RemoveItem( uint32 item_id )
bool VendorItemData::RemoveItem(uint32 item_id)
{
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
if((*i)->item == item_id)
if ((*i)->item == item_id)
{
i = m_items.erase(i);
found = true;
@ -87,8 +86,8 @@ bool VendorItemData::RemoveItem( uint32 item_id )
VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extendedCost) const
{
for(VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i )
if((*i)->item == item_id && (*i)->ExtendedCost == extendedCost)
for (VendorItemList::const_iterator i = m_items.begin(); i != m_items.end(); ++i)
if ((*i)->item == item_id && (*i)->ExtendedCost == extendedCost)
return *i;
return NULL;
}
@ -105,7 +104,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
if (assistant && assistant->CanAssistTo(&m_owner, victim))
{
assistant->SetNoCallAssistance(true);
if(assistant->AI())
if (assistant->AI())
assistant->AI()->AttackStart(victim);
}
}
@ -113,7 +112,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
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
m_assistantGuids.reserve(assistants.size());
@ -157,20 +156,20 @@ bool CreatureCreatePos::Relocate(Creature* cr) const
}
Creature::Creature(CreatureSubtype subtype) :
Unit(), i_AI(NULL),
lootForPickPocketed(false), lootForBody(false), lootForSkin(false), m_groupLootTimer(0), m_groupLootId(0),
m_lootMoney(0), m_lootGroupRecipientId(0),
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_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(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_creatureInfo(NULL)
Unit(), i_AI(NULL),
lootForPickPocketed(false), lootForBody(false), lootForSkin(false), m_groupLootTimer(0), m_groupLootId(0),
m_lootMoney(0), m_lootGroupRecipientId(0),
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_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(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_creatureInfo(NULL)
{
m_regenTimer = 200;
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_CreatureSpellCooldowns.clear();
@ -237,20 +236,20 @@ void Creature::RemoveCorpse()
/**
* 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
if (eventData && eventData->entry_id)
Entry = eventData->entry_id;
CreatureInfo const *normalInfo = ObjectMgr::GetCreatureTemplate(Entry);
if(!normalInfo)
CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(Entry);
if (!normalInfo)
{
sLog.outErrorDb("Creature::UpdateEntry creature entry %u does not exist.", Entry);
return false;
}
CreatureInfo const *cinfo = normalInfo;
CreatureInfo const* cinfo = normalInfo;
for (Difficulty diff = GetMap()->GetDifficulty(); diff > REGULAR_DIFFICULTY; diff = GetPrevDifficulty(diff, GetMap()->IsRaid()))
{
// 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;
}
CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
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);
@ -312,7 +311,8 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
LoadEquipment(cinfo->equipmentId); // else use from diff template
}
else if (data && data->equipmentId != -1)
{ // override, -1 means no equipment
{
// override, -1 means no equipment
LoadEquipment(data->equipmentId);
}
@ -332,7 +332,7 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE
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))
return false;
@ -389,7 +389,7 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData *data /*=
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];
SetVehicleId(GetCreatureInfo()->vehicleId);
@ -401,7 +401,7 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData *data /*=
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
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);
if (const CreatureInfo *creatureDefault = ObjectMgr::GetCreatureTemplate(1))
if (const CreatureInfo* creatureDefault = ObjectMgr::GetCreatureTemplate(1))
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)
{
switch( m_deathState )
switch (m_deathState)
{
case JUST_ALIVED:
// 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
RemoveAllAuras();
if(m_originalEntry != GetEntry())
if (m_originalEntry != GetEntry())
{
// need preserver gameevent state
GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(GetGUIDLow());
UpdateEntry(m_originalEntry, TEAM_NONE, NULL, eventData);
}
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureInfo const* cinfo = GetCreatureInfo();
SelectLevel(cinfo);
SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
@ -501,7 +501,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
LoadCreatureAddon(true);
}
else
SetDeathState( JUST_ALIVED );
SetDeathState(JUST_ALIVED);
//Call AI respawn virtual function
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
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if(!isAlive())
if (!isAlive())
break;
if(!IsInEvadeMode())
if (!IsInEvadeMode())
{
if (AI())
{
@ -591,7 +591,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
// creature can be dead after UpdateAI call
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)
if(!isAlive())
if (!isAlive())
break;
RegenerateAll(update_diff);
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_groupLootTimer = timer;
@ -623,7 +623,7 @@ void Creature::RegenerateAll(uint32 update_diff)
{
if (m_regenTimer > 0)
{
if(update_diff >= m_regenTimer)
if (update_diff >= m_regenTimer)
m_regenTimer = 0;
else
m_regenTimer -= update_diff;
@ -652,7 +652,7 @@ void Creature::RegenerateMana()
// Combat and any controlled creature
if (isInCombat() || GetCharmerOrOwnerGuid())
{
if(!IsUnderLastManaUseEffect())
if (!IsUnderLastManaUseEffect())
{
float ManaIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_MANA);
float Spirit = GetStat(STAT_SPIRIT);
@ -685,7 +685,7 @@ void Creature::RegenerateHealth()
float HealthIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_HEALTH);
float Spirit = GetStat(STAT_SPIRIT);
if( GetPower(POWER_MANA) > 0 )
if (GetPower(POWER_MANA) > 0)
addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate);
else
addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate);
@ -713,7 +713,7 @@ void Creature::DoFleeToGetAssistance()
SetNoSearchAssistance(true);
UpdateSpeed(MOVE_RUN, false);
if(!pCreature)
if (!pCreature)
SetFeared(true, getVictim()->GetObjectGuid(), 0 ,sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_FLEE_DELAY));
else
GetMotionMaster()->MoveSeekAssistance(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ());
@ -723,13 +723,13 @@ void Creature::DoFleeToGetAssistance()
bool Creature::AIM_Initialize()
{
// 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.");
return false;
}
CreatureAI * oldAI = i_AI;
CreatureAI* oldAI = i_AI;
i_motionMaster.Initialize();
i_AI = FactorySelector::selectAI(this);
if (oldAI)
@ -737,7 +737,7 @@ bool Creature::AIM_Initialize()
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());
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:
if (pPlayer->getClass() != GetCreatureInfo()->trainer_class)
@ -817,17 +817,17 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
if (msg)
{
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_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu( 328, GetObjectGuid()); break;
case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu( 1635, GetObjectGuid()); break;
case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu( 4436, GetObjectGuid()); break;
case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu( 4797, GetObjectGuid()); break;
case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu( 5003, GetObjectGuid()); break;
case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu( 5836, GetObjectGuid()); break;
case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu( 4985, GetObjectGuid()); break;
case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu(328, GetObjectGuid()); break;
case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu(1635, GetObjectGuid()); break;
case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu(4436, GetObjectGuid()); break;
case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu(4797, GetObjectGuid()); break;
case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu(5003, GetObjectGuid()); break;
case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu(5836, GetObjectGuid()); break;
case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu(4985, GetObjectGuid()); break;
}
}
return false;
@ -857,7 +857,7 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const
if (msg)
{
pPlayer->PlayerTalkClass->ClearMenus();
switch(GetCreatureInfo()->trainer_class)
switch (GetCreatureInfo()->trainer_class)
{
case RACE_DWARF: pPlayer->PlayerTalkClass->SendGossipMenu(5865, 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_TAUREN: pPlayer->PlayerTalkClass->SendGossipMenu(5864, 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_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
{
if(!isBattleMaster())
if (!isBattleMaster())
return false;
BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry());
if (bgTypeId == BATTLEGROUND_TYPE_NONE)
return false;
if(!msg)
if (!msg)
return pPlayer->GetBGAccessByLevel(bgTypeId);
if(!pPlayer->GetBGAccessByLevel(bgTypeId))
if (!pPlayer->GetBGAccessByLevel(bgTypeId))
{
pPlayer->PlayerTalkClass->ClearMenus();
switch(bgTypeId)
switch (bgTypeId)
{
case BATTLEGROUND_AV: pPlayer->PlayerTalkClass->SendGossipMenu(7616, GetObjectGuid()); break;
case BATTLEGROUND_WS: pPlayer->PlayerTalkClass->SendGossipMenu(7599, GetObjectGuid()); break;
@ -1011,8 +1011,8 @@ Player* Creature::GetLootRecipient() const
return player;
// find any in group
for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player *p = itr->getSource())
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* p = itr->getSource())
return p;
return NULL;
@ -1021,7 +1021,7 @@ Player* Creature::GetLootRecipient() const
/**
* 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
// to loot the creature after it dies
@ -1037,7 +1037,7 @@ void Creature::SetLootRecipient(Unit *unit)
}
Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself();
if(!player) // normal creature, no player involved
if (!player) // normal creature, no player involved
return;
// 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
// preferably after adding to map, because mapid may not be valid otherwise
CreatureData const *data = sObjectMgr.GetCreatureData(GetGUIDLow());
if(!data)
CreatureData const* data = sObjectMgr.GetCreatureData(GetGUIDLow());
if (!data)
{
sLog.outError("Creature::SaveToDB failed, cannot get creature data!");
return;
@ -1073,15 +1073,15 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
uint32 displayId = GetNativeDisplayId();
// 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 (displayId != cinfo->ModelId[0] && displayId != cinfo->ModelId[1] &&
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 (CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelInfo(cinfo->ModelId[i]))
if (CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelInfo(cinfo->ModelId[i]))
if (displayId == minfo->modelid_other_gender)
displayId = 0;
}
@ -1142,7 +1142,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
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;
@ -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;
@ -1267,18 +1267,18 @@ bool Creature::CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team t
return true;
}
bool Creature::LoadFromDB(uint32 guidlow, Map *map)
bool Creature::LoadFromDB(uint32 guidlow, Map* map)
{
CreatureData const* data = sObjectMgr.GetCreatureData(guidlow);
if(!data)
if (!data)
{
sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ", guidlow);
return false;
}
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(data->id);
if(!cinfo)
CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(data->id);
if (!cinfo)
{
sLog.outErrorDb("Creature (Entry: %u) not found in table `creature_template`, can't load. ", data->id);
return false;
@ -1303,17 +1303,17 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
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;
if(CanFly())
if (CanFly())
{
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);
}
}
else if(m_respawnTime) // respawn time set but expired
else if (m_respawnTime) // respawn time set but expired
{
m_respawnTime = 0;
@ -1324,7 +1324,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
if (curhealth)
{
curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank));
if(curhealth < 1)
if (curhealth < 1)
curhealth = 1;
}
@ -1364,7 +1364,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
void Creature::LoadEquipment(uint32 equip_entry, bool force)
{
if(equip_entry == 0)
if (equip_entry == 0)
{
if (force)
{
@ -1375,7 +1375,7 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force)
return;
}
EquipmentInfo const *einfo = sObjectMgr.GetEquipmentInfo(equip_entry);
EquipmentInfo const* einfo = sObjectMgr.GetEquipmentInfo(equip_entry);
if (!einfo)
return;
@ -1387,7 +1387,7 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force)
bool Creature::HasQuest(uint32 quest_id) const
{
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)
return true;
@ -1398,7 +1398,7 @@ bool Creature::HasQuest(uint32 quest_id) const
bool Creature::HasInvolvedQuest(uint32 quest_id) const
{
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)
return true;
@ -1411,7 +1411,7 @@ struct CreatureRespawnDeleteWorker
{
explicit CreatureRespawnDeleteWorker(uint32 guid) : i_guid(guid) {}
void operator() (MapPersistentState* state)
void operator()(MapPersistentState* state)
{
state->SaveCreatureRespawnTime(i_guid, 0);
}
@ -1433,7 +1433,7 @@ void Creature::DeleteFromDB()
void Creature::DeleteFromDB(uint32 lowguid, CreatureData const* data)
{
CreatureRespawnDeleteWorker worker (lowguid);
CreatureRespawnDeleteWorker worker(lowguid);
sMapPersistentStateMgr.DoForAllStatesWithMapId(data->mapid, worker);
sObjectMgr.DeleteCreatureData(lowguid);
@ -1451,7 +1451,7 @@ void Creature::DeleteFromDB(uint32 lowguid, CreatureData const* data)
float Creature::GetAttackDistance(Unit const* pl) const
{
float aggroRate = sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO);
if(aggroRate == 0)
if (aggroRate == 0)
return 0.0f;
uint32 playerlevel = pl->GetLevelForTarget(this);
@ -1460,7 +1460,7 @@ float Creature::GetAttackDistance(Unit const* pl) const
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."
if ( leveldif < - 25)
if (leveldif < - 25)
leveldif = -25;
// "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
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
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)"
if(RetDistance < 5)
if (RetDistance < 5)
RetDistance = 5;
return (RetDistance*aggroRate);
@ -1519,7 +1519,7 @@ void Creature::SetDeathState(DeathState s)
if (s == JUST_ALIVED)
{
CreatureInfo const *cinfo = GetCreatureInfo();
CreatureInfo const* cinfo = GetCreatureInfo();
SetHealth(GetMaxHealth());
SetLootRecipient(NULL);
@ -1570,7 +1570,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn)
{
if (timeMSToDespawn)
{
ForcedDespawnDelayEvent *pEvent = new ForcedDespawnDelayEvent(*this);
ForcedDespawnDelayEvent* pEvent = new ForcedDespawnDelayEvent(*this);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn));
return;
@ -1616,38 +1616,38 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd
return Unit::IsImmuneToSpellEffect(spellInfo, index);
}
SpellEntry const *Creature::ReachWithSpellAttack(Unit *pVictim)
SpellEntry const* Creature::ReachWithSpellAttack(Unit* pVictim)
{
if(!pVictim)
if (!pVictim)
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;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] );
if(!spellInfo)
SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]);
if (!spellInfo)
{
sLog.outError("WORLD: unknown spell id %i", m_spells[i]);
continue;
}
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_ENVIRONMENTAL_DAMAGE) ||
(spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH )
(spellInfo->Effect[j] == SPELL_EFFECT_HEALTH_LEECH)
)
{
bcontinue = false;
break;
}
}
if(bcontinue) continue;
if (bcontinue) continue;
if(spellInfo->manaCost > GetPower(POWER_MANA))
if (spellInfo->manaCost > GetPower(POWER_MANA))
continue;
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
float range = GetSpellMaxRange(srange);
@ -1657,46 +1657,46 @@ SpellEntry const *Creature::ReachWithSpellAttack(Unit *pVictim)
//if(!isInFront( pVictim, range ) && spellInfo->AttributesEx )
// continue;
if( dist > range || dist < minrange )
if (dist > range || dist < minrange)
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;
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;
return spellInfo;
}
return NULL;
}
SpellEntry const *Creature::ReachWithSpellCure(Unit *pVictim)
SpellEntry const* Creature::ReachWithSpellCure(Unit* pVictim)
{
if(!pVictim)
if (!pVictim)
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;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_spells[i] );
if(!spellInfo)
SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]);
if (!spellInfo)
{
sLog.outError("WORLD: unknown spell id %i", m_spells[i]);
continue;
}
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;
break;
}
}
if(bcontinue)
if (bcontinue)
continue;
if(spellInfo->manaCost > GetPower(POWER_MANA))
if (spellInfo->manaCost > GetPower(POWER_MANA))
continue;
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
float range = GetSpellMaxRange(srange);
@ -1706,11 +1706,11 @@ SpellEntry const *Creature::ReachWithSpellCure(Unit *pVictim)
//if(!isInFront( pVictim, range ) && spellInfo->AttributesEx )
// continue;
if( dist > range || dist < minrange )
if (dist > range || dist < minrange)
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;
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;
return spellInfo;
}
@ -1720,26 +1720,26 @@ SpellEntry const *Creature::ReachWithSpellCure(Unit *pVictim)
bool Creature::IsVisibleInGridForPlayer(Player* pl) const
{
// gamemaster in GM mode see all, including ghosts
if(pl->isGameMaster())
if (pl->isGameMaster())
return true;
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INVISIBLE)
return false;
// 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));
}
// Dead player see live creatures near own corpse
if(isAlive())
if (isAlive())
{
Corpse *corpse = pl->GetCorpse();
if(corpse)
Corpse* corpse = pl->GetCorpse();
if (corpse)
{
// 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;
}
}
@ -1772,7 +1772,7 @@ void Creature::CallAssistance()
SetNoCallAssistance(true);
float radius = sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS);
if(radius > 0)
if (radius > 0)
{
std::list<Creature*> assistList;
@ -1784,7 +1784,7 @@ void Creature::CallAssistance()
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)));
}
}
@ -1857,10 +1857,10 @@ bool Creature::CanInitiateAttack()
void Creature::SaveRespawnTime()
{
if(IsPet() || !HasStaticDBSpawnData())
if (IsPet() || !HasStaticDBSpawnData())
return;
if(m_respawnTime > time(NULL)) // dead (no corpse)
if (m_respawnTime > time(NULL)) // dead (no corpse)
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), m_respawnTime);
else if (m_corpseDecayTimer > 0) // dead (corpse)
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))
return true;
if(sMapStore.LookupEntry(GetMapId())->IsDungeon())
if (sMapStore.LookupEntry(GetMapId())->IsDungeon())
return false;
float AttackDist = GetAttackDistance(pVictim);
@ -1914,8 +1914,8 @@ CreatureDataAddon const* Creature::GetCreatureAddon() const
//creature_addon table
bool Creature::LoadCreatureAddon(bool reload)
{
CreatureDataAddon const *cainfo = GetCreatureAddon();
if(!cainfo)
CreatureDataAddon const* cainfo = GetCreatureAddon();
if (!cainfo)
return false;
if (cainfo->mount != 0)
@ -2005,12 +2005,12 @@ void Creature::SetInCombatWithZone()
return;
}
Map::PlayerList const &PlList = pMap->GetPlayers();
Map::PlayerList const& PlList = pMap->GetPlayers();
if (PlList.isEmpty())
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())
{
@ -2140,22 +2140,22 @@ void Creature::_AddCreatureCategoryCooldown(uint32 category, time_t apply_time)
void Creature::AddCreatureSpellCooldown(uint32 spellid)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellid);
if(!spellInfo)
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid);
if (!spellInfo)
return;
uint32 cooldown = GetSpellRecoveryTime(spellInfo);
if(cooldown)
if (cooldown)
_AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/IN_MILLISECONDS);
if(spellInfo->Category)
if (spellInfo->Category)
_AddCreatureCategoryCooldown(spellInfo->Category, time(NULL));
}
bool Creature::HasCategoryCooldown(uint32 spell_id) const
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
if(!spellInfo)
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
if (!spellInfo)
return false;
CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category);
@ -2182,8 +2182,8 @@ bool Creature::IsInEvadeMode() const
bool Creature::HasSpell(uint32 spellID) const
{
uint8 i;
for(i = 0; i < CREATURE_MAX_SPELLS; ++i)
if(spellID == m_spells[i])
for (i = 0; i < CREATURE_MAX_SPELLS; ++i)
if (spellID == m_spells[i])
break;
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 now = time(NULL);
if(m_respawnTime > now) // dead (no corpse)
if (m_respawnTime > now) // dead (no corpse)
return m_respawnTime;
else if (m_corpseDecayTimer > 0) // dead (corpse)
return now + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS;
@ -2199,7 +2199,7 @@ time_t Creature::GetRespawnTimeEx() const
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()))
{
@ -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);
uint32 level = target->getLevel()+sWorld.getConfig(CONFIG_UINT32_WORLD_BOSS_LEVEL_DIFF);
if(level < 1)
if (level < 1)
return 1;
if(level > 255)
if (level > 255)
return 255;
return level;
}
@ -2317,27 +2317,27 @@ VendorItemData const* Creature::GetVendorTemplateItems() const
uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
{
if(!vItem->maxcount)
if (!vItem->maxcount)
return vItem->maxcount;
VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
for(; itr != m_vendorItemCounts.end(); ++itr)
if(itr->itemId==vItem->item)
for (; itr != m_vendorItemCounts.end(); ++itr)
if (itr->itemId==vItem->item)
break;
if(itr == m_vendorItemCounts.end())
if (itr == m_vendorItemCounts.end())
return vItem->maxcount;
VendorItemCount* vCount = &*itr;
time_t ptime = time(NULL);
if( vCount->lastIncrementTime + vItem->incrtime <= ptime )
if (vCount->lastIncrementTime + vItem->incrtime <= ptime)
{
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item);
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);
return vItem->maxcount;
@ -2352,15 +2352,15 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem)
uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count)
{
if(!vItem->maxcount)
if (!vItem->maxcount)
return 0;
VendorItemCounts::iterator itr = m_vendorItemCounts.begin();
for(; itr != m_vendorItemCounts.end(); ++itr)
if(itr->itemId==vItem->item)
for (; itr != m_vendorItemCounts.end(); ++itr)
if (itr->itemId==vItem->item)
break;
if(itr == m_vendorItemCounts.end())
if (itr == m_vendorItemCounts.end())
{
uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0;
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);
if( vCount->lastIncrementTime + vItem->incrtime <= ptime )
if (vCount->lastIncrementTime + vItem->incrtime <= ptime)
{
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item);
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;
else
vCount->count = vItem->maxcount;
@ -2424,7 +2424,7 @@ void Creature::ClearTemporaryFaction()
setFaction(GetCreatureInfo()->faction_A);
}
void Creature::SendAreaSpiritHealerQueryOpcode(Player *pl)
void Creature::SendAreaSpiritHealerQueryOpcode(Player* pl)
{
uint32 next_resurrect = 0;
if (Spell* pcurSpell = GetCurrentSpell(CURRENT_CHANNELED_SPELL))
@ -2468,7 +2468,7 @@ struct AddCreatureToRemoveListInMapsWorker
{
AddCreatureToRemoveListInMapsWorker(ObjectGuid guid) : i_guid(guid) {}
void operator() (Map* map)
void operator()(Map* map)
{
if (Creature* pCreature = map->GetCreature(i_guid))
pCreature->AddObjectToRemoveList();
@ -2488,7 +2488,7 @@ struct SpawnCreatureInMapsWorker
SpawnCreatureInMapsWorker(uint32 guid, CreatureData const* data)
: i_guid(guid), i_data(data) {}
void operator() (Map* map)
void operator()(Map* map)
{
// We use spawn coords to spawn
if (map->IsLoaded(i_data->posX, i_data->posY))

View file

@ -152,11 +152,11 @@ struct CreatureInfo
SkillType GetRequiredLootSkill() const
{
if(type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
if (type_flags & CREATURE_TYPEFLAGS_HERBLOOT)
return SKILL_HERBALISM;
else if(type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
else if (type_flags & CREATURE_TYPEFLAGS_MININGLOOT)
return SKILL_MINING;
else if(type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
else if (type_flags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
return SKILL_ENGINEERING;
else
return SKILL_SKINNING; // normal case
@ -169,7 +169,7 @@ struct CreatureInfo
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;
// if can tame exotic then can tame any temable
@ -328,22 +328,22 @@ struct VendorItemData
VendorItem* GetItem(uint32 slot) const
{
if(slot>=m_items.size()) return NULL;
if (slot>=m_items.size()) return NULL;
return m_items[slot];
}
bool Empty() const { return m_items.empty(); }
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));
}
bool RemoveItem( uint32 item_id );
bool RemoveItem(uint32 item_id);
VendorItem const* FindItemCostPair(uint32 item_id, uint32 extendedCost) const;
void Clear()
{
for (VendorItemList::const_iterator itr = m_items.begin(); itr != m_items.end(); ++itr)
delete (*itr);
delete(*itr);
m_items.clear();
}
};
@ -454,7 +454,7 @@ enum TemporaryFactionFlags // Used at real fact
class MANGOS_DLL_SPEC Creature : public Unit
{
CreatureAI *i_AI;
CreatureAI* i_AI;
public:
@ -464,9 +464,9 @@ class MANGOS_DLL_SPEC Creature : public Unit
void AddToWorld();
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);
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);
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
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; }
CreatureSubtype GetSubtype() const { return m_subtype; }
@ -508,7 +508,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
// redefine Unit::IsImmuneToSpellEffect
bool IsElite() const
{
if(IsPet())
if (IsPet())
return false;
uint32 rank = GetCreatureInfo()->rank;
@ -517,7 +517,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
bool IsWorldBoss() const
{
if(IsPet())
if (IsPet())
return false;
return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
@ -574,10 +574,10 @@ class MANGOS_DLL_SPEC Creature : public Unit
TrainerSpellData const* GetTrainerTemplateSpells() const;
TrainerSpellData const* GetTrainerSpells() const;
CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
CreatureInfo const* GetCreatureInfo() const { return m_creatureInfo; }
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 GetScriptName() const;
@ -588,7 +588,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
void SetDeathState(DeathState s); // overwrite virtual Unit::SetDeathState
bool LoadFromDB(uint32 guid, Map *map);
bool LoadFromDB(uint32 guid, Map* map);
void SaveToDB();
// overwrited in Pet
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
@ -611,8 +611,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
void AllLootRemovedFromCorpse();
Player* GetOriginalLootRecipient() const; // ignore group changes/etc, not for looting
SpellEntry const *ReachWithSpellAttack(Unit *pVictim);
SpellEntry const *ReachWithSpellCure(Unit *pVictim);
SpellEntry const* ReachWithSpellAttack(Unit* pVictim);
SpellEntry const* ReachWithSpellCure(Unit* pVictim);
uint32 m_spells[CREATURE_MAX_SPELLS];
CreatureSpellCooldowns m_CreatureSpellCooldowns;
@ -673,7 +673,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
bool HasQuest(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; }
virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
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 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 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 ClearTemporaryFaction();
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); }
protected:
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);
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);
}
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 (!isTriggered)
@ -51,7 +51,7 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry *pSpell,
return CAST_FAIL_POWER;
}
if (const SpellRangeEntry *pSpellRange = sSpellRangeStore.LookupEntry(pSpell->rangeIndex))
if (const SpellRangeEntry* pSpellRange = sSpellRangeStore.LookupEntry(pSpell->rangeIndex))
{
if (pTarget != m_creature)
{

View file

@ -272,17 +272,17 @@ class MANGOS_DLL_SPEC CreatureAI
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>
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

View file

@ -22,9 +22,9 @@
template<class REAL_AI>
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));
}
#endif

View file

@ -30,22 +30,22 @@ INSTANTIATE_SINGLETON_1(MovementGeneratorRegistry);
namespace FactorySelector
{
CreatureAI* selectAI(Creature *creature)
CreatureAI* selectAI(Creature* creature)
{
// Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets)
if ((!creature->IsPet() || !((Pet*)creature)->isControlled()) && !creature->isCharmed())
if (CreatureAI* scriptedAI = sScriptMgr.GetCreatureAI(creature))
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();
// 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
Unit *owner=NULL;
Unit* owner=NULL;
if ((creature->IsPet() && ((Pet*)creature)->isControlled() &&
((owner=creature->GetOwner()) && owner->GetTypeId()==TYPEID_PLAYER)) || creature->isCharmed())
ai_factory = ai_registry.GetRegistryItem("PetAI");
@ -54,7 +54,7 @@ namespace FactorySelector
// select by script name
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())
ai_factory = ai_registry.GetRegistryItem("GuardAI");
@ -64,14 +64,14 @@ namespace FactorySelector
{
int best_val = PERMIT_BASE_NO;
typedef CreatureAIRegistry::RegistryMapType RMT;
RMT const &l = ai_registry.GetRegisteredItems();
for( RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter)
RMT const& l = ai_registry.GetRegisteredItems();
for (RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter)
{
const CreatureAICreator *factory = iter->second;
const SelectableAI *p = dynamic_cast<const SelectableAI *>(factory);
MANGOS_ASSERT( p != NULL );
const CreatureAICreator* factory = iter->second;
const SelectableAI* p = dynamic_cast<const SelectableAI*>(factory);
MANGOS_ASSERT(p != NULL);
int val = p->Permit(creature);
if( val > best_val )
if (val > best_val)
{
best_val = val;
ai_factory = p;
@ -82,15 +82,15 @@ namespace FactorySelector
// select NullCreatureAI if not another cases
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() );
return ( ai_factory == NULL ? new NullCreatureAI(creature) : ai_factory->Create(creature) );
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));
}
MovementGenerator* selectMovementGenerator(Creature *creature)
MovementGenerator* selectMovementGenerator(Creature* creature)
{
MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance());
MANGOS_ASSERT( creature->GetCreatureInfo() != NULL );
MovementGeneratorCreator const * mv_factory = mv_registry.GetRegistryItem(
MovementGeneratorRegistry& mv_registry(MovementGeneratorRepository::Instance());
MANGOS_ASSERT(creature->GetCreatureInfo() != NULL);
MovementGeneratorCreator const* mv_factory = mv_registry.GetRegistryItem(
creature->GetOwnerGuid().IsPlayer() ? FOLLOW_MOTION_TYPE : creature->GetDefaultMovementType());
/* 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
{
CreatureAI* selectAI(Creature *);
MovementGenerator* selectMovementGenerator(Creature *);
CreatureAI* selectAI(Creature*);
MovementGenerator* selectMovementGenerator(Creature*);
}
#endif

View file

@ -31,7 +31,7 @@
#include "Chat.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)
Time = repeatMin;
@ -47,9 +47,9 @@ bool CreatureEventAIHolder::UpdateRepeatTimer( Creature* creature, uint32 repeat
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_NO;
}
@ -61,7 +61,7 @@ void CreatureEventAI::GetAIInformation(ChatHandler& reader)
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
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)
{
//Debug check
#ifndef MANGOS_DEBUG
#ifndef MANGOS_DEBUG
if ((*i).event_flags & EFLAG_DEBUG_ONLY)
continue;
#endif
#endif
if (m_creature->GetMap()->IsDungeon())
{
if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags)
@ -95,10 +95,10 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
{
//Debug check
#ifndef MANGOS_DEBUG
#ifndef MANGOS_DEBUG
if ((*i).event_flags & EFLAG_DEBUG_ONLY)
continue;
#endif
#endif
if (m_creature->GetMap()->IsDungeon())
{
if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags)
@ -335,7 +335,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
return false;
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;
//Repeat Timers
@ -525,7 +525,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
CanCastResult castResult = DoCastSpellIfCan(target, action.cast.spellId, action.cast.castFlags);
switch(castResult)
switch (castResult)
{
case CAST_FAIL_POWER:
case CAST_FAIL_TOO_FAR:
@ -533,7 +533,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
// Melee current victim if flag not set
if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM))
{
switch(m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType())
switch (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType())
{
case CHASE_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);
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)
pCreature->AI()->AttackStart(target);
break;
@ -580,7 +580,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{
ThreatList const& threatList = m_creature->getThreatManager().getThreatList();
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);
break;
}
@ -620,7 +620,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break;
case ACTION_T_COMBAT_MOVEMENT:
// ignore no affect case
if(m_CombatMovementEnabled==(action.combat_movement.state!=0))
if (m_CombatMovementEnabled==(action.combat_movement.state!=0))
return;
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)
if (m_CombatMovementEnabled)
{
if(action.combat_movement.melee && m_creature->isInCombat())
if(Unit* victim = m_creature->getVictim())
if (action.combat_movement.melee && m_creature->isInCombat())
if (Unit* victim = m_creature->getVictim())
m_creature->SendMeleeAttackStart(victim);
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == IDLE_MOTION_TYPE)
@ -640,8 +640,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
else
{
if(action.combat_movement.melee && m_creature->isInCombat())
if(Unit* victim = m_creature->getVictim())
if (action.combat_movement.melee && m_creature->isInCombat())
if (Unit* victim = m_creature->getVictim())
m_creature->SendMeleeAttackStop(victim);
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;
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;
}
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;
}
else
@ -716,7 +716,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
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));
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;
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);
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;
}
@ -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);
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)
pCreature->AI()->AttackStart(target);
@ -826,7 +826,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
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;
else
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
if (!m_bEmptyList)
@ -1041,7 +1041,7 @@ void CreatureEventAI::EnterCombat(Unit *enemy)
m_EventDiff = 0;
}
void CreatureEventAI::AttackStart(Unit *who)
void CreatureEventAI::AttackStart(Unit* who)
{
if (!who)
return;
@ -1064,7 +1064,7 @@ void CreatureEventAI::AttackStart(Unit *who)
}
}
void CreatureEventAI::MoveInLineOfSight(Unit *who)
void CreatureEventAI::MoveInLineOfSight(Unit* who)
{
if (!who)
return;
@ -1206,7 +1206,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
DoMeleeAttackIfReady();
}
bool CreatureEventAI::IsVisible(Unit *pl) const
bool CreatureEventAI::IsVisible(Unit* pl) const
{
return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_MONSTER))
&& 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);
if((*i).second.SoundId)
if ((*i).second.SoundId)
{
if (GetSoundEntriesStore()->LookupEntry((*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);
}
if((*i).second.Emote)
if ((*i).second.Emote)
{
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());
}
switch((*i).second.Type)
switch ((*i).second.Type)
{
case CHAT_TYPE_SAY:
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)
pSource->MonsterWhisper(textEntry, target);
else sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
}break;
} break;
case CHAT_TYPE_BOSS_WHISPER:
{
if (target && target->GetTypeId() == TYPEID_PLAYER)
pSource->MonsterWhisper(textEntry, target, true);
else sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry);
}break;
} break;
case CHAT_TYPE_ZONE_YELL:
pSource->MonsterYellToZone(textEntry, (*i).second.Language, target);
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
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))
return false;
SpellRangeEntry const *TempRange = NULL;
SpellRangeEntry const* TempRange = NULL;
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;
else
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)
{
if(event.event_type != EVENT_T_SPAWNED)
if (event.event_type != EVENT_T_SPAWNED)
return false;
switch (event.spawned.condition)

View file

@ -563,7 +563,7 @@ typedef UNORDERED_MAP<uint32, CreatureEventAI_Summon> CreatureEventAI_Summon_Map
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;
uint32 Time;
@ -576,7 +576,7 @@ struct CreatureEventAIHolder
class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
{
public:
explicit CreatureEventAI(Creature *c);
explicit CreatureEventAI(Creature* c);
~CreatureEventAI()
{
m_CreatureEventAIList.clear();
@ -587,22 +587,22 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
void JustRespawned();
void Reset();
void JustReachedHome();
void EnterCombat(Unit *enemy);
void EnterCombat(Unit* enemy);
void EnterEvadeMode();
void JustDied(Unit* killer);
void KilledUnit(Unit* victim);
void JustSummoned(Creature* pUnit);
void AttackStart(Unit *who);
void MoveInLineOfSight(Unit *who);
void AttackStart(Unit* who);
void MoveInLineOfSight(Unit* who);
void SpellHit(Unit* pUnit, const SpellEntry* pSpell);
void DamageTaken(Unit* done_by, uint32& damage);
void UpdateAI(const uint32 diff);
bool IsVisible(Unit *) const;
bool IsVisible(Unit*) const;
void ReceiveEmote(Player* pPlayer, uint32 text_emote);
void SummonedCreatureJustDied(Creature* unit);
void SummonedCreatureDespawn(Creature* unit);
static int Permissible(const Creature *);
static int Permissible(const Creature*);
bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL);
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);
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);

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);
// 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...");
if (result)
@ -93,11 +93,12 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use)
m_CreatureEventAI_TextMap[i] = temp;
++count;
} while (result->NextRow());
}
while (result->NextRow());
delete result;
if(check_entry_use)
if (check_entry_use)
CheckUnusedAITexts();
sLog.outString();
@ -116,23 +117,23 @@ void CreatureEventAIMgr::CheckUnusedAITexts()
{
std::set<int32> idx_set;
// 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);
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];
for(int j = 0; j < MAX_ACTIONS; ++j)
for (int j = 0; j < MAX_ACTIONS; ++j)
{
CreatureEventAI_Action const& action = event.action[j];
switch(action.type)
switch (action.type)
{
case ACTION_T_TEXT:
{
for(int k = 0; k < 3; ++k)
for (int k = 0; k < 3; ++k)
if (action.text.TextId[k])
idx_set.erase(action.text.TextId[k]);
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);
}
@ -165,7 +166,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons(bool check_entry_use)
do
{
bar.step();
Field *fields = result->Fetch();
Field* fields = result->Fetch();
CreatureEventAI_Summon temp;
@ -185,16 +186,18 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons(bool check_entry_use)
//Add to map
m_CreatureEventAI_Summon_Map[temp.id] = temp;
++Count;
}while (result->NextRow());
}
while (result->NextRow());
delete result;
if(check_entry_use)
if (check_entry_use)
CheckUnusedAISummons();
sLog.outString();
sLog.outString(">> Loaded %u CreatureEventAI summon definitions", Count);
}else
}
else
{
BarGoLink bar(1);
bar.step();
@ -207,19 +210,19 @@ void CreatureEventAIMgr::CheckUnusedAISummons()
{
std::set<int32> idx_set;
// 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);
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];
for(int j = 0; j < MAX_ACTIONS; ++j)
for (int j = 0; j < MAX_ACTIONS; ++j)
{
CreatureEventAI_Action const& action = event.action[j];
switch(action.type)
switch (action.type)
{
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);
}
@ -245,7 +248,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
m_CreatureEventAI_Event_Map.clear();
// 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, "
"action1_type, action1_param1, action1_param2, action1_param3, "
"action2_type, action2_param1, action2_param2, action2_param3, "
@ -259,7 +262,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
do
{
bar.step();
Field *fields = result->Fetch();
Field* fields = result->Fetch();
CreatureEventAI_Event temp;
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);
break;
case EVENT_T_SPAWNED:
switch(temp.spawned.condition)
switch (temp.spawned.condition)
{
case SPAWNED_EVENT_ALWAY:
break;
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);
break;
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);
default:
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:
{
bool not_set = false;
for(int k = 0; k < 3; ++k)
for (int k = 0; k < 3; ++k)
{
if (action.text.TextId[k])
{
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);
if(!action.text.TextId[k])
if (!action.text.TextId[k])
not_set = true;
// 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]);
action.text.TextId[k] = 0;
@ -592,7 +595,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case ACTION_T_CAST:
{
const SpellEntry *spell = sSpellStore.LookupEntry(action.cast.spellId);
const SpellEntry* spell = sSpellStore.LookupEntry(action.cast.spellId);
if (!spell)
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....
@ -753,9 +756,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
}
break;
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);
action.invincibility_hp_level.hp_level = 100;
@ -811,7 +814,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
//Add to list
m_CreatureEventAI_Event_Map[creature_id].push_back(temp);
++Count;
} while (result->NextRow());
}
while (result->NextRow());
delete result;
@ -834,7 +838,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog.outString();
sLog.outString(">> Loaded %u CreatureEventAI scripts", Count);
}else
}
else
{
BarGoLink bar(1);
bar.step();

View file

@ -25,8 +25,8 @@
class CreatureEventAIMgr
{
public:
CreatureEventAIMgr(){};
~CreatureEventAIMgr(){};
CreatureEventAIMgr() {};
~CreatureEventAIMgr() {};
void LoadCreatureEventAI_Texts(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))
{
// 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)[0].GetUInt32() > 1)

View file

@ -47,7 +47,7 @@ struct WMOAreaTableTripple
int32 adtId;
};
typedef std::map<WMOAreaTableTripple, WMOAreaTableEntry const *> WMOAreaInfoByTripple;
typedef std::map<WMOAreaTableTripple, WMOAreaTableEntry const*> WMOAreaInfoByTripple;
DBCStorage <AreaTableEntry> sAreaStore(AreaTableEntryfmt);
DBCStorage <AreaGroupEntry> sAreaGroupStore(AreaGroupEntryfmt);
@ -195,8 +195,8 @@ typedef std::list<std::string> StoreProblemList;
bool IsAcceptableClientBuild(uint32 build)
{
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD;
for(int i = 0; accepted_versions[i]; ++i)
if(int(build) == accepted_versions[i])
for (int i = 0; accepted_versions[i]; ++i)
if (int(build) == accepted_versions[i])
return true;
return false;
@ -206,7 +206,7 @@ std::string AcceptableClientBuildsListStr()
{
std::ostringstream data;
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] << " ";
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";
if(FILE* file = fopen(filename.c_str(),"rb"))
if (FILE* file = fopen(filename.c_str(),"rb"))
{
char buf[100];
fread(buf,1,100-1,file);
@ -234,7 +234,7 @@ static uint32 ReadDBCBuild(const std::string& dbc_path, LocaleNameStr const* loc
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))
{
@ -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));
std::string dbc_filename = dbc_path + filename;
if(storage.Load(dbc_filename.c_str()))
if (storage.Load(dbc_filename.c_str()))
{
bar.step();
for(uint8 i = 0; fullLocaleNameList[i].name; ++i)
for (uint8 i = 0; fullLocaleNameList[i].name; ++i)
{
if (!(localeData.availableDbcLocales & (1 << i)))
continue;
@ -309,7 +309,7 @@ inline void LoadDBC(LocalData& localeData, BarGoLink& bar, StoreProblemList& err
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
@ -327,15 +327,15 @@ inline void LoadDBC(LocalData& localeData, BarGoLink& bar, StoreProblemList& err
}
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
}
}
else
{
// sort problematic dbc to (1) non compatible and (2) nonexistent
FILE * f=fopen(dbc_filename.c_str(),"rb");
if(f)
FILE* f=fopen(dbc_filename.c_str(),"rb");
if (f)
{
char buf[100];
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));
// 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));
}
}
@ -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,sEmotesTextStore, dbcPath,"EmotesText.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)
{
SimpleFactionsList &flist = sFactionTeamMap[faction->team];
SimpleFactionsList& flist = sFactionTeamMap[faction->team];
flist.push_back(i);
}
}
@ -461,8 +461,8 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMapDifficultyStore, dbcPath,"MapDifficulty.dbc");
// fill data
for(uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++i)
if(MapDifficultyEntry const* entry = sMapDifficultyStore.LookupEntry(i))
for (uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++i)
if (MapDifficultyEntry const* entry = sMapDifficultyStore.LookupEntry(i))
sMapDifficultyMap[MAKE_PAIR32(entry->MapId,entry->Difficulty)] = MapDifficulty(entry->resetTime,entry->maxPlayers);
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,sQuestXPLevelStore, dbcPath,"QuestXP.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 (entry->bracketId > MAX_BATTLEGROUND_BRACKETS)
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,sSoundEntriesStore, dbcPath,"SoundEntries.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);
if(spell && spell->Category)
SpellEntry const* spell = sSpellStore.LookupEntry(i);
if (spell && spell->Category)
sSpellCategoryStore[spell->Category].insert(i);
// 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
#if MANGOS_ENDIAN == MANGOS_BIGENDIAN
#if MANGOS_ENDIAN == MANGOS_BIGENDIAN
std::swap(*((uint32*)(&spell->SpellFamilyFlags)),*(((uint32*)(&spell->SpellFamilyFlags))+1));
#endif
#endif
}
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;
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)
{
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i);
if(!cFamily)
if (!cFamily)
continue;
if(skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
if (skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
continue;
sPetFamilySpellsStore[i].insert(spellInfo->Id);
@ -539,10 +539,10 @@ void LoadDBCStores(const std::string& dataPath)
// create talent spells set
for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i)
{
TalentEntry const *talentInfo = sTalentStore.LookupEntry(i);
TalentEntry const* talentInfo = sTalentStore.LookupEntry(i);
if (!talentInfo) continue;
for (int j = 0; j < MAX_TALENT_RANK; j++)
if(talentInfo->RankID[j])
if (talentInfo->RankID[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
{
// 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 );
if(!talentTabInfo)
TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentTabId);
if (!talentTabInfo)
continue;
// prevent memory corruption; otherwise cls will become 12 below
@ -563,7 +563,7 @@ void LoadDBCStores(const std::string& dataPath)
// store class talent tab pages
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;
}
@ -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,sTaxiPathStore, dbcPath,"TaxiPath.dbc");
for(uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i)
if(TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i))
for (uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i)
if (TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i))
sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID,entry->price);
uint32 pathCount = sTaxiPathStore.GetNumRows();
@ -582,54 +582,54 @@ void LoadDBCStores(const std::string& dataPath)
// Calculate path nodes count
std::vector<uint32> pathLength;
pathLength.resize(pathCount); // 0 and some other indexes not used
for(uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
if(TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
{
if (pathLength[entry->path] < entry->index + 1)
pathLength[entry->path] = entry->index + 1;
}
// Set path length
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]);
// fill data (pointers to sTaxiPathNodeStore elements
for(uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
if(TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
sTaxiPathNodesByPath[entry->path].set(entry->index, entry);
// Initialize global taxinodes mask
// include existing nodes that have at least single not spell base (scripted) path
{
std::set<uint32> spellPaths;
for(uint32 i = 1; i < sSpellStore.GetNumRows (); ++i)
if(SpellEntry const* sInfo = sSpellStore.LookupEntry (i))
for(int j=0; j < MAX_EFFECT_INDEX; ++j)
if(sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/)
for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
if (SpellEntry const* sInfo = sSpellStore.LookupEntry(i))
for (int j=0; j < MAX_EFFECT_INDEX; ++j)
if (sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/)
spellPaths.insert(sInfo->EffectMiscValue[j]);
memset(sTaxiNodesMask,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);
if(!node)
if (!node)
continue;
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;
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
if(spellPaths.find(dest_i->second.ID)==spellPaths.end())
if (spellPaths.find(dest_i->second.ID)==spellPaths.end())
{
ok = true;
break;
}
}
if(!ok)
if (!ok)
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,sWorldMapAreaStore, dbcPath,"WorldMapArea.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));
}
@ -661,16 +661,16 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc");
// 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());
Log::WaitBeforeContinueIfNeed();
exit(1);
}
else if (!bad_dbc_files.empty() )
else if (!bad_dbc_files.empty())
{
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";
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
!sItemExtendedCostStore.LookupEntry(2997) || // last item extended cost 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());
Log::WaitBeforeContinueIfNeed();
@ -693,23 +693,23 @@ void LoadDBCStores(const std::string& dataPath)
}
sLog.outString();
sLog.outString( ">> Initialized %d data stores", DBCFilesCount );
sLog.outString(">> Initialized %d data stores", DBCFilesCount);
}
SimpleFactionsList const* GetFactionTeamList(uint32 faction)
{
FactionTeamMap::const_iterator itr = sFactionTeamMap.find(faction);
if(itr==sFactionTeamMap.end())
if (itr==sFactionTeamMap.end())
return NULL;
return &itr->second;
}
char const* GetPetName(uint32 petfamily, uint32 dbclang)
{
if(!petfamily)
if (!petfamily)
return NULL;
CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(petfamily);
if(!pet_family)
CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(petfamily);
if (!pet_family)
return 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)
{
TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId);
if(itr==sTalentSpellPosMap.end())
if (itr==sTalentSpellPosMap.end())
return NULL;
return &itr->second;
@ -739,7 +739,7 @@ uint32 GetTalentSpellCost(uint32 spellId)
int32 GetAreaFlagByAreaID(uint32 area_id)
{
AreaFlagByAreaID::iterator i = sAreaFlagByAreaID.find(area_id);
if(i == sAreaFlagByAreaID.end())
if (i == sAreaFlagByAreaID.end())
return -1;
return i->second;
@ -748,7 +748,7 @@ int32 GetAreaFlagByAreaID(uint32 area_id)
WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
{
WMOAreaInfoByTripple::iterator i = sWMOAreaInfoByTripple.find(WMOAreaTableTripple(rootid, adtid, groupid));
if(i == sWMOAreaInfoByTripple.end())
if (i == sWMOAreaInfoByTripple.end())
return NULL;
return i->second;
@ -757,18 +757,18 @@ WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid
AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id)
{
int32 areaflag = GetAreaFlagByAreaID(area_id);
if(areaflag < 0)
if (areaflag < 0)
return NULL;
return sAreaStore.LookupEntry(areaflag );
return sAreaStore.LookupEntry(areaflag);
}
AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id)
{
if(area_flag)
if (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 NULL;
@ -777,7 +777,7 @@ AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_i
uint32 GetAreaFlagByMapId(uint32 mapid)
{
AreaFlagByMapID::iterator i = sAreaFlagByMapID.find(mapid);
if(i == sAreaFlagByMapID.end())
if (i == sAreaFlagByMapID.end())
return 0;
else
return i->second;
@ -785,10 +785,10 @@ uint32 GetAreaFlagByMapId(uint32 mapid)
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;
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 mapid;
@ -797,14 +797,14 @@ uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId)
ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId)
{
mapid = GetVirtualMapForMapAndZone(mapid,zoneId);
if(mapid < 2)
if (mapid < 2)
return CONTENT_1_60;
MapEntry const* mapEntry = sMapStore.LookupEntry(mapid);
if(!mapEntry)
if (!mapEntry)
return CONTENT_1_60;
switch(mapEntry->Expansion())
switch (mapEntry->Expansion())
{
default: return CONTENT_1_60;
case 1: return CONTENT_61_70;
@ -815,10 +815,10 @@ ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId)
ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
{
// 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);
if(ch && ch->ChannelID == channel_id)
if (ch && ch->ChannelID == channel_id)
return ch;
}
return NULL;
@ -826,19 +826,19 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
{
if(requiredTotemCategoryId==0)
if (requiredTotemCategoryId==0)
return true;
if(itemTotemCategoryId==0)
if (itemTotemCategoryId==0)
return false;
TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId);
if(!itemEntry)
if (!itemEntry)
return false;
TotemCategoryEntry const* reqEntry = sTotemCategoryStore.LookupEntry(requiredTotemCategoryId);
if(!reqEntry)
if (!reqEntry)
return false;
if(itemEntry->categoryType!=reqEntry->categoryType)
if (itemEntry->categoryType!=reqEntry->categoryType)
return false;
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;
}
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
for(uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i)
for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++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)
{
for(uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i)
for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i)
if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i))
if (entry->mapId == mapid && entry->GetBracketId() == id)
return entry;
@ -928,7 +928,7 @@ bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, flo
{
// 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);
if(dist2 > (atEntry->radius + delta)*(atEntry->radius + delta))
if (dist2 > (atEntry->radius + delta)*(atEntry->radius + delta))
return false;
}
else
@ -953,9 +953,9 @@ bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, flo
float dz = z - atEntry->z;
float dx = rotPlayerX - atEntry->x;
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(dz) > atEntry->box_z/2 + delta) )
(fabs(dz) > atEntry->box_z/2 + delta))
{
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 <EmotesEntry> const* GetEmotesStore();
MANGOS_DLL_SPEC DBCStorage <EmotesTextEntry> const* GetEmotesTextStore();
#endif

View file

@ -44,7 +44,7 @@ struct AchievementEntry
uint32 factionFlag; // 1 m_faction -1=all, 0=horde, 1=alliance
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)
char *name[16]; // 4-19 m_title_lang
char* name[16]; // 4-19 m_title_lang
//uint32 name_flags; // 20 string flags
//char *description[16]; // 21-36 m_description_lang
//uint32 desc_flags; // 37 string flags
@ -889,12 +889,12 @@ struct FactionTemplateEntry
// helpers
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)
return false;
for(int i = 0; i < 4; ++i)
for (int i = 0; i < 4; ++i)
if (friendFaction[i] == entry.faction)
return true;
}
@ -902,12 +902,12 @@ struct FactionTemplateEntry
}
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)
return true;
for(int i = 0; i < 4; ++i)
for (int i = 0; i < 4; ++i)
if (friendFaction[i] == entry.faction)
return false;
}
@ -916,7 +916,7 @@ struct FactionTemplateEntry
bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) !=0; }
bool IsNeutralToAll() const
{
for(int i = 0; i < 4; ++i)
for (int i = 0; i < 4; ++i)
if (enemyFaction[i] != 0)
return false;
return hostileMask == 0 && friendlyMask == 0;
@ -1361,8 +1361,8 @@ struct ScalingStatValuesEntry
//uint32 unk2; // 19 unk, probably also Armor for level (flag 0x80000?)
uint32 armorMod2[4]; // 20-23 Armor for level
/*struct ScalingStatValuesEntry
{
/*struct ScalingStatValuesEntry
{
m_ID
m_charlevel
m_shoulderBudget
@ -1387,17 +1387,17 @@ struct ScalingStatValuesEntry
m_leatherChestArmor
m_mailChestArmor
m_plateChestArmor
};*/
};*/
uint32 getssdMultiplier(uint32 mask) const
{
if (mask & 0x4001F)
{
if(mask & 0x00000001) return ssdMultiplier[0];
if(mask & 0x00000002) return ssdMultiplier[1];
if(mask & 0x00000004) return ssdMultiplier[2];
if(mask & 0x00000008) return ssdMultiplier2;
if(mask & 0x00000010) return ssdMultiplier[3];
if(mask & 0x00040000) return ssdMultiplier3;
if (mask & 0x00000001) return ssdMultiplier[0];
if (mask & 0x00000002) return ssdMultiplier[1];
if (mask & 0x00000004) return ssdMultiplier[2];
if (mask & 0x00000008) return ssdMultiplier2;
if (mask & 0x00000010) return ssdMultiplier[3];
if (mask & 0x00040000) return ssdMultiplier3;
}
return 0;
}
@ -1406,15 +1406,15 @@ struct ScalingStatValuesEntry
{
if (mask & 0x00F001E0)
{
if(mask & 0x00000020) return armorMod[0];
if(mask & 0x00000040) return armorMod[1];
if(mask & 0x00000080) return armorMod[2];
if(mask & 0x00000100) return armorMod[3];
if (mask & 0x00000020) return armorMod[0];
if (mask & 0x00000040) return armorMod[1];
if (mask & 0x00000080) return armorMod[2];
if (mask & 0x00000100) return armorMod[3];
if(mask & 0x00100000) return armorMod2[0]; // cloth
if(mask & 0x00200000) return armorMod2[1]; // leather
if(mask & 0x00400000) return armorMod2[2]; // mail
if(mask & 0x00800000) return armorMod2[3]; // plate
if (mask & 0x00100000) return armorMod2[0]; // cloth
if (mask & 0x00200000) return armorMod2[1]; // leather
if (mask & 0x00400000) return armorMod2[2]; // mail
if (mask & 0x00800000) return armorMod2[3]; // plate
}
return 0;
}
@ -1423,12 +1423,12 @@ struct ScalingStatValuesEntry
{
if (mask & 0x7E00)
{
if(mask & 0x00000200) return dpsMod[0];
if(mask & 0x00000400) return dpsMod[1];
if(mask & 0x00000800) return dpsMod[2];
if(mask & 0x00001000) return dpsMod[3];
if(mask & 0x00002000) return dpsMod[4];
if(mask & 0x00004000) return dpsMod[5]; // not used?
if (mask & 0x00000200) return dpsMod[0];
if (mask & 0x00000400) return dpsMod[1];
if (mask & 0x00000800) return dpsMod[2];
if (mask & 0x00001000) return dpsMod[3];
if (mask & 0x00002000) return dpsMod[4];
if (mask & 0x00004000) return dpsMod[5]; // not used?
}
return 0;
}
@ -1531,7 +1531,7 @@ struct ClassFamilyMask
explicit ClassFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) : Flags(familyFlags), Flags2(familyFlags2) {}
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)
bool IsFitToFamilyMask(uint64 familyFlags, uint32 familyFlags2 = 0) const

View file

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

View file

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

View file

@ -41,7 +41,7 @@ DynamicObject::DynamicObject() : WorldObject()
void DynamicObject::AddToWorld()
{
///- Register the dynamicObject for guid lookup
if(!IsInWorld())
if (!IsInWorld())
GetMap()->GetObjectsStore().insert<DynamicObject>(GetObjectGuid(), (DynamicObject*)this);
Object::AddToWorld();
@ -50,7 +50,7 @@ void DynamicObject::AddToWorld()
void DynamicObject::RemoveFromWorld()
{
///- Remove the dynamicObject from the accessor
if(IsInWorld())
if (IsInWorld())
{
GetMap()->GetObjectsStore().erase<DynamicObject>(GetObjectGuid(), (DynamicObject*)NULL);
GetViewPoint().Event_RemovedFromWorld();
@ -59,13 +59,13 @@ void DynamicObject::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());
SetMap(caster->GetMap());
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());
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
Unit* caster = GetCaster();
if(!caster)
if (!caster)
{
Delete();
return;
@ -127,20 +127,20 @@ void DynamicObject::Update(uint32 update_diff, uint32 p_time)
bool deleteThis = false;
if(m_aliveDuration > int32(p_time))
if (m_aliveDuration > int32(p_time))
m_aliveDuration -= p_time;
else
deleteThis = true;
// have radius and work as persistent effect
if(m_radius)
if (m_radius)
{
// TODO: make a timer and update this in larger intervals
MaNGOS::DynamicObjectUpdater notifier(*this, caster, m_positive);
Cell::VisitAllObjects(this, notifier, m_radius);
}
if(deleteThis)
if (deleteThis)
{
caster->RemoveDynObjectWithGUID(GetObjectGuid());
Delete();
@ -156,12 +156,12 @@ void DynamicObject::Delete()
void DynamicObject::Delay(int32 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)
{
SpellAuraHolder *holder = target->GetSpellAuraHolder(m_spellId, GetCasterGuid());
SpellAuraHolder* holder = target->GetSpellAuraHolder(m_spellId, GetCasterGuid());
if (!holder)
{
++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);
}
bool DynamicObject::IsHostileTo( Unit const* unit ) const
bool DynamicObject::IsHostileTo(Unit const* unit) const
{
if (Unit* owner = GetCaster())
return owner->IsHostileTo(unit);
@ -213,7 +213,7 @@ bool DynamicObject::IsHostileTo( Unit const* unit ) const
return false;
}
bool DynamicObject::IsFriendlyTo( Unit const* unit ) const
bool DynamicObject::IsFriendlyTo(Unit const* unit) const
{
if (Unit* owner = GetCaster())
return owner->IsFriendlyTo(unit);

View file

@ -40,7 +40,7 @@ class DynamicObject : public WorldObject
void AddToWorld();
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 Delete();
uint32 GetSpellId() const { return m_spellId; }
@ -50,9 +50,9 @@ class DynamicObject : public WorldObject
Unit* GetCaster() const;
float GetRadius() const { return m_radius; }
DynamicObjectType GetType() const { return (DynamicObjectType)GetByteValue(DYNAMICOBJECT_BYTES,0); }
bool IsAffecting(Unit *unit) const { return m_affected.find(unit->GetObjectGuid()) != m_affected.end(); }
void AddAffected(Unit *unit) { m_affected.insert(unit->GetObjectGuid()); }
void RemoveAffected(Unit *unit) { m_affected.erase(unit->GetObjectGuid()); }
bool IsAffecting(Unit* unit) const { return m_affected.find(unit->GetObjectGuid()) != m_affected.end(); }
void AddAffected(Unit* unit) { m_affected.insert(unit->GetObjectGuid()); }
void RemoveAffected(Unit* unit) { m_affected.erase(unit->GetObjectGuid()); }
void Delay(int32 delaytime);
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;
GridReference<DynamicObject> &GetGridRef() { return m_gridRef; }
GridReference<DynamicObject>& GetGridRef() { return m_gridRef; }
protected:
uint32 m_spellId;