Core/Scripts: Add GroupScript class
--HG-- branch : trunk
This commit is contained in:
@@ -256,6 +256,8 @@ bool Group::AddInvite(Player *player)
|
|||||||
|
|
||||||
player->SetGroupInvite(this);
|
player->SetGroupInvite(this);
|
||||||
|
|
||||||
|
sScriptMgr.OnGroupInviteMember(this, player->GetGUID());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,6 +316,7 @@ bool Group::AddMember(const uint64 &guid, const char* name)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
SendUpdate();
|
SendUpdate();
|
||||||
|
sScriptMgr.OnGroupAddMember(this, guid);
|
||||||
|
|
||||||
Player *player = sObjectMgr.GetPlayer(guid);
|
Player *player = sObjectMgr.GetPlayer(guid);
|
||||||
if (player)
|
if (player)
|
||||||
@@ -363,6 +366,8 @@ uint32 Group::RemoveMember(const uint64 &guid, const RemoveMethod &method)
|
|||||||
else if (isLFGGroup() && !isLfgDungeonComplete())
|
else if (isLFGGroup() && !isLfgDungeonComplete())
|
||||||
sLFGMgr.OfferContinue(this);
|
sLFGMgr.OfferContinue(this);
|
||||||
|
|
||||||
|
sScriptMgr.OnGroupRemoveMember(this, guid, method);
|
||||||
|
|
||||||
// remove member and change leader (if need) only if strong more 2 members _before_ member remove
|
// remove member and change leader (if need) only if strong more 2 members _before_ member remove
|
||||||
if (GetMembersCount() > (isBGGroup() ? 1u : 2u)) // in BG group case allow 1 members group
|
if (GetMembersCount() > (isBGGroup() ? 1u : 2u)) // in BG group case allow 1 members group
|
||||||
{
|
{
|
||||||
@@ -426,6 +431,7 @@ void Group::ChangeLeader(const uint64 &guid)
|
|||||||
if (slot == m_memberSlots.end())
|
if (slot == m_memberSlots.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sScriptMgr.OnGroupChangeLeader(this, m_leaderGuid, guid);
|
||||||
_setLeader(guid);
|
_setLeader(guid);
|
||||||
|
|
||||||
WorldPacket data(SMSG_GROUP_SET_LEADER, slot->name.size()+1);
|
WorldPacket data(SMSG_GROUP_SET_LEADER, slot->name.size()+1);
|
||||||
@@ -436,8 +442,9 @@ void Group::ChangeLeader(const uint64 &guid)
|
|||||||
|
|
||||||
void Group::Disband(bool hideDestroy /* = false */)
|
void Group::Disband(bool hideDestroy /* = false */)
|
||||||
{
|
{
|
||||||
Player *player;
|
sScriptMgr.OnGroupDisband(this);
|
||||||
|
|
||||||
|
Player *player;
|
||||||
for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
|
for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
|
||||||
{
|
{
|
||||||
player = sObjectMgr.GetPlayer(citr->guid);
|
player = sObjectMgr.GetPlayer(citr->guid);
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ ScriptMgr::~ScriptMgr()
|
|||||||
SCR_CLEAR(AchievementCriteriaScript);
|
SCR_CLEAR(AchievementCriteriaScript);
|
||||||
SCR_CLEAR(PlayerScript);
|
SCR_CLEAR(PlayerScript);
|
||||||
SCR_CLEAR(GuildScript);
|
SCR_CLEAR(GuildScript);
|
||||||
|
SCR_CLEAR(GroupScript);
|
||||||
|
|
||||||
#undef SCR_CLEAR
|
#undef SCR_CLEAR
|
||||||
}
|
}
|
||||||
@@ -1199,6 +1200,36 @@ void ScriptMgr::OnGuildDisband(Guild *guild)
|
|||||||
FOREACH_SCRIPT(GuildScript)->OnDisband(guild);
|
FOREACH_SCRIPT(GuildScript)->OnDisband(guild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnGroupAddMember(Group* group, uint64 guid)
|
||||||
|
{
|
||||||
|
ASSERT(group);
|
||||||
|
FOREACH_SCRIPT(GroupScript)->OnAddMember(group, guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnGroupInviteMember(Group* group, uint64 guid)
|
||||||
|
{
|
||||||
|
ASSERT(group);
|
||||||
|
FOREACH_SCRIPT(GroupScript)->OnInviteMember(group, guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnGroupRemoveMember(Group* group, uint64 guid, RemoveMethod method)
|
||||||
|
{
|
||||||
|
ASSERT(group);
|
||||||
|
FOREACH_SCRIPT(GroupScript)->OnRemoveMember(group, guid, method);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnGroupChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid)
|
||||||
|
{
|
||||||
|
ASSERT(group);
|
||||||
|
FOREACH_SCRIPT(GroupScript)->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnGroupDisband(Group* group)
|
||||||
|
{
|
||||||
|
ASSERT(group);
|
||||||
|
FOREACH_SCRIPT(GroupScript)->OnDisband(group);
|
||||||
|
}
|
||||||
|
|
||||||
SpellScriptLoader::SpellScriptLoader(const char* name)
|
SpellScriptLoader::SpellScriptLoader(const char* name)
|
||||||
: ScriptObject(name)
|
: ScriptObject(name)
|
||||||
{
|
{
|
||||||
@@ -1346,6 +1377,12 @@ GuildScript::GuildScript(const char* name)
|
|||||||
ScriptMgr::ScriptRegistry<GuildScript>::AddScript(this);
|
ScriptMgr::ScriptRegistry<GuildScript>::AddScript(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupScript::GroupScript(const char* name)
|
||||||
|
: ScriptObject(name)
|
||||||
|
{
|
||||||
|
ScriptMgr::ScriptRegistry<GroupScript>::AddScript(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Instantiate static members of ScriptMgr::ScriptRegistry.
|
// Instantiate static members of ScriptMgr::ScriptRegistry.
|
||||||
template<class TScript> std::map<uint32, TScript*> ScriptMgr::ScriptRegistry<TScript>::ScriptPointerList;
|
template<class TScript> std::map<uint32, TScript*> ScriptMgr::ScriptRegistry<TScript>::ScriptPointerList;
|
||||||
template<class TScript> uint32 ScriptMgr::ScriptRegistry<TScript>::_scriptIdCounter = 0;
|
template<class TScript> uint32 ScriptMgr::ScriptRegistry<TScript>::_scriptIdCounter = 0;
|
||||||
@@ -1374,6 +1411,7 @@ template class ScriptMgr::ScriptRegistry<TransportScript>;
|
|||||||
template class ScriptMgr::ScriptRegistry<AchievementCriteriaScript>;
|
template class ScriptMgr::ScriptRegistry<AchievementCriteriaScript>;
|
||||||
template class ScriptMgr::ScriptRegistry<PlayerScript>;
|
template class ScriptMgr::ScriptRegistry<PlayerScript>;
|
||||||
template class ScriptMgr::ScriptRegistry<GuildScript>;
|
template class ScriptMgr::ScriptRegistry<GuildScript>;
|
||||||
|
template class ScriptMgr::ScriptRegistry<GroupScript>;
|
||||||
|
|
||||||
// Undefine utility macros.
|
// Undefine utility macros.
|
||||||
#undef GET_SCRIPT_RET
|
#undef GET_SCRIPT_RET
|
||||||
|
|||||||
@@ -726,6 +726,21 @@ class GuildScript : public ScriptObject
|
|||||||
virtual void OnDisband(Guild* /*guild*/) { }
|
virtual void OnDisband(Guild* /*guild*/) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GroupScript : public ScriptObject
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
GroupScript(const char* name);
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool IsDatabaseBound() const { return false; }
|
||||||
|
|
||||||
|
virtual void OnAddMember(Group* /*group*/, uint64 /*guid*/) { }
|
||||||
|
virtual void OnInviteMember(Group* /*group*/, uint64 /*guid*/) { }
|
||||||
|
virtual void OnRemoveMember(Group* /*group*/, uint64 /*guid*/, RemoveMethod& /*method*/) { }
|
||||||
|
virtual void OnChangeLeader(Group* /*group*/, uint64 /*newLeaderGuid*/, uint64 /*oldLeaderGuid*/) { }
|
||||||
|
virtual void OnDisband(Group* /*group*/) { }
|
||||||
|
};
|
||||||
|
|
||||||
// Placed here due to ScriptRegistry::AddScript dependency.
|
// Placed here due to ScriptRegistry::AddScript dependency.
|
||||||
#define sScriptMgr (*ACE_Singleton<ScriptMgr, ACE_Null_Mutex>::instance())
|
#define sScriptMgr (*ACE_Singleton<ScriptMgr, ACE_Null_Mutex>::instance())
|
||||||
|
|
||||||
@@ -924,6 +939,13 @@ class ScriptMgr
|
|||||||
void OnGuildInfoChanged(Guild *guild, std::string newGInfo);
|
void OnGuildInfoChanged(Guild *guild, std::string newGInfo);
|
||||||
void OnGuildDisband(Guild *guild);
|
void OnGuildDisband(Guild *guild);
|
||||||
|
|
||||||
|
public: /* GroupScript */
|
||||||
|
void OnGroupAddMember(Group* group, uint64 guid);
|
||||||
|
void OnGroupInviteMember(Group* group, uint64 guid);
|
||||||
|
void OnGroupRemoveMember(Group* group, uint64 guid, RemoveMethod method);
|
||||||
|
void OnGroupChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid);
|
||||||
|
void OnGroupDisband(Group* group);
|
||||||
|
|
||||||
public: /* ScriptRegistry */
|
public: /* ScriptRegistry */
|
||||||
|
|
||||||
// This is the global static registry of scripts.
|
// This is the global static registry of scripts.
|
||||||
|
|||||||
Reference in New Issue
Block a user