本文整理汇总了C++中MemberSlot类的典型用法代码示例。如果您正苦于以下问题:C++ MemberSlot类的具体用法?C++ MemberSlot怎么用?C++ MemberSlot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemberSlot类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DEBUG_LOG
void WorldSession::HandleGuildDemoteOpcode(WorldPacket& recvPacket)
{
DEBUG_LOG("WORLD: Received opcode CMSG_GUILD_DEMOTE");
std::string plName;
recvPacket >> plName;
if (!normalizePlayerName(plName))
{ return; }
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
if (!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD);
return;
}
if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_DEMOTE))
{
SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_PERMISSIONS);
return;
}
MemberSlot* slot = guild->GetMemberSlot(plName);
if (!slot)
{
SendGuildCommandResult(GUILD_INVITE_S, plName, ERR_GUILD_PLAYER_NOT_IN_GUILD_S);
return;
}
if (slot->guid == GetPlayer()->GetObjectGuid())
{
SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_NAME_INVALID);
return;
}
// do not allow to demote same or higher rank
if (GetPlayer()->GetRank() >= slot->RankId)
{
SendGuildCommandResult(GUILD_INVITE_S, plName, ERR_GUILD_RANK_TOO_HIGH_S);
return;
}
// do not allow to demote lowest rank
if (slot->RankId >= guild->GetLowestRank())
{
SendGuildCommandResult(GUILD_INVITE_S, plName, ERR_GUILD_RANK_TOO_LOW_S);
return;
}
uint32 newRankId = slot->RankId + 1; // when demoting player, rank is increased
slot->ChangeRank(newRankId);
// Put record into guild log
guild->LogGuildEvent(GUILD_EVENT_LOG_DEMOTE_PLAYER, GetPlayer()->GetObjectGuid(), slot->guid, newRankId);
guild->BroadcastEvent(GE_DEMOTION, _player->GetName(), plName.c_str(), guild->GetRankName(slot->RankId).c_str());
}
示例2: GetMemberSlot
void Guild::SetLeader(ObjectGuid guid)
{
MemberSlot* slot = GetMemberSlot(guid);
if (!slot)
{ return; }
m_LeaderGuid = guid;
slot->ChangeRank(GR_GUILDMASTER);
CharacterDatabase.PExecute("UPDATE guild SET leaderguid='%u' WHERE guildid='%u'", guid.GetCounter(), m_Id);
}
示例3: DEBUG_LOG
void WorldSession::HandleGuildPromoteOpcode(WorldPacket& recvPacket)
{
DEBUG_LOG("WORLD: Received opcode CMSG_GUILD_PROMOTE");
std::string plName;
ObjectGuid targetGuid;
recvPacket.ReadGuidMask<7, 2, 5, 6, 1, 0, 3, 4>(targetGuid);
recvPacket.ReadGuidBytes<0, 5, 2, 3, 6, 4, 1, 7>(targetGuid);
Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
if (!guild)
{
SendGuildCommandResult(GUILD_CREATE_S, "", ERR_GUILD_PLAYER_NOT_IN_GUILD);
return;
}
if (!guild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_PROMOTE))
{
SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_PERMISSIONS);
return;
}
if (!sObjectMgr.GetPlayerNameByGUID(targetGuid, plName))
return;
MemberSlot* slot = guild->GetMemberSlot(targetGuid);
if (!slot)
{
SendGuildCommandResult(GUILD_INVITE_S, plName, ERR_GUILD_PLAYER_NOT_IN_GUILD_S);
return;
}
if (slot->guid == GetPlayer()->GetObjectGuid())
{
SendGuildCommandResult(GUILD_INVITE_S, "", ERR_GUILD_NAME_INVALID);
return;
}
// allow to promote only to lower rank than member's rank
// guildmaster's rank = 0
// GetPlayer()->GetRank() + 1 is highest rank that current player can promote to
if (GetPlayer()->GetRank() + 1 >= slot->RankId)
{
SendGuildCommandResult(GUILD_INVITE_S, plName, ERR_GUILD_RANK_TOO_HIGH_S);
return;
}
uint32 newRankId = slot->RankId - 1; // when promoting player, rank is decreased
slot->ChangeRank(newRankId);
// Put record into guild log
guild->LogGuildEvent(GUILD_EVENT_LOG_PROMOTE_PLAYER, GetPlayer()->GetObjectGuid(), slot->guid, newRankId);
guild->BroadcastEvent(GE_PROMOTION, _player->GetName(), plName.c_str(), guild->GetRankName(newRankId).c_str());
}