mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01:00
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts: sql/base/auth_database.sql sql/base/characters_database.sql src/server/game/Entities/Player/Player.cpp src/server/game/Handlers/LFGHandler.cpp src/server/game/Server/WorldSession.cpp src/server/game/Server/WorldSession.h src/server/game/Server/WorldSocket.cpp src/server/game/World/World.cpp src/server/scripts/Spells/spell_generic.cpp
This commit is contained in:
@@ -35,6 +35,7 @@ set(scripts_STAT_SRCS
|
||||
Commands/cs_modify.cpp
|
||||
Commands/cs_npc.cpp
|
||||
Commands/cs_quest.cpp
|
||||
Commands/cs_rbac.cpp
|
||||
Commands/cs_reload.cpp
|
||||
Commands/cs_reset.cpp
|
||||
Commands/cs_tele.cpp
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
if (!accountName || !password)
|
||||
return false;
|
||||
|
||||
AccountOpResult result = AccountMgr::CreateAccount(std::string(accountName), std::string(password));
|
||||
AccountOpResult result = sAccountMgr->CreateAccount(std::string(accountName), std::string(password));
|
||||
switch (result)
|
||||
{
|
||||
case AOR_OK:
|
||||
@@ -503,36 +503,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
// If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID
|
||||
PreparedStatement* stmt;
|
||||
|
||||
if (gmRealmID == -1)
|
||||
{
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
|
||||
|
||||
stmt->setUInt32(0, targetAccountId);
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM);
|
||||
|
||||
stmt->setUInt32(0, targetAccountId);
|
||||
stmt->setUInt32(1, realmID);
|
||||
}
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
if (gm != 0)
|
||||
{
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS);
|
||||
|
||||
stmt->setUInt32(0, targetAccountId);
|
||||
stmt->setUInt8(1, uint8(gm));
|
||||
stmt->setInt32(2, gmRealmID);
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
RBACData* rbac = isAccountNameGiven ? NULL : handler->getSelectedPlayer()->GetSession()->GetRBACData();
|
||||
sAccountMgr->UpdateAccountAccess(rbac, targetAccountId, uint8(gm), gmRealmID);
|
||||
|
||||
handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
|
||||
return true;
|
||||
|
||||
@@ -28,12 +28,12 @@ void GetPlayerInfo(ChatHandler* handler, Player* player)
|
||||
return;
|
||||
|
||||
uint64 guid = player->GetGUID();
|
||||
LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid);
|
||||
lfg::LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid);
|
||||
|
||||
std::string const& state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid));
|
||||
std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
|
||||
handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(),
|
||||
state.c_str(), uint8(dungeons.size()), sLFGMgr->ConcatenateDungeons(dungeons).c_str(),
|
||||
sLFGMgr->GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str());
|
||||
state.c_str(), uint8(dungeons.size()), lfg::ConcatenateDungeons(dungeons).c_str(),
|
||||
lfg::GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str());
|
||||
}
|
||||
|
||||
class lfg_commandscript : public CommandScript
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
}
|
||||
|
||||
uint64 guid = grp->GetGUID();
|
||||
std::string const& state = sLFGMgr->GetStateString(sLFGMgr->GetState(guid));
|
||||
std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
|
||||
handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(),
|
||||
state.c_str(), sLFGMgr->GetDungeon(guid));
|
||||
|
||||
|
||||
@@ -1549,6 +1549,8 @@ public:
|
||||
|
||||
std::string userName = handler->GetTrinityString(LANG_ERROR);
|
||||
std::string eMail = handler->GetTrinityString(LANG_ERROR);
|
||||
std::string muteReason = "";
|
||||
std::string muteBy = "";
|
||||
std::string lastIp = handler->GetTrinityString(LANG_ERROR);
|
||||
uint32 security = 0;
|
||||
std::string lastLogin = handler->GetTrinityString(LANG_ERROR);
|
||||
@@ -1565,6 +1567,8 @@ public:
|
||||
security = fields[1].GetUInt8();
|
||||
eMail = fields[2].GetString();
|
||||
muteTime = fields[5].GetUInt64();
|
||||
muteReason = fields[6].GetString();
|
||||
muteBy = fields[7].GetString();
|
||||
|
||||
if (eMail.empty())
|
||||
eMail = "-";
|
||||
@@ -1626,7 +1630,7 @@ public:
|
||||
}
|
||||
|
||||
if (muteTime > 0)
|
||||
handler->PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str());
|
||||
handler->PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str(), muteBy.c_str(), muteReason.c_str());
|
||||
|
||||
if (banTime >= 0)
|
||||
handler->PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str());
|
||||
@@ -1824,6 +1828,11 @@ public:
|
||||
return false;
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
std::string muteBy = "";
|
||||
if (handler->GetSession())
|
||||
muteBy = handler->GetSession()->GetPlayerName();
|
||||
else
|
||||
muteBy = "Console";
|
||||
|
||||
if (target)
|
||||
{
|
||||
@@ -1831,7 +1840,7 @@ public:
|
||||
int64 muteTime = time(NULL) + notSpeakTime * MINUTE;
|
||||
target->GetSession()->m_muteTime = muteTime;
|
||||
stmt->setInt64(0, muteTime);
|
||||
ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteReasonStr.c_str());
|
||||
ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1840,7 +1849,9 @@ public:
|
||||
stmt->setInt64(0, muteTime);
|
||||
}
|
||||
|
||||
stmt->setUInt32(1, accountId);
|
||||
stmt->setString(1, muteReasonStr.c_str());
|
||||
stmt->setString(2, muteBy.c_str());
|
||||
stmt->setUInt32(3, accountId);
|
||||
LoginDatabase.Execute(stmt);
|
||||
std::string nameLink = handler->playerLink(targetName);
|
||||
|
||||
@@ -1883,7 +1894,9 @@ public:
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
stmt->setInt64(0, 0);
|
||||
stmt->setUInt32(1, accountId);
|
||||
stmt->setString(1, "");
|
||||
stmt->setString(2, "");
|
||||
stmt->setUInt32(3, accountId);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
if (target)
|
||||
@@ -2832,41 +2845,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 ";
|
||||
Group::MemberSlot const& slot = *itr;
|
||||
|
||||
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 ";
|
||||
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(), lfg::GetRolesString(slot.roles).c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, nameTarget.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
780
src/server/scripts/Commands/cs_rbac.cpp
Normal file
780
src/server/scripts/Commands/cs_rbac.cpp
Normal file
@@ -0,0 +1,780 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* ScriptData
|
||||
Name: rbac_commandscript
|
||||
%Complete: 100
|
||||
Comment: All role based access control related commands (including account related)
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "RBAC.h"
|
||||
#include "Config.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
struct RBACCommandData
|
||||
{
|
||||
RBACCommandData(): id(0), realmId(0), rbac(NULL), needDelete(false) { }
|
||||
uint32 id;
|
||||
int32 realmId;
|
||||
RBACData* rbac;
|
||||
bool needDelete;
|
||||
};
|
||||
|
||||
class rbac_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
rbac_commandscript() : CommandScript("rbac_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand rbacGroupsCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_ADMINISTRATOR, true, &HandleRBACGroupAddCommand, "", NULL },
|
||||
{ "remove", SEC_ADMINISTRATOR, true, &HandleRBACGroupRemoveCommand, "", NULL },
|
||||
{ "", SEC_ADMINISTRATOR, true, &HandleRBACGroupListCommand, "", NULL },
|
||||
{ NULL, SEC_ADMINISTRATOR, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand rbacRolesCommandTable[] =
|
||||
{
|
||||
{ "grant", SEC_ADMINISTRATOR, true, &HandleRBACRoleGrantCommand, "", NULL },
|
||||
{ "deny", SEC_ADMINISTRATOR, true, &HandleRBACRoleDenyCommand, "", NULL },
|
||||
{ "revoke", SEC_ADMINISTRATOR, true, &HandleRBACRoleRevokeCommand, "", NULL },
|
||||
{ "", SEC_ADMINISTRATOR, true, &HandleRBACRoleListCommand, "", NULL },
|
||||
{ NULL, SEC_ADMINISTRATOR, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand rbacPermsCommandTable[] =
|
||||
{
|
||||
{ "grant", SEC_ADMINISTRATOR, true, &HandleRBACPermGrantCommand, "", NULL },
|
||||
{ "deny", SEC_ADMINISTRATOR, true, &HandleRBACPermDenyCommand, "", NULL },
|
||||
{ "revoke", SEC_ADMINISTRATOR, true, &HandleRBACPermRevokeCommand, "", NULL },
|
||||
{ "", SEC_ADMINISTRATOR, true, &HandleRBACPermListCommand, "", NULL },
|
||||
{ NULL, SEC_ADMINISTRATOR, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand rbacListCommandTable[] =
|
||||
{
|
||||
{ "groups", SEC_ADMINISTRATOR, true, &HandleRBACListGroupsCommand, "", NULL },
|
||||
{ "roles", SEC_ADMINISTRATOR, true, &HandleRBACListRolesCommand, "", NULL },
|
||||
{ "permissions", SEC_ADMINISTRATOR, true, &HandleRBACListPermissionsCommand, "", NULL },
|
||||
{ NULL, SEC_ADMINISTRATOR, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand rbacAccountCommandTable[] =
|
||||
{
|
||||
{ "group", SEC_ADMINISTRATOR, true, NULL, "", rbacGroupsCommandTable },
|
||||
{ "role", SEC_ADMINISTRATOR, true, NULL, "", rbacRolesCommandTable },
|
||||
{ "permission", SEC_ADMINISTRATOR, true, NULL, "", rbacPermsCommandTable },
|
||||
{ "", SEC_ADMINISTRATOR, true, &HandleRBACAccountPermissionCommand, "", NULL },
|
||||
{ NULL, SEC_ADMINISTRATOR, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand rbacCommandTable[] =
|
||||
{
|
||||
{ "account", SEC_ADMINISTRATOR, true, NULL, "", rbacAccountCommandTable },
|
||||
{ "list", SEC_ADMINISTRATOR, true, NULL, "", rbacListCommandTable },
|
||||
{ NULL, SEC_ADMINISTRATOR, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "rbac", SEC_ADMINISTRATOR, true, NULL, "", rbacCommandTable },
|
||||
{ NULL, SEC_ADMINISTRATOR, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static RBACCommandData* ReadParams(ChatHandler* handler, char const* args, bool checkParams = true)
|
||||
{
|
||||
if (!args)
|
||||
return NULL;
|
||||
|
||||
char* param1 = strtok((char*)args, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
char* param3 = strtok(NULL, " ");
|
||||
|
||||
int32 realmId = -1;
|
||||
uint32 accountId = 0;
|
||||
std::string accountName;
|
||||
uint32 id = 0;
|
||||
RBACCommandData* data = NULL;
|
||||
RBACData* rdata = NULL;
|
||||
bool useSelectedPlayer = false;
|
||||
|
||||
if (checkParams)
|
||||
{
|
||||
if (!param3)
|
||||
{
|
||||
if (param2)
|
||||
realmId = atoi(param2);
|
||||
|
||||
if (param1)
|
||||
id = atoi(param1);
|
||||
|
||||
useSelectedPlayer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = atoi(param2);
|
||||
realmId = atoi(param3);
|
||||
}
|
||||
|
||||
if (!id)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (realmId < -1 || !realmId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_REALM, realmId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (!param1)
|
||||
useSelectedPlayer = true;
|
||||
|
||||
if (useSelectedPlayer)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayer();
|
||||
if (!player)
|
||||
return NULL;
|
||||
|
||||
rdata = player->GetSession()->GetRBACData();
|
||||
accountId = rdata->GetId();
|
||||
AccountMgr::GetName(accountId, accountName);
|
||||
}
|
||||
else
|
||||
{
|
||||
accountName = param1;
|
||||
|
||||
if (AccountMgr::normalizeString(accountName))
|
||||
accountId = AccountMgr::GetId(accountName);
|
||||
|
||||
if (!accountId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkParams && handler->HasLowerSecurityAccount(NULL, accountId, true))
|
||||
return NULL;
|
||||
|
||||
data = new RBACCommandData();
|
||||
|
||||
if (!rdata)
|
||||
{
|
||||
data->rbac = new RBACData(accountId, accountName, ConfigMgr::GetIntDefault("RealmID", 0));
|
||||
data->rbac->LoadFromDB();
|
||||
data->needDelete = true;
|
||||
}
|
||||
else
|
||||
data->rbac = rdata;
|
||||
|
||||
data->id = id;
|
||||
data->realmId = realmId;
|
||||
return data;
|
||||
}
|
||||
|
||||
static bool HandleRBACGroupAddCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
RBACCommandResult result = command->rbac->AddGroup(command->id, command->realmId);
|
||||
RBACGroup const* group = sAccountMgr->GetRBACGroup(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_GROUP_IN_LIST, command->id, group->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_GROUP_ADDED, command->id, group->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACGroupRemoveCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
RBACCommandResult result = command->rbac->RemoveGroup(command->id, command->realmId);
|
||||
RBACGroup const* group = sAccountMgr->GetRBACGroup(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case RBAC_CANT_REVOKE_NOT_IN_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_GROUP_NOT_IN_LIST, command->id, group->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_GROUP_REMOVED, command->id, group->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACGroupListCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args, false);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_GROUP_LIST_HEADER, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
RBACGroupContainer const& groups = command->rbac->GetGroups();
|
||||
if (groups.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (RBACGroupContainer::const_iterator it = groups.begin(); it != groups.end(); ++it)
|
||||
{
|
||||
RBACGroup const* group = sAccountMgr->GetRBACGroup(*it);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, group->GetId(), group->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACRoleGrantCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
RBACCommandResult result = command->rbac->GrantRole(command->id, command->realmId);
|
||||
RBACRole const* role = sAccountMgr->GetRBACRole(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_GRANTED_IN_LIST, command->id, role->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_IN_DENIED_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_GRANTED_IN_DENIED_LIST, command->id, role->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_GRANTED, command->id, role->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACRoleDenyCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
RBACCommandResult result = command->rbac->DenyRole(command->id, command->realmId);
|
||||
RBACRole const* role = sAccountMgr->GetRBACRole(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_DENIED_IN_LIST, command->id, role->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_IN_GRANTED_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_DENIED_IN_GRANTED_LIST, command->id, role->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_DENIED, command->id, role->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACRoleRevokeCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
RBACCommandResult result = command->rbac->RevokeRole(command->id, command->realmId);
|
||||
RBACRole const* role = sAccountMgr->GetRBACRole(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case RBAC_CANT_REVOKE_NOT_IN_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_REVOKED_NOT_IN_LIST, command->id, role->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_REVOKED, command->id, role->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACRoleListCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args, false);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_LIST_HEADER_GRANTED, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
RBACGroupContainer const& granted = command->rbac->GetGrantedRoles();
|
||||
if (granted.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (RBACRoleContainer::const_iterator it = granted.begin(); it != granted.end(); ++it)
|
||||
{
|
||||
RBACRole const* role = sAccountMgr->GetRBACRole(*it);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, role->GetId(), role->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_ROLE_LIST_HEADER_DENIED, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
RBACGroupContainer const& denied = command->rbac->GetDeniedRoles();
|
||||
if (denied.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (RBACRoleContainer::const_iterator it = denied.begin(); it != denied.end(); ++it)
|
||||
{
|
||||
RBACRole const* role = sAccountMgr->GetRBACRole(*it);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, role->GetId(), role->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermGrantCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
RBACCommandResult result = command->rbac->GrantPermission(command->id, command->realmId);
|
||||
RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_IN_DENIED_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED_IN_DENIED_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermDenyCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
RBACCommandResult result = command->rbac->DenyPermission(command->id, command->realmId);
|
||||
RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_IN_GRANTED_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED_IN_GRANTED_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermRevokeCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
RBACCommandResult result = command->rbac->RevokePermission(command->id, command->realmId);
|
||||
RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case RBAC_CANT_REVOKE_NOT_IN_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_REVOKED_NOT_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_REVOKED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermListCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args, false);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_LIST_HEADER_GRANTED, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
RBACPermissionContainer const& granted = command->rbac->GetGrantedPermissions();
|
||||
if (!granted.any())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (uint32 i = 0; i < RBAC_PERM_MAX; ++i)
|
||||
if (granted.test(i))
|
||||
{
|
||||
RBACPermission const* permission = sAccountMgr->GetRBACPermission(i);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_LIST_HEADER_DENIED, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
RBACPermissionContainer const& denied = command->rbac->GetDeniedPermissions();
|
||||
if (!denied.any())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (uint32 i = 0; i < RBAC_PERM_MAX; ++i)
|
||||
if (denied.test(i))
|
||||
{
|
||||
RBACPermission const* permission = sAccountMgr->GetRBACPermission(i);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACAccountPermissionCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args, false);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_LIST_GLOBAL, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
RBACPermissionContainer const& permissions = command->rbac->GetPermissions();
|
||||
if (!permissions.any())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (uint32 i = 0; i < RBAC_PERM_MAX; ++i)
|
||||
if (permissions.test(i))
|
||||
{
|
||||
RBACPermission const* permission = sAccountMgr->GetRBACPermission(i);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (command->needDelete)
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACListGroupsCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
uint32 id = 0;
|
||||
if (char* param1 = strtok((char*)args, " "))
|
||||
id = atoi(param1);
|
||||
|
||||
if (!id)
|
||||
{
|
||||
RBACGroupsContainer const& groups = sAccountMgr->GetRBACGroupList();
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_GROUPS_HEADER));
|
||||
for (RBACGroupsContainer::const_iterator it = groups.begin(); it != groups.end(); ++it)
|
||||
{
|
||||
RBACGroup const* group = it->second;
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, group->GetId(), group->GetName().c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RBACGroup const* group = sAccountMgr->GetRBACGroup(id);
|
||||
if (!group)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_GROUPS_HEADER));
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, group->GetId(), group->GetName().c_str());
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_ROLES_HEADER));
|
||||
RBACRoleContainer const& roles = group->GetRoles();
|
||||
if (roles.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (RBACRoleContainer::const_iterator it = roles.begin(); it != roles.end(); ++it)
|
||||
{
|
||||
RBACRole const* role = sAccountMgr->GetRBACRole(*it);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, role->GetId(), role->GetName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACListRolesCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
uint32 id = 0;
|
||||
if (char* param1 = strtok((char*)args, " "))
|
||||
id = atoi(param1);
|
||||
|
||||
if (!id)
|
||||
{
|
||||
RBACRolesContainer const& roles = sAccountMgr->GetRBACRoleList();
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_ROLES_HEADER));
|
||||
for (RBACRolesContainer::const_iterator it = roles.begin(); it != roles.end(); ++it)
|
||||
{
|
||||
RBACRole const* role = it->second;
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, role->GetId(), role->GetName().c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RBACRole const* role = sAccountMgr->GetRBACRole(id);
|
||||
if (!role)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_ROLES_HEADER));
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, role->GetId(), role->GetName().c_str());
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMISSIONS_HEADER));
|
||||
RBACPermissionContainer const& permissions = role->GetPermissions();
|
||||
if (!permissions.any())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (uint32 i = 0; i < RBAC_PERM_MAX; ++i)
|
||||
if (permissions.test(i))
|
||||
{
|
||||
RBACPermission const* permission = sAccountMgr->GetRBACPermission(i);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACListPermissionsCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
uint32 id = 0;
|
||||
if (char* param1 = strtok((char*)args, " "))
|
||||
id = atoi(param1);
|
||||
|
||||
if (!id)
|
||||
{
|
||||
RBACPermissionsContainer const& permissions = sAccountMgr->GetRBACPermissionList();
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMISSIONS_HEADER));
|
||||
for (RBACPermissionsContainer::const_iterator it = permissions.begin(); it != permissions.end(); ++it)
|
||||
{
|
||||
RBACPermission const* permission = it->second;
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RBACPermission const* permission = sAccountMgr->GetRBACPermission(id);
|
||||
if (!permission)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMISSIONS_HEADER));
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_rbac_commandscript()
|
||||
{
|
||||
new rbac_commandscript();
|
||||
}
|
||||
@@ -1652,68 +1652,6 @@ class spell_gen_oracle_wolvar_reputation : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
class spell_gen_luck_of_the_draw : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_gen_luck_of_the_draw() : SpellScriptLoader("spell_gen_luck_of_the_draw") { }
|
||||
|
||||
class spell_gen_luck_of_the_draw_AuraScript : public AuraScript
|
||||
{
|
||||
PrepareAuraScript(spell_gen_luck_of_the_draw_AuraScript);
|
||||
|
||||
bool Load()
|
||||
{
|
||||
return GetUnitOwner()->GetTypeId() == TYPEID_PLAYER;
|
||||
}
|
||||
|
||||
// cheap hax to make it have update calls
|
||||
void CalcPeriodic(AuraEffect const* /*effect*/, bool& isPeriodic, int32& amplitude)
|
||||
{
|
||||
isPeriodic = true;
|
||||
amplitude = 5 * IN_MILLISECONDS;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Remove(AURA_REMOVE_BY_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_gen_luck_of_the_draw_AuraScript::CalcPeriodic, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
||||
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_luck_of_the_draw_AuraScript::Update, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
|
||||
}
|
||||
};
|
||||
|
||||
AuraScript* GetAuraScript() const
|
||||
{
|
||||
return new spell_gen_luck_of_the_draw_AuraScript();
|
||||
}
|
||||
};
|
||||
|
||||
enum DummyTrigger
|
||||
{
|
||||
SPELL_PERSISTANT_SHIELD_TRIGGERED = 26470,
|
||||
@@ -3681,7 +3619,6 @@ void AddSC_generic_spell_scripts()
|
||||
new spell_gen_launch();
|
||||
new spell_gen_vehicle_scaling();
|
||||
new spell_gen_oracle_wolvar_reputation();
|
||||
new spell_gen_luck_of_the_draw();
|
||||
new spell_gen_dummy_trigger();
|
||||
new spell_gen_spirit_healer_res();
|
||||
new spell_gen_gadgetzan_transporter_backfire();
|
||||
|
||||
Reference in New Issue
Block a user