[Sync] Some long overdue project sync

This commit is contained in:
Antz 2019-01-08 23:04:45 +00:00 committed by Antz
parent a479a2ccc5
commit 65ec4ea06e
76 changed files with 1693 additions and 1489 deletions

View file

@ -130,7 +130,7 @@ class Grid
*/ */
bool AddGridObject(SPECIFIC_OBJECT* obj) bool AddGridObject(SPECIFIC_OBJECT* obj)
{ {
if (obj->isActiveObject()) if (obj->IsActiveObject())
{ m_activeGridObjects.insert(obj); } { m_activeGridObjects.insert(obj); }
return i_container.template insert<SPECIFIC_OBJECT>(obj); return i_container.template insert<SPECIFIC_OBJECT>(obj);
@ -145,7 +145,7 @@ class Grid
*/ */
bool RemoveGridObject(SPECIFIC_OBJECT* obj) bool RemoveGridObject(SPECIFIC_OBJECT* obj)
{ {
if (obj->isActiveObject()) if (obj->IsActiveObject())
{ m_activeGridObjects.erase(obj); } { m_activeGridObjects.erase(obj); }
return i_container.template remove<SPECIFIC_OBJECT>(obj); return i_container.template remove<SPECIFIC_OBJECT>(obj);

View file

@ -1138,7 +1138,7 @@ void BattleGround::SendRewardMarkByMail(Player* plr, uint32 mark, uint32 count)
/// <param name="plr">The PLR.</param> /// <param name="plr">The PLR.</param>
void BattleGround::RewardQuestComplete(Player* plr) void BattleGround::RewardQuestComplete(Player* plr)
{ {
uint32 quest; uint32 quest = 0;
switch (GetTypeID()) switch (GetTypeID())
{ {
case BATTLEGROUND_AV: case BATTLEGROUND_AV:
@ -2072,6 +2072,11 @@ void BattleGround::CheckArenaWinConditions()
EndBattleGround(ALLIANCE); EndBattleGround(ALLIANCE);
} }
/// <summary>
/// Sets the bg raid.
/// </summary>
/// <param name="team">The team.</param>
/// <param name="bg_raid">The bg_raid.</param>
void BattleGround::SetBgRaid(Team team, Group* bg_raid) void BattleGround::SetBgRaid(Team team, Group* bg_raid)
{ {
Group*& old_raid = m_BgRaids[GetTeamIndexByTeamId(team)]; Group*& old_raid = m_BgRaids[GetTeamIndexByTeamId(team)];

View file

@ -911,9 +911,9 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
{ {
uint32 factionid = chr->getFaction(); uint32 factionid = chr->getFaction();
uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
uint32 NpcFlags = chr->GetUInt32Value(UNIT_NPC_FLAGS); uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
PSendSysMessage(LANG_CURRENT_FACTION, chr->GetGUIDLow(), factionid, flag, NpcFlags, dyflag); PSendSysMessage(LANG_CURRENT_FACTION, chr->GetGUIDLow(), factionid, flag, npcflag, dyflag);
} }
return true; return true;
} }
@ -940,19 +940,19 @@ bool ChatHandler::HandleModifyFactionCommand(char* args)
if (!ExtractOptUInt32(&args, flag, chr->GetUInt32Value(UNIT_FIELD_FLAGS))) if (!ExtractOptUInt32(&args, flag, chr->GetUInt32Value(UNIT_FIELD_FLAGS)))
{ return false; } { return false; }
uint32 NpcFlags; uint32 npcflag;
if (!ExtractOptUInt32(&args, NpcFlags, chr->GetUInt32Value(UNIT_NPC_FLAGS))) if (!ExtractOptUInt32(&args, npcflag, chr->GetUInt32Value(UNIT_NPC_FLAGS)))
{ return false; } { return false; }
uint32 dyflag; uint32 dyflag;
if (!ExtractOptUInt32(&args, dyflag, chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS))) if (!ExtractOptUInt32(&args, dyflag, chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS)))
{ return false; } { return false; }
PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(), factionid, flag, NpcFlags, dyflag); PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(), factionid, flag, npcflag, dyflag);
chr->setFaction(factionid); chr->setFaction(factionid);
chr->SetUInt32Value(UNIT_FIELD_FLAGS, flag); chr->SetUInt32Value(UNIT_FIELD_FLAGS, flag);
chr->SetUInt32Value(UNIT_NPC_FLAGS, NpcFlags); chr->SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS, dyflag); chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS, dyflag);
return true; return true;
@ -2288,14 +2288,15 @@ bool ChatHandler::HandleGoGridCommand(char* args)
bool ChatHandler::HandleModifyDrunkCommand(char* args) bool ChatHandler::HandleModifyDrunkCommand(char* args)
{ {
if (!*args) { return false; } if (!*args)
return false;
uint8 drunkValue = (uint8)atoi(args); uint8 drunkValue = (uint8)atoi(args);
if (drunkValue > 100) if (drunkValue > 100)
drunkValue = 100; drunkValue = 100;
if (Player* target = getSelectedPlayer()) if (Player* target = getSelectedPlayer())
target->SetDrunkValue(drunkValue); target->SetDrunkValue(drunkValue);
return true; return true;
} }

View file

@ -271,7 +271,7 @@ bool ChatHandler::HandleTriggerCommand(char* args)
AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id); AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id);
if (at) if (at)
PSendSysMessage(LANG_TRIGGER_REQ_LEVEL, at->requiredLevel); { PSendSysMessage(LANG_TRIGGER_REQ_LEVEL, at->requiredLevel); }
if (uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger(atEntry->id)) if (uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger(atEntry->id))
{ {
@ -286,9 +286,9 @@ bool ChatHandler::HandleTriggerCommand(char* args)
SendSysMessage(LANG_TRIGGER_REQ_ITEMS); SendSysMessage(LANG_TRIGGER_REQ_ITEMS);
if (at->requiredItem) if (at->requiredItem)
ShowItemListHelper(at->requiredItem, loc_idx, pl); { ShowItemListHelper(at->requiredItem, loc_idx, pl); }
if (at->requiredItem2) if (at->requiredItem2)
ShowItemListHelper(at->requiredItem2, loc_idx, pl); { ShowItemListHelper(at->requiredItem2, loc_idx, pl); }
} }
if (at->requiredQuest) if (at->requiredQuest)
@ -1369,6 +1369,7 @@ bool ChatHandler::HandleCharacterAchievementsCommand(char* args)
void ChatHandler::ShowFactionListHelper(FactionEntry const* factionEntry, LocaleConstant loc, FactionState const* repState /*= NULL*/, Player* target /*= NULL */) void ChatHandler::ShowFactionListHelper(FactionEntry const* factionEntry, LocaleConstant loc, FactionState const* repState /*= NULL*/, Player* target /*= NULL */)
{ {
std::string name = factionEntry->name[loc]; std::string name = factionEntry->name[loc];
// send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format // send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
// or "id - [faction] [no reputation]" format // or "id - [faction] [no reputation]" format
std::ostringstream ss; std::ostringstream ss;
@ -1921,6 +1922,7 @@ bool ChatHandler::HandleNpcMoveCommand(char* args)
Player* player = m_session->GetPlayer(); Player* player = m_session->GetPlayer();
Creature* pCreature = getSelectedCreature(); Creature* pCreature = getSelectedCreature();
if (!pCreature) if (!pCreature)
{ {
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
@ -2476,7 +2478,6 @@ bool ChatHandler::HandleDeMorphCommand(char* /*args*/)
if (!target) if (!target)
{ target = m_session->GetPlayer(); } { target = m_session->GetPlayer(); }
// check online security // check online security
else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target)) else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target))
{ return false; } { return false; }
@ -2679,11 +2680,11 @@ bool ChatHandler::HandleTicketCommand(char* args)
PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, GetOnOffStr(accept)); PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, GetOnOffStr(accept));
} }
else else
PSendSysMessage(LANG_COMMAND_TICKETCOUNT_CONSOLE, count); { PSendSysMessage(LANG_COMMAND_TICKETCOUNT_CONSOLE, count); }
return true; return true;
} }
// ticket accept on // ticket accept on
if (strncmp(px, "on", 3) == 0) if (strncmp(px, "on", 3) == 0)
{ {
@ -2756,7 +2757,7 @@ bool ChatHandler::HandleTicketCommand(char* args)
// no response text? // no response text?
if (!*args) if (!*args)
return false; { return false; }
ticket->SetResponseText(args); ticket->SetResponseText(args);
@ -2771,7 +2772,7 @@ bool ChatHandler::HandleTicketCommand(char* args)
if (ExtractUInt32(&px, num)) if (ExtractUInt32(&px, num))
{ {
if (num == 0) if (num == 0)
return false; { return false; }
// mgr numbering tickets start from 0 // mgr numbering tickets start from 0
GMTicket* ticket = sTicketMgr.GetGMTicketByOrderPos(num - 1); GMTicket* ticket = sTicketMgr.GetGMTicketByOrderPos(num - 1);
@ -2789,7 +2790,7 @@ bool ChatHandler::HandleTicketCommand(char* args)
ObjectGuid target_guid; ObjectGuid target_guid;
std::string target_name; std::string target_name;
if (!ExtractPlayerTarget(&px, NULL, &target_guid, &target_name)) if (!ExtractPlayerTarget(&px, NULL, &target_guid, &target_name))
return false; { return false; }
// ticket $char_name // ticket $char_name
GMTicket* ticket = sTicketMgr.GetGMTicket(target_guid); GMTicket* ticket = sTicketMgr.GetGMTicket(target_guid);
@ -2849,7 +2850,7 @@ bool ChatHandler::HandleDelTicketCommand(char* args)
PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL, GetNameLink(pl).c_str()); PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL, GetNameLink(pl).c_str());
} }
else else
PSendSysMessage(LANG_COMMAND_TICKETDEL); { PSendSysMessage(LANG_COMMAND_TICKETDEL); }
return true; return true;
} }
@ -3139,7 +3140,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
// Did user provide a GUID or did the user select a creature? // Did user provide a GUID or did the user select a creature?
Creature* targetCreature = getSelectedCreature(); // Expect a visual waypoint to be selected Creature* targetCreature = getSelectedCreature(); // Expect a visual waypoint to be selected
Creature* wpOwner; // Who moves along the waypoint Creature* wpOwner = NULL; // Who moves along the waypoint
uint32 wpId = 0; uint32 wpId = 0;
WaypointPathOrigin wpSource = PATH_NO_PATH; WaypointPathOrigin wpSource = PATH_NO_PATH;
int32 wpPathId = 0; int32 wpPathId = 0;
@ -3392,7 +3393,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
} }
} }
Creature* wpOwner; ///< Npc that is moving Creature* wpOwner = NULL; ///< Npc that is moving
TemporarySummonWaypoint* wpTarget = NULL; // Define here for wp-info command TemporarySummonWaypoint* wpTarget = NULL; // Define here for wp-info command
// Show info for the selected waypoint (Step one: get moving npc) // Show info for the selected waypoint (Step one: get moving npc)
@ -3543,7 +3544,7 @@ bool ChatHandler::HandleWpExportCommand(char* args)
if (!*args) if (!*args)
return false; return false;
Creature* wpOwner; Creature* wpOwner = NULL;
WaypointPathOrigin wpOrigin = PATH_NO_PATH; WaypointPathOrigin wpOrigin = PATH_NO_PATH;
int32 wpPathId = 0; int32 wpPathId = 0;

View file

@ -4352,7 +4352,7 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/)
} }
uint32 faction = target->getFaction(); uint32 faction = target->getFaction();
uint32 NpcFlagss = target->GetUInt32Value(UNIT_NPC_FLAGS); uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS);
uint32 displayid = target->GetDisplayId(); uint32 displayid = target->GetDisplayId();
uint32 nativeid = target->GetNativeDisplayId(); uint32 nativeid = target->GetNativeDisplayId();
uint32 Entry = target->GetEntry(); uint32 Entry = target->GetEntry();
@ -4372,11 +4372,11 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/)
break; break;
if (diff < MAX_DIFFICULTY) if (diff < MAX_DIFFICULTY)
PSendSysMessage(LANG_NPCINFO_CHAR_DIFFICULTY, target->GetGuidStr().c_str(), faction, NpcFlagss, PSendSysMessage(LANG_NPCINFO_CHAR_DIFFICULTY, target->GetGuidStr().c_str(), faction, npcflags,
Entry, target->GetCreatureInfo()->Entry, diff, Entry, target->GetCreatureInfo()->Entry, diff,
displayid, nativeid); displayid, nativeid);
else else
PSendSysMessage(LANG_NPCINFO_CHAR, target->GetGuidStr().c_str(), faction, NpcFlagss, Entry, displayid, nativeid); PSendSysMessage(LANG_NPCINFO_CHAR, target->GetGuidStr().c_str(), faction, npcflags, Entry, displayid, nativeid);
PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel());
PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
@ -4386,11 +4386,11 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/)
PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId());
PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ()));
if ((NpcFlagss & UNIT_NPC_FLAG_VENDOR)) if ((npcflags & UNIT_NPC_FLAG_VENDOR))
{ {
SendSysMessage(LANG_NPCINFO_VENDOR); SendSysMessage(LANG_NPCINFO_VENDOR);
} }
if ((NpcFlagss & UNIT_NPC_FLAG_TRAINER)) if ((npcflags & UNIT_NPC_FLAG_TRAINER))
{ {
SendSysMessage(LANG_NPCINFO_TRAINER); SendSysMessage(LANG_NPCINFO_TRAINER);
} }
@ -5387,17 +5387,17 @@ bool ChatHandler::HandleServerRestartCommand(char* args)
{ {
uint32 delay; uint32 delay;
if (!ExtractUInt32(&args, delay)) if (!ExtractUInt32(&args, delay))
return false; { return false; }
uint32 exitcode; uint32 exitcode;
if (!ExtractOptUInt32(&args, exitcode, RESTART_EXIT_CODE)) if (!ExtractOptUInt32(&args, exitcode, RESTART_EXIT_CODE))
return false; { return false; }
// Exit code should be in range of 0-125, 126-255 is used // Exit code should be in range of 0-125, 126-255 is used
// in many shells for their own return codes and code > 255 // in many shells for their own return codes and code > 255
// is not supported in many others // is not supported in many others
if (exitcode > 125) if (exitcode > 125)
return false; { return false; }
sWorld.ShutdownServ(delay, SHUTDOWN_MASK_RESTART, exitcode); sWorld.ShutdownServ(delay, SHUTDOWN_MASK_RESTART, exitcode);
return true; return true;

View file

@ -311,7 +311,7 @@ bool ChatHandler::HandleDebugSendChannelNotifyCommand(char* args)
// Send notification in chat // Send notification in chat
bool ChatHandler::HandleDebugSendChatMsgCommand(char* args) bool ChatHandler::HandleDebugSendChatMsgCommand(char* args)
{ {
const char* msg = "testtest"; const char* msg = args;
uint32 type; uint32 type;
if (!ExtractUInt32(&args, type) || type > 255) if (!ExtractUInt32(&args, type) || type > 255)
@ -1120,7 +1120,7 @@ bool ChatHandler::HandleDebugSpellCoefsCommand(char* args)
direct_calc, direct_calc * SCALE_SPELLPOWER_HEALING, bonus ? bonus->direct_damage : 0.0f, bonus ? bonus->ap_bonus : 0.0f); direct_calc, direct_calc * SCALE_SPELLPOWER_HEALING, bonus ? bonus->direct_damage : 0.0f, bonus ? bonus->ap_bonus : 0.0f);
PSendSysMessage(LANG_SPELLCOEFS, spellid, isDotHeal ? dotHealStr : dotDamageStr, PSendSysMessage(LANG_SPELLCOEFS, spellid, isDotHeal ? dotHealStr : dotDamageStr,
dot_calc, dot_calc * SCALE_SPELLPOWER_HEALING, bonus ? bonus->dot_damage : 0.0f, bonus ? bonus->ap_dot_bonus : 0.0f); dot_calc, dot_calc * SCALE_SPELLPOWER_HEALING, bonus ? bonus->dot_damage : 0.0f, bonus ? bonus->ap_dot_bonus : 0.0f);
return true; return true;
} }

View file

@ -37,7 +37,7 @@ void ConfusedMovementGenerator<T>::Initialize(T& unit)
unit.GetPosition(i_x, i_y, i_z); unit.GetPosition(i_x, i_y, i_z);
if (!unit.IsAlive() || unit.hasUnitState(UNIT_STAT_NOT_MOVE)) if (!unit.IsAlive() || unit.hasUnitState(UNIT_STAT_NOT_MOVE))
return; { return; }
unit.StopMoving(); unit.StopMoving();
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE); unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
@ -57,7 +57,7 @@ void ConfusedMovementGenerator<T>::Reset(T& unit)
i_nextMoveTime.Reset(0); i_nextMoveTime.Reset(0);
if (!unit.IsAlive() || unit.hasUnitState(UNIT_STAT_NOT_MOVE)) if (!unit.IsAlive() || unit.hasUnitState(UNIT_STAT_NOT_MOVE))
return; { return; }
unit.StopMoving(); unit.StopMoving();
unit.addUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE); unit.addUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE);
@ -68,7 +68,7 @@ bool ConfusedMovementGenerator<T>::Update(T& unit, const uint32& diff)
{ {
// ignore in case other no reaction state // ignore in case other no reaction state
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_CONFUSED)) if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_CONFUSED))
return true; { return true; }
if (i_nextMoveTime.Passed()) if (i_nextMoveTime.Passed())
{ {
@ -76,7 +76,7 @@ bool ConfusedMovementGenerator<T>::Update(T& unit, const uint32& diff)
unit.addUnitState(UNIT_STAT_CONFUSED_MOVE); unit.addUnitState(UNIT_STAT_CONFUSED_MOVE);
if (unit.movespline->Finalized()) if (unit.movespline->Finalized())
i_nextMoveTime.Reset(urand(800, 1500)); { i_nextMoveTime.Reset(urand(800, 1500)); }
} }
else else
{ {

View file

@ -28,7 +28,7 @@
#include "MovementGenerator.h" #include "MovementGenerator.h"
template<class T> template<class T>
class ConfusedMovementGenerator class ConfusedMovementGenerator
: public MovementGeneratorMedium< T, ConfusedMovementGenerator<T> > : public MovementGeneratorMedium< T, ConfusedMovementGenerator<T> >
{ {
public: public:

View file

@ -39,7 +39,7 @@ void FleeingMovementGenerator<T>::_setTargetLocation(T& owner)
{ {
// ignore in case other no reaction state // ignore in case other no reaction state
if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING)) if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING))
return; { return; }
float x, y, z; float x, y, z;
if (!_getPoint(owner, x, y, z)) if (!_getPoint(owner, x, y, z))
@ -76,9 +76,9 @@ bool FleeingMovementGenerator<T>::_getPoint(T& owner, float& x, float& y, float&
{ {
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); }
} }
else else
{ {
@ -113,7 +113,7 @@ bool FleeingMovementGenerator<T>::_getPoint(T& owner, float& x, float& y, float&
// try to fix z // try to fix z
if (!owner.GetMap()->GetHeightInRange(owner.GetPhaseMask(), x, y, z)) if (!owner.GetMap()->GetHeightInRange(owner.GetPhaseMask(), x, y, z))
return false; return false;
if (owner.GetTypeId() == TYPEID_PLAYER) if (owner.GetTypeId() == TYPEID_PLAYER)
{ {
// check any collision // check any collision
@ -172,7 +172,7 @@ 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.IsAlive()) if (!owner.IsAlive())
return false; { return false; }
// ignore in case other no reaction state // ignore in case other no reaction state
if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING)) if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING))
@ -183,7 +183,7 @@ bool FleeingMovementGenerator<T>::Update(T& owner, const uint32& time_diff)
i_nextCheckTime.Update(time_diff); i_nextCheckTime.Update(time_diff);
if (i_nextCheckTime.Passed() && owner.movespline->Finalized()) if (i_nextCheckTime.Passed() && owner.movespline->Finalized())
_setTargetLocation(owner); { _setTargetLocation(owner); }
return true; return true;
} }
@ -217,7 +217,7 @@ 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
if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING)) if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING))
@ -228,7 +228,7 @@ bool TimedFleeingMovementGenerator::Update(Unit& owner, const uint32& time_diff)
i_totalFleeTime.Update(time_diff); i_totalFleeTime.Update(time_diff);
if (i_totalFleeTime.Passed()) if (i_totalFleeTime.Passed())
return false; { return false; }
// This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32 &) version // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32 &) version
// This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly // This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly

View file

@ -29,7 +29,7 @@
#include "ObjectGuid.h" #include "ObjectGuid.h"
template<class T> template<class T>
class FleeingMovementGenerator class FleeingMovementGenerator
: public MovementGeneratorMedium< T, FleeingMovementGenerator<T> > : public MovementGeneratorMedium< T, FleeingMovementGenerator<T> >
{ {
public: public:
@ -51,7 +51,7 @@ class FleeingMovementGenerator
TimeTracker i_nextCheckTime; TimeTracker i_nextCheckTime;
}; };
class TimedFleeingMovementGenerator class TimedFleeingMovementGenerator
: public FleeingMovementGenerator<Creature> : public FleeingMovementGenerator<Creature>
{ {
public: public:

View file

@ -42,7 +42,7 @@ 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; }
Movement::MoveSplineInit init(owner); Movement::MoveSplineInit init(owner);
float x, y, z, o; float x, y, z, o;
@ -72,7 +72,7 @@ void HomeMovementGenerator<Creature>::Finalize(Creature& owner)
if (arrived) if (arrived)
{ {
if (owner.GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_REACH_HOME) if (owner.GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_REACH_HOME)
owner.ClearTemporaryFaction(); { owner.ClearTemporaryFaction(); }
owner.SetWalk(!owner.hasUnitState(UNIT_STAT_RUNNING_STATE) && !owner.IsLevitating(), false); owner.SetWalk(!owner.hasUnitState(UNIT_STAT_RUNNING_STATE) && !owner.IsLevitating(), false);
owner.LoadCreatureAddon(true); owner.LoadCreatureAddon(true);

View file

@ -30,10 +30,10 @@
class Creature; class Creature;
template < class T > template < class T >
class HomeMovementGenerator; class HomeMovementGenerator;
template <> template <>
class HomeMovementGenerator<Creature> class HomeMovementGenerator<Creature>
: public MovementGeneratorMedium< Creature, HomeMovementGenerator<Creature> > : public MovementGeneratorMedium< Creature, HomeMovementGenerator<Creature> >
{ {
public: public:

View file

@ -60,7 +60,7 @@ 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;
return true; return true;

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -27,7 +27,7 @@
#include "MovementGenerator.h" #include "MovementGenerator.h"
class IdleMovementGenerator : public MovementGenerator class IdleMovementGenerator : public MovementGenerator
{ {
public: public:
@ -41,7 +41,7 @@ class IdleMovementGenerator : public MovementGenerator
extern IdleMovementGenerator si_idleMovement; extern IdleMovementGenerator si_idleMovement;
class DistractMovementGenerator : public MovementGenerator class DistractMovementGenerator : public MovementGenerator
{ {
public: public:
explicit DistractMovementGenerator(uint32 timer) : m_timer(timer) {} explicit DistractMovementGenerator(uint32 timer) : m_timer(timer) {}
@ -57,7 +57,7 @@ class DistractMovementGenerator : public MovementGenerator
uint32 m_timer; uint32 m_timer;
}; };
class AssistanceDistractMovementGenerator : public DistractMovementGenerator class AssistanceDistractMovementGenerator : public DistractMovementGenerator
{ {
public: public:
AssistanceDistractMovementGenerator(uint32 timer) : AssistanceDistractMovementGenerator(uint32 timer) :

View file

@ -65,7 +65,7 @@ void MotionMaster::Initialize()
(static_cast<WaypointMovementGenerator<Creature>*>(top()))->InitializeWaypointPath(*((Creature*)(m_owner)), 0, PATH_NO_PATH, 0, 0); (static_cast<WaypointMovementGenerator<Creature>*>(top()))->InitializeWaypointPath(*((Creature*)(m_owner)), 0, PATH_NO_PATH, 0, 0);
} }
else else
push(&si_idleMovement); { push(&si_idleMovement); }
} }
MotionMaster::~MotionMaster() MotionMaster::~MotionMaster()
@ -76,14 +76,14 @@ MotionMaster::~MotionMaster()
MovementGenerator* m = top(); MovementGenerator* m = top();
pop(); pop();
if (!isStatic(m)) if (!isStatic(m))
delete m; { delete m; }
} }
} }
void MotionMaster::UpdateMotion(uint32 diff) void MotionMaster::UpdateMotion(uint32 diff)
{ {
if (m_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE)) if (m_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE))
return; { return; }
MANGOS_ASSERT(!empty()); MANGOS_ASSERT(!empty());
m_cleanFlag |= MMCF_UPDATE; m_cleanFlag |= MMCF_UPDATE;
@ -94,7 +94,7 @@ void MotionMaster::UpdateMotion(uint32 diff)
MovementExpired(); MovementExpired();
} }
else else
m_cleanFlag &= ~MMCF_UPDATE; { m_cleanFlag &= ~MMCF_UPDATE; }
if (m_expList) if (m_expList)
{ {
@ -102,14 +102,14 @@ void MotionMaster::UpdateMotion(uint32 diff)
{ {
MovementGenerator* mg = (*m_expList)[i]; MovementGenerator* mg = (*m_expList)[i];
if (!isStatic(mg)) if (!isStatic(mg))
delete mg; { delete mg; }
} }
delete m_expList; delete m_expList;
m_expList = NULL; m_expList = NULL;
if (empty()) if (empty())
Initialize(); { Initialize(); }
if (m_cleanFlag & MMCF_RESET) if (m_cleanFlag & MMCF_RESET)
{ {
@ -128,7 +128,7 @@ void MotionMaster::DirectClean(bool reset, bool all)
curr->Finalize(*m_owner); curr->Finalize(*m_owner);
if (!isStatic(curr)) if (!isStatic(curr))
delete curr; { delete curr; }
} }
if (!all && reset) if (!all && reset)
@ -141,15 +141,15 @@ void MotionMaster::DirectClean(bool reset, bool all)
void MotionMaster::DelayedClean(bool reset, bool all) void MotionMaster::DelayedClean(bool reset, bool all)
{ {
if (reset) if (reset)
m_cleanFlag |= MMCF_RESET; { m_cleanFlag |= MMCF_RESET; }
else else
m_cleanFlag &= ~MMCF_RESET; { m_cleanFlag &= ~MMCF_RESET; }
if (empty() || (!all && size() == 1)) if (empty() || (!all && size() == 1))
return; { return; }
if (!m_expList) if (!m_expList)
m_expList = new ExpireList(); { m_expList = new ExpireList(); }
while (all ? !empty() : size() > 1) while (all ? !empty() : size() > 1)
{ {
@ -158,14 +158,14 @@ void MotionMaster::DelayedClean(bool reset, bool all)
curr->Finalize(*m_owner); curr->Finalize(*m_owner);
if (!isStatic(curr)) if (!isStatic(curr))
m_expList->push_back(curr); { m_expList->push_back(curr); }
} }
} }
void MotionMaster::DirectExpire(bool reset) void MotionMaster::DirectExpire(bool reset)
{ {
if (empty() || size() == 1) if (empty() || size() == 1)
return; { return; }
MovementGenerator* curr = top(); MovementGenerator* curr = top();
pop(); pop();
@ -185,31 +185,31 @@ void MotionMaster::DirectExpire(bool reset)
curr->Finalize(*m_owner); curr->Finalize(*m_owner);
if (!isStatic(curr)) if (!isStatic(curr))
delete curr; { delete curr; }
if (empty()) if (empty())
Initialize(); { Initialize(); }
// Prevent reseting possible new pushed MMGen // Prevent reseting possible new pushed MMGen
if (reset && top() == nowTop) if (reset && top() == nowTop)
top()->Reset(*m_owner); { top()->Reset(*m_owner); }
} }
void MotionMaster::DelayedExpire(bool reset) void MotionMaster::DelayedExpire(bool reset)
{ {
if (reset) if (reset)
m_cleanFlag |= MMCF_RESET; { m_cleanFlag |= MMCF_RESET; }
else else
m_cleanFlag &= ~MMCF_RESET; { m_cleanFlag &= ~MMCF_RESET; }
if (empty() || size() == 1) if (empty() || size() == 1)
return; { return; }
MovementGenerator* curr = top(); MovementGenerator* curr = top();
pop(); pop();
if (!m_expList) if (!m_expList)
m_expList = new ExpireList(); { m_expList = new ExpireList(); }
// also drop stored under top() targeted motions // also drop stored under top() targeted motions
while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)) while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE))
@ -223,13 +223,13 @@ void MotionMaster::DelayedExpire(bool reset)
curr->Finalize(*m_owner); curr->Finalize(*m_owner);
if (!isStatic(curr)) if (!isStatic(curr))
m_expList->push_back(curr); { m_expList->push_back(curr); }
} }
void MotionMaster::MoveIdle() void MotionMaster::MoveIdle()
{ {
if (empty() || !isStatic(top())) if (empty() || !isStatic(top()))
push(&si_idleMovement); { push(&si_idleMovement); }
} }
void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius, float verticalZ) void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius, float verticalZ)
@ -248,7 +248,7 @@ void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius
void MotionMaster::MoveTargetedHome() void MotionMaster::MoveTargetedHome()
{ {
if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL)) if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL))
return; { return; }
Clear(false); Clear(false);
@ -256,7 +256,7 @@ void MotionMaster::MoveTargetedHome()
{ {
// Manual exception for linked mobs // Manual exception for linked mobs
if (m_owner->IsLinkingEventTrigger() && m_owner->GetMap()->GetCreatureLinkingHolder()->TryFollowMaster((Creature*)m_owner)) if (m_owner->IsLinkingEventTrigger() && m_owner->GetMap()->GetCreatureLinkingHolder()->TryFollowMaster((Creature*)m_owner))
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s refollowed linked master", m_owner->GetGuidStr().c_str()); { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s refollowed linked master", m_owner->GetGuidStr().c_str()); }
else else
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted home", m_owner->GetGuidStr().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted home", m_owner->GetGuidStr().c_str());
@ -276,7 +276,7 @@ void MotionMaster::MoveTargetedHome()
} }
} }
else else
sLog.outError("%s attempt targeted home", m_owner->GetGuidStr().c_str()); { sLog.outError("%s attempt targeted home", m_owner->GetGuidStr().c_str()); }
} }
void MotionMaster::MoveConfused() void MotionMaster::MoveConfused()
@ -284,42 +284,42 @@ void MotionMaster::MoveConfused()
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move confused", m_owner->GetGuidStr().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move confused", m_owner->GetGuidStr().c_str());
if (m_owner->GetTypeId() == TYPEID_PLAYER) if (m_owner->GetTypeId() == TYPEID_PLAYER)
Mutate(new ConfusedMovementGenerator<Player>()); { Mutate(new ConfusedMovementGenerator<Player>()); }
else else
Mutate(new ConfusedMovementGenerator<Creature>()); { Mutate(new ConfusedMovementGenerator<Creature>()); }
} }
void MotionMaster::MoveChase(Unit* target, float dist, float angle) void MotionMaster::MoveChase(Unit* target, float dist, float angle)
{ {
// ignore movement request if target not exist // ignore movement request if target not exist
if (!target) if (!target)
return; { return; }
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s chase to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s chase to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str());
if (m_owner->GetTypeId() == TYPEID_PLAYER) if (m_owner->GetTypeId() == TYPEID_PLAYER)
Mutate(new ChaseMovementGenerator<Player>(*target, dist, angle)); { Mutate(new ChaseMovementGenerator<Player>(*target, dist, angle)); }
else else
Mutate(new ChaseMovementGenerator<Creature>(*target, dist, angle)); { Mutate(new ChaseMovementGenerator<Creature>(*target, dist, angle)); }
} }
void MotionMaster::MoveFollow(Unit* target, float dist, float angle) void MotionMaster::MoveFollow(Unit* target, float dist, float angle)
{ {
if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL)) if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL))
return; { return; }
Clear(); Clear();
// ignore movement request if target not exist // ignore movement request if target not exist
if (!target) if (!target)
return; { return; }
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str());
if (m_owner->GetTypeId() == TYPEID_PLAYER) if (m_owner->GetTypeId() == TYPEID_PLAYER)
Mutate(new FollowMovementGenerator<Player>(*target, dist, angle)); { Mutate(new FollowMovementGenerator<Player>(*target, dist, angle)); }
else else
Mutate(new FollowMovementGenerator<Creature>(*target, dist, angle)); { Mutate(new FollowMovementGenerator<Creature>(*target, dist, angle)); }
} }
void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath) void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath)
@ -327,9 +327,9 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generate
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), id, x, y, z); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), id, x, y, z);
if (m_owner->GetTypeId() == TYPEID_PLAYER) if (m_owner->GetTypeId() == TYPEID_PLAYER)
Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath)); { Mutate(new PointMovementGenerator<Player>(id, x, y, z, generatePath)); }
else else
Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath)); { Mutate(new PointMovementGenerator<Creature>(id, x, y, z, generatePath)); }
} }
void MotionMaster::MoveSeekAssistance(float x, float y, float z) void MotionMaster::MoveSeekAssistance(float x, float y, float z)
@ -363,18 +363,18 @@ void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
void MotionMaster::MoveFleeing(Unit* enemy, uint32 time) void MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
{ {
if (!enemy) if (!enemy)
return; { return; }
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetGuidStr().c_str(), enemy->GetGuidStr().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetGuidStr().c_str(), enemy->GetGuidStr().c_str());
if (m_owner->GetTypeId() == TYPEID_PLAYER) if (m_owner->GetTypeId() == TYPEID_PLAYER)
Mutate(new FleeingMovementGenerator<Player>(enemy->GetObjectGuid())); { Mutate(new FleeingMovementGenerator<Player>(enemy->GetObjectGuid())); }
else else
{ {
if (time) if (time)
Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time)); { Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time)); }
else else
Mutate(new FleeingMovementGenerator<Creature>(enemy->GetObjectGuid())); { Mutate(new FleeingMovementGenerator<Creature>(enemy->GetObjectGuid())); }
} }
} }
@ -434,7 +434,7 @@ void MotionMaster::MoveDistract(uint32 timer)
void MotionMaster::MoveFlyOrLand(uint32 id, float x, float y, float z, bool liftOff) void MotionMaster::MoveFlyOrLand(uint32 id, float x, float y, float z, bool liftOff)
{ {
if (m_owner->GetTypeId() != TYPEID_UNIT) if (m_owner->GetTypeId() != TYPEID_UNIT)
return; { return; }
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point for %s (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), liftOff ? "liftoff" : "landing", id, x, y, z); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point for %s (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), liftOff ? "liftoff" : "landing", id, x, y, z);
Mutate(new FlyOrLandMovementGenerator(id, x, y, z, liftOff)); Mutate(new FlyOrLandMovementGenerator(id, x, y, z, liftOff));
@ -457,7 +457,7 @@ void MotionMaster::Mutate(MovementGenerator* m)
} }
if (!empty()) if (!empty())
top()->Interrupt(*m_owner); { top()->Interrupt(*m_owner); }
} }
m->Initialize(*m_owner); m->Initialize(*m_owner);
@ -488,7 +488,7 @@ uint32 MotionMaster::getLastReachedWaypoint() const
for (Impl::container_type::const_reverse_iterator rItr = Impl::c.rbegin(); rItr != Impl::c.rend(); ++rItr) for (Impl::container_type::const_reverse_iterator rItr = Impl::c.rbegin(); rItr != Impl::c.rend(); ++rItr)
{ {
if ((*rItr)->GetMovementGeneratorType() == WAYPOINT_MOTION_TYPE) if ((*rItr)->GetMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
return (static_cast<WaypointMovementGenerator<Creature>*>(*rItr))->getLastReachedWaypoint(); { return (static_cast<WaypointMovementGenerator<Creature>*>(*rItr))->getLastReachedWaypoint(); }
} }
return 0; return 0;
} }
@ -496,7 +496,7 @@ uint32 MotionMaster::getLastReachedWaypoint() const
MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const
{ {
if (empty()) if (empty())
return IDLE_MOTION_TYPE; { return IDLE_MOTION_TYPE; }
return top()->GetMovementGeneratorType(); return top()->GetMovementGeneratorType();
} }
@ -516,7 +516,7 @@ void MotionMaster::GetWaypointPathInformation(std::ostringstream& oss) const
bool MotionMaster::GetDestination(float& x, float& y, float& z) bool MotionMaster::GetDestination(float& x, float& y, float& z)
{ {
if (m_owner->movespline->Finalized()) if (m_owner->movespline->Finalized())
return false; { return false; }
const G3D::Vector3& dest = m_owner->movespline->FinalDestination(); const G3D::Vector3& dest = m_owner->movespline->FinalDestination();
x = dest.x; x = dest.x;
@ -558,7 +558,7 @@ void MotionMaster::MoveFall()
// Abort too if the ground is very near // Abort too if the ground is very near
if (fabs(m_owner->GetPositionZ() - tz) < 0.1f) if (fabs(m_owner->GetPositionZ() - tz) < 0.1f)
return; { return; }
Movement::MoveSplineInit init(*m_owner); Movement::MoveSplineInit init(*m_owner);
init.MoveTo(m_owner->GetPositionX(), m_owner->GetPositionY(), tz); init.MoveTo(m_owner->GetPositionX(), m_owner->GetPositionY(), tz);

View file

@ -68,7 +68,7 @@ enum MMCleanFlag
MMCF_RESET = 2 // Flag if need top()->Reset() MMCF_RESET = 2 // Flag if need top()->Reset()
}; };
class MotionMaster : private std::stack<MovementGenerator*> class MotionMaster : private std::stack<MovementGenerator*>
{ {
private: private:
typedef std::stack<MovementGenerator*> Impl; typedef std::stack<MovementGenerator*> Impl;
@ -95,16 +95,16 @@ class MotionMaster : private std::stack<MovementGenerator*>
void Clear(bool reset = true, bool all = false) void Clear(bool reset = true, bool all = false)
{ {
if (m_cleanFlag & MMCF_UPDATE) if (m_cleanFlag & MMCF_UPDATE)
DelayedClean(reset, all); { DelayedClean(reset, all); }
else else
DirectClean(reset, all); { DirectClean(reset, all); }
} }
void MovementExpired(bool reset = true) void MovementExpired(bool reset = true)
{ {
if (m_cleanFlag & MMCF_UPDATE) if (m_cleanFlag & MMCF_UPDATE)
DelayedExpire(reset); { DelayedExpire(reset); }
else else
DirectExpire(reset); { DirectExpire(reset); }
} }
void MoveIdle(); void MoveIdle();
@ -129,9 +129,9 @@ class MotionMaster : private std::stack<MovementGenerator*>
void propagateSpeedChange(); void propagateSpeedChange();
bool SetNextWaypoint(uint32 pointId); bool SetNextWaypoint(uint32 pointId);
uint32 getLastReachedWaypoint() const; uint32 getLastReachedWaypoint() const;
void GetWaypointPathInformation(std::ostringstream& oss) const; void GetWaypointPathInformation(std::ostringstream& oss) const;
bool GetDestination(float& x, float& y, float& z); bool GetDestination(float& x, float& y, float& z);
private: private:

View file

@ -37,7 +37,7 @@ class Unit;
class Creature; class Creature;
class Player; class Player;
class MovementGenerator class MovementGenerator
{ {
public: public:
virtual ~MovementGenerator(); virtual ~MovementGenerator();
@ -70,7 +70,7 @@ class MovementGenerator
}; };
template<class T, class D> template<class T, class D>
class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator class MovementGeneratorMedium : public MovementGenerator
{ {
public: public:
void Initialize(Unit& u) override void Initialize(Unit& u) override

View file

@ -101,7 +101,6 @@ class PathFinder
const dtNavMeshQuery* m_navMeshQuery; // the nav mesh query used to find the path const dtNavMeshQuery* m_navMeshQuery; // the nav mesh query used to find the path
dtQueryFilter m_filter; // use single filter for all movements, update it when needed dtQueryFilter m_filter; // use single filter for all movements, update it when needed
void setStartPosition(const Vector3& point) { m_startPosition = point; } void setStartPosition(const Vector3& point) { m_startPosition = point; }
void setEndPosition(const Vector3& point) { m_actualEndPosition = point; m_endPosition = point; } void setEndPosition(const Vector3& point) { m_actualEndPosition = point; m_endPosition = point; }

View file

@ -36,7 +36,7 @@ template<class T>
void PointMovementGenerator<T>::Initialize(T& unit) void PointMovementGenerator<T>::Initialize(T& unit)
{ {
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE)) if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE))
return; { return; }
unit.StopMoving(); unit.StopMoving();
@ -52,7 +52,7 @@ void PointMovementGenerator<T>::Finalize(T& unit)
unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
if (unit.movespline->Finalized()) if (unit.movespline->Finalized())
MovementInform(unit); { MovementInform(unit); }
} }
template<class T> template<class T>
@ -79,7 +79,7 @@ bool PointMovementGenerator<T>::Update(T& unit, const uint32& diff)
} }
if (!unit.hasUnitState(UNIT_STAT_ROAMING_MOVE) && unit.movespline->Finalized()) if (!unit.hasUnitState(UNIT_STAT_ROAMING_MOVE) && unit.movespline->Finalized())
Initialize(unit); { Initialize(unit); }
return !unit.movespline->Finalized(); return !unit.movespline->Finalized();
} }
@ -93,7 +93,7 @@ template <>
void PointMovementGenerator<Creature>::MovementInform(Creature& unit) void PointMovementGenerator<Creature>::MovementInform(Creature& unit)
{ {
if (unit.AI()) if (unit.AI())
unit.AI()->MovementInform(POINT_MOTION_TYPE, id); { unit.AI()->MovementInform(POINT_MOTION_TYPE, id); }
if (unit.IsTemporarySummon()) if (unit.IsTemporarySummon())
{ {
@ -101,7 +101,7 @@ void PointMovementGenerator<Creature>::MovementInform(Creature& unit)
if (pSummon->GetSummonerGuid().IsCreatureOrVehicle()) if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
if (Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid()))
if (pSummoner->AI()) if (pSummoner->AI())
pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); { pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); }
} }
} }
@ -123,7 +123,7 @@ void AssistanceMovementGenerator::Finalize(Unit& unit)
((Creature*)&unit)->SetNoCallAssistance(false); ((Creature*)&unit)->SetNoCallAssistance(false);
((Creature*)&unit)->CallAssistance(); ((Creature*)&unit)->CallAssistance();
if (unit.IsAlive()) if (unit.IsAlive())
unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY)); { unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY)); }
} }
bool EffectMovementGenerator::Update(Unit& unit, const uint32&) bool EffectMovementGenerator::Update(Unit& unit, const uint32&)
@ -134,24 +134,24 @@ bool EffectMovementGenerator::Update(Unit& unit, const uint32&)
void EffectMovementGenerator::Finalize(Unit& unit) void EffectMovementGenerator::Finalize(Unit& unit)
{ {
if (unit.GetTypeId() != TYPEID_UNIT) if (unit.GetTypeId() != TYPEID_UNIT)
return; { return; }
if (((Creature&)unit).AI() && unit.movespline->Finalized()) if (((Creature&)unit).AI() && unit.movespline->Finalized())
((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id); { ((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id); }
// Need restore previous movement since we have no proper states system // Need restore previous movement since we have no proper states system
if (unit.IsAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_NO_COMBAT_MOVEMENT)) if (unit.IsAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_NO_COMBAT_MOVEMENT))
{ {
if (Unit* victim = unit.getVictim()) if (Unit* victim = unit.getVictim())
unit.GetMotionMaster()->MoveChase(victim); { unit.GetMotionMaster()->MoveChase(victim); }
else else
unit.GetMotionMaster()->Initialize(); { unit.GetMotionMaster()->Initialize(); }
} }
} }
void FlyOrLandMovementGenerator::Initialize(Unit& unit) void FlyOrLandMovementGenerator::Initialize(Unit& unit)
{ {
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE)) if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE))
return; { return; }
unit.StopMoving(); unit.StopMoving();

