本文整理汇总了C++中BuildCreateUpdateBlockForPlayer函数的典型用法代码示例。如果您正苦于以下问题:C++ BuildCreateUpdateBlockForPlayer函数的具体用法?C++ BuildCreateUpdateBlockForPlayer怎么用?C++ BuildCreateUpdateBlockForPlayer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BuildCreateUpdateBlockForPlayer函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildCreateUpdateBlockForPlayer
void Transport::UpdateForMap(Map const* targetMap)
{
Map::PlayerList const& pl = targetMap->GetPlayers();
if(pl.isEmpty())
return;
if(GetMapId()==targetMap->GetId())
{
for(Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
{
if(this != itr->getSource()->GetTransport())
{
UpdateData transData;
BuildCreateUpdateBlockForPlayer(&transData, itr->getSource());
WorldPacket packet;
transData.BuildPacket(&packet);
itr->getSource()->SendDirectMessage(&packet);
}
}
}
else
{
UpdateData transData;
BuildOutOfRangeUpdateBlock(&transData);
WorldPacket out_packet;
transData.BuildPacket(&out_packet);
for(Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
if(this != itr->getSource()->GetTransport())
itr->getSource()->SendDirectMessage(&out_packet);
}
}
示例2: BuildCreateUpdateBlockForPlayer
void Transport::UpdateForMap(Map const* targetMap)
{
Map::PlayerList const& pl = targetMap->GetPlayers();
if (pl.isEmpty())
return;
if (GetMapId() == targetMap->GetId())
{
for (const auto& itr : pl)
{
if (this != itr.getSource()->GetTransport())
{
UpdateData transData;
BuildCreateUpdateBlockForPlayer(&transData, itr.getSource());
WorldPacket packet;
transData.BuildPacket(packet);
itr.getSource()->SendDirectMessage(packet);
}
}
}
else
{
UpdateData transData;
BuildOutOfRangeUpdateBlock(&transData);
WorldPacket out_packet;
transData.BuildPacket(out_packet);
for (const auto& itr : pl)
if (this != itr.getSource()->GetTransport())
itr.getSource()->SendDirectMessage(out_packet);
}
}
示例3: GetMap
bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
Map const* oldMap = GetMap();
if (oldMap->GetId() != newMapid)
{
Map* newMap = sMapMgr->CreateBaseMap(newMapid);
Map::PlayerList const& oldPlayers = GetMap()->GetPlayers();
if (!oldPlayers.isEmpty())
{
UpdateData data(GetMapId());
BuildOutOfRangeUpdateBlock(&data);
WorldPacket packet;
data.BuildPacket(&packet);
for (Map::PlayerList::const_iterator itr = oldPlayers.begin(); itr != oldPlayers.end(); ++itr)
if (itr->GetSource()->GetTransport() != this)
itr->GetSource()->SendDirectMessage(&packet);
}
UnloadStaticPassengers();
GetMap()->RemoveFromMap<Transport>(this, false);
SetMap(newMap);
Map::PlayerList const& newPlayers = GetMap()->GetPlayers();
if (!newPlayers.isEmpty())
{
for (Map::PlayerList::const_iterator itr = newPlayers.begin(); itr != newPlayers.end(); ++itr)
{
if (itr->GetSource()->GetTransport() != this)
{
UpdateData data(newMapid);
BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
WorldPacket packet;
data.BuildPacket(&packet);
itr->GetSource()->SendDirectMessage(&packet);
}
}
}
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();)
{
WorldObject* obj = (*itr++);
float destX, destY, destZ, destO;
obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation());
switch (obj->GetTypeId())
{
case TYPEID_PLAYER:
if (!obj->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
_passengers.erase(obj);
break;
default:
RemovePassenger(obj);
break;
}
}
Relocate(x, y, z, GetOrientation());
GetMap()->AddToMap<Transport>(this);
return true;
}
else
{
UpdatePosition(x, y, z, GetOrientation());
return false;
}
}
示例4: GetMap
bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
Map const* oldMap = GetMap();
if (oldMap->GetId() != newMapid)
{
Map* newMap = sMapMgr->CreateBaseMap(newMapid);
Map::PlayerList const& oldPlayers = GetMap()->GetPlayers();
if (!oldPlayers.isEmpty())
{
UpdateData data;
BuildOutOfRangeUpdateBlock(&data);
WorldPacket packet;
data.BuildPacket(&packet);
for (Map::PlayerList::const_iterator itr = oldPlayers.begin(); itr != oldPlayers.end(); ++itr)
if (itr->GetSource()->GetTransport() != this)
itr->GetSource()->SendDirectMessage(&packet);
}
UnloadStaticPassengers();
GetMap()->RemoveFromMap<Transport>(this, false);
SetMap(newMap);
Map::PlayerList const& newPlayers = GetMap()->GetPlayers();
if (!newPlayers.isEmpty())
{
for (Map::PlayerList::const_iterator itr = newPlayers.begin(); itr != newPlayers.end(); ++itr)
{
if (itr->GetSource()->GetTransport() != this)
{
UpdateData data;
BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
WorldPacket packet;
data.BuildPacket(&packet);
itr->GetSource()->SendDirectMessage(&packet);
}
}
}
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();)
{
WorldObject* obj = (*itr++);
float destX, destY, destZ, destO;
obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation());
switch (obj->GetTypeId())
{
case TYPEID_UNIT:
if (!IS_PLAYER_GUID(obj->ToUnit()->GetOwnerGUID())) // pets should be teleported with player
obj->ToCreature()->FarTeleportTo(newMap, destX, destY, destZ, destO);
break;
case TYPEID_GAMEOBJECT:
{
GameObject* go = obj->ToGameObject();
go->GetMap()->RemoveFromMap(go, false);
go->Relocate(destX, destY, destZ, destO);
go->SetMap(newMap);
newMap->AddToMap(go);
break;
}
case TYPEID_PLAYER:
if (!obj->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
_passengers.erase(obj);
break;
default:
break;
}
}
Relocate(x, y, z, GetOrientation());
GetMap()->AddToMap<Transport>(this);
return true;
}
else
{
// Teleport players, they need to know it
for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
{
if ((*itr)->GetTypeId() == TYPEID_PLAYER)
{
float destX, destY, destZ, destO;
(*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, GetOrientation());
(*itr)->ToUnit()->NearTeleportTo(destX, destY, destZ, destO);
}
}
UpdatePosition(x, y, z, GetOrientation());
return false;
}
}