本文整理汇总了C++中PlayerPointer::GetSession方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerPointer::GetSession方法的具体用法?C++ PlayerPointer::GetSession怎么用?C++ PlayerPointer::GetSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerPointer
的用法示例。
在下文中一共展示了PlayerPointer::GetSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Say
void Channel::Say(ObjectGuid p, const char *what, uint32 lang, bool skipCheck)
{
if (!what)
return;
if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
lang = LANG_UNIVERSAL;
uint32 sec = 0;
PlayerPointer plr = GetPlayer(p);
if (plr)
sec = plr->GetSession()->GetSecurity();
if (!skipCheck && !IsOn(p))
{
WorldPacket data;
MakeNotMember(&data);
SendToOne(&data, p);
}
else if (!skipCheck && m_players[p].IsMuted())
{
WorldPacket data;
MakeMuted(&data);
SendToOne(&data, p);
}
else if (!skipCheck && m_moderate && !m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
{
WorldPacket data;
MakeNotModerator(&data);
SendToOne(&data, p);
}
else
{
uint32 messageLength = strlen(what) + 1;
WorldPacket data(SMSG_MESSAGECHAT, 1 + 4 + 8 + 4 + m_name.size() + 1 + 8 + 4 + messageLength + 1);
data << uint8(CHAT_MSG_CHANNEL);
data << uint32(lang);
data << m_name;
data << uint32(0);
data << ObjectGuid(p);
data << uint32(messageLength);
data << what;
data << uint8(plr ? plr->chatTag() : 0);
if (!skipCheck && plr &&
plr->GetSession()->GetAccountFlags() & ACCOUNT_FLAG_MUTED_FROM_PUBLIC_CHANNELS &&
plr->GetSession()->GetAccountMaxLevel() < sWorld.getConfig(CONFIG_UINT32_PUB_CHANS_MUTE_VANISH_LEVEL))
plr->GetSession()->SendPacket(&data);
else
SendToAll(&data, (!skipCheck && !m_players[p].IsModerator()) ? p : ObjectGuid());
}
}
示例2: ResetSavedInstances
void InstanceMgr::ResetSavedInstances(PlayerPointer plr)
{
WorldPacket data(SMSG_INSTANCE_RESET, 4);
Instance * in;
InstanceMap::iterator itr;
InstanceMap * instancemap;
uint32 i;
if(!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL)
return;
m_mapLock.Acquire();
for(i = 0; i < NUM_MAPS; ++i)
{
if(m_instances[i] != NULL)
{
instancemap = m_instances[i];
for(itr = instancemap->begin(); itr != instancemap->end();)
{
in = itr->second;
++itr;
if ( in->m_mapInfo->type == INSTANCE_NONRAID &&
( plr->GetLowGUID() == in->m_creatorGuid ||
( plr->GetGroup() && plr->GetGroup()->GetID() == in->m_creatorGroup )))
{
if(in->m_mapMgr && in->m_mapMgr->HasPlayers())
{
plr->GetSession()->SystemMessage("Can't reset instance %u (%s) when there are still players inside!", in->m_instanceId, in->m_mapMgr->GetMapInfo()->name);
continue;
}
// <mapid> has been reset.
data << uint32(in->m_mapId);
plr->GetSession()->SendPacket(&data);
// reset groupinstanceid
if(plr->GetGroup())
plr->GetGroup()->SetGroupInstanceID(0);
// destroy the instance
_DeleteInstance(in, true);
}
}
}
}
m_mapLock.Release();
}
示例3: addMessage
void Antispam::addMessage(const std::string& msg, uint32 type, PlayerPointer from, PlayerPointer to)
{
if (!m_enabled || from->isGameMaster())
return;
if (from->getLevel() > m_restrictionLevel)
return;
uint8 chatType = getConvertedChatType(type);
if (chatType == A_CHAT_TYPE_MAX)
return;
if (m_chatMask && (m_chatMask & (1 << chatType)) == 0)
return;
MessageBlock messageBlock;
messageBlock.fromGuid = from->GetObjectGuid();
messageBlock.fromAccount = from->GetSession()->GetAccountId();
messageBlock.toGuid = (to && !m_mergeAllWhispers ? to->GetObjectGuid() : ObjectGuid());
messageBlock.msg = msg;
messageBlock.type = chatType;
messageBlock.count = 1;
messageBlock.time = time(nullptr);
m_messageQueue.push(messageBlock);
}
示例4: SetOwner
void Channel::SetOwner(ObjectGuid guid, bool exclaim)
{
PlayerPointer newp = GetPlayer(guid);
if (!newp)
return;
if (HasFlag(CHANNEL_FLAG_GENERAL) && newp->GetSession()->GetSecurity() < SEC_GAMEMASTER)
return;
if (m_ownerGuid)
{
// [] will re-add player after it possible removed
PlayerList::iterator p_itr = m_players.find(m_ownerGuid);
if (p_itr != m_players.end())
p_itr->second.SetOwner(false);
}
m_ownerGuid = guid;
if (m_ownerGuid)
{
uint8 oldFlag = GetPlayerFlags(m_ownerGuid);
m_players[m_ownerGuid].SetOwner(true);
WorldPacket data;
MakeModeChange(&data, m_ownerGuid, oldFlag);
SendToAll(&data);
if (exclaim)
{
MakeOwnerChanged(&data, m_ownerGuid);
SendToAll(&data);
}
}
}
示例5: Password
void Channel::Password(ObjectGuid p, const char *pass)
{
uint32 sec = 0;
PlayerPointer plr = GetPlayer(p);
if (plr)
sec = plr->GetSession()->GetSecurity();
if (!IsOn(p))
{
WorldPacket data;
MakeNotMember(&data);
SendToOne(&data, p);
}
else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
{
WorldPacket data;
MakeNotModerator(&data);
SendToOne(&data, p);
}
else
{
m_password = pass;
WorldPacket data;
MakePasswordChanged(&data, p);
SendToAll(&data);
}
}
示例6: CreateGuildCommand
bool ChatHandler::CreateGuildCommand(const char* args, WorldSession *m_session)
{
if(!*args)
return false;
PlayerPointer ptarget = getSelectedChar(m_session);
if(!ptarget) return false;
if(strlen((char*)args)>75)
{
// send message to user
char buf[256];
snprintf((char*)buf,256,"The name was too long by %i", (unsigned int)strlen((char*)args)-75);
SystemMessage(m_session, buf);
return true;
}
for (uint32 i = 0; i < strlen(args); i++) {
if(!isalpha(args[i]) && args[i]!=' ') {
SystemMessage(m_session, "Error, name can only contain chars A-Z and a-z.");
return true;
}
}
Charter tempCharter(0, ptarget->GetLowGUID(), CHARTER_TYPE_GUILD);
tempCharter.SignatureCount=0;
tempCharter.GuildName = string(args);
Guild * pGuild = Guild::Create();
pGuild->CreateFromCharter(&tempCharter, ptarget->GetSession());
SystemMessage(m_session, "Guild created");
return true;
}
示例7: Moderate
void Channel::Moderate(ObjectGuid p)
{
uint32 sec = 0;
PlayerPointer plr = GetPlayer(p);
if (plr)
sec = plr->GetSession()->GetSecurity();
if (!IsOn(p))
{
WorldPacket data;
MakeNotMember(&data);
SendToOne(&data, p);
}
else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
{
WorldPacket data;
MakeNotModerator(&data);
SendToOne(&data, p);
}
else
{
m_moderate = !m_moderate;
WorldPacket data;
if (m_moderate)
MakeModerationOn(&data, p);
else
MakeModerationOff(&data, p);
SendToAll(&data);
}
}
示例8: KickOrBan
void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban)
{
AccountTypes sec = SEC_PLAYER;
PlayerPointer gplr = GetPlayer(good);
if (gplr)
sec = gplr->GetSession()->GetSecurity();
if (!IsOn(good))
{
WorldPacket data;
MakeNotMember(&data);
SendToOne(&data, good);
}
else if (!m_players[good].IsModerator() && sec < SEC_GAMEMASTER)
{
WorldPacket data;
MakeNotModerator(&data);
SendToOne(&data, good);
}
else
{
Player *bad = sObjectMgr.GetPlayer(badname);
if (bad == NULL || !IsOn(bad->GetObjectGuid()))
{
WorldPacket data;
MakePlayerNotFound(&data, badname);
SendToOne(&data, good);
}
else if (sec < SEC_GAMEMASTER && bad->GetObjectGuid() == m_ownerGuid && good != m_ownerGuid)
{
WorldPacket data;
MakeNotOwner(&data);
SendToOne(&data, good);
}
else
{
bool changeowner = (m_ownerGuid == bad->GetObjectGuid());
WorldPacket data;
if (ban && !IsBanned(bad->GetObjectGuid()))
{
m_banned.insert(bad->GetObjectGuid());
MakePlayerBanned(&data, bad->GetObjectGuid(), good);
}
else
MakePlayerKicked(&data, bad->GetObjectGuid(), good);
SendToAll(&data);
m_players.erase(bad->GetObjectGuid());
bad->LeftChannel(this);
if (changeowner)
{
ObjectGuid newowner = !m_players.empty() ? good : ObjectGuid();
SetOwner(newowner);
}
}
}
}
示例9: BuildSavedInstancesForPlayer
void InstanceMgr::BuildSavedInstancesForPlayer(PlayerPointer plr)
{
WorldPacket data(4);
Instance * in;
InstanceMap::iterator itr;
InstanceMap * instancemap;
uint32 i;
if(!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL)
{
m_mapLock.Acquire();
for(i = 0; i < NUM_MAPS; ++i)
{
if(m_instances[i] != NULL)
{
instancemap = m_instances[i];
for(itr = instancemap->begin(); itr != instancemap->end();)
{
in = itr->second;
++itr;
if( PlayerOwnsInstance(in, plr) && in->m_mapInfo->type == INSTANCE_NONRAID )
{
m_mapLock.Release();
data.SetOpcode(SMSG_UPDATE_LAST_INSTANCE);
data << uint32(in->m_mapId);
plr->GetSession()->SendPacket(&data);
data.Initialize(SMSG_UPDATE_INSTANCE_OWNERSHIP);
data << uint32(0x01);
plr->GetSession()->SendPacket(&data);
return;
}
}
}
}
m_mapLock.Release();
}
data.SetOpcode(SMSG_UPDATE_INSTANCE_OWNERSHIP);
data << uint32(0x00);
plr->GetSession()->SendPacket(&data);
}
示例10: HandleInviteToGuild
void WorldSession::HandleInviteToGuild(WorldPacket & recv_data)
{
CHECK_PACKET_SIZE(recv_data, 1);
std::string inviteeName;
recv_data >> inviteeName;
PlayerPointer plyr = objmgr.GetPlayer( inviteeName.c_str() , false);
Guild *pGuild = _player->m_playerInfo->guild;
if(!plyr)
{
Guild::SendGuildCommandResult(this, GUILD_INVITE_S,inviteeName.c_str(),GUILD_PLAYER_NOT_FOUND);
return;
}
else if(!pGuild)
{
Guild::SendGuildCommandResult(this, GUILD_CREATE_S,"",GUILD_PLAYER_NOT_IN_GUILD);
return;
}
if( plyr->GetGuildId() )
{
Guild::SendGuildCommandResult(this, GUILD_INVITE_S,plyr->GetName(),ALREADY_IN_GUILD);
return;
}
else if( plyr->GetGuildInvitersGuid())
{
Guild::SendGuildCommandResult(this, GUILD_INVITE_S,plyr->GetName(),ALREADY_INVITED_TO_GUILD);
return;
}
else if(!_player->m_playerInfo->guildRank->CanPerformCommand(GR_RIGHT_INVITE))
{
Guild::SendGuildCommandResult(this, GUILD_INVITE_S,"",GUILD_PERMISSIONS);
return;
}
else if(plyr->GetTeam()!=_player->GetTeam() && _player->GetSession()->GetPermissionCount() == 0 && !sWorld.cross_faction_world)
{
Guild::SendGuildCommandResult(this, GUILD_INVITE_S,"",GUILD_NOT_ALLIED);
return;
}
else if(pGuild->GetNumMembers() >= MAX_GUILD_MEMBERS)
{
// We can't handle >= 500 members, or WoW will #132. I don't have the proper error code, so just throw the internal one.
Guild::SendGuildCommandResult(this, GUILD_INVITE_S,"",GUILD_INTERNAL);
return;
}
Guild::SendGuildCommandResult(this, GUILD_INVITE_S,inviteeName.c_str(),GUILD_U_HAVE_INVITED);
//41
WorldPacket data(SMSG_GUILD_INVITE, 100);
data << _player->GetName();
data << pGuild->GetGuildName();
plyr->GetSession()->SendPacket(&data);
plyr->SetGuildInvitersGuid( _player->GetLowGUID() );
}
示例11: HandleAddHonorCommand
bool ChatHandler::HandleAddHonorCommand(const char* args, WorldSession* m_session)
{
uint32 HonorAmount = args ? atol(args) : 1;
PlayerPointer plr = getSelectedChar(m_session, true);
if(plr == 0)
return true;
BlueSystemMessage(m_session, "Adding %u honor to player %s.", HonorAmount, plr->GetName());
GreenSystemMessage(plr->GetSession(), "You have had %u honor points added to your character.", HonorAmount);
HonorHandler::AddHonorPointsToPlayer(plr, HonorAmount);
return true;
}
示例12: HandleGroupDeclineOpcode
///////////////////////////////////////////////////////////////////////////////////////
///This function handles CMSG_GROUP_DECLINE:
//////////////////////////////////////////////////////////////////////////////////////
void WorldSession::HandleGroupDeclineOpcode( WorldPacket & recv_data )
{
if(!_player->IsInWorld()) return;
WorldPacket data(SMSG_GROUP_DECLINE, 100);
PlayerPointer player = objmgr.GetPlayer(_player->GetInviter());
if(!player) return;
data << GetPlayer()->GetName();
player->GetSession()->SendPacket( &data );
player->SetInviter(0);
_player->SetInviter(0);
}
示例13: SendShowSignatures
void SendShowSignatures(Charter * c, uint64 i, PlayerPointer p)
{
WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, 100);
data << i;
data << (uint64)c->GetLeader();
data << c->GetID();
data << uint8(c->SignatureCount);
for(uint32 i = 0; i < c->Slots; ++i)
{
if(c->Signatures[i] == 0) continue;
data << uint64(c->Signatures[i]) << uint32(1);
}
data << uint8(0);
p->GetSession()->SendPacket(&data);
}
示例14: HandleAddKillCommand
bool ChatHandler::HandleAddKillCommand(const char* args, WorldSession* m_session)
{
uint32 KillAmount = args ? atol(args) : 1;
PlayerPointer plr = getSelectedChar(m_session, true);
if(plr == 0)
return true;
BlueSystemMessage(m_session, "Adding %u kills to player %s.", KillAmount, plr->GetName());
GreenSystemMessage(plr->GetSession(), "You have had %u honor kills added to your character.", KillAmount);
for(uint32 i = 0; i < KillAmount; ++i)
HonorHandler::OnPlayerKilledUnit(plr, NULLPLR);
return true;
}
示例15: DeliverMessage
void MailSystem::DeliverMessage(MailMessage* message)
{
message->SaveToDB();
PlayerPointer plr = objmgr.GetPlayer((uint32)message->player_guid);
if(plr != NULL)
{
plr->m_mailBox->AddMessage(message);
if((uint32)UNIXTIME >= message->delivery_time)
{
uint32 v = 0;
plr->GetSession()->OutPacket(SMSG_RECEIVED_MAIL, 4, &v);
}
}
}