void WorldSession::HandleUpdateMissileTrajectory(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_UPDATE_MISSILE_TRAJECTORY"); ObjectGuid guid; uint32 spellId; float elevation, speed; WorldLocation src = GetPlayer()->GetPosition(); WorldLocation dst = GetPlayer()->GetPosition(); uint8 moveFlag; recv_data >> guid; // if (!guid.IsPlayer()) // return; recv_data >> spellId; recv_data >> elevation; recv_data >> speed; recv_data >> src.x >> src.y >> src.z; recv_data >> dst.x >> dst.y >> dst.z; recv_data >> moveFlag; Unit* unit = ObjectAccessor::GetUnit(*GetPlayer(), guid); if (!unit) return; Spell* spell = unit ? unit->GetCurrentSpell(CURRENT_GENERIC_SPELL) : NULL; if (!spell || spell->m_spellInfo->Id != spellId || !(spell->m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)) { return; } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WorldSession::HandleUpdateMissileTrajectory spell %u ajusted coords: src %f/%f %f/%f %f/%f dst %f/%f %f/%f %f/%f speed %f/%f elevation %f/%f", spellId, spell->m_targets.getSource().getX(), src.getX(), spell->m_targets.getSource().getY(), src.getY(), spell->m_targets.getSource().getZ(), src.getZ(), spell->m_targets.getDestination().getX(), dst.getX(), spell->m_targets.getDestination().getY(), dst.getY(), spell->m_targets.getDestination().getZ(), dst.getZ(), spell->m_targets.GetSpeed(), speed, spell->m_targets.GetElevation(), elevation); spell->m_targets.setSource(src); spell->m_targets.setDestination(dst); spell->m_targets.SetElevation(elevation); spell->m_targets.SetSpeed(speed); if (moveFlag) { ObjectGuid guid2; // unk guid (possible - active mover) - unused MovementInfo movementInfo; // MovementInfo recv_data >> Unused<uint32>(); // >> MSG_MOVE_STOP recv_data >> guid.ReadAsPacked(); recv_data >> movementInfo; } }
bool WorldLocation::IsValidMapCoord(WorldLocation const& loc) { if (loc.HasMap()) return MapManager::IsValidMapCoord(loc); else return MaNGOS::IsValidMapCoord(loc.getX(), loc.getY(), loc.getZ(), loc.getO()); }
// 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; }