Various Cleanups (game F-K)

This commit is contained in:
Schmoozerd 2012-07-19 21:46:24 +02:00
parent c5c09cee3c
commit 2bd41afb3e
44 changed files with 1903 additions and 1881 deletions

View file

@ -29,9 +29,9 @@
#define MAX_QUIET_DISTANCE 43.0f #define MAX_QUIET_DISTANCE 43.0f
template<class T> template<class T>
void FleeingMovementGenerator<T>::_setTargetLocation(T &owner) void FleeingMovementGenerator<T>::_setTargetLocation(T& owner)
{ {
if(!&owner) if (!&owner)
return; return;
// ignore in case other no reaction state // ignore in case other no reaction state
@ -39,7 +39,7 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T &owner)
return; return;
float x, y, z; float x, y, z;
if(!_getPoint(owner, x, y, z)) if (!_getPoint(owner, x, y, z))
return; return;
owner.addUnitState(UNIT_STAT_FLEEING_MOVE); owner.addUnitState(UNIT_STAT_FLEEING_MOVE);
@ -47,7 +47,7 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T &owner)
PathFinder path(&owner); PathFinder path(&owner);
path.setPathLengthLimit(30.0f); path.setPathLengthLimit(30.0f);
path.calculate(x, y, z); path.calculate(x, y, z);
if(path.getPathType() & PATHFIND_NOPATH) if (path.getPathType() & PATHFIND_NOPATH)
{ {
i_nextCheckTime.Reset(urand(1000, 1500)); i_nextCheckTime.Reset(urand(1000, 1500));
return; return;
@ -61,16 +61,16 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T &owner)
} }
template<class T> template<class T>
bool FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z) bool FleeingMovementGenerator<T>::_getPoint(T& owner, float& x, float& y, float& z)
{ {
if(!&owner) if (!&owner)
return false; return false;
float dist_from_caster, angle_to_caster; float dist_from_caster, angle_to_caster;
if(Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGuid)) if (Unit* fright = ObjectAccessor::GetUnit(owner, i_frightGuid))
{ {
dist_from_caster = fright->GetDistance(&owner); dist_from_caster = fright->GetDistance(&owner);
if(dist_from_caster > 0.2f) if (dist_from_caster > 0.2f)
angle_to_caster = fright->GetAngle(&owner); angle_to_caster = fright->GetAngle(&owner);
else else
angle_to_caster = frand(0, 2*M_PI_F); angle_to_caster = frand(0, 2*M_PI_F);
@ -82,12 +82,12 @@ bool FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float
} }
float dist, angle; float dist, angle;
if(dist_from_caster < MIN_QUIET_DISTANCE) if (dist_from_caster < MIN_QUIET_DISTANCE)
{ {
dist = frand(0.4f, 1.3f)*(MIN_QUIET_DISTANCE - dist_from_caster); dist = frand(0.4f, 1.3f)*(MIN_QUIET_DISTANCE - dist_from_caster);
angle = angle_to_caster + frand(-M_PI_F/8, M_PI_F/8); angle = angle_to_caster + frand(-M_PI_F/8, M_PI_F/8);
} }
else if(dist_from_caster > MAX_QUIET_DISTANCE) else if (dist_from_caster > MAX_QUIET_DISTANCE)
{ {
dist = frand(0.4f, 1.0f)*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); dist = frand(0.4f, 1.0f)*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE);
angle = -angle_to_caster + frand(-M_PI_F/4, M_PI_F/4); angle = -angle_to_caster + frand(-M_PI_F/4, M_PI_F/4);
@ -111,47 +111,47 @@ bool FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float
} }
template<class T> template<class T>
void FleeingMovementGenerator<T>::Initialize(T &owner) void FleeingMovementGenerator<T>::Initialize(T& owner)
{ {
owner.addUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); owner.addUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
owner.StopMoving(); owner.StopMoving();
if(owner.GetTypeId() == TYPEID_UNIT) if (owner.GetTypeId() == TYPEID_UNIT)
owner.SetTargetGuid(ObjectGuid()); owner.SetTargetGuid(ObjectGuid());
_setTargetLocation(owner); _setTargetLocation(owner);
} }
template<> template<>
void FleeingMovementGenerator<Player>::Finalize(Player &owner) void FleeingMovementGenerator<Player>::Finalize(Player& owner)
{ {
owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
owner.StopMoving(); owner.StopMoving();
} }
template<> template<>
void FleeingMovementGenerator<Creature>::Finalize(Creature &owner) void FleeingMovementGenerator<Creature>::Finalize(Creature& owner)
{ {
owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
} }
template<class T> template<class T>
void FleeingMovementGenerator<T>::Interrupt(T &owner) void FleeingMovementGenerator<T>::Interrupt(T& owner)
{ {
// flee state still applied while movegen disabled // flee state still applied while movegen disabled
owner.clearUnitState(UNIT_STAT_FLEEING_MOVE); owner.clearUnitState(UNIT_STAT_FLEEING_MOVE);
} }
template<class T> template<class T>
void FleeingMovementGenerator<T>::Reset(T &owner) void FleeingMovementGenerator<T>::Reset(T& owner)
{ {
Initialize(owner); Initialize(owner);
} }
template<class T> template<class T>
bool FleeingMovementGenerator<T>::Update(T &owner, const uint32 & time_diff) bool FleeingMovementGenerator<T>::Update(T& owner, const uint32& time_diff)
{ {
if( !&owner || !owner.isAlive() ) if (!&owner || !owner.isAlive())
return false; return false;
// ignore in case other no reaction state // ignore in case other no reaction state
@ -168,20 +168,20 @@ bool FleeingMovementGenerator<T>::Update(T &owner, const uint32 & time_diff)
return true; return true;
} }
template void FleeingMovementGenerator<Player>::Initialize(Player &); template void FleeingMovementGenerator<Player>::Initialize(Player&);
template void FleeingMovementGenerator<Creature>::Initialize(Creature &); template void FleeingMovementGenerator<Creature>::Initialize(Creature&);
template bool FleeingMovementGenerator<Player>::_getPoint(Player &, float &, float &, float &); template bool FleeingMovementGenerator<Player>::_getPoint(Player&, float&, float&, float&);
template bool FleeingMovementGenerator<Creature>::_getPoint(Creature &, float &, float &, float &); template bool FleeingMovementGenerator<Creature>::_getPoint(Creature&, float&, float&, float&);
template void FleeingMovementGenerator<Player>::_setTargetLocation(Player &); template void FleeingMovementGenerator<Player>::_setTargetLocation(Player&);
template void FleeingMovementGenerator<Creature>::_setTargetLocation(Creature &); template void FleeingMovementGenerator<Creature>::_setTargetLocation(Creature&);
template void FleeingMovementGenerator<Player>::Interrupt(Player &); template void FleeingMovementGenerator<Player>::Interrupt(Player&);
template void FleeingMovementGenerator<Creature>::Interrupt(Creature &); template void FleeingMovementGenerator<Creature>::Interrupt(Creature&);
template void FleeingMovementGenerator<Player>::Reset(Player &); template void FleeingMovementGenerator<Player>::Reset(Player&);
template void FleeingMovementGenerator<Creature>::Reset(Creature &); template void FleeingMovementGenerator<Creature>::Reset(Creature&);
template bool FleeingMovementGenerator<Player>::Update(Player &, const uint32 &); template bool FleeingMovementGenerator<Player>::Update(Player&, const uint32&);
template bool FleeingMovementGenerator<Creature>::Update(Creature &, const uint32 &); template bool FleeingMovementGenerator<Creature>::Update(Creature&, const uint32&);
void TimedFleeingMovementGenerator::Finalize(Unit &owner) void TimedFleeingMovementGenerator::Finalize(Unit& owner)
{ {
owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE);
if (Unit* victim = owner.getVictim()) if (Unit* victim = owner.getVictim())
@ -194,9 +194,9 @@ void TimedFleeingMovementGenerator::Finalize(Unit &owner)
} }
} }
bool TimedFleeingMovementGenerator::Update(Unit & owner, const uint32 & time_diff) bool TimedFleeingMovementGenerator::Update(Unit& owner, const uint32& time_diff)
{ {
if( !owner.isAlive() ) if (!owner.isAlive())
return false; return false;
// ignore in case other no reaction state // ignore in case other no reaction state

View file

@ -24,29 +24,29 @@
template<class T> template<class T>
class MANGOS_DLL_SPEC FleeingMovementGenerator class MANGOS_DLL_SPEC FleeingMovementGenerator
: public MovementGeneratorMedium< T, FleeingMovementGenerator<T> > : public MovementGeneratorMedium< T, FleeingMovementGenerator<T> >
{ {
public: public:
FleeingMovementGenerator(ObjectGuid fright) : i_frightGuid(fright), i_nextCheckTime(0) {} FleeingMovementGenerator(ObjectGuid fright) : i_frightGuid(fright), i_nextCheckTime(0) {}
void Initialize(T &); void Initialize(T&);
void Finalize(T &); void Finalize(T&);
void Interrupt(T &); void Interrupt(T&);
void Reset(T &); void Reset(T&);
bool Update(T &, const uint32 &); bool Update(T&, const uint32&);
MovementGeneratorType GetMovementGeneratorType() const { return FLEEING_MOTION_TYPE; } MovementGeneratorType GetMovementGeneratorType() const { return FLEEING_MOTION_TYPE; }
private: private:
void _setTargetLocation(T &owner); void _setTargetLocation(T& owner);
bool _getPoint(T &owner, float &x, float &y, float &z); bool _getPoint(T& owner, float& x, float& y, float& z);
ObjectGuid i_frightGuid; ObjectGuid i_frightGuid;
TimeTracker i_nextCheckTime; TimeTracker i_nextCheckTime;
}; };
class MANGOS_DLL_SPEC TimedFleeingMovementGenerator class MANGOS_DLL_SPEC TimedFleeingMovementGenerator
: public FleeingMovementGenerator<Creature> : public FleeingMovementGenerator<Creature>
{ {
public: public:
TimedFleeingMovementGenerator(ObjectGuid fright, uint32 time) : TimedFleeingMovementGenerator(ObjectGuid fright, uint32 time) :
@ -54,8 +54,8 @@ class MANGOS_DLL_SPEC TimedFleeingMovementGenerator
i_totalFleeTime(time) {} i_totalFleeTime(time) {}
MovementGeneratorType GetMovementGeneratorType() const { return TIMED_FLEEING_MOTION_TYPE; } MovementGeneratorType GetMovementGeneratorType() const { return TIMED_FLEEING_MOTION_TYPE; }
bool Update(Unit &, const uint32 &); bool Update(Unit&, const uint32&);
void Finalize(Unit &); void Finalize(Unit&);
private: private:
TimeTracker i_totalFleeTime; TimeTracker i_totalFleeTime;

View file

@ -27,7 +27,7 @@ namespace MaNGOS
{ {
inline float hk_honor_at_level(uint32 level, uint32 count=1) inline float hk_honor_at_level(uint32 level, uint32 count=1)
{ {
return (float)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f ))); return (float)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f)));
} }
} }
namespace XP namespace XP
@ -36,11 +36,11 @@ namespace MaNGOS
inline uint32 GetGrayLevel(uint32 pl_level) inline uint32 GetGrayLevel(uint32 pl_level)
{ {
if( pl_level <= 5 ) if (pl_level <= 5)
return 0; return 0;
else if( pl_level <= 39 ) else if (pl_level <= 39)
return pl_level - 5 - pl_level/10; return pl_level - 5 - pl_level/10;
else if( pl_level <= 59 ) else if (pl_level <= 59)
return pl_level - 1 - pl_level/5; return pl_level - 1 - pl_level/5;
else else
return pl_level - 9; return pl_level - 9;
@ -48,13 +48,13 @@ namespace MaNGOS
inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level) inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level)
{ {
if( mob_level >= pl_level + 5 ) if (mob_level >= pl_level + 5)
return RED; return RED;
else if( mob_level >= pl_level + 3 ) else if (mob_level >= pl_level + 3)
return ORANGE; return ORANGE;
else if( mob_level >= pl_level - 2 ) else if (mob_level >= pl_level - 2)
return YELLOW; return YELLOW;
else if( mob_level > GetGrayLevel(pl_level) ) else if (mob_level > GetGrayLevel(pl_level))
return GREEN; return GREEN;
else else
return GRAY; return GRAY;
@ -62,24 +62,24 @@ namespace MaNGOS
inline uint32 GetZeroDifference(uint32 pl_level) inline uint32 GetZeroDifference(uint32 pl_level)
{ {
if( pl_level < 8 ) return 5; if (pl_level < 8) return 5;
if( pl_level < 10 ) return 6; if (pl_level < 10) return 6;
if( pl_level < 12 ) return 7; if (pl_level < 12) return 7;
if( pl_level < 16 ) return 8; if (pl_level < 16) return 8;
if( pl_level < 20 ) return 9; if (pl_level < 20) return 9;
if( pl_level < 30 ) return 11; if (pl_level < 30) return 11;
if( pl_level < 40 ) return 12; if (pl_level < 40) return 12;
if( pl_level < 45 ) return 13; if (pl_level < 45) return 13;
if( pl_level < 50 ) return 14; if (pl_level < 50) return 14;
if( pl_level < 55 ) return 15; if (pl_level < 55) return 15;
if( pl_level < 60 ) return 16; if (pl_level < 60) return 16;
return 17; return 17;
} }
inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content) inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content)
{ {
uint32 nBaseExp; uint32 nBaseExp;
switch(content) switch (content)
{ {
case CONTENT_1_60: nBaseExp = 45; break; case CONTENT_1_60: nBaseExp = 45; break;
case CONTENT_61_70: nBaseExp = 235; break; case CONTENT_61_70: nBaseExp = 235; break;
@ -89,7 +89,7 @@ namespace MaNGOS
nBaseExp = 45; break; nBaseExp = 45; break;
} }
if( mob_level >= pl_level ) if (mob_level >= pl_level)
{ {
uint32 nLevelDiff = mob_level - pl_level; uint32 nLevelDiff = mob_level - pl_level;
if (nLevelDiff > 4) if (nLevelDiff > 4)
@ -99,7 +99,7 @@ namespace MaNGOS
else else
{ {
uint32 gray_level = GetGrayLevel(pl_level); uint32 gray_level = GetGrayLevel(pl_level);
if( mob_level > gray_level ) if (mob_level > gray_level)
{ {
uint32 ZD = GetZeroDifference(pl_level); uint32 ZD = GetZeroDifference(pl_level);
return (pl_level*5 + nBaseExp) * (ZD + mob_level - pl_level)/ZD; return (pl_level*5 + nBaseExp) * (ZD + mob_level - pl_level)/ZD;
@ -108,18 +108,18 @@ namespace MaNGOS
} }
} }
inline uint32 Gain(Player *pl, Unit *u) inline uint32 Gain(Player* pl, Unit* u)
{ {
if(u->GetTypeId()==TYPEID_UNIT && ( if (u->GetTypeId()==TYPEID_UNIT && (
((Creature*)u)->IsTotem() || ((Creature*)u)->IsPet() || ((Creature*)u)->IsTotem() || ((Creature*)u)->IsPet() ||
(((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) )) (((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL)))
return 0; return 0;
uint32 xp_gain= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(),pl->GetZoneId())); uint32 xp_gain= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(),pl->GetZoneId()));
if( xp_gain == 0 ) if (xp_gain == 0)
return 0; return 0;
if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsElite()) if (u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsElite())
xp_gain *= 2; xp_gain *= 2;
return (uint32)(xp_gain*sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL)); return (uint32)(xp_gain*sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL));
@ -127,14 +127,14 @@ namespace MaNGOS
inline float xp_in_group_rate(uint32 count, bool isRaid) inline float xp_in_group_rate(uint32 count, bool isRaid)
{ {
if(isRaid) if (isRaid)
{ {
// FIX ME: must apply decrease modifiers dependent from raid size // FIX ME: must apply decrease modifiers dependent from raid size
return 1.0f; return 1.0f;
} }
else else
{ {
switch(count) switch (count)
{ {
case 0: case 0:
case 1: case 1:

View file

@ -25,10 +25,10 @@
#include "Player.h" #include "Player.h"
#include "Chat.h" #include "Chat.h"
void WorldSession::SendGMTicketGetTicket(uint32 status, GMTicket *ticket /*= NULL*/) void WorldSession::SendGMTicketGetTicket(uint32 status, GMTicket* ticket /*= NULL*/)
{ {
int len = ticket ? strlen(ticket->GetText()) : 0; int len = ticket ? strlen(ticket->GetText()) : 0;
WorldPacket data( SMSG_GMTICKET_GETTICKET, (4+len+1+4+2+4+4) ); WorldPacket data(SMSG_GMTICKET_GETTICKET, (4+len+1+4+2+4+4));
data << uint32(status); // standard 0x0A, 0x06 if text present data << uint32(status); // standard 0x0A, 0x06 if text present
if (status == 6) if (status == 6)
{ {
@ -44,7 +44,7 @@ void WorldSession::SendGMTicketGetTicket(uint32 status, GMTicket *ticket /*= NUL
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::SendGMResponse(GMTicket *ticket) void WorldSession::SendGMResponse(GMTicket* ticket)
{ {
int len = strlen(ticket->GetText())+1+strlen(ticket->GetResponse())+1; int len = strlen(ticket->GetText())+1+strlen(ticket->GetResponse())+1;
WorldPacket data(SMSG_GMTICKET_GET_RESPONSE, 4+4+len+1+1+1); WorldPacket data(SMSG_GMTICKET_GET_RESPONSE, 4+4+len+1+1+1);
@ -58,14 +58,14 @@ void WorldSession::SendGMResponse(GMTicket *ticket)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGMTicketGetTicketOpcode(WorldPacket& /*recv_data*/)
{ {
SendQueryTimeResponse(); SendQueryTimeResponse();
GMTicket* ticket = sTicketMgr.GetGMTicket(GetPlayer()->GetObjectGuid()); GMTicket* ticket = sTicketMgr.GetGMTicket(GetPlayer()->GetObjectGuid());
if(ticket) if (ticket)
{ {
if(ticket->HasResponse()) if (ticket->HasResponse())
SendGMResponse(ticket); SendGMResponse(ticket);
else else
SendGMTicketGetTicket(0x06, ticket); SendGMTicketGetTicket(0x06, ticket);
@ -74,29 +74,29 @@ void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/ )
SendGMTicketGetTicket(0x0A); SendGMTicketGetTicket(0x0A);
} }
void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket & recv_data ) void WorldSession::HandleGMTicketUpdateTextOpcode(WorldPacket& recv_data)
{ {
std::string ticketText; std::string ticketText;
recv_data >> ticketText; recv_data >> ticketText;
if(GMTicket* ticket = sTicketMgr.GetGMTicket(GetPlayer()->GetObjectGuid())) if (GMTicket* ticket = sTicketMgr.GetGMTicket(GetPlayer()->GetObjectGuid()))
ticket->SetText(ticketText.c_str()); ticket->SetText(ticketText.c_str());
else else
sLog.outError("Ticket update: Player %s (GUID: %u) doesn't have active ticket", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); sLog.outError("Ticket update: Player %s (GUID: %u) doesn't have active ticket", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
} }
void WorldSession::HandleGMTicketDeleteTicketOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGMTicketDeleteTicketOpcode(WorldPacket& /*recv_data*/)
{ {
sTicketMgr.Delete(GetPlayer()->GetObjectGuid()); sTicketMgr.Delete(GetPlayer()->GetObjectGuid());
WorldPacket data( SMSG_GMTICKET_DELETETICKET, 4 ); WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4);
data << uint32(9); data << uint32(9);
SendPacket( &data ); SendPacket(&data);
SendGMTicketGetTicket(0x0A); SendGMTicketGetTicket(0x0A);
} }
void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data ) void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recv_data)
{ {
uint32 map; uint32 map;
float x, y, z; float x, y, z;
@ -113,27 +113,27 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
DEBUG_LOG("TicketCreate: map %u, x %f, y %f, z %f, text %s", map, x, y, z, ticketText.c_str()); DEBUG_LOG("TicketCreate: map %u, x %f, y %f, z %f, text %s", map, x, y, z, ticketText.c_str());
if(sTicketMgr.GetGMTicket(GetPlayer()->GetObjectGuid()) && !isFollowup) if (sTicketMgr.GetGMTicket(GetPlayer()->GetObjectGuid()) && !isFollowup)
{ {
WorldPacket data( SMSG_GMTICKET_CREATE, 4 ); WorldPacket data(SMSG_GMTICKET_CREATE, 4);
data << uint32(1); // 1 - You already have GM ticket data << uint32(1); // 1 - You already have GM ticket
SendPacket( &data ); SendPacket(&data);
return; return;
} }
if(isFollowup) if (isFollowup)
sTicketMgr.Delete(_player->GetObjectGuid()); sTicketMgr.Delete(_player->GetObjectGuid());
sTicketMgr.Create(_player->GetObjectGuid(), ticketText.c_str()); sTicketMgr.Create(_player->GetObjectGuid(), ticketText.c_str());
SendQueryTimeResponse(); SendQueryTimeResponse();
WorldPacket data( SMSG_GMTICKET_CREATE, 4 ); WorldPacket data(SMSG_GMTICKET_CREATE, 4);
data << uint32(2); // 2 - nothing appears (3-error creating, 5-error updating) data << uint32(2); // 2 - nothing appears (3-error creating, 5-error updating)
SendPacket( &data ); SendPacket(&data);
//TODO: Guard player map //TODO: Guard player map
HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers(); HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets()) if (itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets())
@ -141,15 +141,15 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
} }
} }
void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGMTicketSystemStatusOpcode(WorldPacket& /*recv_data*/)
{ {
WorldPacket data( SMSG_GMTICKET_SYSTEMSTATUS, 4 ); WorldPacket data(SMSG_GMTICKET_SYSTEMSTATUS, 4);
data << uint32(1); // we can also disable ticket system by sending 0 value data << uint32(1); // we can also disable ticket system by sending 0 value
SendPacket( &data ); SendPacket(&data);
} }
void WorldSession::HandleGMSurveySubmitOpcode( WorldPacket & recv_data) void WorldSession::HandleGMSurveySubmitOpcode(WorldPacket& recv_data)
{ {
// GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3 // GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3
uint32 x; uint32 x;
@ -158,7 +158,7 @@ void WorldSession::HandleGMSurveySubmitOpcode( WorldPacket & recv_data)
uint8 result[10]; uint8 result[10];
memset(result, 0, sizeof(result)); memset(result, 0, sizeof(result));
for( int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
uint32 questionID; uint32 questionID;
recv_data >> questionID; // GMSurveyQuestions.dbc recv_data >> questionID; // GMSurveyQuestions.dbc
@ -181,7 +181,7 @@ void WorldSession::HandleGMSurveySubmitOpcode( WorldPacket & recv_data)
// TODO: chart this data in some way // TODO: chart this data in some way
} }
void WorldSession::HandleGMResponseResolveOpcode(WorldPacket & recv_data) void WorldSession::HandleGMResponseResolveOpcode(WorldPacket& recv_data)
{ {
// empty opcode // empty opcode
DEBUG_LOG("WORLD: %s", LookupOpcodeName(recv_data.GetOpcode())); DEBUG_LOG("WORLD: %s", LookupOpcodeName(recv_data.GetOpcode()));

View file

@ -32,11 +32,11 @@ void GMTicketMgr::LoadGMTickets()
{ {
m_GMTicketMap.clear(); // For reload case m_GMTicketMap.clear(); // For reload case
QueryResult *result = CharacterDatabase.Query( QueryResult* result = CharacterDatabase.Query(
// 0 1 2 3 4 // 0 1 2 3 4
"SELECT guid, ticket_text, response_text, UNIX_TIMESTAMP(ticket_lastchange), ticket_id FROM character_ticket ORDER BY ticket_id ASC"); "SELECT guid, ticket_text, response_text, UNIX_TIMESTAMP(ticket_lastchange), ticket_id FROM character_ticket ORDER BY ticket_id ASC");
if( !result ) if (!result)
{ {
BarGoLink bar(1); BarGoLink bar(1);
@ -72,7 +72,8 @@ void GMTicketMgr::LoadGMTickets()
ticket.Init(guid, fields[1].GetCppString(), fields[2].GetCppString(), time_t(fields[3].GetUInt64())); ticket.Init(guid, fields[1].GetCppString(), fields[2].GetCppString(), time_t(fields[3].GetUInt64()));
m_GMTicketListByCreatingOrder.push_back(&ticket); m_GMTicketListByCreatingOrder.push_back(&ticket);
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
@ -81,9 +82,9 @@ void GMTicketMgr::LoadGMTickets()
void GMTicketMgr::DeleteAll() void GMTicketMgr::DeleteAll()
{ {
for(GMTicketMap::const_iterator itr = m_GMTicketMap.begin(); itr != m_GMTicketMap.end(); ++itr) for (GMTicketMap::const_iterator itr = m_GMTicketMap.begin(); itr != m_GMTicketMap.end(); ++itr)
{ {
if(Player* owner = sObjectMgr.GetPlayer(itr->first)) if (Player* owner = sObjectMgr.GetPlayer(itr->first))
owner->GetSession()->SendGMTicketGetTicket(0x0A); owner->GetSession()->SendGMTicketGetTicket(0x0A);
} }
CharacterDatabase.Execute("DELETE FROM character_ticket"); CharacterDatabase.Execute("DELETE FROM character_ticket");

View file

@ -121,7 +121,7 @@ class GMTicketMgr
GMTicket* GetGMTicket(ObjectGuid guid) GMTicket* GetGMTicket(ObjectGuid guid)
{ {
GMTicketMap::iterator itr = m_GMTicketMap.find(guid); GMTicketMap::iterator itr = m_GMTicketMap.find(guid);
if(itr == m_GMTicketMap.end()) if (itr == m_GMTicketMap.end())
return NULL; return NULL;
return &(itr->second); return &(itr->second);
} }
@ -138,7 +138,7 @@ class GMTicketMgr
GMTicketList::iterator itr = m_GMTicketListByCreatingOrder.begin(); GMTicketList::iterator itr = m_GMTicketListByCreatingOrder.begin();
std::advance(itr, pos); std::advance(itr, pos);
if(itr == m_GMTicketListByCreatingOrder.end()) if (itr == m_GMTicketListByCreatingOrder.end())
return NULL; return NULL;
return *itr; return *itr;
} }
@ -147,7 +147,7 @@ class GMTicketMgr
void Delete(ObjectGuid guid) void Delete(ObjectGuid guid)
{ {
GMTicketMap::iterator itr = m_GMTicketMap.find(guid); GMTicketMap::iterator itr = m_GMTicketMap.find(guid);
if(itr == m_GMTicketMap.end()) if (itr == m_GMTicketMap.end())
return; return;
itr->second.DeleteFromDB(); itr->second.DeleteFromDB();
m_GMTicketListByCreatingOrder.remove(&itr->second); m_GMTicketListByCreatingOrder.remove(&itr->second);

View file

@ -35,8 +35,8 @@ INSTANTIATE_SINGLETON_1(GameEventMgr);
bool GameEventMgr::CheckOneGameEvent(uint16 entry, time_t currenttime) const bool GameEventMgr::CheckOneGameEvent(uint16 entry, time_t currenttime) const
{ {
// Get the event information // Get the event information
if( mGameEvent[entry].start < currenttime && currenttime < mGameEvent[entry].end && if (mGameEvent[entry].start < currenttime && currenttime < mGameEvent[entry].end &&
((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE)) < (mGameEvent[entry].length * MINUTE) ) ((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE)) < (mGameEvent[entry].length * MINUTE))
return true; return true;
else else
return false; return false;
@ -68,24 +68,24 @@ uint32 GameEventMgr::NextCheck(uint16 entry) const
return delay; return delay;
} }
void GameEventMgr::StartEvent( uint16 event_id, bool overwrite /*=false*/, bool resume /*=false*/) void GameEventMgr::StartEvent(uint16 event_id, bool overwrite /*=false*/, bool resume /*=false*/)
{ {
ApplyNewEvent(event_id, resume); ApplyNewEvent(event_id, resume);
if(overwrite) if (overwrite)
{ {
mGameEvent[event_id].start = time(NULL); mGameEvent[event_id].start = time(NULL);
if(mGameEvent[event_id].end <= mGameEvent[event_id].start) if (mGameEvent[event_id].end <= mGameEvent[event_id].start)
mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length; mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length;
} }
} }
void GameEventMgr::StopEvent( uint16 event_id, bool overwrite ) void GameEventMgr::StopEvent(uint16 event_id, bool overwrite)
{ {
UnApplyEvent(event_id); UnApplyEvent(event_id);
if(overwrite) if (overwrite)
{ {
mGameEvent[event_id].start = time(NULL) - mGameEvent[event_id].length * MINUTE; mGameEvent[event_id].start = time(NULL) - mGameEvent[event_id].length * MINUTE;
if(mGameEvent[event_id].end <= mGameEvent[event_id].start) if (mGameEvent[event_id].end <= mGameEvent[event_id].start)
mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length; mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length;
} }
} }
@ -93,15 +93,15 @@ void GameEventMgr::StopEvent( uint16 event_id, bool overwrite )
void GameEventMgr::LoadFromDB() void GameEventMgr::LoadFromDB()
{ {
{ {
QueryResult *result = WorldDatabase.Query("SELECT MAX(entry) FROM game_event"); QueryResult* result = WorldDatabase.Query("SELECT MAX(entry) FROM game_event");
if( !result ) if (!result)
{ {
sLog.outString(">> Table game_event is empty."); sLog.outString(">> Table game_event is empty.");
sLog.outString(); sLog.outString();
return; return;
} }
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 max_event_id = fields[0].GetUInt16(); uint32 max_event_id = fields[0].GetUInt16();
delete result; delete result;
@ -109,7 +109,7 @@ void GameEventMgr::LoadFromDB()
mGameEvent.resize(max_event_id+1); mGameEvent.resize(max_event_id+1);
} }
QueryResult *result = WorldDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,holiday,description FROM game_event"); QueryResult* result = WorldDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,holiday,description FROM game_event");
if (!result) if (!result)
{ {
mGameEvent.clear(); mGameEvent.clear();
@ -125,7 +125,7 @@ void GameEventMgr::LoadFromDB()
do do
{ {
++count; ++count;
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
@ -168,7 +168,8 @@ void GameEventMgr::LoadFromDB()
pGameEvent.description = fields[6].GetCppString(); pGameEvent.description = fields[6].GetCppString();
} while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
@ -185,7 +186,7 @@ void GameEventMgr::LoadFromDB()
mGameEventCreatureGuids.resize(mGameEvent.size()*2-1); mGameEventCreatureGuids.resize(mGameEvent.size()*2-1);
// 1 2 // 1 2
result = WorldDatabase.Query("SELECT creature.guid, game_event_creature.event " result = WorldDatabase.Query("SELECT creature.guid, game_event_creature.event "
"FROM creature JOIN game_event_creature ON creature.guid = game_event_creature.guid"); "FROM creature JOIN game_event_creature ON creature.guid = game_event_creature.guid");
count = 0; count = 0;
if (!result) if (!result)
@ -194,7 +195,7 @@ void GameEventMgr::LoadFromDB()
bar.step(); bar.step();
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u creatures in game events", count ); sLog.outString(">> Loaded %u creatures in game events", count);
} }
else else
{ {
@ -202,7 +203,7 @@ void GameEventMgr::LoadFromDB()
BarGoLink bar(result->GetRowCount()); BarGoLink bar(result->GetRowCount());
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
@ -253,17 +254,18 @@ void GameEventMgr::LoadFromDB()
GuidList& crelist = mGameEventCreatureGuids[internal_event_id]; GuidList& crelist = mGameEventCreatureGuids[internal_event_id];
crelist.push_back(guid); crelist.push_back(guid);
} while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
sLog.outString( ">> Loaded %u creatures in game events", count ); sLog.outString(">> Loaded %u creatures in game events", count);
} }
mGameEventGameobjectGuids.resize(mGameEvent.size()*2-1); mGameEventGameobjectGuids.resize(mGameEvent.size()*2-1);
// 1 2 // 1 2
result = WorldDatabase.Query("SELECT gameobject.guid, game_event_gameobject.event " result = WorldDatabase.Query("SELECT gameobject.guid, game_event_gameobject.event "
"FROM gameobject JOIN game_event_gameobject ON gameobject.guid=game_event_gameobject.guid"); "FROM gameobject JOIN game_event_gameobject ON gameobject.guid=game_event_gameobject.guid");
count = 0; count = 0;
if (!result) if (!result)
@ -272,7 +274,7 @@ void GameEventMgr::LoadFromDB()
bar.step(); bar.step();
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u gameobjects in game events", count ); sLog.outString(">> Loaded %u gameobjects in game events", count);
} }
else else
{ {
@ -280,7 +282,7 @@ void GameEventMgr::LoadFromDB()
BarGoLink bar(result->GetRowCount()); BarGoLink bar(result->GetRowCount());
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
@ -331,15 +333,16 @@ void GameEventMgr::LoadFromDB()
GuidList& golist = mGameEventGameobjectGuids[internal_event_id]; GuidList& golist = mGameEventGameobjectGuids[internal_event_id];
golist.push_back(guid); golist.push_back(guid);
} while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
sLog.outString( ">> Loaded %u gameobjects in game events", count ); sLog.outString(">> Loaded %u gameobjects in game events", count);
} }
// now recheck that all eventPools linked with events after our skip pools with parents // now recheck that all eventPools linked with events after our skip pools with parents
for(std::map<uint16,int16>::const_iterator itr = pool2event.begin(); itr != pool2event.end(); ++itr) for (std::map<uint16,int16>::const_iterator itr = pool2event.begin(); itr != pool2event.end(); ++itr)
{ {
uint16 pool_id = itr->first; uint16 pool_id = itr->first;
int16 event_id = itr->second; int16 event_id = itr->second;
@ -350,11 +353,11 @@ void GameEventMgr::LoadFromDB()
mGameEventCreatureData.resize(mGameEvent.size()); mGameEventCreatureData.resize(mGameEvent.size());
// 0 1 2 // 0 1 2
result = WorldDatabase.Query("SELECT creature.guid, game_event_creature_data.event, game_event_creature_data.modelid," result = WorldDatabase.Query("SELECT creature.guid, game_event_creature_data.event, game_event_creature_data.modelid,"
// 3 4 // 3 4
"game_event_creature_data.equipment_id, game_event_creature_data.entry_id, " "game_event_creature_data.equipment_id, game_event_creature_data.entry_id, "
// 5 6 // 5 6
"game_event_creature_data.spell_start, game_event_creature_data.spell_end " "game_event_creature_data.spell_start, game_event_creature_data.spell_end "
"FROM creature JOIN game_event_creature_data ON creature.guid=game_event_creature_data.guid"); "FROM creature JOIN game_event_creature_data ON creature.guid=game_event_creature_data.guid");
count = 0; count = 0;
if (!result) if (!result)
@ -363,7 +366,7 @@ void GameEventMgr::LoadFromDB()
bar.step(); bar.step();
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u creature reactions at game events", count ); sLog.outString(">> Loaded %u creature reactions at game events", count);
} }
else else
{ {
@ -371,7 +374,7 @@ void GameEventMgr::LoadFromDB()
BarGoLink bar(result->GetRowCount()); BarGoLink bar(result->GetRowCount());
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
uint32 guid = fields[0].GetUInt32(); uint32 guid = fields[0].GetUInt32();
@ -425,11 +428,12 @@ void GameEventMgr::LoadFromDB()
equiplist.push_back(GameEventCreatureDataPair(guid, newData)); equiplist.push_back(GameEventCreatureDataPair(guid, newData));
mGameEventCreatureDataPerGuid.insert(GameEventCreatureDataPerGuidMap::value_type(guid, event_id)); mGameEventCreatureDataPerGuid.insert(GameEventCreatureDataPerGuidMap::value_type(guid, event_id));
} while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u creature reactions at game events", count ); sLog.outString(">> Loaded %u creature reactions at game events", count);
} }
mGameEventQuests.resize(mGameEvent.size()); mGameEventQuests.resize(mGameEvent.size());
@ -443,7 +447,7 @@ void GameEventMgr::LoadFromDB()
bar.step(); bar.step();
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u quests additions in game events", count ); sLog.outString(">> Loaded %u quests additions in game events", count);
} }
else else
{ {
@ -451,7 +455,7 @@ void GameEventMgr::LoadFromDB()
BarGoLink bar(result->GetRowCount()); BarGoLink bar(result->GetRowCount());
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
uint32 quest = fields[0].GetUInt32(); uint32 quest = fields[0].GetUInt32();
@ -485,11 +489,12 @@ void GameEventMgr::LoadFromDB()
QuestList& questlist = mGameEventQuests[event_id]; QuestList& questlist = mGameEventQuests[event_id];
questlist.push_back(quest); questlist.push_back(quest);
} while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
sLog.outString( ">> Loaded %u quest additions in game events", count ); sLog.outString(">> Loaded %u quest additions in game events", count);
} }
mGameEventMails.resize(mGameEvent.size()*2-1); mGameEventMails.resize(mGameEvent.size()*2-1);
@ -503,7 +508,7 @@ void GameEventMgr::LoadFromDB()
bar.step(); bar.step();
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u start/end game event mails", count ); sLog.outString(">> Loaded %u start/end game event mails", count);
} }
else else
{ {
@ -511,7 +516,7 @@ void GameEventMgr::LoadFromDB()
BarGoLink bar(result->GetRowCount()); BarGoLink bar(result->GetRowCount());
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
uint16 event_id = fields[0].GetUInt16(); uint16 event_id = fields[0].GetUInt16();
@ -565,11 +570,12 @@ void GameEventMgr::LoadFromDB()
MailList& maillist = mGameEventMails[internal_event_id]; MailList& maillist = mGameEventMails[internal_event_id];
maillist.push_back(mail); maillist.push_back(mail);
} while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u start/end game event mails", count ); sLog.outString(">> Loaded %u start/end game event mails", count);
} }
} }
@ -579,30 +585,31 @@ uint32 GameEventMgr::Initialize() // return the next e
ActiveEvents activeAtShutdown; ActiveEvents activeAtShutdown;
if (QueryResult *result = CharacterDatabase.Query("SELECT event FROM game_event_status")) if (QueryResult* result = CharacterDatabase.Query("SELECT event FROM game_event_status"))
{ {
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint16 event_id = fields[0].GetUInt16(); uint16 event_id = fields[0].GetUInt16();
activeAtShutdown.insert(event_id); activeAtShutdown.insert(event_id);
} while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
CharacterDatabase.Execute("TRUNCATE game_event_status"); CharacterDatabase.Execute("TRUNCATE game_event_status");
} }
uint32 delay = Update(&activeAtShutdown); uint32 delay = Update(&activeAtShutdown);
BASIC_LOG("Game Event system initialized." ); BASIC_LOG("Game Event system initialized.");
m_IsGameEventsInit = true; m_IsGameEventsInit = true;
return delay; return delay;
} }
void GameEventMgr::Initialize( MapPersistentState* state ) void GameEventMgr::Initialize(MapPersistentState* state)
{ {
// At map persistent state creating need only apply pool spawn modifications // At map persistent state creating need only apply pool spawn modifications
// other data is global and will be auto-apply // other data is global and will be auto-apply
for(GameEventMgr::ActiveEvents::const_iterator event_itr = m_ActiveEvents.begin(); event_itr != m_ActiveEvents.end(); ++event_itr) for (GameEventMgr::ActiveEvents::const_iterator event_itr = m_ActiveEvents.begin(); event_itr != m_ActiveEvents.end(); ++event_itr)
for (IdList::iterator pool_itr = mGameEventSpawnPoolIds[*event_itr].begin(); pool_itr != mGameEventSpawnPoolIds[*event_itr].end(); ++pool_itr) for (IdList::iterator pool_itr = mGameEventSpawnPoolIds[*event_itr].begin(); pool_itr != mGameEventSpawnPoolIds[*event_itr].end(); ++pool_itr)
sPoolMgr.InitSpawnPool(*state, *pool_itr); sPoolMgr.InitSpawnPool(*state, *pool_itr);
} }
@ -704,7 +711,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
return; return;
} }
for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin();itr != mGameEventCreatureGuids[internal_event_id].end();++itr) for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr)
{ {
// Add to correct cell // Add to correct cell
CreatureData const* data = sObjectMgr.GetCreatureData(*itr); CreatureData const* data = sObjectMgr.GetCreatureData(*itr);
@ -734,7 +741,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
return; return;
} }
for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin();itr != mGameEventGameobjectGuids[internal_event_id].end();++itr) for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr)
{ {
// Add to correct cell // Add to correct cell
GameObjectData const* data = sObjectMgr.GetGOData(*itr); GameObjectData const* data = sObjectMgr.GetGOData(*itr);
@ -760,13 +767,13 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
if (event_id > 0) if (event_id > 0)
{ {
if((size_t)event_id >= mGameEventSpawnPoolIds.size()) if ((size_t)event_id >= mGameEventSpawnPoolIds.size())
{ {
sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventSpawnPoolIds element %i (size: " SIZEFMTD ")", event_id, mGameEventSpawnPoolIds.size()); sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventSpawnPoolIds element %i (size: " SIZEFMTD ")", event_id, mGameEventSpawnPoolIds.size());
return; return;
} }
for (IdList::iterator itr = mGameEventSpawnPoolIds[event_id].begin();itr != mGameEventSpawnPoolIds[event_id].end();++itr) for (IdList::iterator itr = mGameEventSpawnPoolIds[event_id].begin(); itr != mGameEventSpawnPoolIds[event_id].end(); ++itr)
sPoolMgr.SpawnPoolInMaps(*itr, true); sPoolMgr.SpawnPoolInMaps(*itr, true);
} }
} }
@ -781,10 +788,10 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
return; return;
} }
for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin();itr != mGameEventCreatureGuids[internal_event_id].end();++itr) for (GuidList::iterator itr = mGameEventCreatureGuids[internal_event_id].begin(); itr != mGameEventCreatureGuids[internal_event_id].end(); ++itr)
{ {
// Remove the creature from grid // Remove the creature from grid
if( CreatureData const* data = sObjectMgr.GetCreatureData(*itr) ) if (CreatureData const* data = sObjectMgr.GetCreatureData(*itr))
{ {
// negative event id for pool element meaning unspawn in pool and exclude for next spawns // negative event id for pool element meaning unspawn in pool and exclude for next spawns
if (event_id < 0) if (event_id < 0)
@ -811,10 +818,10 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
return; return;
} }
for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin();itr != mGameEventGameobjectGuids[internal_event_id].end();++itr) for (GuidList::iterator itr = mGameEventGameobjectGuids[internal_event_id].begin(); itr != mGameEventGameobjectGuids[internal_event_id].end(); ++itr)
{ {
// Remove the gameobject from grid // Remove the gameobject from grid
if(GameObjectData const* data = sObjectMgr.GetGOData(*itr)) if (GameObjectData const* data = sObjectMgr.GetGOData(*itr))
{ {
// negative event id for pool element meaning unspawn in pool and exclude for next spawns // negative event id for pool element meaning unspawn in pool and exclude for next spawns
if (event_id < 0) if (event_id < 0)
@ -843,7 +850,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
return; return;
} }
for (IdList::iterator itr = mGameEventSpawnPoolIds[event_id].begin();itr != mGameEventSpawnPoolIds[event_id].end();++itr) for (IdList::iterator itr = mGameEventSpawnPoolIds[event_id].begin(); itr != mGameEventSpawnPoolIds[event_id].end(); ++itr)
{ {
sPoolMgr.DespawnPoolInMaps(*itr); sPoolMgr.DespawnPoolInMaps(*itr);
} }
@ -855,7 +862,7 @@ GameEventCreatureData const* GameEventMgr::GetCreatureUpdateDataForActiveEvent(u
// only for active event, creature can be listed for many so search all // only for active event, creature can be listed for many so search all
uint32 event_id = 0; uint32 event_id = 0;
GameEventCreatureDataPerGuidBounds bounds = mGameEventCreatureDataPerGuid.equal_range(lowguid); GameEventCreatureDataPerGuidBounds bounds = mGameEventCreatureDataPerGuid.equal_range(lowguid);
for(GameEventCreatureDataPerGuidMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) for (GameEventCreatureDataPerGuidMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
{ {
if (IsActiveEvent(itr->second)) if (IsActiveEvent(itr->second))
{ {
@ -867,7 +874,7 @@ GameEventCreatureData const* GameEventMgr::GetCreatureUpdateDataForActiveEvent(u
if (!event_id) if (!event_id)
return NULL; return NULL;
for(GameEventCreatureDataList::const_iterator itr = mGameEventCreatureData[event_id].begin();itr != mGameEventCreatureData[event_id].end();++itr) for (GameEventCreatureDataList::const_iterator itr = mGameEventCreatureData[event_id].begin(); itr != mGameEventCreatureData[event_id].end(); ++itr)
if (itr->first == lowguid) if (itr->first == lowguid)
return &itr->second; return &itr->second;
@ -879,7 +886,7 @@ struct GameEventUpdateCreatureDataInMapsWorker
GameEventUpdateCreatureDataInMapsWorker(ObjectGuid guid, CreatureData const* data, GameEventCreatureData* event_data, bool activate) GameEventUpdateCreatureDataInMapsWorker(ObjectGuid guid, CreatureData const* data, GameEventCreatureData* event_data, bool activate)
: i_guid(guid), i_data(data), i_event_data(event_data), i_activate(activate) {} : i_guid(guid), i_data(data), i_event_data(event_data), i_activate(activate) {}
void operator() (Map* map) void operator()(Map* map)
{ {
if (Creature* pCreature = map->GetCreature(i_guid)) if (Creature* pCreature = map->GetCreature(i_guid))
{ {
@ -899,11 +906,11 @@ struct GameEventUpdateCreatureDataInMapsWorker
void GameEventMgr::UpdateCreatureData(int16 event_id, bool activate) void GameEventMgr::UpdateCreatureData(int16 event_id, bool activate)
{ {
for(GameEventCreatureDataList::iterator itr = mGameEventCreatureData[event_id].begin();itr != mGameEventCreatureData[event_id].end();++itr) for (GameEventCreatureDataList::iterator itr = mGameEventCreatureData[event_id].begin(); itr != mGameEventCreatureData[event_id].end(); ++itr)
{ {
// Remove the creature from grid // Remove the creature from grid
CreatureData const* data = sObjectMgr.GetCreatureData(itr->first); CreatureData const* data = sObjectMgr.GetCreatureData(itr->first);
if(!data) if (!data)
continue; continue;
// Update if spawned // Update if spawned
@ -917,11 +924,11 @@ void GameEventMgr::UpdateEventQuests(uint16 event_id, bool Activate)
QuestList::iterator itr; QuestList::iterator itr;
for (itr = mGameEventQuests[event_id].begin(); itr != mGameEventQuests[event_id].end(); ++itr) for (itr = mGameEventQuests[event_id].begin(); itr != mGameEventQuests[event_id].end(); ++itr)
{ {
const Quest *pQuest = sObjectMgr.GetQuestTemplate(*itr); const Quest* pQuest = sObjectMgr.GetQuestTemplate(*itr);
//if (Activate) //if (Activate)
//{ //{
// TODO: implement way to reset quests when event begin. // TODO: implement way to reset quests when event begin.
//} //}
const_cast<Quest*>(pQuest)->SetQuestActiveState(Activate); const_cast<Quest*>(pQuest)->SetQuestActiveState(Activate);
@ -936,7 +943,7 @@ void GameEventMgr::UpdateWorldStates(uint16 event_id, bool Activate)
BattleGroundTypeId bgTypeId = BattleGroundMgr::WeekendHolidayIdToBGType(event.holiday_id); BattleGroundTypeId bgTypeId = BattleGroundMgr::WeekendHolidayIdToBGType(event.holiday_id);
if (bgTypeId != BATTLEGROUND_TYPE_NONE) if (bgTypeId != BATTLEGROUND_TYPE_NONE)
{ {
BattlemasterListEntry const * bl = sBattlemasterListStore.LookupEntry(bgTypeId); BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
if (bl && bl->HolidayWorldStateId) if (bl && bl->HolidayWorldStateId)
{ {
WorldPacket data; WorldPacket data;
@ -960,7 +967,7 @@ void GameEventMgr::SendEventMails(int16 event_id)
// need special query // need special query
std::ostringstream ss; std::ostringstream ss;
ss << "SELECT characters.guid FROM characters, character_queststatus " ss << "SELECT characters.guid FROM characters, character_queststatus "
"WHERE (1 << (characters.race - 1)) & " "WHERE (1 << (characters.race - 1)) & "
<< itr->raceMask << itr->raceMask
<< " AND characters.deleteDate IS NULL AND character_queststatus.guid = characters.guid AND character_queststatus.quest = " << " AND characters.deleteDate IS NULL AND character_queststatus.guid = characters.guid AND character_queststatus.quest = "
<< itr->questId << itr->questId
@ -979,7 +986,7 @@ int16 GameEventMgr::GetGameEventId<Creature>(uint32 guid_or_poolid)
for (uint16 i = 0; i < mGameEventCreatureGuids.size(); i++) // 0 <= i <= 2*(S := mGameEvent.size()) - 2 for (uint16 i = 0; i < mGameEventCreatureGuids.size(); i++) // 0 <= i <= 2*(S := mGameEvent.size()) - 2
for (GuidList::const_iterator itr = mGameEventCreatureGuids[i].begin(); itr != mGameEventCreatureGuids[i].end(); ++itr) for (GuidList::const_iterator itr = mGameEventCreatureGuids[i].begin(); itr != mGameEventCreatureGuids[i].end(); ++itr)
if (*itr == guid_or_poolid) if (*itr == guid_or_poolid)
return i + 1 - mGameEvent.size(); // -S *1 + 1 <= . <= 1*S - 1 return i + 1 - mGameEvent.size(); // -S *1 + 1 <= . <= 1*S - 1
return 0; return 0;
} }
@ -1010,19 +1017,19 @@ GameEventMgr::GameEventMgr()
m_IsGameEventsInit = false; m_IsGameEventsInit = false;
} }
bool GameEventMgr::IsActiveHoliday( HolidayIds id ) bool GameEventMgr::IsActiveHoliday(HolidayIds id)
{ {
if (id == HOLIDAY_NONE) if (id == HOLIDAY_NONE)
return false; return false;
for(GameEventMgr::ActiveEvents::const_iterator itr = m_ActiveEvents.begin(); itr != m_ActiveEvents.end(); ++itr) for (GameEventMgr::ActiveEvents::const_iterator itr = m_ActiveEvents.begin(); itr != m_ActiveEvents.end(); ++itr)
if (mGameEvent[*itr].holiday_id == id) if (mGameEvent[*itr].holiday_id == id)
return true; return true;
return false; return false;
} }
MANGOS_DLL_SPEC bool IsHolidayActive( HolidayIds id ) MANGOS_DLL_SPEC bool IsHolidayActive(HolidayIds id)
{ {
return sGameEventMgr.IsActiveHoliday(id); return sGameEventMgr.IsActiveHoliday(id);
} }

View file

@ -81,7 +81,7 @@ class GameEventMgr
void Initialize(MapPersistentState* state); // called at new MapPersistentState object create void Initialize(MapPersistentState* state); // called at new MapPersistentState object create
uint32 Update(ActiveEvents const* activeAtShutdown = NULL); uint32 Update(ActiveEvents const* activeAtShutdown = NULL);
bool IsValidEvent(uint16 event_id) const { return event_id < mGameEvent.size() && mGameEvent[event_id].isValid(); } bool IsValidEvent(uint16 event_id) const { return event_id < mGameEvent.size() && mGameEvent[event_id].isValid(); }
bool IsActiveEvent(uint16 event_id) const { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); } bool IsActiveEvent(uint16 event_id) const { return (m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); }
bool IsActiveHoliday(HolidayIds id); bool IsActiveHoliday(HolidayIds id);
uint32 Initialize(); uint32 Initialize();
void StartEvent(uint16 event_id, bool overwrite = false, bool resume = false); void StartEvent(uint16 event_id, bool overwrite = false, bool resume = false);

View file

@ -74,7 +74,7 @@ GameObject::~GameObject()
void GameObject::AddToWorld() void GameObject::AddToWorld()
{ {
///- Register the gameobject for guid lookup ///- Register the gameobject for guid lookup
if(!IsInWorld()) if (!IsInWorld())
GetMap()->GetObjectsStore().insert<GameObject>(GetObjectGuid(), (GameObject*)this); GetMap()->GetObjectsStore().insert<GameObject>(GetObjectGuid(), (GameObject*)this);
Object::AddToWorld(); Object::AddToWorld();
@ -83,7 +83,7 @@ void GameObject::AddToWorld()
void GameObject::RemoveFromWorld() void GameObject::RemoveFromWorld()
{ {
///- Remove the gameobject from the accessor ///- Remove the gameobject from the accessor
if(IsInWorld()) if (IsInWorld())
{ {
// Remove GO from owner // Remove GO from owner
if (ObjectGuid owner_guid = GetOwnerGuid()) if (ObjectGuid owner_guid = GetOwnerGuid())
@ -93,7 +93,7 @@ void GameObject::RemoveFromWorld()
else else
{ {
sLog.outError("Delete %s with SpellId %u LinkedGO %u that lost references to owner %s GO list. Crash possible later.", sLog.outError("Delete %s with SpellId %u LinkedGO %u that lost references to owner %s GO list. Crash possible later.",
GetGuidStr().c_str(), m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), owner_guid.GetString().c_str()); GetGuidStr().c_str(), m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), owner_guid.GetString().c_str());
} }
} }
@ -103,14 +103,14 @@ void GameObject::RemoveFromWorld()
Object::RemoveFromWorld(); Object::RemoveFromWorld();
} }
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, QuaternionData rotation, uint8 animprogress, GOState go_state) bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, QuaternionData rotation, uint8 animprogress, GOState go_state)
{ {
MANGOS_ASSERT(map); MANGOS_ASSERT(map);
Relocate(x,y,z,ang); Relocate(x,y,z,ang);
SetMap(map); SetMap(map);
SetPhaseMask(phaseMask,false); SetPhaseMask(phaseMask,false);
if(!IsPositionValid()) if (!IsPositionValid())
{ {
sLog.outError("Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates are invalid (X: %f Y: %f)",guidlow,name_id,x,y); sLog.outError("Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates are invalid (X: %f Y: %f)",guidlow,name_id,x,y);
return false; return false;
@ -137,7 +137,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
SetWorldRotation(rotation.x,rotation.y,rotation.z,rotation.w); SetWorldRotation(rotation.x,rotation.y,rotation.z,rotation.w);
// For most of gameobjects is (0, 0, 0, 1) quaternion, only some transports has not standart rotation // For most of gameobjects is (0, 0, 0, 1) quaternion, only some transports has not standart rotation
if (const GameObjectDataAddon * addon = sGameObjectDataAddonStorage.LookupEntry<GameObjectDataAddon>(guidlow)) if (const GameObjectDataAddon* addon = sGameObjectDataAddonStorage.LookupEntry<GameObjectDataAddon>(guidlow))
SetTransportPathRotation(addon->path_rotation); SetTransportPathRotation(addon->path_rotation);
else else
SetTransportPathRotation(QuaternionData(0,0,0,1)); SetTransportPathRotation(QuaternionData(0,0,0,1));
@ -182,7 +182,7 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
{ {
case GO_NOT_READY: case GO_NOT_READY:
{ {
switch(GetGoType()) switch (GetGoType())
{ {
case GAMEOBJECT_TYPE_TRAP: case GAMEOBJECT_TYPE_TRAP:
{ {
@ -322,7 +322,7 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
if (ok) if (ok)
{ {
Unit *caster = owner ? owner : ok; Unit* caster = owner ? owner : ok;
caster->CastSpell(ok, goInfo->trap.spellId, true, NULL, NULL, GetObjectGuid()); caster->CastSpell(ok, goInfo->trap.spellId, true, NULL, NULL, GetObjectGuid());
// use template cooldown if provided // use template cooldown if provided
@ -336,7 +336,7 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
{ {
//BattleGround gameobjects case //BattleGround gameobjects case
if (((Player*)ok)->InBattleGround()) if (((Player*)ok)->InBattleGround())
if (BattleGround *bg = ((Player*)ok)->GetBattleGround()) if (BattleGround* bg = ((Player*)ok)->GetBattleGround())
bg->HandleTriggerBuff(GetObjectGuid()); bg->HandleTriggerBuff(GetObjectGuid());
} }
} }
@ -355,7 +355,7 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
} }
case GO_ACTIVATED: case GO_ACTIVATED:
{ {
switch(GetGoType()) switch (GetGoType())
{ {
case GAMEOBJECT_TYPE_DOOR: case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON: case GAMEOBJECT_TYPE_BUTTON:
@ -483,10 +483,10 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
void GameObject::Refresh() void GameObject::Refresh()
{ {
// not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway) // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway)
if(m_respawnTime > 0 && m_spawnedByDefault) if (m_respawnTime > 0 && m_spawnedByDefault)
return; return;
if(isSpawned()) if (isSpawned())
GetMap()->Add(this); GetMap()->Add(this);
} }
@ -514,7 +514,7 @@ void GameObject::Delete()
AddObjectToRemoveList(); AddObjectToRemoveList();
} }
void GameObject::getFishLoot(Loot *fishloot, Player* loot_owner) void GameObject::getFishLoot(Loot* fishloot, Player* loot_owner)
{ {
fishloot->clear(); fishloot->clear();
@ -531,8 +531,8 @@ void GameObject::SaveToDB()
{ {
// this should only be used when the gameobject has already been loaded // this should only be used when the gameobject has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise // preferably after adding to map, because mapid may not be valid otherwise
GameObjectData const *data = sObjectMgr.GetGOData(GetGUIDLow()); GameObjectData const* data = sObjectMgr.GetGOData(GetGUIDLow());
if(!data) if (!data)
{ {
sLog.outError("GameObject::SaveToDB failed, cannot get gameobject data!"); sLog.outError("GameObject::SaveToDB failed, cannot get gameobject data!");
return; return;
@ -543,7 +543,7 @@ void GameObject::SaveToDB()
void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
{ {
const GameObjectInfo *goI = GetGOInfo(); const GameObjectInfo* goI = GetGOInfo();
if (!goI) if (!goI)
return; return;
@ -571,22 +571,22 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
// updated in DB // updated in DB
std::ostringstream ss; std::ostringstream ss;
ss << "INSERT INTO gameobject VALUES ( " ss << "INSERT INTO gameobject VALUES ( "
<< GetGUIDLow() << ", " << GetGUIDLow() << ", "
<< GetEntry() << ", " << GetEntry() << ", "
<< mapid << ", " << mapid << ", "
<< uint32(spawnMask) << "," // cast to prevent save as symbol << uint32(spawnMask) << "," // cast to prevent save as symbol
<< uint16(GetPhaseMask()) << "," // prevent out of range error << uint16(GetPhaseMask()) << "," // prevent out of range error
<< GetPositionX() << ", " << GetPositionX() << ", "
<< GetPositionY() << ", " << GetPositionY() << ", "
<< GetPositionZ() << ", " << GetPositionZ() << ", "
<< GetOrientation() << ", " << GetOrientation() << ", "
<< m_worldRotation.x << ", " << m_worldRotation.x << ", "
<< m_worldRotation.y << ", " << m_worldRotation.y << ", "
<< m_worldRotation.z << ", " << m_worldRotation.z << ", "
<< m_worldRotation.w << ", " << m_worldRotation.w << ", "
<< m_respawnDelayTime << ", " << m_respawnDelayTime << ", "
<< uint32(GetGoAnimProgress()) << ", " << uint32(GetGoAnimProgress()) << ", "
<< uint32(GetGoState()) << ")"; << uint32(GetGoState()) << ")";
WorldDatabase.BeginTransaction(); WorldDatabase.BeginTransaction();
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", GetGUIDLow()); WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", GetGUIDLow());
@ -594,11 +594,11 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
WorldDatabase.CommitTransaction(); WorldDatabase.CommitTransaction();
} }
bool GameObject::LoadFromDB(uint32 guid, Map *map) bool GameObject::LoadFromDB(uint32 guid, Map* map)
{ {
GameObjectData const* data = sObjectMgr.GetGOData(guid); GameObjectData const* data = sObjectMgr.GetGOData(guid);
if( !data ) if (!data)
{ {
sLog.outErrorDb("Gameobject (GUID: %u) not found in table `gameobject`, can't load. ",guid); sLog.outErrorDb("Gameobject (GUID: %u) not found in table `gameobject`, can't load. ",guid);
return false; return false;
@ -627,7 +627,7 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
} }
else else
{ {
if(data->spawntimesecs >= 0) if (data->spawntimesecs >= 0)
{ {
m_spawnedByDefault = true; m_spawnedByDefault = true;
m_respawnDelayTime = data->spawntimesecs; m_respawnDelayTime = data->spawntimesecs;
@ -656,7 +656,7 @@ struct GameObjectRespawnDeleteWorker
{ {
explicit GameObjectRespawnDeleteWorker(uint32 guid) : i_guid(guid) {} explicit GameObjectRespawnDeleteWorker(uint32 guid) : i_guid(guid) {}
void operator() (MapPersistentState* state) void operator()(MapPersistentState* state)
{ {
state->SaveGORespawnTime(i_guid, 0); state->SaveGORespawnTime(i_guid, 0);
} }
@ -682,7 +682,7 @@ void GameObject::DeleteFromDB()
WorldDatabase.PExecuteLog("DELETE FROM gameobject_battleground WHERE guid = '%u'", GetGUIDLow()); WorldDatabase.PExecuteLog("DELETE FROM gameobject_battleground WHERE guid = '%u'", GetGUIDLow());
} }
GameObjectInfo const *GameObject::GetGOInfo() const GameObjectInfo const* GameObject::GetGOInfo() const
{ {
return m_goInfo; return m_goInfo;
} }
@ -693,7 +693,7 @@ GameObjectInfo const *GameObject::GetGOInfo() const
bool GameObject::HasQuest(uint32 quest_id) const bool GameObject::HasQuest(uint32 quest_id) const
{ {
QuestRelationsMapBounds bounds = sObjectMgr.GetGOQuestRelationsMapBounds(GetEntry()); QuestRelationsMapBounds bounds = sObjectMgr.GetGOQuestRelationsMapBounds(GetEntry());
for(QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
{ {
if (itr->second == quest_id) if (itr->second == quest_id)
return true; return true;
@ -704,7 +704,7 @@ bool GameObject::HasQuest(uint32 quest_id) const
bool GameObject::HasInvolvedQuest(uint32 quest_id) const bool GameObject::HasInvolvedQuest(uint32 quest_id) const
{ {
QuestRelationsMapBounds bounds = sObjectMgr.GetGOQuestInvolvedRelationsMapBounds(GetEntry()); QuestRelationsMapBounds bounds = sObjectMgr.GetGOQuestInvolvedRelationsMapBounds(GetEntry());
for(QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
{ {
if (itr->second == quest_id) if (itr->second == quest_id)
return true; return true;
@ -715,8 +715,8 @@ bool GameObject::HasInvolvedQuest(uint32 quest_id) const
bool GameObject::IsTransport() const bool GameObject::IsTransport() const
{ {
// If something is marked as a transport, don't transmit an out of range packet for it. // If something is marked as a transport, don't transmit an out of range packet for it.
GameObjectInfo const * gInfo = GetGOInfo(); GameObjectInfo const* gInfo = GetGOInfo();
if(!gInfo) return false; if (!gInfo) return false;
return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT; return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT;
} }
@ -727,29 +727,29 @@ Unit* GameObject::GetOwner() const
void GameObject::SaveRespawnTime() void GameObject::SaveRespawnTime()
{ {
if(m_respawnTime > time(NULL) && m_spawnedByDefault) if (m_respawnTime > time(NULL) && m_spawnedByDefault)
GetMap()->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), m_respawnTime); GetMap()->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), m_respawnTime);
} }
bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
{ {
// Not in world // Not in world
if(!IsInWorld() || !u->IsInWorld()) if (!IsInWorld() || !u->IsInWorld())
return false; return false;
// invisible at client always // invisible at client always
if(!GetGOInfo()->displayId) if (!GetGOInfo()->displayId)
return false; return false;
// Transport always visible at this step implementation // Transport always visible at this step implementation
if(IsTransport() && IsInMap(u)) if (IsTransport() && IsInMap(u))
return true; return true;
// quick check visibility false cases for non-GM-mode // quick check visibility false cases for non-GM-mode
if(!u->isGameMaster()) if (!u->isGameMaster())
{ {
// despawned and then not visible for non-GM in GM-mode // despawned and then not visible for non-GM in GM-mode
if(!isSpawned()) if (!isSpawned())
return false; return false;
// special invisibility cases // special invisibility cases
@ -763,19 +763,19 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi
// check distance // check distance
return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() +
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
} }
void GameObject::Respawn() void GameObject::Respawn()
{ {
if(m_spawnedByDefault && m_respawnTime > 0) if (m_spawnedByDefault && m_respawnTime > 0)
{ {
m_respawnTime = time(NULL); m_respawnTime = time(NULL);
GetMap()->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), 0); GetMap()->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), 0);
} }
} }
bool GameObject::ActivateToQuest(Player *pTarget) const bool GameObject::ActivateToQuest(Player* pTarget) const
{ {
// if GO is ReqCreatureOrGoN for quest // if GO is ReqCreatureOrGoN for quest
if (pTarget->HasQuestForGO(GetEntry())) if (pTarget->HasQuestForGO(GetEntry()))
@ -784,7 +784,7 @@ bool GameObject::ActivateToQuest(Player *pTarget) const
if (!sObjectMgr.IsGameObjectForQuests(GetEntry())) if (!sObjectMgr.IsGameObjectForQuests(GetEntry()))
return false; return false;
switch(GetGoType()) switch (GetGoType())
{ {
case GAMEOBJECT_TYPE_QUESTGIVER: case GAMEOBJECT_TYPE_QUESTGIVER:
{ {
@ -795,9 +795,9 @@ bool GameObject::ActivateToQuest(Player *pTarget) const
QuestRelationsMapBounds bounds = sObjectMgr.GetGOQuestRelationsMapBounds(GetEntry()); QuestRelationsMapBounds bounds = sObjectMgr.GetGOQuestRelationsMapBounds(GetEntry());
for(QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
{ {
const Quest *qInfo = sObjectMgr.GetQuestTemplate(itr->second); const Quest* qInfo = sObjectMgr.GetQuestTemplate(itr->second);
if (pTarget->CanTakeQuest(qInfo, false)) if (pTarget->CanTakeQuest(qInfo, false))
return true; return true;
@ -805,10 +805,10 @@ bool GameObject::ActivateToQuest(Player *pTarget) const
bounds = sObjectMgr.GetGOQuestInvolvedRelationsMapBounds(GetEntry()); bounds = sObjectMgr.GetGOQuestInvolvedRelationsMapBounds(GetEntry());
for(QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
{ {
if ((pTarget->GetQuestStatus(itr->second) == QUEST_STATUS_INCOMPLETE || pTarget->GetQuestStatus(itr->second) == QUEST_STATUS_COMPLETE) if ((pTarget->GetQuestStatus(itr->second) == QUEST_STATUS_INCOMPLETE || pTarget->GetQuestStatus(itr->second) == QUEST_STATUS_COMPLETE)
&& !pTarget->GetQuestRewardStatus(itr->second)) && !pTarget->GetQuestRewardStatus(itr->second))
return true; return true;
} }
@ -824,7 +824,7 @@ bool GameObject::ActivateToQuest(Player *pTarget) const
{ {
//look for battlegroundAV for some objects which are only activated after mine gots captured by own team //look for battlegroundAV for some objects which are only activated after mine gots captured by own team
if (GetEntry() == BG_AV_OBJECTID_MINE_N || GetEntry() == BG_AV_OBJECTID_MINE_S) if (GetEntry() == BG_AV_OBJECTID_MINE_N || GetEntry() == BG_AV_OBJECTID_MINE_S)
if (BattleGround *bg = pTarget->GetBattleGround()) if (BattleGround* bg = pTarget->GetBattleGround())
if (bg->GetTypeID() == BATTLEGROUND_AV && !(((BattleGroundAV*)bg)->PlayerCanDoMineQuest(GetEntry(),pTarget->GetTeam()))) if (bg->GetTypeID() == BATTLEGROUND_AV && !(((BattleGroundAV*)bg)->PlayerCanDoMineQuest(GetEntry(),pTarget->GetTeam())))
return false; return false;
return true; return true;
@ -864,7 +864,7 @@ void GameObject::SummonLinkedTrapIfAny()
GameObject* linkedGO = new GameObject; GameObject* linkedGO = new GameObject;
if (!linkedGO->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, GetMap(), if (!linkedGO->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, GetMap(),
GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation())) GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()))
{ {
delete linkedGO; delete linkedGO;
return; return;
@ -942,10 +942,10 @@ void GameObject::ResetDoorOrButton()
void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */) void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */)
{ {
if(m_lootState != GO_READY) if (m_lootState != GO_READY)
return; return;
if(!time_to_restore) if (!time_to_restore)
time_to_restore = GetGOInfo()->GetAutoCloseTime(); time_to_restore = GetGOInfo()->GetAutoCloseTime();
SwitchDoorOrButton(true,alternative); SwitchDoorOrButton(true,alternative);
@ -956,12 +956,12 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false */) void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false */)
{ {
if(activate) if (activate)
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
else else
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
if(GetGoState() == GO_STATE_READY) //if closed -> open if (GetGoState() == GO_STATE_READY) //if closed -> open
SetGoState(alternative ? GO_STATE_ACTIVE_ALTERNATIVE : GO_STATE_ACTIVE); SetGoState(alternative ? GO_STATE_ACTIVE_ALTERNATIVE : GO_STATE_ACTIVE);
else //if open -> close else //if open -> close
SetGoState(GO_STATE_READY); SetGoState(GO_STATE_READY);
@ -1103,7 +1103,7 @@ void GameObject::Use(Unit* user)
// every slot will be on that straight line // every slot will be on that straight line
float orthogonalOrientation = GetOrientation() + M_PI_F * 0.5f; float orthogonalOrientation = GetOrientation() + M_PI_F * 0.5f;
// find nearest slot // find nearest slot
for(uint32 i=0; i<info->chair.slots; ++i) for (uint32 i=0; i<info->chair.slots; ++i)
{ {
// the distance between this slot and the center of the go - imagine a 1D space // the distance between this slot and the center of the go - imagine a 1D space
float relativeDistance = (info->size*i)-(info->size*(info->chair.slots-1)/2.0f); float relativeDistance = (info->size*i)-(info->size*(info->chair.slots-1)/2.0f);
@ -1207,7 +1207,7 @@ void GameObject::Use(Unit* user)
spellId = info->goober.spellId; spellId = info->goober.spellId;
// database may contain a dummy spell, so it need replacement by actually existing // database may contain a dummy spell, so it need replacement by actually existing
switch(spellId) switch (spellId)
{ {
case 34448: spellId = 26566; break; case 34448: spellId = 26566; break;
case 34452: spellId = 26572; break; case 34452: spellId = 26572; break;
@ -1523,7 +1523,7 @@ void GameObject::Use(Unit* user)
if (player->CanUseBattleGroundObject()) if (player->CanUseBattleGroundObject())
{ {
// in battleground check // in battleground check
BattleGround *bg = player->GetBattleGround(); BattleGround* bg = player->GetBattleGround();
if (!bg) if (!bg)
return; return;
// BG flag dropped // BG flag dropped
@ -1535,7 +1535,7 @@ void GameObject::Use(Unit* user)
GameObjectInfo const* info = GetGOInfo(); GameObjectInfo const* info = GetGOInfo();
if (info) if (info)
{ {
switch(info->id) switch (info->id)
{ {
case 179785: // Silverwing Flag case 179785: // Silverwing Flag
case 179786: // Warsong Flag case 179786: // Warsong Flag
@ -1583,14 +1583,14 @@ void GameObject::Use(Unit* user)
if (!spellId) if (!spellId)
return; return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo) if (!spellInfo)
{ {
sLog.outError("WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u )", spellId, GetEntry(), GetGoType()); sLog.outError("WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u )", spellId, GetEntry(), GetGoType());
return; return;
} }
Spell *spell = new Spell(spellCaster, spellInfo, triggered, GetObjectGuid()); Spell* spell = new Spell(spellCaster, spellInfo, triggered, GetObjectGuid());
// spell target is user of GO // spell target is user of GO
SpellCastTargets targets; SpellCastTargets targets;
@ -1604,7 +1604,7 @@ const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const
{ {
if (loc_idx >= 0) if (loc_idx >= 0)
{ {
GameObjectLocale const *cl = sObjectMgr.GetGameObjectLocale(GetEntry()); GameObjectLocale const* cl = sObjectMgr.GetGameObjectLocale(GetEntry());
if (cl) if (cl)
{ {
if (cl->Name.size() > (size_t)loc_idx && !cl->Name[loc_idx].empty()) if (cl->Name.size() > (size_t)loc_idx && !cl->Name[loc_idx].empty())
@ -1622,7 +1622,8 @@ struct QuaternionCompressed
QuaternionCompressed(int64 val) : m_raw(val) {} QuaternionCompressed(int64 val) : m_raw(val) {}
QuaternionCompressed(const Quat& quat) { Set(quat); } QuaternionCompressed(const Quat& quat) { Set(quat); }
enum{ enum
{
PACK_COEFF_YZ = 1 << 20, PACK_COEFF_YZ = 1 << 20,
PACK_COEFF_X = 1 << 21, PACK_COEFF_X = 1 << 21,
}; };
@ -1676,7 +1677,7 @@ void GameObject::SetTransportPathRotation(QuaternionData rotation)
void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot) void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot)
{ {
Quat quat( G3D::Matrix3::fromEulerAnglesZYX(z_rot, y_rot, x_rot) ); Quat quat(G3D::Matrix3::fromEulerAnglesZYX(z_rot, y_rot, x_rot));
SetWorldRotation(quat.x, quat.y, quat.z, quat.w); SetWorldRotation(quat.x, quat.y, quat.z, quat.w);
} }
@ -1698,8 +1699,8 @@ bool GameObject::IsHostileTo(Unit const* unit) const
return true; return true;
// faction base cases // faction base cases
FactionTemplateEntry const*tester_faction = sFactionTemplateStore.LookupEntry(GetGOInfo()->faction); FactionTemplateEntry const* tester_faction = sFactionTemplateStore.LookupEntry(GetGOInfo()->faction);
FactionTemplateEntry const*target_faction = unit->getFactionTemplateEntry(); FactionTemplateEntry const* target_faction = unit->getFactionTemplateEntry();
if (!tester_faction || !target_faction) if (!tester_faction || !target_faction)
return false; return false;
@ -1741,8 +1742,8 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const
return false; return false;
// faction base cases // faction base cases
FactionTemplateEntry const*tester_faction = sFactionTemplateStore.LookupEntry(GetGOInfo()->faction); FactionTemplateEntry const* tester_faction = sFactionTemplateStore.LookupEntry(GetGOInfo()->faction);
FactionTemplateEntry const*target_faction = unit->getFactionTemplateEntry(); FactionTemplateEntry const* target_faction = unit->getFactionTemplateEntry();
if (!tester_faction || !target_faction) if (!tester_faction || !target_faction)
return false; return false;
@ -1877,7 +1878,7 @@ struct AddGameObjectToRemoveListInMapsWorker
{ {
AddGameObjectToRemoveListInMapsWorker(ObjectGuid guid) : i_guid(guid) {} AddGameObjectToRemoveListInMapsWorker(ObjectGuid guid) : i_guid(guid) {}
void operator() (Map* map) void operator()(Map* map)
{ {
if (GameObject* pGameobject = map->GetGameObject(i_guid)) if (GameObject* pGameobject = map->GetGameObject(i_guid))
pGameobject->AddObjectToRemoveList(); pGameobject->AddObjectToRemoveList();
@ -1897,7 +1898,7 @@ struct SpawnGameObjectInMapsWorker
SpawnGameObjectInMapsWorker(uint32 guid, GameObjectData const* data) SpawnGameObjectInMapsWorker(uint32 guid, GameObjectData const* data)
: i_guid(guid), i_data(data) {} : i_guid(guid), i_data(data) {}
void operator() (Map* map) void operator()(Map* map)
{ {
// Spawn if necessary (loaded grids only) // Spawn if necessary (loaded grids only)
if (map->IsLoaded(i_data->posX, i_data->posY)) if (map->IsLoaded(i_data->posX, i_data->posY))

View file

@ -38,10 +38,10 @@ struct GameObjectInfo
uint32 id; uint32 id;
uint32 type; uint32 type;
uint32 displayId; uint32 displayId;
char *name; char* name;
char *IconName; char* IconName;
char *castBarCaption; char* castBarCaption;
char *unk1; char* unk1;
uint32 faction; uint32 faction;
uint32 flags; uint32 flags;
float size; float size;
@ -404,7 +404,7 @@ struct GameObjectInfo
// helpers // helpers
bool IsDespawnAtAction() const bool IsDespawnAtAction() const
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_CHEST: return chest.consumable; case GAMEOBJECT_TYPE_CHEST: return chest.consumable;
case GAMEOBJECT_TYPE_GOOBER: return goober.consumable; case GAMEOBJECT_TYPE_GOOBER: return goober.consumable;
@ -414,7 +414,7 @@ struct GameObjectInfo
uint32 GetLockId() const uint32 GetLockId() const
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_DOOR: return door.lockId; case GAMEOBJECT_TYPE_DOOR: return door.lockId;
case GAMEOBJECT_TYPE_BUTTON: return button.lockId; case GAMEOBJECT_TYPE_BUTTON: return button.lockId;
@ -433,7 +433,7 @@ struct GameObjectInfo
bool GetDespawnPossibility() const // despawn at targeting of cast? bool GetDespawnPossibility() const // despawn at targeting of cast?
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_DOOR: return door.noDamageImmune; case GAMEOBJECT_TYPE_DOOR: return door.noDamageImmune;
case GAMEOBJECT_TYPE_BUTTON: return button.noDamageImmune; case GAMEOBJECT_TYPE_BUTTON: return button.noDamageImmune;
@ -447,7 +447,7 @@ struct GameObjectInfo
uint32 GetCharges() const // despawn at uses amount uint32 GetCharges() const // despawn at uses amount
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_TRAP: return trap.charges; case GAMEOBJECT_TYPE_TRAP: return trap.charges;
case GAMEOBJECT_TYPE_GUARDPOST: return guardpost.charges; case GAMEOBJECT_TYPE_GUARDPOST: return guardpost.charges;
@ -458,7 +458,7 @@ struct GameObjectInfo
uint32 GetCooldown() const // not triggering at detection target or use until coolodwn expire uint32 GetCooldown() const // not triggering at detection target or use until coolodwn expire
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_TRAP: return trap.cooldown; case GAMEOBJECT_TYPE_TRAP: return trap.cooldown;
case GAMEOBJECT_TYPE_GOOBER: return goober.cooldown; case GAMEOBJECT_TYPE_GOOBER: return goober.cooldown;
@ -468,7 +468,7 @@ struct GameObjectInfo
uint32 GetLinkedGameObjectEntry() const uint32 GetLinkedGameObjectEntry() const
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_BUTTON: return button.linkedTrapId; case GAMEOBJECT_TYPE_BUTTON: return button.linkedTrapId;
case GAMEOBJECT_TYPE_CHEST: return chest.linkedTrapId; case GAMEOBJECT_TYPE_CHEST: return chest.linkedTrapId;
@ -481,7 +481,7 @@ struct GameObjectInfo
uint32 GetAutoCloseTime() const uint32 GetAutoCloseTime() const
{ {
uint32 autoCloseTime = 0; uint32 autoCloseTime = 0;
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_DOOR: autoCloseTime = door.autoCloseTime; break; case GAMEOBJECT_TYPE_DOOR: autoCloseTime = door.autoCloseTime; break;
case GAMEOBJECT_TYPE_BUTTON: autoCloseTime = button.autoCloseTime; break; case GAMEOBJECT_TYPE_BUTTON: autoCloseTime = button.autoCloseTime; break;
@ -496,7 +496,7 @@ struct GameObjectInfo
uint32 GetLootId() const uint32 GetLootId() const
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_CHEST: return chest.lootId; case GAMEOBJECT_TYPE_CHEST: return chest.lootId;
case GAMEOBJECT_TYPE_FISHINGHOLE: return fishinghole.lootId; case GAMEOBJECT_TYPE_FISHINGHOLE: return fishinghole.lootId;
@ -506,7 +506,7 @@ struct GameObjectInfo
uint32 GetGossipMenuId() const uint32 GetGossipMenuId() const
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.gossipID; case GAMEOBJECT_TYPE_QUESTGIVER: return questgiver.gossipID;
case GAMEOBJECT_TYPE_GOOBER: return goober.gossipID; case GAMEOBJECT_TYPE_GOOBER: return goober.gossipID;
@ -516,7 +516,7 @@ struct GameObjectInfo
uint32 GetEventScriptId() const uint32 GetEventScriptId() const
{ {
switch(type) switch (type)
{ {
case GAMEOBJECT_TYPE_GOOBER: return goober.eventId; case GAMEOBJECT_TYPE_GOOBER: return goober.eventId;
case GAMEOBJECT_TYPE_CHEST: return chest.eventId; case GAMEOBJECT_TYPE_CHEST: return chest.eventId;
@ -640,8 +640,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void AddToWorld(); void AddToWorld();
void RemoveFromWorld(); void RemoveFromWorld();
bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang,
QuaternionData rotation = QuaternionData(), uint8 animprogress = GO_ANIMPROGRESS_DEFAULT, GOState go_state = GO_STATE_READY); QuaternionData rotation = QuaternionData(), uint8 animprogress = GO_ANIMPROGRESS_DEFAULT, GOState go_state = GO_STATE_READY);
void Update(uint32 update_diff, uint32 p_time) override; void Update(uint32 update_diff, uint32 p_time) override;
GameObjectInfo const* GetGOInfo() const; GameObjectInfo const* GetGOInfo() const;
@ -660,7 +660,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void SaveToDB(); void SaveToDB();
void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
bool LoadFromDB(uint32 guid, Map *map); bool LoadFromDB(uint32 guid, Map* map);
void DeleteFromDB(); void DeleteFromDB();
void SetOwnerGuid(ObjectGuid ownerGuid) void SetOwnerGuid(ObjectGuid ownerGuid)
@ -682,7 +682,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
time_t GetRespawnTimeEx() const time_t GetRespawnTimeEx() const
{ {
time_t now = time(NULL); time_t now = time(NULL);
if(m_respawnTime > now) if (m_respawnTime > now)
return m_respawnTime; return m_respawnTime;
else else
return now; return now;
@ -697,8 +697,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
bool isSpawned() const bool isSpawned() const
{ {
return m_respawnDelayTime == 0 || return m_respawnDelayTime == 0 ||
(m_respawnTime > 0 && !m_spawnedByDefault) || (m_respawnTime > 0 && !m_spawnedByDefault) ||
(m_respawnTime == 0 && m_spawnedByDefault); (m_respawnTime == 0 && m_spawnedByDefault);
} }
bool isSpawnedByDefault() const { return m_spawnedByDefault; } bool isSpawnedByDefault() const { return m_spawnedByDefault; }
uint32 GetRespawnDelay() const { return m_respawnDelayTime; } uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
@ -762,9 +762,9 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
bool HasQuest(uint32 quest_id) const; bool HasQuest(uint32 quest_id) const;
bool HasInvolvedQuest(uint32 quest_id) const; bool HasInvolvedQuest(uint32 quest_id) const;
bool ActivateToQuest(Player *pTarget) const; bool ActivateToQuest(Player* pTarget) const;
void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false); void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false);
// 0 = use `gameobject`.`spawntimesecs` // 0 = use `gameobject`.`spawntimesecs`
void ResetDoorOrButton(); void ResetDoorOrButton();
bool IsHostileTo(Unit const* unit) const; bool IsHostileTo(Unit const* unit) const;
@ -779,7 +779,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void SetCapturePointSlider(int8 value); void SetCapturePointSlider(int8 value);
GridReference<GameObject> &GetGridRef() { return m_gridRef; } GridReference<GameObject>& GetGridRef() { return m_gridRef; }
protected: protected:
uint32 m_spellId; uint32 m_spellId;
@ -788,7 +788,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
LootState m_lootState; LootState m_lootState;
bool m_spawnedByDefault; bool m_spawnedByDefault;
time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction). time_t m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
// For traps/goober this: spell casting cooldown, for doors/buttons: reset time. // For traps/goober this: spell casting cooldown, for doors/buttons: reset time.
uint32 m_captureTimer; // (msecs) timer used for capture points uint32 m_captureTimer; // (msecs) timer used for capture points
float m_captureSlider; float m_captureSlider;

View file

@ -37,7 +37,7 @@ GossipMenu::~GossipMenu()
void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSender, uint32 dtAction, const std::string& BoxMessage, uint32 BoxMoney, bool Coded) void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, uint32 dtSender, uint32 dtAction, const std::string& BoxMessage, uint32 BoxMoney, bool Coded)
{ {
MANGOS_ASSERT( m_gItems.size() <= GOSSIP_MAX_MENU_ITEMS ); MANGOS_ASSERT(m_gItems.size() <= GOSSIP_MAX_MENU_ITEMS);
GossipMenuItem gItem; GossipMenuItem gItem;
@ -65,7 +65,7 @@ void GossipMenu::AddGossipMenuItemData(int32 action_menu, uint32 action_poi, uin
void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, bool Coded) void GossipMenu::AddMenuItem(uint8 Icon, const std::string& Message, bool Coded)
{ {
AddMenuItem( Icon, Message, 0, 0, "", 0, Coded); AddMenuItem(Icon, Message, 0, 0, "", 0, Coded);
} }
void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, bool Coded) void GossipMenu::AddMenuItem(uint8 Icon, char const* Message, bool Coded)
@ -88,25 +88,25 @@ void GossipMenu::AddMenuItem(uint8 Icon, int32 itemText, uint32 dtSender, uint32
AddMenuItem(Icon, std::string(item_text), dtSender, dtAction, std::string(box_text), BoxMoney, Coded); AddMenuItem(Icon, std::string(item_text), dtSender, dtAction, std::string(box_text), BoxMoney, Coded);
} }
uint32 GossipMenu::MenuItemSender( unsigned int ItemId ) uint32 GossipMenu::MenuItemSender(unsigned int ItemId)
{ {
if ( ItemId >= m_gItems.size() ) if (ItemId >= m_gItems.size())
return 0; return 0;
return m_gItems[ ItemId ].m_gSender; return m_gItems[ ItemId ].m_gSender;
} }
uint32 GossipMenu::MenuItemAction( unsigned int ItemId ) uint32 GossipMenu::MenuItemAction(unsigned int ItemId)
{ {
if ( ItemId >= m_gItems.size() ) if (ItemId >= m_gItems.size())
return 0; return 0;
return m_gItems[ ItemId ].m_gOptionId; return m_gItems[ ItemId ].m_gOptionId;
} }
bool GossipMenu::MenuItemCoded( unsigned int ItemId ) bool GossipMenu::MenuItemCoded(unsigned int ItemId)
{ {
if ( ItemId >= m_gItems.size() ) if (ItemId >= m_gItems.size())
return 0; return 0;
return m_gItems[ ItemId ].m_gCoded; return m_gItems[ ItemId ].m_gCoded;
@ -119,7 +119,7 @@ void GossipMenu::ClearMenu()
m_gMenuId = 0; m_gMenuId = 0;
} }
PlayerMenu::PlayerMenu(WorldSession *session) : mGossipMenu(session) PlayerMenu::PlayerMenu(WorldSession* session) : mGossipMenu(session)
{ {
} }
@ -134,19 +134,19 @@ void PlayerMenu::ClearMenus()
mQuestMenu.ClearMenu(); mQuestMenu.ClearMenu();
} }
uint32 PlayerMenu::GossipOptionSender( unsigned int Selection ) uint32 PlayerMenu::GossipOptionSender(unsigned int Selection)
{ {
return mGossipMenu.MenuItemSender( Selection ); return mGossipMenu.MenuItemSender(Selection);
} }
uint32 PlayerMenu::GossipOptionAction( unsigned int Selection ) uint32 PlayerMenu::GossipOptionAction(unsigned int Selection)
{ {
return mGossipMenu.MenuItemAction( Selection ); return mGossipMenu.MenuItemAction(Selection);
} }
bool PlayerMenu::GossipOptionCoded( unsigned int Selection ) bool PlayerMenu::GossipOptionCoded(unsigned int Selection)
{ {
return mGossipMenu.MenuItemCoded( Selection ); return mGossipMenu.MenuItemCoded(Selection);
} }
void PlayerMenu::SendGossipMenu(uint32 TitleTextId, ObjectGuid objectGuid) void PlayerMenu::SendGossipMenu(uint32 TitleTextId, ObjectGuid objectGuid)
@ -157,7 +157,7 @@ void PlayerMenu::SendGossipMenu(uint32 TitleTextId, ObjectGuid objectGuid)
data << uint32(TitleTextId); data << uint32(TitleTextId);
data << uint32(mGossipMenu.MenuItemCount()); // max count 0x20 data << uint32(mGossipMenu.MenuItemCount()); // max count 0x20
for (uint32 iI = 0; iI < mGossipMenu.MenuItemCount(); ++iI ) for (uint32 iI = 0; iI < mGossipMenu.MenuItemCount(); ++iI)
{ {
GossipMenuItem const& gItem = mGossipMenu.GetItem(iI); GossipMenuItem const& gItem = mGossipMenu.GetItem(iI);
data << uint32(iI); data << uint32(iI);
@ -189,22 +189,22 @@ void PlayerMenu::SendGossipMenu(uint32 TitleTextId, ObjectGuid objectGuid)
data << title; // max 0x200 data << title; // max 0x200
} }
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
//DEBUG_LOG( "WORLD: Sent SMSG_GOSSIP_MESSAGE NPCGuid=%u",GUID_LOPART(npcGUID) ); //DEBUG_LOG( "WORLD: Sent SMSG_GOSSIP_MESSAGE NPCGuid=%u",GUID_LOPART(npcGUID) );
} }
void PlayerMenu::CloseGossip() void PlayerMenu::CloseGossip()
{ {
WorldPacket data( SMSG_GOSSIP_COMPLETE, 0 ); WorldPacket data(SMSG_GOSSIP_COMPLETE, 0);
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
//DEBUG_LOG( "WORLD: Sent SMSG_GOSSIP_COMPLETE" ); //DEBUG_LOG( "WORLD: Sent SMSG_GOSSIP_COMPLETE" );
} }
// Outdated // Outdated
void PlayerMenu::SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, char const * locName ) void PlayerMenu::SendPointOfInterest(float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, char const* locName)
{ {
WorldPacket data( SMSG_GOSSIP_POI, (4+4+4+4+4+10) ); // guess size WorldPacket data(SMSG_GOSSIP_POI, (4+4+4+4+4+10)); // guess size
data << uint32(Flags); data << uint32(Flags);
data << float(X); data << float(X);
data << float(Y); data << float(Y);
@ -212,14 +212,14 @@ void PlayerMenu::SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flag
data << uint32(Data); data << uint32(Data);
data << locName; data << locName;
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
//DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI"); //DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI");
} }
void PlayerMenu::SendPointOfInterest( uint32 poi_id ) void PlayerMenu::SendPointOfInterest(uint32 poi_id)
{ {
PointOfInterest const* poi = sObjectMgr.GetPointOfInterest(poi_id); PointOfInterest const* poi = sObjectMgr.GetPointOfInterest(poi_id);
if(!poi) if (!poi)
{ {
sLog.outErrorDb("Requested send nonexistent POI (Id: %u), ignore.",poi_id); sLog.outErrorDb("Requested send nonexistent POI (Id: %u), ignore.",poi_id);
return; return;
@ -229,11 +229,11 @@ void PlayerMenu::SendPointOfInterest( uint32 poi_id )
int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex();
if (loc_idx >= 0) if (loc_idx >= 0)
if (PointOfInterestLocale const *pl = sObjectMgr.GetPointOfInterestLocale(poi_id)) if (PointOfInterestLocale const* pl = sObjectMgr.GetPointOfInterestLocale(poi_id))
if (pl->IconName.size() > size_t(loc_idx) && !pl->IconName[loc_idx].empty()) if (pl->IconName.size() > size_t(loc_idx) && !pl->IconName[loc_idx].empty())
icon_name = pl->IconName[loc_idx]; icon_name = pl->IconName[loc_idx];
WorldPacket data( SMSG_GOSSIP_POI, (4+4+4+4+4+10) ); // guess size WorldPacket data(SMSG_GOSSIP_POI, (4+4+4+4+4+10)); // guess size
data << uint32(poi->flags); data << uint32(poi->flags);
data << float(poi->x); data << float(poi->x);
data << float(poi->y); data << float(poi->y);
@ -241,20 +241,20 @@ void PlayerMenu::SendPointOfInterest( uint32 poi_id )
data << uint32(poi->data); data << uint32(poi->data);
data << icon_name; data << icon_name;
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
//DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI"); //DEBUG_LOG("WORLD: Sent SMSG_GOSSIP_POI");
} }
void PlayerMenu::SendTalking( uint32 textID ) void PlayerMenu::SendTalking(uint32 textID)
{ {
GossipText const* pGossip = sObjectMgr.GetGossipText(textID); GossipText const* pGossip = sObjectMgr.GetGossipText(textID);
WorldPacket data( SMSG_NPC_TEXT_UPDATE, 100 ); // guess size WorldPacket data(SMSG_NPC_TEXT_UPDATE, 100); // guess size
data << textID; // can be < 0 data << textID; // can be < 0
if (!pGossip) if (!pGossip)
{ {
for(uint32 i = 0; i < 8; ++i) for (uint32 i = 0; i < 8; ++i)
{ {
data << float(0); data << float(0);
data << "Greetings $N"; data << "Greetings $N";
@ -297,23 +297,23 @@ void PlayerMenu::SendTalking( uint32 textID )
data << pGossip->Options[i].Language; data << pGossip->Options[i].Language;
for(int j = 0; j < 3; ++j) for (int j = 0; j < 3; ++j)
{ {
data << pGossip->Options[i].Emotes[j]._Delay; data << pGossip->Options[i].Emotes[j]._Delay;
data << pGossip->Options[i].Emotes[j]._Emote; data << pGossip->Options[i].Emotes[j]._Emote;
} }
} }
} }
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
DEBUG_LOG( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); DEBUG_LOG("WORLD: Sent SMSG_NPC_TEXT_UPDATE ");
} }
void PlayerMenu::SendTalking( char const * title, char const * text ) void PlayerMenu::SendTalking(char const* title, char const* text)
{ {
WorldPacket data( SMSG_NPC_TEXT_UPDATE, 50 ); // guess size WorldPacket data(SMSG_NPC_TEXT_UPDATE, 50); // guess size
data << uint32(0); data << uint32(0);
for(uint32 i = 0; i < 8; ++i) for (uint32 i = 0; i < 8; ++i)
{ {
data << float(0); data << float(0);
data << title; data << title;
@ -327,9 +327,9 @@ void PlayerMenu::SendTalking( char const * title, char const * text )
data << uint32(0); data << uint32(0);
} }
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
DEBUG_LOG( "WORLD: Sent SMSG_NPC_TEXT_UPDATE " ); DEBUG_LOG("WORLD: Sent SMSG_NPC_TEXT_UPDATE ");
} }
/*********************************************************/ /*********************************************************/
@ -346,13 +346,13 @@ QuestMenu::~QuestMenu()
ClearMenu(); ClearMenu();
} }
void QuestMenu::AddMenuItem( uint32 QuestId, uint8 Icon) void QuestMenu::AddMenuItem(uint32 QuestId, uint8 Icon)
{ {
Quest const* qinfo = sObjectMgr.GetQuestTemplate(QuestId); Quest const* qinfo = sObjectMgr.GetQuestTemplate(QuestId);
if (!qinfo) if (!qinfo)
return; return;
MANGOS_ASSERT( m_qItems.size() <= GOSSIP_MAX_MENU_ITEMS ); MANGOS_ASSERT(m_qItems.size() <= GOSSIP_MAX_MENU_ITEMS);
QuestMenuItem qItem; QuestMenuItem qItem;
@ -362,10 +362,10 @@ void QuestMenu::AddMenuItem( uint32 QuestId, uint8 Icon)
m_qItems.push_back(qItem); m_qItems.push_back(qItem);
} }
bool QuestMenu::HasItem( uint32 questid ) bool QuestMenu::HasItem(uint32 questid)
{ {
for (QuestMenuItemList::const_iterator i = m_qItems.begin(); i != m_qItems.end(); ++i) for (QuestMenuItemList::const_iterator i = m_qItems.begin(); i != m_qItems.end(); ++i)
if(i->m_qId == questid) if (i->m_qId == questid)
return true; return true;
return false; return false;
} }
@ -377,22 +377,22 @@ void QuestMenu::ClearMenu()
void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, ObjectGuid npcGUID) void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, ObjectGuid npcGUID)
{ {
WorldPacket data( SMSG_QUESTGIVER_QUEST_LIST, 100 ); // guess size WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100); // guess size
data << ObjectGuid(npcGUID); data << ObjectGuid(npcGUID);
data << Title; data << Title;
data << uint32(eEmote._Delay ); // player emote data << uint32(eEmote._Delay); // player emote
data << uint32(eEmote._Emote ); // NPC emote data << uint32(eEmote._Emote); // NPC emote
size_t count_pos = data.wpos(); size_t count_pos = data.wpos();
data << uint8 ( mQuestMenu.MenuItemCount() ); data << uint8(mQuestMenu.MenuItemCount());
uint32 count = 0; uint32 count = 0;
for (; count < mQuestMenu.MenuItemCount(); ++count ) for (; count < mQuestMenu.MenuItemCount(); ++count)
{ {
QuestMenuItem const& qmi = mQuestMenu.GetItem(count); QuestMenuItem const& qmi = mQuestMenu.GetItem(count);
uint32 questID = qmi.m_qId; uint32 questID = qmi.m_qId;
if(Quest const *pQuest = sObjectMgr.GetQuestTemplate(questID)) if (Quest const* pQuest = sObjectMgr.GetQuestTemplate(questID))
{ {
int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex();
std::string title = pQuest->GetTitle(); std::string title = pQuest->GetTitle();
@ -407,18 +407,18 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title
} }
} }
data.put<uint8>(count_pos, count); data.put<uint8>(count_pos, count);
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid = %s", npcGUID.GetString().c_str()); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid = %s", npcGUID.GetString().c_str());
} }
void PlayerMenu::SendQuestGiverStatus( uint8 questStatus, ObjectGuid npcGUID ) void PlayerMenu::SendQuestGiverStatus(uint8 questStatus, ObjectGuid npcGUID)
{ {
WorldPacket data( SMSG_QUESTGIVER_STATUS, 9 ); WorldPacket data(SMSG_QUESTGIVER_STATUS, 9);
data << npcGUID; data << npcGUID;
data << uint8(questStatus); data << uint8(questStatus);
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
DEBUG_LOG( "WORLD: Sent SMSG_QUESTGIVER_STATUS for %s", npcGUID.GetString().c_str()); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_STATUS for %s", npcGUID.GetString().c_str());
} }
void PlayerMenu::SendQuestGiverQuestDetails(Quest const* pQuest, ObjectGuid guid, bool ActivateAccept) void PlayerMenu::SendQuestGiverQuestDetails(Quest const* pQuest, ObjectGuid guid, bool ActivateAccept)
@ -430,7 +430,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* pQuest, ObjectGuid guid
int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex();
if (loc_idx >= 0) if (loc_idx >= 0)
{ {
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId())) if (QuestLocale const* ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
{ {
if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty()) if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty())
Title = ql->Title[loc_idx]; Title = ql->Title[loc_idx];
@ -520,15 +520,15 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* pQuest, ObjectGuid guid
data << uint32(0); // bonus arena points data << uint32(0); // bonus arena points
data << uint32(0); // rep reward show mask? data << uint32(0); // rep reward show mask?
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
data << uint32(pQuest->RewRepFaction[i]); data << uint32(pQuest->RewRepFaction[i]);
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row) for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row)
data << int32(pQuest->RewRepValueId[i]); data << int32(pQuest->RewRepValueId[i]);
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No bonus is expected given for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No bonus is expected given
data << int32(0); data << int32(0);
//data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value" //data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value"
data << uint32(QUEST_EMOTE_COUNT); data << uint32(QUEST_EMOTE_COUNT);
@ -538,13 +538,13 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* pQuest, ObjectGuid guid
data << uint32(pQuest->DetailsEmoteDelay[i]); // DetailsEmoteDelay (in ms) data << uint32(pQuest->DetailsEmoteDelay[i]); // DetailsEmoteDelay (in ms)
} }
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS - for %s of %s, questid = %u", GetMenuSession()->GetPlayer()->GetGuidStr().c_str(), guid.GetString().c_str(), pQuest->GetQuestId()); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS - for %s of %s, questid = %u", GetMenuSession()->GetPlayer()->GetGuidStr().c_str(), guid.GetString().c_str(), pQuest->GetQuestId());
} }
// send only static data in this packet! // send only static data in this packet!
void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest ) void PlayerMenu::SendQuestQueryResponse(Quest const* pQuest)
{ {
std::string Title, Details, Objectives, EndText, CompletedText; std::string Title, Details, Objectives, EndText, CompletedText;
std::string ObjectiveText[QUEST_OBJECTIVES_COUNT]; std::string ObjectiveText[QUEST_OBJECTIVES_COUNT];
@ -560,7 +560,7 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest )
int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex();
if (loc_idx >= 0) if (loc_idx >= 0)
{ {
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId())) if (QuestLocale const* ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
{ {
if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty()) if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty())
Title = ql->Title[loc_idx]; Title = ql->Title[loc_idx];
@ -573,13 +573,13 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest )
if (ql->CompletedText.size() > (size_t)loc_idx && !ql->CompletedText[loc_idx].empty()) if (ql->CompletedText.size() > (size_t)loc_idx && !ql->CompletedText[loc_idx].empty())
CompletedText = ql->CompletedText[loc_idx]; CompletedText = ql->CompletedText[loc_idx];
for (int i = 0;i < QUEST_OBJECTIVES_COUNT; ++i) for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
if (ql->ObjectiveText[i].size() > (size_t)loc_idx && !ql->ObjectiveText[i][loc_idx].empty()) if (ql->ObjectiveText[i].size() > (size_t)loc_idx && !ql->ObjectiveText[i][loc_idx].empty())
ObjectiveText[i] = ql->ObjectiveText[i][loc_idx]; ObjectiveText[i] = ql->ObjectiveText[i][loc_idx];
} }
} }
WorldPacket data( SMSG_QUEST_QUERY_RESPONSE, 100 ); // guess size WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100); // guess size
data << uint32(pQuest->GetQuestId()); // quest id data << uint32(pQuest->GetQuestId()); // quest id
data << uint32(pQuest->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details) data << uint32(pQuest->GetQuestMethod()); // Accepted values: 0, 1 or 2. 0==IsAutoComplete() (skip objectives/details)
@ -643,15 +643,15 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest )
} }
} }
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
data << uint32(pQuest->RewRepFaction[i]); data << uint32(pQuest->RewRepFaction[i]);
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row) for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row)
data << int32(pQuest->RewRepValueId[i]); data << int32(pQuest->RewRepValueId[i]);
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No bonus is expected given for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No bonus is expected given
data << int32(0); data << int32(0);
//data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value" //data << int32(pQuest->RewRepValue[i]); // current field for store of rep value, can be reused to implement "override value"
data << pQuest->GetPointMapId(); data << pQuest->GetPointMapId();
data << pQuest->GetPointX(); data << pQuest->GetPointX();
@ -689,9 +689,9 @@ void PlayerMenu::SendQuestQueryResponse( Quest const *pQuest )
for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; ++iI) for (iI = 0; iI < QUEST_OBJECTIVES_COUNT; ++iI)
data << ObjectiveText[iI]; data << ObjectiveText[iI];
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
DEBUG_LOG( "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", pQuest->GetQuestId() ); DEBUG_LOG("WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", pQuest->GetQuestId());
} }
void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGUID, bool EnableNext) void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGUID, bool EnableNext)
@ -702,7 +702,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU
int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex();
if (loc_idx >= 0) if (loc_idx >= 0)
{ {
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId())) if (QuestLocale const* ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
{ {
if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty()) if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty())
Title = ql->Title[loc_idx]; Title = ql->Title[loc_idx];
@ -711,7 +711,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU
} }
} }
WorldPacket data( SMSG_QUESTGIVER_OFFER_REWARD, 50 ); // guess size WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 50); // guess size
data << ObjectGuid(npcGUID); data << ObjectGuid(npcGUID);
data << uint32(pQuest->GetQuestId()); data << uint32(pQuest->GetQuestId());
@ -725,7 +725,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU
uint32 EmoteCount = 0; uint32 EmoteCount = 0;
for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i) for (uint32 i = 0; i < QUEST_EMOTE_COUNT; ++i)
{ {
if(pQuest->OfferRewardEmote[i] <= 0) if (pQuest->OfferRewardEmote[i] <= 0)
break; break;
++EmoteCount; ++EmoteCount;
} }
@ -737,17 +737,17 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU
data << uint32(pQuest->OfferRewardEmote[i]); data << uint32(pQuest->OfferRewardEmote[i]);
} }
ItemPrototype const *pItem; ItemPrototype const* pItem;
data << uint32(pQuest->GetRewChoiceItemsCount()); data << uint32(pQuest->GetRewChoiceItemsCount());
for (uint32 i = 0; i < pQuest->GetRewChoiceItemsCount(); ++i) for (uint32 i = 0; i < pQuest->GetRewChoiceItemsCount(); ++i)
{ {
pItem = ObjectMgr::GetItemPrototype( pQuest->RewChoiceItemId[i] ); pItem = ObjectMgr::GetItemPrototype(pQuest->RewChoiceItemId[i]);
data << uint32(pQuest->RewChoiceItemId[i]); data << uint32(pQuest->RewChoiceItemId[i]);
data << uint32(pQuest->RewChoiceItemCount[i]); data << uint32(pQuest->RewChoiceItemCount[i]);
if ( pItem ) if (pItem)
data << uint32(pItem->DisplayInfoID); data << uint32(pItem->DisplayInfoID);
else else
data << uint32(0); data << uint32(0);
@ -760,7 +760,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU
data << uint32(pQuest->RewItemId[i]); data << uint32(pQuest->RewItemId[i]);
data << uint32(pQuest->RewItemCount[i]); data << uint32(pQuest->RewItemCount[i]);
if ( pItem ) if (pItem)
data << uint32(pItem->DisplayInfoID); data << uint32(pItem->DisplayInfoID);
else else
data << uint32(0); data << uint32(0);
@ -787,21 +787,21 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU
data << uint32(0); // bonus arena points data << uint32(0); // bonus arena points
data << uint32(0); // rew rep show mask? data << uint32(0); // rew rep show mask?
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward factions ids
data << uint32(pQuest->RewRepFaction[i]); data << uint32(pQuest->RewRepFaction[i]);
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row) for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // columnid in QuestFactionReward.dbc (if negative, from second row)
data << int32(pQuest->RewRepValueId[i]); data << int32(pQuest->RewRepValueId[i]);
for(int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No diplomacy bonus is expected given, reward also does not display in chat window for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) // reward reputation override. No diplomacy bonus is expected given, reward also does not display in chat window
data << int32(0); data << int32(0);
//data << int32(pQuest->RewRepValue[i]); //data << int32(pQuest->RewRepValue[i]);
GetMenuSession()->SendPacket(&data); GetMenuSession()->SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId()); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId());
} }
void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcGUID, bool Completable, bool CloseOnCancel) void PlayerMenu::SendQuestGiverRequestItems(Quest const* pQuest, ObjectGuid npcGUID, bool Completable, bool CloseOnCancel)
{ {
// We can always call to RequestItems, but this packet only goes out if there are actually // We can always call to RequestItems, but this packet only goes out if there are actually
// items. Otherwise, we'll skip straight to the OfferReward // items. Otherwise, we'll skip straight to the OfferReward
@ -812,7 +812,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcG
int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex(); int loc_idx = GetMenuSession()->GetSessionDbLocaleIndex();
if (loc_idx >= 0) if (loc_idx >= 0)
{ {
if (QuestLocale const *ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId())) if (QuestLocale const* ql = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
{ {
if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty()) if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty())
Title = ql->Title[loc_idx]; Title = ql->Title[loc_idx];
@ -827,7 +827,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcG
return; return;
} }
WorldPacket data( SMSG_QUESTGIVER_REQUEST_ITEMS, 50 ); // guess size WorldPacket data(SMSG_QUESTGIVER_REQUEST_ITEMS, 50); // guess size
data << ObjectGuid(npcGUID); data << ObjectGuid(npcGUID);
data << uint32(pQuest->GetQuestId()); data << uint32(pQuest->GetQuestId());
data << Title; data << Title;
@ -835,7 +835,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcG
data << uint32(0x00); // emote delay data << uint32(0x00); // emote delay
if(Completable) if (Completable)
data << pQuest->GetCompleteEmote(); // emote id data << pQuest->GetCompleteEmote(); // emote id
else else
data << pQuest->GetIncompleteEmote(); data << pQuest->GetIncompleteEmote();
@ -852,23 +852,23 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcG
// Required Money // Required Money
data << uint32(pQuest->GetRewOrReqMoney() < 0 ? -pQuest->GetRewOrReqMoney() : 0); data << uint32(pQuest->GetRewOrReqMoney() < 0 ? -pQuest->GetRewOrReqMoney() : 0);
data << uint32( pQuest->GetReqItemsCount() ); data << uint32(pQuest->GetReqItemsCount());
ItemPrototype const *pItem; ItemPrototype const* pItem;
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{ {
if ( !pQuest->ReqItemId[i] ) if (!pQuest->ReqItemId[i])
continue; continue;
pItem = ObjectMgr::GetItemPrototype(pQuest->ReqItemId[i]); pItem = ObjectMgr::GetItemPrototype(pQuest->ReqItemId[i]);
data << uint32(pQuest->ReqItemId[i]); data << uint32(pQuest->ReqItemId[i]);
data << uint32(pQuest->ReqItemCount[i]); data << uint32(pQuest->ReqItemCount[i]);
if ( pItem ) if (pItem)
data << uint32(pItem->DisplayInfoID); data << uint32(pItem->DisplayInfoID);
else else
data << uint32(0); data << uint32(0);
} }
if ( !Completable ) // Completable = flags1 && flags2 && flags3 && flags4 if (!Completable) // Completable = flags1 && flags2 && flags3 && flags4
data << uint32(0x00); // flags1 data << uint32(0x00); // flags1
else else
data << uint32(0x03); data << uint32(0x03);
@ -877,6 +877,6 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcG
data << uint32(0x08); // flags3 data << uint32(0x08); // flags3
data << uint32(0x10); // flags4 data << uint32(0x10); // flags4
GetMenuSession()->SendPacket( &data ); GetMenuSession()->SendPacket(&data);
DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId()); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId());
} }

View file

@ -185,7 +185,7 @@ class MANGOS_DLL_SPEC GossipMenu
return m_gItems.empty(); return m_gItems.empty();
} }
GossipMenuItem const& GetItem( unsigned int Id ) GossipMenuItem const& GetItem(unsigned int Id)
{ {
return m_gItems[ Id ]; return m_gItems[ Id ];
} }
@ -195,9 +195,9 @@ class MANGOS_DLL_SPEC GossipMenu
return m_gItemsData[indexId]; return m_gItemsData[indexId];
} }
uint32 MenuItemSender( unsigned int ItemId ); uint32 MenuItemSender(unsigned int ItemId);
uint32 MenuItemAction( unsigned int ItemId ); uint32 MenuItemAction(unsigned int ItemId);
bool MenuItemCoded( unsigned int ItemId ); bool MenuItemCoded(unsigned int ItemId);
void ClearMenu(); void ClearMenu();
@ -219,7 +219,7 @@ class QuestMenu
QuestMenu(); QuestMenu();
~QuestMenu(); ~QuestMenu();
void AddMenuItem( uint32 QuestId, uint8 Icon); void AddMenuItem(uint32 QuestId, uint8 Icon);
void ClearMenu(); void ClearMenu();
uint8 MenuItemCount() const uint8 MenuItemCount() const
@ -232,9 +232,9 @@ class QuestMenu
return m_qItems.empty(); return m_qItems.empty();
} }
bool HasItem( uint32 questid ); bool HasItem(uint32 questid);
QuestMenuItem const& GetItem( uint16 Id ) QuestMenuItem const& GetItem(uint16 Id)
{ {
return m_qItems[ Id ]; return m_qItems[ Id ];
} }
@ -250,7 +250,7 @@ class MANGOS_DLL_SPEC PlayerMenu
QuestMenu mQuestMenu; QuestMenu mQuestMenu;
public: public:
explicit PlayerMenu(WorldSession *Session); explicit PlayerMenu(WorldSession* Session);
~PlayerMenu(); ~PlayerMenu();
GossipMenu& GetGossipMenu() { return mGossipMenu; } GossipMenu& GetGossipMenu() { return mGossipMenu; }
@ -261,16 +261,16 @@ class MANGOS_DLL_SPEC PlayerMenu
bool Empty() const { return mGossipMenu.Empty() && mQuestMenu.Empty(); } bool Empty() const { return mGossipMenu.Empty() && mQuestMenu.Empty(); }
void ClearMenus(); void ClearMenus();
uint32 GossipOptionSender( unsigned int Selection ); uint32 GossipOptionSender(unsigned int Selection);
uint32 GossipOptionAction( unsigned int Selection ); uint32 GossipOptionAction(unsigned int Selection);
bool GossipOptionCoded( unsigned int Selection ); bool GossipOptionCoded(unsigned int Selection);
void SendGossipMenu(uint32 titleTextId, ObjectGuid objectGuid); void SendGossipMenu(uint32 titleTextId, ObjectGuid objectGuid);
void CloseGossip(); void CloseGossip();
void SendPointOfInterest( float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, const char * locName ); void SendPointOfInterest(float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, const char* locName);
void SendPointOfInterest( uint32 poi_id ); void SendPointOfInterest(uint32 poi_id);
void SendTalking( uint32 textID ); void SendTalking(uint32 textID);
void SendTalking( char const * title, char const * text ); void SendTalking(char const* title, char const* text);
/*********************************************************/ /*********************************************************/
/*** QUEST SYSTEM ***/ /*** QUEST SYSTEM ***/
@ -279,10 +279,10 @@ class MANGOS_DLL_SPEC PlayerMenu
void SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, ObjectGuid npcGUID); void SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, ObjectGuid npcGUID);
void SendQuestQueryResponse(Quest const *pQuest); void SendQuestQueryResponse(Quest const* pQuest);
void SendQuestGiverQuestDetails(Quest const *pQuest, ObjectGuid npcGUID, bool ActivateAccept); void SendQuestGiverQuestDetails(Quest const* pQuest, ObjectGuid npcGUID, bool ActivateAccept);
void SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGUID, bool EnbleNext); void SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGUID, bool EnbleNext);
void SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcGUID, bool Completable, bool CloseOnCancel); void SendQuestGiverRequestItems(Quest const* pQuest, ObjectGuid npcGUID, bool Completable, bool CloseOnCancel);
}; };
#endif #endif

View file

@ -78,10 +78,10 @@ template<const unsigned int LIMIT>
struct MANGOS_DLL_DECL CoordPair struct MANGOS_DLL_DECL CoordPair
{ {
CoordPair(uint32 x=0, uint32 y=0) : x_coord(x), y_coord(y) {} CoordPair(uint32 x=0, uint32 y=0) : x_coord(x), y_coord(y) {}
CoordPair(const CoordPair<LIMIT> &obj) : x_coord(obj.x_coord), y_coord(obj.y_coord) {} CoordPair(const CoordPair<LIMIT>& obj) : x_coord(obj.x_coord), y_coord(obj.y_coord) {}
bool operator==(const CoordPair<LIMIT> &obj) const { return (obj.x_coord == x_coord && obj.y_coord == y_coord); } bool operator==(const CoordPair<LIMIT>& obj) const { return (obj.x_coord == x_coord && obj.y_coord == y_coord); }
bool operator!=(const CoordPair<LIMIT> &obj) const { return !operator==(obj); } bool operator!=(const CoordPair<LIMIT>& obj) const { return !operator==(obj); }
CoordPair<LIMIT>& operator=(const CoordPair<LIMIT> &obj) CoordPair<LIMIT>& operator=(const CoordPair<LIMIT>& obj)
{ {
x_coord = obj.x_coord; x_coord = obj.x_coord;
y_coord = obj.y_coord; y_coord = obj.y_coord;
@ -90,7 +90,7 @@ struct MANGOS_DLL_DECL CoordPair
void operator<<(const uint32 val) void operator<<(const uint32 val)
{ {
if( x_coord > val ) if (x_coord > val)
x_coord -= val; x_coord -= val;
else else
x_coord = 0; x_coord = 0;
@ -98,7 +98,7 @@ struct MANGOS_DLL_DECL CoordPair
void operator>>(const uint32 val) void operator>>(const uint32 val)
{ {
if( x_coord+val < LIMIT ) if (x_coord+val < LIMIT)
x_coord += val; x_coord += val;
else else
x_coord = LIMIT - 1; x_coord = LIMIT - 1;
@ -106,7 +106,7 @@ struct MANGOS_DLL_DECL CoordPair
void operator-=(const uint32 val) void operator-=(const uint32 val)
{ {
if( y_coord > val ) if (y_coord > val)
y_coord -= val; y_coord -= val;
else else
y_coord = 0; y_coord = 0;
@ -114,7 +114,7 @@ struct MANGOS_DLL_DECL CoordPair
void operator+=(const uint32 val) void operator+=(const uint32 val)
{ {
if( y_coord+val < LIMIT ) if (y_coord+val < LIMIT)
y_coord += val; y_coord += val;
else else
y_coord = LIMIT - 1; y_coord = LIMIT - 1;
@ -137,7 +137,7 @@ typedef CoordPair<TOTAL_NUMBER_OF_CELLS_PER_MAP> CellPair;
namespace MaNGOS namespace MaNGOS
{ {
template<class RET_TYPE, int CENTER_VAL> template<class RET_TYPE, int CENTER_VAL>
inline RET_TYPE Compute(float x, float y, float center_offset, float size) inline RET_TYPE Compute(float x, float y, float center_offset, float size)
{ {
// calculate and store temporary values in double format for having same result as same mySQL calculations // calculate and store temporary values in double format for having same result as same mySQL calculations
double x_offset = (double(x) - center_offset)/size; double x_offset = (double(x) - center_offset)/size;
@ -158,11 +158,11 @@ namespace MaNGOS
return Compute<CellPair, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL); return Compute<CellPair, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL);
} }
inline void NormalizeMapCoord(float &c) inline void NormalizeMapCoord(float& c)
{ {
if(c > MAP_HALFSIZE - 0.5) if (c > MAP_HALFSIZE - 0.5)
c = MAP_HALFSIZE - 0.5; c = MAP_HALFSIZE - 0.5;
else if(c < -(MAP_HALFSIZE - 0.5)) else if (c < -(MAP_HALFSIZE - 0.5))
c = -(MAP_HALFSIZE - 0.5); c = -(MAP_HALFSIZE - 0.5);
} }

View file

@ -66,21 +66,21 @@ GridMap::~GridMap()
unloadData(); unloadData();
} }
bool GridMap::loadData(char *filename) bool GridMap::loadData(char* filename)
{ {
// Unload old data if exist // Unload old data if exist
unloadData(); unloadData();
GridMapFileHeader header; GridMapFileHeader header;
// Not return error if file not found // Not return error if file not found
FILE *in = fopen(filename, "rb"); FILE* in = fopen(filename, "rb");
if (!in) if (!in)
return true; return true;
fread(&header, sizeof(header),1,in); fread(&header, sizeof(header),1,in);
if (header.mapMagic == *((uint32 const*)(MAP_MAGIC)) && if (header.mapMagic == *((uint32 const*)(MAP_MAGIC)) &&
header.versionMagic == *((uint32 const*)(MAP_VERSION_MAGIC)) && header.versionMagic == *((uint32 const*)(MAP_VERSION_MAGIC)) &&
IsAcceptableClientBuild(header.buildMagic)) IsAcceptableClientBuild(header.buildMagic))
{ {
// loadup area data // loadup area data
if (header.areaMapOffset && !loadAreaData(in, header.areaMapOffset, header.areaMapSize)) if (header.areaMapOffset && !loadAreaData(in, header.areaMapOffset, header.areaMapSize))
@ -140,7 +140,7 @@ void GridMap::unloadData()
m_gridGetHeight = &GridMap::getHeightFromFlat; m_gridGetHeight = &GridMap::getHeightFromFlat;
} }
bool GridMap::loadAreaData(FILE *in, uint32 offset, uint32 /*size*/) bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/)
{ {
GridMapAreaHeader header; GridMapAreaHeader header;
fseek(in, offset, SEEK_SET); fseek(in, offset, SEEK_SET);
@ -158,7 +158,7 @@ bool GridMap::loadAreaData(FILE *in, uint32 offset, uint32 /*size*/)
return true; return true;
} }
bool GridMap::loadHeightData(FILE *in, uint32 offset, uint32 /*size*/) bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/)
{ {
GridMapHeightHeader header; GridMapHeightHeader header;
fseek(in, offset, SEEK_SET); fseek(in, offset, SEEK_SET);
@ -202,7 +202,7 @@ bool GridMap::loadHeightData(FILE *in, uint32 offset, uint32 /*size*/)
return true; return true;
} }
bool GridMap::loadGridMapLiquidData(FILE *in, uint32 offset, uint32 /*size*/) bool GridMap::loadGridMapLiquidData(FILE* in, uint32 offset, uint32 /*size*/)
{ {
GridMapLiquidHeader header; GridMapLiquidHeader header;
fseek(in, offset, SEEK_SET); fseek(in, offset, SEEK_SET);
@ -286,7 +286,7 @@ float GridMap::getHeightFromFloat(float x, float y) const
if (x > y) if (x > y)
{ {
// 1 triangle (h1, h2, h5 points) // 1 triangle (h1, h2, h5 points)
float h1 = m_V9[(x_int )*129 + y_int]; float h1 = m_V9[(x_int)*129 + y_int];
float h2 = m_V9[(x_int+1)*129 + y_int]; float h2 = m_V9[(x_int+1)*129 + y_int];
float h5 = 2 * m_V8[x_int*128 + y_int]; float h5 = 2 * m_V8[x_int*128 + y_int];
a = h2-h1; a = h2-h1;
@ -319,7 +319,7 @@ float GridMap::getHeightFromFloat(float x, float y) const
else else
{ {
// 4 triangle (h3, h4, h5 points) // 4 triangle (h3, h4, h5 points)
float h3 = m_V9[(x_int )*129 + y_int+1]; float h3 = m_V9[(x_int)*129 + y_int+1];
float h4 = m_V9[(x_int+1)*129 + y_int+1]; float h4 = m_V9[(x_int+1)*129 + y_int+1];
float h5 = 2 * m_V8[x_int*128 + y_int]; float h5 = 2 * m_V8[x_int*128 + y_int];
a = h4 - h3; a = h4 - h3;
@ -347,7 +347,7 @@ float GridMap::getHeightFromUint8(float x, float y) const
y_int &= (MAP_RESOLUTION - 1); y_int &= (MAP_RESOLUTION - 1);
int32 a, b, c; int32 a, b, c;
uint8 *V9_h1_ptr = &m_uint8_V9[x_int*128 + x_int + y_int]; uint8* V9_h1_ptr = &m_uint8_V9[x_int*128 + x_int + y_int];
if (x+y < 1) if (x+y < 1)
{ {
if (x > y) if (x > y)
@ -415,7 +415,7 @@ float GridMap::getHeightFromUint16(float x, float y) const
y_int &= (MAP_RESOLUTION - 1); y_int &= (MAP_RESOLUTION - 1);
int32 a, b, c; int32 a, b, c;
uint16 *V9_h1_ptr = &m_uint16_V9[x_int*128 + x_int + y_int]; uint16* V9_h1_ptr = &m_uint16_V9[x_int*128 + x_int + y_int];
if (x+y < 1) if (x+y < 1)
{ {
if (x > y) if (x > y)
@ -481,7 +481,7 @@ float GridMap::getLiquidLevel(float x, float y)
if (cx_int < 0 || cx_int >=m_liquid_height) if (cx_int < 0 || cx_int >=m_liquid_height)
return INVALID_HEIGHT_VALUE; return INVALID_HEIGHT_VALUE;
if (cy_int < 0 || cy_int >=m_liquid_width ) if (cy_int < 0 || cy_int >=m_liquid_width)
return INVALID_HEIGHT_VALUE; return INVALID_HEIGHT_VALUE;
return m_liquid_map[cx_int*m_liquid_width + cy_int]; return m_liquid_map[cx_int*m_liquid_width + cy_int];
@ -500,7 +500,7 @@ uint8 GridMap::getTerrainType(float x, float y)
} }
// Get water state on map // Get water state on map
GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData *data) GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData* data)
{ {
// Check water type (if no water return) // Check water type (if no water return)
if (!m_liquid_type && !m_liquidType) if (!m_liquid_type && !m_liquidType)
@ -529,7 +529,7 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re
return LIQUID_MAP_NO_WATER; return LIQUID_MAP_NO_WATER;
int ly_int = y_int - m_liquid_offX; int ly_int = y_int - m_liquid_offX;
if (ly_int < 0 || ly_int >=m_liquid_width ) if (ly_int < 0 || ly_int >=m_liquid_width)
return LIQUID_MAP_NO_WATER; return LIQUID_MAP_NO_WATER;
// Get water level // Get water level
@ -557,12 +557,12 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re
if (delta > 20) // Under water if (delta > 20) // Under water
return LIQUID_MAP_UNDER_WATER; return LIQUID_MAP_UNDER_WATER;
if (delta > 0 ) // In water if (delta > 0) // In water
return LIQUID_MAP_IN_WATER; return LIQUID_MAP_IN_WATER;
if (delta > -1) // Walk on water if (delta > -1) // Walk on water
return LIQUID_MAP_WATER_WALK; return LIQUID_MAP_WATER_WALK;
// Above water // Above water
return LIQUID_MAP_ABOVE_WATER; return LIQUID_MAP_ABOVE_WATER;
} }
@ -570,11 +570,11 @@ bool GridMap::ExistMap(uint32 mapid,int gx,int gy)
{ {
int len = sWorld.GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1; int len = sWorld.GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1;
char* tmp = new char[len]; char* tmp = new char[len];
snprintf(tmp, len, (char *)(sWorld.GetDataPath()+"maps/%03u%02u%02u.map").c_str(),mapid,gx,gy); snprintf(tmp, len, (char*)(sWorld.GetDataPath()+"maps/%03u%02u%02u.map").c_str(),mapid,gx,gy);
FILE *pf=fopen(tmp,"rb"); FILE* pf=fopen(tmp,"rb");
if(!pf) if (!pf)
{ {
sLog.outError("Check existing of map file '%s': not exist!",tmp); sLog.outError("Check existing of map file '%s': not exist!",tmp);
delete[] tmp; delete[] tmp;
@ -584,8 +584,8 @@ bool GridMap::ExistMap(uint32 mapid,int gx,int gy)
GridMapFileHeader header; GridMapFileHeader header;
fread(&header, sizeof(header), 1, pf); fread(&header, sizeof(header), 1, pf);
if (header.mapMagic != *((uint32 const*)(MAP_MAGIC)) || if (header.mapMagic != *((uint32 const*)(MAP_MAGIC)) ||
header.versionMagic != *((uint32 const*)(MAP_VERSION_MAGIC)) || header.versionMagic != *((uint32 const*)(MAP_VERSION_MAGIC)) ||
!IsAcceptableClientBuild(header.buildMagic)) !IsAcceptableClientBuild(header.buildMagic))
{ {
sLog.outError("Map file '%s' is non-compatible version (outdated?). Please, create new using ad.exe program.",tmp); sLog.outError("Map file '%s' is non-compatible version (outdated?). Please, create new using ad.exe program.",tmp);
delete [] tmp; delete [] tmp;
@ -600,13 +600,13 @@ bool GridMap::ExistMap(uint32 mapid,int gx,int gy)
bool GridMap::ExistVMap(uint32 mapid,int gx,int gy) bool GridMap::ExistVMap(uint32 mapid,int gx,int gy)
{ {
if(VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager()) if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager())
{ {
if(vmgr->isMapLoadingEnabled()) if (vmgr->isMapLoadingEnabled())
{ {
// x and y are swapped !! => fixed now // x and y are swapped !! => fixed now
bool exists = vmgr->existsMap((sWorld.GetDataPath()+ "vmaps").c_str(), mapid, gx,gy); bool exists = vmgr->existsMap((sWorld.GetDataPath()+ "vmaps").c_str(), mapid, gx,gy);
if(!exists) if (!exists)
{ {
std::string name = vmgr->getDirFileName(mapid,gx,gy); std::string name = vmgr->getDirFileName(mapid,gx,gy);
sLog.outError("VMap file '%s' is missing or point to wrong version vmap file, redo vmaps with latest vmap_assembler.exe program", (sWorld.GetDataPath()+"vmaps/"+name).c_str()); sLog.outError("VMap file '%s' is missing or point to wrong version vmap file, redo vmaps with latest vmap_assembler.exe program", (sWorld.GetDataPath()+"vmaps/"+name).c_str());
@ -649,7 +649,7 @@ TerrainInfo::~TerrainInfo()
MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(m_mapId); MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(m_mapId);
} }
GridMap * TerrainInfo::Load(const uint32 x, const uint32 y) GridMap* TerrainInfo::Load(const uint32 x, const uint32 y)
{ {
MANGOS_ASSERT(x < MAX_NUMBER_OF_GRIDS); MANGOS_ASSERT(x < MAX_NUMBER_OF_GRIDS);
MANGOS_ASSERT(y < MAX_NUMBER_OF_GRIDS); MANGOS_ASSERT(y < MAX_NUMBER_OF_GRIDS);
@ -658,8 +658,8 @@ GridMap * TerrainInfo::Load(const uint32 x, const uint32 y)
RefGrid(x, y); RefGrid(x, y);
//quick check if GridMap already loaded //quick check if GridMap already loaded
GridMap * pMap = m_GridMaps[x][y]; GridMap* pMap = m_GridMaps[x][y];
if(!pMap) if (!pMap)
pMap = LoadMapAndVMap(x, y); pMap = LoadMapAndVMap(x, y);
return pMap; return pMap;
@ -671,10 +671,10 @@ void TerrainInfo::Unload(const uint32 x, const uint32 y)
MANGOS_ASSERT(x < MAX_NUMBER_OF_GRIDS); MANGOS_ASSERT(x < MAX_NUMBER_OF_GRIDS);
MANGOS_ASSERT(y < MAX_NUMBER_OF_GRIDS); MANGOS_ASSERT(y < MAX_NUMBER_OF_GRIDS);
if(m_GridMaps[x][y]) if (m_GridMaps[x][y])
{ {
//decrease grid reference count... //decrease grid reference count...
if(UnrefGrid(x, y) == 0) if (UnrefGrid(x, y) == 0)
{ {
//TODO: add your additional logic here //TODO: add your additional logic here
@ -687,7 +687,7 @@ void TerrainInfo::Unload(const uint32 x, const uint32 y)
void TerrainInfo::CleanUpGrids(const uint32 diff) void TerrainInfo::CleanUpGrids(const uint32 diff)
{ {
i_timer.Update(diff); i_timer.Update(diff);
if( !i_timer.Passed() ) if (!i_timer.Passed())
return; return;
for (int y = 0; y < MAX_NUMBER_OF_GRIDS; ++y) for (int y = 0; y < MAX_NUMBER_OF_GRIDS; ++y)
@ -695,10 +695,10 @@ void TerrainInfo::CleanUpGrids(const uint32 diff)
for (int x = 0; x < MAX_NUMBER_OF_GRIDS; ++x) for (int x = 0; x < MAX_NUMBER_OF_GRIDS; ++x)
{ {
const int16& iRef = m_GridRef[x][y]; const int16& iRef = m_GridRef[x][y];
GridMap * pMap = m_GridMaps[x][y]; GridMap* pMap = m_GridMaps[x][y];
//delete those GridMap objects which have refcount = 0 //delete those GridMap objects which have refcount = 0
if(pMap && iRef == 0 ) if (pMap && iRef == 0)
{ {
m_GridMaps[x][y] = NULL; m_GridMaps[x][y] = NULL;
//delete grid data if reference count == 0 //delete grid data if reference count == 0
@ -734,7 +734,7 @@ int TerrainInfo::UnrefGrid(const uint32& x, const uint32& y)
int16& iRef = m_GridRef[x][y]; int16& iRef = m_GridRef[x][y];
LOCK_GUARD _lock(m_refMutex); LOCK_GUARD _lock(m_refMutex);
if(iRef > 0) if (iRef > 0)
return (iRef -= 1); return (iRef -= 1);
return 0; return 0;
@ -745,7 +745,7 @@ float TerrainInfo::GetHeight(float x, float y, float z, bool pUseVmaps, float ma
// find raw .map surface under Z coordinates // find raw .map surface under Z coordinates
float mapHeight; float mapHeight;
float z2 = z + 2.f; float z2 = z + 2.f;
if (GridMap *gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y)) if (GridMap* gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y))
{ {
float _mapheight = gmap->getHeight(x,y); float _mapheight = gmap->getHeight(x,y);
@ -804,26 +804,26 @@ float TerrainInfo::GetHeight(float x, float y, float z, bool pUseVmaps, float ma
} }
inline bool IsOutdoorWMO(uint32 mogpFlags, int32 adtId, int32 rootId, int32 groupId, inline bool IsOutdoorWMO(uint32 mogpFlags, int32 adtId, int32 rootId, int32 groupId,
WMOAreaTableEntry const* wmoEntry, AreaTableEntry const* atEntry) WMOAreaTableEntry const* wmoEntry, AreaTableEntry const* atEntry)
{ {
bool outdoor = true; bool outdoor = true;
if(wmoEntry && atEntry) if (wmoEntry && atEntry)
{ {
if(atEntry->flags & AREA_FLAG_OUTSIDE) if (atEntry->flags & AREA_FLAG_OUTSIDE)
return true; return true;
if(atEntry->flags & AREA_FLAG_INSIDE) if (atEntry->flags & AREA_FLAG_INSIDE)
return false; return false;
} }
outdoor = mogpFlags&0x8; outdoor = mogpFlags&0x8;
if(wmoEntry) if (wmoEntry)
{ {
if(wmoEntry->Flags & 4) if (wmoEntry->Flags & 4)
return true; return true;
if((wmoEntry->Flags & 2)!=0) if ((wmoEntry->Flags & 2)!=0)
outdoor = false; outdoor = false;
} }
return outdoor; return outdoor;
@ -835,12 +835,12 @@ bool TerrainInfo::IsOutdoors(float x, float y, float z) const
int32 adtId, rootId, groupId; int32 adtId, rootId, groupId;
// no wmo found? -> outside by default // no wmo found? -> outside by default
if(!GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId)) if (!GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId))
return true; return true;
AreaTableEntry const* atEntry = 0; AreaTableEntry const* atEntry = 0;
WMOAreaTableEntry const* wmoEntry= GetWMOAreaTableEntryByTripple(rootId, adtId, groupId); WMOAreaTableEntry const* wmoEntry= GetWMOAreaTableEntryByTripple(rootId, adtId, groupId);
if(wmoEntry) if (wmoEntry)
{ {
DEBUG_LOG("Got WMOAreaTableEntry! flag %u, areaid %u", wmoEntry->Flags, wmoEntry->areaId); DEBUG_LOG("Got WMOAreaTableEntry! flag %u, areaid %u", wmoEntry->Flags, wmoEntry->areaId);
@ -850,18 +850,18 @@ bool TerrainInfo::IsOutdoors(float x, float y, float z) const
return IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry); return IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry);
} }
bool TerrainInfo::GetAreaInfo(float x, float y, float z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const bool TerrainInfo::GetAreaInfo(float x, float y, float z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
{ {
float vmap_z = z; float vmap_z = z;
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
if (vmgr->getAreaInfo(GetMapId(), x, y, vmap_z, flags, adtId, rootId, groupId)) if (vmgr->getAreaInfo(GetMapId(), x, y, vmap_z, flags, adtId, rootId, groupId))
{ {
// check if there's terrain between player height and object height // check if there's terrain between player height and object height
if(GridMap *gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y)) if (GridMap* gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y))
{ {
float _mapheight = gmap->getHeight(x,y); float _mapheight = gmap->getHeight(x,y);
// z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice... // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice...
if(z + 2.0f > _mapheight && _mapheight > vmap_z) if (z + 2.0f > _mapheight && _mapheight > vmap_z)
return false; return false;
} }
return true; return true;
@ -869,7 +869,7 @@ bool TerrainInfo::GetAreaInfo(float x, float y, float z, uint32 &flags, int32 &a
return false; return false;
} }
uint16 TerrainInfo::GetAreaFlag(float x, float y, float z, bool *isOutdoors) const uint16 TerrainInfo::GetAreaFlag(float x, float y, float z, bool* isOutdoors) const
{ {
uint32 mogpFlags; uint32 mogpFlags;
int32 adtId, rootId, groupId; int32 adtId, rootId, groupId;
@ -877,11 +877,11 @@ uint16 TerrainInfo::GetAreaFlag(float x, float y, float z, bool *isOutdoors) con
AreaTableEntry const* atEntry = 0; AreaTableEntry const* atEntry = 0;
bool haveAreaInfo = false; bool haveAreaInfo = false;
if(GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId)) if (GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId))
{ {
haveAreaInfo = true; haveAreaInfo = true;
wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId); wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId);
if(wmoEntry) if (wmoEntry)
atEntry = GetAreaEntryByAreaID(wmoEntry->areaId); atEntry = GetAreaEntryByAreaID(wmoEntry->areaId);
} }
@ -890,7 +890,7 @@ uint16 TerrainInfo::GetAreaFlag(float x, float y, float z, bool *isOutdoors) con
areaflag = atEntry->exploreFlag; areaflag = atEntry->exploreFlag;
else else
{ {
if(GridMap *gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y)) if (GridMap* gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y))
areaflag = gmap->getArea(x, y); areaflag = gmap->getArea(x, y);
// this used while not all *.map files generated (instances) // this used while not all *.map files generated (instances)
else else
@ -907,9 +907,9 @@ uint16 TerrainInfo::GetAreaFlag(float x, float y, float z, bool *isOutdoors) con
return areaflag; return areaflag;
} }
uint8 TerrainInfo::GetTerrainType(float x, float y ) const uint8 TerrainInfo::GetTerrainType(float x, float y) const
{ {
if(GridMap *gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y)) if (GridMap* gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y))
return gmap->getTerrainType(x, y); return gmap->getTerrainType(x, y);
else else
return 0; return 0;
@ -931,7 +931,7 @@ void TerrainInfo::GetZoneAndAreaId(uint32& zoneid, uint32& areaid, float x, floa
} }
GridMapLiquidStatus TerrainInfo::getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData *data) const GridMapLiquidStatus TerrainInfo::getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData* data) const
{ {
GridMapLiquidStatus result = LIQUID_MAP_NO_WATER; GridMapLiquidStatus result = LIQUID_MAP_NO_WATER;
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
@ -957,14 +957,14 @@ GridMapLiquidStatus TerrainInfo::getLiquidStatus(float x, float y, float z, uint
// Get position delta // Get position delta
if (delta > 20) // Under water if (delta > 20) // Under water
return LIQUID_MAP_UNDER_WATER; return LIQUID_MAP_UNDER_WATER;
if (delta > 0 ) // In water if (delta > 0) // In water
return LIQUID_MAP_IN_WATER; return LIQUID_MAP_IN_WATER;
if (delta > -1) // Walk on water if (delta > -1) // Walk on water
return LIQUID_MAP_WATER_WALK; return LIQUID_MAP_WATER_WALK;
result = LIQUID_MAP_ABOVE_WATER; result = LIQUID_MAP_ABOVE_WATER;
} }
} }
if(GridMap* gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y)) if (GridMap* gmap = const_cast<TerrainInfo*>(this)->GetGrid(x, y))
{ {
GridMapLiquidData map_data; GridMapLiquidData map_data;
GridMapLiquidStatus map_result = gmap->getLiquidStatus(x, y, z, ReqLiquidType, &map_data); GridMapLiquidStatus map_result = gmap->getLiquidStatus(x, y, z, ReqLiquidType, &map_data);
@ -979,17 +979,17 @@ GridMapLiquidStatus TerrainInfo::getLiquidStatus(float x, float y, float z, uint
return result; return result;
} }
bool TerrainInfo::IsInWater(float x, float y, float pZ, GridMapLiquidData *data) const bool TerrainInfo::IsInWater(float x, float y, float pZ, GridMapLiquidData* data) const
{ {
// Check surface in x, y point for liquid // Check surface in x, y point for liquid
if (const_cast<TerrainInfo*>(this)->GetGrid(x, y)) if (const_cast<TerrainInfo*>(this)->GetGrid(x, y))
{ {
GridMapLiquidData liquid_status; GridMapLiquidData liquid_status;
GridMapLiquidData *liquid_ptr = data ? data : &liquid_status; GridMapLiquidData* liquid_ptr = data ? data : &liquid_status;
if (getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr)) if (getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr))
{ {
//if (liquid_prt->level - liquid_prt->depth_level > 2) //??? //if (liquid_prt->level - liquid_prt->depth_level > 2) //???
return true; return true;
} }
} }
return false; return false;
@ -1029,45 +1029,45 @@ float TerrainInfo::GetWaterOrGroundLevel(float x, float y, float z, float* pGrou
GridMapLiquidData liquid_status; GridMapLiquidData liquid_status;
GridMapLiquidStatus res = getLiquidStatus(x, y, ground_z, MAP_ALL_LIQUIDS, &liquid_status); GridMapLiquidStatus res = getLiquidStatus(x, y, ground_z, MAP_ALL_LIQUIDS, &liquid_status);
return res ? ( swim ? liquid_status.level - 2.0f : liquid_status.level) : ground_z; return res ? (swim ? liquid_status.level - 2.0f : liquid_status.level) : ground_z;
} }
return VMAP_INVALID_HEIGHT_VALUE; return VMAP_INVALID_HEIGHT_VALUE;
} }
GridMap * TerrainInfo::GetGrid( const float x, const float y ) GridMap* TerrainInfo::GetGrid(const float x, const float y)
{ {
// half opt method // half opt method
int gx=(int)(32-x/SIZE_OF_GRIDS); //grid x int gx=(int)(32-x/SIZE_OF_GRIDS); //grid x
int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y
//quick check if GridMap already loaded //quick check if GridMap already loaded
GridMap * pMap = m_GridMaps[gx][gy]; GridMap* pMap = m_GridMaps[gx][gy];
if(!pMap) if (!pMap)
pMap = LoadMapAndVMap(gx, gy); pMap = LoadMapAndVMap(gx, gy);
return pMap; return pMap;
} }
GridMap * TerrainInfo::LoadMapAndVMap( const uint32 x, const uint32 y ) GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y)
{ {
//double checked lock pattern //double checked lock pattern
if(!m_GridMaps[x][y]) if (!m_GridMaps[x][y])
{ {
LOCK_GUARD lock(m_mutex); LOCK_GUARD lock(m_mutex);
if(!m_GridMaps[x][y]) if (!m_GridMaps[x][y])
{ {
GridMap * map = new GridMap(); GridMap* map = new GridMap();
// map file name // map file name
char *tmp=NULL; char* tmp=NULL;
int len = sWorld.GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1; int len = sWorld.GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1;
tmp = new char[len]; tmp = new char[len];
snprintf(tmp, len, (char *)(sWorld.GetDataPath()+"maps/%03u%02u%02u.map").c_str(),m_mapId, x, y); snprintf(tmp, len, (char*)(sWorld.GetDataPath()+"maps/%03u%02u%02u.map").c_str(),m_mapId, x, y);
sLog.outDetail("Loading map %s",tmp); sLog.outDetail("Loading map %s",tmp);
if(!map->loadData(tmp)) if (!map->loadData(tmp))
{ {
sLog.outError("Error load map file: \n %s\n", tmp); sLog.outError("Error load map file: \n %s\n", tmp);
//ASSERT(false); //ASSERT(false);
@ -1077,21 +1077,21 @@ GridMap * TerrainInfo::LoadMapAndVMap( const uint32 x, const uint32 y )
m_GridMaps[x][y] = map; m_GridMaps[x][y] = map;
//load VMAPs for current map/grid... //load VMAPs for current map/grid...
const MapEntry * i_mapEntry = sMapStore.LookupEntry(m_mapId); const MapEntry* i_mapEntry = sMapStore.LookupEntry(m_mapId);
const char* mapName = i_mapEntry ? i_mapEntry->name[sWorld.GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; const char* mapName = i_mapEntry ? i_mapEntry->name[sWorld.GetDefaultDbcLocale()] : "UNNAMEDMAP\x0";
int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath()+ "vmaps").c_str(), m_mapId, x, y); int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath()+ "vmaps").c_str(), m_mapId, x, y);
switch(vmapLoadResult) switch (vmapLoadResult)
{ {
case VMAP::VMAP_LOAD_RESULT_OK: case VMAP::VMAP_LOAD_RESULT_OK:
sLog.outDetail("VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y); sLog.outDetail("VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y);
break; break;
case VMAP::VMAP_LOAD_RESULT_ERROR: case VMAP::VMAP_LOAD_RESULT_ERROR:
sLog.outDetail("Could not load VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y); sLog.outDetail("Could not load VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y);
break; break;
case VMAP::VMAP_LOAD_RESULT_IGNORED: case VMAP::VMAP_LOAD_RESULT_IGNORED:
DEBUG_LOG("Ignored VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y); DEBUG_LOG("Ignored VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y);
break; break;
} }
// load navmesh // load navmesh
@ -1139,13 +1139,13 @@ TerrainManager::~TerrainManager()
delete it->second; delete it->second;
} }
TerrainInfo * TerrainManager::LoadTerrain(const uint32 mapId) TerrainInfo* TerrainManager::LoadTerrain(const uint32 mapId)
{ {
Guard _guard(*this); Guard _guard(*this);
TerrainInfo * ptr = NULL; TerrainInfo* ptr = NULL;
TerrainDataMap::const_iterator iter = i_TerrainMap.find(mapId); TerrainDataMap::const_iterator iter = i_TerrainMap.find(mapId);
if(iter == i_TerrainMap.end()) if (iter == i_TerrainMap.end())
{ {
ptr = new TerrainInfo(mapId); ptr = new TerrainInfo(mapId);
i_TerrainMap[mapId] = ptr; i_TerrainMap[mapId] = ptr;
@ -1158,17 +1158,17 @@ TerrainInfo * TerrainManager::LoadTerrain(const uint32 mapId)
void TerrainManager::UnloadTerrain(const uint32 mapId) void TerrainManager::UnloadTerrain(const uint32 mapId)
{ {
if(sWorld.getConfig(CONFIG_BOOL_GRID_UNLOAD) == 0) if (sWorld.getConfig(CONFIG_BOOL_GRID_UNLOAD) == 0)
return; return;
Guard _guard(*this); Guard _guard(*this);
TerrainDataMap::iterator iter = i_TerrainMap.find(mapId); TerrainDataMap::iterator iter = i_TerrainMap.find(mapId);
if(iter != i_TerrainMap.end()) if (iter != i_TerrainMap.end())
{ {
TerrainInfo * ptr = (*iter).second; TerrainInfo* ptr = (*iter).second;
//lets check if this object can be actually freed //lets check if this object can be actually freed
if(ptr->IsReferenced() == false) if (ptr->IsReferenced() == false)
{ {
i_TerrainMap.erase(iter); i_TerrainMap.erase(iter);
delete ptr; delete ptr;
@ -1193,7 +1193,7 @@ void TerrainManager::UnloadAll()
uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id) uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id)
{ {
AreaTableEntry const *entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id); AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id);
if (entry) if (entry)
return entry->ID; return entry->ID;
@ -1203,18 +1203,18 @@ uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id)
uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id) uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id)
{ {
AreaTableEntry const *entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id); AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id);
if( entry ) if (entry)
return ( entry->zone != 0 ) ? entry->zone : entry->ID; return (entry->zone != 0) ? entry->zone : entry->ID;
else else
return 0; return 0;
} }
void TerrainManager::GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag,uint32 map_id) void TerrainManager::GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag,uint32 map_id)
{ {
AreaTableEntry const *entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id); AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id);
areaid = entry ? entry->ID : 0; areaid = entry ? entry->ID : 0;
zoneid = entry ? (( entry->zone != 0 ) ? entry->zone : entry->ID) : 0; zoneid = entry ? ((entry->zone != 0) ? entry->zone : entry->ID) : 0;
} }

View file

@ -123,22 +123,22 @@ class GridMap
// Area data // Area data
uint16 m_gridArea; uint16 m_gridArea;
uint16 *m_area_map; uint16* m_area_map;
// Height level data // Height level data
float m_gridHeight; float m_gridHeight;
float m_gridIntHeightMultiplier; float m_gridIntHeightMultiplier;
union union
{ {
float *m_V9; float* m_V9;
uint16 *m_uint16_V9; uint16* m_uint16_V9;
uint8 *m_uint8_V9; uint8* m_uint8_V9;
}; };
union union
{ {
float *m_V8; float* m_V8;
uint16 *m_uint16_V8; uint16* m_uint16_V8;
uint8 *m_uint8_V8; uint8* m_uint8_V8;
}; };
// Liquid data // Liquid data
@ -148,15 +148,15 @@ class GridMap
uint8 m_liquid_width; uint8 m_liquid_width;
uint8 m_liquid_height; uint8 m_liquid_height;
float m_liquidLevel; float m_liquidLevel;
uint8 *m_liquid_type; uint8* m_liquid_type;
float *m_liquid_map; float* m_liquid_map;
bool loadAreaData(FILE *in, uint32 offset, uint32 size); bool loadAreaData(FILE* in, uint32 offset, uint32 size);
bool loadHeightData(FILE *in, uint32 offset, uint32 size); bool loadHeightData(FILE* in, uint32 offset, uint32 size);
bool loadGridMapLiquidData(FILE *in, uint32 offset, uint32 size); bool loadGridMapLiquidData(FILE* in, uint32 offset, uint32 size);
// Get height functions and pointers // Get height functions and pointers
typedef float (GridMap::*pGetHeightPtr) (float x, float y) const; typedef float(GridMap::*pGetHeightPtr)(float x, float y) const;
pGetHeightPtr m_gridGetHeight; pGetHeightPtr m_gridGetHeight;
float getHeightFromFloat(float x, float y) const; float getHeightFromFloat(float x, float y) const;
float getHeightFromUint16(float x, float y) const; float getHeightFromUint16(float x, float y) const;
@ -168,7 +168,7 @@ class GridMap
GridMap(); GridMap();
~GridMap(); ~GridMap();
bool loadData(char *filaname); bool loadData(char* filaname);
void unloadData(); void unloadData();
static bool ExistMap(uint32 mapid, int gx, int gy); static bool ExistMap(uint32 mapid, int gx, int gy);
@ -178,24 +178,24 @@ class GridMap
float getHeight(float x, float y) { return (this->*m_gridGetHeight)(x, y); } float getHeight(float x, float y) { return (this->*m_gridGetHeight)(x, y); }
float getLiquidLevel(float x, float y); float getLiquidLevel(float x, float y);
uint8 getTerrainType(float x, float y); uint8 getTerrainType(float x, float y);
GridMapLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData *data = 0); GridMapLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData* data = 0);
}; };
template<typename Countable> template<typename Countable>
class MANGOS_DLL_SPEC Referencable class MANGOS_DLL_SPEC Referencable
{ {
public: public:
Referencable() { m_count = 0; } Referencable() { m_count = 0; }
void AddRef() { ++m_count; } void AddRef() { ++m_count; }
bool Release() { return (--m_count < 1); } bool Release() { return (--m_count < 1); }
bool IsReferenced() const { return (m_count > 0); } bool IsReferenced() const { return (m_count > 0); }
private: private:
Referencable(const Referencable&); Referencable(const Referencable&);
Referencable& operator=(const Referencable&); Referencable& operator=(const Referencable&);
Countable m_count; Countable m_count;
}; };
typedef ACE_Atomic_Op<ACE_Thread_Mutex, long> AtomicLong; typedef ACE_Atomic_Op<ACE_Thread_Mutex, long> AtomicLong;
@ -210,113 +210,113 @@ typedef ACE_Atomic_Op<ACE_Thread_Mutex, long> AtomicLong;
//class for sharing and managin GridMap objects //class for sharing and managin GridMap objects
class MANGOS_DLL_SPEC TerrainInfo : public Referencable<AtomicLong> class MANGOS_DLL_SPEC TerrainInfo : public Referencable<AtomicLong>
{ {
public: public:
TerrainInfo(uint32 mapid); TerrainInfo(uint32 mapid);
~TerrainInfo(); ~TerrainInfo();
uint32 GetMapId() const { return m_mapId; } uint32 GetMapId() const { return m_mapId; }
//TODO: move all terrain/vmaps data info query functions //TODO: move all terrain/vmaps data info query functions
//from 'Map' class into this class //from 'Map' class into this class
float GetHeight(float x, float y, float z, bool pCheckVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const; float GetHeight(float x, float y, float z, bool pCheckVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const;
float GetWaterLevel(float x, float y, float z, float* pGround = NULL) const; float GetWaterLevel(float x, float y, float z, float* pGround = NULL) const;
float GetWaterOrGroundLevel(float x, float y, float z, float* pGround = NULL, bool swim = false) const; float GetWaterOrGroundLevel(float x, float y, float z, float* pGround = NULL, bool swim = false) const;
bool IsInWater(float x, float y, float z, GridMapLiquidData *data = 0) const; bool IsInWater(float x, float y, float z, GridMapLiquidData* data = 0) const;
bool IsUnderWater(float x, float y, float z) const; bool IsUnderWater(float x, float y, float z) const;
GridMapLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData *data = 0) const; GridMapLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData* data = 0) const;
uint16 GetAreaFlag(float x, float y, float z, bool *isOutdoors=0) const; uint16 GetAreaFlag(float x, float y, float z, bool* isOutdoors=0) const;
uint8 GetTerrainType(float x, float y ) const; uint8 GetTerrainType(float x, float y) const;
uint32 GetAreaId(float x, float y, float z) const; uint32 GetAreaId(float x, float y, float z) const;
uint32 GetZoneId(float x, float y, float z) const; uint32 GetZoneId(float x, float y, float z) const;
void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, float x, float y, float z) const; void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, float x, float y, float z) const;
bool GetAreaInfo(float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const; bool GetAreaInfo(float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId) const;
bool IsOutdoors(float x, float y, float z) const; bool IsOutdoors(float x, float y, float z) const;
//this method should be used only by TerrainManager //this method should be used only by TerrainManager
//to cleanup unreferenced GridMap objects - they are too heavy //to cleanup unreferenced GridMap objects - they are too heavy
//to destroy them dynamically, especially on highly populated servers //to destroy them dynamically, especially on highly populated servers
//THIS METHOD IS NOT THREAD-SAFE!!!! AND IT SHOULDN'T BE THREAD-SAFE!!!! //THIS METHOD IS NOT THREAD-SAFE!!!! AND IT SHOULDN'T BE THREAD-SAFE!!!!
void CleanUpGrids(const uint32 diff); void CleanUpGrids(const uint32 diff);
protected: protected:
friend class Map; friend class Map;
//load/unload terrain data //load/unload terrain data
GridMap * Load(const uint32 x, const uint32 y); GridMap* Load(const uint32 x, const uint32 y);
void Unload(const uint32 x, const uint32 y); void Unload(const uint32 x, const uint32 y);
private: private:
TerrainInfo(const TerrainInfo&); TerrainInfo(const TerrainInfo&);
TerrainInfo& operator=(const TerrainInfo&); TerrainInfo& operator=(const TerrainInfo&);
GridMap * GetGrid( const float x, const float y ); GridMap* GetGrid(const float x, const float y);
GridMap * LoadMapAndVMap(const uint32 x, const uint32 y ); GridMap* LoadMapAndVMap(const uint32 x, const uint32 y);
int RefGrid(const uint32& x, const uint32& y); int RefGrid(const uint32& x, const uint32& y);
int UnrefGrid(const uint32& x, const uint32& y); int UnrefGrid(const uint32& x, const uint32& y);
const uint32 m_mapId; const uint32 m_mapId;
GridMap *m_GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; GridMap* m_GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
int16 m_GridRef[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; int16 m_GridRef[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
//global garbage collection timer //global garbage collection timer
ShortIntervalTimer i_timer; ShortIntervalTimer i_timer;
typedef ACE_Thread_Mutex LOCK_TYPE; typedef ACE_Thread_Mutex LOCK_TYPE;
typedef ACE_Guard<LOCK_TYPE> LOCK_GUARD; typedef ACE_Guard<LOCK_TYPE> LOCK_GUARD;
LOCK_TYPE m_mutex; LOCK_TYPE m_mutex;
LOCK_TYPE m_refMutex; LOCK_TYPE m_refMutex;
}; };
//class for managing TerrainData object and all sort of geometry querying operations //class for managing TerrainData object and all sort of geometry querying operations
class MANGOS_DLL_DECL TerrainManager : public MaNGOS::Singleton<TerrainManager, MaNGOS::ClassLevelLockable<TerrainManager, ACE_Thread_Mutex> > class MANGOS_DLL_DECL TerrainManager : public MaNGOS::Singleton<TerrainManager, MaNGOS::ClassLevelLockable<TerrainManager, ACE_Thread_Mutex> >
{ {
typedef UNORDERED_MAP<uint32, TerrainInfo *> TerrainDataMap; typedef UNORDERED_MAP<uint32, TerrainInfo*> TerrainDataMap;
friend class MaNGOS::OperatorNew<TerrainManager>; friend class MaNGOS::OperatorNew<TerrainManager>;
public: public:
TerrainInfo * LoadTerrain(const uint32 mapId); TerrainInfo* LoadTerrain(const uint32 mapId);
void UnloadTerrain(const uint32 mapId); void UnloadTerrain(const uint32 mapId);
void Update(const uint32 diff); void Update(const uint32 diff);
void UnloadAll(); void UnloadAll();
uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const
{ {
TerrainInfo *pData = const_cast<TerrainManager*>(this)->LoadTerrain(mapid); TerrainInfo* pData = const_cast<TerrainManager*>(this)->LoadTerrain(mapid);
return pData->GetAreaFlag(x, y, z); return pData->GetAreaFlag(x, y, z);
} }
uint32 GetAreaId(uint32 mapid, float x, float y, float z) const uint32 GetAreaId(uint32 mapid, float x, float y, float z) const
{ {
return TerrainManager::GetAreaIdByAreaFlag(GetAreaFlag(mapid, x, y, z),mapid); return TerrainManager::GetAreaIdByAreaFlag(GetAreaFlag(mapid, x, y, z),mapid);
} }
uint32 GetZoneId(uint32 mapid, float x, float y, float z) const uint32 GetZoneId(uint32 mapid, float x, float y, float z) const
{ {
return TerrainManager::GetZoneIdByAreaFlag(GetAreaFlag(mapid, x, y, z),mapid); return TerrainManager::GetZoneIdByAreaFlag(GetAreaFlag(mapid, x, y, z),mapid);
} }
void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, uint32 mapid, float x, float y, float z) void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, uint32 mapid, float x, float y, float z)
{ {
TerrainManager::GetZoneAndAreaIdByAreaFlag(zoneid,areaid,GetAreaFlag(mapid, x, y, z),mapid); TerrainManager::GetZoneAndAreaIdByAreaFlag(zoneid,areaid,GetAreaFlag(mapid, x, y, z),mapid);
} }
static uint32 GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id); static uint32 GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id);
static uint32 GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id); static uint32 GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id);
static void GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag,uint32 map_id); static void GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag,uint32 map_id);
private: private:
TerrainManager(); TerrainManager();
~TerrainManager(); ~TerrainManager();
TerrainManager(const TerrainManager &); TerrainManager(const TerrainManager&);
TerrainManager& operator=(const TerrainManager &); TerrainManager& operator=(const TerrainManager&);
typedef MaNGOS::ClassLevelLockable<TerrainManager, ACE_Thread_Mutex>::Lock Guard; typedef MaNGOS::ClassLevelLockable<TerrainManager, ACE_Thread_Mutex>::Lock Guard;
TerrainDataMap i_TerrainMap; TerrainDataMap i_TerrainMap;
}; };
#define sTerrainMgr TerrainManager::Instance() #define sTerrainMgr TerrainManager::Instance()

View file

@ -29,9 +29,9 @@
using namespace MaNGOS; using namespace MaNGOS;
void VisibleChangesNotifier::Visit(CameraMapType &m) void VisibleChangesNotifier::Visit(CameraMapType& m)
{ {
for(CameraMapType::iterator iter=m.begin(); iter != m.end(); ++iter) for (CameraMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
{ {
iter->getSource()->UpdateVisibilityOf(&i_object); iter->getSource()->UpdateVisibilityOf(&i_object);
} }
@ -42,9 +42,9 @@ void VisibleNotifier::Notify()
Player& player = *i_camera.GetOwner(); Player& player = *i_camera.GetOwner();
// at this moment i_clientGUIDs have guids that not iterate at grid level checks // at this moment i_clientGUIDs have guids that not iterate at grid level checks
// but exist one case when this possible and object not out of range: transports // but exist one case when this possible and object not out of range: transports
if(Transport* transport = player.GetTransport()) if (Transport* transport = player.GetTransport())
{ {
for(Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin();itr!=transport->GetPassengers().end();++itr) for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr!=transport->GetPassengers().end(); ++itr)
{ {
if (i_clientGUIDs.find((*itr)->GetObjectGuid()) != i_clientGUIDs.end()) if (i_clientGUIDs.find((*itr)->GetObjectGuid()) != i_clientGUIDs.end())
{ {
@ -58,12 +58,12 @@ void VisibleNotifier::Notify()
// generate outOfRange for not iterate objects // generate outOfRange for not iterate objects
i_data.AddOutOfRangeGUID(i_clientGUIDs); i_data.AddOutOfRangeGUID(i_clientGUIDs);
for(GuidSet::iterator itr = i_clientGUIDs.begin();itr!=i_clientGUIDs.end();++itr) for (GuidSet::iterator itr = i_clientGUIDs.begin(); itr!=i_clientGUIDs.end(); ++itr)
{ {
player.m_clientGUIDs.erase(*itr); player.m_clientGUIDs.erase(*itr);
DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is out of range (no in active cells set) now for %s", DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is out of range (no in active cells set) now for %s",
itr->GetString().c_str(), player.GetGuidStr().c_str()); itr->GetString().c_str(), player.GetGuidStr().c_str());
} }
if (i_data.HasData()) if (i_data.HasData())
@ -75,7 +75,7 @@ void VisibleNotifier::Notify()
// send out of range to other players if need // send out of range to other players if need
GuidSet const& oor = i_data.GetOutOfRangeGUIDs(); GuidSet const& oor = i_data.GetOutOfRangeGUIDs();
for(GuidSet::const_iterator iter = oor.begin(); iter != oor.end(); ++iter) for (GuidSet::const_iterator iter = oor.begin(); iter != oor.end(); ++iter)
{ {
if (!iter->IsPlayer()) if (!iter->IsPlayer())
continue; continue;
@ -88,7 +88,7 @@ void VisibleNotifier::Notify()
// Now do operations that required done at object visibility change to visible // Now do operations that required done at object visibility change to visible
// send data at target visibility change (adding to client) // send data at target visibility change (adding to client)
for(std::set<WorldObject*>::const_iterator vItr = i_visibleNow.begin(); vItr != i_visibleNow.end(); ++vItr) for (std::set<WorldObject*>::const_iterator vItr = i_visibleNow.begin(); vItr != i_visibleNow.end(); ++vItr)
{ {
// target aura duration for caster show only if target exist at caster client // target aura duration for caster show only if target exist at caster client
if ((*vItr) != &player && (*vItr)->isType(TYPEMASK_UNIT)) if ((*vItr) != &player && (*vItr)->isType(TYPEMASK_UNIT))
@ -96,9 +96,9 @@ void VisibleNotifier::Notify()
} }
} }
void MessageDeliverer::Visit(CameraMapType &m) void MessageDeliverer::Visit(CameraMapType& m)
{ {
for(CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
Player* owner = iter->getSource()->GetOwner(); Player* owner = iter->getSource()->GetOwner();
@ -113,9 +113,9 @@ void MessageDeliverer::Visit(CameraMapType &m)
} }
} }
void MessageDelivererExcept::Visit(CameraMapType &m) void MessageDelivererExcept::Visit(CameraMapType& m)
{ {
for(CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
Player* owner = iter->getSource()->GetOwner(); Player* owner = iter->getSource()->GetOwner();
@ -127,27 +127,27 @@ void MessageDelivererExcept::Visit(CameraMapType &m)
} }
} }
void ObjectMessageDeliverer::Visit(CameraMapType &m) void ObjectMessageDeliverer::Visit(CameraMapType& m)
{ {
for(CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
if(!iter->getSource()->GetBody()->InSamePhase(i_phaseMask)) if (!iter->getSource()->GetBody()->InSamePhase(i_phaseMask))
continue; continue;
if(WorldSession* session = iter->getSource()->GetOwner()->GetSession()) if (WorldSession* session = iter->getSource()->GetOwner()->GetSession())
session->SendPacket(i_message); session->SendPacket(i_message);
} }
} }
void MessageDistDeliverer::Visit(CameraMapType &m) void MessageDistDeliverer::Visit(CameraMapType& m)
{ {
for(CameraMapType::iterator iter=m.begin(); iter != m.end(); ++iter) for (CameraMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
{ {
Player * owner = iter->getSource()->GetOwner(); Player* owner = iter->getSource()->GetOwner();
if ((i_toSelf || owner != &i_player) && if ((i_toSelf || owner != &i_player) &&
(!i_ownTeamOnly || owner->GetTeam() == i_player.GetTeam()) && (!i_ownTeamOnly || owner->GetTeam() == i_player.GetTeam()) &&
(!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_player,i_dist))) (!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_player,i_dist)))
{ {
if (!i_player.InSamePhase(iter->getSource()->GetBody())) if (!i_player.InSamePhase(iter->getSource()->GetBody()))
continue; continue;
@ -158,9 +158,9 @@ void MessageDistDeliverer::Visit(CameraMapType &m)
} }
} }
void ObjectMessageDistDeliverer::Visit(CameraMapType &m) void ObjectMessageDistDeliverer::Visit(CameraMapType& m)
{ {
for(CameraMapType::iterator iter=m.begin(); iter != m.end(); ++iter) for (CameraMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
{ {
if (!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_object,i_dist)) if (!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_object,i_dist))
{ {
@ -174,9 +174,9 @@ void ObjectMessageDistDeliverer::Visit(CameraMapType &m)
} }
template<class T> template<class T>
void ObjectUpdater::Visit(GridRefManager<T> &m) void ObjectUpdater::Visit(GridRefManager<T>& m)
{ {
for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
WorldObject::UpdateHelper helper(iter->getSource()); WorldObject::UpdateHelper helper(iter->getSource());
helper.Update(i_timeDiff); helper.Update(i_timeDiff);
@ -186,21 +186,21 @@ void ObjectUpdater::Visit(GridRefManager<T> &m)
bool CannibalizeObjectCheck::operator()(Corpse* u) bool CannibalizeObjectCheck::operator()(Corpse* u)
{ {
// ignore bones // ignore bones
if(u->GetType()==CORPSE_BONES) if (u->GetType()==CORPSE_BONES)
return false; return false;
Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGuid()); Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGuid());
if( !owner || i_fobj->IsFriendlyTo(owner)) if (!owner || i_fobj->IsFriendlyTo(owner))
return false; return false;
if(i_fobj->IsWithinDistInMap(u, i_range) ) if (i_fobj->IsWithinDistInMap(u, i_range))
return true; return true;
return false; return false;
} }
void MaNGOS::RespawnDo::operator()( Creature* u ) const void MaNGOS::RespawnDo::operator()(Creature* u) const
{ {
// prevent respawn creatures for not active BG event // prevent respawn creatures for not active BG event
Map* map = u->GetMap(); Map* map = u->GetMap();
@ -214,7 +214,7 @@ void MaNGOS::RespawnDo::operator()( Creature* u ) const
u->Respawn(); u->Respawn();
} }
void MaNGOS::RespawnDo::operator()( GameObject* u ) const void MaNGOS::RespawnDo::operator()(GameObject* u) const
{ {
// prevent respawn gameobject for not active BG event // prevent respawn gameobject for not active BG event
Map* map = u->GetMap(); Map* map = u->GetMap();
@ -267,5 +267,5 @@ bool MaNGOS::AnyAssistCreatureInRangeCheck::operator()(Creature* u)
return true; return true;
} }
template void ObjectUpdater::Visit<GameObject>(GameObjectMapType &); template void ObjectUpdater::Visit<GameObject>(GameObjectMapType&);
template void ObjectUpdater::Visit<DynamicObject>(DynamicObjectMapType &); template void ObjectUpdater::Visit<DynamicObject>(DynamicObjectMapType&);

View file

@ -39,29 +39,29 @@ namespace MaNGOS
GuidSet i_clientGUIDs; GuidSet i_clientGUIDs;
std::set<WorldObject*> i_visibleNow; std::set<WorldObject*> i_visibleNow;
explicit VisibleNotifier(Camera &c) : i_camera(c), i_clientGUIDs(c.GetOwner()->m_clientGUIDs) {} explicit VisibleNotifier(Camera& c) : i_camera(c), i_clientGUIDs(c.GetOwner()->m_clientGUIDs) {}
template<class T> void Visit(GridRefManager<T> &m); template<class T> void Visit(GridRefManager<T>& m);
void Visit(CameraMapType &m) {} void Visit(CameraMapType& m) {}
void Notify(void); void Notify(void);
}; };
struct MANGOS_DLL_DECL VisibleChangesNotifier struct MANGOS_DLL_DECL VisibleChangesNotifier
{ {
WorldObject &i_object; WorldObject& i_object;
explicit VisibleChangesNotifier(WorldObject &object) : i_object(object) {} explicit VisibleChangesNotifier(WorldObject& object) : i_object(object) {}
template<class T> void Visit(GridRefManager<T> &) {} template<class T> void Visit(GridRefManager<T>&) {}
void Visit(CameraMapType &); void Visit(CameraMapType&);
}; };
struct MANGOS_DLL_DECL MessageDeliverer struct MANGOS_DLL_DECL MessageDeliverer
{ {
Player &i_player; Player& i_player;
WorldPacket *i_message; WorldPacket* i_message;
bool i_toSelf; bool i_toSelf;
MessageDeliverer(Player &pl, WorldPacket *msg, bool to_self) : i_player(pl), i_message(msg), i_toSelf(to_self) {} MessageDeliverer(Player& pl, WorldPacket* msg, bool to_self) : i_player(pl), i_message(msg), i_toSelf(to_self) {}
void Visit(CameraMapType &m); void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {} template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
}; };
struct MessageDelivererExcept struct MessageDelivererExcept
@ -70,94 +70,94 @@ namespace MaNGOS
WorldPacket* i_message; WorldPacket* i_message;
Player const* i_skipped_receiver; Player const* i_skipped_receiver;
MessageDelivererExcept(WorldObject const* obj, WorldPacket *msg, Player const* skipped) MessageDelivererExcept(WorldObject const* obj, WorldPacket* msg, Player const* skipped)
: i_phaseMask(obj->GetPhaseMask()), i_message(msg), i_skipped_receiver(skipped) {} : i_phaseMask(obj->GetPhaseMask()), i_message(msg), i_skipped_receiver(skipped) {}
void Visit(CameraMapType &m); void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {} template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
}; };
struct MANGOS_DLL_DECL ObjectMessageDeliverer struct MANGOS_DLL_DECL ObjectMessageDeliverer
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
WorldPacket *i_message; WorldPacket* i_message;
explicit ObjectMessageDeliverer(WorldObject& obj, WorldPacket *msg) explicit ObjectMessageDeliverer(WorldObject& obj, WorldPacket* msg)
: i_phaseMask(obj.GetPhaseMask()), i_message(msg) {} : i_phaseMask(obj.GetPhaseMask()), i_message(msg) {}
void Visit(CameraMapType &m); void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {} template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
}; };
struct MANGOS_DLL_DECL MessageDistDeliverer struct MANGOS_DLL_DECL MessageDistDeliverer
{ {
Player &i_player; Player& i_player;
WorldPacket *i_message; WorldPacket* i_message;
bool i_toSelf; bool i_toSelf;
bool i_ownTeamOnly; bool i_ownTeamOnly;
float i_dist; float i_dist;
MessageDistDeliverer(Player &pl, WorldPacket *msg, float dist, bool to_self, bool ownTeamOnly) MessageDistDeliverer(Player& pl, WorldPacket* msg, float dist, bool to_self, bool ownTeamOnly)
: i_player(pl), i_message(msg), i_toSelf(to_self), i_ownTeamOnly(ownTeamOnly), i_dist(dist) {} : i_player(pl), i_message(msg), i_toSelf(to_self), i_ownTeamOnly(ownTeamOnly), i_dist(dist) {}
void Visit(CameraMapType &m); void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {} template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
}; };
struct MANGOS_DLL_DECL ObjectMessageDistDeliverer struct MANGOS_DLL_DECL ObjectMessageDistDeliverer
{ {
WorldObject &i_object; WorldObject& i_object;
WorldPacket *i_message; WorldPacket* i_message;
float i_dist; float i_dist;
ObjectMessageDistDeliverer(WorldObject &obj, WorldPacket *msg, float dist) : i_object(obj), i_message(msg), i_dist(dist) {} ObjectMessageDistDeliverer(WorldObject& obj, WorldPacket* msg, float dist) : i_object(obj), i_message(msg), i_dist(dist) {}
void Visit(CameraMapType &m); void Visit(CameraMapType& m);
template<class SKIP> void Visit(GridRefManager<SKIP> &) {} template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
}; };
struct MANGOS_DLL_DECL ObjectUpdater struct MANGOS_DLL_DECL ObjectUpdater
{ {
uint32 i_timeDiff; uint32 i_timeDiff;
explicit ObjectUpdater(const uint32 &diff) : i_timeDiff(diff) {} explicit ObjectUpdater(const uint32& diff) : i_timeDiff(diff) {}
template<class T> void Visit(GridRefManager<T> &m); template<class T> void Visit(GridRefManager<T>& m);
void Visit(PlayerMapType &) {} void Visit(PlayerMapType&) {}
void Visit(CorpseMapType &) {} void Visit(CorpseMapType&) {}
void Visit(CameraMapType &) {} void Visit(CameraMapType&) {}
void Visit(CreatureMapType &); void Visit(CreatureMapType&);
}; };
struct MANGOS_DLL_DECL PlayerRelocationNotifier struct MANGOS_DLL_DECL PlayerRelocationNotifier
{ {
Player &i_player; Player& i_player;
PlayerRelocationNotifier(Player &pl) : i_player(pl) {} PlayerRelocationNotifier(Player& pl) : i_player(pl) {}
template<class T> void Visit(GridRefManager<T> &) {} template<class T> void Visit(GridRefManager<T>&) {}
void Visit(CreatureMapType &); void Visit(CreatureMapType&);
}; };
struct MANGOS_DLL_DECL CreatureRelocationNotifier struct MANGOS_DLL_DECL CreatureRelocationNotifier
{ {
Creature &i_creature; Creature& i_creature;
CreatureRelocationNotifier(Creature &c) : i_creature(c) {} CreatureRelocationNotifier(Creature& c) : i_creature(c) {}
template<class T> void Visit(GridRefManager<T> &) {} template<class T> void Visit(GridRefManager<T>&) {}
#ifdef WIN32 #ifdef WIN32
template<> void Visit(PlayerMapType &); template<> void Visit(PlayerMapType&);
#endif #endif
}; };
struct MANGOS_DLL_DECL DynamicObjectUpdater struct MANGOS_DLL_DECL DynamicObjectUpdater
{ {
DynamicObject &i_dynobject; DynamicObject& i_dynobject;
Unit* i_check; Unit* i_check;
bool i_positive; bool i_positive;
DynamicObjectUpdater(DynamicObject &dynobject, Unit* caster, bool positive) : i_dynobject(dynobject), i_positive(positive) DynamicObjectUpdater(DynamicObject& dynobject, Unit* caster, bool positive) : i_dynobject(dynobject), i_positive(positive)
{ {
i_check = caster; i_check = caster;
Unit* owner = i_check->GetOwner(); Unit* owner = i_check->GetOwner();
if(owner) if (owner)
i_check = owner; i_check = owner;
} }
template<class T> inline void Visit(GridRefManager<T> &) {} template<class T> inline void Visit(GridRefManager<T>&) {}
#ifdef WIN32 #ifdef WIN32
template<> inline void Visit<Player>(PlayerMapType &); template<> inline void Visit<Player>(PlayerMapType&);
template<> inline void Visit<Creature>(CreatureMapType &); template<> inline void Visit<Creature>(CreatureMapType&);
#endif #endif
void VisitHelper(Unit* target); void VisitHelper(Unit* target);
}; };
@ -197,45 +197,45 @@ namespace MaNGOS
// WorldObject searchers & workers // WorldObject searchers & workers
template<class Check> template<class Check>
struct MANGOS_DLL_DECL WorldObjectSearcher struct MANGOS_DLL_DECL WorldObjectSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
WorldObject* &i_object; WorldObject*& i_object;
Check &i_check; Check& i_check;
WorldObjectSearcher(WorldObject* & result, Check& check) WorldObjectSearcher(WorldObject*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {}
void Visit(GameObjectMapType &m); void Visit(GameObjectMapType& m);
void Visit(PlayerMapType &m); void Visit(PlayerMapType& m);
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
void Visit(CorpseMapType &m); void Visit(CorpseMapType& m);
void Visit(DynamicObjectMapType &m); void Visit(DynamicObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
template<class Check> template<class Check>
struct MANGOS_DLL_DECL WorldObjectListSearcher struct MANGOS_DLL_DECL WorldObjectListSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
std::list<WorldObject*> &i_objects; std::list<WorldObject*>& i_objects;
Check& i_check; Check& i_check;
WorldObjectListSearcher(std::list<WorldObject*> &objects, Check & check) WorldObjectListSearcher(std::list<WorldObject*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {}
void Visit(PlayerMapType &m); void Visit(PlayerMapType& m);
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
void Visit(CorpseMapType &m); void Visit(CorpseMapType& m);
void Visit(GameObjectMapType &m); void Visit(GameObjectMapType& m);
void Visit(DynamicObjectMapType &m); void Visit(DynamicObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
template<class Do> template<class Do>
struct MANGOS_DLL_DECL WorldObjectWorker struct MANGOS_DLL_DECL WorldObjectWorker
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
Do const& i_do; Do const& i_do;
@ -243,190 +243,190 @@ namespace MaNGOS
WorldObjectWorker(WorldObject const* searcher, Do const& _do) WorldObjectWorker(WorldObject const* searcher, Do const& _do)
: i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {} : i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {}
void Visit(GameObjectMapType &m) void Visit(GameObjectMapType& m)
{ {
for(GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if(itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource()); i_do(itr->getSource());
} }
void Visit(PlayerMapType &m) void Visit(PlayerMapType& m)
{ {
for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if(itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource()); i_do(itr->getSource());
} }
void Visit(CreatureMapType &m) void Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if(itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource()); i_do(itr->getSource());
} }
void Visit(CorpseMapType &m) void Visit(CorpseMapType& m)
{ {
for(CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if(itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource()); i_do(itr->getSource());
} }
void Visit(DynamicObjectMapType &m) void Visit(DynamicObjectMapType& m)
{ {
for(DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if(itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource()); i_do(itr->getSource());
} }
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// Gameobject searchers // Gameobject searchers
template<class Check> template<class Check>
struct MANGOS_DLL_DECL GameObjectSearcher struct MANGOS_DLL_DECL GameObjectSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
GameObject* &i_object; GameObject*& i_object;
Check &i_check; Check& i_check;
GameObjectSearcher(GameObject* & result, Check& check) GameObjectSearcher(GameObject*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {}
void Visit(GameObjectMapType &m); void Visit(GameObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// Last accepted by Check GO if any (Check can change requirements at each call) // Last accepted by Check GO if any (Check can change requirements at each call)
template<class Check> template<class Check>
struct MANGOS_DLL_DECL GameObjectLastSearcher struct MANGOS_DLL_DECL GameObjectLastSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
GameObject* &i_object; GameObject*& i_object;
Check& i_check; Check& i_check;
GameObjectLastSearcher(GameObject* & result, Check& check) GameObjectLastSearcher(GameObject*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
void Visit(GameObjectMapType &m); void Visit(GameObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
template<class Check> template<class Check>
struct MANGOS_DLL_DECL GameObjectListSearcher struct MANGOS_DLL_DECL GameObjectListSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
std::list<GameObject*> &i_objects; std::list<GameObject*>& i_objects;
Check& i_check; Check& i_check;
GameObjectListSearcher(std::list<GameObject*> &objects, Check & check) GameObjectListSearcher(std::list<GameObject*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {}
void Visit(GameObjectMapType &m); void Visit(GameObjectMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// Unit searchers // Unit searchers
// First accepted by Check Unit if any // First accepted by Check Unit if any
template<class Check> template<class Check>
struct MANGOS_DLL_DECL UnitSearcher struct MANGOS_DLL_DECL UnitSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
Unit* &i_object; Unit*& i_object;
Check & i_check; Check& i_check;
UnitSearcher(Unit* & result, Check & check) UnitSearcher(Unit*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {}
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
void Visit(PlayerMapType &m); void Visit(PlayerMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// Last accepted by Check Unit if any (Check can change requirements at each call) // Last accepted by Check Unit if any (Check can change requirements at each call)
template<class Check> template<class Check>
struct MANGOS_DLL_DECL UnitLastSearcher struct MANGOS_DLL_DECL UnitLastSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
Unit* &i_object; Unit*& i_object;
Check & i_check; Check& i_check;
UnitLastSearcher(Unit* & result, Check & check) UnitLastSearcher(Unit*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {}
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
void Visit(PlayerMapType &m); void Visit(PlayerMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// All accepted by Check units if any // All accepted by Check units if any
template<class Check> template<class Check>
struct MANGOS_DLL_DECL UnitListSearcher struct MANGOS_DLL_DECL UnitListSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
std::list<Unit*> &i_objects; std::list<Unit*>& i_objects;
Check& i_check; Check& i_check;
UnitListSearcher(std::list<Unit*> &objects, Check & check) UnitListSearcher(std::list<Unit*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {}
void Visit(PlayerMapType &m); void Visit(PlayerMapType& m);
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// Creature searchers // Creature searchers
template<class Check> template<class Check>
struct MANGOS_DLL_DECL CreatureSearcher struct MANGOS_DLL_DECL CreatureSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
Creature* &i_object; Creature*& i_object;
Check & i_check; Check& i_check;
CreatureSearcher(Creature* & result, Check & check) CreatureSearcher(Creature*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {}
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// Last accepted by Check Creature if any (Check can change requirements at each call) // Last accepted by Check Creature if any (Check can change requirements at each call)
template<class Check> template<class Check>
struct MANGOS_DLL_DECL CreatureLastSearcher struct MANGOS_DLL_DECL CreatureLastSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
Creature* &i_object; Creature*& i_object;
Check & i_check; Check& i_check;
CreatureLastSearcher(Creature* & result, Check & check) CreatureLastSearcher(Creature*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {}
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
template<class Check> template<class Check>
struct MANGOS_DLL_DECL CreatureListSearcher struct MANGOS_DLL_DECL CreatureListSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
std::list<Creature*> &i_objects; std::list<Creature*>& i_objects;
Check& i_check; Check& i_check;
CreatureListSearcher(std::list<Creature*> &objects, Check & check) CreatureListSearcher(std::list<Creature*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {}
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
template<class Do> template<class Do>
@ -438,14 +438,14 @@ namespace MaNGOS
CreatureWorker(WorldObject const* searcher, Do& _do) CreatureWorker(WorldObject const* searcher, Do& _do)
: i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {} : i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {}
void Visit(CreatureMapType &m) void Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if(itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource()); i_do(itr->getSource());
} }
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// Player searchers // Player searchers
@ -454,30 +454,30 @@ namespace MaNGOS
struct MANGOS_DLL_DECL PlayerSearcher struct MANGOS_DLL_DECL PlayerSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
Player* &i_object; Player*& i_object;
Check & i_check; Check& i_check;
PlayerSearcher(Player* & result, Check & check) PlayerSearcher(Player*& result, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {}
void Visit(PlayerMapType &m); void Visit(PlayerMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
template<class Check> template<class Check>
struct MANGOS_DLL_DECL PlayerListSearcher struct MANGOS_DLL_DECL PlayerListSearcher
{ {
uint32 i_phaseMask; uint32 i_phaseMask;
std::list<Player*> &i_objects; std::list<Player*>& i_objects;
Check& i_check; Check& i_check;
PlayerListSearcher(std::list<Player*> &objects, Check & check) PlayerListSearcher(std::list<Player*>& objects, Check& check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {}
void Visit(PlayerMapType &m); void Visit(PlayerMapType& m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
template<class Do> template<class Do>
@ -489,14 +489,14 @@ namespace MaNGOS
PlayerWorker(WorldObject const* searcher, Do& _do) PlayerWorker(WorldObject const* searcher, Do& _do)
: i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {} : i_phaseMask(searcher->GetPhaseMask()), i_do(_do) {}
void Visit(PlayerMapType &m) void Visit(PlayerMapType& m)
{ {
for(PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if(itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
i_do(itr->getSource()); i_do(itr->getSource());
} }
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
template<class Do> template<class Do>
@ -509,13 +509,13 @@ namespace MaNGOS
CameraDistWorker(WorldObject const* searcher, float _dist, Do& _do) CameraDistWorker(WorldObject const* searcher, float _dist, Do& _do)
: i_searcher(searcher), i_dist(_dist), i_do(_do) {} : i_searcher(searcher), i_dist(_dist), i_do(_do) {}
void Visit(CameraMapType &m) void Visit(CameraMapType& m)
{ {
for(CameraMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (CameraMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->GetBody()->InSamePhase(i_searcher) && itr->getSource()->GetBody()->IsWithinDist(i_searcher,i_dist)) if (itr->getSource()->GetBody()->InSamePhase(i_searcher) && itr->getSource()->GetBody()->IsWithinDist(i_searcher,i_dist))
i_do(itr->getSource()->GetOwner()); i_do(itr->getSource()->GetOwner());
} }
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
}; };
// CHECKS && DO classes // CHECKS && DO classes
@ -546,9 +546,9 @@ namespace MaNGOS
bool operator()(Creature* u) bool operator()(Creature* u)
{ {
if (i_fobj->isHonorOrXPTarget(u) || if (i_fobj->isHonorOrXPTarget(u) ||
u->getDeathState() != CORPSE || u->IsDeadByDefault() || u->IsTaxiFlying() || u->getDeathState() != CORPSE || u->IsDeadByDefault() || u->IsTaxiFlying() ||
( u->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID-1)) )==0 || (u->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID-1)))==0 ||
(u->GetDisplayId() != u->GetNativeDisplayId())) (u->GetDisplayId() != u->GetNativeDisplayId()))
return false; return false;
return i_fobj->IsWithinDistInMap(u, i_range); return i_fobj->IsWithinDistInMap(u, i_range);
@ -567,7 +567,7 @@ namespace MaNGOS
bool operator()(Player* u) bool operator()(Player* u)
{ {
if (u->getDeathState()!=CORPSE || u->IsTaxiFlying() || if (u->getDeathState()!=CORPSE || u->IsTaxiFlying() ||
u->HasAuraType(SPELL_AURA_GHOST) || (u->GetDisplayId() != u->GetNativeDisplayId())) u->HasAuraType(SPELL_AURA_GHOST) || (u->GetDisplayId() != u->GetNativeDisplayId()))
return false; return false;
return i_fobj->IsWithinDistInMap(u, i_range); return i_fobj->IsWithinDistInMap(u, i_range);
@ -575,8 +575,8 @@ namespace MaNGOS
bool operator()(Creature* u) bool operator()(Creature* u)
{ {
if (u->getDeathState()!=CORPSE || u->IsTaxiFlying() || u->IsDeadByDefault() || if (u->getDeathState()!=CORPSE || u->IsTaxiFlying() || u->IsDeadByDefault() ||
(u->GetDisplayId() != u->GetNativeDisplayId()) || (u->GetDisplayId() != u->GetNativeDisplayId()) ||
(u->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL)!=0) (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL)!=0)
return false; return false;
return i_fobj->IsWithinDistInMap(u, i_range); return i_fobj->IsWithinDistInMap(u, i_range);
@ -594,7 +594,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_fobj; } WorldObject const& GetFocusObject() const { return *i_fobj; }
bool operator()(Player* u) bool operator()(Player* u)
{ {
if( i_fobj->IsFriendlyTo(u) || u->isAlive() || u->IsTaxiFlying() ) if (i_fobj->IsFriendlyTo(u) || u->isAlive() || u->IsTaxiFlying())
return false; return false;
return i_fobj->IsWithinDistInMap(u, i_range); return i_fobj->IsWithinDistInMap(u, i_range);
@ -603,7 +603,7 @@ namespace MaNGOS
bool operator()(Creature* u) bool operator()(Creature* u)
{ {
if (i_fobj->IsFriendlyTo(u) || u->isAlive() || u->IsTaxiFlying() || if (i_fobj->IsFriendlyTo(u) || u->isAlive() || u->IsTaxiFlying() ||
(u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD)==0) (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD)==0)
return false; return false;
return i_fobj->IsWithinDistInMap(u, i_range); return i_fobj->IsWithinDistInMap(u, i_range);
@ -635,10 +635,10 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_unit; } WorldObject const& GetFocusObject() const { return *i_unit; }
bool operator()(GameObject* go) const bool operator()(GameObject* go) const
{ {
if(go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS) if (go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS)
return false; return false;
if(go->GetGOInfo()->spellFocus.focusId != i_focusId) if (go->GetGOInfo()->spellFocus.focusId != i_focusId)
return false; return false;
float dist = (float)go->GetGOInfo()->spellFocus.dist; float dist = (float)go->GetGOInfo()->spellFocus.dist;
@ -658,7 +658,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return i_obj; } WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(GameObject* go) bool operator()(GameObject* go)
{ {
if(go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, (float)go->GetGOInfo()->fishinghole.radius)) if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, (float)go->GetGOInfo()->fishinghole.radius))
{ {
i_range = i_obj.GetDistance(go); i_range = i_obj.GetDistance(go);
return true; return true;
@ -682,7 +682,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return i_obj; } WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(GameObject* go) bool operator()(GameObject* go)
{ {
if(go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range)) if (go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range))
{ {
i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
return true; return true;
@ -770,7 +770,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp) if (u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp)
{ {
i_hp = u->GetMaxHealth() - u->GetHealth(); i_hp = u->GetMaxHealth() - u->GetHealth();
return true; return true;
@ -790,8 +790,8 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && if (u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
(u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_CAN_NOT_REACT))) (u->isCharmed() || u->isFrozen() || u->hasUnitState(UNIT_STAT_CAN_NOT_REACT)))
{ {
return true; return true;
} }
@ -809,8 +809,8 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
if(u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && if (u->isAlive() && u->isInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) &&
!(u->HasAura(i_spell, EFFECT_INDEX_0) || u->HasAura(i_spell, EFFECT_INDEX_1) || u->HasAura(i_spell, EFFECT_INDEX_2))) !(u->HasAura(i_spell, EFFECT_INDEX_0) || u->HasAura(i_spell, EFFECT_INDEX_1) || u->HasAura(i_spell, EFFECT_INDEX_2)))
{ {
return true; return true;
} }
@ -829,7 +829,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u)) if (u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u))
return true; return true;
else else
return false; return false;
@ -849,9 +849,9 @@ namespace MaNGOS
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
return u->isAlive() return u->isAlive()
&& i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsWithinDistInMap(u, i_range)
&& !i_funit->IsFriendlyTo(u) && !i_funit->IsFriendlyTo(u)
&& u->isVisibleForOrDetect(i_funit,i_funit,false); && u->isVisibleForOrDetect(i_funit,i_funit,false);
} }
private: private:
WorldObject const* i_obj; WorldObject const* i_obj;
@ -866,7 +866,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsFriendlyTo(u)) if (u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsFriendlyTo(u))
return true; return true;
else else
return false; return false;
@ -883,7 +883,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range)) if (u->isAlive() && i_obj->IsWithinDistInMap(u, i_range))
return true; return true;
return false; return false;
@ -901,8 +901,8 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
if( u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) && if (u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) &&
!i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit,i_funit,false) ) !i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit,i_funit,false))
{ {
i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
return true; return true;
@ -936,7 +936,7 @@ namespace MaNGOS
return false; return false;
// ignore totems as AoE targets // ignore totems as AoE targets
if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsTotem()) if (u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsTotem())
return false; return false;
// check visibility only for unit-like original casters // check visibility only for unit-like original casters
@ -971,10 +971,10 @@ namespace MaNGOS
if (!u->isTargetableForAttack()) if (!u->isTargetableForAttack())
return false; return false;
if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsTotem()) if (u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsTotem())
return false; return false;
if(( i_targetForPlayer ? !i_obj->IsFriendlyTo(u) : i_obj->IsHostileTo(u) )&& i_obj->IsWithinDistInMap(u, i_range)) if ((i_targetForPlayer ? !i_obj->IsFriendlyTo(u) : i_obj->IsHostileTo(u))&& i_obj->IsWithinDistInMap(u, i_range))
return true; return true;
return false; return false;
@ -1030,7 +1030,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_funit; } WorldObject const& GetFocusObject() const { return *i_funit; }
bool operator()(Creature* u) bool operator()(Creature* u)
{ {
if(u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit))) if (u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit)))
return true; return true;
return false; return false;
@ -1063,15 +1063,15 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Creature* u) bool operator()(Creature* u)
{ {
if(u == i_obj) if (u == i_obj)
return false; return false;
if(!u->CanAssistTo(i_obj,i_enemy)) if (!u->CanAssistTo(i_obj,i_enemy))
return false; return false;
if(!i_obj->IsWithinDistInMap(u, i_range)) if (!i_obj->IsWithinDistInMap(u, i_range))
return false; return false;
if(!i_obj->IsWithinLOSInMap(u)) if (!i_obj->IsWithinLOSInMap(u))
return false; return false;
i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check
@ -1120,7 +1120,7 @@ namespace MaNGOS
public: public:
AllCreaturesOfEntryInRangeCheck(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {} AllCreaturesOfEntryInRangeCheck(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
WorldObject const& GetFocusObject() const { return *m_pObject; } WorldObject const& GetFocusObject() const { return *m_pObject; }
bool operator() (Unit* pUnit) bool operator()(Unit* pUnit)
{ {
if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit,m_fRange,false)) if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit,m_fRange,false))
return true; return true;
@ -1146,7 +1146,7 @@ namespace MaNGOS
WorldObject const& GetFocusObject() const { return *i_obj; } WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Player* u) bool operator()(Player* u)
{ {
if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range)) if (u->isAlive() && i_obj->IsWithinDistInMap(u, i_range))
return true; return true;
return false; return false;
@ -1165,8 +1165,8 @@ namespace MaNGOS
bool operator()(Player* u) bool operator()(Player* u)
{ {
return u->isAlive() return u->isAlive()
&& i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsWithinDistInMap(u, i_range)
&& u->HasAura(i_spellId); && u->HasAura(i_spellId);
} }
private: private:
WorldObject const* i_obj; WorldObject const* i_obj;
@ -1183,7 +1183,7 @@ namespace MaNGOS
bool operator()(Player* u) bool operator()(Player* u)
{ {
return u->CanUseOutdoorCapturePoint() && return u->CanUseOutdoorCapturePoint() &&
i_obj->IsWithinDistInMap(u, i_range); i_obj->IsWithinDistInMap(u, i_range);
} }
private: private:
WorldObject const* i_obj; WorldObject const* i_obj;
@ -1199,10 +1199,10 @@ namespace MaNGOS
~LocalizedPacketDo() ~LocalizedPacketDo()
{ {
for(size_t i = 0; i < i_data_cache.size(); ++i) for (size_t i = 0; i < i_data_cache.size(); ++i)
delete i_data_cache[i]; delete i_data_cache[i];
} }
void operator()( Player* p ); void operator()(Player* p);
private: private:
Builder& i_builder; Builder& i_builder;
@ -1219,24 +1219,24 @@ namespace MaNGOS
~LocalizedPacketListDo() ~LocalizedPacketListDo()
{ {
for(size_t i = 0; i < i_data_cache.size(); ++i) for (size_t i = 0; i < i_data_cache.size(); ++i)
for(size_t j = 0; j < i_data_cache[i].size(); ++j) for (size_t j = 0; j < i_data_cache[i].size(); ++j)
delete i_data_cache[i][j]; delete i_data_cache[i][j];
} }
void operator()( Player* p ); void operator()(Player* p);
private: private:
Builder& i_builder; Builder& i_builder;
std::vector<WorldPacketList> i_data_cache; std::vector<WorldPacketList> i_data_cache;
// 0 = default, i => i-1 locale index // 0 = default, i => i-1 locale index
}; };
#ifndef WIN32 #ifndef WIN32
template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType &); template<> void PlayerRelocationNotifier::Visit<Creature>(CreatureMapType&);
template<> void CreatureRelocationNotifier::Visit<Player>(PlayerMapType &); template<> void CreatureRelocationNotifier::Visit<Player>(PlayerMapType&);
template<> void CreatureRelocationNotifier::Visit<Creature>(CreatureMapType &); template<> void CreatureRelocationNotifier::Visit<Creature>(CreatureMapType&);
template<> inline void DynamicObjectUpdater::Visit<Creature>(CreatureMapType &); template<> inline void DynamicObjectUpdater::Visit<Creature>(CreatureMapType&);
template<> inline void DynamicObjectUpdater::Visit<Player>(PlayerMapType &); template<> inline void DynamicObjectUpdater::Visit<Player>(PlayerMapType&);
#endif #endif
} }
#endif #endif

View file

@ -30,18 +30,18 @@
#include "DBCStores.h" #include "DBCStores.h"
template<class T> template<class T>
inline void MaNGOS::VisibleNotifier::Visit(GridRefManager<T> &m) inline void MaNGOS::VisibleNotifier::Visit(GridRefManager<T>& m)
{ {
for(typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
i_camera.UpdateVisibilityOf(iter->getSource(), i_data, i_visibleNow); i_camera.UpdateVisibilityOf(iter->getSource(), i_data, i_visibleNow);
i_clientGUIDs.erase(iter->getSource()->GetObjectGuid()); i_clientGUIDs.erase(iter->getSource()->GetObjectGuid());
} }
} }
inline void MaNGOS::ObjectUpdater::Visit(CreatureMapType &m) inline void MaNGOS::ObjectUpdater::Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
WorldObject::UpdateHelper helper(iter->getSource()); WorldObject::UpdateHelper helper(iter->getSource());
helper.Update(i_timeDiff); helper.Update(i_timeDiff);
@ -73,12 +73,12 @@ inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
} }
} }
inline void MaNGOS::PlayerRelocationNotifier::Visit(CreatureMapType &m) inline void MaNGOS::PlayerRelocationNotifier::Visit(CreatureMapType& m)
{ {
if (!i_player.isAlive() || i_player.IsTaxiFlying()) if (!i_player.isAlive() || i_player.IsTaxiFlying())
return; return;
for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
Creature* c = iter->getSource(); Creature* c = iter->getSource();
if (c->isAlive()) if (c->isAlive())
@ -87,12 +87,12 @@ inline void MaNGOS::PlayerRelocationNotifier::Visit(CreatureMapType &m)
} }
template<> template<>
inline void MaNGOS::CreatureRelocationNotifier::Visit(PlayerMapType &m) inline void MaNGOS::CreatureRelocationNotifier::Visit(PlayerMapType& m)
{ {
if (!i_creature.isAlive()) if (!i_creature.isAlive())
return; return;
for(PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
{ {
Player* player = iter->getSource(); Player* player = iter->getSource();
if (player->isAlive() && !player->IsTaxiFlying()) if (player->isAlive() && !player->IsTaxiFlying())
@ -101,12 +101,12 @@ inline void MaNGOS::CreatureRelocationNotifier::Visit(PlayerMapType &m)
} }
template<> template<>
inline void MaNGOS::CreatureRelocationNotifier::Visit(CreatureMapType &m) inline void MaNGOS::CreatureRelocationNotifier::Visit(CreatureMapType& m)
{ {
if (!i_creature.isAlive()) if (!i_creature.isAlive())
return; return;
for(CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
Creature* c = iter->getSource(); Creature* c = iter->getSource();
if (c != &i_creature && c->isAlive()) if (c != &i_creature && c->isAlive())
@ -116,7 +116,7 @@ inline void MaNGOS::CreatureRelocationNotifier::Visit(CreatureMapType &m)
inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
{ {
if (!target->isAlive() || target->IsTaxiFlying() ) if (!target->isAlive() || target->IsTaxiFlying())
return; return;
if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->IsTotem()) if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->IsTotem())
@ -138,21 +138,21 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
return; return;
// for player casts use less strict negative and more stricted positive targeting // for player casts use less strict negative and more stricted positive targeting
if (i_check->GetTypeId() == TYPEID_PLAYER ) if (i_check->GetTypeId() == TYPEID_PLAYER)
{ {
if (i_check->IsFriendlyTo( target ) != i_positive) if (i_check->IsFriendlyTo(target) != i_positive)
return; return;
} }
else else
{ {
if (i_check->IsHostileTo( target ) == i_positive) if (i_check->IsHostileTo(target) == i_positive)
return; return;
} }
if (i_dynobject.IsAffecting(target)) if (i_dynobject.IsAffecting(target))
return; return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId()); SpellEntry const* spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId());
SpellEffectIndex eff_index = i_dynobject.GetEffIndex(); SpellEffectIndex eff_index = i_dynobject.GetEffIndex();
// Check target immune to spell or aura // Check target immune to spell or aura
@ -161,7 +161,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
// Apply PersistentAreaAura on target // Apply PersistentAreaAura on target
// in case 2 dynobject overlap areas for same spell, same holder is selected, so dynobjects share holder // in case 2 dynobject overlap areas for same spell, same holder is selected, so dynobjects share holder
SpellAuraHolder *holder = target->GetSpellAuraHolder(spellInfo->Id, i_dynobject.GetCasterGuid()); SpellAuraHolder* holder = target->GetSpellAuraHolder(spellInfo->Id, i_dynobject.GetCasterGuid());
if (holder) if (holder)
{ {
@ -192,16 +192,16 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target)
} }
template<> template<>
inline void MaNGOS::DynamicObjectUpdater::Visit(CreatureMapType &m) inline void MaNGOS::DynamicObjectUpdater::Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
VisitHelper(itr->getSource()); VisitHelper(itr->getSource());
} }
template<> template<>
inline void MaNGOS::DynamicObjectUpdater::Visit(PlayerMapType &m) inline void MaNGOS::DynamicObjectUpdater::Visit(PlayerMapType& m)
{ {
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
VisitHelper(itr->getSource()); VisitHelper(itr->getSource());
} }
@ -210,13 +210,13 @@ inline void MaNGOS::DynamicObjectUpdater::Visit(PlayerMapType &m)
// WorldObject searchers & workers // WorldObject searchers & workers
template<class Check> template<class Check>
void MaNGOS::WorldObjectSearcher<Check>::Visit(GameObjectMapType &m) void MaNGOS::WorldObjectSearcher<Check>::Visit(GameObjectMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -230,13 +230,13 @@ void MaNGOS::WorldObjectSearcher<Check>::Visit(GameObjectMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectSearcher<Check>::Visit(PlayerMapType &m) void MaNGOS::WorldObjectSearcher<Check>::Visit(PlayerMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -250,13 +250,13 @@ void MaNGOS::WorldObjectSearcher<Check>::Visit(PlayerMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectSearcher<Check>::Visit(CreatureMapType &m) void MaNGOS::WorldObjectSearcher<Check>::Visit(CreatureMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -270,13 +270,13 @@ void MaNGOS::WorldObjectSearcher<Check>::Visit(CreatureMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectSearcher<Check>::Visit(CorpseMapType &m) void MaNGOS::WorldObjectSearcher<Check>::Visit(CorpseMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -290,13 +290,13 @@ void MaNGOS::WorldObjectSearcher<Check>::Visit(CorpseMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectSearcher<Check>::Visit(DynamicObjectMapType &m) void MaNGOS::WorldObjectSearcher<Check>::Visit(DynamicObjectMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -310,45 +310,45 @@ void MaNGOS::WorldObjectSearcher<Check>::Visit(DynamicObjectMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectListSearcher<Check>::Visit(PlayerMapType &m) void MaNGOS::WorldObjectListSearcher<Check>::Visit(PlayerMapType& m)
{ {
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectListSearcher<Check>::Visit(CreatureMapType &m) void MaNGOS::WorldObjectListSearcher<Check>::Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectListSearcher<Check>::Visit(CorpseMapType &m) void MaNGOS::WorldObjectListSearcher<Check>::Visit(CorpseMapType& m)
{ {
for(CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectListSearcher<Check>::Visit(GameObjectMapType &m) void MaNGOS::WorldObjectListSearcher<Check>::Visit(GameObjectMapType& m)
{ {
for(GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
} }
template<class Check> template<class Check>
void MaNGOS::WorldObjectListSearcher<Check>::Visit(DynamicObjectMapType &m) void MaNGOS::WorldObjectListSearcher<Check>::Visit(DynamicObjectMapType& m)
{ {
for(DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
@ -357,13 +357,13 @@ void MaNGOS::WorldObjectListSearcher<Check>::Visit(DynamicObjectMapType &m)
// Gameobject searchers // Gameobject searchers
template<class Check> template<class Check>
void MaNGOS::GameObjectSearcher<Check>::Visit(GameObjectMapType &m) void MaNGOS::GameObjectSearcher<Check>::Visit(GameObjectMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -377,9 +377,9 @@ void MaNGOS::GameObjectSearcher<Check>::Visit(GameObjectMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::GameObjectLastSearcher<Check>::Visit(GameObjectMapType &m) void MaNGOS::GameObjectLastSearcher<Check>::Visit(GameObjectMapType& m)
{ {
for(GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -390,9 +390,9 @@ void MaNGOS::GameObjectLastSearcher<Check>::Visit(GameObjectMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::GameObjectListSearcher<Check>::Visit(GameObjectMapType &m) void MaNGOS::GameObjectListSearcher<Check>::Visit(GameObjectMapType& m)
{ {
for(GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
@ -401,13 +401,13 @@ void MaNGOS::GameObjectListSearcher<Check>::Visit(GameObjectMapType &m)
// Unit searchers // Unit searchers
template<class Check> template<class Check>
void MaNGOS::UnitSearcher<Check>::Visit(CreatureMapType &m) void MaNGOS::UnitSearcher<Check>::Visit(CreatureMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -421,13 +421,13 @@ void MaNGOS::UnitSearcher<Check>::Visit(CreatureMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::UnitSearcher<Check>::Visit(PlayerMapType &m) void MaNGOS::UnitSearcher<Check>::Visit(PlayerMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -441,9 +441,9 @@ void MaNGOS::UnitSearcher<Check>::Visit(PlayerMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::UnitLastSearcher<Check>::Visit(CreatureMapType &m) void MaNGOS::UnitLastSearcher<Check>::Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -454,9 +454,9 @@ void MaNGOS::UnitLastSearcher<Check>::Visit(CreatureMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::UnitLastSearcher<Check>::Visit(PlayerMapType &m) void MaNGOS::UnitLastSearcher<Check>::Visit(PlayerMapType& m)
{ {
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -467,18 +467,18 @@ void MaNGOS::UnitLastSearcher<Check>::Visit(PlayerMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::UnitListSearcher<Check>::Visit(PlayerMapType &m) void MaNGOS::UnitListSearcher<Check>::Visit(PlayerMapType& m)
{ {
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
} }
template<class Check> template<class Check>
void MaNGOS::UnitListSearcher<Check>::Visit(CreatureMapType &m) void MaNGOS::UnitListSearcher<Check>::Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
@ -487,13 +487,13 @@ void MaNGOS::UnitListSearcher<Check>::Visit(CreatureMapType &m)
// Creature searchers // Creature searchers
template<class Check> template<class Check>
void MaNGOS::CreatureSearcher<Check>::Visit(CreatureMapType &m) void MaNGOS::CreatureSearcher<Check>::Visit(CreatureMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -507,9 +507,9 @@ void MaNGOS::CreatureSearcher<Check>::Visit(CreatureMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::CreatureLastSearcher<Check>::Visit(CreatureMapType &m) void MaNGOS::CreatureLastSearcher<Check>::Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -520,22 +520,22 @@ void MaNGOS::CreatureLastSearcher<Check>::Visit(CreatureMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::CreatureListSearcher<Check>::Visit(CreatureMapType &m) void MaNGOS::CreatureListSearcher<Check>::Visit(CreatureMapType& m)
{ {
for(CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
} }
template<class Check> template<class Check>
void MaNGOS::PlayerSearcher<Check>::Visit(PlayerMapType &m) void MaNGOS::PlayerSearcher<Check>::Visit(PlayerMapType& m)
{ {
// already found // already found
if (i_object) if (i_object)
return; return;
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
if (!itr->getSource()->InSamePhase(i_phaseMask)) if (!itr->getSource()->InSamePhase(i_phaseMask))
continue; continue;
@ -549,16 +549,16 @@ void MaNGOS::PlayerSearcher<Check>::Visit(PlayerMapType &m)
} }
template<class Check> template<class Check>
void MaNGOS::PlayerListSearcher<Check>::Visit(PlayerMapType &m) void MaNGOS::PlayerListSearcher<Check>::Visit(PlayerMapType& m)
{ {
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask)) if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource())) if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource()); i_objects.push_back(itr->getSource());
} }
template<class Builder> template<class Builder>
void MaNGOS::LocalizedPacketDo<Builder>::operator()( Player* p ) void MaNGOS::LocalizedPacketDo<Builder>::operator()(Player* p)
{ {
int32 loc_idx = p->GetSession()->GetSessionDbLocaleIndex(); int32 loc_idx = p->GetSession()->GetSessionDbLocaleIndex();
uint32 cache_idx = loc_idx+1; uint32 cache_idx = loc_idx+1;
@ -583,7 +583,7 @@ void MaNGOS::LocalizedPacketDo<Builder>::operator()( Player* p )
} }
template<class Builder> template<class Builder>
void MaNGOS::LocalizedPacketListDo<Builder>::operator()( Player* p ) void MaNGOS::LocalizedPacketListDo<Builder>::operator()(Player* p)
{ {
int32 loc_idx = p->GetSession()->GetSessionDbLocaleIndex(); int32 loc_idx = p->GetSession()->GetSessionDbLocaleIndex();
uint32 cache_idx = loc_idx+1; uint32 cache_idx = loc_idx+1;
@ -602,7 +602,7 @@ void MaNGOS::LocalizedPacketListDo<Builder>::operator()( Player* p )
else else
data_list = &i_data_cache[cache_idx]; data_list = &i_data_cache[cache_idx];
for(size_t i = 0; i < data_list->size(); ++i) for (size_t i = 0; i < data_list->size(); ++i)
p->SendDirectMessage((*data_list)[i]); p->SendDirectMessage((*data_list)[i]);
} }

View file

@ -22,18 +22,18 @@
#include "Log.h" #include "Log.h"
void void
InvalidState::Update(Map &, NGridType &, GridInfo &, const uint32 &/*x*/, const uint32 &/*y*/, const uint32 &) const InvalidState::Update(Map&, NGridType&, GridInfo&, const uint32& /*x*/, const uint32& /*y*/, const uint32&) const
{ {
} }
void void
ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 &x, const uint32 &y, const uint32 &t_diff) const ActiveState::Update(Map& m, NGridType& grid, GridInfo& info, const uint32& x, const uint32& y, const uint32& t_diff) const
{ {
// Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle // Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle
info.UpdateTimeTracker(t_diff); info.UpdateTimeTracker(t_diff);
if( info.getTimeTracker().Passed() ) if (info.getTimeTracker().Passed())
{ {
if( grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(x, y) ) if (grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(x, y))
{ {
ObjectGridStoper stoper(grid); ObjectGridStoper stoper(grid);
stoper.StopN(); stoper.StopN();
@ -47,7 +47,7 @@ ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 &x, c
} }
void void
IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &) const IdleState::Update(Map& m, NGridType& grid, GridInfo&, const uint32& x, const uint32& y, const uint32&) const
{ {
m.ResetGridExpiry(grid); m.ResetGridExpiry(grid);
grid.SetGridState(GRID_STATE_REMOVAL); grid.SetGridState(GRID_STATE_REMOVAL);
@ -55,14 +55,14 @@ IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32 &x, const ui
} }
void void
RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 &x, const uint32 &y, const uint32 &t_diff) const RemovalState::Update(Map& m, NGridType& grid, GridInfo& info, const uint32& x, const uint32& y, const uint32& t_diff) const
{ {
if(!info.getUnloadLock()) if (!info.getUnloadLock())
{ {
info.UpdateTimeTracker(t_diff); info.UpdateTimeTracker(t_diff);
if( info.getTimeTracker().Passed() ) if (info.getTimeTracker().Passed())
{ {
if( !m.UnloadGrid(x, y, false) ) if (!m.UnloadGrid(x, y, false))
{ {
DEBUG_LOG("Grid[%u,%u] for map %u differed unloading due to players or active objects nearby", x, y, m.GetId()); DEBUG_LOG("Grid[%u,%u] for map %u differed unloading due to players or active objects nearby", x, y, m.GetId());
m.ResetGridExpiry(grid); m.ResetGridExpiry(grid);

View file

@ -25,35 +25,35 @@ class MANGOS_DLL_DECL GridState
{ {
public: public:
virtual void Update(Map &, NGridType&, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &t_diff) const = 0; virtual void Update(Map&, NGridType&, GridInfo&, const uint32& x, const uint32& y, const uint32& t_diff) const = 0;
}; };
class MANGOS_DLL_DECL InvalidState : public GridState class MANGOS_DLL_DECL InvalidState : public GridState
{ {
public: public:
void Update(Map &, NGridType &, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &t_diff) const; void Update(Map&, NGridType&, GridInfo&, const uint32& x, const uint32& y, const uint32& t_diff) const;
}; };
class MANGOS_DLL_DECL ActiveState : public GridState class MANGOS_DLL_DECL ActiveState : public GridState
{ {
public: public:
void Update(Map &, NGridType &, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &t_diff) const; void Update(Map&, NGridType&, GridInfo&, const uint32& x, const uint32& y, const uint32& t_diff) const;
}; };
class MANGOS_DLL_DECL IdleState : public GridState class MANGOS_DLL_DECL IdleState : public GridState
{ {
public: public:
void Update(Map &, NGridType &, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &t_diff) const; void Update(Map&, NGridType&, GridInfo&, const uint32& x, const uint32& y, const uint32& t_diff) const;
}; };
class MANGOS_DLL_DECL RemovalState : public GridState class MANGOS_DLL_DECL RemovalState : public GridState
{ {
public: public:
void Update(Map &, NGridType &, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &t_diff) const; void Update(Map&, NGridType&, GridInfo&, const uint32& x, const uint32& y, const uint32& t_diff) const;
}; };
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -139,7 +139,7 @@ enum GroupUpdateFlags
}; };
#define GROUP_UPDATE_FLAGS_COUNT 20 #define GROUP_UPDATE_FLAGS_COUNT 20
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19 // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19
static const uint8 GroupUpdateLength[GROUP_UPDATE_FLAGS_COUNT] = { 0, 2, 2, 2, 1, 2, 2, 2, 2, 4, 8, 8, 1, 2, 2, 2, 1, 2, 2, 8}; static const uint8 GroupUpdateLength[GROUP_UPDATE_FLAGS_COUNT] = { 0, 2, 2, 2, 1, 2, 2, 2, 2, 4, 8, 8, 1, 2, 2, 2, 1, 2, 2, 8};
class Roll : public LootValidatorRef class Roll : public LootValidatorRef
@ -147,11 +147,11 @@ class Roll : public LootValidatorRef
public: public:
Roll(ObjectGuid _lootedTragetGuid, LootMethod method, LootItem const& li) Roll(ObjectGuid _lootedTragetGuid, LootMethod method, LootItem const& li)
: lootedTargetGUID(_lootedTragetGuid), itemid(li.itemid), itemRandomPropId(li.randomPropertyId), itemRandomSuffix(li.randomSuffix), : lootedTargetGUID(_lootedTragetGuid), itemid(li.itemid), itemRandomPropId(li.randomPropertyId), itemRandomSuffix(li.randomSuffix),
itemCount(li.count), totalPlayersRolling(0), totalNeed(0), totalGreed(0), totalPass(0), itemSlot(0), itemCount(li.count), totalPlayersRolling(0), totalNeed(0), totalGreed(0), totalPass(0), itemSlot(0),
m_method(method), m_commonVoteMask(ROLL_VOTE_MASK_ALL) {} m_method(method), m_commonVoteMask(ROLL_VOTE_MASK_ALL) {}
~Roll() { } ~Roll() { }
void setLoot(Loot *pLoot) { link(pLoot, this); } void setLoot(Loot* pLoot) { link(pLoot, this); }
Loot *getLoot() { return getTarget(); } Loot* getLoot() { return getTarget(); }
void targetObjectBuildLink(); void targetObjectBuildLink();
void CalculateCommonVoteMask(uint32 max_enchanting_skill); void CalculateCommonVoteMask(uint32 max_enchanting_skill);
@ -177,7 +177,7 @@ class Roll : public LootValidatorRef
struct InstanceGroupBind struct InstanceGroupBind
{ {
DungeonPersistentState *state; DungeonPersistentState* state;
bool perm; bool perm;
/* permanent InstanceGroupBinds exist iff the leader has a permanent /* permanent InstanceGroupBinds exist iff the leader has a permanent
PlayerInstanceBind for the same instance. */ PlayerInstanceBind for the same instance. */
@ -211,13 +211,13 @@ class MANGOS_DLL_SPEC Group
~Group(); ~Group();
// group manipulation methods // group manipulation methods
bool Create(ObjectGuid guid, const char * name); bool Create(ObjectGuid guid, const char* name);
bool LoadGroupFromDB(Field *fields); bool LoadGroupFromDB(Field* fields);
bool LoadMemberFromDB(uint32 guidLow, uint8 subgroup, bool assistant); bool LoadMemberFromDB(uint32 guidLow, uint8 subgroup, bool assistant);
bool AddInvite(Player *player); bool AddInvite(Player* player);
uint32 RemoveInvite(Player *player); uint32 RemoveInvite(Player* player);
void RemoveAllInvites(); void RemoveAllInvites();
bool AddLeaderInvite(Player *player); bool AddLeaderInvite(Player* player);
bool AddMember(ObjectGuid guid, const char* name); bool AddMember(ObjectGuid guid, const char* name);
uint32 RemoveMember(ObjectGuid guid, uint8 method); // method: 0=just remove, 1=kick uint32 RemoveMember(ObjectGuid guid, uint8 method); // method: 0=just remove, 1=kick
void ChangeLeader(ObjectGuid guid); void ChangeLeader(ObjectGuid guid);
@ -235,7 +235,7 @@ class MANGOS_DLL_SPEC Group
bool isBGGroup() const { return m_bgGroup != NULL; } bool isBGGroup() const { return m_bgGroup != NULL; }
bool IsCreated() const { return GetMembersCount() > 0; } bool IsCreated() const { return GetMembersCount() > 0; }
ObjectGuid GetLeaderGuid() const { return m_leaderGuid; } ObjectGuid GetLeaderGuid() const { return m_leaderGuid; }
const char * GetLeaderName() const { return m_leaderName.c_str(); } const char* GetLeaderName() const { return m_leaderName.c_str(); }
LootMethod GetLootMethod() const { return m_lootMethod; } LootMethod GetLootMethod() const { return m_lootMethod; }
ObjectGuid GetLooterGuid() const { return m_looterGuid; } ObjectGuid GetLooterGuid() const { return m_looterGuid; }
ItemQualities GetLootThreshold() const { return m_lootThreshold; } ItemQualities GetLootThreshold() const { return m_lootThreshold; }
@ -245,7 +245,7 @@ class MANGOS_DLL_SPEC Group
bool IsLeader(ObjectGuid guid) const { return GetLeaderGuid() == guid; } bool IsLeader(ObjectGuid guid) const { return GetLeaderGuid() == guid; }
ObjectGuid GetMemberGuid(const std::string& name) ObjectGuid GetMemberGuid(const std::string& name)
{ {
for(member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
if (itr->name == name) if (itr->name == name)
return itr->guid; return itr->guid;
@ -272,7 +272,7 @@ class MANGOS_DLL_SPEC Group
MemberSlotList const& GetMemberSlots() const { return m_memberSlots; } MemberSlotList const& GetMemberSlots() const { return m_memberSlots; }
GroupReference* GetFirstMember() { return m_memberMgr.getFirst(); } GroupReference* GetFirstMember() { return m_memberMgr.getFirst(); }
uint32 GetMembersCount() const { return m_memberSlots.size(); } uint32 GetMembersCount() const { return m_memberSlots.size(); }
void GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player* & member_with_max_level, Player* & not_gray_member_with_max_level, Player* additional = NULL); void GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player*& member_with_max_level, Player*& not_gray_member_with_max_level, Player* additional = NULL);
uint8 GetMemberGroup(ObjectGuid guid) const uint8 GetMemberGroup(ObjectGuid guid) const
{ {
member_citerator mslot = _getMemberCSlot(guid); member_citerator mslot = _getMemberCSlot(guid);
@ -285,11 +285,11 @@ class MANGOS_DLL_SPEC Group
// some additional raid methods // some additional raid methods
void ConvertToRaid(); void ConvertToRaid();
void SetBattlegroundGroup(BattleGround *bg) { m_bgGroup = bg; } void SetBattlegroundGroup(BattleGround* bg) { m_bgGroup = bg; }
GroupJoinBattlegroundResult CanJoinBattleGroundQueue(BattleGround const* bgOrTemplate, BattleGroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot); GroupJoinBattlegroundResult CanJoinBattleGroundQueue(BattleGround const* bgOrTemplate, BattleGroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot);
void ChangeMembersGroup(ObjectGuid guid, uint8 group); void ChangeMembersGroup(ObjectGuid guid, uint8 group);
void ChangeMembersGroup(Player *player, uint8 group); void ChangeMembersGroup(Player* player, uint8 group);
ObjectGuid GetMainTankGuid() const { return m_mainTankGuid; } ObjectGuid GetMainTankGuid() const { return m_mainTankGuid; }
ObjectGuid GetMainAssistantGuid() const { return m_mainAssistantGuid; } ObjectGuid GetMainAssistantGuid() const { return m_mainAssistantGuid; }
@ -329,12 +329,12 @@ class MANGOS_DLL_SPEC Group
bool InCombatToInstance(uint32 instanceId); bool InCombatToInstance(uint32 instanceId);
void ResetInstances(InstanceResetMethod method, bool isRaid, Player* SendMsgTo); void ResetInstances(InstanceResetMethod method, bool isRaid, Player* SendMsgTo);
void SendTargetIconList(WorldSession *session); void SendTargetIconList(WorldSession* session);
void SendUpdate(); void SendUpdate();
void UpdatePlayerOutOfRange(Player* pPlayer); void UpdatePlayerOutOfRange(Player* pPlayer);
// ignore: GUID of player that will be ignored // ignore: GUID of player that will be ignored
void BroadcastPacket(WorldPacket *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignore = ObjectGuid()); void BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignore = ObjectGuid());
void BroadcastReadyCheck(WorldPacket *packet); void BroadcastReadyCheck(WorldPacket* packet);
void OfflineReadyCheck(); void OfflineReadyCheck();
void RewardGroupAtKill(Unit* pVictim, Player* player_tap); void RewardGroupAtKill(Unit* pVictim, Player* player_tap);
@ -345,10 +345,10 @@ class MANGOS_DLL_SPEC Group
/*** LOOT SYSTEM ***/ /*** LOOT SYSTEM ***/
/*********************************************************/ /*********************************************************/
void SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r); void SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll& r);
void SendLootRoll(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 rollType, const Roll &r); void SendLootRoll(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 rollType, const Roll& r);
void SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, RollVote rollType, const Roll &r); void SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, RollVote rollType, const Roll& r);
void SendLootAllPassed(const Roll &r); void SendLootAllPassed(const Roll& r);
void GroupLoot(WorldObject* pSource, Loot* loot); void GroupLoot(WorldObject* pSource, Loot* loot);
void NeedBeforeGreed(WorldObject* pSource, Loot* loot); void NeedBeforeGreed(WorldObject* pSource, Loot* loot);
void MasterLoot(WorldObject* pSource, Loot* loot); void MasterLoot(WorldObject* pSource, Loot* loot);
@ -356,10 +356,10 @@ class MANGOS_DLL_SPEC Group
void StartLootRoll(WorldObject* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill); void StartLootRoll(WorldObject* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill);
void EndRoll(); void EndRoll();
void LinkMember(GroupReference *pRef) { m_memberMgr.insertFirst(pRef); } void LinkMember(GroupReference* pRef) { m_memberMgr.insertFirst(pRef); }
void DelinkMember(GroupReference* /*pRef*/ ) { } void DelinkMember(GroupReference* /*pRef*/) { }
InstanceGroupBind* BindToInstance(DungeonPersistentState *save, bool permanent, bool load = false); InstanceGroupBind* BindToInstance(DungeonPersistentState* save, bool permanent, bool load = false);
void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false); void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false);
InstanceGroupBind* GetBoundInstance(uint32 mapId, Player* player); InstanceGroupBind* GetBoundInstance(uint32 mapId, Player* player);
InstanceGroupBind* GetBoundInstance(Map* aMap, Difficulty difficulty); InstanceGroupBind* GetBoundInstance(Map* aMap, Difficulty difficulty);
@ -374,11 +374,11 @@ class MANGOS_DLL_SPEC Group
void _removeRolls(ObjectGuid guid); void _removeRolls(ObjectGuid guid);
bool _setMembersGroup(ObjectGuid guid, uint8 group); bool _setMembersGroup(ObjectGuid guid, uint8 group);
bool _setAssistantFlag(ObjectGuid guid, const bool &state); bool _setAssistantFlag(ObjectGuid guid, const bool& state);
bool _setMainTank(ObjectGuid guid); bool _setMainTank(ObjectGuid guid);
bool _setMainAssistant(ObjectGuid guid); bool _setMainAssistant(ObjectGuid guid);
void _homebindIfInstance(Player *player); void _homebindIfInstance(Player* player);
void _initRaidSubGroupsCounter() void _initRaidSubGroupsCounter()
{ {
@ -394,7 +394,7 @@ class MANGOS_DLL_SPEC Group
member_citerator _getMemberCSlot(ObjectGuid guid) const member_citerator _getMemberCSlot(ObjectGuid guid) const
{ {
for(member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
if (itr->guid == guid) if (itr->guid == guid)
return itr; return itr;
@ -403,7 +403,7 @@ class MANGOS_DLL_SPEC Group
member_witerator _getMemberWSlot(ObjectGuid guid) member_witerator _getMemberWSlot(ObjectGuid guid)
{ {
for(member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
if (itr->guid == guid) if (itr->guid == guid)
return itr; return itr;

View file

@ -48,10 +48,10 @@ void WorldSession::SendPartyResult(PartyOperation operation, const std::string&
data << uint32(res); data << uint32(res);
data << uint32(0); // LFD cooldown related (used with ERR_PARTY_LFG_BOOT_COOLDOWN_S and ERR_PARTY_LFG_BOOT_NOT_ELIGIBLE_S) data << uint32(0); // LFD cooldown related (used with ERR_PARTY_LFG_BOOT_COOLDOWN_S and ERR_PARTY_LFG_BOOT_NOT_ELIGIBLE_S)
SendPacket( &data ); SendPacket(&data);
} }
void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data ) void WorldSession::HandleGroupInviteOpcode(WorldPacket& recv_data)
{ {
std::string membername; std::string membername;
recv_data >> membername; recv_data >> membername;
@ -60,62 +60,62 @@ void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data )
// attempt add selected player // attempt add selected player
// cheating // cheating
if(!normalizePlayerName(membername)) if (!normalizePlayerName(membername))
{ {
SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S);
return; return;
} }
Player *player = sObjectMgr.GetPlayer(membername.c_str()); Player* player = sObjectMgr.GetPlayer(membername.c_str());
// no player // no player
if(!player) if (!player)
{ {
SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S); SendPartyResult(PARTY_OP_INVITE, membername, ERR_BAD_PLAYER_NAME_S);
return; return;
} }
// can't group with // can't group with
if(!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam()) if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam())
{ {
SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION); SendPartyResult(PARTY_OP_INVITE, membername, ERR_PLAYER_WRONG_FACTION);
return; return;
} }
if(GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId()) if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId())
{ {
SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S); SendPartyResult(PARTY_OP_INVITE, membername, ERR_TARGET_NOT_IN_INSTANCE_S);
return; return;
} }
// just ignore us // just ignore us
if(player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) if (player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid()))
{ {
SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S); SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S);
return; return;
} }
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if( group && group->isBGGroup() ) if (group && group->isBGGroup())
group = GetPlayer()->GetOriginalGroup(); group = GetPlayer()->GetOriginalGroup();
if(group && group->isRaidGroup() && !player->GetAllowLowLevelRaid() && (player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_FOR_RAID))) if (group && group->isRaidGroup() && !player->GetAllowLowLevelRaid() && (player->getLevel() < sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_FOR_RAID)))
{ {
SendPartyResult(PARTY_OP_INVITE, "", ERR_RAID_DISALLOWED_BY_LEVEL); SendPartyResult(PARTY_OP_INVITE, "", ERR_RAID_DISALLOWED_BY_LEVEL);
return; return;
} }
Group *group2 = player->GetGroup(); Group* group2 = player->GetGroup();
if( group2 && group2->isBGGroup() ) if (group2 && group2->isBGGroup())
group2 = player->GetOriginalGroup(); group2 = player->GetOriginalGroup();
// player already in another group or invited // player already in another group or invited
if( group2 || player->GetGroupInvite() ) if (group2 || player->GetGroupInvite())
{ {
SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S); SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S);
return; return;
} }
if(group) if (group)
{ {
// not have permissions for invite // not have permissions for invite
if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && !group->IsAssistant(GetPlayer()->GetObjectGuid())) if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && !group->IsAssistant(GetPlayer()->GetObjectGuid()))
@ -124,7 +124,7 @@ void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data )
return; return;
} }
// not have place // not have place
if(group->IsFull()) if (group->IsFull())
{ {
SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
return; return;
@ -134,16 +134,16 @@ void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data )
// ok, but group not exist, start a new group // ok, but group not exist, start a new group
// but don't create and save the group to the DB until // but don't create and save the group to the DB until
// at least one person joins // at least one person joins
if(!group) if (!group)
{ {
group = new Group; group = new Group;
// new group: if can't add then delete // new group: if can't add then delete
if(!group->AddLeaderInvite(GetPlayer())) if (!group->AddLeaderInvite(GetPlayer()))
{ {
delete group; delete group;
return; return;
} }
if(!group->AddInvite(player)) if (!group->AddInvite(player))
{ {
delete group; delete group;
return; return;
@ -152,7 +152,7 @@ void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data )
else else
{ {
// already existing group: if can't add then just leave // already existing group: if can't add then just leave
if(!group->AddInvite(player)) if (!group->AddInvite(player))
{ {
return; return;
} }
@ -172,18 +172,18 @@ void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data )
SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK); SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK);
} }
void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data ) void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recv_data)
{ {
recv_data.read_skip<uint32>(); // roles mask? recv_data.read_skip<uint32>(); // roles mask?
Group *group = GetPlayer()->GetGroupInvite(); Group* group = GetPlayer()->GetGroupInvite();
if (!group) if (!group)
return; return;
if (group->GetLeaderGuid() == GetPlayer()->GetObjectGuid()) if (group->GetLeaderGuid() == GetPlayer()->GetObjectGuid())
{ {
sLog.outError("HandleGroupAcceptOpcode: %s tried to accept an invite to his own group", sLog.outError("HandleGroupAcceptOpcode: %s tried to accept an invite to his own group",
GetPlayer()->GetGuidStr().c_str()); GetPlayer()->GetGuidStr().c_str());
return; return;
} }
@ -194,7 +194,7 @@ void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data )
/********************/ /********************/
// not have place // not have place
if(group->IsFull()) if (group->IsFull())
{ {
SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL); SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
return; return;
@ -214,18 +214,18 @@ void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data )
} }
// everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! // everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
if(!group->AddMember(GetPlayer()->GetObjectGuid(), GetPlayer()->GetName())) if (!group->AddMember(GetPlayer()->GetObjectGuid(), GetPlayer()->GetName()))
return; return;
} }
void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGroupDeclineOpcode(WorldPacket& /*recv_data*/)
{ {
Group *group = GetPlayer()->GetGroupInvite(); Group* group = GetPlayer()->GetGroupInvite();
if (!group) if (!group)
return; return;
// remember leader if online // remember leader if online
Player *leader = sObjectMgr.GetPlayer(group->GetLeaderGuid()); Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid());
// uninvite, group can be deleted // uninvite, group can be deleted
GetPlayer()->UninviteFromGroup(); GetPlayer()->UninviteFromGroup();
@ -234,12 +234,12 @@ void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ )
return; return;
// report // report
WorldPacket data( SMSG_GROUP_DECLINE, 10 ); // guess size WorldPacket data(SMSG_GROUP_DECLINE, 10); // guess size
data << GetPlayer()->GetName(); data << GetPlayer()->GetName();
leader->GetSession()->SendPacket( &data ); leader->GetSession()->SendPacket(&data);
} }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
@ -260,7 +260,7 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data)
} }
Group* grp = GetPlayer()->GetGroup(); Group* grp = GetPlayer()->GetGroup();
if(!grp) if (!grp)
return; return;
if (grp->IsMember(guid)) if (grp->IsMember(guid))
@ -278,7 +278,7 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data)
SendPartyResult(PARTY_OP_LEAVE, "", ERR_TARGET_NOT_IN_GROUP_S); SendPartyResult(PARTY_OP_LEAVE, "", ERR_TARGET_NOT_IN_GROUP_S);
} }
void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recv_data)
{ {
std::string membername; std::string membername;
recv_data >> membername; recv_data >> membername;
@ -320,16 +320,16 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data)
SendPartyResult(PARTY_OP_LEAVE, membername, ERR_TARGET_NOT_IN_GROUP_S); SendPartyResult(PARTY_OP_LEAVE, membername, ERR_TARGET_NOT_IN_GROUP_S);
} }
void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data ) void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if (!group) if (!group)
return; return;
Player *player = sObjectMgr.GetPlayer(guid); Player* player = sObjectMgr.GetPlayer(guid);
/** error handling **/ /** error handling **/
if (!player || !group->IsLeader(GetPlayer()->GetObjectGuid()) || player->GetGroup() != group) if (!player || !group->IsLeader(GetPlayer()->GetObjectGuid()) || player->GetGroup() != group)
@ -340,12 +340,12 @@ void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data )
group->ChangeLeader(guid); group->ChangeLeader(guid);
} }
void WorldSession::HandleGroupDisbandOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGroupDisbandOpcode(WorldPacket& /*recv_data*/)
{ {
if(!GetPlayer()->GetGroup()) if (!GetPlayer()->GetGroup())
return; return;
if(_player->InBattleGround()) if (_player->InBattleGround())
{ {
SendPartyResult(PARTY_OP_INVITE, "", ERR_INVITE_RESTRICTED); SendPartyResult(PARTY_OP_INVITE, "", ERR_INVITE_RESTRICTED);
return; return;
@ -360,14 +360,14 @@ void WorldSession::HandleGroupDisbandOpcode( WorldPacket & /*recv_data*/ )
GetPlayer()->RemoveFromGroup(); GetPlayer()->RemoveFromGroup();
} }
void WorldSession::HandleLootMethodOpcode( WorldPacket & recv_data ) void WorldSession::HandleLootMethodOpcode(WorldPacket& recv_data)
{ {
uint32 lootMethod; uint32 lootMethod;
ObjectGuid lootMaster; ObjectGuid lootMaster;
uint32 lootThreshold; uint32 lootThreshold;
recv_data >> lootMethod >> lootMaster >> lootThreshold; recv_data >> lootMethod >> lootMaster >> lootThreshold;
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if (!group) if (!group)
return; return;
@ -383,7 +383,7 @@ void WorldSession::HandleLootMethodOpcode( WorldPacket & recv_data )
group->SendUpdate(); group->SendUpdate();
} }
void WorldSession::HandleLootRoll( WorldPacket &recv_data ) void WorldSession::HandleLootRoll(WorldPacket& recv_data)
{ {
ObjectGuid lootedTarget; ObjectGuid lootedTarget;
uint32 itemSlot; uint32 itemSlot;
@ -402,7 +402,7 @@ void WorldSession::HandleLootRoll( WorldPacket &recv_data )
return; return;
// everything is fine, do it, if false then some cheating problem found // everything is fine, do it, if false then some cheating problem found
if(!group->CountRollVote(GetPlayer(), lootedTarget, itemSlot, RollVote(rollType))) if (!group->CountRollVote(GetPlayer(), lootedTarget, itemSlot, RollVote(rollType)))
return; return;
switch (rollType) switch (rollType)
@ -423,7 +423,7 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data)
recv_data >> x; recv_data >> x;
recv_data >> y; recv_data >> y;
if(!GetPlayer()->GetGroup()) if (!GetPlayer()->GetGroup())
return; return;
//DEBUG_LOG("Received opcode MSG_MINIMAP_PING X: %f, Y: %f", x, y); //DEBUG_LOG("Received opcode MSG_MINIMAP_PING X: %f, Y: %f", x, y);
@ -446,7 +446,7 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data)
recv_data >> maximum; recv_data >> maximum;
/** error handling **/ /** error handling **/
if(minimum > maximum || maximum > 10000) // < 32768 for urand call if (minimum > maximum || maximum > 10000) // < 32768 for urand call
return; return;
/********************/ /********************/
@ -460,34 +460,34 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data)
data << uint32(maximum); data << uint32(maximum);
data << uint32(roll); data << uint32(roll);
data << GetPlayer()->GetObjectGuid(); data << GetPlayer()->GetObjectGuid();
if(GetPlayer()->GetGroup()) if (GetPlayer()->GetGroup())
GetPlayer()->GetGroup()->BroadcastPacket(&data, false); GetPlayer()->GetGroup()->BroadcastPacket(&data, false);
else else
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleRaidTargetUpdateOpcode( WorldPacket & recv_data ) void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recv_data)
{ {
uint8 x; uint8 x;
recv_data >> x; recv_data >> x;
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if(!group) if (!group)
return; return;
/** error handling **/ /** error handling **/
/********************/ /********************/
// everything is fine, do it // everything is fine, do it
if(x == 0xFF) // target icon request if (x == 0xFF) // target icon request
{ {
group->SendTargetIconList(this); group->SendTargetIconList(this);
} }
else // target icon update else // target icon update
{ {
if (group->isRaidGroup() && if (group->isRaidGroup() &&
!group->IsLeader(GetPlayer()->GetObjectGuid()) && !group->IsLeader(GetPlayer()->GetObjectGuid()) &&
!group->IsAssistant(GetPlayer()->GetObjectGuid())) !group->IsAssistant(GetPlayer()->GetObjectGuid()))
return; return;
ObjectGuid guid; ObjectGuid guid;
@ -496,13 +496,13 @@ void WorldSession::HandleRaidTargetUpdateOpcode( WorldPacket & recv_data )
} }
} }
void WorldSession::HandleGroupRaidConvertOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleGroupRaidConvertOpcode(WorldPacket& /*recv_data*/)
{ {
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if(!group) if (!group)
return; return;
if(_player->InBattleGround()) if (_player->InBattleGround())
return; return;
/** error handling **/ /** error handling **/
@ -515,7 +515,7 @@ void WorldSession::HandleGroupRaidConvertOpcode( WorldPacket & /*recv_data*/ )
group->ConvertToRaid(); group->ConvertToRaid();
} }
void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ) void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recv_data)
{ {
std::string name; std::string name;
uint8 groupNr; uint8 groupNr;
@ -527,13 +527,13 @@ void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data )
return; return;
// we will get correct pointer for group here, so we don't have to check if group is BG raid // we will get correct pointer for group here, so we don't have to check if group is BG raid
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if(!group) if (!group)
return; return;
/** error handling **/ /** error handling **/
if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && if (!group->IsLeader(GetPlayer()->GetObjectGuid()) &&
!group->IsAssistant(GetPlayer()->GetObjectGuid())) !group->IsAssistant(GetPlayer()->GetObjectGuid()))
return; return;
if (!group->HasFreeSlotSubGroup(groupNr)) if (!group->HasFreeSlotSubGroup(groupNr))
@ -550,14 +550,14 @@ void WorldSession::HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data )
} }
} }
void WorldSession::HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data ) void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
uint8 flag; uint8 flag;
recv_data >> guid; recv_data >> guid;
recv_data >> flag; recv_data >> flag;
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if (!group) if (!group)
return; return;
@ -570,7 +570,7 @@ void WorldSession::HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data )
group->SetAssistant(guid, (flag==0?false:true)); group->SetAssistant(guid, (flag==0?false:true));
} }
void WorldSession::HandlePartyAssignmentOpcode( WorldPacket & recv_data ) void WorldSession::HandlePartyAssignmentOpcode(WorldPacket& recv_data)
{ {
uint8 role; uint8 role;
uint8 apply; uint8 apply;
@ -580,7 +580,7 @@ void WorldSession::HandlePartyAssignmentOpcode( WorldPacket & recv_data )
DEBUG_LOG("MSG_PARTY_ASSIGNMENT"); DEBUG_LOG("MSG_PARTY_ASSIGNMENT");
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if (!group) if (!group)
return; return;
@ -592,7 +592,7 @@ void WorldSession::HandlePartyAssignmentOpcode( WorldPacket & recv_data )
// everything is fine, do it // everything is fine, do it
if (apply) if (apply)
{ {
switch(role) switch (role)
{ {
case 0: group->SetMainTank(guid); break; case 0: group->SetMainTank(guid); break;
case 1: group->SetMainAssistant(guid); break; case 1: group->SetMainAssistant(guid); break;
@ -608,17 +608,17 @@ void WorldSession::HandlePartyAssignmentOpcode( WorldPacket & recv_data )
} }
} }
void WorldSession::HandleRaidReadyCheckOpcode( WorldPacket & recv_data ) void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recv_data)
{ {
if(recv_data.empty()) // request if (recv_data.empty()) // request
{ {
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if(!group) if (!group)
return; return;
/** error handling **/ /** error handling **/
if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && if (!group->IsLeader(GetPlayer()->GetObjectGuid()) &&
!group->IsAssistant(GetPlayer()->GetObjectGuid())) !group->IsAssistant(GetPlayer()->GetObjectGuid()))
return; return;
/********************/ /********************/
@ -634,8 +634,8 @@ void WorldSession::HandleRaidReadyCheckOpcode( WorldPacket & recv_data )
uint8 state; uint8 state;
recv_data >> state; recv_data >> state;
Group *group = GetPlayer()->GetGroup(); Group* group = GetPlayer()->GetGroup();
if(!group) if (!group)
return; return;
// everything is fine, do it // everything is fine, do it
@ -646,7 +646,7 @@ void WorldSession::HandleRaidReadyCheckOpcode( WorldPacket & recv_data )
} }
} }
void WorldSession::HandleRaidReadyCheckFinishedOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleRaidReadyCheckFinishedOpcode(WorldPacket& /*recv_data*/)
{ {
//Group* group = GetPlayer()->GetGroup(); //Group* group = GetPlayer()->GetGroup();
//if(!group) //if(!group)
@ -658,7 +658,7 @@ void WorldSession::HandleRaidReadyCheckFinishedOpcode( WorldPacket & /*recv_data
// Is any reaction need? // Is any reaction need?
} }
void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data) void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacket* data)
{ {
uint32 mask = player->GetGroupUpdateFlag(); uint32 mask = player->GetGroupUpdateFlag();
@ -714,9 +714,9 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
{ {
const uint64& auramask = player->GetAuraUpdateMask(); const uint64& auramask = player->GetAuraUpdateMask();
*data << uint64(auramask); *data << uint64(auramask);
for(uint32 i = 0; i < MAX_AURAS; ++i) for (uint32 i = 0; i < MAX_AURAS; ++i)
{ {
if(auramask & (uint64(1) << i)) if (auramask & (uint64(1) << i))
{ {
*data << uint32(player->GetVisibleAura(i)); *data << uint32(player->GetVisibleAura(i));
*data << uint8(1); *data << uint8(1);
@ -724,13 +724,13 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
} }
} }
Pet *pet = player->GetPet(); Pet* pet = player->GetPet();
if (mask & GROUP_UPDATE_FLAG_PET_GUID) if (mask & GROUP_UPDATE_FLAG_PET_GUID)
*data << (pet ? pet->GetObjectGuid() : ObjectGuid()); *data << (pet ? pet->GetObjectGuid() : ObjectGuid());
if (mask & GROUP_UPDATE_FLAG_PET_NAME) if (mask & GROUP_UPDATE_FLAG_PET_NAME)
{ {
if(pet) if (pet)
*data << pet->GetName(); *data << pet->GetName();
else else
*data << uint8(0); *data << uint8(0);
@ -738,7 +738,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID) if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID)
{ {
if(pet) if (pet)
*data << uint16(pet->GetDisplayId()); *data << uint16(pet->GetDisplayId());
else else
*data << uint16(0); *data << uint16(0);
@ -746,7 +746,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP) if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP)
{ {
if(pet) if (pet)
*data << uint32(pet->GetHealth()); *data << uint32(pet->GetHealth());
else else
*data << uint32(0); *data << uint32(0);
@ -754,7 +754,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP) if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP)
{ {
if(pet) if (pet)
*data << uint32(pet->GetMaxHealth()); *data << uint32(pet->GetMaxHealth());
else else
*data << uint32(0); *data << uint32(0);
@ -762,7 +762,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE) if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE)
{ {
if(pet) if (pet)
*data << uint8(pet->getPowerType()); *data << uint8(pet->getPowerType());
else else
*data << uint8(0); *data << uint8(0);
@ -770,7 +770,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_CUR_POWER) if (mask & GROUP_UPDATE_FLAG_PET_CUR_POWER)
{ {
if(pet) if (pet)
*data << uint16(pet->GetPower(pet->getPowerType())); *data << uint16(pet->GetPower(pet->getPowerType()));
else else
*data << uint16(0); *data << uint16(0);
@ -778,7 +778,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_MAX_POWER) if (mask & GROUP_UPDATE_FLAG_PET_MAX_POWER)
{ {
if(pet) if (pet)
*data << uint16(pet->GetMaxPower(pet->getPowerType())); *data << uint16(pet->GetMaxPower(pet->getPowerType()));
else else
*data << uint16(0); *data << uint16(0);
@ -786,13 +786,13 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_AURAS) if (mask & GROUP_UPDATE_FLAG_PET_AURAS)
{ {
if(pet) if (pet)
{ {
const uint64& auramask = pet->GetAuraUpdateMask(); const uint64& auramask = pet->GetAuraUpdateMask();
*data << uint64(auramask); *data << uint64(auramask);
for(uint32 i = 0; i < MAX_AURAS; ++i) for (uint32 i = 0; i < MAX_AURAS; ++i)
{ {
if(auramask & (uint64(1) << i)) if (auramask & (uint64(1) << i))
{ {
*data << uint32(pet->GetVisibleAura(i)); *data << uint32(pet->GetVisibleAura(i));
*data << uint8(1); *data << uint8(1);
@ -805,7 +805,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
} }
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/ /*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data ) void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS"); DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
ObjectGuid guid; ObjectGuid guid;
@ -823,14 +823,14 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
return; return;
} }
Pet *pet = player->GetPet(); Pet* pet = player->GetPet();
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8); WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data << player->GetPackGUID(); data << player->GetPackGUID();
uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
if(pet) if (pet)
mask1 = 0x7FFFFFFF; // for hunters and other classes with pets mask1 = 0x7FFFFFFF; // for hunters and other classes with pets
Powers powerType = player->getPowerType(); Powers powerType = player->getPowerType();
@ -873,9 +873,9 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
uint64 auramask = 0; uint64 auramask = 0;
size_t maskPos = data.wpos(); size_t maskPos = data.wpos();
data << uint64(auramask); // placeholder data << uint64(auramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i) for (uint8 i = 0; i < MAX_AURAS; ++i)
{ {
if(uint32 aura = player->GetVisibleAura(i)) if (uint32 aura = player->GetVisibleAura(i))
{ {
auramask |= (uint64(1) << i); auramask |= (uint64(1) << i);
data << uint32(aura); data << uint32(aura);
@ -884,7 +884,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
} }
data.put<uint64>(maskPos, auramask); // GROUP_UPDATE_FLAG_AURAS data.put<uint64>(maskPos, auramask); // GROUP_UPDATE_FLAG_AURAS
if(pet) if (pet)
{ {
Powers petpowertype = pet->getPowerType(); Powers petpowertype = pet->getPowerType();
data << pet->GetObjectGuid(); // GROUP_UPDATE_FLAG_PET_GUID data << pet->GetObjectGuid(); // GROUP_UPDATE_FLAG_PET_GUID
@ -899,9 +899,9 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
uint64 petauramask = 0; uint64 petauramask = 0;
size_t petMaskPos = data.wpos(); size_t petMaskPos = data.wpos();
data << uint64(petauramask); // placeholder data << uint64(petauramask); // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i) for (uint8 i = 0; i < MAX_AURAS; ++i)
{ {
if(uint32 petaura = pet->GetVisibleAura(i)) if (uint32 petaura = pet->GetVisibleAura(i))
{ {
petauramask |= (uint64(1) << i); petauramask |= (uint64(1) << i);
data << uint32(petaura); data << uint32(petaura);
@ -919,13 +919,13 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleRequestRaidInfoOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleRequestRaidInfoOpcode(WorldPacket& /*recv_data*/)
{ {
// every time the player checks the character screen // every time the player checks the character screen
_player->SendRaidInfo(); _player->SendRaidInfo();
} }
void WorldSession::HandleOptOutOfLootOpcode( WorldPacket & recv_data ) void WorldSession::HandleOptOutOfLootOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received CMSG_OPT_OUT_OF_LOOT"); DEBUG_LOG("WORLD: Received CMSG_OPT_OUT_OF_LOOT");
@ -933,18 +933,18 @@ void WorldSession::HandleOptOutOfLootOpcode( WorldPacket & recv_data )
recv_data >> unkn; recv_data >> unkn;
// ignore if player not loaded // ignore if player not loaded
if(!GetPlayer()) // needed because STATUS_AUTHED if (!GetPlayer()) // needed because STATUS_AUTHED
{ {
if(unkn != 0) if (unkn != 0)
sLog.outError("CMSG_GROUP_PASS_ON_LOOT value<>0 for not-loaded character!"); sLog.outError("CMSG_GROUP_PASS_ON_LOOT value<>0 for not-loaded character!");
return; return;
} }
if(unkn != 0) if (unkn != 0)
sLog.outError("CMSG_GROUP_PASS_ON_LOOT: activation not implemented!"); sLog.outError("CMSG_GROUP_PASS_ON_LOOT: activation not implemented!");
} }
void WorldSession::HandleSetAllowLowLevelRaidOpcode( WorldPacket & recv_data ) void WorldSession::HandleSetAllowLowLevelRaidOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received CMSG_SET_ALLOW_LOW_LEVEL_RAID: %4X", recv_data.GetOpcode()); DEBUG_LOG("WORLD: Received CMSG_SET_ALLOW_LOW_LEVEL_RAID: %4X", recv_data.GetOpcode());

View file

@ -28,6 +28,6 @@ class GroupReference;
class GroupRefManager : public RefManager<Group, Player> class GroupRefManager : public RefManager<Group, Player>
{ {
public: public:
GroupReference* getFirst() { return ((GroupReference* ) RefManager<Group, Player>::getFirst()); } GroupReference* getFirst() { return ((GroupReference*) RefManager<Group, Player>::getFirst()); }
}; };
#endif #endif

View file

@ -34,7 +34,7 @@ class MANGOS_DLL_SPEC GroupReference : public Reference<Group, Player>
public: public:
GroupReference() : Reference<Group, Player>(), iSubGroup(0) {} GroupReference() : Reference<Group, Player>(), iSubGroup(0) {}
~GroupReference() { unlink(); } ~GroupReference() { unlink(); }
GroupReference *next() { return (GroupReference*)Reference<Group, Player>::next(); } GroupReference* next() { return (GroupReference*)Reference<Group, Player>::next(); }
uint8 getSubGroup() const { return iSubGroup; } uint8 getSubGroup() const { return iSubGroup; }
void setSubGroup(uint8 pSubGroup) { iSubGroup = pSubGroup; } void setSubGroup(uint8 pSubGroup) { iSubGroup = pSubGroup; }
}; };

View file

@ -22,7 +22,7 @@
#include "Player.h" #include "Player.h"
#include "World.h" #include "World.h"
int GuardAI::Permissible(const Creature *creature) int GuardAI::Permissible(const Creature* creature)
{ {
if (creature->IsGuard()) if (creature->IsGuard())
return PERMIT_BASE_SPECIAL; return PERMIT_BASE_SPECIAL;
@ -30,19 +30,19 @@ int GuardAI::Permissible(const Creature *creature)
return PERMIT_BASE_NO; return PERMIT_BASE_NO;
} }
GuardAI::GuardAI(Creature *c) : CreatureAI(c), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) GuardAI::GuardAI(Creature* c) : CreatureAI(c), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK)
{ {
} }
void GuardAI::MoveInLineOfSight(Unit *u) void GuardAI::MoveInLineOfSight(Unit* u)
{ {
// Ignore Z for flying creatures // Ignore Z for flying creatures
if (!m_creature->CanFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE) if (!m_creature->CanFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE)
return; return;
if (!m_creature->getVictim() && u->isTargetableForAttack() && if (!m_creature->getVictim() && u->isTargetableForAttack() &&
( u->IsHostileToPlayers() || m_creature->IsHostileTo(u) /*|| u->getVictim() && m_creature->IsFriendlyTo(u->getVictim())*/ ) && (u->IsHostileToPlayers() || m_creature->IsHostileTo(u) /*|| u->getVictim() && m_creature->IsFriendlyTo(u->getVictim())*/) &&
u->isInAccessablePlaceFor(m_creature)) u->isInAccessablePlaceFor(m_creature))
{ {
float attackRadius = m_creature->GetAttackDistance(u); float attackRadius = m_creature->GetAttackDistance(u);
if (m_creature->IsWithinDistInMap(u,attackRadius)) if (m_creature->IsWithinDistInMap(u,attackRadius))
@ -115,18 +115,18 @@ void GuardAI::UpdateAI(const uint32 /*diff*/)
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
bool GuardAI::IsVisible(Unit *pl) const bool GuardAI::IsVisible(Unit* pl) const
{ {
return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_GUARDER)) return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_GUARDER))
&& pl->isVisibleForOrDetect(m_creature,m_creature,true); && pl->isVisibleForOrDetect(m_creature,m_creature,true);
} }
void GuardAI::AttackStart(Unit *u) void GuardAI::AttackStart(Unit* u)
{ {
if( !u ) if (!u)
return; return;
if(m_creature->Attack(u,true)) if (m_creature->Attack(u,true))
{ {
i_victimGuid = u->GetObjectGuid(); i_victimGuid = u->GetObjectGuid();
m_creature->AddThreat(u); m_creature->AddThreat(u);
@ -137,8 +137,8 @@ void GuardAI::AttackStart(Unit *u)
} }
} }
void GuardAI::JustDied(Unit *killer) void GuardAI::JustDied(Unit* killer)
{ {
if(Player* pkiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) if (Player* pkiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
m_creature->SendZoneUnderAttackMessage(pkiller); m_creature->SendZoneUnderAttackMessage(pkiller);
} }

View file

@ -27,24 +27,24 @@ class Creature;
class MANGOS_DLL_DECL GuardAI : public CreatureAI class MANGOS_DLL_DECL GuardAI : public CreatureAI
{ {
enum GuardState enum GuardState
{ {
STATE_NORMAL = 1, STATE_NORMAL = 1,
STATE_LOOK_AT_VICTIM = 2 STATE_LOOK_AT_VICTIM = 2
}; };
public: public:
explicit GuardAI(Creature *c); explicit GuardAI(Creature* c);
void MoveInLineOfSight(Unit *); void MoveInLineOfSight(Unit*);
void AttackStart(Unit *); void AttackStart(Unit*);
void EnterEvadeMode(); void EnterEvadeMode();
void JustDied(Unit *); void JustDied(Unit*);
bool IsVisible(Unit *) const; bool IsVisible(Unit*) const;
void UpdateAI(const uint32); void UpdateAI(const uint32);
static int Permissible(const Creature *); static int Permissible(const Creature*);
private: private:
ObjectGuid i_victimGuid; ObjectGuid i_victimGuid;

File diff suppressed because it is too large Load diff

View file

@ -191,7 +191,7 @@ enum GuildEmblem
inline uint32 GetGuildBankTabPrice(uint8 Index) inline uint32 GetGuildBankTabPrice(uint8 Index)
{ {
switch(Index) switch (Index)
{ {
case 0: return 100; case 0: return 100;
case 1: return 250; case 1: return 250;
@ -225,8 +225,8 @@ struct GuildBankEventLogEntry
bool isMoneyEvent() const bool isMoneyEvent() const
{ {
return EventType == GUILD_BANK_LOG_DEPOSIT_MONEY || return EventType == GUILD_BANK_LOG_DEPOSIT_MONEY ||
EventType == GUILD_BANK_LOG_WITHDRAW_MONEY || EventType == GUILD_BANK_LOG_WITHDRAW_MONEY ||
EventType == GUILD_BANK_LOG_REPAIR_MONEY; EventType == GUILD_BANK_LOG_REPAIR_MONEY;
} }
}; };
@ -279,7 +279,7 @@ struct RankInfo
{ {
RankInfo(const std::string& _name, uint32 _rights, uint32 _money) : Name(_name), Rights(_rights), BankMoneyPerDay(_money) RankInfo(const std::string& _name, uint32 _rights, uint32 _money) : Name(_name), Rights(_rights), BankMoneyPerDay(_money)
{ {
for(uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i) for (uint8 i = 0; i < GUILD_BANK_MAX_TABS; ++i)
{ {
TabRight[i] = 0; TabRight[i] = 0;
TabSlotPerDay[i] = 0; TabSlotPerDay[i] = 0;
@ -307,7 +307,7 @@ class Guild
typedef UNORDERED_MAP<uint32, MemberSlot> MemberList; typedef UNORDERED_MAP<uint32, MemberSlot> MemberList;
typedef std::vector<RankInfo> RankList; typedef std::vector<RankInfo> RankList;
uint32 GetId(){ return m_Id; } uint32 GetId() { return m_Id; }
ObjectGuid GetLeaderGuid() const { return m_LeaderGuid; } ObjectGuid GetLeaderGuid() const { return m_LeaderGuid; }
std::string const& GetName() const { return m_Name; } std::string const& GetName() const { return m_Name; }
std::string const& GetMOTD() const { return MOTD; } std::string const& GetMOTD() const { return MOTD; }
@ -334,15 +334,15 @@ class Guild
uint32 GetMemberSize() const { return members.size(); } uint32 GetMemberSize() const { return members.size(); }
uint32 GetAccountsNumber(); uint32 GetAccountsNumber();
bool LoadGuildFromDB(QueryResult *guildDataResult); bool LoadGuildFromDB(QueryResult* guildDataResult);
bool CheckGuildStructure(); bool CheckGuildStructure();
bool LoadRanksFromDB(QueryResult *guildRanksResult); bool LoadRanksFromDB(QueryResult* guildRanksResult);
bool LoadMembersFromDB(QueryResult *guildMembersResult); bool LoadMembersFromDB(QueryResult* guildMembersResult);
void BroadcastToGuild(WorldSession *session, const std::string& msg, uint32 language = LANG_UNIVERSAL); void BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language = LANG_UNIVERSAL);
void BroadcastToOfficers(WorldSession *session, const std::string& msg, uint32 language = LANG_UNIVERSAL); void BroadcastToOfficers(WorldSession* session, const std::string& msg, uint32 language = LANG_UNIVERSAL);
void BroadcastPacketToRank(WorldPacket *packet, uint32 rankId); void BroadcastPacketToRank(WorldPacket* packet, uint32 rankId);
void BroadcastPacket(WorldPacket *packet); void BroadcastPacket(WorldPacket* packet);
void BroadcastEvent(GuildEvents event, ObjectGuid guid, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL); void BroadcastEvent(GuildEvents event, ObjectGuid guid, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL);
void BroadcastEvent(GuildEvents event, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL) void BroadcastEvent(GuildEvents event, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL)
@ -353,9 +353,9 @@ class Guild
template<class Do> template<class Do>
void BroadcastWorker(Do& _do, Player* except = NULL) void BroadcastWorker(Do& _do, Player* except = NULL)
{ {
for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
if(Player *player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first))) if (Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)))
if(player != except) if (player != except)
_do(player); _do(player);
} }
@ -386,35 +386,35 @@ class Guild
MemberSlot* GetMemberSlot(const std::string& name) MemberSlot* GetMemberSlot(const std::string& name)
{ {
for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
if(itr->second.Name == name) if (itr->second.Name == name)
return &itr->second; return &itr->second;
return NULL; return NULL;
} }
void Roster(WorldSession *session = NULL); // NULL = broadcast void Roster(WorldSession* session = NULL); // NULL = broadcast
void Query(WorldSession *session); void Query(WorldSession* session);
// Guild EventLog // Guild EventLog
void LoadGuildEventLogFromDB(); void LoadGuildEventLogFromDB();
void DisplayGuildEventLog(WorldSession *session); void DisplayGuildEventLog(WorldSession* session);
void LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2 = ObjectGuid(), uint8 newRank = 0); void LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid playerGuid2 = ObjectGuid(), uint8 newRank = 0);
// ** Guild bank ** // ** Guild bank **
// Content & item deposit/withdraw // Content & item deposit/withdraw
void DisplayGuildBankContent(WorldSession *session, uint8 TabId); void DisplayGuildBankContent(WorldSession* session, uint8 TabId);
void DisplayGuildBankMoneyUpdate(WorldSession *session); void DisplayGuildBankMoneyUpdate(WorldSession* session);
void SwapItems( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount); void SwapItems(Player* pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTabDst, uint8 BankTabSlotDst, uint32 SplitedAmount);
void MoveFromBankToChar( Player * pl, uint8 BankTab, uint8 BankTabSlot, uint8 PlayerBag, uint8 PlayerSlot, uint32 SplitedAmount); void MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uint8 PlayerBag, uint8 PlayerSlot, uint32 SplitedAmount);
void MoveFromCharToBank( Player * pl, uint8 PlayerBag, uint8 PlayerSlot, uint8 BankTab, uint8 BankTabSlot, uint32 SplitedAmount); void MoveFromCharToBank(Player* pl, uint8 PlayerBag, uint8 PlayerSlot, uint8 BankTab, uint8 BankTabSlot, uint32 SplitedAmount);
// Tabs // Tabs
void DisplayGuildBankTabsInfo(WorldSession *session); void DisplayGuildBankTabsInfo(WorldSession* session);
void CreateNewBankTab(); void CreateNewBankTab();
void SetGuildBankTabText(uint8 TabId, std::string text); void SetGuildBankTabText(uint8 TabId, std::string text);
void SendGuildBankTabText(WorldSession *session, uint8 TabId); void SendGuildBankTabText(WorldSession* session, uint8 TabId);
void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon); void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon);
uint8 GetPurchasedTabs() const { return m_TabListMap.size(); } uint8 GetPurchasedTabs() const { return m_TabListMap.size(); }
uint32 GetBankRights(uint32 rankId, uint8 TabId) const; uint32 GetBankRights(uint32 rankId, uint8 TabId) const;
@ -423,7 +423,7 @@ class Guild
// Load // Load
void LoadGuildBankFromDB(); void LoadGuildBankFromDB();
// Money deposit/withdraw // Money deposit/withdraw
void SendMoneyInfo(WorldSession *session, uint32 LowGuid); void SendMoneyInfo(WorldSession* session, uint32 LowGuid);
bool MemberMoneyWithdraw(uint32 amount, uint32 LowGuid); bool MemberMoneyWithdraw(uint32 amount, uint32 LowGuid);
uint64 GetGuildBankMoney() { return m_GuildBankMoney; } uint64 GetGuildBankMoney() { return m_GuildBankMoney; }
void SetBankMoney(int64 money); void SetBankMoney(int64 money);
@ -436,12 +436,12 @@ class Guild
uint32 GetBankMoneyPerDay(uint32 rankId); uint32 GetBankMoneyPerDay(uint32 rankId);
uint32 GetBankSlotPerDay(uint32 rankId, uint8 TabId); uint32 GetBankSlotPerDay(uint32 rankId, uint8 TabId);
// rights per day // rights per day
bool LoadBankRightsFromDB(QueryResult *guildBankTabRightsResult); bool LoadBankRightsFromDB(QueryResult* guildBankTabRightsResult);
// Guild Bank Event Logs // Guild Bank Event Logs
void LoadGuildBankEventLogFromDB(); void LoadGuildBankEventLogFromDB();
void DisplayGuildBankLogs(WorldSession *session, uint8 TabId); void DisplayGuildBankLogs(WorldSession* session, uint8 TabId);
void LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0); void LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0);
bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry ); bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry);
protected: protected:
void AddRank(const std::string& name,uint32 rights,uint32 money); void AddRank(const std::string& name,uint32 rights,uint32 money);
@ -486,16 +486,16 @@ class Guild
// used only from high level Swap/Move functions // used only from high level Swap/Move functions
Item* GetItem(uint8 TabId, uint8 SlotId); Item* GetItem(uint8 TabId, uint8 SlotId);
InventoryResult CanStoreItem( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item *pItem, bool swap = false) const; InventoryResult CanStoreItem(uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32 count, Item* pItem, bool swap = false) const;
Item* StoreItem( uint8 tab, GuildItemPosCountVec const& pos, Item *pItem ); Item* StoreItem(uint8 tab, GuildItemPosCountVec const& pos, Item* pItem);
void RemoveItem(uint8 tab, uint8 slot ); void RemoveItem(uint8 tab, uint8 slot);
void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2 = -1); void DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2 = -1);
void DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots); void DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec const& slots);
// internal common parts for CanStore/StoreItem functions // internal common parts for CanStore/StoreItem functions
void AppendDisplayGuildBankSlot( WorldPacket& data, GuildBankTab const *tab, int32 slot ); void AppendDisplayGuildBankSlot(WorldPacket& data, GuildBankTab const* tab, int32 slot);
InventoryResult _CanStoreItem_InSpecificSlot( uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item *pSrcItem ) const; InventoryResult _CanStoreItem_InSpecificSlot(uint8 tab, uint8 slot, GuildItemPosCountVec& dest, uint32& count, bool swap, Item* pSrcItem) const;
InventoryResult _CanStoreItem_InTab( uint8 tab, GuildItemPosCountVec& dest, uint32& count, bool merge, Item *pSrcItem, uint8 skip_slot ) const; InventoryResult _CanStoreItem_InTab(uint8 tab, GuildItemPosCountVec& dest, uint32& count, bool merge, Item* pSrcItem, uint8 skip_slot) const;
Item* _StoreItem( uint8 tab, uint8 slot, Item *pItem, uint32 count, bool clone ); Item* _StoreItem(uint8 tab, uint8 slot, Item* pItem, uint32 count, bool clone);
}; };
#endif #endif

View file

@ -51,11 +51,11 @@ void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket)
std::string gname; std::string gname;
recvPacket >> gname; recvPacket >> gname;
if(GetPlayer()->GetGuildId()) // already in guild if (GetPlayer()->GetGuildId()) // already in guild
return; return;
Guild *guild = new Guild; Guild* guild = new Guild;
if(!guild->Create(GetPlayer(), gname)) if (!guild->Create(GetPlayer(), gname))
{ {
delete guild; delete guild;
return; return;
@ -69,28 +69,28 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket)
DEBUG_LOG("WORLD: Received CMSG_GUILD_INVITE"); DEBUG_LOG("WORLD: Received CMSG_GUILD_INVITE");
std::string Invitedname, plname; std::string Invitedname, plname;
Player * player = NULL; Player* player = NULL;
recvPacket >> Invitedname; recvPacket >> Invitedname;
if(normalizePlayerName(Invitedname)) if (normalizePlayerName(Invitedname))
player = ObjectAccessor::FindPlayerByName(Invitedname.c_str()); player = ObjectAccessor::FindPlayerByName(Invitedname.c_str());
if(!player) if (!player)
{ {
SendGuildCommandResult(GUILD_INVITE_S, Invitedname, ERR_GUILD_PLAYER_NOT_FOUND_S); SendGuildCommandResult(GUILD_INVITE_S, Invitedname, ERR_GUILD_PLAYER_NOT_FOUND_S);
return; return;
} }
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
if(!guild) if (!guild)
{ {
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD); SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD);
return; return;
} }
// OK result but not send invite // OK result but not send invite
if(player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) if (player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid()))
return; return;
// not let enemies sign guild charter // not let enemies sign guild charter
@ -100,21 +100,21 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket)
return; return;
} }
if(player->GetGuildId()) if (player->GetGuildId())
{ {
plname = player->GetName(); plname = player->GetName();
SendGuildCommandResult(GUILD_INVITE_S, plname, ERR_ALREADY_IN_GUILD_S); SendGuildCommandResult(GUILD_INVITE_S, plname, ERR_ALREADY_IN_GUILD_S);
return; return;
} }
if(player->GetGuildIdInvited()) if (player->GetGuildIdInvited())
{ {
plname = player->GetName(); plname = player->GetName();
SendGuildCommandResult(GUILD_INVITE_S, plname, ERR_ALREADY_INVITED_TO_GUILD_S); SendGuildCommandResult(GUILD_INVITE_S, plname, ERR_ALREADY_INVITED_TO_GUILD_S);
return; return;
} }
if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_INVITE)) if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_INVITE))
{ {
SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_PERMISSIONS); SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_PERMISSIONS);
return; return;
@ -193,8 +193,8 @@ void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket)
void WorldSession::HandleGuildAcceptOpcode(WorldPacket& /*recvPacket*/) void WorldSession::HandleGuildAcceptOpcode(WorldPacket& /*recvPacket*/)
{ {
Guild *guild; Guild* guild;
Player *player = GetPlayer(); Player* player = GetPlayer();
DEBUG_LOG("WORLD: Received CMSG_GUILD_ACCEPT"); DEBUG_LOG("WORLD: Received CMSG_GUILD_ACCEPT");
@ -227,7 +227,7 @@ void WorldSession::HandleGuildInfoOpcode(WorldPacket& /*recvPacket*/)
DEBUG_LOG("WORLD: Received CMSG_GUILD_INFO"); DEBUG_LOG("WORLD: Received CMSG_GUILD_INFO");
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
if(!guild) if (!guild)
{ {
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD); SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD);
return; return;
@ -256,7 +256,7 @@ void WorldSession::HandleGuildPromoteOpcode(WorldPacket& recvPacket)
std::string plName; std::string plName;
recvPacket >> plName; recvPacket >> plName;
if(!normalizePlayerName(plName)) if (!normalizePlayerName(plName))
return; return;
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
@ -309,18 +309,18 @@ void WorldSession::HandleGuildDemoteOpcode(WorldPacket& recvPacket)
std::string plName; std::string plName;
recvPacket >> plName; recvPacket >> plName;
if(!normalizePlayerName(plName)) if (!normalizePlayerName(plName))
return; return;
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
if(!guild) if (!guild)
{ {
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD); SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD);
return; return;
} }
if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_DEMOTE)) if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_DEMOTE))
{ {
SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_PERMISSIONS); SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_PERMISSIONS);
return; return;
@ -432,9 +432,9 @@ void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket)
std::string name; std::string name;
recvPacket >> name; recvPacket >> name;
Player *oldLeader = GetPlayer(); Player* oldLeader = GetPlayer();
if(!normalizePlayerName(name)) if (!normalizePlayerName(name))
return; return;
Guild* guild = sGuildMgr.GetGuildById(oldLeader->GetGuildId()); Guild* guild = sGuildMgr.GetGuildById(oldLeader->GetGuildId());
@ -506,7 +506,7 @@ void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket)
std::string name,PNOTE; std::string name,PNOTE;
recvPacket >> name; recvPacket >> name;
if(!normalizePlayerName(name)) if (!normalizePlayerName(name))
return; return;
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
@ -697,13 +697,13 @@ void WorldSession::HandleGuildChangeInfoTextOpcode(WorldPacket& recvPacket)
recvPacket >> GINFO; recvPacket >> GINFO;
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()); Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
if(!guild) if (!guild)
{ {
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD); SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD);
return; return;
} }
if(!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_MODIFY_GUILD_INFO)) if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_MODIFY_GUILD_INFO))
{ {
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PERMISSIONS); SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PERMISSIONS);
return; return;
@ -722,7 +722,7 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket)
recvPacket >> vendorGuid; recvPacket >> vendorGuid;
recvPacket >> EmblemStyle >> EmblemColor >> BorderStyle >> BorderColor >> BackgroundColor; recvPacket >> EmblemStyle >> EmblemColor >> BorderStyle >> BorderColor >> BackgroundColor;
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_TABARDDESIGNER); Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_TABARDDESIGNER);
if (!pCreature) if (!pCreature)
{ {
//"That's not an emblem vendor!" //"That's not an emblem vendor!"
@ -768,30 +768,30 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket)
void WorldSession::HandleGuildEventLogQueryOpcode(WorldPacket& /* recvPacket */) void WorldSession::HandleGuildEventLogQueryOpcode(WorldPacket& /* recvPacket */)
{ {
// empty // empty
DEBUG_LOG("WORLD: Received (MSG_GUILD_EVENT_LOG_QUERY)"); DEBUG_LOG("WORLD: Received (MSG_GUILD_EVENT_LOG_QUERY)");
if(uint32 GuildId = GetPlayer()->GetGuildId()) if (uint32 GuildId = GetPlayer()->GetGuildId())
if (Guild* pGuild = sGuildMgr.GetGuildById(GuildId)) if (Guild* pGuild = sGuildMgr.GetGuildById(GuildId))
pGuild->DisplayGuildEventLog(this); pGuild->DisplayGuildEventLog(this);
} }
/****** GUILD BANK *******/ /****** GUILD BANK *******/
void WorldSession::HandleGuildBankMoneyWithdrawn( WorldPacket & /* recv_data */ ) void WorldSession::HandleGuildBankMoneyWithdrawn(WorldPacket& /* recv_data */)
{ {
DEBUG_LOG("WORLD: Received (MSG_GUILD_BANK_MONEY_WITHDRAWN)"); DEBUG_LOG("WORLD: Received (MSG_GUILD_BANK_MONEY_WITHDRAWN)");
if(uint32 GuildId = GetPlayer()->GetGuildId()) if (uint32 GuildId = GetPlayer()->GetGuildId())
if (Guild* pGuild = sGuildMgr.GetGuildById(GuildId)) if (Guild* pGuild = sGuildMgr.GetGuildById(GuildId))
pGuild->SendMoneyInfo(this, GetPlayer()->GetGUIDLow()); pGuild->SendMoneyInfo(this, GetPlayer()->GetGUIDLow());
} }
void WorldSession::HandleGuildPermissions( WorldPacket& /* recv_data */ ) void WorldSession::HandleGuildPermissions(WorldPacket& /* recv_data */)
{ {
DEBUG_LOG("WORLD: Received (MSG_GUILD_PERMISSIONS)"); DEBUG_LOG("WORLD: Received (MSG_GUILD_PERMISSIONS)");
if(uint32 GuildId = GetPlayer()->GetGuildId()) if (uint32 GuildId = GetPlayer()->GetGuildId())
{ {
if (Guild* pGuild = sGuildMgr.GetGuildById(GuildId)) if (Guild* pGuild = sGuildMgr.GetGuildById(GuildId))
{ {
@ -804,7 +804,7 @@ void WorldSession::HandleGuildPermissions( WorldPacket& /* recv_data */ )
data << uint32(pGuild->GetMemberMoneyWithdrawRem(GetPlayer()->GetGUIDLow())); data << uint32(pGuild->GetMemberMoneyWithdrawRem(GetPlayer()->GetGUIDLow()));
data << uint8(pGuild->GetPurchasedTabs()); // tabs count data << uint8(pGuild->GetPurchasedTabs()); // tabs count
// why sending all info when not all tabs are purchased??? // why sending all info when not all tabs are purchased???
for(int i = 0; i < GUILD_BANK_MAX_TABS; ++i) for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i)
{ {
data << uint32(pGuild->GetBankRights(rankId, uint8(i))); data << uint32(pGuild->GetBankRights(rankId, uint8(i)));
data << uint32(pGuild->GetMemberSlotWithdrawRem(GetPlayer()->GetGUIDLow(), uint8(i))); data << uint32(pGuild->GetMemberSlotWithdrawRem(GetPlayer()->GetGUIDLow(), uint8(i)));
@ -816,7 +816,7 @@ void WorldSession::HandleGuildPermissions( WorldPacket& /* recv_data */ )
} }
/* Called when clicking on Guild bank gameobject */ /* Called when clicking on Guild bank gameobject */
void WorldSession::HandleGuildBankerActivate( WorldPacket & recv_data ) void WorldSession::HandleGuildBankerActivate(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANKER_ACTIVATE)"); DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANKER_ACTIVATE)");
@ -840,7 +840,7 @@ void WorldSession::HandleGuildBankerActivate( WorldPacket & recv_data )
} }
/* Called when opening guild bank tab only (first one) */ /* Called when opening guild bank tab only (first one) */
void WorldSession::HandleGuildBankQueryTab( WorldPacket & recv_data ) void WorldSession::HandleGuildBankQueryTab(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_QUERY_TAB)"); DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_QUERY_TAB)");
@ -868,7 +868,7 @@ void WorldSession::HandleGuildBankQueryTab( WorldPacket & recv_data )
pGuild->DisplayGuildBankContent(this, TabId); pGuild->DisplayGuildBankContent(this, TabId);
} }
void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data ) void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_DEPOSIT_MONEY)"); DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_DEPOSIT_MONEY)");
@ -905,10 +905,10 @@ void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data )
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
// logging money // logging money
if(_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) if (_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
{ {
sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)", sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)",
_player->GetName(),_player->GetSession()->GetAccountId(),money,GuildId); _player->GetName(),_player->GetSession()->GetAccountId(),money,GuildId);
} }
// log // log
@ -919,7 +919,7 @@ void WorldSession::HandleGuildBankDepositMoney( WorldPacket & recv_data )
pGuild->DisplayGuildBankMoneyUpdate(this); pGuild->DisplayGuildBankMoneyUpdate(this);
} }
void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data ) void WorldSession::HandleGuildBankWithdrawMoney(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_WITHDRAW_MONEY)"); DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_WITHDRAW_MONEY)");
@ -938,7 +938,7 @@ void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data )
return; return;
Guild* pGuild = sGuildMgr.GetGuildById(GuildId); Guild* pGuild = sGuildMgr.GetGuildById(GuildId);
if(!pGuild) if (!pGuild)
return; return;
if (!pGuild->GetPurchasedTabs()) if (!pGuild->GetPurchasedTabs())
@ -972,7 +972,7 @@ void WorldSession::HandleGuildBankWithdrawMoney( WorldPacket & recv_data )
pGuild->DisplayGuildBankMoneyUpdate(this); pGuild->DisplayGuildBankMoneyUpdate(this);
} }
void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data ) void WorldSession::HandleGuildBankSwapItems(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_SWAP_ITEMS)"); DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_SWAP_ITEMS)");
@ -1016,9 +1016,9 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
recv_data >> SplitedAmount; recv_data >> SplitedAmount;
if (BankTabSlotDst >= GUILD_BANK_MAX_SLOTS || if (BankTabSlotDst >= GUILD_BANK_MAX_SLOTS ||
(BankTabDst == BankTab && BankTabSlotDst == BankTabSlot) || (BankTabDst == BankTab && BankTabSlotDst == BankTabSlot) ||
BankTab >= pGuild->GetPurchasedTabs() || BankTab >= pGuild->GetPurchasedTabs() ||
BankTabDst >= pGuild->GetPurchasedTabs()) BankTabDst >= pGuild->GetPurchasedTabs())
{ {
recv_data.rpos(recv_data.wpos()); // prevent additional spam at rejected packet recv_data.rpos(recv_data.wpos()); // prevent additional spam at rejected packet
return; return;
@ -1045,7 +1045,7 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
} }
if ((BankTabSlot >= GUILD_BANK_MAX_SLOTS && BankTabSlot != 0xFF) || if ((BankTabSlot >= GUILD_BANK_MAX_SLOTS && BankTabSlot != 0xFF) ||
BankTab >= pGuild->GetPurchasedTabs()) BankTab >= pGuild->GetPurchasedTabs())
{ {
recv_data.rpos(recv_data.wpos()); // prevent additional spam at rejected packet recv_data.rpos(recv_data.wpos()); // prevent additional spam at rejected packet
return; return;
@ -1065,9 +1065,9 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
// Player <-> Bank // Player <-> Bank
// allow work with inventory only // allow work with inventory only
if(!Player::IsInventoryPos(PlayerBag, PlayerSlot) && !(PlayerBag == NULL_BAG && PlayerSlot == NULL_SLOT) ) if (!Player::IsInventoryPos(PlayerBag, PlayerSlot) && !(PlayerBag == NULL_BAG && PlayerSlot == NULL_SLOT))
{ {
_player->SendEquipError( EQUIP_ERR_NONE, NULL, NULL ); _player->SendEquipError(EQUIP_ERR_NONE, NULL, NULL);
return; return;
} }
@ -1078,7 +1078,7 @@ void WorldSession::HandleGuildBankSwapItems( WorldPacket & recv_data )
pGuild->MoveFromCharToBank(_player, PlayerBag, PlayerSlot, BankTab, BankTabSlot, SplitedAmount); pGuild->MoveFromCharToBank(_player, PlayerBag, PlayerSlot, BankTab, BankTabSlot, SplitedAmount);
} }
void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data ) void WorldSession::HandleGuildBankBuyTab(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_BUY_TAB)"); DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_BUY_TAB)");
@ -1096,7 +1096,7 @@ void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data )
return; return;
Guild* pGuild = sGuildMgr.GetGuildById(GuildId); Guild* pGuild = sGuildMgr.GetGuildById(GuildId);
if(!pGuild) if (!pGuild)
return; return;
// m_PurchasedTabs = 0 when buying Tab 0, that is why this check can be made // m_PurchasedTabs = 0 when buying Tab 0, that is why this check can be made
@ -1118,7 +1118,7 @@ void WorldSession::HandleGuildBankBuyTab( WorldPacket & recv_data )
pGuild->DisplayGuildBankTabsInfo(this); pGuild->DisplayGuildBankTabsInfo(this);
} }
void WorldSession::HandleGuildBankUpdateTab( WorldPacket & recv_data ) void WorldSession::HandleGuildBankUpdateTab(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_UPDATE_TAB)"); DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_UPDATE_TAB)");
@ -1157,7 +1157,7 @@ void WorldSession::HandleGuildBankUpdateTab( WorldPacket & recv_data )
pGuild->DisplayGuildBankContent(this, TabId); pGuild->DisplayGuildBankContent(this, TabId);
} }
void WorldSession::HandleGuildBankLogQuery( WorldPacket & recv_data ) void WorldSession::HandleGuildBankLogQuery(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received (MSG_GUILD_BANK_LOG_QUERY)"); DEBUG_LOG("WORLD: Received (MSG_GUILD_BANK_LOG_QUERY)");
@ -1179,7 +1179,7 @@ void WorldSession::HandleGuildBankLogQuery( WorldPacket & recv_data )
pGuild->DisplayGuildBankLogs(this, TabId); pGuild->DisplayGuildBankLogs(this, TabId);
} }
void WorldSession::HandleQueryGuildBankTabText(WorldPacket &recv_data) void WorldSession::HandleQueryGuildBankTabText(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received MSG_QUERY_GUILD_BANK_TEXT"); DEBUG_LOG("WORLD: Received MSG_QUERY_GUILD_BANK_TEXT");
@ -1200,7 +1200,7 @@ void WorldSession::HandleQueryGuildBankTabText(WorldPacket &recv_data)
pGuild->SendGuildBankTabText(this, TabId); pGuild->SendGuildBankTabText(this, TabId);
} }
void WorldSession::HandleSetGuildBankTabText(WorldPacket &recv_data) void WorldSession::HandleSetGuildBankTabText(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received CMSG_SET_GUILD_BANK_TEXT"); DEBUG_LOG("WORLD: Received CMSG_SET_GUILD_BANK_TEXT");
@ -1223,9 +1223,9 @@ void WorldSession::HandleSetGuildBankTabText(WorldPacket &recv_data)
pGuild->SetGuildBankTabText(TabId, Text); pGuild->SetGuildBankTabText(TabId, Text);
} }
void WorldSession::SendSaveGuildEmblem( uint32 msg ) void WorldSession::SendSaveGuildEmblem(uint32 msg)
{ {
WorldPacket data(MSG_SAVE_GUILD_EMBLEM, 4); WorldPacket data(MSG_SAVE_GUILD_EMBLEM, 4);
data << uint32(msg); // not part of guild data << uint32(msg); // not part of guild
SendPacket( &data ); SendPacket(&data);
} }

View file

@ -58,7 +58,7 @@ Guild* GuildMgr::GetGuildById(uint32 guildId) const
Guild* GuildMgr::GetGuildByName(std::string const& name) const Guild* GuildMgr::GetGuildByName(std::string const& name) const
{ {
for(GuildMap::const_iterator itr = m_GuildMap.begin(); itr != m_GuildMap.end(); ++itr) for (GuildMap::const_iterator itr = m_GuildMap.begin(); itr != m_GuildMap.end(); ++itr)
if (itr->second->GetName() == name) if (itr->second->GetName() == name)
return itr->second; return itr->second;
@ -67,7 +67,7 @@ Guild* GuildMgr::GetGuildByName(std::string const& name) const
Guild* GuildMgr::GetGuildByLeader(ObjectGuid const& guid) const Guild* GuildMgr::GetGuildByLeader(ObjectGuid const& guid) const
{ {
for(GuildMap::const_iterator itr = m_GuildMap.begin(); itr != m_GuildMap.end(); ++itr) for (GuildMap::const_iterator itr = m_GuildMap.begin(); itr != m_GuildMap.end(); ++itr)
if (itr->second->GetLeaderGuid() == guid) if (itr->second->GetLeaderGuid() == guid)
return itr->second; return itr->second;
@ -89,9 +89,9 @@ void GuildMgr::LoadGuilds()
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6
QueryResult* result = CharacterDatabase.Query("SELECT guild.guildid,guild.name,leaderguid,EmblemStyle,EmblemColor,BorderStyle,BorderColor," QueryResult* result = CharacterDatabase.Query("SELECT guild.guildid,guild.name,leaderguid,EmblemStyle,EmblemColor,BorderStyle,BorderColor,"
// 7 8 9 10 11 12 // 7 8 9 10 11 12
"BackgroundColor,info,motd,createdate,BankMoney,(SELECT COUNT(guild_bank_tab.guildid) FROM guild_bank_tab WHERE guild_bank_tab.guildid = guild.guildid) " "BackgroundColor,info,motd,createdate,BankMoney,(SELECT COUNT(guild_bank_tab.guildid) FROM guild_bank_tab WHERE guild_bank_tab.guildid = guild.guildid) "
"FROM guild ORDER BY guildid ASC"); "FROM guild ORDER BY guildid ASC");
if (!result) if (!result)
{ {
@ -111,13 +111,13 @@ void GuildMgr::LoadGuilds()
// load guild members // load guild members
// 0 1 2 3 4 5 6 // 0 1 2 3 4 5 6
QueryResult* guildMembersResult = CharacterDatabase.Query("SELECT guildid,guild_member.guid,rank,pnote,offnote,BankResetTimeMoney,BankRemMoney," QueryResult* guildMembersResult = CharacterDatabase.Query("SELECT guildid,guild_member.guid,rank,pnote,offnote,BankResetTimeMoney,BankRemMoney,"
// 7 8 9 10 11 12 // 7 8 9 10 11 12
"BankResetTimeTab0,BankRemSlotsTab0,BankResetTimeTab1,BankRemSlotsTab1,BankResetTimeTab2,BankRemSlotsTab2," "BankResetTimeTab0,BankRemSlotsTab0,BankResetTimeTab1,BankRemSlotsTab1,BankResetTimeTab2,BankRemSlotsTab2,"
// 13 14 15 16 17 18 // 13 14 15 16 17 18
"BankResetTimeTab3,BankRemSlotsTab3,BankResetTimeTab4,BankRemSlotsTab4,BankResetTimeTab5,BankRemSlotsTab5," "BankResetTimeTab3,BankRemSlotsTab3,BankResetTimeTab4,BankRemSlotsTab4,BankResetTimeTab5,BankRemSlotsTab5,"
// 19 20 21 22 23 24 // 19 20 21 22 23 24
"characters.name, characters.level, characters.class, characters.zone, characters.logout_time, characters.account " "characters.name, characters.level, characters.class, characters.zone, characters.logout_time, characters.account "
"FROM guild_member LEFT JOIN characters ON characters.guid = guild_member.guid ORDER BY guildid ASC"); "FROM guild_member LEFT JOIN characters ON characters.guid = guild_member.guid ORDER BY guildid ASC");
// load guild bank tab rights // load guild bank tab rights
// 0 1 2 3 4 // 0 1 2 3 4
@ -134,11 +134,11 @@ void GuildMgr::LoadGuilds()
Guild* newGuild = new Guild; Guild* newGuild = new Guild;
if (!newGuild->LoadGuildFromDB(result) || if (!newGuild->LoadGuildFromDB(result) ||
!newGuild->LoadRanksFromDB(guildRanksResult) || !newGuild->LoadRanksFromDB(guildRanksResult) ||
!newGuild->LoadMembersFromDB(guildMembersResult) || !newGuild->LoadMembersFromDB(guildMembersResult) ||
!newGuild->LoadBankRightsFromDB(guildBankTabRightsResult) || !newGuild->LoadBankRightsFromDB(guildBankTabRightsResult) ||
!newGuild->CheckGuildStructure() !newGuild->CheckGuildStructure()
) )
{ {
newGuild->Disband(); newGuild->Disband();
delete newGuild; delete newGuild;
@ -149,7 +149,8 @@ void GuildMgr::LoadGuilds()
newGuild->LoadGuildBankEventLogFromDB(); newGuild->LoadGuildBankEventLogFromDB();
newGuild->LoadGuildBankFromDB(); newGuild->LoadGuildBankFromDB();
AddGuild(newGuild); AddGuild(newGuild);
} while(result->NextRow()); }
while (result->NextRow());
delete result; delete result;
delete guildRanksResult; delete guildRanksResult;

View file

@ -24,16 +24,16 @@
#include "movement/MoveSplineInit.h" #include "movement/MoveSplineInit.h"
#include "movement/MoveSpline.h" #include "movement/MoveSpline.h"
void HomeMovementGenerator<Creature>::Initialize(Creature & owner) void HomeMovementGenerator<Creature>::Initialize(Creature& owner)
{ {
_setTargetLocation(owner); _setTargetLocation(owner);
} }
void HomeMovementGenerator<Creature>::Reset(Creature &) void HomeMovementGenerator<Creature>::Reset(Creature&)
{ {
} }
void HomeMovementGenerator<Creature>::_setTargetLocation(Creature & owner) void HomeMovementGenerator<Creature>::_setTargetLocation(Creature& owner)
{ {
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE)) if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
return; return;
@ -55,7 +55,7 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature & owner)
owner.clearUnitState(UNIT_STAT_ALL_STATE); owner.clearUnitState(UNIT_STAT_ALL_STATE);
} }
bool HomeMovementGenerator<Creature>::Update(Creature &owner, const uint32& time_diff) bool HomeMovementGenerator<Creature>::Update(Creature& owner, const uint32& time_diff)
{ {
arrived = owner.movespline->Finalized(); arrived = owner.movespline->Finalized();
return !arrived; return !arrived;

View file

@ -28,22 +28,22 @@ class MANGOS_DLL_SPEC HomeMovementGenerator;
template <> template <>
class MANGOS_DLL_SPEC HomeMovementGenerator<Creature> class MANGOS_DLL_SPEC HomeMovementGenerator<Creature>
: public MovementGeneratorMedium< Creature, HomeMovementGenerator<Creature> > : public MovementGeneratorMedium< Creature, HomeMovementGenerator<Creature> >
{ {
public: public:
HomeMovementGenerator() : arrived(false) {} HomeMovementGenerator() : arrived(false) {}
~HomeMovementGenerator() {} ~HomeMovementGenerator() {}
void Initialize(Creature &); void Initialize(Creature&);
void Finalize(Creature &); void Finalize(Creature&);
void Interrupt(Creature &) {} void Interrupt(Creature&) {}
void Reset(Creature &); void Reset(Creature&);
bool Update(Creature &, const uint32 &); bool Update(Creature&, const uint32&);
MovementGeneratorType GetMovementGeneratorType() const { return HOME_MOTION_TYPE; } MovementGeneratorType GetMovementGeneratorType() const { return HOME_MOTION_TYPE; }
private: private:
void _setTargetLocation(Creature &); void _setTargetLocation(Creature&);
bool arrived; bool arrived;
}; };
#endif #endif

View file

@ -23,7 +23,7 @@
#include "SpellMgr.h" #include "SpellMgr.h"
#include "Map.h" #include "Map.h"
HostileRefManager::HostileRefManager( Unit *pOwner ) : iOwner(pOwner), m_redirectionMod(0.0f) HostileRefManager::HostileRefManager(Unit* pOwner) : iOwner(pOwner), m_redirectionMod(0.0f)
{ {
} }
@ -38,7 +38,7 @@ HostileRefManager::~HostileRefManager()
// The pVictim is hated than by them as well // The pVictim is hated than by them as well
// use for buffs and healing threat functionality // use for buffs and healing threat functionality
void HostileRefManager::threatAssist(Unit *pVictim, float pThreat, SpellEntry const *pThreatSpell, bool pSingleTarget) void HostileRefManager::threatAssist(Unit* pVictim, float pThreat, SpellEntry const* pThreatSpell, bool pSingleTarget)
{ {
uint32 size = pSingleTarget ? 1 : getSize(); // if pSingleTarget do not devide threat uint32 size = pSingleTarget ? 1 : getSize(); // if pSingleTarget do not devide threat
float threat = pThreat/size; float threat = pThreat/size;
@ -58,7 +58,7 @@ void HostileRefManager::addThreatPercent(int32 pValue)
HostileReference* ref; HostileReference* ref;
ref = getFirst(); ref = getFirst();
while(ref != NULL) while (ref != NULL)
{ {
ref->addThreatPercent(pValue); ref->addThreatPercent(pValue);
ref = ref->next(); ref = ref->next();
@ -73,7 +73,7 @@ void HostileRefManager::setOnlineOfflineState(bool pIsOnline)
HostileReference* ref; HostileReference* ref;
ref = getFirst(); ref = getFirst();
while(ref != NULL) while (ref != NULL)
{ {
ref->setOnlineOfflineState(pIsOnline); ref->setOnlineOfflineState(pIsOnline);
ref = ref->next(); ref = ref->next();
@ -86,7 +86,7 @@ void HostileRefManager::setOnlineOfflineState(bool pIsOnline)
void HostileRefManager::updateThreatTables() void HostileRefManager::updateThreatTables()
{ {
HostileReference* ref = getFirst(); HostileReference* ref = getFirst();
while(ref) while (ref)
{ {
ref->updateOnlineStatus(); ref->updateOnlineStatus();
ref = ref->next(); ref = ref->next();
@ -100,7 +100,7 @@ void HostileRefManager::updateThreatTables()
void HostileRefManager::deleteReferences() void HostileRefManager::deleteReferences()
{ {
HostileReference* ref = getFirst(); HostileReference* ref = getFirst();
while(ref) while (ref)
{ {
HostileReference* nextRef = ref->next(); HostileReference* nextRef = ref->next();
ref->removeReference(); ref->removeReference();
@ -115,10 +115,10 @@ void HostileRefManager::deleteReferences()
void HostileRefManager::deleteReferencesForFaction(uint32 faction) void HostileRefManager::deleteReferencesForFaction(uint32 faction)
{ {
HostileReference* ref = getFirst(); HostileReference* ref = getFirst();
while(ref) while (ref)
{ {
HostileReference* nextRef = ref->next(); HostileReference* nextRef = ref->next();
if(ref->getSource()->getOwner()->getFactionTemplateEntry()->faction == faction) if (ref->getSource()->getOwner()->getFactionTemplateEntry()->faction == faction)
{ {
ref->removeReference(); ref->removeReference();
delete ref; delete ref;
@ -130,13 +130,13 @@ void HostileRefManager::deleteReferencesForFaction(uint32 faction)
//================================================= //=================================================
// delete one reference, defined by Unit // delete one reference, defined by Unit
void HostileRefManager::deleteReference(Unit *pCreature) void HostileRefManager::deleteReference(Unit* pCreature)
{ {
HostileReference* ref = getFirst(); HostileReference* ref = getFirst();
while(ref) while (ref)
{ {
HostileReference* nextRef = ref->next(); HostileReference* nextRef = ref->next();
if(ref->getSource()->getOwner() == pCreature) if (ref->getSource()->getOwner() == pCreature)
{ {
ref->removeReference(); ref->removeReference();
delete ref; delete ref;
@ -149,13 +149,13 @@ void HostileRefManager::deleteReference(Unit *pCreature)
//================================================= //=================================================
// set state for one reference, defined by Unit // set state for one reference, defined by Unit
void HostileRefManager::setOnlineOfflineState(Unit *pCreature,bool pIsOnline) void HostileRefManager::setOnlineOfflineState(Unit* pCreature,bool pIsOnline)
{ {
HostileReference* ref = getFirst(); HostileReference* ref = getFirst();
while(ref) while (ref)
{ {
HostileReference* nextRef = ref->next(); HostileReference* nextRef = ref->next();
if(ref->getSource()->getOwner() == pCreature) if (ref->getSource()->getOwner() == pCreature)
{ {
ref->setOnlineOfflineState(pIsOnline); ref->setOnlineOfflineState(pIsOnline);
break; break;

View file

@ -33,7 +33,7 @@ struct SpellEntry;
class HostileRefManager : public RefManager<Unit, ThreatManager> class HostileRefManager : public RefManager<Unit, ThreatManager>
{ {
public: public:
explicit HostileRefManager(Unit *pOwner); explicit HostileRefManager(Unit* pOwner);
~HostileRefManager(); ~HostileRefManager();
Unit* getOwner() { return iOwner; } Unit* getOwner() { return iOwner; }
@ -41,7 +41,7 @@ class HostileRefManager : public RefManager<Unit, ThreatManager>
// send threat to all my hateres for the pVictim // send threat to all my hateres for the pVictim
// The pVictim is hated than by them as well // The pVictim is hated than by them as well
// use for buffs and healing threat functionality // use for buffs and healing threat functionality
void threatAssist(Unit *pVictim, float threat, SpellEntry const *threatSpell = 0, bool pSingleTarget=false); void threatAssist(Unit* pVictim, float threat, SpellEntry const* threatSpell = 0, bool pSingleTarget=false);
void addThreatPercent(int32 pValue); void addThreatPercent(int32 pValue);
@ -52,17 +52,17 @@ class HostileRefManager : public RefManager<Unit, ThreatManager>
// Remove specific faction references // Remove specific faction references
void deleteReferencesForFaction(uint32 faction); void deleteReferencesForFaction(uint32 faction);
HostileReference* getFirst() { return ((HostileReference* ) RefManager<Unit, ThreatManager>::getFirst()); } HostileReference* getFirst() { return ((HostileReference*) RefManager<Unit, ThreatManager>::getFirst()); }
void updateThreatTables(); void updateThreatTables();
void setOnlineOfflineState(bool pIsOnline); void setOnlineOfflineState(bool pIsOnline);
// set state for one reference, defined by Unit // set state for one reference, defined by Unit
void setOnlineOfflineState(Unit *pCreature,bool pIsOnline); void setOnlineOfflineState(Unit* pCreature,bool pIsOnline);
// delete one reference, defined by Unit // delete one reference, defined by Unit
void deleteReference(Unit *pCreature); void deleteReference(Unit* pCreature);
// redirection threat data // redirection threat data
void SetThreatRedirection(ObjectGuid guid, uint32 pct) void SetThreatRedirection(ObjectGuid guid, uint32 pct)

View file

@ -53,7 +53,7 @@ DistractMovementGenerator::Interrupt(Unit& /*owner*/)
bool bool
DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff) DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff)
{ {
if(time_diff > m_timer) if (time_diff > m_timer)
return false; return false;
m_timer -= time_diff; m_timer -= time_diff;
@ -61,7 +61,7 @@ DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff)
} }
void void
AssistanceDistractMovementGenerator::Finalize(Unit &unit) AssistanceDistractMovementGenerator::Finalize(Unit& unit)
{ {
unit.clearUnitState(UNIT_STAT_DISTRACTED); unit.clearUnitState(UNIT_STAT_DISTRACTED);
if (Unit* victim = unit.getVictim()) if (Unit* victim = unit.getVictim())

View file

@ -25,11 +25,11 @@ class MANGOS_DLL_SPEC IdleMovementGenerator : public MovementGenerator
{ {
public: public:
void Initialize(Unit &) {} void Initialize(Unit&) {}
void Finalize(Unit &) {} void Finalize(Unit&) {}
void Interrupt(Unit &) {} void Interrupt(Unit&) {}
void Reset(Unit &); void Reset(Unit&);
bool Update(Unit &, const uint32 &) { return true; } bool Update(Unit&, const uint32&) { return true; }
MovementGeneratorType GetMovementGeneratorType() const { return IDLE_MOTION_TYPE; } MovementGeneratorType GetMovementGeneratorType() const { return IDLE_MOTION_TYPE; }
}; };
@ -42,8 +42,8 @@ class MANGOS_DLL_SPEC DistractMovementGenerator : public MovementGenerator
void Initialize(Unit& owner); void Initialize(Unit& owner);
void Finalize(Unit& owner); void Finalize(Unit& owner);
void Interrupt(Unit& ); void Interrupt(Unit&);
void Reset(Unit& ); void Reset(Unit&);
bool Update(Unit& owner, const uint32& time_diff); bool Update(Unit& owner, const uint32& time_diff);
MovementGeneratorType GetMovementGeneratorType() const { return DISTRACT_MOTION_TYPE; } MovementGeneratorType GetMovementGeneratorType() const { return DISTRACT_MOTION_TYPE; }

View file

@ -39,16 +39,16 @@ void InstanceData::SaveToDB()
CharacterDatabase.PExecute("UPDATE world SET data = '%s' WHERE map = '%u'", data.c_str(), instance->GetId()); CharacterDatabase.PExecute("UPDATE world SET data = '%s' WHERE map = '%u'", data.c_str(), instance->GetId());
} }
bool InstanceData::CheckAchievementCriteriaMeet( uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= NULL*/, uint32 /*miscvalue1*/ /*= 0*/ ) bool InstanceData::CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= NULL*/, uint32 /*miscvalue1*/ /*= 0*/)
{ {
sLog.outError("Achievement system call InstanceData::CheckAchievementCriteriaMeet but instance script for map %u not have implementation for achievement criteria %u", sLog.outError("Achievement system call InstanceData::CheckAchievementCriteriaMeet but instance script for map %u not have implementation for achievement criteria %u",
instance->GetId(),criteria_id); instance->GetId(),criteria_id);
return false; return false;
} }
bool InstanceData::CheckConditionCriteriaMeet(Player const* /*source*/, uint32 map_id, uint32 instance_condition_id) bool InstanceData::CheckConditionCriteriaMeet(Player const* /*source*/, uint32 map_id, uint32 instance_condition_id)
{ {
sLog.outError("Condition system call InstanceData::CheckConditionCriteriaMeet but instance script for map %u not have implementation for player condition criteria with internal id %u for map %u", sLog.outError("Condition system call InstanceData::CheckConditionCriteriaMeet but instance script for map %u not have implementation for player condition criteria with internal id %u for map %u",
instance->GetId(), instance_condition_id, map_id); instance->GetId(), instance_condition_id, map_id);
return false; return false;
} }

View file

@ -32,10 +32,10 @@ class MANGOS_DLL_SPEC InstanceData
{ {
public: public:
explicit InstanceData(Map *map) : instance(map) {} explicit InstanceData(Map* map) : instance(map) {}
virtual ~InstanceData() {} virtual ~InstanceData() {}
Map *instance; Map* instance;
//On creation, NOT load. //On creation, NOT load.
virtual void Initialize() {} virtual void Initialize() {}
@ -56,28 +56,28 @@ class MANGOS_DLL_SPEC InstanceData
virtual bool IsEncounterInProgress() const { return false; }; virtual bool IsEncounterInProgress() const { return false; };
//Called when a player successfully enters the instance (after really added to map) //Called when a player successfully enters the instance (after really added to map)
virtual void OnPlayerEnter(Player *) {} virtual void OnPlayerEnter(Player*) {}
//Called when a player dies inside instance //Called when a player dies inside instance
virtual void OnPlayerDeath(Player *) {} virtual void OnPlayerDeath(Player*) {}
//Called when a player leaves the instance (before really removed from map (or possibly world)) //Called when a player leaves the instance (before really removed from map (or possibly world))
virtual void OnPlayerLeave(Player *) {} virtual void OnPlayerLeave(Player*) {}
//Called when a gameobject is created //Called when a gameobject is created
virtual void OnObjectCreate(GameObject *) {} virtual void OnObjectCreate(GameObject*) {}
//called on creature creation //called on creature creation
virtual void OnCreatureCreate(Creature * /*creature*/) {} virtual void OnCreatureCreate(Creature* /*creature*/) {}
//called on creature enter combat //called on creature enter combat
virtual void OnCreatureEnterCombat(Creature * /*creature*/) {} virtual void OnCreatureEnterCombat(Creature* /*creature*/) {}
//called on creature evade //called on creature evade
virtual void OnCreatureEvade(Creature * /*creature*/) {} virtual void OnCreatureEvade(Creature* /*creature*/) {}
//called on creature death //called on creature death
virtual void OnCreatureDeath(Creature * /*creature*/) {} virtual void OnCreatureDeath(Creature* /*creature*/) {}
//All-purpose data storage 64 bit //All-purpose data storage 64 bit
virtual uint64 GetData64(uint32 /*Data*/) { return 0; } virtual uint64 GetData64(uint32 /*Data*/) { return 0; }

View file

@ -715,7 +715,7 @@ void Item::SetItemRandomProperties(int32 randomPropId)
if (item_rand) if (item_rand)
{ {
if (GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != -int32(item_rand->ID) || if (GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != -int32(item_rand->ID) ||
!GetItemSuffixFactor()) !GetItemSuffixFactor())
{ {
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, -int32(item_rand->ID)); SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, -int32(item_rand->ID));
UpdateItemSuffixFactor(); UpdateItemSuffixFactor();
@ -776,7 +776,7 @@ void Item::AddToUpdateQueueOf(Player* player)
if (!player) if (!player)
{ {
sLog.outError("Item::AddToUpdateQueueOf - %s current owner (%s) not in world!", sLog.outError("Item::AddToUpdateQueueOf - %s current owner (%s) not in world!",
GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str()); GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str());
return; return;
} }
} }
@ -784,7 +784,7 @@ void Item::AddToUpdateQueueOf(Player* player)
if (player->GetObjectGuid() != GetOwnerGuid()) if (player->GetObjectGuid() != GetOwnerGuid())
{ {
sLog.outError("Item::AddToUpdateQueueOf - %s current owner (%s) and inventory owner (%s) don't match!", sLog.outError("Item::AddToUpdateQueueOf - %s current owner (%s) and inventory owner (%s) don't match!",
GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), player->GetGuidStr().c_str()); GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), player->GetGuidStr().c_str());
return; return;
} }
@ -806,7 +806,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
if (!player) if (!player)
{ {
sLog.outError("Item::RemoveFromUpdateQueueOf - %s current owner (%s) not in world!", sLog.outError("Item::RemoveFromUpdateQueueOf - %s current owner (%s) not in world!",
GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str()); GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str());
return; return;
} }
} }
@ -814,7 +814,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
if (player->GetObjectGuid() != GetOwnerGuid()) if (player->GetObjectGuid() != GetOwnerGuid())
{ {
sLog.outError("Item::RemoveFromUpdateQueueOf - %s current owner (%s) and inventory owner (%s) don't match!", sLog.outError("Item::RemoveFromUpdateQueueOf - %s current owner (%s) and inventory owner (%s) don't match!",
GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), player->GetGuidStr().c_str()); GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), player->GetGuidStr().c_str());
return; return;
} }
@ -840,12 +840,12 @@ bool Item::CanBeTraded(bool mail) const
if ((!mail || !IsBoundAccountWide()) && IsSoulBound()) if ((!mail || !IsBoundAccountWide()) && IsSoulBound())
return false; return false;
if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()) ) if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
return false; return false;
if (Player* owner = GetOwner()) if (Player* owner = GetOwner())
{ {
if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK ) if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK)
return false; return false;
if (owner->GetLootGuid() == GetObjectGuid()) if (owner->GetLootGuid() == GetObjectGuid())
return false; return false;
@ -1078,7 +1078,7 @@ void Item::SendTimeUpdate(Player* owner)
owner->GetSession()->SendPacket(&data); owner->GetSession()->SendPacket(&data);
} }
Item* Item::CreateItem( uint32 item, uint32 count, Player const* player, uint32 randomPropertyId) Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 randomPropertyId)
{ {
if (count < 1) if (count < 1)
return NULL; //don't create item at zero count return NULL; //don't create item at zero count
@ -1238,8 +1238,8 @@ void Item::SetLootState(ItemLootUpdateState state)
{ {
case ITEM_LOOT_NONE: case ITEM_LOOT_NONE:
case ITEM_LOOT_NEW: case ITEM_LOOT_NEW:
assert(false); // not used in state change calls assert(false); // not used in state change calls
return; return;
case ITEM_LOOT_TEMPORARY: case ITEM_LOOT_TEMPORARY:
assert(m_lootState == ITEM_LOOT_NONE); // called only for not generated yet loot case assert(m_lootState == ITEM_LOOT_NONE); // called only for not generated yet loot case
m_lootState = ITEM_LOOT_TEMPORARY; m_lootState = ITEM_LOOT_TEMPORARY;

View file

@ -268,17 +268,17 @@ struct ItemRequiredTarget
bool IsFitToRequirements(Unit* pUnitTarget) const; bool IsFitToRequirements(Unit* pUnitTarget) const;
}; };
bool ItemCanGoIntoBag(ItemPrototype const *proto, ItemPrototype const *pBagProto); bool ItemCanGoIntoBag(ItemPrototype const* proto, ItemPrototype const* pBagProto);
class MANGOS_DLL_SPEC Item : public Object class MANGOS_DLL_SPEC Item : public Object
{ {
public: public:
static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL, uint32 randomPropertyId = 0); static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL, uint32 randomPropertyId = 0);
Item* CloneItem( uint32 count, Player const* player = NULL ) const; Item* CloneItem(uint32 count, Player const* player = NULL) const;
Item(); Item();
virtual bool Create( uint32 guidlow, uint32 itemid, Player const* owner); virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
ItemPrototype const* GetProto() const; ItemPrototype const* GetProto() const;
@ -308,8 +308,8 @@ class MANGOS_DLL_SPEC Item : public Object
bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const; bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const;
bool GemsFitSockets() const; bool GemsFitSockets() const;
uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); } uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); }
void SetCount(uint32 value) { SetUInt32Value (ITEM_FIELD_STACK_COUNT, value); } void SetCount(uint32 value) { SetUInt32Value(ITEM_FIELD_STACK_COUNT, value); }
uint32 GetMaxStackCount() const { return GetProto()->GetMaxStackSize(); } uint32 GetMaxStackCount() const { return GetProto()->GetMaxStackSize(); }
uint8 GetGemCountWithID(uint32 GemID) const; uint8 GetGemCountWithID(uint32 GemID) const;
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const; uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const;
@ -320,7 +320,7 @@ class MANGOS_DLL_SPEC Item : public Object
uint8 GetBagSlot() const; uint8 GetBagSlot() const;
void SetSlot(uint8 slot) {m_slot = slot;} void SetSlot(uint8 slot) {m_slot = slot;}
uint16 GetPos() const { return uint16(GetBagSlot()) << 8 | GetSlot(); } uint16 GetPos() const { return uint16(GetBagSlot()) << 8 | GetSlot(); }
void SetContainer(Bag *container) { m_container = container; } void SetContainer(Bag* container) { m_container = container; }
bool IsInBag() const { return m_container != NULL; } bool IsInBag() const { return m_container != NULL; }
bool IsEquipped() const; bool IsEquipped() const;

View file

@ -53,7 +53,7 @@ void LoadRandomEnchantmentsTable()
float chance; float chance;
uint32 count = 0; uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT entry, ench, chance FROM item_enchantment_template"); QueryResult* result = WorldDatabase.Query("SELECT entry, ench, chance FROM item_enchantment_template");
if (result) if (result)
{ {
@ -61,7 +61,7 @@ void LoadRandomEnchantmentsTable()
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
entry = fields[0].GetUInt32(); entry = fields[0].GetUInt32();
@ -69,20 +69,21 @@ void LoadRandomEnchantmentsTable()
chance = fields[2].GetFloat(); chance = fields[2].GetFloat();
if (chance > 0.000001f && chance <= 100.0f) if (chance > 0.000001f && chance <= 100.0f)
RandomItemEnch[entry].push_back( EnchStoreItem(ench, chance) ); RandomItemEnch[entry].push_back(EnchStoreItem(ench, chance));
++count; ++count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
sLog.outString( ">> Loaded %u Item Enchantment definitions", count ); sLog.outString(">> Loaded %u Item Enchantment definitions", count);
} }
else else
{ {
sLog.outString(); sLog.outString();
sLog.outErrorDb( ">> Loaded 0 Item Enchantment definitions. DB table `item_enchantment_template` is empty."); sLog.outErrorDb(">> Loaded 0 Item Enchantment definitions. DB table `item_enchantment_template` is empty.");
} }
} }
@ -101,7 +102,7 @@ uint32 GetItemEnchantMod(uint32 entry)
double dRoll = rand_chance(); double dRoll = rand_chance();
float fCount = 0; float fCount = 0;
for(EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter) for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
{ {
fCount += ench_iter->chance; fCount += ench_iter->chance;
@ -109,10 +110,10 @@ uint32 GetItemEnchantMod(uint32 entry)
} }
//we could get here only if sum of all enchantment chances is lower than 100% //we could get here only if sum of all enchantment chances is lower than 100%
dRoll = (irand(0, (int)floor(fCount * 100) + 1)) / 100; dRoll = (irand(0, (int)floor(fCount * 100) + 1)) / 100;
fCount = 0; fCount = 0;
for(EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter) for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
{ {
fCount += ench_iter->chance; fCount += ench_iter->chance;
@ -124,21 +125,21 @@ uint32 GetItemEnchantMod(uint32 entry)
uint32 GenerateEnchSuffixFactor(uint32 item_id) uint32 GenerateEnchSuffixFactor(uint32 item_id)
{ {
ItemPrototype const *itemProto = ObjectMgr::GetItemPrototype(item_id); ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(item_id);
if(!itemProto) if (!itemProto)
return 0; return 0;
if(!itemProto->RandomSuffix) if (!itemProto->RandomSuffix)
return 0; return 0;
RandomPropertiesPointsEntry const *randomProperty = sRandomPropertiesPointsStore.LookupEntry(itemProto->ItemLevel); RandomPropertiesPointsEntry const* randomProperty = sRandomPropertiesPointsStore.LookupEntry(itemProto->ItemLevel);
if(!randomProperty) if (!randomProperty)
return 0; return 0;
uint32 suffixFactor; uint32 suffixFactor;
switch(itemProto->InventoryType) switch (itemProto->InventoryType)
{ {
// Items of that type don`t have points // Items of that type don`t have points
case INVTYPE_NON_EQUIP: case INVTYPE_NON_EQUIP:
case INVTYPE_BAG: case INVTYPE_BAG:
case INVTYPE_TABARD: case INVTYPE_TABARD:

File diff suppressed because it is too large Load diff

View file

@ -477,7 +477,7 @@ const uint32 MaxItemSubclassValues[MAX_ITEM_CLASS] =
inline uint8 ItemSubClassToDurabilityMultiplierId(uint32 ItemClass, uint32 ItemSubClass) inline uint8 ItemSubClassToDurabilityMultiplierId(uint32 ItemClass, uint32 ItemSubClass)
{ {
switch(ItemClass) switch (ItemClass)
{ {
case ITEM_CLASS_WEAPON: return ItemSubClass; case ITEM_CLASS_WEAPON: return ItemSubClass;
case ITEM_CLASS_ARMOR: return ItemSubClass + 21; case ITEM_CLASS_ARMOR: return ItemSubClass + 21;
@ -615,7 +615,7 @@ struct ItemPrototype
// helpers // helpers
bool CanChangeEquipStateInCombat() const bool CanChangeEquipStateInCombat() const
{ {
switch(InventoryType) switch (InventoryType)
{ {
case INVTYPE_RELIC: case INVTYPE_RELIC:
case INVTYPE_SHIELD: case INVTYPE_SHIELD:
@ -623,7 +623,7 @@ struct ItemPrototype
return true; return true;
} }
switch(Class) switch (Class)
{ {
case ITEM_CLASS_WEAPON: case ITEM_CLASS_WEAPON:
case ITEM_CLASS_PROJECTILE: case ITEM_CLASS_PROJECTILE: