本文整理汇总了C++中PlayerPointer::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerPointer::GetName方法的具体用法?C++ PlayerPointer::GetName怎么用?C++ PlayerPointer::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerPointer
的用法示例。
在下文中一共展示了PlayerPointer::GetName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnQuestComplete
void OnQuestComplete( PlayerPointer mTarget, QuestLogEntry * qLogEntry)
{
if( mTarget == NULL || mTarget->GetMapMgr() == NULL || mTarget->GetMapMgr()->GetInterface() == NULL )
return;
float SSX = mTarget->GetPositionX();
float SSY = mTarget->GetPositionY();
float SSZ = mTarget->GetPositionZ();
GameObjectPointer skull1 = mTarget->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(SSX, SSY, SSZ, 2551);
if(skull1)
return;
CreaturePointer Kin_weelay = mTarget->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(SSX, SSY, SSZ, 2519);
if(Kin_weelay == NULL)
return;
string msg1 = "Ah. Good ";
msg1 += mTarget->GetName();
msg1 += ". Now let us see what tale these heads tell...";
Kin_weelay->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, msg1.c_str());
Kin_weelay->CastSpell(Kin_weelay, dbcSpell.LookupEntry(3644), false);
skull1->Despawn(5000);
GameObjectPointer skull2 = mTarget->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords(SSX, SSY, SSZ, 2551);
if(skull2)
skull2->Despawn(5000);
if(Kin_weelay == NULL)
return;
string msg = "There, ";
msg += mTarget->GetName();
msg += ". You may now speak to the Bloodscalp chief and his witchdoctor.";
sEventMgr.AddEvent(TO_UNIT(Kin_weelay), &Creature::SendChatMessage, (uint8)CHAT_MSG_MONSTER_SAY, (uint32)LANG_UNIVERSAL, msg.c_str(), EVENT_UNIT_CHAT_MSG, 500, 1, 1);
}
示例2: 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() );
}
示例3: 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;
}
示例4: HandleResetReputationCommand
bool ChatHandler::HandleResetReputationCommand(const char *args, WorldSession *m_session)
{
PlayerPointer plr = getSelectedChar(m_session);
if(!plr)
{
SystemMessage(m_session, "Select a player or yourself first.");
return true;
}
plr->_InitialReputation();
SystemMessage(m_session, "Done. Relog for changes to take effect.");
sGMLog.writefromsession(m_session, "used reset reputation for %s", plr->GetName());
return true;
}
示例5: Invite
void Channel::Invite(ObjectGuid p, const char *newname)
{
if (!IsOn(p))
{
WorldPacket data;
MakeNotMember(&data);
SendToOne(&data, p);
return;
}
PlayerPointer newp = GetPlayer(newname);
if (!newp)
{
WorldPacket data;
MakePlayerNotFound(&data, newname);
SendToOne(&data, p);
return;
}
PlayerPointer plr = GetPlayer(p);
if (!plr.get())
return;
if (newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
{
WorldPacket data;
MakeInviteWrongFaction(&data);
SendToOne(&data, p);
return;
}
if (IsOn(newp->GetObjectGuid()))
{
WorldPacket data;
MakePlayerAlreadyMember(&data, newp->GetObjectGuid());
SendToOne(&data, p);
return;
}
WorldPacket data;
if (!newp->GetSocial()->HasIgnore(p))
{
MakeInvite(&data, p);
SendToOne(&data, newp->GetObjectGuid());
data.clear();
}
MakePlayerInvited(&data, newp->GetName());
SendToOne(&data, p);
}
示例6: 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;
}
示例7: HandleInvincibleCommand
bool ChatHandler::HandleInvincibleCommand(const char *args, WorldSession *m_session)
{
PlayerPointer chr = getSelectedChar(m_session);
char msg[100];
if(chr)
{
chr->bInvincible = !chr->bInvincible;
snprintf(msg, 100, "Invincibility is now %s", chr->bInvincible ? "ON. You may have to leave and re-enter this zone for changes to take effect." : "OFF. Exit and re-enter this zone for this change to take effect.");
} else {
snprintf(msg, 100, "Select a player or yourself first.");
}
if(chr!=m_session->GetPlayer()&&chr)
sGMLog.writefromsession(m_session, "toggled invincibility on %s", chr->GetName());
SystemMessage(m_session, msg);
return true;
}
示例8: HandleGuildDecline
void WorldSession::HandleGuildDecline(WorldPacket & recv_data)
{
WorldPacket data;
PlayerPointer plyr = GetPlayer();
if(!plyr)
return;
PlayerPointer inviter = objmgr.GetPlayer( plyr->GetGuildInvitersGuid() );
plyr->UnSetGuildInvitersGuid();
if(!inviter)
return;
data.Initialize(SMSG_GUILD_DECLINE);
data << plyr->GetName();
inviter->GetSession()->SendPacket(&data);
}
示例9: OnQuestStart
void OnQuestStart(PlayerPointer mTarget, QuestLogEntry * qLogEntry)
{
if( !mTarget || !mTarget->GetMapMgr() || !mTarget->GetMapMgr()->GetInterface() )
return;
Yor = sEAS.SpawnCreature( mTarget, 17393, -4634.246582f, -13071.686523f, -14.755350f, 1.569997f, 0 );
if( !Yor )
return;
Yor->CastSpell( Yor, 25035, true ); // Apparition Effect
Yor->m_escorter = mTarget;
Yor->GetAIInterface()->StopMovement( 1000 );
Yor->SetUInt32Value( UNIT_NPC_FLAGS, 0 );
char msg[256];
snprintf((char*)msg, 256, "Come, %s . Let us leave the water together, purified.", mTarget->GetName() );
Yor->SendChatMessage( CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, msg );
sEAS.CreateCustomWaypointMap( Yor );
sEAS.WaypointCreate( Yor, -4650.081055f, -13016.692383f, 1.776296f, 2.021601f, 0, 256, 16393 );
sEAS.WaypointCreate( Yor, -3886.341553f, -13098.914063f, 3.964841f, 1.855801f, 1000, 256, 16393 );
sEAS.WaypointCreate( Yor, -4677.421387f, -12983.874023f, 0.833827f, 2.335760f, 0, 256, 16393 ); // Should look player
sEAS.EnableWaypoints( Yor );
//We have to set up these pointers first to resolve ambiguity in the event manager template
UnitPointer Totem = TO_UNIT(Yor);
UnitPointer Plr = TO_UNIT(mTarget);
// Change to Stillpine form
sEventMgr.AddEvent(Totem, &Unit::EventCastSpell, Totem, dbcSpell.LookupEntry(30446), EVENT_CREATURE_UPDATE, 15500, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
string msg2 = "[Furbolg] We go now, together. We will seek Vark.";
sEventMgr.AddEvent(Totem, &Unit::SendChatMessage, (uint8)CHAT_MSG_MONSTER_SAY, (uint32)LANG_UNIVERSAL, msg2.c_str(), EVENT_UNIT_CHAT_MSG, 26500, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
// Change to nightsaber form
sEventMgr.AddEvent(Totem, &Unit::EventCastSpell, Totem, dbcSpell.LookupEntry(30448), EVENT_CREATURE_UPDATE, 30000, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
string msg3 = "[Furbolg] Follow me to Vark.";
sEventMgr.AddEvent(Totem, &Unit::SendChatMessage, (uint8)CHAT_MSG_MONSTER_SAY, (uint32)LANG_UNIVERSAL, msg3.c_str(), EVENT_UNIT_CHAT_MSG, 31000, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
if( mTarget->CalcDistance( Totem, Plr ) <= 10 )
sEventMgr.AddEvent(Totem, &Unit::EventCastSpell, Plr, dbcSpell.LookupEntry(30448), EVENT_CREATURE_UPDATE, 31000, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
}
示例10: HandleAcceptTrade
void WorldSession::HandleAcceptTrade(WorldPacket & recv_data)
{
if(!_player->IsInWorld() || _player->mTradeTarget == 0)
return;
uint32 TradeStatus = TRADE_STATUS_ACCEPTED;
PlayerPointer pTarget = _player->GetTradeTarget();
if(pTarget == NULL || !pTarget->IsInWorld())
TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;
// Tell the other player we're green.
if(pTarget->m_session && pTarget->m_session->GetSocket())
pTarget->m_session->SendTradeStatus(TradeStatus);
_player->mTradeStatus = TradeStatus;
//Both sides accepted? Let's trade!
if(_player->mTradeStatus == TRADE_STATUS_ACCEPTED && pTarget->mTradeStatus == TRADE_STATUS_ACCEPTED)
{
// Ready!
uint32 ItemCount = 0;
uint32 TargetItemCount = 0;
ItemPointer pItem;
// Count items on both sides, check if bags are empty.
for(uint32 Index = 0; Index < 6; ++Index)
{
if(_player->mTradeItems[Index] != NULL)
{
pItem = _player->mTradeItems[Index];
if( pItem != NULL && pItem->IsContainer() && TO_CONTAINER(pItem)->HasItems())
{
sCheatLog.writefromsession(this, "%s involved in bag-trick trade with %s", _player->GetName(),pTarget->GetName());
_player->GetItemInterface()->BuildInventoryChangeError( pItem, NULLITEM, INV_ERR_CANT_TRADE_EQUIP_BAGS);
TradeStatus = TRADE_STATUS_CANCELLED;
break;
}
else
++ItemCount;
}
if(pTarget->mTradeItems[Index] != NULL)
{
pItem = pTarget->mTradeItems[Index];
if( pItem != NULL && pItem->IsContainer() && TO_CONTAINER(pItem)->HasItems() )
{
sCheatLog.writefromsession(this, "%s involved in bag-trick trade with %s.", pTarget->GetName(),_player->GetName());
pTarget->GetItemInterface()->BuildInventoryChangeError( pItem, NULLITEM, INV_ERR_CANT_TRADE_EQUIP_BAGS);
TradeStatus = TRADE_STATUS_CANCELLED;
break;
}
else
++TargetItemCount;
}
}
//Do we have something to trade?
if( ItemCount == 0 && TargetItemCount == 0 && _player->mTradeGold == 0 && pTarget->mTradeGold == 0 )
TradeStatus = TRADE_STATUS_CANCELLED;
//Do we have enough free slots on both sides?
else if((_player->m_ItemInterface->CalculateFreeSlots(NULL) + ItemCount) < TargetItemCount || (pTarget->m_ItemInterface->CalculateFreeSlots(NULL) + TargetItemCount) < ItemCount )
TradeStatus = TRADE_STATUS_CANCELLED;
//Everything still ok?
else if(TradeStatus == TRADE_STATUS_ACCEPTED)
{
uint64 Guid;
//Swapp 6 itemslots (7th will not trade)
for(uint32 Index = 0; Index < 6; ++Index)
{
Guid = _player->mTradeItems[Index] ? _player->mTradeItems[Index]->GetGUID() : 0;
if(Guid != 0)
{
if( _player->mTradeItems[Index]->IsSoulbound())
_player->GetItemInterface()->BuildInventoryChangeError( _player->mTradeItems[Index], NULLITEM, INV_ERR_CANNOT_TRADE_THAT);
else
{
//Remove from player
pItem = _player->m_ItemInterface->SafeRemoveAndRetreiveItemByGuidRemoveStats(Guid, true);
//and add to pTarget
if(pItem != NULL)
{
pItem->SetOwner(pTarget);
if( !pTarget->m_ItemInterface->AddItemToFreeSlot(pItem) )
{
pItem->Destructor();
pItem = NULLITEM;
}
}
if(GetPermissionCount()>0 || pTarget->GetSession()->GetPermissionCount()>0)
sGMLog.writefromsession(this, "trade item %s with %s (soulbound = %d)", _player->mTradeItems[Index]->GetProto()->Name1, pTarget->GetName());
}
}
Guid = pTarget->mTradeItems[Index] ? pTarget->mTradeItems[Index]->GetGUID() : 0;
if(Guid != 0)
{
if( pTarget->mTradeItems[Index]->IsSoulbound())
pTarget->GetItemInterface()->BuildInventoryChangeError( pTarget->mTradeItems[Index], NULLITEM, INV_ERR_CANNOT_TRADE_THAT);
//.........这里部分代码省略.........
示例11: AssaultControlPoint
void ArathiBasin::AssaultControlPoint(PlayerPointer pPlayer, uint32 Id)
{
#if defined(BG_ANTI_CHEAT) && !defined(_DEBUG)
if(!m_started)
{
SendChatMessage(CHAT_MSG_BG_SYSTEM_NEUTRAL, pPlayer->GetGUID(), "%s has been removed from the game for cheating.", pPlayer->GetName());
pPlayer->SoftDisconnect();
return;
}
#endif
bool isVirgin = false;
uint32 Team = pPlayer->m_bgTeam;
uint32 Owner;
if(m_basesOwnedBy[Id]==-1 && m_basesAssaultedBy[Id]==-1)
{
isVirgin = true;
// omgwtfbbq our flag is a virgin?
m_mapMgr->GetStateManager().UpdateWorldState(NeutralFields[Id], 0);
}
if(m_basesOwnedBy[Id] != -1)
{
Owner = m_basesOwnedBy[Id];
// set it to uncontrolled for now
m_basesOwnedBy[Id] = -1;
// this control point just got taken over by someone! oh noes!
if( m_spiritGuides[Id] != NULL )
{
map<CreaturePointer,set<uint32> >::iterator itr = m_resurrectMap.find(m_spiritGuides[Id]);
if( itr != m_resurrectMap.end() )
{
for( set<uint32>::iterator it2 = itr->second.begin(); it2 != itr->second.end(); ++it2 )
{
PlayerPointer r_plr = m_mapMgr->GetPlayer( *it2 );
if( r_plr != NULL && r_plr->isDead() )
{
HookHandleRepop( r_plr );
QueueAtNearestSpiritGuide(r_plr, itr->first);
}
}
}
m_resurrectMap.erase( itr );
m_spiritGuides[Id]->Despawn( 0, 0 );
m_spiritGuides[Id] = NULLCREATURE;
}
// detract one from the teams controlled points
m_capturedBases[Owner] -= 1;
m_mapMgr->GetStateManager().UpdateWorldState(Owner ? WORLDSTATE_AB_HORDE_CAPTUREBASE : WORLDSTATE_AB_ALLIANCE_CAPTUREBASE, m_capturedBases[Owner]);
// reset the world states
m_mapMgr->GetStateManager().UpdateWorldState(OwnedFields[Id][Owner], 0);
// modify the resource update time period
if(m_capturedBases[Owner]==0)
this->event_RemoveEvents(EVENT_AB_RESOURCES_UPDATE_TEAM_0+Owner);
else
this->event_ModifyTime(EVENT_AB_RESOURCES_UPDATE_TEAM_0 + Owner, ResourceUpdateIntervals[m_capturedBases[Owner]]);
}
// Contested Flag, not ours, and is not virgin
uint32 otherTeam = Team ? 0 : 1;
if( !isVirgin && m_basesLastOwnedBy[Id] == Team && m_basesOwnedBy[Id] == -1 )
{
m_mapMgr->GetStateManager().UpdateWorldState(AssaultFields[Id][Team ? 0 : 1], 0);
this->event_RemoveEvents(EVENT_AB_CAPTURE_CP_1 + Id);
SendChatMessage(Team ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE, pPlayer->GetGUID(), "$N has defended the %s!", ControlPointNames[Id]);
m_basesAssaultedBy[Id] = Team;
CaptureControlPoint( Id, Team );
return;
}
// nigga stole my flag!
if(m_basesAssaultedBy[Id] != -1)
{
Owner = m_basesAssaultedBy[Id];
// woah! vehicle hijack!
m_basesAssaultedBy[Id] = Team;
m_mapMgr->GetStateManager().UpdateWorldState(AssaultFields[Id][Owner], 0);
// make sure the event does not trigger
sEventMgr.RemoveEvents(shared_from_this(), EVENT_AB_CAPTURE_CP_1 + Id);
// no need to remove the spawn, SpawnControlPoint will do this.
}
m_basesAssaultedBy[Id] = Team;
// spawn the new control point gameobject
SpawnControlPoint(Id, Team ? AB_SPAWN_TYPE_HORDE_ASSAULT : AB_SPAWN_TYPE_ALLIANCE_ASSAULT);
// send out the chat message and sound
SendChatMessage(Team ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE, pPlayer->GetGUID(), "$N claims the %s! If left unchallenged, the %s will control it in 1 minute!", ControlPointNames[Id],
Team ? "Horde" : "Alliance");
//.........这里部分代码省略.........
示例12: 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.
//.........这里部分代码省略.........
示例13: 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());
}
//.........这里部分代码省略.........
示例14: DumpStats
//.........这里部分代码省略.........
fprintf(f, " <statsummary>\n");
uint32 i;
for(i = 0; i <= RACE_DRAENEI; ++i)
{
if( race_names[i] != NULL )
fprintf(f, " <%s>%u</%s>\n", race_names[i], races[i], race_names[i]);
}
for(i = 0; i <= DRUID; ++i)
{
if( class_names[i] != NULL )
fprintf(f, " <%s>%u</%s>\n", class_names[i], classes[i], class_names[i]);
}
fprintf(f, " </statsummary>\n");
PlayerPointer plr;
uint32 t = (uint32)time(NULL);
char otime[100];
{
fprintf(f, " <instances>\n");
// need a big buffer..
static char buf[500000];
memset(buf, 0, 500000);
// Dump Instance Information
//sWorldCreator.BuildXMLStats(buf);
sInstanceMgr.BuildXMLStats(buf);
fprintf(f, buf);
fprintf(f, " </instances>\n");
}
{
// GM Information
fprintf(f, " <gms>\n");
while(!gms.empty())
{
plr = gms.front();
gms.pop_front();
if(!plr->bGMTagOn)
continue;
FillOnlineTime(t - plr->OnlineTime, otime);
fprintf(f, " <gmplr>\n");
fprintf(f, " <name>%s</name>\n", plr->GetName());
fprintf(f, " <race>%u</race>\n", plr->getRace());
fprintf(f, " <class>%u</class>\n", (unsigned int)plr->getClass());
fprintf(f, " <gender>%u</gender>\n", (unsigned int)plr->getGender());
fprintf(f, " <pvprank>%u</pvprank>\n", (unsigned int)plr->GetPVPRank());
fprintf(f, " <level>%u</level>\n", (unsigned int)plr->GetUInt32Value(UNIT_FIELD_LEVEL));
fprintf(f, " <map>%u</map>\n", (unsigned int)plr->GetMapId());
fprintf(f, " <areaid>%u</areaid>\n", (unsigned int)plr->GetAreaID());
fprintf(f, " <ontime>%s</ontime>\n", otime);
fprintf(f, " <latency>%u</latency>\n", (unsigned int)plr->GetSession()->GetLatency());
fprintf(f, " <permissions>%s</permissions>\n", plr->GetSession()->GetPermissions());
fprintf(f, " </gmplr>\n");
}
fprintf(f, " </gms>\n");
}
{
fprintf(f, " <sessions>\n");
// Dump Player Information
objmgr._playerslock.AcquireReadLock();
HM_NAMESPACE::hash_map<uint32, PlayerPointer>::const_iterator itr;
for (itr = objmgr._players.begin(); itr != objmgr._players.end(); itr++)
{
plr = itr->second;
if(itr->second->GetSession() && itr->second->IsInWorld())
{
FillOnlineTime(t - plr->OnlineTime, otime);
fprintf(f, " <plr>\n");
fprintf(f, " <name>%s</name>\n", plr->GetName());
fprintf(f, " <race>%u</race>\n", (unsigned int)plr->getRace());
fprintf(f, " <class>%u</class>\n", (unsigned int)plr->getClass());
fprintf(f, " <gender>%u</gender>\n", (unsigned int)plr->getGender());
fprintf(f, " <pvprank>%u</pvprank>\n", (unsigned int)plr->GetPVPRank());
fprintf(f, " <level>%u</level>\n", (unsigned int)plr->GetUInt32Value(UNIT_FIELD_LEVEL));
fprintf(f, " <map>%u</map>\n", (unsigned int)plr->GetMapId());
fprintf(f, " <areaid>%u</areaid>\n", (unsigned int)plr->GetAreaID());
//requested by Zdarkside for he's online map. I hope it does not scre up any parser. If so, then make a better one :P
fprintf(f, " <xpos>%f</xpos>\n", plr->GetPositionX ());
fprintf(f, " <ypos>%f</ypos>\n", plr->GetPositionY());
fprintf(f, " <ontime>%s</ontime>\n", otime);
fprintf(f, " <latency>%u</latency>\n", (unsigned int)plr->GetSession()->GetLatency());
fprintf(f, " </plr>\n");
if(plr->GetSession()->GetPermissionCount() > 0)
gms.push_back(plr);
}
}
objmgr._playerslock.ReleaseReadLock();
fprintf(f, " </sessions>\n");
}
fprintf(f, "</serverpage>\n");
fclose(f);
}