mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
[7598] Implement proper hide out of range (at another map) transports. Remove duplicate name field. Author: VladimirMangos
--HG-- branch : trunk
This commit is contained in:
@@ -1954,7 +1954,8 @@ void Map::SendInitTransports( Player * player )
|
||||
|
||||
for (MapManager::TransportSet::iterator i = tset.begin(); i != tset.end(); ++i)
|
||||
{
|
||||
if((*i) != player->GetTransport()) // send data for current transport in other place
|
||||
// send data for current transport in other place
|
||||
if((*i) != player->GetTransport() && (*i)->GetMapId()==i_id)
|
||||
{
|
||||
hasTransport = true;
|
||||
(*i)->BuildCreateUpdateBlockForPlayer(&transData, player);
|
||||
@@ -1981,7 +1982,7 @@ void Map::SendRemoveTransports( Player * player )
|
||||
|
||||
// except used transport
|
||||
for (MapManager::TransportSet::iterator i = tset.begin(); i != tset.end(); ++i)
|
||||
if(player->GetTransport() != (*i))
|
||||
if((*i) != player->GetTransport() && (*i)->GetMapId()!=i_id)
|
||||
(*i)->BuildOutOfRangeUpdateBlock(&transData);
|
||||
|
||||
WorldPacket packet;
|
||||
|
||||
@@ -89,8 +89,6 @@ void MapManager::LoadTransports()
|
||||
continue;
|
||||
}
|
||||
|
||||
t->m_name = goinfo->name;
|
||||
|
||||
float x, y, z, o;
|
||||
uint32 mapid;
|
||||
x = t->m_WayPoints[0].x; y = t->m_WayPoints[0].y; z = t->m_WayPoints[0].z; mapid = t->m_WayPoints[0].mapid; o = 1;
|
||||
@@ -185,6 +183,8 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z,
|
||||
if(dynflags)
|
||||
SetUInt32Value(GAMEOBJECT_DYNAMIC, MAKE_PAIR32(0, dynflags));
|
||||
|
||||
SetName(goinfo->name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -439,11 +439,9 @@ Transport::WayPointMap::iterator Transport::GetNextWayPoint()
|
||||
|
||||
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
|
||||
{
|
||||
//MapManager::Instance().GetMap(oldMapid)->Remove((GameObject *)this, false);
|
||||
Map const* oldMap = GetMap();
|
||||
SetMapId(newMapid);
|
||||
//MapManager::Instance().LoadGrid(newMapid,x,y,true);
|
||||
Relocate(x, y, z);
|
||||
//MapManager::Instance().GetMap(newMapid)->Add<GameObject>((GameObject *)this);
|
||||
|
||||
for(PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();)
|
||||
{
|
||||
@@ -467,13 +465,21 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
|
||||
//data << uint32(0);
|
||||
//plr->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
Map const* newMap = GetMap();
|
||||
|
||||
if(oldMap != newMap)
|
||||
{
|
||||
UpdateForMap(oldMap);
|
||||
UpdateForMap(newMap);
|
||||
}
|
||||
}
|
||||
|
||||
bool Transport::AddPassenger(Player* passenger)
|
||||
{
|
||||
if (m_passengers.find(passenger) == m_passengers.end())
|
||||
{
|
||||
sLog.outDetail("Player %s boarded transport %s.", passenger->GetName(), this->m_name.c_str());
|
||||
sLog.outDetail("Player %s boarded transport %s.", passenger->GetName(), GetName());
|
||||
m_passengers.insert(passenger);
|
||||
}
|
||||
return true;
|
||||
@@ -482,7 +488,7 @@ bool Transport::AddPassenger(Player* passenger)
|
||||
bool Transport::RemovePassenger(Player* passenger)
|
||||
{
|
||||
if (m_passengers.erase(passenger))
|
||||
sLog.outDetail("Player %s removed from transport %s.", passenger->GetName(), m_name.c_str());
|
||||
sLog.outDetail("Player %s removed from transport %s.", passenger->GetName(), GetName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -511,7 +517,6 @@ void Transport::Update(uint32 /*p_time*/)
|
||||
}
|
||||
else
|
||||
{
|
||||
//MapManager::Instance().GetMap(m_curr->second.mapid)->GameobjectRelocation((GameObject *)this, m_curr->second.x, m_curr->second.y, m_curr->second.z, this->m_orientation);
|
||||
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
|
||||
}
|
||||
/*
|
||||
@@ -549,10 +554,6 @@ void Transport::Update(uint32 /*p_time*/)
|
||||
if (m_curr == m_WayPoints.begin() && (sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0)
|
||||
sLog.outDetail(" ************ BEGIN ************** %s", this->m_name.c_str());
|
||||
|
||||
// MapManager::Instance().GetMap(m_curr->second.mapid)->Add(&this); // -> // ->Add(t);
|
||||
//MapManager::Instance().GetMap(m_curr->second.mapid)->Remove((GameObject *)this, false); // -> // ->Add(t);
|
||||
//MapManager::Instance().GetMap(m_curr->second.mapid)->Add((GameObject *)this); // -> // ->Add(t);
|
||||
|
||||
if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0)
|
||||
sLog.outDetail("%s moved to %d %f %f %f %d", this->m_name.c_str(), m_curr->second.id, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
|
||||
|
||||
@@ -561,3 +562,36 @@ void Transport::Update(uint32 /*p_time*/)
|
||||
}
|
||||
}
|
||||
|
||||
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, true);
|
||||
itr->getSource()->SendDirectMessage(&packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateData transData;
|
||||
BuildOutOfRangeUpdateBlock(&transData);
|
||||
WorldPacket out_packet;
|
||||
transData.BuildPacket(&out_packet, true);
|
||||
|
||||
for(Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
|
||||
if(this != itr->getSource()->GetTransport())
|
||||
itr->getSource()->SendDirectMessage(&out_packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class TransportPath
|
||||
std::vector<PathNode> i_nodes;
|
||||
};
|
||||
|
||||
class Transport : private GameObject
|
||||
class Transport : protected GameObject
|
||||
{
|
||||
public:
|
||||
explicit Transport();
|
||||
@@ -83,7 +83,6 @@ class Transport : private GameObject
|
||||
typedef std::set<Player*> PlayerSet;
|
||||
PlayerSet const& GetPassengers() const { return m_passengers; }
|
||||
|
||||
std::string m_name;
|
||||
private:
|
||||
struct WayPoint
|
||||
{
|
||||
@@ -114,6 +113,7 @@ class Transport : private GameObject
|
||||
|
||||
private:
|
||||
void TeleportTransport(uint32 newMapid, float x, float y, float z);
|
||||
void UpdateForMap(Map const* map);
|
||||
WayPointMap::iterator GetNextWayPoint();
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user