aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.cpp26
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.h3
-rw-r--r--src/server/game/Maps/Map.cpp6
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp53
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp46
5 files changed, 78 insertions, 56 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 0f23925cc2b..4c6a8b92e0b 100644
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -2039,3 +2039,29 @@ void LFGMgr::SetupGroupMember(uint64 guid, uint64 gguid)
SetGroup(guid, gguid);
AddPlayerToGroup(gguid, guid);
}
+
+bool LFGMgr::inRandomLfgDungeon(uint64 guid)
+{
+ if (GetState(guid) != LFG_STATE_NONE)
+ {
+ LfgDungeonSet const& dungeons = GetSelectedDungeons(guid);
+ if (!dungeons.empty())
+ {
+ LFGDungeonData const* dungeon = GetLFGDungeon(*dungeons.begin());
+ if (dungeon && (dungeon->type == LFG_TYPE_RANDOM || dungeon->seasonal))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool LFGMgr::inLfgDungeonMap(uint64 guid, uint32 map, Difficulty difficulty)
+{
+ if (uint32 dungeonId = GetDungeon(guid, true))
+ if (LFGDungeonData const* dungeon = GetLFGDungeon(dungeonId))
+ if (uint32(dungeon->map) == map && dungeon->difficulty == difficulty)
+ return true;
+
+ return false;
+}
diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h
index 74c7ca9e3d3..5b26cf9854c 100644
--- a/src/server/game/DungeonFinding/LFGMgr.h
+++ b/src/server/game/DungeonFinding/LFGMgr.h
@@ -381,6 +381,9 @@ class LFGMgr
void SetupGroupMember(uint64 guid, uint64 gguid);
uint64 GetGroup(uint64 guid);
+ bool inRandomLfgDungeon(uint64 guid);
+ bool inLfgDungeonMap(uint64 guid, uint32 map, Difficulty difficulty);
+
private:
uint8 GetTeam(uint64 guid);
void RestoreState(uint64 guid, char const* debugMsg);
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 184450ef8d6..6358acfb97d 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -2486,11 +2486,7 @@ bool InstanceMap::AddPlayerToMap(Player* player)
}
if (group && group->isLFGGroup())
- if (uint32 dungeonId = sLFGMgr->GetDungeon(group->GetGUID(), true))
- if (LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(dungeonId))
- if (LFGDungeonData const* randomDungeon = sLFGMgr->GetLFGDungeon(*(sLFGMgr->GetSelectedDungeons(player->GetGUID()).begin())))
- if (uint32(dungeon->map) == GetId() && dungeon->difficulty == GetDifficulty() && randomDungeon->type == LFG_TYPE_RANDOM)
- player->CastSpell(player, LFG_SPELL_LUCK_OF_THE_DRAW, true);
+ player->CastSpell(player, LFG_SPELL_LUCK_OF_THE_DRAW, true);
}
// for normal instances cancel the reset schedule when the
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index ce9d5088317..08140772db9 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -33,7 +33,7 @@
#include "ace/INET_Addr.h"
#include "Player.h"
#include "Pet.h"
-#include "LFG.h"
+#include "LFGMgr.h"
#include "GroupMgr.h"
class misc_commandscript : public CommandScript
@@ -2834,41 +2834,40 @@ public:
{
handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"));
Group::MemberSlotList const& members = groupTarget->GetMemberSlots();
- Group::MemberSlotList::const_iterator itr;
- for (itr = members.begin(); itr != members.end(); ++itr)
+ for (Group::MemberSlotList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
{
- std::ostringstream flags, roles;
- if ((*itr).flags & MEMBER_FLAG_ASSISTANT)
- flags << "Assistant ";
- if ((*itr).flags & MEMBER_FLAG_MAINTANK)
- flags << "MainTank ";
- if ((*itr).flags & MEMBER_FLAG_MAINASSIST)
- flags << "MainAssist ";
-
- if ((*itr).roles & PLAYER_ROLE_LEADER)
- roles << "Leader ";
- if ((*itr).roles & PLAYER_ROLE_TANK)
- roles << "Tank ";
- if ((*itr).roles & PLAYER_ROLE_HEALER)
- roles << "Healer ";
- if ((*itr).roles & PLAYER_ROLE_DAMAGE)
- roles << "Damage ";
+ Group::MemberSlot const& slot = *itr;
+
+ std::string flags;
+ if (slot.flags & MEMBER_FLAG_ASSISTANT)
+ flags = "Assistant";
+
+ if (slot.flags & MEMBER_FLAG_MAINTANK)
+ {
+ if (!flags.empty())
+ flags.append(", ");
+ flags.append("MainTank");
+ }
+
+ if (slot.flags & MEMBER_FLAG_MAINASSIST)
+ {
+ if (!flags.empty())
+ flags.append(", ");
+ flags.append("MainAssist");
+ }
+
+ if (flags.empty())
+ flags = "None";
Player* p = ObjectAccessor::FindPlayer((*itr).guid);
const char* onlineState = (p && p->IsInWorld()) ? "online" : "offline";
- std::string flagsStr = (flags.str().empty()) ? "None" : flags.str();
- std::string rolesStr = (roles.str().empty()) ? "None" : roles.str();
-
- handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, (*itr).name.c_str(), onlineState, GUID_LOPART((*itr).guid), flagsStr.c_str(), rolesStr.c_str());
+ handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, slot.name.c_str(), onlineState,
+ GUID_LOPART(slot.guid), flags.c_str(), LFGMgr::GetRolesString(slot.roles).c_str());
}
- return true;
}
else
- {
handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, nameTarget.c_str());
- return true;
- }
return true;
}
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index e7befff87a3..54ca3efd6d5 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -1715,10 +1715,29 @@ class spell_gen_luck_of_the_draw : public SpellScriptLoader
class spell_gen_luck_of_the_draw_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_luck_of_the_draw_AuraScript);
+ Map const* map;
+ Difficulty difficulty;
bool Load()
{
- return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER;
+ Player* owner = GetUnitOwner()->ToPlayer();
+ if (!owner)
+ return false;
+
+ Group* group = owner->GetGroup();
+ if (!group || group->isLFGGroup())
+ return false;
+
+ if (!sLFGMgr->inRandomLfgDungeon(owner->GetGUID()))
+ return false;
+
+ map = owner->GetMap();
+ difficulty = owner->GetMap()->GetDifficulty();
+
+ if (!sLFGMgr->inLfgDungeonMap(owner->GetGUID(), map->GetId(), difficulty))
+ return false;
+
+ return true;
}
// cheap hax to make it have update calls
@@ -1730,30 +1749,9 @@ class spell_gen_luck_of_the_draw : public SpellScriptLoader
void Update(AuraEffect* /*effect*/)
{
- if (Player* owner = GetUnitOwner()->ToPlayer())
- {
- const LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(owner->GetGUID());
- LfgDungeonSet::const_iterator itr = dungeons.begin();
-
- if (itr == dungeons.end())
- {
- Remove(AURA_REMOVE_BY_DEFAULT);
- return;
- }
-
-
- LFGDungeonData const* randomDungeon = sLFGMgr->GetLFGDungeon(*itr);
- if (Group* group = owner->GetGroup())
- if (Map const* map = owner->GetMap())
- if (group->isLFGGroup())
- if (uint32 dungeonId = sLFGMgr->GetDungeon(group->GetGUID(), true))
- if (LFGDungeonData const* dungeon = sLFGMgr->GetLFGDungeon(dungeonId))
- if (uint32(dungeon->map) == map->GetId() && dungeon->difficulty == map->GetDifficulty())
- if (randomDungeon && randomDungeon->type == LFG_TYPE_RANDOM)
- return; // in correct dungeon
-
+ Map const* currentMap = GetUnitOwner()->ToPlayer()->GetMap();
+ if (currentMap != map || currentMap->GetDifficulty() != difficulty)
Remove(AURA_REMOVE_BY_DEFAULT);
- }
}
void Register()