本文整理汇总了C++中WorldLocation::GetMapId方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldLocation::GetMapId方法的具体用法?C++ WorldLocation::GetMapId怎么用?C++ WorldLocation::GetMapId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldLocation
的用法示例。
在下文中一共展示了WorldLocation::GetMapId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPosition
// Return true, only if transport has correct position!
bool MOTransport::SetPosition(WorldLocation const& loc, bool teleport)
{
// prevent crash when a bad coord is sent by the client
if (!MaNGOS::IsValidMapCoord(loc.getX(), loc.getY(), loc.getZ(), loc.getO()))
{
DEBUG_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "Transport::SetPosition(%f, %f, %f, %f, %d) bad coordinates for transport %s!", loc.getX(), loc.getY(), loc.getZ(), loc.getO(), teleport, GetName());
return false;
}
if (teleport || GetMapId() != loc.GetMapId())
{
Map* oldMap = GetMap();
Map* newMap = sMapMgr.CreateMap(loc.GetMapId(), this);
if (!newMap)
{
sLog.outError("Transport::SetPosition cannot create map %u for transport %s!", loc.GetMapId(), GetName());
return false;
}
if (oldMap != newMap)
{
// Transport inserted in current map ActiveObjects list
if (!GetTransportKit()->GetPassengers().empty())
{
DEBUG_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES,"Transport::SetPosition %s notify passengers (count " SIZEFMTD ") for change map from %u to %u",GetObjectGuid().GetString().c_str(), GetTransportKit()->GetPassengers().size(), GetPosition().GetMapId(), loc.GetMapId());
GetTransportKit()->CallForAllPassengers(NotifyMapChangeBegin(oldMap, GetPosition(), loc));
}
oldMap->Remove((GameObject*)this, false);
SkipUpdate(true);
SetMap(newMap);
Relocate(loc);
SetLocationMapId(loc.GetMapId());
SetLocationInstanceId(loc.GetInstanceId());
newMap->Add((GameObject*)this);
// Transport inserted in current map ActiveObjects list
if (!GetTransportKit()->GetPassengers().empty())
{
DEBUG_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES,"Transport::SetPosition %s notify passengers (count " SIZEFMTD ") for finished change map to %u",GetObjectGuid().GetString().c_str(), GetTransportKit()->GetPassengers().size(), loc.GetMapId());
GetTransportKit()->CallForAllPassengers(NotifyMapChangeEnd(newMap,loc));
}
DEBUG_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "Transport::SetPosition %s teleported to (%f, %f, %f, %f)", GetObjectGuid().GetString().c_str(), loc.x, loc.y, loc.z, loc.orientation);
return true;
}
else if (!(GetPosition() == loc))
GetMap()->Relocation((GameObject*)this, loc);
}
else if (!(GetPosition() == loc))
GetMap()->Relocation((GameObject*)this, loc);
return false;
}
示例2: RandomTeleport
void RandomPlayerbotMgr::RandomTeleport(Player* bot, vector<WorldLocation> &locs)
{
if (bot->IsBeingTeleported())
return;
if (locs.empty())
{
sLog->outMessage("playerbot", LOG_LEVEL_ERROR, "Cannot teleport bot %s - no locations available", bot->GetName().c_str());
return;
}
for (int attemtps = 0; attemtps < 10; ++attemtps)
{
int index = urand(0, locs.size() - 1);
WorldLocation loc = locs[index];
float x = loc.m_positionX + urand(0, sPlayerbotAIConfig.grindDistance) - sPlayerbotAIConfig.grindDistance / 2;
float y = loc.m_positionY + urand(0, sPlayerbotAIConfig.grindDistance) - sPlayerbotAIConfig.grindDistance / 2;
float z = loc.m_positionZ;
Map* map = sMapMgr->FindMap(loc.GetMapId(), 0);
if (!map)
continue;
if (!map->IsOutdoors(x, y, z) ||
map->IsInWater(x, y, z))
continue;
uint32 areaId = map->GetAreaId(x, y, z);
if (!areaId)
continue;
AreaTableEntry const* area = sAreaStore.LookupEntry(areaId);
if (!area)
continue;
float ground = map->GetHeight(x, y, z + 0.5f);
if (ground <= INVALID_HEIGHT)
continue;
z = 0.05f + ground;
sLog->outMessage("playerbot", LOG_LEVEL_INFO, "Random teleporting bot %s to %s %f,%f,%f", bot->GetName().c_str(), area->area_name[0], x, y, z);
bot->GetMotionMaster()->Clear();
bot->TeleportTo(loc.GetMapId(), x, y, z, 0);
return;
}
sLog->outMessage("playerbot", LOG_LEVEL_ERROR, "Cannot teleport bot %s - no locations available", bot->GetName().c_str());
}
示例3: SendSpiritResurrect
void WorldSession::SendSpiritResurrect()
{
_player->ResurrectPlayer(0.5f, true);
_player->DurabilityLossAll(0.25f, true);
// get corpse nearest graveyard
WorldSafeLocsEntry const* corpseGrave = NULL;
WorldLocation corpseLocation = _player->GetCorpseLocation();
if (_player->HasCorpse())
{
corpseGrave = sObjectMgr->GetClosestGraveYard(corpseLocation.GetPositionX(), corpseLocation.GetPositionY(),
corpseLocation.GetPositionZ(), corpseLocation.GetMapId(), _player->GetTeam());
}
// now can spawn bones
_player->SpawnCorpseBones();
// teleport to nearest from corpse graveyard, if different from nearest to player ghost
if (corpseGrave)
{
WorldSafeLocsEntry const* ghostGrave = sObjectMgr->GetClosestGraveYard(
_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam());
if (corpseGrave != ghostGrave)
_player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation());
// or update at original position
else
_player->UpdateObjectVisibility();
}
// or update at original position
else
_player->UpdateObjectVisibility();
}
示例4: HandleCorpseQueryOpcode
void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recvData*/)
{
if (!_player->HasCorpse())
{
WorldPacket data(MSG_CORPSE_QUERY, 1);
data << uint8(0); // corpse not found
SendPacket(&data);
return;
}
WorldLocation corpseLocation = _player->GetCorpseLocation();
uint32 corpseMapID = corpseLocation.GetMapId();
uint32 mapID = corpseLocation.GetMapId();
float x = corpseLocation.GetPositionX();
float y = corpseLocation.GetPositionY();
float z = corpseLocation.GetPositionZ();
// if corpse at different map
if (mapID != _player->GetMapId())
{
// search entrance map for proper show entrance
if (MapEntry const* corpseMapEntry = sMapStore.LookupEntry(mapID))
{
if (corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0)
{
// if corpse map have entrance
if (Map const* entranceMap = sMapMgr->CreateBaseMap(corpseMapEntry->entrance_map))
{
mapID = corpseMapEntry->entrance_map;
x = corpseMapEntry->entrance_x;
y = corpseMapEntry->entrance_y;
z = entranceMap->GetHeight(GetPlayer()->GetPhaseMask(), x, y, MAX_HEIGHT);
}
}
}
}
WorldPacket data(MSG_CORPSE_QUERY, 1+(6*4));
data << uint8(1); // corpse found
data << int32(mapID);
data << float(x);
data << float(y);
data << float(z);
data << int32(corpseMapID);
data << uint32(0); // unknown
SendPacket(&data);
}
示例5: return
bool WorldLocation::operator == (WorldLocation const& loc) const
{
return (
(realmid == 0 || realmid == loc.realmid)
&& (!HasMap() || GetMapId() == loc.GetMapId())
&& (GetInstanceId() == 0 || GetInstanceId() == loc.GetInstanceId())
&& ((Position)*this) == ((Position)loc));
}
示例6: GetDistance
float WorldLocation::GetDistance(WorldLocation const& loc) const
{
return (!HasMap() || !loc.HasMap() || ((GetMapId() == loc.GetMapId()) && (GetInstanceId() == loc.GetInstanceId()))) ?
((Position)*this).GetDistance((Position)loc) :
MAX_VISIBILITY_DISTANCE + 1.0f;
};
示例7: HandleMoveWorldportAckOpcode
void WorldSession::HandleMoveWorldportAckOpcode()
{
// ignore unexpected far teleports
if (!GetPlayer()->IsBeingTeleportedFar())
return;
GetPlayer()->SetSemaphoreTeleportFar(false);
GetPlayer()->SetIgnoreMovementCount(5);
// get the teleport destination
WorldLocation const loc = GetPlayer()->GetTeleportDest();
// possible errors in the coordinate validity check
if (!MapManager::IsValidMapCoord(loc))
{
LogoutPlayer(false);
return;
}
// get the destination map entry, not the current one, this will fix homebind and reset greeting
MapEntry const* mEntry = sMapStore.LookupEntry(loc.GetMapId());
InstanceTemplate const* mInstance = sObjectMgr->GetInstanceTemplate(loc.GetMapId());
// reset instance validity, except if going to an instance inside an instance
if (GetPlayer()->m_InstanceValid == false && !mInstance)
GetPlayer()->m_InstanceValid = true;
Map* oldMap = GetPlayer()->GetMap();
if (GetPlayer()->IsInWorld())
{
sLog->outError(LOG_FILTER_NETWORKIO, "Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName(), oldMap->GetId(), loc.GetMapId());
oldMap->RemovePlayerFromMap(GetPlayer(), false);
}
// relocate the player to the teleport destination
Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer());
// the CanEnter checks are done in TeleporTo but conditions may change
// while the player is in transit, for example the map may get full
if (!newMap || !newMap->CanEnter(GetPlayer()))
{
sLog->outError(LOG_FILTER_NETWORKIO, "Map %d could not be created for player %d, porting player to homebind", loc.GetMapId(), GetPlayer()->GetGUIDLow());
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
return;
}
else
GetPlayer()->Relocate(&loc);
GetPlayer()->ResetMap();
GetPlayer()->SetMap(newMap);
GetPlayer()->SendInitialPacketsBeforeAddToMap();
if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer()))
{
sLog->outError(LOG_FILTER_NETWORKIO, "WORLD: failed to teleport player %s (%d) to map %d (%s) because of unknown reason!",
GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown");
GetPlayer()->ResetMap();
GetPlayer()->SetMap(oldMap);
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
return;
}
// battleground state prepare (in case join to BG), at relogin/tele player not invited
// only add to bg group and object, if the player was invited (else he entered through command)
if (_player->InBattleground())
{
// cleanup setting if outdated
if (!mEntry->IsBattlegroundOrArena())
{
// We're not in BG
_player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE);
// reset destination bg team
_player->SetBGTeam(0);
_player->SetByteValue(PLAYER_BYTES_3, 3, 0);
}
// join to bg case
else if (Battleground* bg = _player->GetBattleground())
if (_player->IsInvitedForBattlegroundInstance(_player->GetBattlegroundId()))
bg->AddPlayer(_player);
}
GetPlayer()->SendInitialPacketsAfterAddToMap();
// Update position client-side to avoid undermap
/*WorldPacket data(SMSG_MOVE_UPDATE);
_player->m_movementInfo.pos.m_positionX = loc.m_positionX;
_player->m_movementInfo.pos.m_positionY = loc.m_positionY;
_player->m_movementInfo.pos.m_positionZ = loc.m_positionZ;
uint32 mstime = getMSTime();
if (m_clientTimeDelay == 0)
m_clientTimeDelay = mstime - _player->m_movementInfo.time;
_player->m_movementInfo.time = _player->m_movementInfo.time + m_clientTimeDelay + MOVEMENT_PACKET_TIME_DELAY;
_player->WriteMovementInfo(data);
_player->GetSession()->SendPacket(&data);*/
// flight fast teleport case
if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
//.........这里部分代码省略.........