本文整理汇总了C++中Group::GetID方法的典型用法代码示例。如果您正苦于以下问题:C++ Group::GetID方法的具体用法?C++ Group::GetID怎么用?C++ Group::GetID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::GetID方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleGroupAcceptOpcode
////////////////////////////////////////////////////////////////
///This function handles CMSG_GROUP_ACCEPT:
////////////////////////////////////////////////////////////////
void WorldSession::HandleGroupAcceptOpcode(WorldPacket & recv_data)
{
CHECK_INWORLD_RETURN;
// we are in group already
if(_player->GetGroup() != NULL)
return;
Player* player = objmgr.GetPlayer(_player->GetInviter());
if(!player)
return;
player->SetInviter(0);
_player->SetInviter(0);
Group* grp = player->GetGroup();
if(grp != NULL)
{
grp->AddMember(_player->m_playerInfo);
_player->iInstanceType = grp->m_difficulty;
_player->SendDungeonDifficulty();
//sInstanceSavingManager.ResetSavedInstancesForPlayer(_player);
return;
}
// If we're this far, it means we have no existing group, and have to make one.
grp = new Group(true);
grp->m_difficulty = static_cast<uint8>(player->iInstanceType);
grp->AddMember(player->m_playerInfo); // add the inviter first, therefore he is the leader
grp->AddMember(_player->m_playerInfo); // add us.
_player->iInstanceType = grp->m_difficulty;
_player->SendDungeonDifficulty();
Instance* instance = sInstanceMgr.GetInstanceByIds(player->GetMapId(), player->GetInstanceID());
if(instance != NULL && instance->m_creatorGuid == player->GetLowGUID())
{
grp->m_instanceIds[instance->m_mapId][instance->m_difficulty] = instance->m_instanceId;
instance->m_creatorGroup = grp->GetID();
instance->m_creatorGuid = 0;
instance->SaveToDB();
}
//sInstanceSavingManager.ResetSavedInstancesForPlayer(_player);
// Currentgroup and all that shit are set by addmember.
}
示例2: HandleResetInstanceCommand
bool ChatHandler::HandleResetInstanceCommand(const char* args, WorldSession* m_session)
{
uint32 instanceId;
int argc = 1;
char* playername = NULL;
char* guidString = (char*)args;
// Parse arguments
char* space = (char*)strchr(args, ' ');
if (space)
{
*space = '\0';
playername = space + 1;
argc = 2;
}
instanceId = atoi(guidString);
if (!instanceId)
{
RedSystemMessage(m_session, "You must specify an instance id.");
return true;
}
Player* plr;
if (argc == 1)
plr = getSelectedChar(m_session, true);
else
plr = objmgr.GetPlayer((const char*)playername, false);;
if (!plr)
{
RedSystemMessage(m_session, "Player not found");
return true;
}
Instance* instance = sInstanceMgr.GetInstanceByIds(NUM_MAPS, instanceId);
if (instance == NULL)
{
RedSystemMessage(m_session, "There's no instance with id %u.", instanceId);
return true;
}
if (IS_PERSISTENT_INSTANCE(instance))
{
if (m_session->CanUseCommand('z'))
{
bool foundSomething = false;
plr->getPlayerInfo()->savedInstanceIdsLock.Acquire();
for (uint32 difficulty = 0; difficulty < NUM_INSTANCE_MODES; difficulty++)
{
PlayerInstanceMap::iterator itr = plr->getPlayerInfo()->savedInstanceIds[difficulty].find(instance->m_mapId);
if (itr == plr->getPlayerInfo()->savedInstanceIds[difficulty].end() || (*itr).second != instance->m_instanceId)
continue;
plr->SetPersistentInstanceId(instance->m_mapId, difficulty, 0);
SystemMessage(m_session, "Instance with id %u (%s) is persistent and will only be revoked from player.", instanceId, GetDifficultyString(static_cast<uint8>(difficulty)));
foundSomething = true;
}
plr->getPlayerInfo()->savedInstanceIdsLock.Release();
if (!foundSomething)
RedSystemMessage(m_session, "Player is not assigned to persistent instance with id %u.", instanceId);
return true;
}
else
{
RedSystemMessage(m_session, "Instance with id %u is persistent and can only be removed from player by admins.", instanceId);
return true;
}
}
if (instance->m_mapMgr && instance->m_mapMgr->HasPlayers())
{
RedSystemMessage(m_session, "Failed to reset non-persistent instance with id %u, due to player still inside.", instanceId);
return true;
}
if (instance->m_creatorGroup)
{
Group* group = plr->GetGroup();
if (group == NULL || instance->m_creatorGroup != group->GetID())
{
RedSystemMessage(m_session, "Player %s is not a member of the group assigned to the non-persistent instance with id %u.", plr->GetName(), instanceId);
return true;
}
}
else if (instance->m_creatorGuid == 0 || instance->m_creatorGuid != plr->GetLowGUID())
{
RedSystemMessage(m_session, "Player %s is not assigned to instance with id %u.", plr->GetName(), instanceId);
return true;
}
// tell player the instance was reset
WorldPacket data(SMSG_INSTANCE_RESET, 4);
data << instance->m_mapId;
plr->GetSession()->SendPacket(&data);
// shut down instance
sInstanceMgr.DeleteBattlegroundInstance(instance->m_mapId, instance->m_instanceId);
//.........这里部分代码省略.........
示例3: PreTeleport
//.........这里部分代码省略.........
{
m_mapLock.Release();
return INSTANCE_ABORT_NOT_FOUND;
}
m_instances[mapid] = new InstanceMap;
instancemap = m_instances[mapid];
}
else
{
InstanceMap::iterator itr;
// this is the case when we enter an already existing instance ( with summons for example )
if(instanceid != 0)
{
itr = instancemap->find(instanceid);
if(itr != instancemap->end())
{
in = itr->second;
if(!CHECK_INSTANCE_GROUP(in, pGroup))
{
// Another group is already playing in this instance of the dungeon...
m_mapLock.Release();
sChatHandler.SystemMessageToPlr(plr, "Another group is already inside this instance of the dungeon.");
return INSTANCE_ABORT_NOT_IN_RAID_GROUP;
}
// Try to add instance ID to player
plr->SetPersistentInstanceId(in);
// Set current group
if(pGroup)
in->m_creatorGroup = pGroup->GetID();
m_mapLock.Release();
return INSTANCE_OK;
}
else
{
m_mapLock.Release();
return INSTANCE_ABORT_NOT_FOUND;
}
}
else // this is the case when we enter the normal way (e.g. we enter thru the portal )
{
in = NULL;
if(pGroup != NULL) // we are in a group
{
uint32 grpdiff;
// We want to use the raid difficulty for raids, and dungeon difficulty for dungeons
if(inf->type == INSTANCE_RAID)
grpdiff = pGroup->m_raiddifficulty;
else
grpdiff = pGroup->m_difficulty;
if((inf->type == INSTANCE_MULTIMODE && grpdiff == MODE_HEROIC) || inf->type == INSTANCE_RAID)
{
// This is the case when we don't have this map on this difficulty saved yet for the player entering
if(plr->GetPersistentInstanceId(mapid, grpdiff) == 0)
{
// The group has this instance saved already so we will use it
if(pGroup->m_instanceIds[mapid][ grpdiff ] != 0)
{
示例4: HandleArenaJoin
//.........这里部分代码省略.........
return;
}
if((*itx)->m_loggedInPlayer)
{
ArenaTeam * t = (*itx)->m_loggedInPlayer->m_arenaTeams[arenateamtype];
if( t != NULL )
{
if ( team_id == 0 )
team_id = t->m_id;
if ( team_id != t->m_id )
{
m_session->SystemMessage("Sorry, not all your party members are in same arena team.");
pGroup->Unlock();
return;
}
}
else
{
m_session->SystemMessage("Sorry, not all your party members are in same arena team.");
pGroup->Unlock();
return;
}
if( (*itx)->m_loggedInPlayer->m_bgIsQueued )
BattlegroundManager.RemovePlayerFromQueues((*itx)->m_loggedInPlayer);
/*
if((*itx)->m_loggedInPlayer->m_bg || (*itx)->m_loggedInPlayer->m_bg || (*itx)->m_loggedInPlayer->m_bgIsQueued)
{
m_session->SystemMessage("One or more of your party members are already queued or inside a battleground.");
pGroup->Unlock();
return;
}
*/
--maxplayers;
}
}
if( maxplayers > 0 )
{
m_session->SystemMessage("Sorry, you have too few valid arena members in your group.");
pGroup->Unlock();
return;
}
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data << uint32(6); // all arenas
for(itx = pGroup->GetSubGroup(0)->GetGroupMembersBegin(); itx != pGroup->GetSubGroup(0)->GetGroupMembersEnd(); ++itx)
{
if((*itx)->m_loggedInPlayer)
{
SendBattlefieldStatus((*itx)->m_loggedInPlayer, 1, BattlegroundType, 0 , 0, 0,1);
(*itx)->m_loggedInPlayer->m_bgIsQueued = true;
(*itx)->m_loggedInPlayer->m_bgQueueInstanceId = 0;
(*itx)->m_loggedInPlayer->m_bgQueueType = BattlegroundType;
(*itx)->m_loggedInPlayer->GetSession()->SendPacket(&data);
(*itx)->m_loggedInPlayer->m_bgEntryPointX=(*itx)->m_loggedInPlayer->GetPositionX();
(*itx)->m_loggedInPlayer->m_bgEntryPointY=(*itx)->m_loggedInPlayer->GetPositionY();
(*itx)->m_loggedInPlayer->m_bgEntryPointZ=(*itx)->m_loggedInPlayer->GetPositionZ();
(*itx)->m_loggedInPlayer->m_bgEntryPointMap=(*itx)->m_loggedInPlayer->GetMapId();
}
}
pGroup->Unlock();
m_queueLock.Acquire();
m_queuedGroups[BattlegroundType].push_back(pGroup->GetID());
m_queueLock.Release();
Log.Success("BattlegroundMgr", "Group %u is now in battleground queue for arena type %u", pGroup->GetID(), BattlegroundType);
/* send the battleground status packet */
return;
}
}
/* Queue him! */
m_queueLock.Acquire();
m_queuedPlayers[BattlegroundType][lgroup].push_back(pguid);
Log.Success("BattlegroundMgr", "Player %u is now in battleground queue for {Arena %u}", m_session->GetPlayer()->GetLowGUID(), BattlegroundType );
/* send the battleground status packet */
SendBattlefieldStatus(m_session->GetPlayer(), 1, BattlegroundType, 0 , 0, 0,0);
m_session->GetPlayer()->m_bgIsQueued = true;
m_session->GetPlayer()->m_bgQueueInstanceId = 0;
m_session->GetPlayer()->m_bgQueueType = BattlegroundType;
/* Set battleground entry point */
m_session->GetPlayer()->m_bgEntryPointX = m_session->GetPlayer()->GetPositionX();
m_session->GetPlayer()->m_bgEntryPointY = m_session->GetPlayer()->GetPositionY();
m_session->GetPlayer()->m_bgEntryPointZ = m_session->GetPlayer()->GetPositionZ();
m_session->GetPlayer()->m_bgEntryPointMap = m_session->GetPlayer()->GetMapId();
m_session->GetPlayer()->m_bgEntryPointInstance = m_session->GetPlayer()->GetInstanceID();
m_queueLock.Release();
}
示例5: PreTeleport
//.........这里部分代码省略.........
}
else
{
// search all active instances and see if we have one here.
for(itr = instancemap->begin(); itr != instancemap->end();)
{
in = itr->second;
++itr;
//we have an instance,but do we own it?
uint8 owns = PlayerOwnsInstance(in, plr);
if( owns >= OWNER_CHECK_OK )
{
// check the player count and in combat status.
if(in->m_mapMgr && in->m_mapMgr->HasPlayers() && !plr->triggerpass_cheat)
{
if( in->m_mapMgr->IsCombatInProgress())
{
m_mapLock.Release();
return INSTANCE_ABORT_ENCOUNTER;
}
// check if we are full
if( in->m_mapMgr->GetPlayerCount() >= inf->playerlimit )
{
m_mapLock.Release();
return INSTANCE_ABORT_FULL;
}
}
uint32 plrdiff = map->israid() ? plr->iRaidType : plr->iInstanceType;
if(in->m_difficulty == plrdiff)
{
//wakeup call for saved instances
if(!in->m_mapMgr)
in->m_mapMgr = _CreateInstance(in);
if(owns == OWNER_CHECK_SAVED_OK && !in->m_mapMgr->HasPlayers())
{
if(plr->GetGroup())
in->m_creatorGroup = plr->GetGroupID();
}
// found our instance, allow him in.
m_mapLock.Release();
return INSTANCE_OK;
}
}
else
DEBUG_LOG("InstanceMgr","Check failed %s, return code %u",plr->GetName(), owns);
}
}
}
else
{
if(instanceid != 0)
{
// wtf, how can we have an instance_id for a mapid which doesn't even exist?
m_mapLock.Release();
return INSTANCE_ABORT_NOT_FOUND;
}
// this mapid hasn't been added yet, so we gotta create the hashmap now.
m_instances[mapid] = new InstanceMap;
instancemap = m_instances[mapid];
}
// if we're here, it means we need to create a new instance.
bool raid = map->israid();
in = new Instance;
in->m_creation = UNIXTIME;
in->m_expiration = (raid ? UNIXTIME + inf->cooldown : 0); // expire time 0 is 10 minutes after last player leaves
in->m_creatorGuid = plr->GetLowGUID();
in->m_creatorGroup = (pGroup ? pGroup->GetID() : 0);
in->m_difficulty = (raid ? plr->iRaidType : plr->iInstanceType);
in->m_instanceId = GenerateInstanceID();
in->m_mapId = mapid;
in->m_mapMgr = NULLMAPMGR; // always start off without a map manager, it is created in _CreateInstance(in)
//crash fix; GM's without group will start up raid instances as if they where nonraids
//this to avoid exipring check, this is mainly for developers purpose; GM's should NOT invite any players here!
if( plr->triggerpass_cheat && !plr->GetGroup() && raid)
{
const char * message = "Started this instance for development purposes only, do not invite players!!";
sEventMgr.AddEvent( plr, &Player::_Warn, message, EVENT_UNIT_SENDMESSAGE, 5000, 1, 0);
}
in->m_mapInfo = inf;
in->m_dbcMap = map;
in->m_isBattleground = false;
plr->SetInstanceID(in->m_instanceId);
DEBUG_LOG("InstanceMgr", "Prepared new %s %u for player %u and group %u on map %u with difficulty %u. (%u)", raid ? "Raid" : "Instance" ,in->m_instanceId, in->m_creatorGuid, in->m_creatorGroup, in->m_mapId, in->m_difficulty, in->m_instanceId);
// apply it in the instance map
instancemap->insert( InstanceMap::value_type( in->m_instanceId, in ) );
// create the actual instance (if we don't GetInstance() won't be able to access it).
in->m_mapMgr = _CreateInstance(in);
// instance created ok, i guess? return the ok for him to transport.
m_mapLock.Release();
return INSTANCE_OK;
}
示例6: EventQueueUpdate
//.........这里部分代码省略.........
if(!pGroup || !pGroup->m_isqueued || !pGroup->GetLeader() || pGroup->GetLeader()->arenaTeam[i - 4] == NULL) continue;
uint32 maxRange = pGroup->GetLeader()->arenaTeam[i - 4]->m_queueSearchRange;
pGroup->GetLeader()->arenaTeam[i - 4]->m_queueSearchRange += 100;
vector<uint32> inRangeGroups;
uint32 rating = pGroup->GetLeader()->arenaTeam[i - 4]->m_stat_rating;
for(itp = m_queuedGroups[i].begin(); itp != m_queuedGroups[i].end();)
{
Group * tGrp = objmgr.GetGroupById(*itp);
if(!tGrp || !tGrp->m_isqueued || !tGrp->GetLeader() || tGrp->GetLeader()->arenaTeam[i - 4] == NULL)
{
itp = m_queuedGroups[i].erase(itp);
continue;
}
++itp;
if( pGroup == tGrp )
continue;
uint32 tRating = tGrp->GetLeader()->arenaTeam[i - 4]->m_stat_rating;
int32 diff = (int32)tRating - (int32)rating;
if(diff < 0)
diff = -diff;
if(diff > (int32)maxRange)
continue;
//Log.Notice("Debug", "EventQueueUpdate added 1 in range arena");
inRangeGroups.push_back(tGrp->GetID());
}
// K, we have a giant list of groups that we could group with, hopefully!
// or not, we can't go on :(
if(!inRangeGroups.size())
continue;
// But if we're here, we can :D
uint32 r = 0;
if( inRangeGroups.size() > 1 )
r = RandomUInt((uint32)inRangeGroups.size() - 1);
Group * pairGroup = objmgr.GetGroupById(inRangeGroups[r]);
if(!pairGroup) continue;
// Now, let's create this rated Arena Match :)
//Log.Notice("Debug", "EventQueueUpdate creating arena");
Arena * arena = (Arena*)CreateInstance(i, LEVEL_GROUP_70);
ArenaTeam *pTeamPair[2];
if(arena)
{
//Log.Notice("Debug", "EventQueueUpdate arena created");
removegroups.push_back(pGroup->GetID());
removegroups.push_back(pairGroup->GetID());
pGroup->m_isqueued = false;
pairGroup->m_isqueued = false;
arena->rated_match = true;
if( pGroup->GetLeader()->arenaTeam[i - 4] != NULL )
{
arena->m_ratedTeams[0] = pGroup->GetLeader()->arenaTeam[i - 4]->m_id;
示例7: HandleResetInstanceCommand
bool ChatHandler::HandleResetInstanceCommand(const char* args, WorldSession *m_session)
{
uint32 instanceId = (args ? atoi(args) : 0);
if(instanceId == 0)
return false;
Player * plr = getSelectedChar(m_session, true);
if(!plr)
return true;
Instance *instance = sInstanceMgr.GetInstanceByIds(NUM_MAPS, instanceId);
if(instance == NULL)
{
RedSystemMessage(m_session, "There's no instance with id %u.", instanceId);
return true;
}
if(IS_PERSISTENT_INSTANCE(instance))
{
if(m_session->CanUseCommand('z'))
{
bool foundSomething = false;
plr->m_playerInfo->savedInstanceIdsLock.Acquire();
for(int difficulty=0; difficulty<NUM_INSTANCE_MODES; difficulty++)
{
PlayerInstanceMap::iterator itr = plr->m_playerInfo->savedInstanceIds[difficulty].find(instance->m_mapId);
if(itr == plr->m_playerInfo->savedInstanceIds[difficulty].end() || (*itr).second != instance->m_instanceId)
continue;
plr->SetPersistentInstanceId(instance->m_mapId, difficulty, 0);
SystemMessage(m_session, "Instance with id %u (%s) is persistent and will only be revoked from player.", instanceId, GetDifficultyString(difficulty));
foundSomething = true;
}
plr->m_playerInfo->savedInstanceIdsLock.Release();
if(!foundSomething)
RedSystemMessage(m_session, "Player is not assigned to persistent instance with id %u.", instanceId);
return true;
}
else
{
RedSystemMessage(m_session, "Instance with id %u is persistent and can only be removed from player by admins.", instanceId);
return true;
}
}
if(instance->m_mapMgr && instance->m_mapMgr->HasPlayers())
{
RedSystemMessage(m_session, "Failed to reset non-persistent instance with id %u, due to player still inside.", instanceId);
return true;
}
if(instance->m_creatorGroup)
{
Group *group = plr->GetGroup();
if(group == NULL || instance->m_creatorGroup != group->GetID())
{
RedSystemMessage(m_session, "Player %s is not a member of the group assigned to the non-persistent instance with id %u.", plr->GetName(), instanceId);
return true;
}
}
else if(instance->m_creatorGuid == 0 || instance->m_creatorGuid != plr->GetLowGUID())
{
RedSystemMessage(m_session, "Player %s is not assigned to instance with id %u.", plr->GetName(), instanceId);
return true;
}
//TODO: Reset that instance...^^
RedSystemMessage(m_session, "Resetting single non-persistent instances is not available yet.");
sGMLog.writefromsession(m_session, "used reset instance command on %s, instance %u,", plr->GetName(), instanceId);
return true;
}
示例8: PreTeleport
//.........这里部分代码省略.........
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());
}
}
}
else
{
if(instanceid != 0)
{
return INSTANCE_ABORT_NOT_FOUND;
}
// gotta create the hashmap.
m_instances[mapid] = new InstanceMap;
instancemap = m_instances[mapid];
}
// if we're here, it means we need to create a new instance.
in = new Instance;
in->m_creation = UNIXTIME;
in->m_expiration = (inf->type == INSTANCE_NONRAID) ? 0 : UNIXTIME + inf->cooldown; // expire time 0 is 10 minutes after last player leaves
in->m_creatorGuid = pGroup ? 0 : plr->GetLowGUID(); // creator guid is 0 if its owned by a group.
in->m_creatorGroup = pGroup ? pGroup->GetID() : 0;
in->m_difficulty = plr->iInstanceType;
in->m_instanceId = GenerateInstanceID();
in->m_mapId = mapid;
in->m_mapMgr = NULLMAPMGR; // always start off without a map manager, it is created in GetInstance()
//crash fix; GM's without group will start up raid instances as if they where nonraids
//this to avoid exipring check, this is mainly for developers purpose; GM's should NOT invite any players here!
if( plr->triggerpass_cheat && !plr->GetGroup() && inf->type == INSTANCE_RAID)
{
inf->type = INSTANCE_NONRAID;
sGMLog.writefromsession(plr->GetSession(), "Started a raid instance %d [%s] as non_raid instance.", mapid, inf->name);
DEBUG_LOG("InstanceMgr","Started a raid instance %d [%s] as non_raid instance.", mapid, inf->name);
}
in->m_mapInfo = inf;
in->m_isBattleground=false;
plr->SetInstanceID(in->m_instanceId);
if( plr->GetGroup() && !plr->GetSession()->HasGMPermissions())//GM should not set the instanceID
pGroup->SetGroupInstanceID(in->m_instanceId);
DEBUG_LOG("InstanceMgr", "Prepared new instance %u for player %u and group %u on map %u. (%u)",in->m_instanceId, in->m_creatorGuid, in->m_creatorGroup, in->m_mapId, in->m_instanceId);
// apply it in the instance map
instancemap->insert( InstanceMap::value_type( in->m_instanceId, in ) );
// create the actual instance (if we don't GetInstance() won't be able to access it).
in->m_mapMgr = _CreateInstance(in);
// instance created ok, i guess? return the ok for him to transport.
m_mapLock.Release();
return INSTANCE_OK;
}
示例9: HandleGroupAcceptOpcode
////////////////////////////////////////////////////////////////
///This function handles CMSG_GROUP_ACCEPT and deny:
////////////////////////////////////////////////////////////////
void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data )
{
if(!_player->IsInWorld())
{
return;
}
uint8 packet_type;
recv_data >> packet_type;
if( packet_type == 0 ) //0x80 for group accept and 0 is for decline
{
HandleGroupDeclineOpcode( recv_data );
return;
}
Player *player = objmgr.GetPlayer(_player->GetInviter());
if ( !player )
{
return;
}
//check if this invite is still valid
if( player->GetInviter() != _player->GetLowGUID() || _player->GetInviter() != player->GetLowGUID() )
{
_player->BroadcastMessage( "Group invite from player %s expired", player->GetName() );
player->BroadcastMessage( "Group invite from player %s expired", _player->GetName() );
return;
}
player->SetInviter(0);
_player->SetInviter(0);
Group *grp = player->GetGroup();
if(grp)
{
grp->AddMember(_player->m_playerInfo);
_player->dungeon_difficulty = grp->dungeon_difficulty;
_player->raid_difficulty = grp->raid_difficulty;
_player->SendDungeonDifficulty();
_player->SendRaidDifficulty();
//sInstanceSavingManager.ResetSavedInstancesForPlayer(_player);
return;
}
// If we're this far, it means we have no existing group, and have to make one.
grp = new Group(true);
grp->dungeon_difficulty = player->dungeon_difficulty;
grp->raid_difficulty = player->raid_difficulty;
grp->AddMember(player->m_playerInfo); // add the inviter first, therefore he is the leader
grp->AddMember(_player->m_playerInfo); // add us.
_player->dungeon_difficulty = grp->dungeon_difficulty;
_player->raid_difficulty = grp->raid_difficulty;
_player->SendDungeonDifficulty();
_player->SendRaidDifficulty();
Instance *instance = sInstanceMgr.GetInstanceByIds(player->GetMapId(), player->GetInstanceID());
if(instance != NULL && instance->m_creatorGuid == player->GetLowGUID())
{
grp->AddSavedInstance(instance->m_mapId,instance->instance_difficulty,instance->m_instanceId);
instance->m_creatorGroup = grp->GetID();
instance->m_creatorGuid = 0;
instance->SaveToDB();
}
//sInstanceSavingManager.ResetSavedInstancesForPlayer(_player);
// Currentgroup and all that shit are set by addmember.
}
示例10: RemovePlayerFromQueues
void CBattlegroundManager::RemovePlayerFromQueues(Player* plr)
{
m_queueLock.Acquire();
ARCEMU_ASSERT(plr->m_bgQueueType < BATTLEGROUND_NUM_TYPES);
sEventMgr.RemoveEvents(plr, EVENT_BATTLEGROUND_QUEUE_UPDATE);
uint32 lgroup = GetLevelGrouping(plr->getLevel());
list<uint32>::iterator itr;
itr = m_queuedPlayers[plr->m_bgQueueType][lgroup].begin();
while (itr != m_queuedPlayers[plr->m_bgQueueType][lgroup].end())
{
if ((*itr) == plr->GetLowGUID())
{
Log.Debug("BattlegroundManager", "Removing player %u from queue instance %u type %u", plr->GetLowGUID(), plr->m_bgQueueInstanceId, plr->m_bgQueueType);
m_queuedPlayers[plr->m_bgQueueType][lgroup].erase(itr);
break;
}
++itr;
}
plr->m_bgIsQueued = false;
plr->m_bgTeam = plr->GetTeam();
plr->m_pendingBattleground = NULL;
SendBattlefieldStatus(plr, BGSTATUS_NOFLAGS, 0, 0, 0, 0, 0);
m_queueLock.Release();
Group* group;
group = plr->GetGroup();
if (group) //if da niggas in a group, boot dis bitch ass' group outa da q
{
Log.Debug("BattlegroundManager", "Player %u removed whilst in a group. Removing players group %u from queue", plr->GetLowGUID(), group->GetID());
RemoveGroupFromQueues(group);
}
}
示例11: HandleArenaJoin
//.........这里部分代码省略.........
case BATTLEGROUND_ARENA_2V2:
default:
maxplayers = 2;
break;
}
if (pGroup->GetLeader()->m_loggedInPlayer && pGroup->GetLeader()->m_loggedInPlayer->m_arenaTeams[type] == NULL)
{
m_session->SendNotInArenaTeamPacket(uint8(maxplayers));
return;
}
pGroup->Lock();
for (itx = pGroup->GetSubGroup(0)->GetGroupMembersBegin(); itx != pGroup->GetSubGroup(0)->GetGroupMembersEnd(); ++itx)
{
if (maxplayers == 0)
{
m_session->SystemMessage(m_session->LocalizedWorldSrv(58));
pGroup->Unlock();
return;
}
if ((*itx)->lastLevel < PLAYER_ARENA_MIN_LEVEL)
{
m_session->SystemMessage(m_session->LocalizedWorldSrv(59));
pGroup->Unlock();
return;
}
if ((*itx)->m_loggedInPlayer)
{
if ((*itx)->m_loggedInPlayer->m_bg || (*itx)->m_loggedInPlayer->m_bgIsQueued)
{
m_session->SystemMessage(m_session->LocalizedWorldSrv(60));
pGroup->Unlock();
return;
};
if ((*itx)->m_loggedInPlayer->m_arenaTeams[type] != pGroup->GetLeader()->m_loggedInPlayer->m_arenaTeams[type])
{
m_session->SystemMessage(m_session->LocalizedWorldSrv(61));
pGroup->Unlock();
return;
}
--maxplayers;
}
}
WorldPacket data(SMSG_GROUP_JOINED_BATTLEGROUND, 4);
data << uint32(6); // all arenas
for (itx = pGroup->GetSubGroup(0)->GetGroupMembersBegin(); itx != pGroup->GetSubGroup(0)->GetGroupMembersEnd(); ++itx)
{
if ((*itx)->m_loggedInPlayer)
{
SendBattlefieldStatus((*itx)->m_loggedInPlayer, BGSTATUS_INQUEUE, BattlegroundType, 0, 0, 0, 1);
(*itx)->m_loggedInPlayer->m_bgIsQueued = true;
(*itx)->m_loggedInPlayer->m_bgQueueInstanceId = 0;
(*itx)->m_loggedInPlayer->m_bgQueueType = BattlegroundType;
(*itx)->m_loggedInPlayer->GetSession()->SendPacket(&data);
(*itx)->m_loggedInPlayer->m_bgEntryPointX = (*itx)->m_loggedInPlayer->GetPositionX();
(*itx)->m_loggedInPlayer->m_bgEntryPointY = (*itx)->m_loggedInPlayer->GetPositionY();
(*itx)->m_loggedInPlayer->m_bgEntryPointZ = (*itx)->m_loggedInPlayer->GetPositionZ();
(*itx)->m_loggedInPlayer->m_bgEntryPointMap = (*itx)->m_loggedInPlayer->GetMapId();
}
}
pGroup->Unlock();
m_queueLock.Acquire();
m_queuedGroups[BattlegroundType].push_back(pGroup->GetID());
m_queueLock.Release();
Log.Notice("BattlegroundMgr", "Group %u is now in battleground queue for arena type %u", pGroup->GetID(), BattlegroundType);
/* send the battleground status packet */
return;
}
}
/* Queue him! */
m_queueLock.Acquire();
m_queuedPlayers[BattlegroundType][lgroup].push_back(pguid);
Log.Notice("BattlegroundMgr", "Player %u is now in battleground queue for {Arena %u}", m_session->GetPlayer()->GetLowGUID(), BattlegroundType);
/* send the battleground status packet */
SendBattlefieldStatus(m_session->GetPlayer(), BGSTATUS_INQUEUE, BattlegroundType, 0, 0, 0, 0);
m_session->GetPlayer()->m_bgIsQueued = true;
m_session->GetPlayer()->m_bgQueueInstanceId = 0;
m_session->GetPlayer()->m_bgQueueType = BattlegroundType;
/* Set battleground entry point */
m_session->GetPlayer()->m_bgEntryPointX = m_session->GetPlayer()->GetPositionX();
m_session->GetPlayer()->m_bgEntryPointY = m_session->GetPlayer()->GetPositionY();
m_session->GetPlayer()->m_bgEntryPointZ = m_session->GetPlayer()->GetPositionZ();
m_session->GetPlayer()->m_bgEntryPointMap = m_session->GetPlayer()->GetMapId();
m_session->GetPlayer()->m_bgEntryPointInstance = m_session->GetPlayer()->GetInstanceID();
m_queueLock.Release();
}
示例12: GetRewardingGroup
//Yeahlight: Searches for the group that will be rewarded with exp and first loot rights
returnGroup HateList::GetRewardingGroup()
{
groupDamage groupsToConsider[255] = {0};
int16 groupCounter = 0;
int16 groupID = 0;
int16 leadingGroupID = 0;
sint32 highestGroupDamage = 0;
sint32 entityDamage = 0;
Mob* entity = NULL;
returnGroup groupToReward;
Group* group = NULL;
bool groupFound = false;
for(int i = 0; i < 255; i++)
{
groupsToConsider[i].groupID = -1;
groupsToConsider[i].groupDamageTotal = -1;
}
groupToReward.damage = 0;
groupToReward.group = NULL;
LinkedListIterator<tHateEntry*> iterator(list);
iterator.Reset();
while(iterator.MoreElements())
{
entityDamage = 0;
if(iterator.GetData())
entityDamage = iterator.GetData()->damage;
if(entityDamage > 0)
{
entity = iterator.GetData()->ent;
//Yeahlight: Entity exists in the zone
if(entity)
{
//Yeahlight: Entity is a client
if(entity->IsClient())
{
//Yeahlight: PC is grouped
if(entity->CastToClient()->IsGrouped())
{
group = entity_list.GetGroupByClient(entity->CastToClient());
//Yeahlight: Group exists
if(group)
{
groupID = group->GetID();
//Yeahlight: We do not have a group list started yet, so start it off with this group
if(groupCounter == 0)
{
groupsToConsider[0].groupID = groupID;
groupsToConsider[0].groupDamageTotal = iterator.GetData()->damage;
groupsToConsider[0].group = group;
groupCounter++;
}
//Yeahlight: A group list has been created already
else
{
//Yeahlight: Iterate through the group list
for(int i = 0; i < groupCounter; i++)
{
//Yeahlight: Found the group for which this PC resides
if(groupID == groupsToConsider[i].groupID)
{
//Yeahlight: Add the client's damage to the group's total
groupsToConsider[i].groupDamageTotal += iterator.GetData()->damage;
//Yeahlight: Flag the PC as found
groupFound = true;
//Yeahlight: "Break out" of the loop
i = groupCounter;
}
}
//Yeahlight: This grouped PC did not find their group in the list, so we need to add their group
if(!groupFound)
{
groupsToConsider[groupCounter].groupID = groupID;
groupsToConsider[groupCounter].groupDamageTotal = iterator.GetData()->damage;
groupsToConsider[groupCounter].group = group;
groupCounter++;
}
}
}
//Yeahlight: Group does not exist
else
{
}
}
//Yeahlight: PC is not grouped
else
{
}
}
//Yeahlight: Entity is the pet of a client
else if(entity->IsNPC() && entity->GetOwner() && entity->GetOwner()->IsClient())
{
//Yeahlight: Owner of the pet is grouped
if(entity->GetOwner()->CastToClient()->IsGrouped())
{
group = entity_list.GetGroupByClient(entity->GetOwner()->CastToClient());
//.........这里部分代码省略.........
示例13: ResetSavedInstances
void InstanceMgr::ResetSavedInstances(Player * plr)
{
WorldPacket *pData;
Instance * in;
InstanceMap::iterator itr;
InstanceMap * instancemap;
uint32 i;
if (!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL)
return;
m_mapLock.Acquire();
Group *group = plr->GetGroup();
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 (IS_RESETABLE_INSTANCE(in) && ((group && group->GetID() == in->m_creatorGroup) || plr->GetLowGUID() == in->m_creatorGuid))
{
if (in->m_mapMgr && in->m_mapMgr->HasPlayers())
{
pData = new WorldPacket(SMSG_INSTANCE_RESET_FAILED, 8);
*pData << uint32(INSTANCE_RESET_ERROR_PLAYERS_INSIDE);
*pData << uint32(in->m_mapId);
plr->GetSession()->SendPacket(pData);
delete pData;
continue;
}
if (group)
{
group->m_instanceIds[in->m_mapId][in->m_difficulty] = 0;
}
// <mapid> has been reset.
pData = new WorldPacket(SMSG_INSTANCE_RESET, 4);
*pData << uint32(in->m_mapId);
plr->GetSession()->SendPacket(pData);
delete pData;
// destroy the instance
_DeleteInstance(in, true);
}
}
}
}
m_mapLock.Release();
/* plr->m_playerInfo->savedInstanceIdsLock.Acquire();
for(int difficulty=0; difficulty<NUM_INSTANCE_MODES; difficulty++)
{
PlayerInstanceMap::iterator itr,itr2=plr->m_playerInfo->savedInstanceIds[difficulty].begin();
for(; itr2 != plr->m_playerInfo->savedInstanceIds[difficulty].end();)
{
itr = itr2;
itr2++;
in = sInstanceMgr.GetInstanceByIds((*itr).first, (*itr).second);
if( !in )
continue;
if(((group && group->GetID() == in->m_creatorGroup) || plr->GetLowGUID() == in->m_creatorGuid))
{
if(in->m_mapMgr && in->m_mapMgr->HasPlayers())
{
pData = new WorldPacket(SMSG_RESET_INSTANCE_FAILED, 8);
*pData << uint32(INSTANCE_RESET_ERROR_PLAYERS_INSIDE);
*pData << uint32(in->m_mapId);
plr->GetSession()->SendPacket(pData);
delete pData;
continue;
}
if(group)
{
group->m_instanceIds[in->m_mapId][in->m_difficulty] = 0;
}
// <mapid> has been reset.
pData = new WorldPacket(SMSG_RESET_INSTANCE, 4);
*pData << uint32(in->m_mapId);
plr->GetSession()->SendPacket(pData);
delete pData;
//remove instance from player
plr->SetPersistentInstanceId(in->m_mapId, difficulty, 0);
// destroy the instance
_DeleteInstance(in, true);
}
}
}
plr->m_playerInfo->savedInstanceIdsLock.Release();*/
}
示例14: PreTeleport
uint32 InstanceMgr::PreTeleport(uint32 mapid, Player * plr, uint32 instanceid)
{
// preteleport is where all the magic happens :P instance creation, etc.
MapInfo * inf = WorldMapInfoStorage.LookupEntry(mapid);
Group * pGroup;
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;
pGroup = plr->GetGroup();
// players without groups cannot enter raids and heroic instances
if (pGroup == NULL && (inf->type == INSTANCE_RAID || (inf->type == INSTANCE_MULTIMODE && plr->iInstanceType >= MODE_HEROIC)) && !plr->TriggerpassCheat)
return INSTANCE_ABORT_NOT_IN_RAID_GROUP;
// players without raid groups cannot enter raid instances
if (pGroup != NULL && pGroup->GetGroupType() != GROUP_TYPE_RAID && inf->type == INSTANCE_RAID && !plr->TriggerpassCheat)
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 == NULL)
{
if (instanceid != 0)
{
m_mapLock.Release();
return INSTANCE_ABORT_NOT_FOUND;
}
// gotta create the hashmap.
m_instances[mapid] = new InstanceMap;
instancemap = m_instances[mapid];
}
else
{
InstanceMap::iterator itr;
if (instanceid != 0)
{
itr = instancemap->find(instanceid);
if (itr != instancemap->end())
{
in = itr->second;
if (!CHECK_INSTANCE_GROUP(in, pGroup))
{
// Another group is already playing in this instance of the dungeon...
m_mapLock.Release();
sChatHandler.SystemMessageToPlr(plr, "Another group is already inside this instance of the dungeon.");
return INSTANCE_ABORT_NOT_IN_RAID_GROUP;
}
// Try to add instance ID to player
plr->SetPersistentInstanceId(in);
// Set current group
if (pGroup)
in->m_creatorGroup = pGroup->GetID();
m_mapLock.Release();
return INSTANCE_OK;
}
else
{
m_mapLock.Release();
return INSTANCE_ABORT_NOT_FOUND;
}
}
else
{
in = NULL;
if (pGroup != NULL)
{
if ((inf->type == INSTANCE_MULTIMODE && pGroup->m_difficulty >= MODE_HEROIC) || inf->type == INSTANCE_RAID)
{
if (plr->GetPersistentInstanceId(mapid, pGroup->m_difficulty) == 0)
//.........这里部分代码省略.........