View file

@ -28,7 +28,7 @@
#include "MovementGenerator.h" #include "MovementGenerator.h"
template<class T> template<class T>
class PointMovementGenerator class PointMovementGenerator
: public MovementGeneratorMedium< T, PointMovementGenerator<T> > : public MovementGeneratorMedium< T, PointMovementGenerator<T> >
{ {
public: public:
@ -52,7 +52,7 @@ class PointMovementGenerator
bool m_generatePath; bool m_generatePath;
}; };
class AssistanceMovementGenerator class AssistanceMovementGenerator
: public PointMovementGenerator<Creature> : public PointMovementGenerator<Creature>
{ {
public: public:
@ -78,7 +78,7 @@ class EffectMovementGenerator : public MovementGenerator
uint32 m_Id; uint32 m_Id;
}; };
class FlyOrLandMovementGenerator : public PointMovementGenerator<Creature> class FlyOrLandMovementGenerator : public PointMovementGenerator<Creature>
{ {
public: public:
FlyOrLandMovementGenerator(uint32 _id, float _x, float _y, float _z, bool liftOff) : FlyOrLandMovementGenerator(uint32 _id, float _x, float _y, float _z, bool liftOff) :

View file

@ -104,7 +104,7 @@ void RandomMovementGenerator<Creature>::Initialize(Creature& creature)
creature.addUnitState(UNIT_STAT_ROAMING); // _MOVE set in _setRandomLocation creature.addUnitState(UNIT_STAT_ROAMING); // _MOVE set in _setRandomLocation
if (!creature.IsAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE)) if (!creature.IsAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
return; { return; }
_setRandomLocation(creature); _setRandomLocation(creature);
} }
@ -144,7 +144,7 @@ bool RandomMovementGenerator<Creature>::Update(Creature& creature, const uint32&
{ {
i_nextMoveTime.Update(diff); i_nextMoveTime.Update(diff);
if (i_nextMoveTime.Passed()) if (i_nextMoveTime.Passed())
_setRandomLocation(creature); { _setRandomLocation(creature); }
} }
return true; return true;
} }

View file

