本文整理汇总了C++中PlayerPointer::GetGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerPointer::GetGroup方法的具体用法?C++ PlayerPointer::GetGroup怎么用?C++ PlayerPointer::GetGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerPointer
的用法示例。
在下文中一共展示了PlayerPointer::GetGroup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: HandleGroupAcceptOpcode
////////////////////////////////////////////////////////////////
///This function handles CMSG_GROUP_ACCEPT:
////////////////////////////////////////////////////////////////
void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data )
{
if(!_player->IsInWorld()) return;
PlayerPointer player = objmgr.GetPlayer(_player->GetInviter());
if ( !player )
return;
player->SetInviter(0);
_player->SetInviter(0);
Group *grp = player->GetGroup();
if(grp)
{
grp->AddMember(_player->m_playerInfo);
if(grp->GetLeader()->m_loggedInPlayer)
_player->iInstanceType = grp->GetLeader()->m_loggedInPlayer->iInstanceType;
_player->GetSession()->OutPacket(MSG_SET_DUNGEON_DIFFICULTY, 4, &_player->iInstanceType);
return;
}
// If we're this far, it means we have no existing group, and have to make one.
grp = new Group(true);
grp->AddMember(player->m_playerInfo); // add the inviter first, therefore he is the leader
grp->AddMember(_player->m_playerInfo); // add us.
_player->iInstanceType = player->iInstanceType;
_player->GetSession()->OutPacket(MSG_SET_DUNGEON_DIFFICULTY, 4, &player->iInstanceType);
}
示例3: HandleGroupSetLeaderOpcode
//////////////////////////////////////////////////////////////////////////////////////////
///This function handles CMSG_GROUP_SET_LEADER:
//////////////////////////////////////////////////////////////////////////////////////////
void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data )
{
if(!_player->IsInWorld()) return;
// important note _player->GetName() can be wrong.
CHECK_PACKET_SIZE(recv_data, 1);
WorldPacket data;
uint64 MemberGuid;
PlayerPointer player;
recv_data >> MemberGuid;
player = objmgr.GetPlayer((uint32)MemberGuid);
if ( player == NULL )
{
//SendPartyCommandResult(_player, 0, membername, ERR_PARTY_CANNOT_FIND);
SendPartyCommandResult(_player, 0, _player->GetName(), ERR_PARTY_CANNOT_FIND);
return;
}
if(!_player->IsGroupLeader())
{
SendPartyCommandResult(_player, 0, "", ERR_PARTY_YOU_ARE_NOT_LEADER);
return;
}
if(player->GetGroup() != _player->GetGroup())
{
//SendPartyCommandResult(_player, 0, membername, ERR_PARTY_IS_NOT_IN_YOUR_PARTY);
SendPartyCommandResult(_player, 0, _player->GetName(), ERR_PARTY_IS_NOT_IN_YOUR_PARTY);
return;
}
Group *pGroup = _player->GetGroup();
if(pGroup)
pGroup->SetLeader(player,false);
}
示例4: OnPlayerKilledUnit
void HonorHandler::OnPlayerKilledUnit( PlayerPointer pPlayer, UnitPointer pVictim )
{
if( pVictim == NULL || pPlayer == NULL || !pVictim->IsPlayer() || !pPlayer->IsPlayer() )
return;
if( TO_PLAYER( pVictim )->m_honorless )
return;
if( pVictim->IsPlayer() )
{
if( pPlayer->m_bg )
{
if( TO_PLAYER( pVictim )->m_bgTeam == pPlayer->m_bgTeam )
return;
// patch 2.4, players killed >50 times in battlegrounds won't be worth honor for the rest of that bg
if( TO_PLAYER(pVictim)->m_bgScore.Deaths >= 50 )
return;
}
else
{
if( pPlayer->GetTeam() == TO_PLAYER( pVictim )->GetTeam() )
return;
}
}
// Calculate points
int32 Points = CalculateHonorPointsForKill(pPlayer, pVictim);
if( Points > 0 )
{
if( pPlayer->m_bg )
{
// hackfix for battlegrounds (since the gorups there are disabled, we need to do this manually)
vector<PlayerPointer > toadd;
uint32 t = pPlayer->m_bgTeam;
toadd.reserve(15); // shouldnt have more than this
pPlayer->m_bg->Lock();
set<PlayerPointer > * s = &pPlayer->m_bg->m_players[t];
for(set<PlayerPointer >::iterator itr = s->begin(); itr != s->end(); ++itr)
{
if((*itr) == pPlayer || (*itr)->isInRange(pPlayer,40.0f))
toadd.push_back(*itr);
}
if( toadd.size() > 0 )
{
uint32 pts = Points / (uint32)toadd.size();
for(vector<PlayerPointer >::iterator vtr = toadd.begin(); vtr != toadd.end(); ++vtr)
{
AddHonorPointsToPlayer(*vtr, pts);
(*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKill();
(*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillClass( pVictim->getClass() );
(*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillRace( pVictim->getRace() );
(*vtr)->m_killsToday++;
(*vtr)->m_killsLifetime++;
pPlayer->m_bg->HookOnHK(*vtr);
if(pVictim)
{
// Send PVP credit
WorldPacket data(SMSG_PVP_CREDIT, 12);
uint32 pvppoints = pts * 10;
data << pvppoints << pVictim->GetGUID() << uint32(TO_PLAYER(pVictim)->GetPVPRank());
(*vtr)->GetSession()->SendPacket(&data);
}
}
}
pPlayer->m_bg->Unlock();
}
else if(pPlayer->GetGroup())
{
Group *pGroup = pPlayer->GetGroup();
PlayerPointer gPlayer = NULLPLR;
int32 GroupPoints;
pGroup->Lock();
GroupPoints = (Points / (pGroup->MemberCount() ? pGroup->MemberCount() : 1));
GroupMembersSet::iterator gitr;
for(uint32 k = 0; k < pGroup->GetSubGroupCount(); k++)
{
for(gitr = pGroup->GetSubGroup(k)->GetGroupMembersBegin(); gitr != pGroup->GetSubGroup(k)->GetGroupMembersEnd(); ++gitr)
{
gPlayer = (*gitr)->m_loggedInPlayer;
if(gPlayer && (gPlayer == pPlayer || gPlayer->isInRange(pPlayer,100.0f))) // visible range
{
gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKill();
gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillClass( pVictim->getClass() );
gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillRace( pVictim->getRace() );
gPlayer->m_killsToday++;
gPlayer->m_killsLifetime++;
if(gPlayer->m_bg)
gPlayer->m_bg->HookOnHK(gPlayer);
sHookInterface.OnHonorableKill(gPlayer, TO_PLAYER(pVictim));
AddHonorPointsToPlayer(gPlayer, GroupPoints);
if(pVictim)
//.........这里部分代码省略.........
示例5: HandleGroupInviteOpcode
//////////////////////////////////////////////////////////////
/// This function handles CMSG_GROUP_INVITE
//////////////////////////////////////////////////////////////
void WorldSession::HandleGroupInviteOpcode( WorldPacket & recv_data )
{
if(!_player->IsInWorld())
return;
CHECK_PACKET_SIZE(recv_data, 1);
WorldPacket data(100);
std::string membername;
PlayerPointer player = NULLPLR;
Group *group = NULL;
recv_data >> membername;
if(_player->HasBeenInvited())return;
player = objmgr.GetPlayer(membername.c_str(), false);
if ( player == NULL)
{
SendPartyCommandResult(_player, 0, membername, ERR_PARTY_CANNOT_FIND);
return;
}
if (player == _player)
{
return;
}
if ( _player->InGroup() && (!_player->IsGroupLeader() || _player->GetGroup()->HasFlag(GROUP_FLAG_BATTLEGROUND_GROUP) ) )
{
SendPartyCommandResult(_player, 0, "", ERR_PARTY_YOU_ARE_NOT_LEADER);
return;
}
group = _player->GetGroup();
if ( group != NULL )
{
if (group->IsFull())
{
SendPartyCommandResult(_player, 0, "", ERR_PARTY_IS_FULL);
return;
}
}
if ( player->InGroup() )
{
SendPartyCommandResult(_player, player->GetGroup()->GetGroupType(), membername, ERR_PARTY_ALREADY_IN_GROUP);
data.SetOpcode(SMSG_GROUP_INVITE);
data << uint8(0);
data << GetPlayer()->GetName();
player->GetSession()->SendPacket(&data);
return;
}
if(player->GetTeam()!=_player->GetTeam() && _player->GetSession()->GetPermissionCount() == 0 && !sWorld.cross_faction_world)
{
SendPartyCommandResult(_player, 0, membername, ERR_PARTY_WRONG_FACTION);
return;
}
if ( player->HasBeenInvited() )
{
SendPartyCommandResult(_player, 0, membername, ERR_PARTY_ALREADY_IN_GROUP);
return;
}
if( player->Social_IsIgnoring( _player->GetLowGUID() ) )
{
SendPartyCommandResult(_player, 0, membername, ERR_PARTY_IS_IGNORING_YOU);
return;
}
if( player->bGMTagOn && !_player->GetSession()->HasPermissions())
{
SendPartyCommandResult(_player, 0, membername, ERR_PARTY_CANNOT_FIND);
return;
}
// 16/08/06 - change to guid to prevent very unlikely event of a crash in deny, etc
_player->SetInviter(_player->GetLowGUID());//bugfix if player invtied 2 people-> he can be in 2 parties
data.SetOpcode(SMSG_GROUP_INVITE);
data << uint8(1);
data << GetPlayer()->GetName();
player->GetSession()->SendPacket(&data);
uint32 gtype = 0;
if(group)
gtype = group->GetGroupType();
SendPartyCommandResult(_player, gtype, membername, ERR_PARTY_NO_ERROR);
// 16/08/06 - change to guid to prevent very unlikely event of a crash in deny, etc
player->SetInviter(_player->GetLowGUID());
}
示例6: GetInstance
MapMgrPointer InstanceMgr::GetInstance(ObjectPointer obj)
{
PlayerPointer plr;
Instance * in;
InstanceMap::iterator itr;
InstanceMap * instancemap;
MapInfo * inf = WorldMapInfoStorage.LookupEntry(obj->GetMapId());
// we can *never* teleport to maps without a mapinfo.
if( inf == NULL || obj->GetMapId() >= NUM_MAPS )
return NULLMAPMGR;
if( obj->IsPlayer() )
{
// players can join instances based on their groups/solo status.
plr = TO_PLAYER( obj );
// single-instance maps never go into the instance set.
if( inf->type == INSTANCE_NULL )
return m_singleMaps[obj->GetMapId()];
m_mapLock.Acquire();
instancemap = m_instances[obj->GetMapId()];
if(instancemap != NULL)
{
// check our instance_id, which we saved before in Player::_Relocate
uint32 plr_instanceID = obj->GetInstanceID();
itr = instancemap->find(plr_instanceID);
if(itr != instancemap->end())
{
in = itr->second;
if(in && in->m_mapMgr)
{
m_mapLock.Release();
return in->m_mapMgr;
}
}
// iterate over our instances, and see if any of them are owned/joinable by him.
for(itr = instancemap->begin(); itr != instancemap->end();)
{
in = itr->second;
++itr;
// Is this our instance?
uint8 poinst = PlayerOwnsInstance(in, plr);
if(poinst >= OWNER_CHECK_OK )
{
//Has it been created yet?
if(in->m_mapMgr == NULL)
{
// create the actual instance.
in->m_mapMgr = _CreateInstance(in);
m_mapLock.Release();
// first one to enter, set the group instance ID
if( plr->GetGroup() && !plr->GetSession()->HasGMPermissions() )
plr->GetGroup()->SetGroupInstanceID(in->m_instanceId);
return in->m_mapMgr;
}
else // instance has found and verfied; us it.
{
if( poinst != OWNER_CHECK_GM_INSIDE && in->m_mapMgr->HasPlayers() && plr->GetGroup() && plr->GetGroup()->GetGroupInstanceID() != in->m_instanceId )
{
Log.Warning("InstanceMgr","Reset GroupInstanceID for existing instance %u [%s] , old_ID = %u, new_ID = %u", in->m_mapId, in->m_mapInfo->name, plr->GetGroup()->GetGroupInstanceID(), in->m_instanceId );
plr->GetGroup()->SetGroupInstanceID(in->m_instanceId);
}
else if(in->m_mapMgr->HasPlayers() && plr->GetGroup() && plr->GetGroup()->GetGroupInstanceID() != in->m_instanceId)
{
Log.Warning("InstanceMgr","Forced GroupInstanceID for instance %u [%s] started by GM, old_ID = %u, new_ID = %u", in->m_mapId, in->m_mapInfo->name, plr->GetGroup()->GetGroupInstanceID(), in->m_instanceId );
plr->GetGroup()->SetGroupInstanceID(in->m_instanceId);
}
m_mapLock.Release();
return in->m_mapMgr;
}
}
else
DEBUG_LOG("InstanceMgr","Check failed %s",plr->GetName());
}
}
// if we're here, it means there are no instances on that map, or none of the instances on that map are joinable
// by this player.
m_mapLock.Release();
return NULLMAPMGR;
}
else
{
// units are *always* limited to their set instance ids.
if(inf->type == INSTANCE_NULL)
return m_singleMaps[obj->GetMapId()];
m_mapLock.Acquire();
instancemap = m_instances[obj->GetMapId()];
if(instancemap)
{
itr = instancemap->find(obj->GetInstanceID());
if(itr != instancemap->end())
{
// we never create instances just for units.
//.........这里部分代码省略.........
示例7: PreTeleport
uint32 InstanceMgr::PreTeleport(uint32 mapid, PlayerPointer plr, uint32 instanceid)
{
// preteleport is where all the magic happens :P instance creation, etc.
MapInfo * inf = WorldMapInfoStorage.LookupEntry(mapid);
Group * pGroup = plr->GetGroup() ;
InstanceMap * instancemap;
Instance * in;
if(inf == NULL || mapid>=NUM_MAPS)
return INSTANCE_ABORT_NOT_FOUND;
// main continent check.
if(inf->type == INSTANCE_NULL)
{
// this will be useful when clustering comes into play.
// we can check if the destination world server is online or not and then cancel them before they load.
return (m_singleMaps[mapid] != NULL) ? INSTANCE_OK : INSTANCE_ABORT_NOT_FOUND;
}
// shouldn't happen
if(inf->type==INSTANCE_PVP)
return INSTANCE_ABORT_NOT_FOUND;
if( !plr->triggerpass_cheat )
{
// players without groups cannot enter raid instances (no soloing them:P)
if( pGroup == NULL && (inf->type == INSTANCE_RAID || inf->type == INSTANCE_MULTIMODE))
return INSTANCE_ABORT_NOT_IN_RAID_GROUP;
// check that heroic mode is available if the player has requested it.
if(plr->iInstanceType && inf->type != INSTANCE_MULTIMODE)
return INSTANCE_ABORT_HEROIC_MODE_NOT_AVAILABLE;
}
// if we are here, it means:
// 1) we're a non-raid instance
// 2) we're a raid instance, and the person is in a group.
// so, first we have to check if they have an instance on this map already, if so, allow them to teleport to that.
// otherwise, we can create them a new one.
m_mapLock.Acquire();
instancemap = m_instances[mapid];
if(instancemap)
{
InstanceMap::iterator itr;
if(instanceid != 0)
{
//try to find our instance in ones active now.
itr = instancemap->find(instanceid);
if(itr != instancemap->end())
{
Instance *inn = itr->second;
if( PlayerOwnsInstance( inn, plr ) >= OWNER_CHECK_OK )
{
m_mapLock.Release();
return INSTANCE_OK;
}
}
//There are no active maps, re-check if this concerns a saved instance.
Instance * saved_in = sInstanceMgr.GetSavedInstance( mapid, plr->GetLowGUID() );
if( saved_in && saved_in->m_instanceId == instanceid )
{
if ( PlayerOwnsInstance( saved_in, plr ) >= OWNER_CHECK_OK )
{
m_mapLock.Release();
return INSTANCE_OK;
}
}
m_mapLock.Release();
return INSTANCE_ABORT_NOT_FOUND;
}
else
{
// search all active instances and see if we have one here.
for(itr = instancemap->begin(); itr != instancemap->end();)
{
in = itr->second;
++itr;
if(PlayerOwnsInstance(in, plr) >= OWNER_CHECK_OK )
{
m_mapLock.Release();
// check the player count and in combat status.
if(in->m_mapMgr && in->m_mapMgr->HasPlayers() && !plr->triggerpass_cheat)
{
if( in->m_mapMgr->IsCombatInProgress())
return INSTANCE_ABORT_ENCOUNTER;
// check if we are full
if( in->m_mapMgr->GetPlayerCount() >= inf->playerlimit )
return INSTANCE_ABORT_FULL;
}
// found our instance, allow him in.
return INSTANCE_OK;
}
else
DEBUG_LOG("InstanceMgr","Check failed %s",plr->GetName());
}
//.........这里部分代码省略.........