@ -31,7 +31,7 @@
#define MOVEMENT_RANDOM_MMGEN_CHANCE_NO_BREAK 30 #define MOVEMENT_RANDOM_MMGEN_CHANCE_NO_BREAK 30
template<class T> template<class T>
class RandomMovementGenerator class RandomMovementGenerator
: public MovementGeneratorMedium< T, RandomMovementGenerator<T> > : public MovementGeneratorMedium< T, RandomMovementGenerator<T> >
{ {
public: public:

View file

@ -38,10 +38,10 @@ template<class T, typename D>
void TargetedMovementGeneratorMedium<T, D>::_setTargetLocation(T& owner, bool updateDestination) void TargetedMovementGeneratorMedium<T, D>::_setTargetLocation(T& owner, bool updateDestination)
{ {
if (!i_target.isValid() || !i_target->IsInWorld()) if (!i_target.isValid() || !i_target->IsInWorld())
return; { return; }
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE)) if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
return; { return; }
float x, y, z; float x, y, z;
@ -55,7 +55,7 @@ void TargetedMovementGeneratorMedium<T, D>::_setTargetLocation(T& owner, bool up
if (!RequiresNewPosition(owner, x, y, z)) if (!RequiresNewPosition(owner, x, y, z))
{ {
if (!owner.movespline->Finalized()) if (!owner.movespline->Finalized())
return; { return; }
} }
// Chase Movement and angle == 0 case: Chase to current angle // Chase Movement and angle == 0 case: Chase to current angle
else if (this->GetMovementGeneratorType() == CHASE_MOTION_TYPE && i_angle == 0.0f) else if (this->GetMovementGeneratorType() == CHASE_MOTION_TYPE && i_angle == 0.0f)
@ -78,14 +78,14 @@ void TargetedMovementGeneratorMedium<T, D>::_setTargetLocation(T& owner, bool up
} }
if (!i_path) if (!i_path)
i_path = new PathFinder(&owner); { i_path = new PathFinder(&owner); }
// allow pets following their master to cheat while generating paths // allow pets following their master to cheat while generating paths
bool forceDest = (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->IsPet() bool forceDest = (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->IsPet()
&& owner.hasUnitState(UNIT_STAT_FOLLOW)); && owner.hasUnitState(UNIT_STAT_FOLLOW));
i_path->calculate(x, y, z, forceDest); i_path->calculate(x, y, z, forceDest);
if (i_path->getPathType() & PATHFIND_NOPATH) if (i_path->getPathType() & PATHFIND_NOPATH)
return; { return; }
D::_addUnitStateMove(owner); D::_addUnitStateMove(owner);
i_targetReached = false; i_targetReached = false;
@ -101,10 +101,10 @@ template<class T, typename D>
bool TargetedMovementGeneratorMedium<T, D>::Update(T& owner, const uint32& time_diff) bool TargetedMovementGeneratorMedium<T, D>::Update(T& owner, const uint32& time_diff)
{ {
if (!i_target.isValid() || !i_target->IsInWorld()) if (!i_target.isValid() || !i_target->IsInWorld())
return false; { return false; }
if (!owner.IsAlive()) if (!owner.IsAlive())
return true; { return true; }
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE)) if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
{ {
@ -122,7 +122,7 @@ bool TargetedMovementGeneratorMedium<T, D>::Update(T& owner, const uint32& time_
if (owner.IsNonMeleeSpellCasted(false, false, true)) if (owner.IsNonMeleeSpellCasted(false, false, true))
{ {
if (!owner.IsStopped()) if (!owner.IsStopped())
owner.StopMoving(); { owner.StopMoving(); }
return true; return true;
} }
@ -139,17 +139,16 @@ bool TargetedMovementGeneratorMedium<T, D>::Update(T& owner, const uint32& time_
{ {
i_recheckDistance.Reset(this->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE ? 50 : 100); i_recheckDistance.Reset(this->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE ? 50 : 100);
G3D::Vector3 dest = owner.movespline->FinalDestination(); G3D::Vector3 dest = owner.movespline->FinalDestination();
targetMoved = RequiresNewPosition(owner, dest.x, dest.y, dest.z); targetMoved = RequiresNewPosition(owner, dest.x, dest.y, dest.z);
} }
if (m_speedChanged || targetMoved) if (m_speedChanged || targetMoved)
_setTargetLocation(owner, targetMoved); { _setTargetLocation(owner, targetMoved); }
if (owner.movespline->Finalized()) if (owner.movespline->Finalized())
{ {
if (i_angle == 0.f && !owner.HasInArc(0.01f, i_target.getTarget())) if (i_angle == 0.f && !owner.HasInArc(0.01f, i_target.getTarget()))
owner.SetInFront(i_target.getTarget()); { owner.SetInFront(i_target.getTarget()); }
if (!i_targetReached) if (!i_targetReached)
{ {
@ -171,9 +170,9 @@ bool TargetedMovementGeneratorMedium<T, D>::RequiresNewPosition(T& owner, float
{ {
// More distance let have better performance, less distance let have more sensitive reaction at target move. // More distance let have better performance, less distance let have more sensitive reaction at target move.
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly()) if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly())
return !i_target->IsWithinDist3d(x, y, z, this->GetDynamicTargetDistance(owner, true)); { return !i_target->IsWithinDist3d(x, y, z, this->GetDynamicTargetDistance(owner, true)); }
else else
return !i_target->IsWithinDist2d(x, y, this->GetDynamicTargetDistance(owner, true)); { return !i_target->IsWithinDist2d(x, y, this->GetDynamicTargetDistance(owner, true)); }
} }
//-----------------------------------------------// //-----------------------------------------------//
@ -192,7 +191,7 @@ template<class T>
void ChaseMovementGenerator<T>::_reachTarget(T& owner) void ChaseMovementGenerator<T>::_reachTarget(T& owner)
{ {
if (owner.CanReachWithMeleeAttack(this->i_target.getTarget())) if (owner.CanReachWithMeleeAttack(this->i_target.getTarget()))
owner.Attack(this->i_target.getTarget(), true); { owner.Attack(this->i_target.getTarget(), true); }
} }
template<> template<>
@ -237,7 +236,7 @@ template<class T>
float ChaseMovementGenerator<T>::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const float ChaseMovementGenerator<T>::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const
{ {
if (!forRangeCheck) if (!forRangeCheck)
return this->i_offset + CHASE_DEFAULT_RANGE_FACTOR * this->i_target->GetCombatReach(&owner); { return this->i_offset + CHASE_DEFAULT_RANGE_FACTOR * this->i_target->GetCombatReach(&owner); }
return CHASE_RECHASE_RANGE_FACTOR * this->i_target->GetCombatReach(&owner) - this->i_target->GetObjectBoundingRadius(); return CHASE_RECHASE_RANGE_FACTOR * this->i_target->GetCombatReach(&owner) - this->i_target->GetObjectBoundingRadius();
} }
@ -261,7 +260,7 @@ bool FollowMovementGenerator<Player>::EnableWalking() const
} }
template<> template<>
void FollowMovementGenerator<Player>::_updateSpeed(Player &/*u*/) void FollowMovementGenerator<Player>::_updateSpeed(Player& /*u*/)
{ {
// nothing to do for Player // nothing to do for Player
} }
@ -271,7 +270,7 @@ void FollowMovementGenerator<Creature>::_updateSpeed(Creature& u)
{ {
// pet only sync speed with owner // pet only sync speed with owner
if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid()) if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid())
return; { return; }
u.UpdateSpeed(MOVE_RUN, true); u.UpdateSpeed(MOVE_RUN, true);
u.UpdateSpeed(MOVE_WALK, true); u.UpdateSpeed(MOVE_WALK, true);
@ -327,12 +326,12 @@ template<class T>
float FollowMovementGenerator<T>::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const float FollowMovementGenerator<T>::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const
{ {
if (!forRangeCheck) if (!forRangeCheck)
return this->i_offset + owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius(); { return this->i_offset + owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius(); }
float allowed_dist = sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE) - this->i_target->GetObjectBoundingRadius(); float allowed_dist = sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE) - this->i_target->GetObjectBoundingRadius();
allowed_dist += FOLLOW_RECALCULATE_FACTOR * (owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius()); allowed_dist += FOLLOW_RECALCULATE_FACTOR * (owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius());
if (this->i_offset > FOLLOW_DIST_GAP_FOR_DIST_FACTOR) if (this->i_offset > FOLLOW_DIST_GAP_FOR_DIST_FACTOR)
allowed_dist += FOLLOW_DIST_RECALCULATE_FACTOR * this->i_offset; { allowed_dist += FOLLOW_DIST_RECALCULATE_FACTOR * this->i_offset; }
return allowed_dist; return allowed_dist;
} }

View file

@ -30,7 +30,7 @@
class PathFinder; class PathFinder;
class TargetedMovementGeneratorBase class TargetedMovementGeneratorBase
{ {
public: public:
TargetedMovementGeneratorBase(Unit& target) { i_target.link(&target, this); } TargetedMovementGeneratorBase(Unit& target) { i_target.link(&target, this); }
@ -40,7 +40,7 @@ class TargetedMovementGeneratorBase
}; };
template<class T, typename D> template<class T, typename D>
class TargetedMovementGeneratorMedium class TargetedMovementGeneratorMedium
: public MovementGeneratorMedium< T, D >, public TargetedMovementGeneratorBase : public MovementGeneratorMedium< T, D >, public TargetedMovementGeneratorBase
{ {
protected: protected:
@ -78,7 +78,7 @@ class TargetedMovementGeneratorMedium
}; };
template<class T> template<class T>
class ChaseMovementGenerator : public TargetedMovementGeneratorMedium<T, ChaseMovementGenerator<T> > class ChaseMovementGenerator : public TargetedMovementGeneratorMedium<T, ChaseMovementGenerator<T> >
{ {
public: public:
ChaseMovementGenerator(Unit& target, float offset, float angle) ChaseMovementGenerator(Unit& target, float offset, float angle)
@ -103,7 +103,7 @@ class ChaseMovementGenerator : public TargetedMovementGeneratorMedium<T, ChaseM
}; };
template<class T> template<class T>
class FollowMovementGenerator : public TargetedMovementGeneratorMedium<T, FollowMovementGenerator<T> > class FollowMovementGenerator : public TargetedMovementGeneratorMedium<T, FollowMovementGenerator<T> >
{ {
public: public:
FollowMovementGenerator(Unit& target) FollowMovementGenerator(Unit& target)

View file

@ -65,7 +65,7 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature& creature, int32 pat
} }
if (i_path->empty()) if (i_path->empty())
return; { return; }
// Initialize the i_currentNode to point to the first node // Initialize the i_currentNode to point to the first node
i_currentNode = i_path->begin()->first; i_currentNode = i_path->begin()->first;
m_lastReachedWaypoint = 0; m_lastReachedWaypoint = 0;
@ -101,18 +101,18 @@ void WaypointMovementGenerator<Creature>::Interrupt(Creature& creature)
void WaypointMovementGenerator<Creature>::Reset(Creature& creature) void WaypointMovementGenerator<Creature>::Reset(Creature& creature)
{ {
creature.addUnitState(UNIT_STAT_ROAMING); creature.addUnitState(UNIT_STAT_ROAMING);
StartMove(creature); StartMove(creature);
} }
void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature) void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
{ {
if (!i_path || i_path->empty()) if (!i_path || i_path->empty())
return; { return; }
m_lastReachedWaypoint = i_currentNode; m_lastReachedWaypoint = i_currentNode;
if (m_isArrivalDone) if (m_isArrivalDone)
return; { return; }
creature.clearUnitState(UNIT_STAT_ROAMING_MOVE); creature.clearUnitState(UNIT_STAT_ROAMING_MOVE);
m_isArrivalDone = true; m_isArrivalDone = true;
@ -131,13 +131,13 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
if (WaypointBehavior* behavior = node.behavior) if (WaypointBehavior* behavior = node.behavior)
{ {
if (behavior->emote != 0) if (behavior->emote != 0)
creature.HandleEmote(behavior->emote); { creature.HandleEmote(behavior->emote); }
if (behavior->spell != 0) if (behavior->spell != 0)
creature.CastSpell(&creature, behavior->spell, false); { creature.CastSpell(&creature, behavior->spell, false); }
if (behavior->model1 != 0) if (behavior->model1 != 0)
creature.SetDisplayId(behavior->model1); { creature.SetDisplayId(behavior->model1); }
if (behavior->textid[0]) if (behavior->textid[0])
{ {
@ -150,16 +150,16 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
for (; i < MAX_WAYPOINT_TEXT; ++i) for (; i < MAX_WAYPOINT_TEXT; ++i)
{ {
if (!behavior->textid[i]) if (!behavior->textid[i])
break; { break; }
} }
textId = behavior->textid[urand(0, i - 1)]; textId = behavior->textid[urand(0, i - 1)];
} }
if (MangosStringLocale const* textData = sObjectMgr.GetMangosStringLocale(textId)) if (MangosStringLocale const* textData = sObjectMgr.GetMangosStringLocale(textId))
creature.MonsterText(textData, NULL); { creature.MonsterText(textData, NULL); }
else else
sLog.outErrorDb("%s reached waypoint %u, attempted to do text %i, but required text-data could not be found", creature.GetGuidStr().c_str(), i_currentNode, textId); { sLog.outErrorDb("%s reached waypoint %u, attempted to do text %i, but required text-data could not be found", creature.GetGuidStr().c_str(), i_currentNode, textId); }
} }
} }
@ -179,13 +179,13 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
void WaypointMovementGenerator<Creature>::StartMove(Creature& creature) void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
{ {
if (!i_path || i_path->empty()) if (!i_path || i_path->empty())
return; { return; }
if (Stopped(creature)) if (Stopped(creature))
return; { return; }
if (!creature.IsAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE)) if (!creature.IsAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
return; { return; }
WaypointPath::const_iterator currPoint = i_path->find(i_currentNode); WaypointPath::const_iterator currPoint = i_path->find(i_currentNode);
MANGOS_ASSERT(currPoint != i_path->end()); MANGOS_ASSERT(currPoint != i_path->end());
@ -193,7 +193,7 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
if (WaypointBehavior* behavior = currPoint->second.behavior) if (WaypointBehavior* behavior = currPoint->second.behavior)
{ {
if (behavior->model2 != 0) if (behavior->model2 != 0)
creature.SetDisplayId(behavior->model2); { creature.SetDisplayId(behavior->model2); }
creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
} }
@ -231,7 +231,7 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
init.MoveTo(nextNode.x, nextNode.y, nextNode.z, true); init.MoveTo(nextNode.x, nextNode.y, nextNode.z, true);
if (nextNode.orientation != 100 && nextNode.delay != 0) if (nextNode.orientation != 100 && nextNode.delay != 0)
init.SetFacing(nextNode.orientation); { init.SetFacing(nextNode.orientation); }
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE) && !creature.IsLevitating(), false); creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE) && !creature.IsLevitating(), false);
init.Launch(); init.Launch();
} }
@ -256,12 +256,12 @@ bool WaypointMovementGenerator<Creature>::Update(Creature& creature, const uint3
if (Stopped(creature)) if (Stopped(creature))
{ {
if (CanMove(diff, creature)) if (CanMove(diff, creature))
StartMove(creature); { StartMove(creature); }
} }
else else
{ {
if (creature.IsStopped()) if (creature.IsStopped())
Stop(STOP_TIME_FOR_PLAYER); { Stop(STOP_TIME_FOR_PLAYER); }
else if (creature.movespline->Finalized()) else if (creature.movespline->Finalized())
{ {
OnArrived(creature); OnArrived(creature);
@ -289,12 +289,12 @@ bool WaypointMovementGenerator<Creature>::GetResetPosition(Creature&, float& x,
{ {
// prevent a crash at empty waypoint path. // prevent a crash at empty waypoint path.
if (!i_path || i_path->empty()) if (!i_path || i_path->empty())
return false; { return false; }
WaypointPath::const_iterator lastPoint = i_path->find(m_lastReachedWaypoint); WaypointPath::const_iterator lastPoint = i_path->find(m_lastReachedWaypoint);
// Special case: Before the first waypoint is reached, m_lastReachedWaypoint is set to 0 (which may not be contained in i_path) // Special case: Before the first waypoint is reached, m_lastReachedWaypoint is set to 0 (which may not be contained in i_path)
if (!m_lastReachedWaypoint && lastPoint == i_path->end()) if (!m_lastReachedWaypoint && lastPoint == i_path->end())
return false; { return false; }
MANGOS_ASSERT(lastPoint != i_path->end()); MANGOS_ASSERT(lastPoint != i_path->end());
@ -367,14 +367,14 @@ bool WaypointMovementGenerator<Creature>::SetNextWaypoint(uint32 pointId)
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
{ {
if (i_currentNode >= i_path->size()) if (i_currentNode >= i_path->size())
return i_path->size(); { return i_path->size(); }
uint32 curMapId = (*i_path)[i_currentNode].mapid; uint32 curMapId = (*i_path)[i_currentNode].mapid;
for (uint32 i = i_currentNode; i < i_path->size(); ++i) for (uint32 i = i_currentNode; i < i_path->size(); ++i)
{ {
if ((*i_path)[i].mapid != curMapId) if ((*i_path)[i].mapid != curMapId)
return i; { return i; }
} }
return i_path->size(); return i_path->size();
@ -398,7 +398,7 @@ void FlightPathMovementGenerator::Finalize(Player& player)
{ {
player.GetHostileRefManager().setOnlineOfflineState(true); player.GetHostileRefManager().setOnlineOfflineState(true);
if (player.pvpInfo.inHostileArea) if (player.pvpInfo.inHostileArea)
player.CastSpell(&player, 2479, true); { player.CastSpell(&player, 2479, true); }
// update z position to ground and orientation for landing point // update z position to ground and orientation for landing point
// this prevent cheating with landing point at lags // this prevent cheating with landing point at lags
@ -446,7 +446,7 @@ bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff)
{ {
DoEventIfAny(player, (*i_path)[i_currentNode], departureEvent); DoEventIfAny(player, (*i_path)[i_currentNode], departureEvent);
if (pointId == i_currentNode) if (pointId == i_currentNode)
break; { break; }
i_currentNode += (uint32)departureEvent; i_currentNode += (uint32)departureEvent;
departureEvent = !departureEvent; departureEvent = !departureEvent;
} }
@ -459,7 +459,7 @@ bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff)
void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport() void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
{ {
if (i_path->empty()) if (i_path->empty())
return; { return; }
uint32 map0 = (*i_path)[0].mapid; uint32 map0 = (*i_path)[0].mapid;

View file

@ -39,10 +39,10 @@
#include <set> #include <set>
#define FLIGHT_TRAVEL_UPDATE 100 #define FLIGHT_TRAVEL_UPDATE 100
#define STOP_TIME_FOR_PLAYER (3 * MINUTE * IN_MILLISECONDS) // 3 Minutes #define STOP_TIME_FOR_PLAYER (3 * MINUTE * IN_MILLISECONDS)// 3 Minutes
template<class T, class P> template<class T, class P>
class MANGOS_DLL_SPEC PathMovementBase class PathMovementBase
{ {
public: public:
PathMovementBase() : i_currentNode(0) {} PathMovementBase() : i_currentNode(0) {}
@ -63,12 +63,12 @@ class MANGOS_DLL_SPEC PathMovementBase
*/ */
template<class T> template<class T>
class WaypointMovementGenerator; class WaypointMovementGenerator;
template<> template<>
class MANGOS_DLL_SPEC WaypointMovementGenerator<Creature> class WaypointMovementGenerator<Creature>
: public MovementGeneratorMedium< Creature, WaypointMovementGenerator<Creature> >, : public MovementGeneratorMedium< Creature, WaypointMovementGenerator<Creature> >,
public PathMovementBase<Creature, WaypointPath const*> public PathMovementBase<Creature, WaypointPath const*>
{ {
public: public:
WaypointMovementGenerator(Creature&) : i_nextMoveTime(0), m_isArrivalDone(false), m_lastReachedWaypoint(0) {} WaypointMovementGenerator(Creature&) : i_nextMoveTime(0), m_isArrivalDone(false), m_lastReachedWaypoint(0) {}
@ -111,7 +111,7 @@ class MANGOS_DLL_SPEC WaypointMovementGenerator<Creature>
/** FlightPathMovementGenerator generates movement of the player for the paths /** FlightPathMovementGenerator generates movement of the player for the paths
* and hence generates ground and activities for the player. * and hence generates ground and activities for the player.
*/ */
class FlightPathMovementGenerator class FlightPathMovementGenerator
: public MovementGeneratorMedium< Player, FlightPathMovementGenerator >, : public MovementGeneratorMedium< Player, FlightPathMovementGenerator >,
public PathMovementBase<Player, TaxiPathNodeList const*> public PathMovementBase<Player, TaxiPathNodeList const*>
{ {

View file

@ -34,7 +34,7 @@ int AggressorAI::Permissible(const Creature* creature)
{ {
// have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight
if (!creature->IsCivilian() && !creature->IsNeutralToAll()) if (!creature->IsCivilian() && !creature->IsNeutralToAll())
return PERMIT_BASE_PROACTIVE; { return PERMIT_BASE_PROACTIVE; }
return PERMIT_BASE_NO; return PERMIT_BASE_NO;
} }
@ -47,10 +47,10 @@ void AggressorAI::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->CanInitiateAttack() && u->IsTargetableForAttack() && if (m_creature->CanInitiateAttack() && u->IsTargetableForAttack() &&
m_creature->IsHostileTo(u) && u->isInAccessablePlaceFor(m_creature)) m_creature->IsHostileTo(u) && u->isInAccessablePlaceFor(m_creature))
{ {
float attackRadius = m_creature->GetAttackDistance(u); float attackRadius = m_creature->GetAttackDistance(u);
if (m_creature->IsWithinDistInMap(u, attackRadius) && m_creature->IsWithinLOSInMap(u)) if (m_creature->IsWithinDistInMap(u, attackRadius) && m_creature->IsWithinLOSInMap(u))
@ -111,7 +111,7 @@ void AggressorAI::EnterEvadeMode()
// Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead // Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
m_creature->GetMotionMaster()->MoveTargetedHome(); { m_creature->GetMotionMaster()->MoveTargetedHome(); }
} }
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
@ -124,7 +124,7 @@ void AggressorAI::UpdateAI(const uint32 /*diff*/)
{ {
// update i_victimGuid if m_creature->getVictim() !=0 and changed // update i_victimGuid if m_creature->getVictim() !=0 and changed
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return; { return; }
i_victimGuid = m_creature->getVictim()->GetObjectGuid(); i_victimGuid = m_creature->getVictim()->GetObjectGuid();
@ -140,7 +140,7 @@ bool AggressorAI::IsVisible(Unit* pl) const
void AggressorAI::AttackStart(Unit* u) void AggressorAI::AttackStart(Unit* u)
{ {
if (!u || !m_creature->CanAttackByItself()) if (!u || !m_creature->CanAttackByItself())
return; { return; }
if (m_creature->Attack(u, true)) if (m_creature->Attack(u, true))
{ {

View file

@ -580,7 +580,7 @@ uint32 ArenaTeam::GetPoints(uint32 MemberRating)
else if (m_Type == ARENA_TYPE_3v3) else if (m_Type == ARENA_TYPE_3v3)
points *= 0.88f; points *= 0.88f;
return (uint32)points; return (uint32) points;
} }
bool ArenaTeam::HaveMember(ObjectGuid guid) const bool ArenaTeam::HaveMember(ObjectGuid guid) const
@ -736,8 +736,8 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map<uint32, uint32>& PlayerPoints)
if (m_stats.games_week < 10) if (m_stats.games_week < 10)
return; return;
// to get points, a player has to participate in at least 30% of the matches // to get points, a player has to participate in at least 30% of the matches
uint32 min_plays = (uint32)ceil(m_stats.games_week * 0.3); uint32 min_plays = (uint32) ceil(m_stats.games_week * 0.3);
for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
{ {
// the player participated in enough games, update his points // the player participated in enough games, update his points
uint32 points_to_add = 0; uint32 points_to_add = 0;

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -56,7 +56,7 @@ AuctionHouseMgr::AuctionHouseMgr()
AuctionHouseMgr::~AuctionHouseMgr() AuctionHouseMgr::~AuctionHouseMgr()
{ {
for (ItemMap::const_iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr) for (ItemMap::const_iterator itr = mAitems.begin(); itr != mAitems.end(); ++itr)
delete itr->second; { delete itr->second; }
} }
@ -143,7 +143,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction)
} }
} }
else if (!bidder) else if (!bidder)
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid); { bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid); }
if (auction_owner) if (auction_owner)
auction_owner->GetSession()->SendAuctionOwnerNotification(auction); auction_owner->GetSession()->SendAuctionOwnerNotification(auction);
@ -412,29 +412,29 @@ void AuctionHouseMgr::LoadAuctions()
auction->itemGuidLow = 0; // must be 0 if auction delivery pending auction->itemGuidLow = 0; // must be 0 if auction delivery pending
else else
{ {
// check if sold item exists for guid // check if sold item exists for guid
// and item_template in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems) // and item_template in fact (GetAItem will fail if problematic in result check in AuctionHouseMgr::LoadAuctionItems)
Item* pItem = GetAItem(auction->itemGuidLow); Item* pItem = GetAItem(auction->itemGuidLow);
if (!pItem) if (!pItem)
{ {
auction->DeleteFromDB(); auction->DeleteFromDB();
sLog.outError("Auction %u has not a existing item : %u, deleted", auction->Id, auction->itemGuidLow); sLog.outError("Auction %u has not a existing item : %u, deleted", auction->Id, auction->itemGuidLow);
delete auction; delete auction;
continue; continue;
} }
// overwrite by real item data // overwrite by real item data
if ((auction->itemTemplate != pItem->GetEntry()) || if ((auction->itemTemplate != pItem->GetEntry()) ||
(auction->itemCount != pItem->GetCount()) || (auction->itemCount != pItem->GetCount()) ||
(auction->itemRandomPropertyId != pItem->GetItemRandomPropertyId())) (auction->itemRandomPropertyId != pItem->GetItemRandomPropertyId()))
{ {
auction->itemTemplate = pItem->GetEntry(); auction->itemTemplate = pItem->GetEntry();
auction->itemCount = pItem->GetCount(); auction->itemCount = pItem->GetCount();
auction->itemRandomPropertyId = pItem->GetItemRandomPropertyId(); auction->itemRandomPropertyId = pItem->GetItemRandomPropertyId();
// No SQL injection (no strings) // No SQL injection (no strings)
CharacterDatabase.PExecute("UPDATE auction SET item_template = %u, item_count = %u, item_randompropertyid = %i WHERE itemguid = %u", CharacterDatabase.PExecute("UPDATE auction SET item_template = %u, item_count = %u, item_randompropertyid = %i WHERE itemguid = %u",
auction->itemTemplate, auction->itemCount, auction->itemRandomPropertyId, auction->itemGuidLow); auction->itemTemplate, auction->itemCount, auction->itemRandomPropertyId, auction->itemGuidLow);
} }
} }
@ -844,7 +844,7 @@ void WorldSession::BuildListAuctionItems(std::vector<AuctionEntry*> const& aucti
{ continue; } { continue; }
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax))) if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
continue; { continue; }
if (usable != 0x00) if (usable != 0x00)
{ {

View file

@ -22,12 +22,30 @@
* and lore are copyrighted by Blizzard Entertainment, Inc. * and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
/**
* This is part of the code that takes care of the Auction House and all that can happen with it,
* it takes care of adding new items to it, bidding/buyouting them etc. Also handles the errors
* that can happen, ie: you don't have enough money, your account isn't paid for (won't really
* happen on these servers), the item you are trying to buy doesn't exist etc.
*
* This is also what is partly used by the \ref AuctionHouseBot as an interface to what it needs
* for performing the usual operations such as checking what has been bidded on etc.
*
* \todo Add more info about how the auction house system works.
*/
#ifndef _AUCTION_HOUSE_MGR_H #ifndef _AUCTION_HOUSE_MGR_H
#define _AUCTION_HOUSE_MGR_H #define _AUCTION_HOUSE_MGR_H
#include "Common.h" #include "Common.h"
#include "DBCStructure.h" #include "DBCStructure.h"
/** \addtogroup auctionhouse
* @{
* \file
*/
class Item; class Item;
class Player; class Player;
class Unit; class Unit;
@ -37,24 +55,28 @@ class WorldPacket;
#define MAX_AUCTION_SORT 12 #define MAX_AUCTION_SORT 12
#define AUCTION_SORT_REVERSED 0x10 #define AUCTION_SORT_REVERSED 0x10
/**
* Documentation for this taken directly from comments in source
* \todo Needs real documentation of what these values mean and where they are sent etc.
*/
enum AuctionError enum AuctionError
{ {
AUCTION_OK = 0, // depends on enum AuctionAction AUCTION_OK = 0, ///< depends on enum AuctionAction
AUCTION_ERR_INVENTORY = 1, // depends on enum InventoryChangeResult AUCTION_ERR_INVENTORY = 1, ///< depends on enum InventoryChangeResult
AUCTION_ERR_DATABASE = 2, // ERR_AUCTION_DATABASE_ERROR (default) AUCTION_ERR_DATABASE = 2, ///< ERR_AUCTION_DATABASE_ERROR (default)
AUCTION_ERR_NOT_ENOUGH_MONEY = 3, // ERR_NOT_ENOUGH_MONEY AUCTION_ERR_NOT_ENOUGH_MONEY = 3, ///< ERR_NOT_ENOUGH_MONEY
AUCTION_ERR_ITEM_NOT_FOUND = 4, // ERR_ITEM_NOT_FOUND AUCTION_ERR_ITEM_NOT_FOUND = 4, ///< ERR_ITEM_NOT_FOUND
AUCTION_ERR_HIGHER_BID = 5, // ERR_AUCTION_HIGHER_BID AUCTION_ERR_HIGHER_BID = 5, ///< ERR_AUCTION_HIGHER_BID
AUCTION_ERR_BID_INCREMENT = 7, // ERR_AUCTION_BID_INCREMENT AUCTION_ERR_BID_INCREMENT = 7, ///< ERR_AUCTION_BID_INCREMENT
AUCTION_ERR_BID_OWN = 10, // ERR_AUCTION_BID_OWN AUCTION_ERR_BID_OWN = 10, ///< ERR_AUCTION_BID_OWN
AUCTION_ERR_RESTRICTED_ACCOUNT = 13 // ERR_RESTRICTED_ACCOUNT AUCTION_ERR_RESTRICTED_ACCOUNT = 13 ///< ERR_RESTRICTED_ACCOUNT
}; };
enum AuctionAction enum AuctionAction
{ {
AUCTION_STARTED = 0, // ERR_AUCTION_STARTED AUCTION_STARTED = 0, ///< ERR_AUCTION_STARTED
AUCTION_REMOVED = 1, // ERR_AUCTION_REMOVED AUCTION_REMOVED = 1, ///< ERR_AUCTION_REMOVED
AUCTION_BID_PLACED = 2 // ERR_AUCTION_BID_PLACED AUCTION_BID_PLACED = 2 ///< ERR_AUCTION_BID_PLACED
}; };
struct AuctionEntry struct AuctionEntry
@ -99,7 +121,7 @@ class AuctionHouseObject
~AuctionHouseObject() ~AuctionHouseObject()
{ {
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
delete itr->second; { delete itr->second; }
} }
typedef std::map<uint32, AuctionEntry*> AuctionEntryMap; typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
@ -150,11 +172,16 @@ class AuctionSorter
Player* m_viewPlayer; Player* m_viewPlayer;
}; };
/**
* This describes the type of auction house that we are dealing with, they can be either:
* - neutral (anyone can do their shopping there)
* - alliance/horde (only the respective faction can shop there)
*/
enum AuctionHouseType enum AuctionHouseType
{ {
AUCTION_HOUSE_ALLIANCE = 0, AUCTION_HOUSE_ALLIANCE = 0, ///< Alliance only auction house
AUCTION_HOUSE_HORDE = 1, AUCTION_HOUSE_HORDE = 1, ///< Horde only auction house
AUCTION_HOUSE_NEUTRAL = 2 AUCTION_HOUSE_NEUTRAL = 2 ///< Neutral auction house, anyone can do business here
}; };
#define MAX_AUCTION_HOUSE_TYPE 3 #define MAX_AUCTION_HOUSE_TYPE 3
@ -205,6 +232,9 @@ class AuctionHouseMgr
ItemMap mAitems; ItemMap mAitems;
}; };
/// Convenience define to access the singleton object for the Auction House Manager
#define sAuctionMgr MaNGOS::Singleton<AuctionHouseMgr>::Instance() #define sAuctionMgr MaNGOS::Singleton<AuctionHouseMgr>::Instance()
/** @} */
#endif #endif

View file

@ -40,7 +40,7 @@ Bag::Bag(): Item()
Bag::~Bag() Bag::~Bag()
{ {
for (int i = 0; i < MAX_BAG_SIZE; ++i) for (int i = 0; i < MAX_BAG_SIZE; ++i)
delete m_bagslot[i]; { delete m_bagslot[i]; }
} }
void Bag::AddToWorld() void Bag::AddToWorld()
@ -49,14 +49,14 @@ void Bag::AddToWorld()
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i]) if (m_bagslot[i])
m_bagslot[i]->AddToWorld(); { m_bagslot[i]->AddToWorld(); }
} }
void Bag::RemoveFromWorld() void Bag::RemoveFromWorld()
{ {
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i]) if (m_bagslot[i])
m_bagslot[i]->RemoveFromWorld(); { m_bagslot[i]->RemoveFromWorld(); }
Item::RemoveFromWorld(); Item::RemoveFromWorld();
} }
@ -66,7 +66,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid); ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid);
if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE) if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
return false; { return false; }
Object::_Create(guidlow, 0, HIGHGUID_CONTAINER); Object::_Create(guidlow, 0, HIGHGUID_CONTAINER);
@ -101,7 +101,7 @@ void Bag::SaveToDB()
bool Bag::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid) bool Bag::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
{ {
if (!Item::LoadFromDB(guidLow, fields, ownerGuid)) if (!Item::LoadFromDB(guidLow, fields, ownerGuid))
return false; { return false; }
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`) // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
for (int i = 0; i < MAX_BAG_SIZE; ++i) for (int i = 0; i < MAX_BAG_SIZE; ++i)
@ -119,7 +119,7 @@ void Bag::DeleteFromDB()
{ {
for (int i = 0; i < MAX_BAG_SIZE; ++i) for (int i = 0; i < MAX_BAG_SIZE; ++i)
if (m_bagslot[i]) if (m_bagslot[i])
m_bagslot[i]->DeleteFromDB(); { m_bagslot[i]->DeleteFromDB(); }
Item::DeleteFromDB(); Item::DeleteFromDB();
} }
@ -129,7 +129,7 @@ uint32 Bag::GetFreeSlots() const
uint32 slots = 0; uint32 slots = 0;
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
if (!m_bagslot[i]) if (!m_bagslot[i])
++slots; { ++slots; }
return slots; return slots;
} }
@ -139,7 +139,7 @@ void Bag::RemoveItem(uint8 slot, bool /*update*/)
MANGOS_ASSERT(slot < MAX_BAG_SIZE); MANGOS_ASSERT(slot < MAX_BAG_SIZE);
if (m_bagslot[slot]) if (m_bagslot[slot])
m_bagslot[slot]->SetContainer(NULL); { m_bagslot[slot]->SetContainer(NULL); }
m_bagslot[slot] = NULL; m_bagslot[slot] = NULL;
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid()); SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid());
@ -166,7 +166,7 @@ void Bag::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) cons
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i]) if (m_bagslot[i])
m_bagslot[i]->BuildCreateUpdateBlockForPlayer(data, target); { m_bagslot[i]->BuildCreateUpdateBlockForPlayer(data, target); }
} }
// If the bag is empty returns true // If the bag is empty returns true
@ -174,7 +174,7 @@ bool Bag::IsEmpty() const
{ {
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i]) if (m_bagslot[i])
return false; { return false; }
return true; return true;
} }
@ -183,7 +183,7 @@ Item* Bag::GetItemByEntry(uint32 item) const
{ {
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i] && m_bagslot[i]->GetEntry() == item) if (m_bagslot[i] && m_bagslot[i]->GetEntry() == item)
return m_bagslot[i]; { return m_bagslot[i]; }
return NULL; return NULL;
} }
@ -204,7 +204,7 @@ uint32 Bag::GetItemCount(uint32 item, Item* eItem) const
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i]) if (m_bagslot[i])
if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item) if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item)
count += m_bagslot[i]->GetCount(); { count += m_bagslot[i]->GetCount(); }
if (eItem && eItem->GetProto()->GemProperties) if (eItem && eItem->GetProto()->GemProperties)
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
@ -232,7 +232,7 @@ uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const
for (uint32 i = 0; i < GetBagSize(); ++i) for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i] != 0) if (m_bagslot[i] != 0)
if (m_bagslot[i]->GetObjectGuid() == guid) if (m_bagslot[i]->GetObjectGuid() == guid)
return i; { return i; }
return NULL_SLOT; return NULL_SLOT;
} }
@ -240,7 +240,7 @@ uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const
Item* Bag::GetItemByPos(uint8 slot) const Item* Bag::GetItemByPos(uint8 slot) const
{ {
if (slot < GetBagSize()) if (slot < GetBagSize())
return m_bagslot[slot]; { return m_bagslot[slot]; }
return NULL; return NULL;
} }

View file

@ -78,7 +78,7 @@ class Bag : public Item
inline Item* NewItemOrBag(ItemPrototype const* proto) inline Item* NewItemOrBag(ItemPrototype const* proto)
{ {
if (proto->InventoryType == INVTYPE_BAG) if (proto->InventoryType == INVTYPE_BAG)
return new Bag; { return new Bag; }
return new Item; return new Item;
} }

View file

@ -53,7 +53,7 @@ void Camera::UpdateForCurrentViewPoint()
m_gridRef.unlink(); m_gridRef.unlink();
if (GridType* grid = m_source->GetViewPoint().m_grid) if (GridType* grid = m_source->GetViewPoint().m_grid)
grid->AddWorldObject(this); { grid->AddWorldObject(this); }
UpdateVisibilityForOwner(); UpdateVisibilityForOwner();
} }
@ -63,7 +63,7 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
MANGOS_ASSERT(obj); MANGOS_ASSERT(obj);
if (m_source == obj) if (m_source == obj)
return; { return; }
if (!m_owner.IsInMap(obj)) if (!m_owner.IsInMap(obj))
{ {
@ -79,18 +79,18 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
// detach and deregister from active objects if there are no more reasons to be active // detach and deregister from active objects if there are no more reasons to be active
m_source->GetViewPoint().Detach(this); m_source->GetViewPoint().Detach(this);
if (!m_source->isActiveObject()) if (!m_source->IsActiveObject())
m_source->GetMap()->RemoveFromActive(m_source); { m_source->GetMap()->RemoveFromActive(m_source); }
m_source = obj; m_source = obj;
if (!m_source->isActiveObject()) if (!m_source->IsActiveObject())
m_source->GetMap()->AddToActive(m_source); { m_source->GetMap()->AddToActive(m_source); }
m_source->GetViewPoint().Attach(this); m_source->GetViewPoint().Attach(this);
if (update_far_sight_field) if (update_far_sight_field)
m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid())); { m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid())); }
UpdateForCurrentViewPoint(); UpdateForCurrentViewPoint();
} }
@ -98,7 +98,7 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
void Camera::Event_ViewPointVisibilityChanged() void Camera::Event_ViewPointVisibilityChanged()
{ {
if (!m_owner.HaveAtClient(m_source)) if (!m_owner.HaveAtClient(m_source))
ResetView(); { ResetView(); }
} }
void Camera::ResetView(bool update_far_sight_field /*= true*/) void Camera::ResetView(bool update_far_sight_field /*= true*/)

View file

@ -35,7 +35,7 @@ class WorldPacket;
class Player; class Player;
/// Camera - object-receiver. Receives broadcast packets from nearby worldobjects, object visibility changes and sends them to client /// Camera - object-receiver. Receives broadcast packets from nearby worldobjects, object visibility changes and sends them to client
class Camera class Camera
{ {
friend class ViewPoint; friend class ViewPoint;
public: public:
@ -77,13 +77,13 @@ class Camera
public: public:
GridReference<Camera>& GetGridRef() { return m_gridRef; } GridReference<Camera>& GetGridRef() { return m_gridRef; }
bool isActiveObject() const { return false; } bool IsActiveObject() const { return false; }
private: private:
GridReference<Camera> m_gridRef; GridReference<Camera> m_gridRef;
}; };
/// Object-observer, notifies farsight object state to cameras that attached to it /// Object-observer, notifies farsight object state to cameras that attached to it
class ViewPoint class ViewPoint
{ {
friend class Camera; friend class Camera;

View file

@ -55,7 +55,7 @@ void Corpse::AddToWorld()
{ {
///- Register the corpse for guid lookup ///- Register the corpse for guid lookup
if (!IsInWorld()) if (!IsInWorld())
sObjectAccessor.AddObject(this); { sObjectAccessor.AddObject(this); }
Object::AddToWorld(); Object::AddToWorld();
} }
@ -64,7 +64,7 @@ void Corpse::RemoveFromWorld()
{ {
///- Remove the corpse from the accessor ///- Remove the corpse from the accessor
if (IsInWorld()) if (IsInWorld())
sObjectAccessor.RemoveObject(this); { sObjectAccessor.RemoveObject(this); }
Object::RemoveFromWorld(); Object::RemoveFromWorld();
} }
@ -232,9 +232,9 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field* fields)
uint32 flags = CORPSE_FLAG_UNK2; uint32 flags = CORPSE_FLAG_UNK2;
if (playerFlags & PLAYER_FLAGS_HIDE_HELM) if (playerFlags & PLAYER_FLAGS_HIDE_HELM)
flags |= CORPSE_FLAG_HIDE_HELM; { flags |= CORPSE_FLAG_HIDE_HELM; }
if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK) if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
flags |= CORPSE_FLAG_HIDE_CLOAK; { flags |= CORPSE_FLAG_HIDE_CLOAK; }
SetUInt32Value(CORPSE_FIELD_FLAGS, flags); SetUInt32Value(CORPSE_FIELD_FLAGS, flags);
// no need to mark corpse as lootable, because corpses are not saved in battle grounds // no need to mark corpse as lootable, because corpses are not saved in battle grounds
@ -265,23 +265,23 @@ bool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint,
bool Corpse::IsHostileTo(Unit const* unit) const bool Corpse::IsHostileTo(Unit const* unit) const
{ {
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid())) if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
return owner->IsHostileTo(unit); { return owner->IsHostileTo(unit); }
else else
return false; { return false; }
} }
bool Corpse::IsFriendlyTo(Unit const* unit) const bool Corpse::IsFriendlyTo(Unit const* unit) const
{ {
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid())) if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
return owner->IsFriendlyTo(unit); { return owner->IsFriendlyTo(unit); }
else else
return true; { return true; }
} }
bool Corpse::IsExpired(time_t t) const bool Corpse::IsExpired(time_t t) const
{ {
if (m_type == CORPSE_BONES) if (m_type == CORPSE_BONES)
return m_time < t - 60 * MINUTE; { return m_time < t - 60 * MINUTE; }
else else
return m_time < t - 3 * DAY; { return m_time < t - 3 * DAY; }
} }

View file

@ -89,7 +89,7 @@ class Corpse : public WorldObject
Player* lootRecipient; Player* lootRecipient;
bool lootForBody; bool lootForBody;
GridReference<Corpse> &GetGridRef() { return m_gridRef; } GridReference<Corpse>& GetGridRef() { return m_gridRef; }
bool IsExpired(time_t t) const; bool IsExpired(time_t t) const;
private: private:

File diff suppressed because it is too large Load diff

View file

@ -91,20 +91,20 @@ struct CreatureInfo
uint32 FactionAlliance; uint32 FactionAlliance;
uint32 FactionHorde; uint32 FactionHorde;
float Scale; float Scale;
uint32 Family; // enum CreatureFamily values (optional) uint32 Family; // enum CreatureFamily values (optional)
uint32 CreatureType; // enum CreatureType values uint32 CreatureType; // enum CreatureType values
uint32 InhabitType; uint32 InhabitType;
uint32 RegenerateStats; uint32 RegenerateStats;
int32 RacialLeader; int32 RacialLeader;
uint32 NpcFlags; uint32 NpcFlags;
uint32 UnitFlags; // enum UnitFlags mask values uint32 UnitFlags; // enum UnitFlags mask values
uint32 UnitFlags2; // enum UnitFlags2 mask values uint32 UnitFlags2; // enum UnitFlags2 mask values
uint32 DynamicFlags; uint32 DynamicFlags;
uint32 ExtraFlags; uint32 ExtraFlags;
uint32 CreatureTypeFlags; // enum CreatureTypeFlags mask values uint32 CreatureTypeFlags; // enum CreatureTypeFlags mask values
float SpeedWalk; float SpeedWalk;
float SpeedRun; float SpeedRun;
uint32 UnitClass; // enum Classes. Note only 4 classes are known for creatures. uint32 UnitClass; // enum Classes. Note only 4 classes are known for creatures.
uint32 Rank; uint32 Rank;
int32 Expansion; // creature expansion, important for stats, CAN BE -1 as marker for some invalid cases. int32 Expansion; // creature expansion, important for stats, CAN BE -1 as marker for some invalid cases.
float HealthMultiplier; float HealthMultiplier;
@ -166,13 +166,13 @@ struct CreatureInfo
SkillType GetRequiredLootSkill() const SkillType GetRequiredLootSkill() const
{ {
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_HERBLOOT) if (CreatureTypeFlags & CREATURE_TYPEFLAGS_HERBLOOT)
return SKILL_HERBALISM; { return SKILL_HERBALISM; }
else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_MININGLOOT) else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_MININGLOOT)
return SKILL_MINING; { return SKILL_MINING; }
else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_ENGINEERLOOT) else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
return SKILL_ENGINEERING; return SKILL_ENGINEERING;
else else
return SKILL_SKINNING; // normal case { return SKILL_SKINNING; } // normal case
} }
bool IsExotic() const bool IsExotic() const
@ -341,8 +341,8 @@ enum SelectFlags
enum RegenStatsFlags enum RegenStatsFlags
{ {
REGEN_FLAG_HEALTH = 0x001, REGEN_FLAG_HEALTH = 0x001,
REGEN_FLAG_POWER = 0x002, REGEN_FLAG_POWER = 0x002,
}; };
// Vendors // Vendors
@ -377,7 +377,7 @@ struct VendorItemData
VendorItem* GetItem(uint32 slot) const VendorItem* GetItem(uint32 slot) const
{ {
if (slot >= m_items.size()) return NULL; if (slot >= m_items.size()) { return NULL; }
return m_items[slot]; return m_items[slot];
} }
bool Empty() const { return m_items.empty(); } bool Empty() const { return m_items.empty(); }
@ -690,6 +690,12 @@ class Creature : public Unit
* \return ObjectGuid Player GUID. * \return ObjectGuid Player GUID.
*/ */
ObjectGuid GetLootRecipientGuid() const { return m_lootRecipientGuid; } ObjectGuid GetLootRecipientGuid() const { return m_lootRecipientGuid; }
/**
* function returning the group recipient ID.
*
* \return uint32 Group ID.
*/
uint32 GetLootGroupRecipientId() const { return m_lootGroupRecipientId; } uint32 GetLootGroupRecipientId() const { return m_lootGroupRecipientId; }
Player* GetLootRecipient() const; // use group cases as prefered Player* GetLootRecipient() const; // use group cases as prefered
Group* GetGroupLootRecipient() const; Group* GetGroupLootRecipient() const;

View file

@ -117,7 +117,7 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
} }
// Interrupt any previous spell // Interrupt any previous spell
if (uiCastFlags & CAST_INTERRUPT_PREVIOUS && pCaster->IsNonMeleeSpellCasted(false)) if ((uiCastFlags & CAST_INTERRUPT_PREVIOUS) && pCaster->IsNonMeleeSpellCasted(false))
{ pCaster->InterruptNonMeleeSpells(false); } { pCaster->InterruptNonMeleeSpells(false); }
// Creature should always stop before it will cast a non-instant spell // Creature should always stop before it will cast a non-instant spell
@ -153,16 +153,16 @@ void CreatureAI::SetCombatMovement(bool enable, bool stopOrStartMovement /*=fals
m_isCombatMovement = enable; m_isCombatMovement = enable;
if (enable) if (enable)
m_creature->clearUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); { m_creature->clearUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); }
else else
m_creature->addUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); { m_creature->addUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); }
if (stopOrStartMovement && m_creature->getVictim()) // Only change current movement while in combat if (stopOrStartMovement && m_creature->getVictim()) // Only change current movement while in combat
{ {
if (enable) if (enable)
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle); { m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle); }
else if (!enable && m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) else if (!enable && m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
m_creature->StopMoving(); { m_creature->StopMoving(); }
} }
} }
@ -261,7 +261,7 @@ void CreatureAI::SendAIEventAround(AIEventType eventType, Unit* pInvoker, uint32
} }
} }
void CreatureAI::SendAIEvent(AIEventType eventType, Unit* pInvoker, Creature* pReceiver, uint32 miscValue /*=0*/) const void CreatureAI::SendAIEvent(AIEventType eventType, Unit* pInvoker, Creature* pReceiver, uint32 miscValue /*=0*/) const
{ {
MANGOS_ASSERT(pReceiver); MANGOS_ASSERT(pReceiver);
pReceiver->AI()->ReceiveAIEvent(eventType, m_creature, pInvoker, miscValue); pReceiver->AI()->ReceiveAIEvent(eventType, m_creature, pInvoker, miscValue);

View file

@ -91,14 +91,14 @@ enum AIEventType
// Internal Use // Internal Use
AI_EVENT_CALL_ASSISTANCE = 13, // Sender = Attacked Npc, Invoker = Enemy AI_EVENT_CALL_ASSISTANCE = 13, // Sender = Attacked Npc, Invoker = Enemy
// Predefined for SD2 // Predefined for SD3
AI_EVENT_START_ESCORT = 100, // Invoker = Escorting Player AI_EVENT_START_ESCORT = 100, // Invoker = Escorting Player
AI_EVENT_START_ESCORT_B = 101, // Invoker = Escorting Player AI_EVENT_START_ESCORT_B = 101, // Invoker = Escorting Player
AI_EVENT_START_EVENT = 102, // Invoker = EventStarter AI_EVENT_START_EVENT = 102, // Invoker = EventStarter
AI_EVENT_START_EVENT_A = 103, // Invoker = EventStarter AI_EVENT_START_EVENT_A = 103, // Invoker = EventStarter
AI_EVENT_START_EVENT_B = 104, // Invoker = EventStarter AI_EVENT_START_EVENT_B = 104, // Invoker = EventStarter
// Some IDs for special cases in SD2 // Some IDs for special cases in SD3
AI_EVENT_CUSTOM_A = 1000, AI_EVENT_CUSTOM_A = 1000,
AI_EVENT_CUSTOM_B = 1001, AI_EVENT_CUSTOM_B = 1001,
AI_EVENT_CUSTOM_C = 1002, AI_EVENT_CUSTOM_C = 1002,
@ -121,7 +121,7 @@ class CreatureAI
///== Information about AI ======================== ///== Information about AI ========================
/** /**
* This function is used to display information about the AI. * This funcion is used to display information about the AI.
* It is called when the .npc aiinfo command is used. * It is called when the .npc aiinfo command is used.
* Use this for on-the-fly debugging * Use this for on-the-fly debugging
* @param reader is a ChatHandler to send messages to. * @param reader is a ChatHandler to send messages to.
@ -327,7 +327,7 @@ class CreatureAI
///== Event Handling =============================== ///== Event Handling ===============================
/** /*
* Send an AI Event to nearby Creatures around * Send an AI Event to nearby Creatures around
* @param uiType number to specify the event, default cases listed in enum AIEventType * @param uiType number to specify the event, default cases listed in enum AIEventType
* @param pInvoker Unit that triggered this event (like an attacker) * @param pInvoker Unit that triggered this event (like an attacker)
@ -336,7 +336,7 @@ class CreatureAI
*/ */
void SendAIEventAround(AIEventType eventType, Unit* pInvoker, uint32 uiDelay, float fRadius, uint32 miscValue = 0) const; void SendAIEventAround(AIEventType eventType, Unit* pInvoker, uint32 uiDelay, float fRadius, uint32 miscValue = 0) const;
/** /*
* Send an AI Event to a Creature * Send an AI Event to a Creature
* @param eventType to specify the event, default cases listed in enum AIEventType * @param eventType to specify the event, default cases listed in enum AIEventType
* @param pInvoker Unit that triggered this event (like an attacker) * @param pInvoker Unit that triggered this event (like an attacker)
@ -344,7 +344,7 @@ class CreatureAI
*/ */
void SendAIEvent(AIEventType eventType, Unit* pInvoker, Creature* pReceiver, uint32 miscValue = 0) const; void SendAIEvent(AIEventType eventType, Unit* pInvoker, Creature* pReceiver, uint32 miscValue = 0) const;
/** /*
* Called when an AI Event is received * Called when an AI Event is received
* @param eventType to specify the event, default cases listed in enum AIEventType * @param eventType to specify the event, default cases listed in enum AIEventType
* @param pSender Creature that sent this event * @param pSender Creature that sent this event

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -48,7 +48,7 @@ namespace FactorySelector
// Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets) // Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets)
if (!creature->IsPet() || !static_cast<Pet*>(creature)->isControlled()) if (!creature->IsPet() || !static_cast<Pet*>(creature)->isControlled())
return scriptedAI; { return scriptedAI; }
} }
CreatureAIRegistry& ai_registry(CreatureAIRepository::Instance()); CreatureAIRegistry& ai_registry(CreatureAIRepository::Instance());
@ -64,17 +64,17 @@ namespace FactorySelector
{ {
Unit* controler = creature->GetOwner() ? creature->GetOwner() : creature->GetCharmer(); Unit* controler = creature->GetOwner() ? creature->GetOwner() : creature->GetCharmer();
if (controler && controler->GetTypeId() == TYPEID_PLAYER && controler->IsAlive()) if (controler && controler->GetTypeId() == TYPEID_PLAYER && controler->IsAlive())
ai_factory = ai_registry.GetRegistryItem("PetAI"); { ai_factory = ai_registry.GetRegistryItem("PetAI"); }
} }
else if (creature->IsTotem()) else if (creature->IsTotem())
ai_factory = ai_registry.GetRegistryItem("TotemAI"); { ai_factory = ai_registry.GetRegistryItem("TotemAI"); }
// select by script name // select by script name
if (!ai_factory && !ainame.empty()) if (!ai_factory && !ainame.empty())
ai_factory = ai_registry.GetRegistryItem(ainame.c_str()); { ai_factory = ai_registry.GetRegistryItem(ainame.c_str()); }
if (!ai_factory && creature->IsGuard()) if (!ai_factory && creature->IsGuard())
ai_factory = ai_registry.GetRegistryItem("GuardAI"); { ai_factory = ai_registry.GetRegistryItem("GuardAI"); }
// select by permit check // select by permit check
if (!ai_factory) if (!ai_factory)

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -40,9 +40,9 @@
bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax) bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax)
{ {
if (repeatMin == repeatMax) if (repeatMin == repeatMax)
Time = repeatMin; { Time = repeatMin; }
else if (repeatMax > repeatMin) else if (repeatMax > repeatMin)
Time = urand(repeatMin, repeatMax); { Time = urand(repeatMin, repeatMax); }
else else
{ {
sLog.outErrorEventAI("Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", creature->GetEntry(), Event.event_id, Event.event_type); sLog.outErrorEventAI("Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", creature->GetEntry(), Event.event_id, Event.event_type);
@ -56,7 +56,7 @@ bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatM
int CreatureEventAI::Permissible(const Creature* creature) int CreatureEventAI::Permissible(const Creature* creature)
{ {
if (creature->GetAIName() == "EventAI") if (creature->GetAIName() == "EventAI")
return PERMIT_BASE_SPECIAL; { return PERMIT_BASE_SPECIAL; }
return PERMIT_BASE_NO; return PERMIT_BASE_NO;
} }
@ -67,17 +67,17 @@ void CreatureEventAI::GetAIInformation(ChatHandler& reader)
reader.PSendSysMessage(LANG_NPC_EVENTAI_COMBAT, reader.GetOnOffStr(m_MeleeEnabled)); reader.PSendSysMessage(LANG_NPC_EVENTAI_COMBAT, reader.GetOnOffStr(m_MeleeEnabled));
if (sLog.HasLogFilter(LOG_FILTER_EVENT_AI_DEV)) // Give some more details if in EventAI Dev Mode if (sLog.HasLogFilter(LOG_FILTER_EVENT_AI_DEV)) // Give some more details if in EventAI Dev Mode
return; { return; }
reader.PSendSysMessage("Current events of this creature:"); reader.PSendSysMessage("Current events of this creature:");
for (CreatureEventAIList::const_iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr) for (CreatureEventAIList::const_iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr)
{ {
if (itr->Event.action[2].type != ACTION_T_NONE) if (itr->Event.action[2].type != ACTION_T_NONE)
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1, itr->Event.action[2].type, itr->Event.action[2].raw.param1); { reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1, itr->Event.action[2].type, itr->Event.action[2].raw.param1); }
else if (itr->Event.action[1].type != ACTION_T_NONE) else if (itr->Event.action[1].type != ACTION_T_NONE)
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1); { reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1); }
else else
reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) action[type(param1)]: %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time/1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1); { reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) action[type(param1)]: %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1); }
} }
} }
@ -110,7 +110,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
// Debug check // Debug check
#ifndef MANGOS_DEBUG #ifndef MANGOS_DEBUG
if (i->event_flags & EFLAG_DEBUG_ONLY) if (i->event_flags & EFLAG_DEBUG_ONLY)
continue; { continue; }
#endif #endif
if (m_creature->GetMap()->IsDungeon()) if (m_creature->GetMap()->IsDungeon())
{ {
@ -133,7 +133,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
// Debug check // Debug check
#ifndef MANGOS_DEBUG #ifndef MANGOS_DEBUG
if (i->event_flags & EFLAG_DEBUG_ONLY) if (i->event_flags & EFLAG_DEBUG_ONLY)
continue; { continue; }
#endif #endif
bool storeEvent = false; bool storeEvent = false;
if (m_creature->GetMap()->IsDungeon()) if (m_creature->GetMap()->IsDungeon())
@ -155,7 +155,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c),
} }
} }
else else
sLog.outErrorEventAI("EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry()); { sLog.outErrorEventAI("EventMap for Creature %u is empty but creature is using CreatureEventAI.", m_creature->GetEntry()); }
} }
#define LOG_PROCESS_EVENT \ #define LOG_PROCESS_EVENT \
@ -186,21 +186,21 @@ inline bool IsTimerBasedEvent(EventAI_Type type)
} }
} }
bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker, Creature* pAIEventSender) bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker, Creature* pAIEventSender /*=NULL*/)
{ {
if (!pHolder.Enabled || pHolder.Time) if (!pHolder.Enabled || pHolder.Time)
return false; { return false; }
// Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask) // Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask)
if (pHolder.Event.event_inverse_phase_mask & (1 << m_Phase)) if (pHolder.Event.event_inverse_phase_mask & (1 << m_Phase))
{ {
if (!IsTimerBasedEvent(pHolder.Event.event_type)) if (!IsTimerBasedEvent(pHolder.Event.event_type))
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Event %u skipped because of phasemask %u. Current phase %u", pHolder.Event.event_id, pHolder.Event.event_inverse_phase_mask, m_Phase); { DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Event %u skipped because of phasemask %u. Current phase %u", pHolder.Event.event_id, pHolder.Event.event_inverse_phase_mask, m_Phase); }
return false; return false;
} }
if (!IsTimerBasedEvent(pHolder.Event.event_type)) if (!IsTimerBasedEvent(pHolder.Event.event_type))
LOG_PROCESS_EVENT; { LOG_PROCESS_EVENT; }
CreatureEventAI_Event const& event = pHolder.Event; CreatureEventAI_Event const& event = pHolder.Event;
@ -209,7 +209,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
{ {
case EVENT_T_TIMER_IN_COMBAT: case EVENT_T_TIMER_IN_COMBAT:
if (!m_creature->IsInCombat()) if (!m_creature->IsInCombat())
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -217,7 +217,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
break; break;
case EVENT_T_TIMER_OOC: case EVENT_T_TIMER_OOC:
if (m_creature->IsInCombat() || m_creature->IsInEvadeMode()) if (m_creature->IsInCombat() || m_creature->IsInEvadeMode())
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -231,12 +231,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_HP: case EVENT_T_HP:
{ {
if (!m_creature->IsInCombat() || !m_creature->GetMaxHealth()) if (!m_creature->IsInCombat() || !m_creature->GetMaxHealth())
return false; { return false; }
uint32 perc = (m_creature->GetHealth() * 100) / m_creature->GetMaxHealth(); uint32 perc = (m_creature->GetHealth() * 100) / m_creature->GetMaxHealth();
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -246,12 +246,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_MANA: case EVENT_T_MANA:
{ {
if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_MANA)) if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_MANA))
return false; { return false; }
uint32 perc = (m_creature->GetPower(POWER_MANA) * 100) / m_creature->GetMaxPower(POWER_MANA); uint32 perc = (m_creature->GetPower(POWER_MANA) * 100) / m_creature->GetMaxPower(POWER_MANA);
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -293,12 +293,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_TARGET_HP: case EVENT_T_TARGET_HP:
{ {
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth()) if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth())
return false; { return false; }
uint32 perc = (m_creature->getVictim()->GetHealth() * 100) / m_creature->getVictim()->GetMaxHealth(); uint32 perc = (m_creature->getVictim()->GetHealth() * 100) / m_creature->getVictim()->GetMaxHealth();
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -307,7 +307,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
} }
case EVENT_T_TARGET_CASTING: case EVENT_T_TARGET_CASTING:
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true)) if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true))
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -316,11 +316,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_FRIENDLY_HP: case EVENT_T_FRIENDLY_HP:
{ {
if (!m_creature->IsInCombat()) if (!m_creature->IsInCombat())
return false; { return false; }
Unit* pUnit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit); Unit* pUnit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit);
if (!pUnit) if (!pUnit)
return false; { return false; }
pActionInvoker = pUnit; pActionInvoker = pUnit;
@ -332,14 +332,14 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_FRIENDLY_IS_CC: case EVENT_T_FRIENDLY_IS_CC:
{ {
if (!m_creature->IsInCombat()) if (!m_creature->IsInCombat())
return false; { return false; }
std::list<Creature*> pList; std::list<Creature*> pList;
DoFindFriendlyCC(pList, (float)event.friendly_is_cc.radius); DoFindFriendlyCC(pList, (float)event.friendly_is_cc.radius);
// List is empty // List is empty
if (pList.empty()) if (pList.empty())
return false; { return false; }
// We don't really care about the whole list, just return first available // We don't really care about the whole list, just return first available
pActionInvoker = *(pList.begin()); pActionInvoker = *(pList.begin());
@ -355,7 +355,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
// List is empty // List is empty
if (pList.empty()) if (pList.empty())
return false; { return false; }
// We don't really care about the whole list, just return first available // We don't really care about the whole list, just return first available
pActionInvoker = *(pList.begin()); pActionInvoker = *(pList.begin());
@ -370,11 +370,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
{ {
// Prevent event from occuring on no unit or non creatures // Prevent event from occuring on no unit or non creatures
if (!pActionInvoker || pActionInvoker->GetTypeId() != TYPEID_UNIT) if (!pActionInvoker || pActionInvoker->GetTypeId() != TYPEID_UNIT)
return false; { return false; }
// Creature id doesn't match up // Creature id doesn't match up
if (((Creature*)pActionInvoker)->GetEntry() != event.summoned.creatureId) if (((Creature*)pActionInvoker)->GetEntry() != event.summoned.creatureId)
return false; { return false; }
// Repeat Timers // Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.summoned.repeatMin, event.summoned.repeatMax); pHolder.UpdateRepeatTimer(m_creature, event.summoned.repeatMin, event.summoned.repeatMax);
@ -383,12 +383,12 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_TARGET_MANA: case EVENT_T_TARGET_MANA:
{ {
if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxPower(POWER_MANA)) if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxPower(POWER_MANA))
return false; { return false; }
uint32 perc = (m_creature->getVictim()->GetPower(POWER_MANA) * 100) / m_creature->getVictim()->GetMaxPower(POWER_MANA); uint32 perc = (m_creature->getVictim()->GetPower(POWER_MANA) * 100) / m_creature->getVictim()->GetMaxPower(POWER_MANA);
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false; { return false; }
// Repeat Timers // Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax); pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax);
@ -404,7 +404,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId); SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId);
if (!holder || holder->GetStackAmount() < event.buffed.amount) if (!holder || holder->GetStackAmount() < event.buffed.amount)
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -414,11 +414,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_TARGET_AURA: case EVENT_T_TARGET_AURA:
{ {
if (!m_creature->IsInCombat() || !m_creature->getVictim()) if (!m_creature->IsInCombat() || !m_creature->getVictim())
return false; { return false; }
SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId); SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId);
if (!holder || holder->GetStackAmount() < event.buffed.amount) if (!holder || holder->GetStackAmount() < event.buffed.amount)
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -432,7 +432,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId); SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId);
if (holder && holder->GetStackAmount() >= event.buffed.amount) if (holder && holder->GetStackAmount() >= event.buffed.amount)
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -442,11 +442,11 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_TARGET_MISSING_AURA: case EVENT_T_TARGET_MISSING_AURA:
{ {
if (!m_creature->IsInCombat() || !m_creature->getVictim()) if (!m_creature->IsInCombat() || !m_creature->getVictim())
return false; { return false; }
SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId); SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId);
if (holder && holder->GetStackAmount() >= event.buffed.amount) if (holder && holder->GetStackAmount() >= event.buffed.amount)
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
@ -458,13 +458,13 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
case EVENT_T_ENERGY: case EVENT_T_ENERGY:
{ {
if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_ENERGY)) if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_ENERGY))
return false; { return false; }
uint32 perc = (m_creature->GetPower(POWER_ENERGY) * 100) / m_creature->GetMaxPower(POWER_ENERGY); uint32 perc = (m_creature->GetPower(POWER_ENERGY) * 100) / m_creature->GetMaxPower(POWER_ENERGY);
if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin)
return false; { return false; }
LOG_PROCESS_EVENT; LOG_PROCESS_EVENT;
// Repeat Timers // Repeat Timers
pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax); pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax);
@ -477,20 +477,20 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
// Disable non-repeatable events // Disable non-repeatable events
if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE)) if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE))
pHolder.Enabled = false; { pHolder.Enabled = false; }
// Store random here so that all random actions match up // Store random here so that all random actions match up
uint32 rnd = rand(); uint32 rnd = rand();
// Return if chance for event is not met // Return if chance for event is not met
if (pHolder.Event.event_chance <= rnd % 100) if (pHolder.Event.event_chance <= rnd % 100)
return false; { return false; }
// Process actions, normal case // Process actions, normal case
if (!(pHolder.Event.event_flags & EFLAG_RANDOM_ACTION)) if (!(pHolder.Event.event_flags & EFLAG_RANDOM_ACTION))
{ {
for (uint32 j = 0; j < MAX_ACTIONS; ++j) for (uint32 j = 0; j < MAX_ACTIONS; ++j)
ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker, pAIEventSender); { ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker, pAIEventSender); }
} }
// Process actions, random case // Process actions, random case
else else
@ -499,7 +499,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
uint32 count = 0; uint32 count = 0;
for (uint32 j = 0; j < MAX_ACTIONS; ++j) for (uint32 j = 0; j < MAX_ACTIONS; ++j)
if (pHolder.Event.action[j].type != ACTION_T_NONE) if (pHolder.Event.action[j].type != ACTION_T_NONE)
++count; { ++count; }
if (count) if (count)
{ {
@ -513,7 +513,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
if (pHolder.Event.action[j].type != ACTION_T_NONE) if (pHolder.Event.action[j].type != ACTION_T_NONE)
{ {
if (!idx) if (!idx)
break; { break; }
--idx; --idx;
} }
} }
@ -527,7 +527,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker, Creature* pAIEventSender) void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker, Creature* pAIEventSender)
{ {
if (action.type == ACTION_T_NONE) if (action.type == ACTION_T_NONE)
return; { return; }
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Process action %u (script %u) triggered for %s (invoked by %s)", DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Process action %u (script %u) triggered for %s (invoked by %s)",
action.type, EventId, m_creature->GetGuidStr().c_str(), pActionInvoker ? pActionInvoker->GetGuidStr().c_str() : "<no invoker>"); action.type, EventId, m_creature->GetGuidStr().c_str(), pActionInvoker ? pActionInvoker->GetGuidStr().c_str() : "<no invoker>");
@ -539,7 +539,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_CHANCED_TEXT: case ACTION_T_CHANCED_TEXT:
{ {
if (!action.text.TextId[0]) if (!action.text.TextId[0])
return; { return; }
int32 textId = 0; int32 textId = 0;
@ -548,9 +548,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (action.text.TextId[1] && action.text.TextId[2]) if (action.text.TextId[1] && action.text.TextId[2])
textId = action.text.TextId[rnd % 3]; textId = action.text.TextId[rnd % 3];
else if (action.text.TextId[1] && (rnd % 2)) else if (action.text.TextId[1] && (rnd % 2))
textId = action.text.TextId[1]; { textId = action.text.TextId[1]; }
else else
textId = action.text.TextId[0]; { textId = action.text.TextId[0]; }
} }
// ACTION_T_CHANCED_TEXT, chance hits // ACTION_T_CHANCED_TEXT, chance hits
else if ((rnd % 100) < action.chanced_text.chance) else if ((rnd % 100) < action.chanced_text.chance)
@ -558,7 +558,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (action.chanced_text.TextId[0] && action.chanced_text.TextId[1]) if (action.chanced_text.TextId[0] && action.chanced_text.TextId[1])
textId = action.chanced_text.TextId[rnd % 2]; textId = action.chanced_text.TextId[rnd % 2];
else else
textId = action.chanced_text.TextId[0]; { textId = action.chanced_text.TextId[0]; }
} }
if (textId) if (textId)
@ -568,11 +568,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (pActionInvoker) if (pActionInvoker)
{ {
if (pActionInvoker->GetTypeId() == TYPEID_PLAYER) if (pActionInvoker->GetTypeId() == TYPEID_PLAYER)
target = pActionInvoker; { target = pActionInvoker; }
else if (Unit* owner = pActionInvoker->GetOwner()) else if (Unit* owner = pActionInvoker->GetOwner())
{ {
if (owner->GetTypeId() == TYPEID_PLAYER) if (owner->GetTypeId() == TYPEID_PLAYER)
target = owner; { target = owner; }
} }
} }
else if ((target = m_creature->getVictim())) else if ((target = m_creature->getVictim()))
@ -580,20 +580,20 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (target->GetTypeId() != TYPEID_PLAYER) if (target->GetTypeId() != TYPEID_PLAYER)
if (Unit* owner = target->GetOwner()) if (Unit* owner = target->GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER) if (owner->GetTypeId() == TYPEID_PLAYER)
target = owner; { target = owner; }
} }
if (!DoDisplayText(m_creature, textId, target)) if (!DoDisplayText(m_creature, textId, target))
sLog.outErrorEventAI("Error attempting to display text %i, used by script %u", textId, EventId); { sLog.outErrorEventAI("Error attempting to display text %i, used by script %u", textId, EventId); }
} }
break; break;
} }
case ACTION_T_SET_FACTION: case ACTION_T_SET_FACTION:
{ {
if (action.set_faction.factionId) if (action.set_faction.factionId)
m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags); { m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags); }
else // no id provided, assume reset and then use default else // no id provided, assume reset and then use default
m_creature->ClearTemporaryFaction(); { m_creature->ClearTemporaryFaction(); }
break; break;
} }
@ -612,10 +612,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
} }
// if no param1, then use value from param2 (modelId) // if no param1, then use value from param2 (modelId)
else else
m_creature->SetDisplayId(action.morph.modelId); { m_creature->SetDisplayId(action.morph.modelId); }
} }
else else
m_creature->DeMorph(); { m_creature->DeMorph(); }
break; break;
} }
case ACTION_T_SOUND: case ACTION_T_SOUND:
@ -628,14 +628,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ {
int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3); int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3);
if (temp >= 0) if (temp >= 0)
m_creature->PlayDirectSound(temp); { m_creature->PlayDirectSound(temp); }
break; break;
} }
case ACTION_T_RANDOM_EMOTE: case ACTION_T_RANDOM_EMOTE:
{ {
int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3); int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3);
if (temp >= 0) if (temp >= 0)
m_creature->HandleEmote(temp); { m_creature->HandleEmote(temp); }
break; break;
} }
case ACTION_T_CAST: case ACTION_T_CAST:
@ -652,7 +652,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (!target) if (!target)
{ {
if (reportTargetError) if (reportTargetError)
sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId); { sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId); }
return; return;
} }
@ -715,53 +715,52 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{ {
Unit* target = GetTargetByType(action.summon.target, pActionInvoker, pAIEventSender, reportTargetError); Unit* target = GetTargetByType(action.summon.target, pActionInvoker, pAIEventSender, reportTargetError);
if (!target && reportTargetError) if (!target && reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON(%u), target-type %u", EventId, action.type, action.summon.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON(%u), target-type %u", EventId, action.type, action.summon.target); }
Creature* pCreature = NULL; Creature* pCreature = NULL;
if (action.summon.duration) if (action.summon.duration)
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, action.summon.duration); { pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, action.summon.duration); }
else else
pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); { pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); }
if (!pCreature) if (!pCreature)
sLog.outErrorEventAI("failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry()); { sLog.outErrorEventAI("failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry()); }
else if (action.summon.target != TARGET_T_SELF && target) else if (action.summon.target != TARGET_T_SELF && target)
pCreature->AI()->AttackStart(target); { pCreature->AI()->AttackStart(target); }
break; break;
} }
case ACTION_T_THREAT_SINGLE_PCT: case ACTION_T_THREAT_SINGLE_PCT:
if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker, pAIEventSender, reportTargetError)) if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker, pAIEventSender, reportTargetError))
m_creature->GetThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); { m_creature->GetThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); }
else if (reportTargetError) else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_THREAT_SINGLE_PCT(%u), target-type %u", EventId, action.type, action.threat_single_pct.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_THREAT_SINGLE_PCT(%u), target-type %u", EventId, action.type, action.threat_single_pct.target); }
break; break;
case ACTION_T_THREAT_ALL_PCT: case ACTION_T_THREAT_ALL_PCT:
{ {
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList(); ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i) for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
if (Unit* Temp = m_creature->GetMap()->GetUnit((*i)->getUnitGuid())) if (Unit* Temp = m_creature->GetMap()->GetUnit((*i)->getUnitGuid()))
m_creature->GetThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); { m_creature->GetThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); }
break; break;
} }
case ACTION_T_QUEST_EVENT: case ACTION_T_QUEST_EVENT:
if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker, pAIEventSender, reportTargetError)) if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker, pAIEventSender, reportTargetError))
{ {
if (target->GetTypeId() == TYPEID_PLAYER) if (target->GetTypeId() == TYPEID_PLAYER)
((Player*)target)->AreaExploredOrEventHappens(action.quest_event.questId); { ((Player*)target)->AreaExploredOrEventHappens(action.quest_event.questId); }
} }
else if (reportTargetError) else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_QUEST_EVENT(%u), target-type %u", EventId, action.type, action.quest_event.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_QUEST_EVENT(%u), target-type %u", EventId, action.type, action.quest_event.target); }
break; break;
case ACTION_T_CAST_EVENT: case ACTION_T_CAST_EVENT:
if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER)) if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER))
{ {
if (target->GetTypeId() == TYPEID_PLAYER) if (target->GetTypeId() == TYPEID_PLAYER)
((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetObjectGuid(), action.cast_event.spellId); { ((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetObjectGuid(), action.cast_event.spellId); }
} }
else if (reportTargetError) else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_CST_EVENT(%u), target-type %u", EventId, action.type, action.cast_event.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_CST_EVENT(%u), target-type %u", EventId, action.type, action.cast_event.target); }
break; break;
case ACTION_T_SET_UNIT_FIELD: case ACTION_T_SET_UNIT_FIELD:
{ {
@ -769,38 +768,38 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
// not allow modify important for integrity object fields // not allow modify important for integrity object fields
if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END)
return; { return; }
else if (reportTargetError) else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FIELD(%u), target-type %u", EventId, action.type, action.set_unit_field.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FIELD(%u), target-type %u", EventId, action.type, action.set_unit_field.target); }
break; break;
} }
case ACTION_T_SET_UNIT_FLAG: case ACTION_T_SET_UNIT_FLAG:
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError)) if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); { target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); }
else if (reportTargetError) else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); }
break; break;
case ACTION_T_REMOVE_UNIT_FLAG: case ACTION_T_REMOVE_UNIT_FLAG:
if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError)) if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError))
target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); { target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); }
else if (reportTargetError) else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVE_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVE_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); }
case ACTION_T_AUTO_ATTACK: case ACTION_T_AUTO_ATTACK:
m_MeleeEnabled = action.auto_attack.state != 0; m_MeleeEnabled = action.auto_attack.state != 0;
break; break;
case ACTION_T_COMBAT_MOVEMENT: case ACTION_T_COMBAT_MOVEMENT:
// ignore no affect case // ignore no affect case
if (m_isCombatMovement == (action.combat_movement.state != 0) || m_creature->IsNonMeleeSpellCasted(false)) if (m_isCombatMovement == (action.combat_movement.state != 0) || m_creature->IsNonMeleeSpellCasted(false))
return; { return; }
SetCombatMovement(action.combat_movement.state != 0, true); SetCombatMovement(action.combat_movement.state != 0, true);
if (m_isCombatMovement && action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim()) if (m_isCombatMovement && action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim())
m_creature->SendMeleeAttackStart(m_creature->getVictim()); { m_creature->SendMeleeAttackStart(m_creature->getVictim()); }
else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim()) else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim())
m_creature->SendMeleeAttackStop(m_creature->getVictim()); { m_creature->SendMeleeAttackStop(m_creature->getVictim()); }
break; break;
case ACTION_T_SET_PHASE: case ACTION_T_SET_PHASE:
m_Phase = action.set_phase.phase; m_Phase = action.set_phase.phase;
@ -816,11 +815,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
} }
else if (new_phase >= MAX_PHASE) else if (new_phase >= MAX_PHASE)
{ {
sLog.outErrorEventAI("Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE - 1, MAX_PHASE - 1, m_creature->GetEntry()); sLog.outErrorEventAI("Event %d incremented Phase above %u. Phase mask can not be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE - 1, MAX_PHASE - 1, m_creature->GetEntry());
m_Phase = MAX_PHASE - 1; m_Phase = MAX_PHASE - 1;
} }
else else
m_Phase = new_phase; { m_Phase = new_phase; }
DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_INC_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase); DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_INC_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase);
break; break;
@ -840,21 +839,21 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
temp->GroupEventHappens(action.quest_event_all.questId, m_creature); temp->GroupEventHappens(action.quest_event_all.questId, m_creature);
} }
else if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER) else if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER)
((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature); { ((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature); }
break; break;
case ACTION_T_CAST_EVENT_ALL: case ACTION_T_CAST_EVENT_ALL:
{ {
ThreatList const& threatList = m_creature->GetThreatManager().getThreatList(); ThreatList const& threatList = m_creature->GetThreatManager().getThreatList();
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i) for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
if (Player* temp = m_creature->GetMap()->GetPlayer((*i)->getUnitGuid())) if (Player* temp = m_creature->GetMap()->GetPlayer((*i)->getUnitGuid()))
temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); { temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); }
break; break;
} }
case ACTION_T_REMOVEAURASFROMSPELL: case ACTION_T_REMOVEAURASFROMSPELL:
if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker, pAIEventSender, reportTargetError)) if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker, pAIEventSender, reportTargetError))
target->RemoveAurasDueToSpell(action.remove_aura.spellId); { target->RemoveAurasDueToSpell(action.remove_aura.spellId); }
else if (reportTargetError) else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVEAURASFROMSPELL(%u), target-type %u", EventId, action.type, action.remove_aura.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVEAURASFROMSPELL(%u), target-type %u", EventId, action.type, action.remove_aura.target); }
break; break;
case ACTION_T_RANGED_MOVEMENT: case ACTION_T_RANGED_MOVEMENT:
m_attackDistance = (float)action.ranged_movement.distance; m_attackDistance = (float)action.ranged_movement.distance;
@ -876,16 +875,16 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
break; break;
case ACTION_T_RANDOM_PHASE_RANGE: case ACTION_T_RANDOM_PHASE_RANGE:
if (action.random_phase_range.phaseMax > action.random_phase_range.phaseMin) if (action.random_phase_range.phaseMax > action.random_phase_range.phaseMin)
m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin)); { m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin)); }
else else
sLog.outErrorEventAI("ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); { sLog.outErrorEventAI("ACTION_T_RANDOM_PHASE_RANGE can not have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); }
break; break;
case ACTION_T_SUMMON_ID: case ACTION_T_SUMMON_ID:
{ {
Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker, pAIEventSender, reportTargetError); Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker, pAIEventSender, reportTargetError);
if (!target && reportTargetError) if (!target && reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON_ID(%u), target-type %u", EventId, action.type, action.summon_id.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON_ID(%u), target-type %u", EventId, action.type, action.summon_id.target); }
CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId); CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId);
if (i == sEventAIMgr.GetCreatureEventAISummonMap().end()) if (i == sEventAIMgr.GetCreatureEventAISummonMap().end())
{ {
@ -900,26 +899,26 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_DESPAWN, 0);
if (!pCreature) if (!pCreature)
sLog.outErrorEventAI("failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry()); { sLog.outErrorEventAI("failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry()); }
else if (action.summon_id.target != TARGET_T_SELF && target) else if (action.summon_id.target != TARGET_T_SELF && target)
pCreature->AI()->AttackStart(target); { pCreature->AI()->AttackStart(target); }
break; break;
} }
case ACTION_T_KILLED_MONSTER: case ACTION_T_KILLED_MONSTER:
// first attempt player/group who tapped creature // first attempt player/group who tapped creature
if (Player* pPlayer = m_creature->GetLootRecipient()) if (Player* pPlayer = m_creature->GetLootRecipient())
pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); { pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); }
else else
{ {
// if not available, use pActionInvoker // if not available, use pActionInvoker
if (Unit* pTarget = GetTargetByType(action.killed_monster.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER)) if (Unit* pTarget = GetTargetByType(action.killed_monster.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER))
{ {
if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself()) if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself())
pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); { pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); }
} }
else if (reportTargetError) else if (reportTargetError)
sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_KILLED_MONSTER(%u), target-type %u", EventId, action.type, action.killed_monster.target); { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_KILLED_MONSTER(%u), target-type %u", EventId, action.type, action.killed_monster.target); }
} }
break; break;
case ACTION_T_SET_INST_DATA: case ACTION_T_SET_INST_DATA:
@ -940,7 +939,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
if (!target) if (!target)
{ {
if (reportTargetError) if (reportTargetError)
sLog.outErrorEventAI("Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry()); { sLog.outErrorEventAI("Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry()); }
return; return;
} }
@ -957,7 +956,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_UPDATE_TEMPLATE: case ACTION_T_UPDATE_TEMPLATE:
if (m_creature->GetEntry() == action.update_template.creatureId) if (m_creature->GetEntry() == action.update_template.creatureId)
{ {
sLog.outErrorEventAI("Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, m_creature->GetEntry()); sLog.outErrorEventAI("Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, m_creature->GetEntry());
return; return;
} }
@ -967,7 +965,6 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_DIE: case ACTION_T_DIE:
if (m_creature->IsDead()) if (m_creature->IsDead())
{ {
sLog.outErrorEventAI("Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry()); sLog.outErrorEventAI("Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry());
return; return;
} }
@ -996,9 +993,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
{ {
if (action.invincibility_hp_level.is_percent) if (action.invincibility_hp_level.is_percent)
m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100; { m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100; }
else else
m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; { m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; }
break; break;
} }
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL: case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL:
@ -1016,10 +1013,10 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
} }
// if no param1, then use value from param2 (modelId) // if no param1, then use value from param2 (modelId)
else else
m_creature->Mount(action.mount.modelId); { m_creature->Mount(action.mount.modelId); }
} }
else else
m_creature->Unmount(); { m_creature->Unmount(); }
break; break;
} }
@ -1079,11 +1076,11 @@ void CreatureEventAI::JustRespawned() // NOTE that this is
if (i->Event.event_type == EVENT_T_TIMER_GENERIC) if (i->Event.event_type == EVENT_T_TIMER_GENERIC)
{ {
if (i->UpdateRepeatTimer(m_creature, i->Event.timer.initialMin, i->Event.timer.initialMax)) if (i->UpdateRepeatTimer(m_creature, i->Event.timer.initialMin, i->Event.timer.initialMax))
i->Enabled = true; { i->Enabled = true; }
} }
// Handle Spawned Events // Handle Spawned Events
else if (SpawnedEventConditionsCheck((*i).Event)) else if (SpawnedEventConditionsCheck((*i).Event))
ProcessEvent(*i); { ProcessEvent(*i); }
} }
} }
@ -1099,7 +1096,7 @@ void CreatureEventAI::Reset()
CreatureEventAI_Event const& event = i->Event; CreatureEventAI_Event const& event = i->Event;
switch (event.event_type) switch (event.event_type)
{ {
// Reset all out of combat timers // Reset all out of combat timers
case EVENT_T_TIMER_OOC: case EVENT_T_TIMER_OOC:
{ {
if (i->UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax)) if (i->UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax))
@ -1120,7 +1117,7 @@ void CreatureEventAI::JustReachedHome()
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{ {
if (i->Event.event_type == EVENT_T_REACHED_HOME) if (i->Event.event_type == EVENT_T_REACHED_HOME)
ProcessEvent(*i); { ProcessEvent(*i); }
} }
Reset(); Reset();
@ -1134,7 +1131,7 @@ void CreatureEventAI::EnterEvadeMode()
// only alive creatures that are not on transport can return to home position // only alive creatures that are not on transport can return to home position
if (m_creature->IsAlive() && !m_creature->IsBoarded()) if (m_creature->IsAlive() && !m_creature->IsBoarded())
m_creature->GetMotionMaster()->MoveTargetedHome(); { m_creature->GetMotionMaster()->MoveTargetedHome(); }
m_creature->SetLootRecipient(NULL); m_creature->SetLootRecipient(NULL);
@ -1142,7 +1139,7 @@ void CreatureEventAI::EnterEvadeMode()
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{ {
if (i->Event.event_type == EVENT_T_EVADE) if (i->Event.event_type == EVENT_T_EVADE)
ProcessEvent(*i); { ProcessEvent(*i); }
} }
} }
@ -1154,17 +1151,17 @@ void CreatureEventAI::JustDied(Unit* killer)
{ {
// Send Zone Under Attack message to the LocalDefense and WorldDefense Channels // Send Zone Under Attack message to the LocalDefense and WorldDefense Channels
if (Player* pKiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) if (Player* pKiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
m_creature->SendZoneUnderAttackMessage(pKiller); { m_creature->SendZoneUnderAttackMessage(pKiller); }
} }
if (m_throwAIEventMask & (1 << AI_EVENT_JUST_DIED)) if (m_throwAIEventMask & (1 << AI_EVENT_JUST_DIED))
SendAIEventAround(AI_EVENT_JUST_DIED, killer, 0, AIEVENT_DEFAULT_THROW_RADIUS); { SendAIEventAround(AI_EVENT_JUST_DIED, killer, 0, AIEVENT_DEFAULT_THROW_RADIUS); }
// Handle On Death events // Handle On Death events
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{ {
if (i->Event.event_type == EVENT_T_DEATH) if (i->Event.event_type == EVENT_T_DEATH)
ProcessEvent(*i, killer); { ProcessEvent(*i, killer); }
} }
// reset phase after any death state events // reset phase after any death state events
@ -1174,12 +1171,12 @@ void CreatureEventAI::JustDied(Unit* killer)
void CreatureEventAI::KilledUnit(Unit* victim) void CreatureEventAI::KilledUnit(Unit* victim)
{ {
if (victim->GetTypeId() != TYPEID_PLAYER) if (victim->GetTypeId() != TYPEID_PLAYER)
return; { return; }
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{ {
if (i->Event.event_type == EVENT_T_KILL) if (i->Event.event_type == EVENT_T_KILL)
ProcessEvent(*i, victim); { ProcessEvent(*i, victim); }
} }
} }
@ -1188,7 +1185,7 @@ void CreatureEventAI::JustSummoned(Creature* pUnit)
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{ {
if (i->Event.event_type == EVENT_T_SUMMONED_UNIT) if (i->Event.event_type == EVENT_T_SUMMONED_UNIT)
ProcessEvent(*i, pUnit); { ProcessEvent(*i, pUnit); }
} }
} }
@ -1197,7 +1194,7 @@ void CreatureEventAI::SummonedCreatureJustDied(Creature* pUnit)
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{ {
if (i->Event.event_type == EVENT_T_SUMMONED_JUST_DIED) if (i->Event.event_type == EVENT_T_SUMMONED_JUST_DIED)
ProcessEvent(*i, pUnit); { ProcessEvent(*i, pUnit); }
} }
} }
@ -1206,7 +1203,7 @@ void CreatureEventAI::SummonedCreatureDespawn(Creature* pUnit)
for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i)
{ {
if (i->Event.event_type == EVENT_T_SUMMONED_JUST_DESPAWN) if (i->Event.event_type == EVENT_T_SUMMONED_JUST_DESPAWN)
ProcessEvent(*i, pUnit); { ProcessEvent(*i, pUnit); }
} }
} }
@ -1217,8 +1214,8 @@ void CreatureEventAI::ReceiveAIEvent(AIEventType eventType, Creature* pSender, U
for (CreatureEventAIList::iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr) for (CreatureEventAIList::iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr)
{ {
if (itr->Event.event_type == EVENT_T_RECEIVE_AI_EVENT && if (itr->Event.event_type == EVENT_T_RECEIVE_AI_EVENT &&
itr->Event.receiveAIEvent.eventType == eventType && (!itr->Event.receiveAIEvent.senderEntry || itr->Event.receiveAIEvent.senderEntry == pSender->GetEntry())) itr->Event.receiveAIEvent.eventType == eventType && (!itr->Event.receiveAIEvent.senderEntry || itr->Event.receiveAIEvent.senderEntry == pSender->GetEntry()))
ProcessEvent(*itr, pInvoker, pSender); { ProcessEvent(*itr, pInvoker, pSender); }
} }
} }
@ -1234,12 +1231,12 @@ void CreatureEventAI::EnterCombat(Unit* enemy)
i->Enabled = true; i->Enabled = true;
ProcessEvent(*i, enemy); ProcessEvent(*i, enemy);
break; break;
// Reset all in combat timers // Reset all in combat timers
case EVENT_T_TIMER_IN_COMBAT: case EVENT_T_TIMER_IN_COMBAT:
if (i->UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax)) if (i->UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax))
i->Enabled = true; i->Enabled = true;
break; break;
// All normal events need to be re-enabled and their time set to 0 // All normal events need to be re-enabled and their time set to 0
default: default:
i->Enabled = true; i->Enabled = true;
i->Time = 0; i->Time = 0;
@ -1254,7 +1251,7 @@ void CreatureEventAI::EnterCombat(Unit* enemy)
void CreatureEventAI::AttackStart(Unit* who) void CreatureEventAI::AttackStart(Unit* who)
{ {
if (!who || !m_creature->CanAttackByItself()) if (!who || !m_creature->CanAttackByItself())
return; { return; }
if (m_creature->Attack(who, m_MeleeEnabled)) if (m_creature->Attack(who, m_MeleeEnabled))
{ {
@ -1269,7 +1266,7 @@ void CreatureEventAI::AttackStart(Unit* who)
void CreatureEventAI::MoveInLineOfSight(Unit* who) void CreatureEventAI::MoveInLineOfSight(Unit* who)
{ {
if (!who) if (!who)
return; { return; }
// Check for OOC LOS Event // Check for OOC LOS Event
if (m_HasOOCLoSEvent && !m_creature->getVictim()) if (m_HasOOCLoSEvent && !m_creature->getVictim())
@ -1294,13 +1291,13 @@ void CreatureEventAI::MoveInLineOfSight(Unit* who)
} }
if (m_creature->IsCivilian() || m_creature->IsNeutralToAll()) if (m_creature->IsCivilian() || m_creature->IsNeutralToAll())
return; { return; }
if (m_creature->CanInitiateAttack() && who->IsTargetableForAttack() && if (m_creature->CanInitiateAttack() && who->IsTargetableForAttack() &&
m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature)) m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature))
{ {
if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
return; { return; }
float attackRadius = m_creature->GetAttackDistance(who); float attackRadius = m_creature->GetAttackDistance(who);
if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who))
@ -1326,7 +1323,7 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
// If spell id matches (or no spell id) & if spell school matches (or no spell school) // If spell id matches (or no spell id) & if spell school matches (or no spell school)
if (!i->Event.spell_hit.spellId || pSpell->Id == i->Event.spell_hit.spellId) if (!i->Event.spell_hit.spellId || pSpell->Id == i->Event.spell_hit.spellId)
if (pSpell->SchoolMask & i->Event.spell_hit.schoolMask) if (pSpell->SchoolMask & i->Event.spell_hit.schoolMask)
ProcessEvent(*i, pUnit); { ProcessEvent(*i, pUnit); }
} }
void CreatureEventAI::UpdateAI(const uint32 diff) void CreatureEventAI::UpdateAI(const uint32 diff)
@ -1347,7 +1344,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
{ {
if (i->Time > m_EventDiff) if (i->Time > m_EventDiff)
{ {
// Do not decrement timers if event cannot trigger in this phase // Do not decrement timers if event can not trigger in this phase
if (!(i->Event.event_inverse_phase_mask & (1 << m_Phase))) if (!(i->Event.event_inverse_phase_mask & (1 << m_Phase)))
i->Time -= m_EventDiff; i->Time -= m_EventDiff;
} }
@ -1433,52 +1430,52 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke
case TARGET_T_HOSTILE: case TARGET_T_HOSTILE:
resTarget = m_creature->getVictim(); resTarget = m_creature->getVictim();
if (!resTarget) if (!resTarget)
isError = true; { isError = true; }
return resTarget; return resTarget;
case TARGET_T_HOSTILE_SECOND_AGGRO: case TARGET_T_HOSTILE_SECOND_AGGRO:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 1, forSpellId, selectFlags); resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 1, forSpellId, selectFlags);
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty())) if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty()))
isError = true; { isError = true; }
return resTarget; return resTarget;
case TARGET_T_HOSTILE_LAST_AGGRO: case TARGET_T_HOSTILE_LAST_AGGRO:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_BOTTOMAGGRO, 0, forSpellId, selectFlags); resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_BOTTOMAGGRO, 0, forSpellId, selectFlags);
if (!resTarget && m_creature->GetThreatManager().getThreatList().empty()) if (!resTarget && m_creature->GetThreatManager().getThreatList().empty())
isError = true; { isError = true; }
return resTarget; return resTarget;
case TARGET_T_HOSTILE_RANDOM: case TARGET_T_HOSTILE_RANDOM:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, selectFlags); resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, selectFlags);
if (!resTarget && m_creature->GetThreatManager().getThreatList().empty()) if (!resTarget && m_creature->GetThreatManager().getThreatList().empty())
isError = true; { isError = true; }
return resTarget; return resTarget;
case TARGET_T_HOSTILE_RANDOM_NOT_TOP: case TARGET_T_HOSTILE_RANDOM_NOT_TOP:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, selectFlags); resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, selectFlags);
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty())) if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty()))
isError = true; { isError = true; }
return resTarget; return resTarget;
case TARGET_T_HOSTILE_RANDOM_PLAYER: case TARGET_T_HOSTILE_RANDOM_PLAYER:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, SELECT_FLAG_PLAYER | selectFlags); resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, SELECT_FLAG_PLAYER | selectFlags);
if (!resTarget) if (!resTarget)
isError = true; { isError = true; }
return resTarget; return resTarget;
case TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER: case TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER:
resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, SELECT_FLAG_PLAYER | selectFlags); resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, SELECT_FLAG_PLAYER | selectFlags);
if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty())) if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty()))
isError = true; { isError = true; }
return resTarget; return resTarget;
case TARGET_T_ACTION_INVOKER: case TARGET_T_ACTION_INVOKER:
if (!pActionInvoker) if (!pActionInvoker)
isError = true; { isError = true; }
return pActionInvoker; return pActionInvoker;
case TARGET_T_ACTION_INVOKER_OWNER: case TARGET_T_ACTION_INVOKER_OWNER:
resTarget = pActionInvoker ? pActionInvoker->GetCharmerOrOwnerOrSelf() : NULL; resTarget = pActionInvoker ? pActionInvoker->GetCharmerOrOwnerOrSelf() : NULL;
if (!resTarget) if (!resTarget)
isError = true; { isError = true; }
return resTarget; return resTarget;
case TARGET_T_EVENT_SENDER: case TARGET_T_EVENT_SENDER:
if (!pAIEventSender) if (!pAIEventSender)
isError = true; { isError = true; }
return pAIEventSender; return pAIEventSender;
default: default:
isError = true; isError = true;
return NULL; return NULL;
}; };
@ -1493,7 +1490,7 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
/* /*
typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes;
This means that if we only search grid then we cannot possibly return pets or players so this is safe This means that if we only search grid then we can not possibly return pets or players so this is safe
*/ */
Cell::VisitGridObjects(m_creature, searcher, range); Cell::VisitGridObjects(m_creature, searcher, range);
return pUnit; return pUnit;
@ -1542,9 +1539,9 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
if (m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel + damage) if (m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel + damage)
{ {
if (m_creature->GetHealth() <= m_InvinceabilityHpLevel) if (m_creature->GetHealth() <= m_InvinceabilityHpLevel)
damage = 0; { damage = 0; }
else else
damage = m_creature->GetHealth() - m_InvinceabilityHpLevel; { damage = m_creature->GetHealth() - m_InvinceabilityHpLevel; }
} }
uint32 step = m_throwAIEventStep != 100 ? m_throwAIEventStep : 0; uint32 step = m_throwAIEventStep != 100 ? m_throwAIEventStep : 0;
@ -1556,7 +1553,7 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
AIEventType sendEvent[HEALTH_STEPS] = { AI_EVENT_LOST_SOME_HEALTH, AI_EVENT_LOST_HEALTH, AI_EVENT_CRITICAL_HEALTH }; AIEventType sendEvent[HEALTH_STEPS] = { AI_EVENT_LOST_SOME_HEALTH, AI_EVENT_LOST_HEALTH, AI_EVENT_CRITICAL_HEALTH };
if (newHealthPercent > healthSteps[step]) if (newHealthPercent > healthSteps[step])
return; // Not reached the next mark { return; } // Not reached the next mark
// search for highest reached mark (with actual event attached) // search for highest reached mark (with actual event attached)
for (uint32 i = HEALTH_STEPS - 1; i > step; --i) for (uint32 i = HEALTH_STEPS - 1; i > step; --i)
@ -1569,7 +1566,7 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
} }
if (m_throwAIEventMask & (1 << sendEvent[step])) if (m_throwAIEventMask & (1 << sendEvent[step]))
SendAIEventAround(sendEvent[step], dealer, 0, AIEVENT_DEFAULT_THROW_RADIUS); { SendAIEventAround(sendEvent[step], dealer, 0, AIEVENT_DEFAULT_THROW_RADIUS); }
m_throwAIEventStep = step + 1; m_throwAIEventStep = step + 1;
} }
@ -1578,12 +1575,12 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage)
void CreatureEventAI::HealedBy(Unit* healer, uint32& healedAmount) void CreatureEventAI::HealedBy(Unit* healer, uint32& healedAmount)
{ {
if (m_throwAIEventStep == 100) if (m_throwAIEventStep == 100)
return; { return; }
if (m_creature->GetHealth() + healedAmount >= m_creature->GetMaxHealth()) if (m_creature->GetHealth() + healedAmount >= m_creature->GetMaxHealth())
{ {
if (m_throwAIEventMask & (1 << AI_EVENT_GOT_FULL_HEALTH)) if (m_throwAIEventMask & (1 << AI_EVENT_GOT_FULL_HEALTH))
SendAIEventAround(AI_EVENT_GOT_FULL_HEALTH, healer, 0, AIEVENT_DEFAULT_THROW_RADIUS); { SendAIEventAround(AI_EVENT_GOT_FULL_HEALTH, healer, 0, AIEVENT_DEFAULT_THROW_RADIUS); }
m_throwAIEventStep = 100; m_throwAIEventStep = 100;
} }
} }
@ -1591,7 +1588,7 @@ void CreatureEventAI::HealedBy(Unit* healer, uint32& healedAmount)
bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event) bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event)
{ {
if (event.event_type != EVENT_T_SPAWNED) if (event.event_type != EVENT_T_SPAWNED)
return false; { return false; }
switch (event.spawned.condition) switch (event.spawned.condition)
{ {

View file

@ -176,7 +176,7 @@ enum SpawnedEventMode
struct CreatureEventAI_Action struct CreatureEventAI_Action
{ {
EventAI_ActionType type : 16; EventAI_ActionType type: 16;
union union
{ {
// ACTION_T_TEXT = 1 // ACTION_T_TEXT = 1
@ -627,7 +627,7 @@ struct CreatureEventAIHolder
bool UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax); bool UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax);
}; };
class CreatureEventAI : public CreatureAI class CreatureEventAI : public CreatureAI
{ {
public: public:
explicit CreatureEventAI(Creature* c); explicit CreatureEventAI(Creature* c);
@ -656,7 +656,7 @@ class CreatureEventAI : public CreatureAI
void ReceiveEmote(Player* pPlayer, uint32 text_emote) override; void ReceiveEmote(Player* pPlayer, uint32 text_emote) override;
void SummonedCreatureJustDied(Creature* unit) override; void SummonedCreatureJustDied(Creature* unit) override;
void SummonedCreatureDespawn(Creature* unit) override; void SummonedCreatureDespawn(Creature* unit) override;
void ReceiveAIEvent(AIEventType eventType, Creature* pSender, Unit* pInvoker, uint32 miscValue) override; void ReceiveAIEvent(AIEventType eventType, Creature* pSender, Unit* pInvoker, uint32 miscValue) override;
static int Permissible(const Creature*); static int Permissible(const Creature*);
@ -666,7 +666,7 @@ class CreatureEventAI : public CreatureAI
inline int32 GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3); inline int32 GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3);
/// If the bool& param is true, an error should be reported /// If the bool& param is true, an error should be reported
inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker, Creature* pAIEventSender, bool& isError, uint32 forSpellId = 0, uint32 selectFlags = 0); inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker, Creature* pAIEventSender, bool& isError, uint32 forSpellId = 0, uint32 selectFlags = 0);
bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event); bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event);
Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff); Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff);

View file

@ -42,14 +42,15 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use)
{ {
// Load EventAI Text // Load EventAI Text
sObjectMgr.LoadMangosStrings(WorldDatabase, "creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID, true); sObjectMgr.LoadMangosStrings(WorldDatabase, "creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID, true);
if (check_entry_use) if (check_entry_use)
CheckUnusedAITexts(); { CheckUnusedAITexts(); }
} }
void CreatureEventAIMgr::CheckUnusedAITexts() void CreatureEventAIMgr::CheckUnusedAITexts()
{ {
if (m_usedTextsAmount == sObjectMgr.GetLoadedStringsCount(MIN_CREATURE_AI_TEXT_STRING_ID)) if (m_usedTextsAmount == sObjectMgr.GetLoadedStringsCount(MIN_CREATURE_AI_TEXT_STRING_ID))
return; { return; }
sLog.outString("Checking EventAI for unused texts, this might take a while"); sLog.outString("Checking EventAI for unused texts, this might take a while");
@ -57,7 +58,7 @@ void CreatureEventAIMgr::CheckUnusedAITexts()
// check not used strings this is negative range // check not used strings this is negative range
for (int32 i = MAX_CREATURE_AI_TEXT_STRING_ID + 1; i <= MIN_CREATURE_AI_TEXT_STRING_ID; ++i) for (int32 i = MAX_CREATURE_AI_TEXT_STRING_ID + 1; i <= MIN_CREATURE_AI_TEXT_STRING_ID; ++i)
if (sObjectMgr.GetMangosStringLocale(i)) if (sObjectMgr.GetMangosStringLocale(i))
idx_set.insert(i); { idx_set.insert(i); }
for (CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr) for (CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr)
{ {
@ -77,7 +78,7 @@ void CreatureEventAIMgr::CheckUnusedAITexts()
int k = action.type == ACTION_T_TEXT ? 0 : 1; int k = action.type == ACTION_T_TEXT ? 0 : 1;
for (; k < 3; ++k) for (; k < 3; ++k)
if (action.text.TextId[k]) if (action.text.TextId[k])
idx_set.erase(action.text.TextId[k]); { idx_set.erase(action.text.TextId[k]); }
break; break;
} }
default: break; default: break;
@ -105,7 +106,7 @@ bool IsValidTargetType(EventAI_Type eventType, EventAI_ActionType actionType, ui
case TARGET_T_HOSTILE_RANDOM: case TARGET_T_HOSTILE_RANDOM:
case TARGET_T_HOSTILE_RANDOM_NOT_TOP: case TARGET_T_HOSTILE_RANDOM_NOT_TOP:
if (actionType == ACTION_T_QUEST_EVENT || actionType == ACTION_T_CAST_EVENT || actionType == ACTION_T_QUEST_EVENT_ALL || actionType == ACTION_T_KILLED_MONSTER) if (actionType == ACTION_T_QUEST_EVENT || actionType == ACTION_T_CAST_EVENT || actionType == ACTION_T_QUEST_EVENT_ALL || actionType == ACTION_T_KILLED_MONSTER)
sLog.outErrorEventAI("Event %u Action%u uses LIKELY bad Target type %u for event-type %u (must target player)", eventId, action, targetType, eventType); { sLog.outErrorEventAI("Event %u Action%u uses LIKELY bad Target type %u for event-type %u (must target player)", eventId, action, targetType, eventType); }
// no break, check if valid at all // no break, check if valid at all
case TARGET_T_HOSTILE: case TARGET_T_HOSTILE:
case TARGET_T_HOSTILE_SECOND_AGGRO: case TARGET_T_HOSTILE_SECOND_AGGRO:
@ -117,10 +118,10 @@ bool IsValidTargetType(EventAI_Type eventType, EventAI_ActionType actionType, ui
case EVENT_T_TIMER_OOC: case EVENT_T_TIMER_OOC:
case EVENT_T_OOC_LOS: case EVENT_T_OOC_LOS:
case EVENT_T_REACHED_HOME: case EVENT_T_REACHED_HOME:
sLog.outErrorEventAI("Event %u Action%u uses incorrect Target type %u for event-type %u (cannot be used OOC)", eventId, action, targetType, eventType); sLog.outErrorEventAI("Event %u Action%u uses incorrect Target type %u for event-type %u (can not be used OOC)", eventId, action, targetType, eventType);
return false; return false;
case EVENT_T_TIMER_GENERIC: case EVENT_T_TIMER_GENERIC:
sLog.outErrorEventAI("Event %u Action%u uses LIKELY incorrect Target type %u for event-type %u (cannot be used OOC)", eventId, action, targetType, eventType); sLog.outErrorEventAI("Event %u Action%u uses LIKELY incorrect Target type %u for event-type %u (can not be used OOC)", eventId, action, targetType, eventType);
return true; // Does not need to be an error return true; // Does not need to be an error
default: default:
return true; return true;
@ -304,7 +305,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
// No chance of this event occuring // No chance of this event occuring
if (temp.event_chance == 0) if (temp.event_chance == 0)
sLog.outErrorEventAI("Event %u has 0 percent chance. Event will never trigger!", i); { sLog.outErrorEventAI("Event %u has 0 percent chance. Event will never trigger!", i); }
// Chance above 100, force it to be 100 // Chance above 100, force it to be 100
else if (temp.event_chance > 100) else if (temp.event_chance > 100)
{ {
@ -319,9 +320,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case EVENT_T_TIMER_OOC: case EVENT_T_TIMER_OOC:
case EVENT_T_TIMER_GENERIC: case EVENT_T_TIMER_GENERIC:
if (temp.timer.initialMax < temp.timer.initialMin) if (temp.timer.initialMax < temp.timer.initialMin)
sLog.outErrorEventAI("Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); }
if (temp.timer.repeatMax < temp.timer.repeatMin) if (temp.timer.repeatMax < temp.timer.repeatMin)
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_HP: case EVENT_T_HP:
case EVENT_T_MANA: case EVENT_T_MANA:
@ -329,14 +330,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case EVENT_T_TARGET_MANA: case EVENT_T_TARGET_MANA:
case EVENT_T_ENERGY: case EVENT_T_ENERGY:
if (temp.percent_range.percentMax > 100) if (temp.percent_range.percentMax > 100)
sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i); }
if (temp.percent_range.percentMax <= temp.percent_range.percentMin) if (temp.percent_range.percentMax <= temp.percent_range.percentMin)
sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i); }
if (temp.event_flags & EFLAG_REPEATABLE && !temp.percent_range.repeatMin && !temp.percent_range.repeatMax) if (temp.event_flags & EFLAG_REPEATABLE && !temp.percent_range.repeatMin && !temp.percent_range.repeatMax)
{ {
sLog.outErrorEventAI("Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but cannot be repeatable without timers. Removing EFLAG_REPEATABLE for event %u.", temp.creature_id, i); sLog.outErrorEventAI("Creature %u has param3 and param4=0 (RepeatMin/RepeatMax) but can not be repeatable without timers. Removing EFLAG_REPEATABLE for event %u.", temp.creature_id, i);
temp.event_flags &= ~EFLAG_REPEATABLE; temp.event_flags &= ~EFLAG_REPEATABLE;
} }
break; break;
@ -351,24 +352,24 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
} }
if ((temp.spell_hit.schoolMask & pSpell->SchoolMask) != pSpell->SchoolMask) if ((temp.spell_hit.schoolMask & pSpell->SchoolMask) != pSpell->SchoolMask)
sLog.outErrorEventAI("Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i); { sLog.outErrorEventAI("Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i); }
} }
if (!temp.spell_hit.schoolMask) if (!temp.spell_hit.schoolMask)
sLog.outErrorEventAI("Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i); { sLog.outErrorEventAI("Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i); }
if (temp.spell_hit.repeatMax < temp.spell_hit.repeatMin) if (temp.spell_hit.repeatMax < temp.spell_hit.repeatMin)
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_RANGE: case EVENT_T_RANGE:
if (temp.range.maxDist < temp.range.minDist) if (temp.range.maxDist < temp.range.minDist)
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (MaxDist < MinDist). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (MaxDist < MinDist). Event will never repeat.", temp.creature_id, i); }
if (temp.range.repeatMax < temp.range.repeatMin) if (temp.range.repeatMax < temp.range.repeatMin)
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_OOC_LOS: case EVENT_T_OOC_LOS:
if (temp.ooc_los.repeatMax < temp.ooc_los.repeatMin) if (temp.ooc_los.repeatMax < temp.ooc_los.repeatMin)
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_SPAWNED: case EVENT_T_SPAWNED:
switch (temp.spawned.condition) switch (temp.spawned.condition)
@ -377,11 +378,11 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break; break;
case SPAWNED_EVENT_MAP: case SPAWNED_EVENT_MAP:
if (!sMapStore.LookupEntry(temp.spawned.conditionValue1)) if (!sMapStore.LookupEntry(temp.spawned.conditionValue1))
sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); { sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); }
break; break;
case SPAWNED_EVENT_ZONE: case SPAWNED_EVENT_ZONE:
if (!GetAreaEntryByAreaID(temp.spawned.conditionValue1)) if (!GetAreaEntryByAreaID(temp.spawned.conditionValue1))
sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); { sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); }
break; break;
default: default:
sLog.outErrorEventAI("Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition); sLog.outErrorEventAI("Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition);
@ -390,11 +391,11 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break; break;
case EVENT_T_FRIENDLY_HP: case EVENT_T_FRIENDLY_HP:
if (temp.friendly_hp.repeatMax < temp.friendly_hp.repeatMin) if (temp.friendly_hp.repeatMax < temp.friendly_hp.repeatMin)
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_FRIENDLY_IS_CC: case EVENT_T_FRIENDLY_IS_CC:
if (temp.friendly_is_cc.repeatMax < temp.friendly_is_cc.repeatMin) if (temp.friendly_is_cc.repeatMax < temp.friendly_is_cc.repeatMin)
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_FRIENDLY_MISSING_BUFF: case EVENT_T_FRIENDLY_MISSING_BUFF:
{ {
@ -410,29 +411,29 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
continue; continue;
} }
if (temp.friendly_buff.repeatMax < temp.friendly_buff.repeatMin) if (temp.friendly_buff.repeatMax < temp.friendly_buff.repeatMin)
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
} }
case EVENT_T_KILL: case EVENT_T_KILL:
if (temp.kill.repeatMax < temp.kill.repeatMin) if (temp.kill.repeatMax < temp.kill.repeatMin)
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_TARGET_CASTING: case EVENT_T_TARGET_CASTING:
if (temp.target_casting.repeatMax < temp.target_casting.repeatMin) if (temp.target_casting.repeatMax < temp.target_casting.repeatMin)
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_SUMMONED_UNIT: case EVENT_T_SUMMONED_UNIT:
case EVENT_T_SUMMONED_JUST_DIED: case EVENT_T_SUMMONED_JUST_DIED:
case EVENT_T_SUMMONED_JUST_DESPAWN: case EVENT_T_SUMMONED_JUST_DESPAWN:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(temp.summoned.creatureId)) if (!sCreatureStorage.LookupEntry<CreatureInfo>(temp.summoned.creatureId))
sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summoned.creatureId); { sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summoned.creatureId); }
if (temp.summoned.repeatMax < temp.summoned.repeatMin) if (temp.summoned.repeatMax < temp.summoned.repeatMin)
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
case EVENT_T_QUEST_ACCEPT: case EVENT_T_QUEST_ACCEPT:
case EVENT_T_QUEST_COMPLETE: case EVENT_T_QUEST_COMPLETE:
if (!sObjectMgr.GetQuestTemplate(temp.quest.questId)) if (!sObjectMgr.GetQuestTemplate(temp.quest.questId))
sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent quest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId); { sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent quest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId); }
sLog.outErrorEventAI("Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i); sLog.outErrorEventAI("Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i);
continue; continue;
@ -490,7 +491,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
continue; continue;
} }
if (temp.buffed.repeatMax < temp.buffed.repeatMin) if (temp.buffed.repeatMax < temp.buffed.repeatMin)
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
break; break;
} }
case EVENT_T_RECEIVE_AI_EVENT: case EVENT_T_RECEIVE_AI_EVENT:
@ -539,9 +540,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case ACTION_T_CHANCED_TEXT: case ACTION_T_CHANCED_TEXT:
// Check first param as chance // Check first param as chance
if (!action.chanced_text.chance) if (!action.chanced_text.chance)
sLog.outErrorEventAI("Event %u Action %u has not set chance param1. Text will not be displayed", i, j + 1); { sLog.outErrorEventAI("Event %u Action %u has not set chance param1. Text will not be displayed", i, j + 1); }
else if (action.chanced_text.chance >= 100) else if (action.chanced_text.chance >= 100)
sLog.outErrorEventAI("Event %u Action %u has set chance param1 >= 100. Text will always be displayed", i, j + 1); { sLog.outErrorEventAI("Event %u Action %u has set chance param1 >= 100. Text will always be displayed", i, j + 1); }
// no break here to check texts // no break here to check texts
case ACTION_T_TEXT: case ACTION_T_TEXT:
{ {
@ -552,10 +553,10 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
if (action.text.TextId[k]) if (action.text.TextId[k])
{ {
if (k > firstTextParam && not_set) if (k > firstTextParam && not_set)
sLog.outErrorEventAI("Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j + 1, k + 1); { sLog.outErrorEventAI("Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j + 1, k + 1); }
if (!action.text.TextId[k]) if (!action.text.TextId[k])
not_set = true; { not_set = true; }
// range negative // range negative
else if (action.text.TextId[k] > MIN_CREATURE_AI_TEXT_STRING_ID || action.text.TextId[k] <= MAX_CREATURE_AI_TEXT_STRING_ID) else if (action.text.TextId[k] > MIN_CREATURE_AI_TEXT_STRING_ID || action.text.TextId[k] <= MAX_CREATURE_AI_TEXT_STRING_ID)
{ {
@ -568,7 +569,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
action.text.TextId[k] = 0; action.text.TextId[k] = 0;
} }
else else
usedTextIds.insert(action.text.TextId[k]); { usedTextIds.insert(action.text.TextId[k]); }
} }
} }
break; break;
@ -606,33 +607,33 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break; break;
case ACTION_T_SOUND: case ACTION_T_SOUND:
if (!sSoundEntriesStore.LookupEntry(action.sound.soundId)) if (!sSoundEntriesStore.LookupEntry(action.sound.soundId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SoundID %u.", i, j + 1, action.sound.soundId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SoundID %u.", i, j + 1, action.sound.soundId); }
break; break;
case ACTION_T_EMOTE: case ACTION_T_EMOTE:
if (!sEmotesStore.LookupEntry(action.emote.emoteId)) if (!sEmotesStore.LookupEntry(action.emote.emoteId))
sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.emote.emoteId); { sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.emote.emoteId); }
break; break;
case ACTION_T_RANDOM_SOUND: case ACTION_T_RANDOM_SOUND:
if (!sSoundEntriesStore.LookupEntry(action.random_sound.soundId1)) if (!sSoundEntriesStore.LookupEntry(action.random_sound.soundId1))
sLog.outErrorEventAI("Event %u Action %u param1 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId1); { sLog.outErrorEventAI("Event %u Action %u param1 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId1); }
if (action.random_sound.soundId2 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId2)) if (action.random_sound.soundId2 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId2))
sLog.outErrorEventAI("Event %u Action %u param2 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId2); { sLog.outErrorEventAI("Event %u Action %u param2 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId2); }
if (action.random_sound.soundId3 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId3)) if (action.random_sound.soundId3 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId3))
sLog.outErrorEventAI("Event %u Action %u param3 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId3); { sLog.outErrorEventAI("Event %u Action %u param3 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId3); }
break; break;
case ACTION_T_RANDOM_EMOTE: case ACTION_T_RANDOM_EMOTE:
if (!sEmotesStore.LookupEntry(action.random_emote.emoteId1)) if (!sEmotesStore.LookupEntry(action.random_emote.emoteId1))
sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId1); { sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId1); }
if (action.random_emote.emoteId2 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId2)) if (action.random_emote.emoteId2 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId2))
sLog.outErrorEventAI("Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId2); { sLog.outErrorEventAI("Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId2); }
if (action.random_emote.emoteId3 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId3)) if (action.random_emote.emoteId3 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId3))
sLog.outErrorEventAI("Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId3); { sLog.outErrorEventAI("Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId3); }
break; break;
case ACTION_T_CAST: case ACTION_T_CAST:
{ {
const SpellEntry* spell = sSpellStore.LookupEntry(action.cast.spellId); const SpellEntry* spell = sSpellStore.LookupEntry(action.cast.spellId);
if (!spell) if (!spell)
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast.spellId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast.spellId); }
/* FIXME: temp.raw.param3 not have event tipes with recovery time in it.... /* FIXME: temp.raw.param3 not have event tipes with recovery time in it....
else else
{ {
@ -647,7 +648,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
// Cast is always triggered if target is forced to cast on self // Cast is always triggered if target is forced to cast on self
if (action.cast.castFlags & CAST_FORCE_TARGET_SELF) if (action.cast.castFlags & CAST_FORCE_TARGET_SELF)
action.cast.castFlags |= CAST_TRIGGERED; { action.cast.castFlags |= CAST_TRIGGERED; }
IsValidTargetType(temp.event_type, action.type, action.cast.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.cast.target, i, j + 1);
@ -656,7 +657,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
{ {
// spell must be cast on self, but is not // spell must be cast on self, but is not
if ((IsOnlySelfTargeting(spell) || spell->rangeIndex == SPELL_RANGE_IDX_SELF_ONLY) && action.cast.target != TARGET_T_SELF && !(action.cast.castFlags & CAST_FORCE_TARGET_SELF)) if ((IsOnlySelfTargeting(spell) || spell->rangeIndex == SPELL_RANGE_IDX_SELF_ONLY) && action.cast.target != TARGET_T_SELF && !(action.cast.castFlags & CAST_FORCE_TARGET_SELF))
sLog.outErrorEventAI("Event %u Action %u uses SpellID %u that must be self cast (target is %u)", i, j + 1, action.cast.spellId, action.cast.target); { sLog.outErrorEventAI("Event %u Action %u uses SpellID %u that must be self cast (target is %u)", i, j + 1, action.cast.spellId, action.cast.target); }
// TODO: spell must be cast on enemy, but is not // TODO: spell must be cast on enemy, but is not
@ -664,51 +665,51 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
if (action.cast.target == TARGET_T_ACTION_INVOKER && if (action.cast.target == TARGET_T_ACTION_INVOKER &&
(IsSpellHaveEffect(spell, SPELL_EFFECT_QUEST_COMPLETE) || IsSpellHaveEffect(spell, SPELL_EFFECT_CREATE_RANDOM_ITEM) || IsSpellHaveEffect(spell, SPELL_EFFECT_DUMMY) (IsSpellHaveEffect(spell, SPELL_EFFECT_QUEST_COMPLETE) || IsSpellHaveEffect(spell, SPELL_EFFECT_CREATE_RANDOM_ITEM) || IsSpellHaveEffect(spell, SPELL_EFFECT_DUMMY)
|| IsSpellHaveEffect(spell, SPELL_EFFECT_KILL_CREDIT_PERSONAL) || IsSpellHaveEffect(spell, SPELL_EFFECT_KILL_CREDIT_GROUP))) || IsSpellHaveEffect(spell, SPELL_EFFECT_KILL_CREDIT_PERSONAL) || IsSpellHaveEffect(spell, SPELL_EFFECT_KILL_CREDIT_GROUP)))
sLog.outErrorEventAI("Event %u Action %u has TARGET_T_ACTION_INVOKER(%u) target type, but should have TARGET_T_ACTION_INVOKER_OWNER(%u).", i, j + 1, TARGET_T_ACTION_INVOKER, TARGET_T_ACTION_INVOKER_OWNER); { sLog.outErrorEventAI("Event %u Action %u has TARGET_T_ACTION_INVOKER(%u) target type, but should have TARGET_T_ACTION_INVOKER_OWNER(%u).", i, j + 1, TARGET_T_ACTION_INVOKER, TARGET_T_ACTION_INVOKER_OWNER); }
// Spell that should only target players, but could get any // Spell that should only target players, but could get any
if (spell->HasAttribute(SPELL_ATTR_EX3_TARGET_ONLY_PLAYER) && if (spell->HasAttribute(SPELL_ATTR_EX3_TARGET_ONLY_PLAYER) &&
(action.cast.target == TARGET_T_ACTION_INVOKER || action.cast.target == TARGET_T_HOSTILE_RANDOM || action.cast.target == TARGET_T_HOSTILE_RANDOM_NOT_TOP)) (action.cast.target == TARGET_T_ACTION_INVOKER || action.cast.target == TARGET_T_HOSTILE_RANDOM || action.cast.target == TARGET_T_HOSTILE_RANDOM_NOT_TOP))
sLog.outErrorEventAI("Event %u Action %u uses Target type %u for a spell (%u) that should only target players. This could be wrong.", i, j + 1, action.cast.target, action.cast.spellId); { sLog.outErrorEventAI("Event %u Action %u uses Target type %u for a spell (%u) that should only target players. This could be wrong.", i, j + 1, action.cast.target, action.cast.spellId); }
} }
break; break;
} }
case ACTION_T_SUMMON: case ACTION_T_SUMMON:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon.creatureId)) if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon.creatureId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon.creatureId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon.creatureId); }
IsValidTargetType(temp.event_type, action.type, action.summon.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.summon.target, i, j + 1);
break; break;
case ACTION_T_THREAT_SINGLE_PCT: case ACTION_T_THREAT_SINGLE_PCT:
if (std::abs(action.threat_single_pct.percent) > 100) if (std::abs(action.threat_single_pct.percent) > 100)
sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_single_pct.percent); { sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_single_pct.percent); }
IsValidTargetType(temp.event_type, action.type, action.threat_single_pct.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.threat_single_pct.target, i, j + 1);
break; break;
case ACTION_T_THREAT_ALL_PCT: case ACTION_T_THREAT_ALL_PCT:
if (std::abs(action.threat_all_pct.percent) > 100) if (std::abs(action.threat_all_pct.percent) > 100)
sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_all_pct.percent); { sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_all_pct.percent); }
break; break;
case ACTION_T_QUEST_EVENT: case ACTION_T_QUEST_EVENT:
if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event.questId)) if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event.questId))
{ {
if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT)) if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT))
sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event.questId); { sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event.questId); }
} }
else else
sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event.questId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event.questId); }
IsValidTargetType(temp.event_type, action.type, action.quest_event.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.quest_event.target, i, j + 1);
break; break;
case ACTION_T_CAST_EVENT: case ACTION_T_CAST_EVENT:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event.creatureId)) if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event.creatureId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event.creatureId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event.creatureId); }
if (!sSpellStore.LookupEntry(action.cast_event.spellId)) if (!sSpellStore.LookupEntry(action.cast_event.spellId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event.spellId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event.spellId); }
IsValidTargetType(temp.event_type, action.type, action.cast_event.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.cast_event.target, i, j + 1);
break; break;
case ACTION_T_SET_UNIT_FIELD: case ACTION_T_SET_UNIT_FIELD:
if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END)
sLog.outErrorEventAI("Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j + 1); { sLog.outErrorEventAI("Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j + 1); }
IsValidTargetType(temp.event_type, action.type, action.set_unit_field.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.set_unit_field.target, i, j + 1);
break; break;
case ACTION_T_SET_UNIT_FLAG: case ACTION_T_SET_UNIT_FLAG:
@ -717,47 +718,47 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break; break;
case ACTION_T_SET_PHASE: case ACTION_T_SET_PHASE:
if (action.set_phase.phase >= MAX_PHASE) if (action.set_phase.phase >= MAX_PHASE)
sLog.outErrorEventAI("Event %u Action %u attempts to set phase >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); { sLog.outErrorEventAI("Event %u Action %u attempts to set phase >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
break; break;
case ACTION_T_INC_PHASE: case ACTION_T_INC_PHASE:
if (action.set_inc_phase.step == 0) if (action.set_inc_phase.step == 0)
sLog.outErrorEventAI("Event %u Action %u is incrementing phase by 0. Was this intended?", i, j + 1); { sLog.outErrorEventAI("Event %u Action %u is incrementing phase by 0. Was this intended?", i, j + 1); }
else if (std::abs(action.set_inc_phase.step) > MAX_PHASE - 1) else if (std::abs(action.set_inc_phase.step) > MAX_PHASE - 1)
sLog.outErrorEventAI("Event %u Action %u is change phase by too large for any use %i.", i, j + 1, action.set_inc_phase.step); { sLog.outErrorEventAI("Event %u Action %u is change phase by too large for any use %i.", i, j + 1, action.set_inc_phase.step); }
break; break;
case ACTION_T_QUEST_EVENT_ALL: case ACTION_T_QUEST_EVENT_ALL:
if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event_all.questId)) if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event_all.questId))
{ {
if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT)) if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT))
sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event_all.questId); { sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event_all.questId); }
} }
else else
sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event_all.questId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event_all.questId); }
break; break;
case ACTION_T_CAST_EVENT_ALL: case ACTION_T_CAST_EVENT_ALL:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event_all.creatureId)) if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event_all.creatureId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event_all.creatureId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event_all.creatureId); }
if (!sSpellStore.LookupEntry(action.cast_event_all.spellId)) if (!sSpellStore.LookupEntry(action.cast_event_all.spellId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event_all.spellId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event_all.spellId); }
break; break;
case ACTION_T_REMOVEAURASFROMSPELL: case ACTION_T_REMOVEAURASFROMSPELL:
if (!sSpellStore.LookupEntry(action.remove_aura.spellId)) if (!sSpellStore.LookupEntry(action.remove_aura.spellId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.remove_aura.spellId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.remove_aura.spellId); }
IsValidTargetType(temp.event_type, action.type, action.remove_aura.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.remove_aura.target, i, j + 1);
break; break;
case ACTION_T_RANDOM_PHASE: // PhaseId1, PhaseId2, PhaseId3 case ACTION_T_RANDOM_PHASE: // PhaseId1, PhaseId2, PhaseId3
if (action.random_phase.phase1 >= MAX_PHASE) if (action.random_phase.phase1 >= MAX_PHASE)
sLog.outErrorEventAI("Event %u Action %u attempts to set phase1 >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); { sLog.outErrorEventAI("Event %u Action %u attempts to set phase1 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
if (action.random_phase.phase2 >= MAX_PHASE) if (action.random_phase.phase2 >= MAX_PHASE)
sLog.outErrorEventAI("Event %u Action %u attempts to set phase2 >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); { sLog.outErrorEventAI("Event %u Action %u attempts to set phase2 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
if (action.random_phase.phase3 >= MAX_PHASE) if (action.random_phase.phase3 >= MAX_PHASE)
sLog.outErrorEventAI("Event %u Action %u attempts to set phase3 >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); { sLog.outErrorEventAI("Event %u Action %u attempts to set phase3 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
break; break;
case ACTION_T_RANDOM_PHASE_RANGE: // PhaseMin, PhaseMax case ACTION_T_RANDOM_PHASE_RANGE: // PhaseMin, PhaseMax
if (action.random_phase_range.phaseMin >= MAX_PHASE) if (action.random_phase_range.phaseMin >= MAX_PHASE)
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMin >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); { sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMin >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
if (action.random_phase_range.phaseMin >= MAX_PHASE) if (action.random_phase_range.phaseMin >= MAX_PHASE)
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); { sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
if (action.random_phase_range.phaseMin >= action.random_phase_range.phaseMax) if (action.random_phase_range.phaseMin >= action.random_phase_range.phaseMax)
{ {
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax <= phaseMin.", i, j + 1); sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax <= phaseMin.", i, j + 1);
@ -767,21 +768,21 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break; break;
case ACTION_T_SUMMON_ID: case ACTION_T_SUMMON_ID:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon_id.creatureId)) if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon_id.creatureId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon_id.creatureId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon_id.creatureId); }
IsValidTargetType(temp.event_type, action.type, action.summon_id.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.summon_id.target, i, j + 1);
if (m_CreatureEventAI_Summon_Map.find(action.summon_id.spawnId) == m_CreatureEventAI_Summon_Map.end()) if (m_CreatureEventAI_Summon_Map.find(action.summon_id.spawnId) == m_CreatureEventAI_Summon_Map.end())
sLog.outErrorEventAI("Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j + 1, action.summon_id.spawnId); { sLog.outErrorEventAI("Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j + 1, action.summon_id.spawnId); }
break; break;
case ACTION_T_KILLED_MONSTER: case ACTION_T_KILLED_MONSTER:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.killed_monster.creatureId)) if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.killed_monster.creatureId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.killed_monster.creatureId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.killed_monster.creatureId); }
IsValidTargetType(temp.event_type, action.type, action.killed_monster.target, i, j + 1); IsValidTargetType(temp.event_type, action.type, action.killed_monster.target, i, j + 1);
break; break;
case ACTION_T_SET_INST_DATA: case ACTION_T_SET_INST_DATA:
if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL))
sLog.outErrorEventAI("Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j + 1); sLog.outErrorEventAI("Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j + 1);
if (action.set_inst_data.value > 4/*SPECIAL*/) if (action.set_inst_data.value > 4/*SPECIAL*/)
sLog.outErrorEventAI("Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j + 1); { sLog.outErrorEventAI("Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j + 1); }
break; break;
case ACTION_T_SET_INST_DATA64: case ACTION_T_SET_INST_DATA64:
if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL))
@ -790,7 +791,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break; break;
case ACTION_T_UPDATE_TEMPLATE: case ACTION_T_UPDATE_TEMPLATE:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.update_template.creatureId)) if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.update_template.creatureId))
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.update_template.creatureId); { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.update_template.creatureId); }
break; break;
case ACTION_T_SET_SHEATH: case ACTION_T_SET_SHEATH:
if (action.set_sheath.sheath >= MAX_SHEATH_STATE) if (action.set_sheath.sheath >= MAX_SHEATH_STATE)
@ -858,7 +859,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
continue; continue;
} }
if (action.throwEvent.radius > SIZE_OF_GRIDS) if (action.throwEvent.radius > SIZE_OF_GRIDS)
sLog.outErrorEventAI("Event %u Action %u uses unexpectedly huge radius %u (expected to be less than %f)", i, j + 1, action.throwEvent.radius, SIZE_OF_GRIDS); { sLog.outErrorEventAI("Event %u Action %u uses unexpectedly huge radius %u (expected to be less than %f)", i, j + 1, action.throwEvent.radius, SIZE_OF_GRIDS); }
if (action.throwEvent.radius == 0) if (action.throwEvent.radius == 0)
{ {
@ -867,7 +868,6 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
} }
break; break;
case ACTION_T_SET_THROW_MASK: case ACTION_T_SET_THROW_MASK:
if (action.setThrowMask.eventTypeMask & ~((1 << MAXIMAL_AI_EVENT_EVENTAI) - 1)) if (action.setThrowMask.eventTypeMask & ~((1 << MAXIMAL_AI_EVENT_EVENTAI) - 1))
{ {
@ -913,9 +913,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
bool ainame = strcmp(cInfo->AIName, "EventAI") == 0; bool ainame = strcmp(cInfo->AIName, "EventAI") == 0;
bool hasevent = m_CreatureEventAI_Event_Map.find(i) != m_CreatureEventAI_Event_Map.end(); bool hasevent = m_CreatureEventAI_Event_Map.find(i) != m_CreatureEventAI_Event_Map.end();
if (ainame && !hasevent) if (ainame && !hasevent)
sLog.outErrorEventAI("EventAI not has script for creature entry (%u), but AIName = '%s'.", i, cInfo->AIName); { sLog.outErrorEventAI("EventAI not has script for creature entry (%u), but AIName = '%s'.", i, cInfo->AIName); }
else if (!ainame && hasevent) else if (!ainame && hasevent)
sLog.outErrorEventAI("EventAI has script for creature entry (%u), but AIName = '%s' instead 'EventAI'.", i, cInfo->AIName); { sLog.outErrorEventAI("EventAI has script for creature entry (%u), but AIName = '%s' instead 'EventAI'.", i, cInfo->AIName); }
} }
} }

View file

@ -134,9 +134,9 @@ void DynamicObject::Update(uint32 /*update_diff*/, uint32 p_time)
bool deleteThis = false; bool deleteThis = false;
if (m_aliveDuration > int32(p_time)) if (m_aliveDuration > int32(p_time))
m_aliveDuration -= p_time; { m_aliveDuration -= p_time; }
else else
deleteThis = true; { deleteThis = true; }
// have radius and work as persistent effect // have radius and work as persistent effect
if (m_radius) if (m_radius)
@ -197,36 +197,35 @@ void DynamicObject::Delay(int32 delaytime)
++iter; ++iter;
} }
else else
m_affected.erase(iter++); { m_affected.erase(iter++); }
} }
} }
bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
{ {
if (!IsInWorld() || !u->IsInWorld()) if (!IsInWorld() || !u->IsInWorld())
return false; { return false; }
// always seen by owner // always seen by owner
if (GetCasterGuid() == u->GetObjectGuid()) if (GetCasterGuid() == u->GetObjectGuid())
return true; { return true; }
// normal case // normal case
return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
} }
bool DynamicObject::IsHostileTo(Unit const* unit) const bool DynamicObject::IsHostileTo(Unit const* unit) const
{ {
if (Unit* owner = GetCaster()) if (Unit* owner = GetCaster())
return owner->IsHostileTo(unit); { return owner->IsHostileTo(unit); }
else else
return false; { return false; }
} }
bool DynamicObject::IsFriendlyTo(Unit const* unit) const bool DynamicObject::IsFriendlyTo(Unit const* unit) const
{ {
if (Unit* owner = GetCaster()) if (Unit* owner = GetCaster())
return owner->IsFriendlyTo(unit); { return owner->IsFriendlyTo(unit); }
else else
return true; { return true; }
} }

View file

@ -72,7 +72,7 @@ class DynamicObject : public WorldObject
bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const override; bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const override;
GridReference<DynamicObject> &GetGridRef() { return m_gridRef; } GridReference<DynamicObject>& GetGridRef() { return m_gridRef; }
protected: protected:
uint32 m_spellId; uint32 m_spellId;

View file

@ -36,6 +36,8 @@ namespace MaNGOS
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
{ {
enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY }; enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY };
@ -43,9 +45,9 @@ 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
@ -55,30 +57,30 @@ 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; }
} }
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;
} }
@ -100,7 +102,7 @@ namespace MaNGOS
{ {
uint32 nLevelDiff = mob_level - pl_level; uint32 nLevelDiff = mob_level - pl_level;
if (nLevelDiff > 4) if (nLevelDiff > 4)
nLevelDiff = 4; { nLevelDiff = 4; }
return ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2; return ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2;
} }
else else
@ -118,16 +120,16 @@ 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()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_XP_AT_KILL))) (((Creature*)u)->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_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));
} }

View file

@ -63,10 +63,9 @@ void GMTicketMgr::LoadGMTickets()
uint32 guidlow = fields[0].GetUInt32(); uint32 guidlow = fields[0].GetUInt32();
if (!guidlow) if (!guidlow)
continue; { continue; }
ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, guidlow); ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, guidlow);
GMTicket& ticket = m_GMTicketMap[guid]; GMTicket& ticket = m_GMTicketMap[guid];
if (ticket.GetPlayerGuid()) // already exist if (ticket.GetPlayerGuid()) // already exist
@ -90,7 +89,7 @@ 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");
m_GMTicketListByCreatingOrder.clear(); m_GMTicketListByCreatingOrder.clear();

View file

@ -31,12 +31,63 @@
#include "ObjectGuid.h" #include "ObjectGuid.h"
#include <map> #include <map>
/**
* \addtogroup game
* @{
* \file
*/
/**
* This is the class that takes care of representing a ticket made to the GMs on the server
* with a question of some sort.
*
* The code responsible for taking care of the opcodes coming
* in can be found in:
* - \ref WorldSession::SendGMTicketStatusUpdate
* - \ref WorldSession::SendGMTicketGetTicket
* - \ref WorldSession::HandleGMTicketGetTicketOpcode
* - \ref WorldSession::HandleGMTicketUpdateTextOpcode
* - \ref WorldSession::HandleGMTicketDeleteTicketOpcode
* - \ref WorldSession::HandleGMTicketCreateOpcode
* - \ref WorldSession::HandleGMTicketSystemStatusOpcode
* - \ref WorldSession::HandleGMTicketSurveySubmitOpcode
* These in their turn will make calls to the \ref GMTicketMgr which will take
* care of what needs to be done by giving back a \ref GMTicket. The database table interesting
* in this case is character_ticket in the characaters database.
*
* Theres also some handling of tickets in \ref ChatHandler::HandleTicketCommand where
* you can turn on/off accepting tickets with your current GM char. You can also turn
* off tickets globally, this will show the client a message about tickets not being
* available at the moment. The commands that can be used are:
* <dl>
* <dt>.ticket on/off</dt>
* <dd>Turns on/off showing new incoming tickets for you character</dd>
* <dt>.ticket system_on/off</dt>
* <dd>Will turn the whole ticket reporting system on/off, ie: if it's off the clients
* will get a message that the system is unavailable when trying to submit a ticket</dd>
* <dt>.ticket close $character_name/.ticket close #num_of_ticket</dt>
* <dd>Will close a ticket for the given character name or the given number of the ticket,
* this will make the little icon in the top right go away for the player</dd>
* <dt>.ticket close_survey $character_name/.ticket close_survey #num_of_ticket</dt>
* <dd>Does the same as .ticket close but instead of just closing it it also asks the \ref Player
* to answer a survey about how please they were with the experience</dd>
* <dt>.ticket respond $character_name/.ticket respond #num_of_ticket</dt>
* <dd>Will respond to a ticket, this will whisper the \ref Player who asked the question and from
* there on you will have to explain the solution etc. and then close the ticket again.</dd>
* <dt>.ticket</dt>
* <dd>Shows the number of currently active tickets</dd>
* <dt>.ticket $character_name/.ticket #num_of_ticket</dt>
* <dd>Will show the question and name of the character for the given ticket</dd>
*
* \todo Do not remove tickets from db when closing but mark them as solved instead.
* \todo Log conversations between GM and the player receiving help.
*/
class GMTicket class GMTicket
{ {
public: public:
explicit GMTicket() : m_lastUpdate(0) explicit GMTicket() : m_lastUpdate(0)
{ {}
}
void Init(ObjectGuid guid, const std::string& text, const std::string& responsetext, time_t update) void Init(ObjectGuid guid, const std::string& text, const std::string& responsetext, time_t update)
{ {
@ -46,6 +97,10 @@ class GMTicket
m_lastUpdate = update; m_lastUpdate = update;
} }
/**
* Gets the \ref Player s \ref ObjectGuid which asked the question and created the ticket
* @return the \ref ObjectGuid for the \ref Player that asked the question
*/
ObjectGuid const& GetPlayerGuid() const ObjectGuid const& GetPlayerGuid() const
{ {
return m_guid; return m_guid;
@ -66,6 +121,10 @@ class GMTicket
return m_lastUpdate; return m_lastUpdate;
} }
/**
* Changes the tickets question text.
* @param text the text to change the question to
*/
void SetText(const char* text) void SetText(const char* text)
{ {
m_text = text ? text : ""; m_text = text ? text : "";
@ -128,7 +187,7 @@ class GMTicketMgr
{ {
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);
} }
@ -140,21 +199,28 @@ class GMTicketMgr
GMTicket* GetGMTicketByOrderPos(uint32 pos) GMTicket* GetGMTicketByOrderPos(uint32 pos)
{ {
if (pos >= GetTicketCount()) if (pos >= GetTicketCount())
return NULL; { return NULL; }
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;
} }
/**
* This will delete a \ref GMTicket from this manager of tickets so that we don't
* need to handle it anymore, this should be used in conjunction with setting
* resolved = 1 in the character_ticket table.
*
* Note: This will _not_ remove anything from the DB
* @param guid guid of the \ref Player who created the ticket that we want to delete
*/
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);
m_GMTicketMap.erase(itr); m_GMTicketMap.erase(itr);
@ -162,6 +228,18 @@ class GMTicketMgr
void DeleteAll(); void DeleteAll();
/**
* This will create a new \ref GMTicket and fill it with the given question so that
* a GM can find it and answer it. Should only be called if we've already checked
* that there are no open tickets already, as this function will close any other
* currently open tickets for the given \ref Player and open a new one with the given
* text.
*
* Tables of interest here are characters.character_ticket and possibly characaters.
* character_whispers
* @param guid \ref ObjectGuid of the creator of the \ref GMTicket
* @param text the question text sent
*/
void Create(ObjectGuid guid, const char* text) void Create(ObjectGuid guid, const char* text)
{ {
GMTicket& ticket = m_GMTicketMap[guid]; GMTicket& ticket = m_GMTicketMap[guid];
@ -181,4 +259,6 @@ class GMTicketMgr
}; };
#define sTicketMgr MaNGOS::Singleton<GMTicketMgr>::Instance() #define sTicketMgr MaNGOS::Singleton<GMTicketMgr>::Instance()
/** @} */
#endif #endif

View file

@ -772,7 +772,7 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi
{ {
// 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)
@ -780,14 +780,14 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi
// 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
if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed) if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed)
@ -1216,7 +1216,7 @@ void GameObject::Use(Unit* user)
// TODO: Improve this when more information is available, currently these traps are known that must send the anim (Onyxia/ Heigan Fissures/ Trap in DireMaul) // TODO: Improve this when more information is available, currently these traps are known that must send the anim (Onyxia/ Heigan Fissures/ Trap in DireMaul)
if (GetDisplayId() == 4392 || GetDisplayId() == 4472 || GetDisplayId() == 4491 || GetDisplayId() == 6785 || GetDisplayId() == 3073 || GetDisplayId() == 7998) if (GetDisplayId() == 4392 || GetDisplayId() == 4472 || GetDisplayId() == 4491 || GetDisplayId() == 6785 || GetDisplayId() == 3073 || GetDisplayId() == 7998)
SendGameObjectCustomAnim(GetObjectGuid()); { SendGameObjectCustomAnim(GetObjectGuid()); }
// TODO: Despawning of traps? (Also related to code in ::Update) // TODO: Despawning of traps? (Also related to code in ::Update)
return; return;
@ -1354,7 +1354,7 @@ void GameObject::Use(Unit* user)
if (!scriptReturnValue) if (!scriptReturnValue)
{ GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); } { GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); }
else else
return; { return; }
// cast this spell later if provided // cast this spell later if provided
spellId = info->goober.spellId; spellId = info->goober.spellId;
@ -2143,19 +2143,19 @@ void GameObject::SetCapturePointSlider(float value, bool isLocked)
// only activate non-locked capture point // only activate non-locked capture point
if (!isLocked) if (!isLocked)
SetLootState(GO_ACTIVATED); { SetLootState(GO_ACTIVATED); }
// set the state of the capture point based on the slider value // set the state of the capture point based on the slider value
if ((int)m_captureSlider == CAPTURE_SLIDER_ALLIANCE) if ((int)m_captureSlider == CAPTURE_SLIDER_ALLIANCE)
m_captureState = CAPTURE_STATE_WIN_ALLIANCE; { m_captureState = CAPTURE_STATE_WIN_ALLIANCE; }
else if ((int)m_captureSlider == CAPTURE_SLIDER_HORDE) else if ((int)m_captureSlider == CAPTURE_SLIDER_HORDE)
m_captureState = CAPTURE_STATE_WIN_HORDE; { m_captureState = CAPTURE_STATE_WIN_HORDE; }
else if (m_captureSlider > CAPTURE_SLIDER_MIDDLE + info->capturePoint.neutralPercent * 0.5f) else if (m_captureSlider > CAPTURE_SLIDER_MIDDLE + info->capturePoint.neutralPercent * 0.5f)
m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; { m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; }
else if (m_captureSlider < CAPTURE_SLIDER_MIDDLE - info->capturePoint.neutralPercent * 0.5f) else if (m_captureSlider < CAPTURE_SLIDER_MIDDLE - info->capturePoint.neutralPercent * 0.5f)
m_captureState = CAPTURE_STATE_PROGRESS_HORDE; { m_captureState = CAPTURE_STATE_PROGRESS_HORDE; }
else else
m_captureState = CAPTURE_STATE_NEUTRAL; { m_captureState = CAPTURE_STATE_NEUTRAL; }
} }
void GameObject::TickCapturePoint() void GameObject::TickCapturePoint()
@ -2499,3 +2499,4 @@ uint32 GameObject::GetScriptId()
{ {
return sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, -int32(GetGUIDLow())) ? sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, -int32(GetGUIDLow())) : sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, GetEntry()); return sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, -int32(GetGUIDLow())) ? sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, -int32(GetGUIDLow())) : sScriptMgr.GetBoundScriptId(SCRIPTED_GAMEOBJECT, GetEntry());
} }

View file

@ -31,7 +31,7 @@
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; }
return PERMIT_BASE_NO; return PERMIT_BASE_NO;
} }
@ -44,11 +44,11 @@ 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))
@ -107,14 +107,14 @@ void GuardAI::EnterEvadeMode()
// Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead // Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
m_creature->GetMotionMaster()->MoveTargetedHome(); { m_creature->GetMotionMaster()->MoveTargetedHome(); }
} }
void GuardAI::UpdateAI(const uint32 /*diff*/) void GuardAI::UpdateAI(const uint32 /*diff*/)
{ {
// update i_victimGuid if i_creature.getVictim() !=0 and changed // update i_victimGuid if i_creature.getVictim() !=0 and changed
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return; { return; }
i_victimGuid = m_creature->getVictim()->GetObjectGuid(); i_victimGuid = m_creature->getVictim()->GetObjectGuid();
@ -130,7 +130,7 @@ bool GuardAI::IsVisible(Unit* pl) const
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))
{ {
@ -146,5 +146,5 @@ 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

@ -79,7 +79,7 @@ void MemberSlot::ChangeRank(uint32 newRank)
Player* player = sObjectMgr.GetPlayer(guid); Player* player = sObjectMgr.GetPlayer(guid);
// If player not online data in data field will be loaded from guild tabs no need to update it !! // If player not online data in data field will be loaded from guild tabs no need to update it !!
if (player) if (player)
player->SetRank(newRank); { player->SetRank(newRank); }
CharacterDatabase.PExecute("UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, guid.GetCounter()); CharacterDatabase.PExecute("UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, guid.GetCounter());
} }
@ -117,11 +117,11 @@ Guild::~Guild()
bool Guild::Create(Player* leader, std::string gname) bool Guild::Create(Player* leader, std::string gname)
{ {
if (sGuildMgr.GetGuildByName(gname)) if (sGuildMgr.GetGuildByName(gname))
return false; { return false; }
WorldSession* lSession = leader->GetSession(); WorldSession* lSession = leader->GetSession();
if (!lSession) if (!lSession)
return false; { return false; }
m_LeaderGuid = leader->GetObjectGuid(); m_LeaderGuid = leader->GetObjectGuid();
m_Name = gname; m_Name = gname;
@ -179,12 +179,12 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank)
if (pl) if (pl)
{ {
if (pl->GetGuildId() != 0) if (pl->GetGuildId() != 0)
return false; { return false; }
} }
else else
{ {
if (Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild if (Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild
return false; { return false; }
} }
// remove all player signs from another petitions // remove all player signs from another petitions
@ -211,7 +211,7 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank)
// 0 1 2 3 4 // 0 1 2 3 4
QueryResult* result = CharacterDatabase.PQuery("SELECT name,level,class,zone,account FROM characters WHERE guid = '%u'", lowguid); QueryResult* result = CharacterDatabase.PQuery("SELECT name,level,class,zone,account FROM characters WHERE guid = '%u'", lowguid);
if (!result) if (!result)
return false; // player doesn't exist { return false; } // player doesn't exist
Field* fields = result->Fetch(); Field* fields = result->Fetch();
newmember.Name = fields[0].GetCppString(); newmember.Name = fields[0].GetCppString();
@ -222,9 +222,9 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank)
delete result; delete result;
if (newmember.Level < 1 || newmember.Level > STRONG_MAX_LEVEL || if (newmember.Level < 1 || newmember.Level > STRONG_MAX_LEVEL ||
!((1 << (newmember.Class - 1)) & CLASSMASK_ALL_PLAYABLE)) !((1 << (newmember.Class - 1)) & CLASSMASK_ALL_PLAYABLE))
{ {
sLog.outError("%s has a broken data in field `characters` table, cannot add him to guild.", plGuid.GetString().c_str()); sLog.outError("%s has a broken data in field `characters` table, can not add him to guild.", plGuid.GetString().c_str());
return false; return false;
} }
} }
@ -296,7 +296,7 @@ void Guild::SetGINFO(std::string ginfo)
bool Guild::LoadGuildFromDB(QueryResult* guildDataResult) bool Guild::LoadGuildFromDB(QueryResult* guildDataResult)
{ {
if (!guildDataResult) if (!guildDataResult)
return false; { return false; }
Field* fields = guildDataResult->Fetch(); Field* fields = guildDataResult->Fetch();
@ -335,10 +335,10 @@ bool Guild::CheckGuildStructure()
if (GM_rights == -1) if (GM_rights == -1)
{ {
if (DelMember(m_LeaderGuid)) if (DelMember(m_LeaderGuid))
return false; // guild will disbanded and deleted in caller { return false; } // guild will disbanded and deleted in caller
} }
else if (GM_rights != GR_GUILDMASTER) else if (GM_rights != GR_GUILDMASTER)
SetLeader(m_LeaderGuid); { SetLeader(m_LeaderGuid); }
// Allow only 1 guildmaster, set other to officer // Allow only 1 guildmaster, set other to officer
for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
@ -365,7 +365,7 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
// GUILD RANKS are sequence starting from 0 = GUILD_MASTER (ALL PRIVILEGES) to max 9 (lowest privileges) // GUILD RANKS are sequence starting from 0 = GUILD_MASTER (ALL PRIVILEGES) to max 9 (lowest privileges)
// the lower rank id is considered higher rank - so promotion does rank-- and demotion does rank++ // the lower rank id is considered higher rank - so promotion does rank-- and demotion does rank++
// between ranks in sequence cannot be gaps - so 0,1,2,4 cannot be // between ranks in sequence can not be gaps - so 0,1,2,4 can not be
// min ranks count is 5 and max is 10. // min ranks count is 5 and max is 10.
do do
@ -373,7 +373,7 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
fields = guildRanksResult->Fetch(); fields = guildRanksResult->Fetch();
// condition that would be true when all ranks in QueryResult will be processed and guild without ranks is being processed // condition that would be true when all ranks in QueryResult will be processed and guild without ranks is being processed
if (!fields) if (!fields)
break; { break; }
uint32 guildId = fields[0].GetUInt32(); uint32 guildId = fields[0].GetUInt32();
if (guildId < m_Id) if (guildId < m_Id)
@ -385,7 +385,7 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
} }
if (guildId > m_Id) // we loaded all ranks for this guild already, break cycle if (guildId > m_Id) // we loaded all ranks for this guild already, break cycle
break; { break; }
uint32 rankID = fields[1].GetUInt32(); uint32 rankID = fields[1].GetUInt32();
std::string rankName = fields[2].GetCppString(); std::string rankName = fields[2].GetCppString();
@ -393,11 +393,11 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
uint32 rankMoney = fields[4].GetUInt32(); uint32 rankMoney = fields[4].GetUInt32();
if (rankID != m_Ranks.size()) // guild_rank.ids are sequence 0,1,2,3.. if (rankID != m_Ranks.size()) // guild_rank.ids are sequence 0,1,2,3..
broken_ranks = true; { broken_ranks = true; }
// first rank is guildmaster, prevent loss leader rights // first rank is guildmaster, prevent loss leader rights
if (m_Ranks.empty()) if (m_Ranks.empty())
rankRights |= GR_RIGHT_ALL; { rankRights |= GR_RIGHT_ALL; }
AddRank(rankName, rankRights, rankMoney); AddRank(rankName, rankRights, rankMoney);
} }
@ -432,14 +432,14 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult) bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult)
{ {
if (!guildMembersResult) if (!guildMembersResult)
return false; { return false; }
do do
{ {
Field* fields = guildMembersResult->Fetch(); Field* fields = guildMembersResult->Fetch();
// this condition will be true when all rows in QueryResult are processed and new guild without members is going to be loaded - prevent crash // this condition will be true when all rows in QueryResult are processed and new guild without members is going to be loaded - prevent crash
if (!fields) if (!fields)
break; { break; }
uint32 guildId = fields[0].GetUInt32(); uint32 guildId = fields[0].GetUInt32();
if (guildId < m_Id) if (guildId < m_Id)
{ {
@ -451,7 +451,7 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult)
if (guildId > m_Id) if (guildId > m_Id)
// we loaded all members for this guild already, break cycle // we loaded all members for this guild already, break cycle
break; { break; }
MemberSlot newmember; MemberSlot newmember;
uint32 lowguid = fields[1].GetUInt32(); uint32 lowguid = fields[1].GetUInt32();
@ -459,7 +459,7 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult)
newmember.RankId = fields[2].GetUInt32(); newmember.RankId = fields[2].GetUInt32();
// don't allow member to have not existing rank! // don't allow member to have not existing rank!
if (newmember.RankId >= m_Ranks.size()) if (newmember.RankId >= m_Ranks.size())
newmember.RankId = GetLowestRank(); { newmember.RankId = GetLowestRank(); }
newmember.Pnote = fields[3].GetCppString(); newmember.Pnote = fields[3].GetCppString();
newmember.OFFnote = fields[4].GetCppString(); newmember.OFFnote = fields[4].GetCppString();
@ -467,8 +467,8 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult)
newmember.BankRemMoney = fields[6].GetUInt32(); newmember.BankRemMoney = fields[6].GetUInt32();
for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i)
{ {
newmember.BankResetTimeTab[i] = fields[7 + (2 * i)].GetUInt32(); newmember.BankResetTimeTab[i] = fields[7+(2*i)].GetUInt32();
newmember.BankRemSlotsTab[i] = fields[8 + (2 * i)].GetUInt32(); newmember.BankRemSlotsTab[i] = fields[8+(2*i)].GetUInt32();
} }
newmember.Name = fields[19].GetCppString(); newmember.Name = fields[19].GetCppString();
@ -504,7 +504,7 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult)
while (guildMembersResult->NextRow()); while (guildMembersResult->NextRow());
if (members.empty()) if (members.empty())
return false; { return false; }
UpdateAccountsNumber(); UpdateAccountsNumber();
@ -515,7 +515,7 @@ void Guild::SetLeader(ObjectGuid guid)
{ {
MemberSlot* slot = GetMemberSlot(guid); MemberSlot* slot = GetMemberSlot(guid);
if (!slot) if (!slot)
return; { return; }
m_LeaderGuid = guid; m_LeaderGuid = guid;
slot->ChangeRank(GR_GUILDMASTER); slot->ChangeRank(GR_GUILDMASTER);
@ -558,13 +558,13 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding)
} }
if (!best) if (!best)
return true; { return true; }
SetLeader(newLeaderGUID); SetLeader(newLeaderGUID);
// If player not online data in data field will be loaded from guild tabs no need to update it !! // If player not online data in data field will be loaded from guild tabs no need to update it !!
if (Player* newLeader = sObjectMgr.GetPlayer(newLeaderGUID)) if (Player* newLeader = sObjectMgr.GetPlayer(newLeaderGUID))
newLeader->SetRank(GR_GUILDMASTER); { newLeader->SetRank(GR_GUILDMASTER); }
// when leader non-exist (at guild load with deleted leader only) not send broadcasts // when leader non-exist (at guild load with deleted leader only) not send broadcasts
if (oldLeader) if (oldLeader)
@ -691,7 +691,7 @@ void Guild::BroadcastPacket(WorldPacket* packet)
{ {
Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)); Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
if (player) if (player)
player->GetSession()->SendPacket(packet); { player->GetSession()->SendPacket(packet); }
} }
} }
@ -703,7 +703,7 @@ void Guild::BroadcastPacketToRank(WorldPacket* packet, uint32 rankId)
{ {
Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)); Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
if (player) if (player)
player->GetSession()->SendPacket(packet); { player->GetSession()->SendPacket(packet); }
} }
} }
} }
@ -744,7 +744,7 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max
void Guild::CreateRank(std::string name_, uint32 rights) void Guild::CreateRank(std::string name_, uint32 rights)
{ {
if (m_Ranks.size() >= GUILD_RANKS_MAX_COUNT) if (m_Ranks.size() >= GUILD_RANKS_MAX_COUNT)
return; { return; }
// ranks are sequence 0,1,2,... where 0 means guildmaster // ranks are sequence 0,1,2,... where 0 means guildmaster
uint32 new_rank_id = m_Ranks.size(); uint32 new_rank_id = m_Ranks.size();
@ -775,7 +775,7 @@ void Guild::DelRank(uint32 rankId)
// client won't allow to have less than GUILD_RANKS_MIN_COUNT ranks in guild // client won't allow to have less than GUILD_RANKS_MIN_COUNT ranks in guild
if (m_Ranks.size() <= GUILD_RANKS_MIN_COUNT || rankId < GUILD_RANKS_MIN_COUNT) if (m_Ranks.size() <= GUILD_RANKS_MIN_COUNT || rankId < GUILD_RANKS_MIN_COUNT)
return; { return; }
RankList::iterator itr = m_Ranks.erase(m_Ranks.begin() + rankId); RankList::iterator itr = m_Ranks.erase(m_Ranks.begin() + rankId);
// delete lowest guild_rank // delete lowest guild_rank
@ -826,7 +826,7 @@ void Guild::SwitchRank(uint32 rankId, bool up)
std::string Guild::GetRankName(uint32 rankId) std::string Guild::GetRankName(uint32 rankId)
{ {
if (rankId >= m_Ranks.size()) if (rankId >= m_Ranks.size())
return "<unknown>"; { return "<unknown>"; }
return m_Ranks[rankId].Name; return m_Ranks[rankId].Name;
} }
@ -834,7 +834,7 @@ std::string Guild::GetRankName(uint32 rankId)
uint32 Guild::GetRankRights(uint32 rankId) uint32 Guild::GetRankRights(uint32 rankId)
{ {
if (rankId >= m_Ranks.size()) if (rankId >= m_Ranks.size())
return 0; { return 0; }
return m_Ranks[rankId].Rights; return m_Ranks[rankId].Rights;
} }
@ -842,7 +842,7 @@ uint32 Guild::GetRankRights(uint32 rankId)
void Guild::SetRankName(uint32 rankId, std::string name_) void Guild::SetRankName(uint32 rankId, std::string name_)
{ {
if (rankId >= m_Ranks.size()) if (rankId >= m_Ranks.size())
return; { return; }
m_Ranks[rankId].Name = name_; m_Ranks[rankId].Name = name_;
@ -854,7 +854,7 @@ void Guild::SetRankName(uint32 rankId, std::string name_)
void Guild::SetRankRights(uint32 rankId, uint32 rights) void Guild::SetRankRights(uint32 rankId, uint32 rights)
{ {
if (rankId >= m_Ranks.size()) if (rankId >= m_Ranks.size())
return; { return; }
m_Ranks[rankId].Rights = rights; m_Ranks[rankId].Rights = rights;
@ -980,15 +980,15 @@ void Guild::Roster(WorldSession* session /*= NULL*/)
data << uint32(0); data << uint32(0);
if (session) if (session)
session->SendPacket(&data); { session->SendPacket(&data); }
else else
BroadcastPacket(&data); { BroadcastPacket(&data); }
DEBUG_LOG("WORLD: Sent (SMSG_GUILD_ROSTER)"); DEBUG_LOG("WORLD: Sent (SMSG_GUILD_ROSTER)");
} }
void Guild::Query(WorldSession* session) void Guild::Query(WorldSession* session)
{ {
WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, 8 * 32 + 200); // we can only guess size WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (8 * 32 + 200)); // we can only guess size
data << GetObjectGuid(); data << GetObjectGuid();
data << m_Name; data << m_Name;
@ -996,9 +996,9 @@ void Guild::Query(WorldSession* session)
for (size_t i = 0 ; i < GUILD_RANKS_MAX_COUNT; ++i) // show always 10 ranks for (size_t i = 0 ; i < GUILD_RANKS_MAX_COUNT; ++i) // show always 10 ranks
{ {
if (i < m_Ranks.size()) if (i < m_Ranks.size())
data << m_Ranks[i].Name; { data << m_Ranks[i].Name; }
else else
data << uint8(0); // null string { data << uint8(0); } // null string
} }
// Rank order of creation // Rank order of creation
@ -1079,12 +1079,12 @@ uint32 Guild::GetAccountsNumber()
{ {
// not need recalculation // not need recalculation
if (m_accountsNumber) if (m_accountsNumber)
return m_accountsNumber; { return m_accountsNumber; }
// We use a set to be sure each element will be unique // We use a set to be sure each element will be unique
std::set<uint32> accountsIdSet; std::set<uint32> accountsIdSet;
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr) for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
accountsIdSet.insert(itr->second.accountId); { accountsIdSet.insert(itr->second.accountId); }
m_accountsNumber = accountsIdSet.size(); m_accountsNumber = accountsIdSet.size();
@ -1119,7 +1119,7 @@ void Guild::LoadGuildEventLogFromDB()
// 0 1 2 3 4 5 // 0 1 2 3 4 5
QueryResult* result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_RECORDS); QueryResult* result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_RECORDS);
if (!result) if (!result)
return; { return; }
bool isNextLogGuidSet = false; bool isNextLogGuidSet = false;
// uint32 configCount = sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT); // uint32 configCount = sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT);
// First event in list will be the oldest and the latest event is last event in list // First event in list will be the oldest and the latest event is last event in list
@ -1164,7 +1164,7 @@ void Guild::LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid pl
m_GuildEventLogNextGuid = (m_GuildEventLogNextGuid + 1) % sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT); m_GuildEventLogNextGuid = (m_GuildEventLogNextGuid + 1) % sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT);
// Check max records limit // Check max records limit
if (m_GuildEventLog.size() >= GUILD_EVENTLOG_MAX_RECORDS) if (m_GuildEventLog.size() >= GUILD_EVENTLOG_MAX_RECORDS)
m_GuildEventLog.pop_front(); { m_GuildEventLog.pop_front(); }
// Add event to list // Add event to list
m_GuildEventLog.push_back(NewEvent); m_GuildEventLog.push_back(NewEvent);
// Save event to DB // Save event to DB
@ -1510,6 +1510,12 @@ bool Guild::MemberMoneyWithdraw(uint64 amount, uint32 LowGuid)
CharacterDatabase.PExecute("UPDATE guild_member SET BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'", CharacterDatabase.PExecute("UPDATE guild_member SET BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'",
itr->second.BankRemMoney, m_Id, LowGuid); itr->second.BankRemMoney, m_Id, LowGuid);
} }
//#ifdef ENABLE_ELUNA
// Player* player = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, LowGuid));
// sEluna->OnMemberWitdrawMoney(this, player, amount, false); // IsRepair not a part of Mangos, implement?
//#endif
return true; return true;
} }
@ -1877,6 +1883,10 @@ void Guild::LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uin
m_GuildBankEventLog_Item[TabId].push_back(NewEvent); m_GuildBankEventLog_Item[TabId].push_back(NewEvent);
} }
#ifdef ENABLE_ELUNA
sEluna->OnBankEvent(this, EventType, TabId, PlayerGuidLow, ItemOrMoney, ItemStackCount, DestTabId);
#endif
// save event to database // save event to database
CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u' AND TabId='%u'", m_Id, currentLogGuid, currentTabId); CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u' AND TabId='%u'", m_Id, currentLogGuid, currentTabId);
@ -2630,7 +2640,7 @@ void Guild::BroadcastEvent(GuildEvents event, ObjectGuid guid, char const* str1
data << str2; data << str2;
} }
else if (str1) else if (str1)
data << str1; { data << str1; }
if (guid) if (guid)
data << ObjectGuid(guid); data << ObjectGuid(guid);

View file

@ -39,7 +39,7 @@ class Item;
enum GuildDefaultRanks enum GuildDefaultRanks
{ {
// these ranks can be modified, but they cannot be deleted // these ranks can be modified, but they can not be deleted
GR_GUILDMASTER = 0, GR_GUILDMASTER = 0,
GR_OFFICER = 1, GR_OFFICER = 1,
GR_VETERAN = 2, GR_VETERAN = 2,
@ -401,7 +401,7 @@ class Guild
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); }
} }
void CreateRank(std::string name, uint32 rights); void CreateRank(std::string name, uint32 rights);
@ -443,7 +443,7 @@ class Guild
{ {
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;
} }

View file

@ -104,8 +104,7 @@ void LoadRandomEnchantmentsTable()
uint32 GetItemEnchantMod(int32 entry) uint32 GetItemEnchantMod(int32 entry)
{ {
if (!entry) if (!entry) { return 0; }
return 0;
EnchantmentStore::const_iterator tab; EnchantmentStore::const_iterator tab;
if (entry > 0) if (entry > 0)
@ -135,7 +134,7 @@ uint32 GetItemEnchantMod(int32 entry)
{ {
fCount += ench_iter->chance; fCount += ench_iter->chance;
if (fCount > dRoll) return ench_iter->ench; if (fCount > dRoll) { return ench_iter->ench; }
} }
// 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%
@ -146,7 +145,7 @@ uint32 GetItemEnchantMod(int32 entry)
{ {
fCount += ench_iter->chance; fCount += ench_iter->chance;
if (fCount > dRoll) return ench_iter->ench; if (fCount > dRoll) { return ench_iter->ench; }
} }
return 0; return 0;

View file

@ -598,7 +598,7 @@ struct ItemPrototype
uint32 Delay; uint32 Delay;
float RangedModRange; float RangedModRange;
_Spell Spells[MAX_ITEM_PROTO_SPELLS]; _Spell Spells[MAX_ITEM_PROTO_SPELLS];
uint32 Bonding; uint32 Bonding; ///< See \ref ItemBondingType
char* Description; char* Description;
uint32 PageText; uint32 PageText;
uint32 LanguageID; uint32 LanguageID;
@ -622,7 +622,7 @@ struct ItemPrototype
float ArmorDamageModifier; float ArmorDamageModifier;
uint32 Duration; uint32 Duration;
uint32 ItemLimitCategory; // id from ItemLimitCategory.dbc uint32 ItemLimitCategory; // id from ItemLimitCategory.dbc
uint32 HolidayId; uint32 HolidayId; // id from Holidays.dbc
uint32 DisenchantID; uint32 DisenchantID;
uint32 FoodType; uint32 FoodType;
float StatScalingFactor; float StatScalingFactor;
@ -662,7 +662,7 @@ struct ItemPrototype
float GetMinDamage() const { return floor(getDPS() * float(Delay) / 1000.0f * 0.7f + 0.5f); } float GetMinDamage() const { return floor(getDPS() * float(Delay) / 1000.0f * 0.7f + 0.5f); }
float GetMaxDamage() const { return floor(getDPS() * float(Delay) / 1000.0f * 1.3f + 0.5f); } float GetMaxDamage() const { return floor(getDPS() * float(Delay) / 1000.0f * 1.3f + 0.5f); }
bool IsPotion() const { return Class==ITEM_CLASS_CONSUMABLE && SubClass==ITEM_SUBCLASS_POTION; } bool IsPotion() const { return Class == ITEM_CLASS_CONSUMABLE && SubClass == ITEM_SUBCLASS_POTION; }
bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_FLAG_CONJURED); } bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_FLAG_CONJURED); }
bool IsVellum() const bool IsVellum() const
{ {

View file

@ -62,7 +62,7 @@ class LootTemplate::LootGroup // A set of loot def
public: public:
void AddEntry(LootStoreItem& item); // Adds an entry to the group (at loading stage) void AddEntry(LootStoreItem& item); // Adds an entry to the group (at loading stage)
bool HasQuestDrop() const; // True if group includes at least 1 quest drop entry bool HasQuestDrop() const; // True if group includes at least 1 quest drop entry
bool HasQuestDropForPlayer(Player const* player) const; bool HasQuestDropForPlayer(Player const* player) const; // The same for active quests of the player
// The same for active quests of the player // The same for active quests of the player
void Process(Loot& loot) const; // Rolls an item from the group (if any) and adds the item to the loot void Process(Loot& loot) const; // Rolls an item from the group (if any) and adds the item to the loot
float RawTotalChance() const; // Overall chance for the group (without equal chanced items) float RawTotalChance() const; // Overall chance for the group (without equal chanced items)
@ -82,7 +82,7 @@ class LootTemplate::LootGroup // A set of loot def
void LootStore::Clear() void LootStore::Clear()
{ {
for (LootTemplateMap::const_iterator itr = m_LootTemplates.begin(); itr != m_LootTemplates.end(); ++itr) for (LootTemplateMap::const_iterator itr = m_LootTemplates.begin(); itr != m_LootTemplates.end(); ++itr)
delete itr->second; { delete itr->second; }
m_LootTemplates.clear(); m_LootTemplates.clear();
} }
@ -91,7 +91,7 @@ void LootStore::Clear()
void LootStore::Verify() const void LootStore::Verify() const
{ {
for (LootTemplateMap::const_iterator i = m_LootTemplates.begin(); i != m_LootTemplates.end(); ++i) for (LootTemplateMap::const_iterator i = m_LootTemplates.begin(); i != m_LootTemplates.end(); ++i)
i->second->Verify(*this, i->first); { i->second->Verify(*this, i->first); }
} }
// Loads a *_loot_template DB table into loot store // Loads a *_loot_template DB table into loot store
@ -152,7 +152,7 @@ void LootStore::LoadLootTable()
LootStoreItem storeitem = LootStoreItem(item, type, chanceOrQuestChance, group, conditionId, mincountOrRef, maxcount); LootStoreItem storeitem = LootStoreItem(item, type, chanceOrQuestChance, group, conditionId, mincountOrRef, maxcount);
if (!storeitem.IsValid(*this, entry)) // Validity checks if (!storeitem.IsValid(*this, entry)) // Validity checks
continue; { continue; }
// Looking for the template of the entry // Looking for the template of the entry
// often entries are put together // often entries are put together
@ -193,7 +193,7 @@ bool LootStore::HaveQuestLootFor(uint32 loot_id) const
{ {
LootTemplateMap::const_iterator itr = m_LootTemplates.find(loot_id); LootTemplateMap::const_iterator itr = m_LootTemplates.find(loot_id);
if (itr == m_LootTemplates.end()) if (itr == m_LootTemplates.end())
return false; { return false; }
// scan loot for quest items // scan loot for quest items
return itr->second->HasQuestDrop(m_LootTemplates); return itr->second->HasQuestDrop(m_LootTemplates);
@ -204,7 +204,7 @@ bool LootStore::HaveQuestLootForPlayer(uint32 loot_id, Player* player) const
LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id); LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id);
if (tab != m_LootTemplates.end()) if (tab != m_LootTemplates.end())
if (tab->second->HasQuestDropForPlayer(m_LootTemplates, player)) if (tab->second->HasQuestDropForPlayer(m_LootTemplates, player))
return true; { return true; }
return false; return false;
} }
@ -214,7 +214,7 @@ LootTemplate const* LootStore::GetLootFor(uint32 loot_id) const
LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id); LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id);
if (tab == m_LootTemplates.end()) if (tab == m_LootTemplates.end())
return NULL; { return NULL; }
return tab->second; return tab->second;
} }
@ -224,20 +224,20 @@ void LootStore::LoadAndCollectLootIds(LootIdSet& ids_set)
LoadLootTable(); LoadLootTable();
for (LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab) for (LootTemplateMap::const_iterator tab = m_LootTemplates.begin(); tab != m_LootTemplates.end(); ++tab)
ids_set.insert(tab->first); { ids_set.insert(tab->first); }
} }
void LootStore::CheckLootRefs(LootIdSet* ref_set) const void LootStore::CheckLootRefs(LootIdSet* ref_set) const
{ {
for (LootTemplateMap::const_iterator ltItr = m_LootTemplates.begin(); ltItr != m_LootTemplates.end(); ++ltItr) for (LootTemplateMap::const_iterator ltItr = m_LootTemplates.begin(); ltItr != m_LootTemplates.end(); ++ltItr)
ltItr->second->CheckLootRefs(ref_set); { ltItr->second->CheckLootRefs(ref_set); }
} }
void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const
{ {
// all still listed ids isn't referenced // all still listed ids isn't referenced
for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr) for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr)
sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr, GetEntryName()); { sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr, GetEntryName()); }
} }
void LootStore::ReportNotExistedId(uint32 id) const void LootStore::ReportNotExistedId(uint32 id) const
@ -254,10 +254,10 @@ void LootStore::ReportNotExistedId(uint32 id) const
bool LootStoreItem::Roll(bool rate) const bool LootStoreItem::Roll(bool rate) const
{ {
if (chance >= 100.0f) if (chance >= 100.0f)
return true; { return true; }
if (mincountOrRef < 0) // reference case if (mincountOrRef < 0) // reference case
return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f)); { return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f)); }
if (type == LOOTITEM_TYPE_CURRENCY) if (type == LOOTITEM_TYPE_CURRENCY)
return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_CURRENCY) : 1.0f)); return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_CURRENCY) : 1.0f));
@ -473,7 +473,7 @@ LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Play
{ {
// ignore currencies, looted items, FFA (each player get own copy) and not allowed items // ignore currencies, looted items, FFA (each player get own copy) and not allowed items
if (currency || is_looted || freeforall || (conditionId && !condition_ok) || !AllowedForPlayer(viewer, lootTarget)) if (currency || is_looted || freeforall || (conditionId && !condition_ok) || !AllowedForPlayer(viewer, lootTarget))
return MAX_LOOT_SLOT_TYPE; { return MAX_LOOT_SLOT_TYPE; }
switch (permission) switch (permission)
{ {
@ -500,7 +500,7 @@ void Loot::AddItem(LootStoreItem const& item)
if (item.needs_quest) // Quest drop if (item.needs_quest) // Quest drop
{ {
if (m_questItems.size() < MAX_NR_QUEST_ITEMS) if (m_questItems.size() < MAX_NR_QUEST_ITEMS)
m_questItems.push_back(LootItem(item)); { m_questItems.push_back(LootItem(item)); }
} }
else if (items.size() < MAX_NR_LOOT_ITEMS) // Non-quest drop else if (items.size() < MAX_NR_LOOT_ITEMS) // Non-quest drop
{ {
@ -514,7 +514,7 @@ void Loot::AddItem(LootStoreItem const& item)
{ {
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item.itemid); ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item.itemid);
if (!proto || !(proto->Flags & ITEM_FLAG_PARTY_LOOT)) if (!proto || !(proto->Flags & ITEM_FLAG_PARTY_LOOT))
++unlootedCount; { ++unlootedCount; }
} }
} }
} }
@ -524,14 +524,14 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner,
{ {
// Must be provided // Must be provided
if (!loot_owner) if (!loot_owner)
return false; { return false; }
LootTemplate const* tab = store.GetLootFor(loot_id); LootTemplate const* tab = store.GetLootFor(loot_id);
if (!tab) if (!tab)
{ {
if (!noEmptyError) if (!noEmptyError)
sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.", store.GetName(), loot_id); { sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.", store.GetName(), loot_id); }
return false; return false;
} }
@ -546,11 +546,11 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner,
{ {
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* pl = itr->getSource()) if (Player* pl = itr->getSource())
FillNotNormalLootFor(pl); { FillNotNormalLootFor(pl); }
} }
// ... for personal loot // ... for personal loot
else else
FillNotNormalLootFor(loot_owner); { FillNotNormalLootFor(loot_owner); }
return true; return true;
} }
@ -565,11 +565,11 @@ void Loot::FillNotNormalLootFor(Player* pl)
qmapitr = m_playerQuestItems.find(plguid); qmapitr = m_playerQuestItems.find(plguid);
if (qmapitr == m_playerQuestItems.end()) if (qmapitr == m_playerQuestItems.end())
FillQuestLoot(pl); { FillQuestLoot(pl); }
qmapitr = m_playerFFAItems.find(plguid); qmapitr = m_playerFFAItems.find(plguid);
if (qmapitr == m_playerFFAItems.end()) if (qmapitr == m_playerFFAItems.end())
FillFFALoot(pl); { FillFFALoot(pl); }
qmapitr = m_playerNonQuestNonFFANonCurrencyConditionalItems.find(plguid); qmapitr = m_playerNonQuestNonFFANonCurrencyConditionalItems.find(plguid);
if (qmapitr == m_playerNonQuestNonFFANonCurrencyConditionalItems.end()) if (qmapitr == m_playerNonQuestNonFFANonCurrencyConditionalItems.end())
@ -624,7 +624,7 @@ QuestItemList* Loot::FillFFALoot(Player* player)
QuestItemList* Loot::FillQuestLoot(Player* player) QuestItemList* Loot::FillQuestLoot(Player* player)
{ {
if (items.size() == MAX_NR_LOOT_ITEMS) return NULL; if (items.size() == MAX_NR_LOOT_ITEMS) { return NULL; }
QuestItemList* ql = new QuestItemList(); QuestItemList* ql = new QuestItemList();
for (uint8 i = 0; i < m_questItems.size(); ++i) for (uint8 i = 0; i < m_questItems.size(); ++i)
@ -639,12 +639,12 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
// //
// increase once if one looter only, looter-times if free for all // increase once if one looter only, looter-times if free for all
if (item.freeforall || !item.is_blocked) if (item.freeforall || !item.is_blocked)
++unlootedCount; { ++unlootedCount; }
item.is_blocked = true; item.is_blocked = true;
if (items.size() + ql->size() == MAX_NR_LOOT_ITEMS) if (items.size() + ql->size() == MAX_NR_LOOT_ITEMS)
break; { break; }
} }
} }
if (ql->empty()) if (ql->empty())
@ -696,9 +696,9 @@ void Loot::NotifyItemRemoved(uint8 lootIndex)
i_next = i; i_next = i;
++i_next; ++i_next;
if (Player* pl = ObjectAccessor::FindPlayer(*i)) if (Player* pl = ObjectAccessor::FindPlayer(*i))
pl->SendNotifyLootItemRemoved(lootIndex); { pl->SendNotifyLootItemRemoved(lootIndex); }
else else
m_playersLooting.erase(i); { m_playersLooting.erase(i); }
} }
} }
@ -711,9 +711,9 @@ void Loot::NotifyMoneyRemoved()
i_next = i; i_next = i;
++i_next; ++i_next;
if (Player* pl = ObjectAccessor::FindPlayer(*i)) if (Player* pl = ObjectAccessor::FindPlayer(*i))
pl->SendNotifyLootMoneyRemoved(); { pl->SendNotifyLootMoneyRemoved(); }
else else
m_playersLooting.erase(i); { m_playersLooting.erase(i); }
} }
} }
@ -740,14 +740,14 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
uint8 j; uint8 j;
for (j = 0; j < pql.size(); ++j) for (j = 0; j < pql.size(); ++j)
if (pql[j].index == questIndex) if (pql[j].index == questIndex)
break; { break; }
if (j < pql.size()) if (j < pql.size())
pl->SendNotifyLootItemRemoved(items.size() + j); { pl->SendNotifyLootItemRemoved(items.size() + j); }
} }
} }
else else
m_playersLooting.erase(i); { m_playersLooting.erase(i); }
} }
} }
@ -756,11 +756,11 @@ void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
if (maxAmount > 0) if (maxAmount > 0)
{ {
if (maxAmount <= minAmount) if (maxAmount <= minAmount)
gold = uint32(maxAmount * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); { gold = uint32(maxAmount * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); }
else if ((maxAmount - minAmount) < 32700) else if ((maxAmount - minAmount) < 32700)
gold = uint32(urand(minAmount, maxAmount) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); { gold = uint32(urand(minAmount, maxAmount) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); }
else else
gold = uint32(urand(minAmount >> 8, maxAmount >> 8) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)) << 8; { gold = uint32(urand(minAmount >> 8, maxAmount >> 8) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)) << 8; }
} }
} }
@ -776,7 +776,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite
{ {
QuestItem* qitem2 = &itr->second->at(questSlot); QuestItem* qitem2 = &itr->second->at(questSlot);
if (qitem) if (qitem)
*qitem = qitem2; { *qitem = qitem2; }
item = &m_questItems[qitem2->index]; item = &m_questItems[qitem2->index];
is_looted = qitem2->is_looted; is_looted = qitem2->is_looted;
} }
@ -813,7 +813,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite
{ {
QuestItem* ffaitem2 = (QuestItem*) & (*iter); QuestItem* ffaitem2 = (QuestItem*) & (*iter);
if (ffaitem) if (ffaitem)
*ffaitem = ffaitem2; { *ffaitem = ffaitem2; }
is_looted = ffaitem2->is_looted; is_looted = ffaitem2->is_looted;
break; break;
} }
@ -830,7 +830,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite
{ {
QuestItem* conditem2 = (QuestItem*) & (*iter); QuestItem* conditem2 = (QuestItem*) & (*iter);
if (conditem) if (conditem)
*conditem = conditem2; { *conditem = conditem2; }
is_looted = conditem2->is_looted; is_looted = conditem2->is_looted;
break; break;
} }
@ -840,7 +840,7 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite
} }
if (is_looted) if (is_looted)
return NULL; { return NULL; }
return item; return item;
} }
@ -897,7 +897,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
{ {
LootSlotType slot_type = l.items[i].GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget()); LootSlotType slot_type = l.items[i].GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget());
if (slot_type >= MAX_LOOT_SLOT_TYPE) if (slot_type >= MAX_LOOT_SLOT_TYPE)
continue; { continue; }
b << uint8(i) << l.items[i]; b << uint8(i) << l.items[i];
b << uint8(slot_type); // 0 - get 1 - look only 2 - master selection b << uint8(slot_type); // 0 - get 1 - look only 2 - master selection
@ -915,7 +915,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget(), !ci->is_looted); LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget(), !ci->is_looted);
if (slot_type >= MAX_LOOT_SLOT_TYPE) if (slot_type >= MAX_LOOT_SLOT_TYPE)
continue; { continue; }
b << uint8(ci->index) << item; b << uint8(ci->index) << item;
b << uint8(slot_type); // allow loot b << uint8(slot_type); // allow loot
@ -992,9 +992,9 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
void LootTemplate::LootGroup::AddEntry(LootStoreItem& item) void LootTemplate::LootGroup::AddEntry(LootStoreItem& item)
{ {
if (item.chance != 0) if (item.chance != 0)
ExplicitlyChanced.push_back(item); { ExplicitlyChanced.push_back(item); }
else else
EqualChanced.push_back(item); { EqualChanced.push_back(item); }
} }
// Rolls an item from the group, returns NULL if all miss their chances // Rolls an item from the group, returns NULL if all miss their chances
@ -1007,15 +1007,15 @@ LootStoreItem const* LootTemplate::LootGroup::Roll() const
for (uint32 i = 0; i < ExplicitlyChanced.size(); ++i) // check each explicitly chanced entry in the template and modify its chance based on quality. for (uint32 i = 0; i < ExplicitlyChanced.size(); ++i) // check each explicitly chanced entry in the template and modify its chance based on quality.
{ {
if (ExplicitlyChanced[i].chance >= 100.0f) if (ExplicitlyChanced[i].chance >= 100.0f)
return &ExplicitlyChanced[i]; { return &ExplicitlyChanced[i]; }
Roll -= ExplicitlyChanced[i].chance; Roll -= ExplicitlyChanced[i].chance;
if (Roll < 0) if (Roll < 0)
return &ExplicitlyChanced[i]; { return &ExplicitlyChanced[i]; }
} }
} }
if (!EqualChanced.empty()) // If nothing selected yet - an item is taken from equal-chanced part if (!EqualChanced.empty()) // If nothing selected yet - an item is taken from equal-chanced part
return &EqualChanced[irand(0, EqualChanced.size() - 1)]; { return &EqualChanced[irand(0, EqualChanced.size() - 1)]; }
return NULL; // Empty drop from the group return NULL; // Empty drop from the group
} }
@ -1025,10 +1025,10 @@ bool LootTemplate::LootGroup::HasQuestDrop() const
{ {
for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if (i->needs_quest) if (i->needs_quest)
return true; { return true; }
for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i) for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i)
if (i->needs_quest) if (i->needs_quest)
return true; { return true; }
return false; return false;
} }
@ -1037,10 +1037,10 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const
{ {
for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if (player->HasQuestForItem(i->itemid)) if (player->HasQuestForItem(i->itemid))
return true; { return true; }
for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i) for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i)
if (player->HasQuestForItem(i->itemid)) if (player->HasQuestForItem(i->itemid))
return true; { return true; }
return false; return false;
} }
@ -1049,7 +1049,7 @@ void LootTemplate::LootGroup::Process(Loot& loot) const
{ {
LootStoreItem const* item = Roll(); LootStoreItem const* item = Roll();
if (item != NULL) if (item != NULL)
loot.AddItem(*item); { loot.AddItem(*item); }
} }
// Overall chance for the group without equal chanced items // Overall chance for the group without equal chanced items
@ -1059,7 +1059,7 @@ float LootTemplate::LootGroup::RawTotalChance() const
for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if (!i->needs_quest) if (!i->needs_quest)
result += i->chance; { result += i->chance; }
return result; return result;
} }
@ -1070,7 +1070,7 @@ float LootTemplate::LootGroup::TotalChance() const
float result = RawTotalChance(); float result = RawTotalChance();
if (!EqualChanced.empty() && result < 100.0f) if (!EqualChanced.empty() && result < 100.0f)
return 100.0f; { return 100.0f; }
return result; return result;
} }
@ -1096,9 +1096,9 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const
if (ieItr->mincountOrRef < 0) if (ieItr->mincountOrRef < 0)
{ {
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); { LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); }
else if (ref_set) else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef); { ref_set->erase(-ieItr->mincountOrRef); }
} }
} }
@ -1107,9 +1107,9 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const
if (ieItr->mincountOrRef < 0) if (ieItr->mincountOrRef < 0)
{ {
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); { LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); }
else if (ref_set) else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef); { ref_set->erase(-ieItr->mincountOrRef); }
} }
} }
} }
@ -1124,11 +1124,11 @@ void LootTemplate::AddEntry(LootStoreItem& item)
if (item.group > 0 && item.mincountOrRef > 0) // Group if (item.group > 0 && item.mincountOrRef > 0) // Group
{ {
if (item.group >= Groups.size()) if (item.group >= Groups.size())
Groups.resize(item.group); // Adds new group the the loot template if needed { Groups.resize(item.group); } // Adds new group the the loot template if needed
Groups[item.group - 1].AddEntry(item); // Adds new entry to the group Groups[item.group - 1].AddEntry(item); // Adds new entry to the group
} }
else // Non-grouped entries and references are stored together else // Non-grouped entries and references are stored together
Entries.push_back(item); { Entries.push_back(item); }
} }
// Rolls for every item in the template and adds the rolled items the the loot // Rolls for every item in the template and adds the rolled items the the loot
@ -1137,7 +1137,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
if (groupId) // Group reference uses own processing of the group if (groupId) // Group reference uses own processing of the group
{ {
if (groupId > Groups.size()) if (groupId > Groups.size())
return; // Error message already printed at loading stage { return; } // Error message already printed at loading stage
Groups[groupId - 1].Process(loot); Groups[groupId - 1].Process(loot);
return; return;
@ -1147,29 +1147,29 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i) for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i)
{ {
if (!i->Roll(rate)) if (!i->Roll(rate))
continue; // Bad luck for the entry { continue; } // Bad luck for the entry
if (i->mincountOrRef < 0 && i->type == LOOT_ITEM_TYPE_ITEM) // References processing if (i->mincountOrRef < 0 && i->type == LOOT_ITEM_TYPE_ITEM) // References processing
{ {
LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(-i->mincountOrRef); LootTemplate const* Referenced = LootTemplates_Reference.GetLootFor(-i->mincountOrRef);
if (!Referenced) if (!Referenced)
continue; // Error message already printed at loading stage { continue; } // Error message already printed at loading stage
// Check condition // Check condition
if (i->conditionId && !sObjectMgr.IsPlayerMeetToCondition(i->conditionId, NULL, NULL, loot.GetLootTarget(), CONDITION_FROM_REFERING_LOOT)) if (i->conditionId && !sObjectMgr.IsPlayerMeetToCondition(i->conditionId, NULL, NULL, loot.GetLootTarget(), CONDITION_FROM_REFERING_LOOT))
continue; { continue; }
for (uint32 loop = 0; loop < i->maxcount; ++loop) // Ref multiplicator for (uint32 loop = 0; loop < i->maxcount; ++loop) // Ref multiplicator
Referenced->Process(loot, store, rate, i->group); { Referenced->Process(loot, store, rate, i->group); }
} }
else // Plain entries (not a reference, not grouped) else // Plain entries (not a reference, not grouped)
loot.AddItem(*i); // Chance is already checked, just add { loot.AddItem(*i); } // Chance is already checked, just add
} }
// Now processing groups // Now processing groups
for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i) for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i)
i->Process(loot); { i->Process(loot); }
} }
// True if template includes at least 1 quest drop entry // True if template includes at least 1 quest drop entry
@ -1178,7 +1178,7 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
if (groupId) // Group reference if (groupId) // Group reference
{ {
if (groupId > Groups.size()) if (groupId > Groups.size())
return false; // Error message [should be] already printed at loading stage { return false; } // Error message [should be] already printed at loading stage
return Groups[groupId - 1].HasQuestDrop(); return Groups[groupId - 1].HasQuestDrop();
} }
@ -1188,18 +1188,18 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
{ {
LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef); LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef);
if (Referenced == store.end()) if (Referenced == store.end())
continue; // Error message [should be] already printed at loading stage { continue; } // Error message [should be] already printed at loading stage
if (Referenced->second->HasQuestDrop(store, i->group)) if (Referenced->second->HasQuestDrop(store, i->group))
return true; { return true; }
} }
else if (i->needs_quest) else if (i->needs_quest)
return true; // quest drop found { return true; } // quest drop found
} }
// Now processing groups // Now processing groups
for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i) for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i)
if (i->HasQuestDrop()) if (i->HasQuestDrop())
return true; { return true; }
return false; return false;
} }
@ -1210,7 +1210,7 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co
if (groupId) // Group reference if (groupId) // Group reference
{ {
if (groupId > Groups.size()) if (groupId > Groups.size())
return false; // Error message already printed at loading stage { return false; } // Error message already printed at loading stage
return Groups[groupId - 1].HasQuestDropForPlayer(player); return Groups[groupId - 1].HasQuestDropForPlayer(player);
} }
@ -1221,18 +1221,18 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co
{ {
LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef); LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef);
if (Referenced == store.end()) if (Referenced == store.end())
continue; // Error message already printed at loading stage { continue; } // Error message already printed at loading stage
if (Referenced->second->HasQuestDropForPlayer(store, player, i->group)) if (Referenced->second->HasQuestDropForPlayer(store, player, i->group))
return true; { return true; }
} }
else if (player->HasQuestForItem(i->itemid)) else if (player->HasQuestForItem(i->itemid))
return true; // active quest drop found { return true; } // active quest drop found
} }
// Now checking groups // Now checking groups
for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i) for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i)
if (i->HasQuestDropForPlayer(player)) if (i->HasQuestDropForPlayer(player))
return true; { return true; }
return false; return false;
} }
@ -1242,7 +1242,7 @@ void LootTemplate::Verify(LootStore const& lootstore, uint32 id) const
{ {
// Checking group chances // Checking group chances
for (uint32 i = 0; i < Groups.size(); ++i) for (uint32 i = 0; i < Groups.size(); ++i)
Groups[i].Verify(lootstore, id, i + 1); { Groups[i].Verify(lootstore, id, i + 1); }
// TODO: References validity checks // TODO: References validity checks
} }
@ -1254,14 +1254,14 @@ void LootTemplate::CheckLootRefs(LootIdSet* ref_set) const
if (ieItr->mincountOrRef < 0) if (ieItr->mincountOrRef < 0)
{ {
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); { LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); }
else if (ref_set) else if (ref_set)
ref_set->erase(-ieItr->mincountOrRef); { ref_set->erase(-ieItr->mincountOrRef); }
} }
} }
for (LootGroups::const_iterator grItr = Groups.begin(); grItr != Groups.end(); ++grItr) for (LootGroups::const_iterator grItr = Groups.begin(); grItr != Groups.end(); ++grItr)
grItr->CheckLootRefs(ref_set); { grItr->CheckLootRefs(ref_set); }
} }
void LoadLootTemplates_Creature() void LoadLootTemplates_Creature()
@ -1284,7 +1284,7 @@ void LoadLootTemplates_Creature()
} }
} }
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); { ids_set.erase(*itr); }
// for alterac valley we've defined Player-loot inside creature_loot_template id=0 // for alterac valley we've defined Player-loot inside creature_loot_template id=0
// this hack is used, so that we won't need to create an extra table player_loot_template for just one case // this hack is used, so that we won't need to create an extra table player_loot_template for just one case
@ -1314,7 +1314,7 @@ void LoadLootTemplates_Disenchant()
} }
} }
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); { ids_set.erase(*itr); }
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Disenchant.ReportUnusedIds(ids_set); LootTemplates_Disenchant.ReportUnusedIds(ids_set);
} }
@ -1329,7 +1329,7 @@ void LoadLootTemplates_Fishing()
{ {
if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i)) if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i))
if (ids_set.find(areaEntry->ID) != ids_set.end()) if (ids_set.find(areaEntry->ID) != ids_set.end())
ids_set.erase(areaEntry->ID); { ids_set.erase(areaEntry->ID); }
} }
// by default (look config options) fishing at fail provide junk loot, entry 0 use for store this loot // by default (look config options) fishing at fail provide junk loot, entry 0 use for store this loot
@ -1356,7 +1356,7 @@ void LoadLootTemplates_Gameobject()
} }
} }
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); { ids_set.erase(*itr); }
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Gameobject.ReportUnusedIds(ids_set); LootTemplates_Gameobject.ReportUnusedIds(ids_set);
@ -1373,13 +1373,13 @@ void LoadLootTemplates_Item()
if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i)) if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
{ {
if (!(proto->Flags & ITEM_FLAG_LOOTABLE)) if (!(proto->Flags & ITEM_FLAG_LOOTABLE))
continue; { continue; }
if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0) if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0)
ids_set.erase(proto->ItemId); { ids_set.erase(proto->ItemId); }
// wdb have wrong data cases, so skip by default // wdb have wrong data cases, so skip by default
else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK))
LootTemplates_Item.ReportNotExistedId(proto->ItemId); { LootTemplates_Item.ReportNotExistedId(proto->ItemId); }
} }
} }
@ -1432,7 +1432,7 @@ void LoadLootTemplates_Pickpocketing()
} }
} }
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); { ids_set.erase(*itr); }
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Pickpocketing.ReportUnusedIds(ids_set); LootTemplates_Pickpocketing.ReportUnusedIds(ids_set);
@ -1472,7 +1472,7 @@ void LoadLootTemplates_Mail()
for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i) for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
if (sMailTemplateStore.LookupEntry(i)) if (sMailTemplateStore.LookupEntry(i))
if (ids_set.find(i) != ids_set.end()) if (ids_set.find(i) != ids_set.end())
ids_set.erase(i); { ids_set.erase(i); }
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Mail.ReportUnusedIds(ids_set); LootTemplates_Mail.ReportUnusedIds(ids_set);
@ -1498,7 +1498,7 @@ void LoadLootTemplates_Skinning()
} }
} }
for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr)
ids_set.erase(*itr); { ids_set.erase(*itr); }
// output error for any still listed (not referenced from appropriate table) ids // output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Skinning.ReportUnusedIds(ids_set); LootTemplates_Skinning.ReportUnusedIds(ids_set);

View file

@ -38,7 +38,7 @@ class LootStore;
class WorldObject; class WorldObject;
#define MAX_NR_LOOT_ITEMS 16 #define MAX_NR_LOOT_ITEMS 16
// note: the client cannot show more than 16 items total // note: the client can not show more than 16 items total
#define MAX_NR_QUEST_ITEMS 32 #define MAX_NR_QUEST_ITEMS 32
// unrelated to the number of quest items shown, just for reserve // unrelated to the number of quest items shown, just for reserve
@ -196,7 +196,7 @@ class LootStore
class LootTemplate class LootTemplate
{ {
class LootGroup; // A set of loot definitions for items (refs are not allowed inside) class LootGroup; // A set of loot definitions for items (refs are not allowed inside)
typedef std::vector<LootGroup> LootGroups; typedef std::vector<LootGroup> LootGroups;
public: public:
@ -281,15 +281,15 @@ struct Loot
m_playerCurrencies.clear(); m_playerCurrencies.clear();
for (QuestItemMap::const_iterator itr = m_playerQuestItems.begin(); itr != m_playerQuestItems.end(); ++itr) for (QuestItemMap::const_iterator itr = m_playerQuestItems.begin(); itr != m_playerQuestItems.end(); ++itr)
delete itr->second; { delete itr->second; }
m_playerQuestItems.clear(); m_playerQuestItems.clear();
for (QuestItemMap::const_iterator itr = m_playerFFAItems.begin(); itr != m_playerFFAItems.end(); ++itr) for (QuestItemMap::const_iterator itr = m_playerFFAItems.begin(); itr != m_playerFFAItems.end(); ++itr)
delete itr->second; { delete itr->second; }
m_playerFFAItems.clear(); m_playerFFAItems.clear();
for (QuestItemMap::const_iterator itr = m_playerNonQuestNonFFANonCurrencyConditionalItems.begin(); itr != m_playerNonQuestNonFFANonCurrencyConditionalItems.end(); ++itr) for (QuestItemMap::const_iterator itr = m_playerNonQuestNonFFANonCurrencyConditionalItems.begin(); itr != m_playerNonQuestNonFFANonCurrencyConditionalItems.end(); ++itr)
delete itr->second; { delete itr->second; }
m_playerNonQuestNonFFANonCurrencyConditionalItems.clear(); m_playerNonQuestNonFFANonCurrencyConditionalItems.clear();
m_playersLooting.clear(); m_playersLooting.clear();

View file

@ -133,14 +133,14 @@ void Object::SendForcedObjectUpdate()
void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const
{ {
if (!target) if (!target)
return; { return; }
uint8 updatetype = UPDATETYPE_CREATE_OBJECT; uint8 updatetype = UPDATETYPE_CREATE_OBJECT;
uint16 updateFlags = m_updateFlag; uint16 updateFlags = m_updateFlag;
/** lower flag1 **/ /** lower flag1 **/
if (target == this) // building packet for yourself if (target == this) // building packet for yourself
updateFlags |= UPDATEFLAG_SELF; { updateFlags |= UPDATEFLAG_SELF; }
if (m_itsNewObject) if (m_itsNewObject)
{ {
@ -1493,7 +1493,7 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const
void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap /*=NULL*/) const void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap /*=NULL*/) const
{ {
if (!atMap) if (!atMap)
atMap = GetMap(); { atMap = GetMap(); }
switch (GetTypeId()) switch (GetTypeId())
{ {
@ -1511,16 +1511,16 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap
if (max_z > INVALID_HEIGHT) if (max_z > INVALID_HEIGHT)
{ {
if (z > max_z) if (z > max_z)
z = max_z; { z = max_z; }
else if (z < ground_z) else if (z < ground_z)
z = ground_z; { z = ground_z; }
} }
} }
else else
{ {
float ground_z = atMap->GetHeight(GetPhaseMask(), x, y, z); float ground_z = atMap->GetHeight(GetPhaseMask(), x, y, z);
if (z < ground_z) if (z < ground_z)
z = ground_z; { z = ground_z; }
} }
break; break;
} }
@ -1534,9 +1534,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap
if (max_z > INVALID_HEIGHT) if (max_z > INVALID_HEIGHT)
{ {
if (z > max_z) if (z > max_z)
z = max_z; { z = max_z; }
else if (z < ground_z) else if (z < ground_z)
z = ground_z; { z = ground_z; }
} }
} }
else else
@ -1551,7 +1551,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap
{ {
float ground_z = atMap->GetHeight(GetPhaseMask(), x, y, z); float ground_z = atMap->GetHeight(GetPhaseMask(), x, y, z);
if (ground_z > INVALID_HEIGHT) if (ground_z > INVALID_HEIGHT)
z = ground_z; { z = ground_z; }
break; break;
} }
} }
@ -1566,7 +1566,7 @@ void WorldObject::MonsterSay(const char* text, uint32 language, Unit const* targ
{ {
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket data(SMSG_MESSAGECHAT, 200);
ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_SAY, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(), ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_SAY, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(),
target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : ""); target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : "");
SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY), true); SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY), true);
} }
@ -1574,7 +1574,7 @@ void WorldObject::MonsterYell(const char* text, uint32 language, Unit const* tar
{ {
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket data(SMSG_MESSAGECHAT, 200);
ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_YELL, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(), ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_YELL, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(),
target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : ""); target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : "");
SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL), true); SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL), true);
} }
@ -1582,7 +1582,7 @@ void WorldObject::MonsterTextEmote(const char* text, Unit const* target, bool Is
{ {
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket data(SMSG_MESSAGECHAT, 200);
ChatHandler::BuildChatPacket(data, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(), ChatHandler::BuildChatPacket(data, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(),
target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : ""); target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : "");
SendMessageToSetInRange(&data, sWorld.getConfig(IsBossEmote ? CONFIG_FLOAT_LISTEN_RANGE_YELL : CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE), true); SendMessageToSetInRange(&data, sWorld.getConfig(IsBossEmote ? CONFIG_FLOAT_LISTEN_RANGE_YELL : CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE), true);
} }
@ -1593,7 +1593,7 @@ void WorldObject::MonsterWhisper(const char* text, Unit const* target, bool IsBo
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket data(SMSG_MESSAGECHAT, 200);
ChatHandler::BuildChatPacket(data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(), ChatHandler::BuildChatPacket(data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(),
target->GetObjectGuid(), target->GetName()); target->GetObjectGuid(), target->GetName());
((Player*)target)->GetSession()->SendPacket(&data); ((Player*)target)->GetSession()->SendPacket(&data);
} }
@ -1601,19 +1601,19 @@ namespace MaNGOS
{ {
class MonsterChatBuilder class MonsterChatBuilder
{ {
public: public:
MonsterChatBuilder(WorldObject const& obj, ChatMsg msgtype, MangosStringLocale const* textData, Language language, Unit const* target) MonsterChatBuilder(WorldObject const& obj, ChatMsg msgtype, MangosStringLocale const* textData, Language language, Unit const* target)
: i_object(obj), i_msgtype(msgtype), i_textData(textData), i_language(language), i_target(target) {} : i_object(obj), i_msgtype(msgtype), i_textData(textData), i_language(language), i_target(target) {}
void operator()(WorldPacket& data, int32 loc_idx) void operator()(WorldPacket& data, int32 loc_idx)
{ {
char const* text = NULL; char const* text = NULL;
if ((int32)i_textData->Content.size() > loc_idx + 1 && !i_textData->Content[loc_idx + 1].empty()) if ((int32)i_textData->Content.size() > loc_idx + 1 && !i_textData->Content[loc_idx + 1].empty())
text = i_textData->Content[loc_idx + 1].c_str(); { text = i_textData->Content[loc_idx + 1].c_str(); }
else else
text = i_textData->Content[0].c_str(); { text = i_textData->Content[0].c_str(); }
ChatHandler::BuildChatPacket(data, i_msgtype, text, i_language, CHAT_TAG_NONE, i_object.GetObjectGuid(), i_object.GetNameForLocaleIdx(loc_idx), ChatHandler::BuildChatPacket(data, i_msgtype, text, i_language, CHAT_TAG_NONE, i_object.GetObjectGuid(), i_object.GetNameForLocaleIdx(loc_idx),
i_target ? i_target->GetObjectGuid() : ObjectGuid(), i_target ? i_target->GetNameForLocaleIdx(loc_idx) : ""); i_target ? i_target->GetObjectGuid() : ObjectGuid(), i_target ? i_target->GetNameForLocaleIdx(loc_idx) : "");
} }
private: private:
@ -1656,7 +1656,7 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta
case CHAT_TYPE_WHISPER: case CHAT_TYPE_WHISPER:
{ {
if (!target || target->GetTypeId() != TYPEID_PLAYER) if (!target || target->GetTypeId() != TYPEID_PLAYER)
return; { return; }
MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_WHISPER, textData, LANG_UNIVERSAL, target); MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_WHISPER, textData, LANG_UNIVERSAL, target);
MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build); MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build);
say_do((Player*)target); say_do((Player*)target);
@ -1665,7 +1665,7 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta
case CHAT_TYPE_BOSS_WHISPER: case CHAT_TYPE_BOSS_WHISPER:
{ {
if (!target || target->GetTypeId() != TYPEID_PLAYER) if (!target || target->GetTypeId() != TYPEID_PLAYER)
return; { return; }
MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_RAID_BOSS_WHISPER, textData, LANG_UNIVERSAL, target); MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_RAID_BOSS_WHISPER, textData, LANG_UNIVERSAL, target);
MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build); MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build);
say_do((Player*)target); say_do((Player*)target);
@ -1679,7 +1679,7 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta
Map::PlayerList const& pList = GetMap()->GetPlayers(); Map::PlayerList const& pList = GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
if (itr->getSource()->GetZoneId() == zoneid) if (itr->getSource()->GetZoneId() == zoneid)
say_do(itr->getSource()); { say_do(itr->getSource()); }
break; break;
} }
} }
@ -1771,12 +1771,12 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
Team team = TEAM_NONE; Team team = TEAM_NONE;
if (GetTypeId() == TYPEID_PLAYER) if (GetTypeId() == TYPEID_PLAYER)
team = ((Player*)this)->GetTeam(); { team = ((Player*)this)->GetTeam(); }
CreatureCreatePos pos(GetMap(), x, y, z, ang, GetPhaseMask()); CreatureCreatePos pos(GetMap(), x, y, z, ang, GetPhaseMask());
if (x == 0.0f && y == 0.0f && z == 0.0f) if (x == 0.0f && y == 0.0f && z == 0.0f)
pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang); { pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang); }
if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(cinfo->GetHighGuid()), pos, cinfo, team)) if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(cinfo->GetHighGuid()), pos, cinfo, team))
{ {
@ -1795,8 +1795,8 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
pCreature->Summon(spwtype, despwtime); // Also initializes the AI and MMGen pCreature->Summon(spwtype, despwtime); // Also initializes the AI and MMGen
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
((Creature*)this)->AI()->JustSummoned(pCreature); { ((Creature*)this)->AI()->JustSummoned(pCreature); }
#ifdef ENABLE_ELUNA #ifdef ENABLE_ELUNA
if (Unit* summoner = ToUnit()) if (Unit* summoner = ToUnit())
sEluna->OnSummoned(pCreature, summoner); sEluna->OnSummoned(pCreature, summoner);
@ -1804,7 +1804,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
// Creature Linking, Initial load is handled like respawn // Creature Linking, Initial load is handled like respawn
if (pCreature->IsLinkingEventTrigger()) if (pCreature->IsLinkingEventTrigger())
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature); { GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature); }
// return the creature therewith the summoner has access to it // return the creature therewith the summoner has access to it
return pCreature; return pCreature;
@ -1816,7 +1816,7 @@ GameObject* WorldObject::SummonGameObject(uint32 id, float x, float y, float z,
Map *map = GetMap(); Map *map = GetMap();
if(!map) if (!map)
return NULL; return NULL;
if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), id, map, GetPhaseMask(), x, y, z, angle)) if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), id, map, GetPhaseMask(), x, y, z, angle))
@ -1934,9 +1934,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
if (!sWorld.getConfig(CONFIG_BOOL_DETECT_POS_COLLISION)) if (!sWorld.getConfig(CONFIG_BOOL_DETECT_POS_COLLISION))
{ {
if (searcher) if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); // update to LOS height if available { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available
else else
UpdateGroundPositionZ(x, y, z); { UpdateGroundPositionZ(x, y, z); }
return; return;
} }
@ -1962,12 +1962,12 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
if (selector.CheckOriginalAngle()) if (selector.CheckOriginalAngle())
{ {
if (searcher) if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); // update to LOS height if available { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available
else else
UpdateGroundPositionZ(x, y, z); { UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
return; { return; }
first_los_conflict = true; // first point have LOS problems first_los_conflict = true; // first point have LOS problems
} }
@ -1984,12 +1984,12 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
z = GetPositionZ(); z = GetPositionZ();
if (searcher) if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); // update to LOS height if available { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available
else else
UpdateGroundPositionZ(x, y, z); { UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
return; { return; }
} }
// BAD NEWS: not free pos (or used or have LOS problems) // BAD NEWS: not free pos (or used or have LOS problems)
@ -2000,9 +2000,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
y = first_y; y = first_y;
if (searcher) if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); // update to LOS height if available { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available
else else
UpdateGroundPositionZ(x, y, z); { UpdateGroundPositionZ(x, y, z); }
return; return;
} }
@ -2016,12 +2016,12 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
z = GetPositionZ(); z = GetPositionZ();
if (searcher) if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); // update to LOS height if available { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available
else else
UpdateGroundPositionZ(x, y, z); { UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
return; { return; }
} }
// BAD BAD NEWS: all found pos (free and used) have LOS problem :( // BAD BAD NEWS: all found pos (free and used) have LOS problem :(
@ -2029,9 +2029,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
y = first_y; y = first_y;
if (searcher) if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z, GetMap());// update to LOS height if available { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available
else else
UpdateGroundPositionZ(x, y, z); { UpdateGroundPositionZ(x, y, z); }
} }
void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update) void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
@ -2060,9 +2060,9 @@ void WorldObject::PlayDirectSound(uint32 sound_id, Player const* target /*= NULL
data << uint32(sound_id); data << uint32(sound_id);
data << ObjectGuid(); data << ObjectGuid();
if (target) if (target)
target->SendDirectMessage(&data); { target->SendDirectMessage(&data); }
else else
SendMessageToSet(&data, true); { SendMessageToSet(&data, true); }
} }
void WorldObject::PlayMusic(uint32 sound_id, Player const* target /*= NULL*/) const void WorldObject::PlayMusic(uint32 sound_id, Player const* target /*= NULL*/) const
@ -2166,9 +2166,9 @@ void WorldObject::SetActiveObjectState(bool active)
// player's update implemented in a different from other active worldobject's way // player's update implemented in a different from other active worldobject's way
// it's considired to use generic way in future // it's considired to use generic way in future
{ {
if (isActiveObject() && !active) if (IsActiveObject() && !active)
{ GetMap()->RemoveFromActive(this); } { GetMap()->RemoveFromActive(this); }
else if (!isActiveObject() && active) else if (!IsActiveObject() && active)
{ GetMap()->AddToActive(this); } { GetMap()->AddToActive(this); }
} }
m_isActiveObject = active; m_isActiveObject = active;

View file

@ -41,10 +41,10 @@
#define ATTACK_DISTANCE 5.0f #define ATTACK_DISTANCE 5.0f
#define INSPECT_DISTANCE 28.0f #define INSPECT_DISTANCE 28.0f
#define TRADE_DISTANCE 11.11f #define TRADE_DISTANCE 11.11f
#define MAX_VISIBILITY_DISTANCE 333.0f // max distance for visible object show, limited in 333 yards #define MAX_VISIBILITY_DISTANCE 333.0f // max distance for visible object show, limited in 333 yards
#define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents #define DEFAULT_VISIBILITY_DISTANCE 90.0f // default visible distance, 90 yards on continents
#define DEFAULT_VISIBILITY_INSTANCE 120.0f // default visible distance in instances, 120 yards #define DEFAULT_VISIBILITY_INSTANCE 120.0f // default visible distance in instances, 120 yards
#define DEFAULT_VISIBILITY_BGARENAS 180.0f // default visible distance in BG/Arenas, 180 yards #define DEFAULT_VISIBILITY_BGARENAS 180.0f // default visible distance in BG/Arenas, 180 yards
#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // currently used (correctly?) for any non Unit world objects. This is actually the bounding_radius, like player/creature from creature_model_data #define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // currently used (correctly?) for any non Unit world objects. This is actually the bounding_radius, like player/creature from creature_model_data
#define DEFAULT_OBJECT_SCALE 1.0f // player/item scale as default, npc/go from database, pets from dbc #define DEFAULT_OBJECT_SCALE 1.0f // player/item scale as default, npc/go from database, pets from dbc
@ -545,7 +545,7 @@ class WorldObject : public Object
bool IsPositionValid() const; bool IsPositionValid() const;
void UpdateGroundPositionZ(float x, float y, float& z) const; void UpdateGroundPositionZ(float x, float y, float& z) const;
void UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap = NULL) const; void UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap = NULL) const;
void GetRandomPoint(float x, float y, float z, float distance, float& rand_x, float& rand_y, float& rand_z, float minDist = 0.0f, float const* ori = NULL) const; void GetRandomPoint(float x, float y, float z, float distance, float& rand_x, float& rand_y, float& rand_z, float minDist = 0.0f, float const* ori = NULL) const;
@ -658,7 +658,7 @@ class WorldObject : public Object
Creature* SummonCreature(uint32 id, float x, float y, float z, float ang, TempSummonType spwtype, uint32 despwtime, bool asActiveObject = false, bool setRun = false); Creature* SummonCreature(uint32 id, float x, float y, float z, float ang, TempSummonType spwtype, uint32 despwtime, bool asActiveObject = false, bool setRun = false);
GameObject* SummonGameObject(uint32 id, float x, float y, float z, float angle, uint32 despwtime); GameObject* SummonGameObject(uint32 id, float x, float y, float z, float angle, uint32 despwtime);
bool isActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); } bool IsActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); }
void SetActiveObjectState(bool active); void SetActiveObjectState(bool active);
ViewPoint& GetViewPoint() { return m_viewPoint; } ViewPoint& GetViewPoint() { return m_viewPoint; }
@ -667,6 +667,7 @@ class WorldObject : public Object
bool PrintCoordinatesError(float x, float y, float z, char const* descr) const; bool PrintCoordinatesError(float x, float y, float z, char const* descr) const;
virtual void StartGroupLoot(Group* /*group*/, uint32 /*timer*/) { } virtual void StartGroupLoot(Group* /*group*/, uint32 /*timer*/) { }
#ifdef ENABLE_ELUNA #ifdef ENABLE_ELUNA
ElunaEventProcessor* elunaEvents; ElunaEventProcessor* elunaEvents;
#endif /* ENABLE_ELUNA */ #endif /* ENABLE_ELUNA */

View file

@ -59,13 +59,13 @@ Unit*
ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid guid) ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid guid)
{ {
if (!guid) if (!guid)
return NULL; { return NULL; }
if (guid.IsPlayer()) if (guid.IsPlayer())
return FindPlayer(guid); { return FindPlayer(guid); }
if (!u.IsInWorld()) if (!u.IsInWorld())
return NULL; { return NULL; }
return u.GetMap()->GetAnyTypeCreature(guid); return u.GetMap()->GetAnyTypeCreature(guid);
} }
@ -74,9 +74,9 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
{ {
Corpse* ret = HashMapHolder<Corpse>::Find(guid); Corpse* ret = HashMapHolder<Corpse>::Find(guid);
if (!ret) if (!ret)
return NULL; { return NULL; }
if (ret->GetMapId() != mapid) if (ret->GetMapId() != mapid)
return NULL; { return NULL; }
return ret; return ret;
} }
@ -84,11 +84,11 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/) Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/)
{ {
if (!guid) if (!guid)
return NULL; { return NULL; }
Player* plr = HashMapHolder<Player>::Find(guid); Player* plr = HashMapHolder<Player>::Find(guid);
if (!plr || (!plr->IsInWorld() && inWorld)) if (!plr || (!plr->IsInWorld() && inWorld))
return NULL; { return NULL; }
return plr; return plr;
} }
@ -99,8 +99,7 @@ Player* ObjectAccessor::FindPlayerByName(const char* name)
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers(); HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld() && (::strcmp(name, iter->second->GetName()) == 0)) if (iter->second->IsInWorld() && (::strcmp(name, iter->second->GetName()) == 0))
return iter->second; { return iter->second; }
return NULL; return NULL;
} }
@ -129,11 +128,11 @@ ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid guid)
Guard guard(i_corpseGuard); Guard guard(i_corpseGuard);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid); Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
if (iter == i_player2corpse.end()) if (iter == i_player2corpse.end())
return NULL; { return NULL; }
MANGOS_ASSERT(iter->second->GetType() != CORPSE_BONES); MANGOS_ASSERT(iter->second->GetType() != CORPSE_BONES);
return iter->second; return iter->second;
} }
@ -143,9 +142,10 @@ ObjectAccessor::RemoveCorpse(Corpse* corpse)
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES); MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
Guard guard(i_corpseGuard); Guard guard(i_corpseGuard);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid()); Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid());
if (iter == i_player2corpse.end()) if (iter == i_player2corpse.end())
return; { return; }
// build mapid*cellid -> guid_set map // build mapid*cellid -> guid_set map
CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY()); CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
@ -163,6 +163,7 @@ ObjectAccessor::AddCorpse(Corpse* corpse)
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES); MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
Guard guard(i_corpseGuard); Guard guard(i_corpseGuard);
MANGOS_ASSERT(i_player2corpse.find(corpse->GetOwnerGuid()) == i_player2corpse.end()); MANGOS_ASSERT(i_player2corpse.find(corpse->GetOwnerGuid()) == i_player2corpse.end());
i_player2corpse[corpse->GetOwnerGuid()] = corpse; i_player2corpse[corpse->GetOwnerGuid()] = corpse;
@ -177,22 +178,23 @@ void
ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map) ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map)
{ {
Guard guard(i_corpseGuard); Guard guard(i_corpseGuard);
for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
if (iter->second->GetGrid() == gridpair) if (iter->second->GetGrid() == gridpair)
{ {
// verify, if the corpse in our instance (add only corpses which are) // verify, if the corpse in our instance (add only corpses which are)
if (map->Instanceable()) if (map->Instanceable())
{ {
if (iter->second->GetInstanceId() == map->GetInstanceId()) if (iter->second->GetInstanceId() == map->GetInstanceId())
{ {
grid.AddWorldObject(iter->second); grid.AddWorldObject(iter->second);
} }
} }
else else
{ {
grid.AddWorldObject(iter->second); grid.AddWorldObject(iter->second);
} }
} }
} }
Corpse* Corpse*
@ -216,7 +218,7 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
// do not load the map if it's not loaded // do not load the map if it's not loaded
Map* map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId()); Map* map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId());
if (map) if (map)
map->Remove(corpse, false); { map->Remove(corpse, false); }
// remove corpse from DB // remove corpse from DB
corpse->DeleteFromDB(); corpse->DeleteFromDB();
@ -226,14 +228,14 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
// ignore bones creating option in case insignia // ignore bones creating option in case insignia
if (map && (insignia || if (map && (insignia ||
(map->IsBattleGroundOrArena() ? sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_BG_OR_ARENA) : sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_WORLD))) && (map->IsBattleGroundOrArena() ? sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_BG_OR_ARENA) : sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_WORLD))) &&
!map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY())) !map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
{ {
// Create bones, don't change Corpse // Create bones, don't change Corpse
bones = new Corpse; bones = new Corpse;
bones->Create(corpse->GetGUIDLow()); bones->Create(corpse->GetGUIDLow());
for (int i = 3; i < CORPSE_END; ++i) // don't overwrite guid and object type for (int i = 3; i < CORPSE_END; ++i) // don't overwrite guid and object type
bones->SetUInt32Value(i, corpse->GetUInt32Value(i)); { bones->SetUInt32Value(i, corpse->GetUInt32Value(i)); }
bones->SetGrid(corpse->GetGrid()); bones->SetGrid(corpse->GetGrid());
// bones->m_time = m_time; // don't overwrite time // bones->m_time = m_time; // don't overwrite time
@ -248,7 +250,7 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
for (int i = 0; i < EQUIPMENT_SLOT_END; ++i) for (int i = 0; i < EQUIPMENT_SLOT_END; ++i)
{ {
if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i)) if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); { bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); }
} }
// add bones in grid store if grid loaded where corpse placed // add bones in grid store if grid loaded where corpse placed
@ -271,7 +273,7 @@ void ObjectAccessor::RemoveOldCorpses()
++next; ++next;
if (!itr->second->IsExpired(now)) if (!itr->second->IsExpired(now))
continue; { continue; }
ConvertCorpseForPlayer(itr->first); ConvertCorpseForPlayer(itr->first);
} }

View file

@ -40,7 +40,7 @@ char const* ObjectGuid::GetTypeName(HighGuid high)
case HIGHGUID_UNIT: return "Creature"; case HIGHGUID_UNIT: return "Creature";
case HIGHGUID_PET: return "Pet"; case HIGHGUID_PET: return "Pet";
case HIGHGUID_VEHICLE: return "Vehicle"; case HIGHGUID_VEHICLE: return "Vehicle";
case HIGHGUID_DYNAMICOBJECT:return "DynObject"; case HIGHGUID_DYNAMICOBJECT: return "DynObject";
case HIGHGUID_CORPSE: return "Corpse"; case HIGHGUID_CORPSE: return "Corpse";
case HIGHGUID_MO_TRANSPORT: return "MoTransport"; case HIGHGUID_MO_TRANSPORT: return "MoTransport";
case HIGHGUID_INSTANCE: return "InstanceID"; case HIGHGUID_INSTANCE: return "InstanceID";
@ -60,12 +60,12 @@ std::string ObjectGuid::GetString() const
{ {
std::string name; std::string name;
if (sObjectMgr.GetPlayerNameByGUID(*this, name)) if (sObjectMgr.GetPlayerNameByGUID(*this, name))
str << " " << name; { str << " " << name; }
} }
str << " ("; str << " (";
if (HasEntry()) if (HasEntry())
str << (IsPet() ? "Petnumber: " : "Entry: ") << GetEntry() << " "; { str << (IsPet() ? "Petnumber: " : "Entry: ") << GetEntry() << " "; }
str << "Guid: " << GetCounter() << ")"; str << "Guid: " << GetCounter() << ")";
return str.str(); return str.str();
} }

View file

@ -95,7 +95,7 @@ struct PackedGuidReader
#define NUM_GUID_BYTES sizeof(uint64) #define NUM_GUID_BYTES sizeof(uint64)
class ObjectGuid class ObjectGuid
{ {
public: // constructors public: // constructors
ObjectGuid() : m_guid(0) {} ObjectGuid() : m_guid(0) {}
@ -171,7 +171,7 @@ class ObjectGuid
case HIGHGUID_PET: return TYPEID_UNIT; case HIGHGUID_PET: return TYPEID_UNIT;
case HIGHGUID_PLAYER: return TYPEID_PLAYER; case HIGHGUID_PLAYER: return TYPEID_PLAYER;
case HIGHGUID_GAMEOBJECT: return TYPEID_GAMEOBJECT; case HIGHGUID_GAMEOBJECT: return TYPEID_GAMEOBJECT;
case HIGHGUID_DYNAMICOBJECT:return TYPEID_DYNAMICOBJECT; case HIGHGUID_DYNAMICOBJECT: return TYPEID_DYNAMICOBJECT;
case HIGHGUID_CORPSE: return TYPEID_CORPSE; case HIGHGUID_CORPSE: return TYPEID_CORPSE;
case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT; case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT;
case HIGHGUID_VEHICLE: return TYPEID_UNIT; case HIGHGUID_VEHICLE: return TYPEID_UNIT;

File diff suppressed because it is too large Load diff

View file

@ -216,8 +216,10 @@ typedef std::pair<QuestRelationsMap::const_iterator, QuestRelationsMap::const_it
struct PetLevelInfo struct PetLevelInfo
{ {
PetLevelInfo() : health(0), mana(0), armor(0) PetLevelInfo() : health(0), mana(0)
{ for (int i = 0; i < MAX_STATS; ++i) stats[i] = 0; } {
for (int i = 0; i < MAX_STATS; ++i) stats[i] = 0;
}
uint16 stats[MAX_STATS]; uint16 stats[MAX_STATS];
uint16 health; uint16 health;
@ -476,7 +478,10 @@ class PlayerCondition
: m_entry(_entry), m_condition(ConditionType(_condition)), m_value1(_value1), m_value2(_value2) {} : m_entry(_entry), m_condition(ConditionType(_condition)), m_value1(_value1), m_value2(_value2) {}
// Checks correctness of values // Checks correctness of values
bool IsValid() const { return IsValid(m_entry, m_condition, m_value1, m_value2); } bool IsValid() const
{
return IsValid(m_entry, m_condition, m_value1, m_value2);
}
static bool IsValid(uint16 entry, ConditionType condition, uint32 value1, uint32 value2); static bool IsValid(uint16 entry, ConditionType condition, uint32 value1, uint32 value2);
static bool CanBeUsedWithoutPlayer(uint16 entry); static bool CanBeUsedWithoutPlayer(uint16 entry);
@ -546,11 +551,17 @@ class IdGenerator
explicit IdGenerator(char const* _name) : m_name(_name), m_nextGuid(1) {} explicit IdGenerator(char const* _name) : m_name(_name), m_nextGuid(1) {}
public: // modifiers public: // modifiers
void Set(T val) { m_nextGuid = val; } void Set(T val)
{
m_nextGuid = val;
}
T Generate(); T Generate();
public: // accessors public: // accessors
T GetNextAfterMaxUsed() const { return m_nextGuid; } T GetNextAfterMaxUsed() const
{
return m_nextGuid;
}
private: // fields private: // fields
char const* m_name; char const* m_name;
@ -606,10 +617,10 @@ class ObjectMgr
PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const
{ {
if (race >= MAX_RACES) return NULL; if (race >= MAX_RACES) { return NULL; }
if (class_ >= MAX_CLASSES) return NULL; if (class_ >= MAX_CLASSES) { return NULL; }
PlayerInfo const* info = &playerInfo[race][class_]; PlayerInfo const* info = &playerInfo[race][class_];
if (info->displayId_m == 0 || info->displayId_f == 0) return NULL; if (info->displayId_m == 0 || info->displayId_f == 0) { return NULL; }
return info; return info;
} }
void GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const; void GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const;
@ -629,13 +640,16 @@ class ObjectMgr
QuestMap::const_iterator itr = mQuestTemplates.find(quest_id); QuestMap::const_iterator itr = mQuestTemplates.find(quest_id);
return itr != mQuestTemplates.end() ? itr->second : NULL; return itr != mQuestTemplates.end() ? itr->second : NULL;
} }
QuestMap const& GetQuestTemplates() const { return mQuestTemplates; } QuestMap const& GetQuestTemplates() const
{
return mQuestTemplates;
}
uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
{ {
QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID); QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID);
if (itr != mQuestAreaTriggerMap.end()) if (itr != mQuestAreaTriggerMap.end())
return itr->second; { return itr->second; }
return 0; return 0;
} }
bool IsTavernAreaTrigger(uint32 Trigger_ID) const bool IsTavernAreaTrigger(uint32 Trigger_ID) const
@ -660,7 +674,7 @@ class ObjectMgr
{ {
AreaTriggerMap::const_iterator itr = mAreaTriggers.find(trigger); AreaTriggerMap::const_iterator itr = mAreaTriggers.find(trigger);
if (itr != mAreaTriggers.end()) if (itr != mAreaTriggers.end())
return &itr->second; { return &itr->second; }
return NULL; return NULL;
} }
@ -671,7 +685,7 @@ class ObjectMgr
{ {
RepRewardRateMap::const_iterator itr = m_RepRewardRateMap.find(factionId); RepRewardRateMap::const_iterator itr = m_RepRewardRateMap.find(factionId);
if (itr != m_RepRewardRateMap.end()) if (itr != m_RepRewardRateMap.end())
return &itr->second; { return &itr->second; }
return NULL; return NULL;
} }
@ -680,7 +694,7 @@ class ObjectMgr
{ {
RepOnKillMap::const_iterator itr = mRepOnKill.find(id); RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
if (itr != mRepOnKill.end()) if (itr != mRepOnKill.end())
return &itr->second; { return &itr->second; }
return NULL; return NULL;
} }
@ -688,7 +702,7 @@ class ObjectMgr
{ {
RepSpilloverTemplateMap::const_iterator itr = m_RepSpilloverTemplateMap.find(factionId); RepSpilloverTemplateMap::const_iterator itr = m_RepSpilloverTemplateMap.find(factionId);
if (itr != m_RepSpilloverTemplateMap.end()) if (itr != m_RepSpilloverTemplateMap.end())
return &itr->second; { return &itr->second; }
return NULL; return NULL;
} }
@ -697,7 +711,7 @@ class ObjectMgr
{ {
PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id); PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id);
if (itr != mPointsOfInterest.end()) if (itr != mPointsOfInterest.end())
return &itr->second; { return &itr->second; }
return NULL; return NULL;
} }
@ -721,9 +735,7 @@ class ObjectMgr
{ {
DungeonFinderRewardsMap::const_iterator itr = mDungeonFinderRewardsMap.find(level); DungeonFinderRewardsMap::const_iterator itr = mDungeonFinderRewardsMap.find(level);
if (itr != mDungeonFinderRewardsMap.end()) if (itr != mDungeonFinderRewardsMap.end())
{ { return &itr->second; }
return &itr->second;
}
return NULL; return NULL;
} }
@ -761,7 +773,10 @@ class ObjectMgr
void LoadCreatureInvolvedRelations(); void LoadCreatureInvolvedRelations();
bool LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value, bool extra_content); bool LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value, bool extra_content);
bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase, "mangos_string", MIN_MANGOS_STRING_ID, MAX_MANGOS_STRING_ID, false); } bool LoadMangosStrings()
{
return LoadMangosStrings(WorldDatabase, "mangos_string", MIN_MANGOS_STRING_ID, MAX_MANGOS_STRING_ID, false);
}
void LoadCreatureLocales(); void LoadCreatureLocales();
void LoadCreatureTemplates(); void LoadCreatureTemplates();
void LoadCreatures(); void LoadCreatures();
@ -826,10 +841,15 @@ class ObjectMgr
void LoadGossipMenus(); void LoadGossipMenus();
void LoadVendorTemplates(); void LoadVendorTemplates();
void LoadVendors() { LoadVendors("npc_vendor", false); } void LoadVendors()
{
LoadVendors("npc_vendor", false);
}
void LoadTrainerTemplates(); void LoadTrainerTemplates();
void LoadTrainers() { LoadTrainers("npc_trainer", false); } void LoadTrainers()
{
LoadTrainers("npc_trainer", false);
}
/// @param _map Map* of the map for which to load active entities. If NULL active entities on continents are loaded /// @param _map Map* of the map for which to load active entities. If NULL active entities on continents are loaded
void LoadActiveEntities(Map* _map); void LoadActiveEntities(Map* _map);
@ -851,26 +871,63 @@ class ObjectMgr
void SetHighestGuids(); void SetHighestGuids();
// used for set initial guid counter for map local guids // used for set initial guid counter for map local guids
uint32 GetFirstTemporaryCreatureLowGuid() const { return m_FirstTemporaryCreatureGuid; } uint32 GetFirstTemporaryCreatureLowGuid() const
uint32 GetFirstTemporaryGameObjectLowGuid() const { return m_FirstTemporaryGameObjectGuid; } {
return m_FirstTemporaryCreatureGuid;
}
uint32 GetFirstTemporaryGameObjectLowGuid() const
{
return m_FirstTemporaryGameObjectGuid;
}
// used in .npc add/.gobject add commands for adding static spawns // used in .npc add/.gobject add commands for adding static spawns
uint32 GenerateStaticCreatureLowGuid() { if (m_StaticCreatureGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryCreatureGuid) return 0; return m_StaticCreatureGuids.Generate(); } uint32 GenerateStaticCreatureLowGuid()
uint32 GenerateStaticGameObjectLowGuid() { if (m_StaticGameObjectGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryGameObjectGuid) return 0; return m_StaticGameObjectGuids.Generate(); } {
if (m_StaticCreatureGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryCreatureGuid)
{ return 0; }
return m_StaticCreatureGuids.Generate();
}
uint32 GenerateStaticGameObjectLowGuid()
{
if (m_StaticGameObjectGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryGameObjectGuid)
{ return 0; }
return m_StaticGameObjectGuids.Generate();
}
uint32 GeneratePlayerLowGuid() { return m_CharGuids.Generate(); } uint32 GeneratePlayerLowGuid()
uint32 GenerateItemLowGuid() { return m_ItemGuids.Generate(); } {
uint32 GenerateCorpseLowGuid() { return m_CorpseGuids.Generate(); } return m_CharGuids.Generate();
}
uint32 GenerateItemLowGuid()
{
return m_ItemGuids.Generate();
}
uint32 GenerateCorpseLowGuid()
{
return m_CorpseGuids.Generate();
}
uint32 GenerateInstanceLowGuid() { return m_InstanceGuids.Generate(); } uint32 GenerateInstanceLowGuid() { return m_InstanceGuids.Generate(); }
uint32 GenerateGroupLowGuid() { return m_GroupGuids.Generate(); } uint32 GenerateGroupLowGuid() { return m_GroupGuids.Generate(); }
uint32 GenerateArenaTeamId() { return m_ArenaTeamIds.Generate(); } uint32 GenerateArenaTeamId() { return m_ArenaTeamIds.Generate(); }
uint32 GenerateAuctionID() { return m_AuctionIds.Generate(); } uint32 GenerateAuctionID()
{
return m_AuctionIds.Generate();
}
uint64 GenerateEquipmentSetGuid() { return m_EquipmentSetIds.Generate(); } uint64 GenerateEquipmentSetGuid() { return m_EquipmentSetIds.Generate(); }
uint32 GenerateGuildId() { return m_GuildIds.Generate(); } uint32 GenerateGuildId()
{
return m_GuildIds.Generate();
}
// uint32 GenerateItemTextID() { return m_ItemGuids.Generate(); } // uint32 GenerateItemTextID() { return m_ItemGuids.Generate(); }
uint32 GenerateMailID() { return m_MailIds.Generate(); } uint32 GenerateMailID()
uint32 GeneratePetNumber() { return m_PetNumbers.Generate(); } {
return m_MailIds.Generate();
}
uint32 GeneratePetNumber()
{
return m_PetNumbers.Generate();
}
MailLevelReward const* GetMailLevelReward(uint32 level, uint32 raceMask) MailLevelReward const* GetMailLevelReward(uint32 level, uint32 raceMask)
{ {
@ -888,7 +945,7 @@ class ObjectMgr
CreatureDataPair const* GetCreatureDataPair(uint32 guid) const CreatureDataPair const* GetCreatureDataPair(uint32 guid) const
{ {
CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid); CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid);
if (itr == mCreatureDataMap.end()) return NULL; if (itr == mCreatureDataMap.end()) { return NULL; }
return &*itr; return &*itr;
} }
@ -898,7 +955,10 @@ class ObjectMgr
return dataPair ? &dataPair->second : NULL; return dataPair ? &dataPair->second : NULL;
} }
CreatureData& NewOrExistCreatureData(uint32 guid) { return mCreatureDataMap[guid]; } CreatureData& NewOrExistCreatureData(uint32 guid)
{
return mCreatureDataMap[guid];
}
void DeleteCreatureData(uint32 guid); void DeleteCreatureData(uint32 guid);
template<typename Worker> template<typename Worker>
@ -906,13 +966,13 @@ class ObjectMgr
{ {
for (CreatureDataMap::const_iterator itr = mCreatureDataMap.begin(); itr != mCreatureDataMap.end(); ++itr) for (CreatureDataMap::const_iterator itr = mCreatureDataMap.begin(); itr != mCreatureDataMap.end(); ++itr)
if (worker(*itr)) if (worker(*itr))
break; { break; }
} }
CreatureLocale const* GetCreatureLocale(uint32 entry) const CreatureLocale const* GetCreatureLocale(uint32 entry) const
{ {
CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry); CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry);
if (itr == mCreatureLocaleMap.end()) return NULL; if (itr == mCreatureLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
@ -921,14 +981,14 @@ class ObjectMgr
GameObjectLocale const* GetGameObjectLocale(uint32 entry) const GameObjectLocale const* GetGameObjectLocale(uint32 entry) const
{ {
GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry); GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry);
if (itr == mGameObjectLocaleMap.end()) return NULL; if (itr == mGameObjectLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
ItemLocale const* GetItemLocale(uint32 entry) const ItemLocale const* GetItemLocale(uint32 entry) const
{ {
ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry); ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry);
if (itr == mItemLocaleMap.end()) return NULL; if (itr == mItemLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
@ -937,7 +997,7 @@ class ObjectMgr
QuestLocale const* GetQuestLocale(uint32 entry) const QuestLocale const* GetQuestLocale(uint32 entry) const
{ {
QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry); QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry);
if (itr == mQuestLocaleMap.end()) return NULL; if (itr == mQuestLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
@ -946,39 +1006,39 @@ class ObjectMgr
NpcTextLocale const* GetNpcTextLocale(uint32 entry) const NpcTextLocale const* GetNpcTextLocale(uint32 entry) const
{ {
NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry); NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry);
if (itr == mNpcTextLocaleMap.end()) return NULL; if (itr == mNpcTextLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
typedef std::string NpcTextArray[MAX_GOSSIP_TEXT_OPTIONS]; typedef std::string NpcTextArray[MAX_GOSSIP_TEXT_OPTIONS];
void GetNpcTextLocaleStringsAll(uint32 entry, int32 loc_idx, NpcTextArray* text0_Ptr, NpcTextArray* text1_Ptr) const; void GetNpcTextLocaleStringsAll(uint32 entry, int32 loc_idx, NpcTextArray *text0_Ptr, NpcTextArray* text1_Ptr) const;
void GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::string* text0_0_Ptr, std::string* text1_0_Ptr) const; void GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::string* text0_0_Ptr, std::string* text1_0_Ptr) const;
PageTextLocale const* GetPageTextLocale(uint32 entry) const PageTextLocale const* GetPageTextLocale(uint32 entry) const
{ {
PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry); PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry);
if (itr == mPageTextLocaleMap.end()) return NULL; if (itr == mPageTextLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const
{ {
GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry); GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry);
if (itr == mGossipMenuItemsLocaleMap.end()) return NULL; if (itr == mGossipMenuItemsLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const
{ {
PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id); PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id);
if (itr == mPointOfInterestLocaleMap.end()) return NULL; if (itr == mPointOfInterestLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
GameObjectDataPair const* GetGODataPair(uint32 guid) const GameObjectDataPair const* GetGODataPair(uint32 guid) const
{ {
GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid); GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid);
if (itr == mGameObjectDataMap.end()) return NULL; if (itr == mGameObjectDataMap.end()) { return NULL; }
return &*itr; return &*itr;
} }
@ -988,7 +1048,10 @@ class ObjectMgr
return dataPair ? &dataPair->second : NULL; return dataPair ? &dataPair->second : NULL;
} }
GameObjectData& NewGOData(uint32 guid) { return mGameObjectDataMap[guid]; } GameObjectData& NewGOData(uint32 guid)
{
return mGameObjectDataMap[guid];
}
void DeleteGOData(uint32 guid); void DeleteGOData(uint32 guid);
template<typename Worker> template<typename Worker>
@ -996,21 +1059,20 @@ class ObjectMgr
{ {
for (GameObjectDataMap::const_iterator itr = mGameObjectDataMap.begin(); itr != mGameObjectDataMap.end(); ++itr) for (GameObjectDataMap::const_iterator itr = mGameObjectDataMap.begin(); itr != mGameObjectDataMap.end(); ++itr)
if (worker(*itr)) // arg = GameObjectDataPair if (worker(*itr)) // arg = GameObjectDataPair
break; { break; }
} }
MangosStringLocale const* GetMangosStringLocale(int32 entry) const MangosStringLocale const* GetMangosStringLocale(int32 entry) const
{ {
MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry); MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry);
if (itr == mMangosStringLocaleMap.end()) return NULL; if (itr == mMangosStringLocaleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
uint32 GetLoadedStringsCount(int32 minEntry) const uint32 GetLoadedStringsCount(int32 minEntry) const
{ {
std::map<int32, uint32>::const_iterator itr = m_loadedStringCount.find(minEntry); std::map<int32, uint32>::const_iterator itr = m_loadedStringCount.find(minEntry);
if (itr != m_loadedStringCount.end()) if (itr != m_loadedStringCount.end())
return itr->second; { return itr->second; }
return 0; return 0;
} }
@ -1056,12 +1118,15 @@ class ObjectMgr
GameTele const* GetGameTele(uint32 id) const GameTele const* GetGameTele(uint32 id) const
{ {
GameTeleMap::const_iterator itr = m_GameTeleMap.find(id); GameTeleMap::const_iterator itr = m_GameTeleMap.find(id);
if (itr == m_GameTeleMap.end()) return NULL; if (itr == m_GameTeleMap.end()) { return NULL; }
return &itr->second; return &itr->second;
} }
GameTele const* GetGameTele(const std::string& name) const; GameTele const* GetGameTele(const std::string& name) const;
GameTeleMap const& GetGameTeleMap() const { return m_GameTeleMap; } GameTeleMap const& GetGameTeleMap() const
{
return m_GameTeleMap;
}
bool AddGameTele(GameTele& data); bool AddGameTele(GameTele& data);
bool DeleteGameTele(const std::string& name); bool DeleteGameTele(const std::string& name);
@ -1069,7 +1134,7 @@ class ObjectMgr
{ {
CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry); CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry);
if (iter == m_mCacheNpcTextIdMap.end()) if (iter == m_mCacheNpcTextIdMap.end())
return 0; { return 0; }
return iter->second; return iter->second;
} }
@ -1078,7 +1143,7 @@ class ObjectMgr
{ {
CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry); CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry);
if (iter == m_mCacheTrainerSpellMap.end()) if (iter == m_mCacheTrainerSpellMap.end())
return NULL; { return NULL; }
return &iter->second; return &iter->second;
} }
@ -1087,7 +1152,7 @@ class ObjectMgr
{ {
CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerTemplateSpellMap.find(entry); CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerTemplateSpellMap.find(entry);
if (iter == m_mCacheTrainerTemplateSpellMap.end()) if (iter == m_mCacheTrainerTemplateSpellMap.end())
return NULL; { return NULL; }
return &iter->second; return &iter->second;
} }
@ -1096,7 +1161,7 @@ class ObjectMgr
{ {
CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry); CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry);
if (iter == m_mCacheVendorItemMap.end()) if (iter == m_mCacheVendorItemMap.end())
return NULL; { return NULL; }
return &iter->second; return &iter->second;
} }
@ -1105,7 +1170,7 @@ class ObjectMgr
{ {
CacheVendorItemMap::const_iterator iter = m_mCacheVendorTemplateItemMap.find(entry); CacheVendorItemMap::const_iterator iter = m_mCacheVendorTemplateItemMap.find(entry);
if (iter == m_mCacheVendorTemplateItemMap.end()) if (iter == m_mCacheVendorTemplateItemMap.end())
return NULL; { return NULL; }
return &iter->second; return &iter->second;
} }
@ -1190,14 +1255,16 @@ class ObjectMgr
return m_GOQuestInvolvedRelations.equal_range(entry); return m_GOQuestInvolvedRelations.equal_range(entry);
} }
QuestRelationsMap& GetCreatureQuestRelationsMap() { return m_CreatureQuestRelations; } QuestRelationsMap& GetCreatureQuestRelationsMap()
{
return m_CreatureQuestRelations;
}
uint32 GetModelForRace(uint32 sourceModelId, uint32 racemask); uint32 GetModelForRace(uint32 sourceModelId, uint32 racemask);
/** /**
* \brief: Data returned is used to compute health, mana, armor, damage of creatures. May be NULL. * \brief: Data returned is used to compute health, mana, armor, damage of creatures. May be NULL.
* \param uint32 level creature level * \param uint32 level creature level
* \param uint32 unitClass creature class, related to CLASSMASK_ALL_CREATURES * \param uint32 unitClass creature class, related to CLASSMASK_ALL_CREATURES
* \param uint32 expansion creature expansion (we could have creature exp = 0 for wotlk as well as exp = 1 or exp = 2) * \param uint32 expansion creature expansion (we could have creature exp = 0 for vanilla, exp = 1 for tbc, exp = 2 for wotlk)
* \return: CreatureClassLvlStats const* or NULL * \return: CreatureClassLvlStats const* or NULL
* *
* Description: GetCreatureClassLvlStats give fast access to creature stats data. * Description: GetCreatureClassLvlStats give fast access to creature stats data.
@ -1358,7 +1425,7 @@ class ObjectMgr
NpcTextLocaleMap mNpcTextLocaleMap; NpcTextLocaleMap mNpcTextLocaleMap;
PageTextLocaleMap mPageTextLocaleMap; PageTextLocaleMap mPageTextLocaleMap;
MangosStringLocaleMap mMangosStringLocaleMap; MangosStringLocaleMap mMangosStringLocaleMap;
std::map<int32 /*minEntryOfBracket*/, uint32 /*count*/> m_loadedStringCount; std::map < int32 /*minEntryOfBracket*/, uint32 /*count*/ > m_loadedStringCount;
GossipMenuItemsLocaleMap mGossipMenuItemsLocaleMap; GossipMenuItemsLocaleMap mGossipMenuItemsLocaleMap;
PointOfInterestLocaleMap mPointOfInterestLocaleMap; PointOfInterestLocaleMap mPointOfInterestLocaleMap;
DungeonEncounterMap m_DungeonEncounters; DungeonEncounterMap m_DungeonEncounters;

View file

@ -358,7 +358,7 @@ Map::Add(T* obj)
obj->SetMap(this); obj->SetMap(this);
Cell cell(p); Cell cell(p);
if (obj->isActiveObject()) if (obj->IsActiveObject())
{ EnsureGridLoadedAtEnter(cell); } { EnsureGridLoadedAtEnter(cell); }
else else
{ EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); } { EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); }
@ -369,7 +369,7 @@ Map::Add(T* obj)
AddToGrid(obj, grid, cell); AddToGrid(obj, grid, cell);
obj->AddToWorld(); obj->AddToWorld();
if (obj->isActiveObject()) if (obj->IsActiveObject())
{ AddToActive(obj); } { AddToActive(obj); }
DEBUG_LOG("%s enters grid[%u,%u]", obj->GetGuidStr().c_str(), cell.GridX(), cell.GridY()); DEBUG_LOG("%s enters grid[%u,%u]", obj->GetGuidStr().c_str(), cell.GridX(), cell.GridY());
@ -685,7 +685,7 @@ Map::Remove(T* obj, bool remove)
NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
MANGOS_ASSERT(grid != NULL); MANGOS_ASSERT(grid != NULL);
if (obj->isActiveObject()) if (obj->IsActiveObject())
{ RemoveFromActive(obj); } { RemoveFromActive(obj); }
if (remove) if (remove)
@ -776,7 +776,7 @@ bool Map::CreatureCellRelocation(Creature* c, const Cell& new_cell)
Cell const& old_cell = c->GetCurrentCell(); Cell const& old_cell = c->GetCurrentCell();
if (old_cell.DiffGrid(new_cell)) if (old_cell.DiffGrid(new_cell))
{ {
if (!c->isActiveObject() && !loaded(new_cell.gridPair())) if (!c->IsActiveObject() && !loaded(new_cell.gridPair()))
{ {
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
return false; return false;

View file

@ -134,7 +134,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair& cell, GridRefManager<T>&
addUnitState(obj, cell); addUnitState(obj, cell);
obj->SetMap(map); obj->SetMap(map);
obj->AddToWorld(); obj->AddToWorld();
if (obj->isActiveObject()) if (obj->IsActiveObject())
map->AddToActive(obj); map->AddToActive(obj);
obj->GetViewPoint().Event_AddedToWorld(&grid); obj->GetViewPoint().Event_AddedToWorld(&grid);
@ -167,7 +167,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair& cell, CorpseMapType
addUnitState(obj, cell); addUnitState(obj, cell);
obj->SetMap(map); obj->SetMap(map);
obj->AddToWorld(); obj->AddToWorld();
if (obj->isActiveObject()) if (obj->IsActiveObject())
map->AddToActive(obj); map->AddToActive(obj);
++count; ++count;

View file

@ -178,7 +178,7 @@ namespace Movement
time_passed = 0; time_passed = 0;
vertical_acceleration = 0.f; vertical_acceleration = 0.f;
effect_start_time = 0; effect_start_time = 0;
// detect Stop command // detect Stop command
if (splineflags.done) if (splineflags.done)
{ {

View file

@ -68,10 +68,10 @@ namespace Movement
if (transportInfo) if (transportInfo)
transportInfo->GetLocalPosition(real_position.x, real_position.y, real_position.z, real_position.orientation); transportInfo->GetLocalPosition(real_position.x, real_position.y, real_position.z, real_position.orientation);
// there is a big chane that current position is unknown if current state is not finalized, need compute it // there is a big chance that current position is unknown if current state is not finalized, need compute it
// this also allows calculate spline position and update map position in much greater intervals // this also allows calculate spline position and update map position in much greater intervals
if (!move_spline.Finalized() && !transportInfo) if (!move_spline.Finalized() && !transportInfo)
real_position = move_spline.ComputePosition(); { real_position = move_spline.ComputePosition(); }
if (args.path.empty()) if (args.path.empty())
{ {
@ -92,10 +92,10 @@ namespace Movement
moveFlags |= MOVEFLAG_FORWARD; moveFlags |= MOVEFLAG_FORWARD;
if (args.velocity == 0.f) if (args.velocity == 0.f)
args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags)); { args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags)); }
if (!args.Validate(&unit)) if (!args.Validate(&unit))
return 0; { return 0; }
unit.m_movementInfo.SetMovementFlags((MovementFlags)moveFlags); unit.m_movementInfo.SetMovementFlags((MovementFlags)moveFlags);
move_spline.Initialize(args); move_spline.Initialize(args);
@ -132,7 +132,7 @@ namespace Movement
if (transportInfo) if (transportInfo)
transportInfo->GetLocalPosition(real_position.x, real_position.y, real_position.z, real_position.orientation); transportInfo->GetLocalPosition(real_position.x, real_position.y, real_position.z, real_position.orientation);
// there is a big chane that current position is unknown if current state is not finalized, need compute it // there is a big chance that current position is unknown if current state is not finalized, need compute it
// this also allows calculate spline position and update map position in much greater intervals // this also allows calculate spline position and update map position in much greater intervals
if (!move_spline.Finalized() && !transportInfo) if (!move_spline.Finalized() && !transportInfo)
real_position = move_spline.ComputePosition(); real_position = move_spline.ComputePosition();
@ -143,7 +143,7 @@ namespace Movement
MoveTo(real_position); MoveTo(real_position);
} }
// corrent first vertex // current first vertex
args.path[0] = real_position; args.path[0] = real_position;
args.flags = MoveSplineFlag::Done; args.flags = MoveSplineFlag::Done;

View file

@ -43,7 +43,7 @@ namespace Movement
* @brief Initializes and launches spline movement * @brief Initializes and launches spline movement
* *
*/ */
class MANGOS_DLL_SPEC MoveSplineInit class MoveSplineInit
{ {
public: public:
@ -60,8 +60,11 @@ namespace Movement
* @return int32 duration - estimated travel time * @return int32 duration - estimated travel time
*/ */
int32 Launch(); int32 Launch();
/* Stop any creature movement */ /**
* @brief Stop any creature movement
*
*/
void Stop(); void Stop();
/* Adds movement by parabolic trajectory /* Adds movement by parabolic trajectory
@ -75,7 +78,7 @@ namespace Movement
*/ */
void SetAnimation(AnimType anim); void SetAnimation(AnimType anim);
/** /*
* @brief Adds final facing animation * @brief Adds final facing animation
* sets unit's facing to specified point/angle after all path done. * sets unit's facing to specified point/angle after all path done.
* you can have only one final facing: previous will be overriden * you can have only one final facing: previous will be overriden
@ -170,7 +173,9 @@ namespace Movement
/* Sets ExitVehicle flag /* Sets ExitVehicle flag
*/ */
void SetExitVehicle(); void SetExitVehicle();
PointsArray& Path() { return args.path; } PointsArray& Path() { return args.path; }
protected: protected:
MoveSplineInitArgs args; /**< TODO */ MoveSplineInitArgs args; /**< TODO */

View file

@ -80,6 +80,11 @@ namespace Movement
*/ */
struct MoveSplineInitArgs struct MoveSplineInitArgs
{ {
/**
* @brief
*
* @param path_capacity
*/
MoveSplineInitArgs(size_t path_capacity = 16) : path_Idx_offset(0), MoveSplineInitArgs(size_t path_capacity = 16) : path_Idx_offset(0),
velocity(0.f), parabolic_amplitude(0.f), time_perc(0.f), splineId(0), initialOrientation(0.f) velocity(0.f), parabolic_amplitude(0.f), time_perc(0.f), splineId(0), initialOrientation(0.f)
{ {

View file

@ -59,7 +59,7 @@ namespace LuaGameObject
*/ */
int IsActive(lua_State* L, GameObject* go) int IsActive(lua_State* L, GameObject* go)
{ {
Eluna::Push(L, go->isActiveObject()); Eluna::Push(L, go->IsActiveObject());
return 1; return 1;
} }