summaryrefslogtreecommitdiff
path: root/indra/newview/llagent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llagent.cpp')
-rw-r--r--indra/newview/llagent.cpp128
1 files changed, 111 insertions, 17 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index c65bc0fa50..389448654a 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -108,7 +108,8 @@ const U8 AGENT_STATE_EDITING = 0x10;
// Autopilot constants
const F32 AUTOPILOT_HEIGHT_ADJUST_DISTANCE = 8.f; // meters
const F32 AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND = 1.f; // meters
-const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS = 1.5f; // seconds
+const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS_WALK = 1.5f; // seconds
+const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS_FLY = 2.5f; // seconds. Flying is less presize, needs a bit more time
const F32 MAX_VELOCITY_AUTO_LAND_SQUARED = 4.f * 4.f;
const F64 CHAT_AGE_FAST_RATE = 3.0;
@@ -387,6 +388,7 @@ LLAgent::LLAgent() :
mTeleportFinishedSlot(),
mTeleportFailedSlot(),
mIsMaturityRatingChangingDuringTeleport(false),
+ mTPNeedsNeabyChatSeparator(false),
mMaturityRatingChange(0U),
mIsDoSendMaturityPreferenceToServer(false),
mMaturityPreferenceRequestId(0U),
@@ -878,13 +880,12 @@ boost::signals2::connection LLAgent::addParcelChangedCallback(parcel_changed_cal
}
// static
-void LLAgent::capabilityReceivedCallback(const LLUUID &region_id)
+void LLAgent::capabilityReceivedCallback(const LLUUID &region_id, LLViewerRegion *regionp)
{
- LLViewerRegion* region = gAgent.getRegion();
- if (region && region->getRegionID() == region_id)
+ if (regionp && regionp->getRegionID() == region_id)
{
- region->requestSimulatorFeatures();
- LLAppViewer::instance()->updateNameLookupUrl();
+ regionp->requestSimulatorFeatures();
+ LLAppViewer::instance()->updateNameLookupUrl(regionp);
}
}
@@ -935,7 +936,7 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
if (regionp->capabilitiesReceived())
{
regionp->requestSimulatorFeatures();
- LLAppViewer::instance()->updateNameLookupUrl();
+ LLAppViewer::instance()->updateNameLookupUrl(regionp);
}
else
{
@@ -961,11 +962,11 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
if (regionp->capabilitiesReceived())
{
- LLAppViewer::instance()->updateNameLookupUrl();
+ LLAppViewer::instance()->updateNameLookupUrl(regionp);
}
else
{
- regionp->setCapabilitiesReceivedCallback([](const LLUUID &region_id) {LLAppViewer::instance()->updateNameLookupUrl(); });
+ regionp->setCapabilitiesReceivedCallback([](const LLUUID &region_id, LLViewerRegion* regionp) {LLAppViewer::instance()->updateNameLookupUrl(regionp); });
}
}
@@ -1562,6 +1563,12 @@ void LLAgent::startAutoPilotGlobal(
{
return;
}
+
+ if (target_global.isExactlyZero())
+ {
+ LL_WARNS() << "Canceling attempt to start autopilot towards invalid position" << LL_ENDL;
+ return;
+ }
// Are there any pending callbacks from previous auto pilot requests?
if (mAutoPilotFinishedCallback)
@@ -1777,7 +1784,16 @@ void LLAgent::autoPilot(F32 *delta_yaw)
if (target_dist >= mAutoPilotTargetDist)
{
mAutoPilotNoProgressFrameCount++;
- if (mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS * gFPSClamped)
+ bool out_of_time = false;
+ if (getFlying())
+ {
+ out_of_time = mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS_FLY * gFPSClamped;
+ }
+ else
+ {
+ out_of_time = mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS_WALK * gFPSClamped;
+ }
+ if (out_of_time)
{
stopAutoPilot();
return;
@@ -1826,7 +1842,7 @@ void LLAgent::autoPilot(F32 *delta_yaw)
F32 slow_distance;
if (getFlying())
{
- slow_distance = llmax(6.f, mAutoPilotStopDistance + 5.f);
+ slow_distance = llmax(8.f, mAutoPilotStopDistance + 5.f);
}
else
{
@@ -1870,14 +1886,41 @@ void LLAgent::autoPilot(F32 *delta_yaw)
}
else if (mAutoPilotTargetDist > mAutoPilotStopDistance)
{
- // walking/flying slow
+ // walking/flying slow
+ U32 movement_flag = 0;
+
if (at * direction > 0.9f)
{
- setControlFlags(AGENT_CONTROL_AT_POS);
- }
- else if (at * direction < -0.9f)
- {
- setControlFlags(AGENT_CONTROL_AT_NEG);
+ movement_flag = AGENT_CONTROL_AT_POS;
+ }
+ else if (at * direction < -0.9f)
+ {
+ movement_flag = AGENT_CONTROL_AT_NEG;
+ }
+
+ if (getFlying())
+ {
+ // flying is too fast and has high inertia, artificially slow it down
+ // Don't update flags too often, server might not react
+ static U64 last_time_microsec = 0;
+ U64 time_microsec = LLTimer::getTotalTime();
+ U64 delta = time_microsec - last_time_microsec;
+ // fly during ~0-40 ms, stop during ~40-250 ms
+ if (delta > 250000) // 250ms
+ {
+ // reset even if !movement_flag
+ last_time_microsec = time_microsec;
+ }
+ else if (delta > 40000) // 40 ms
+ {
+ clearControlFlags(AGENT_CONTROL_AT_POS | AGENT_CONTROL_AT_POS);
+ movement_flag = 0;
+ }
+ }
+
+ if (movement_flag)
+ {
+ setControlFlags(movement_flag);
}
}
@@ -3934,6 +3977,7 @@ void LLAgent::clearTeleportRequest()
LLVoiceClient::getInstance()->setHidden(FALSE);
}
mTeleportRequest.reset();
+ mTPNeedsNeabyChatSeparator = false;
}
void LLAgent::setMaturityRatingChangeDuringTeleport(U8 pMaturityRatingChange)
@@ -3942,6 +3986,12 @@ void LLAgent::setMaturityRatingChangeDuringTeleport(U8 pMaturityRatingChange)
mMaturityRatingChange = pMaturityRatingChange;
}
+void LLAgent::sheduleTeleportIM()
+{
+ // is supposed to be called during teleport so we are still waiting for parcel
+ mTPNeedsNeabyChatSeparator = true;
+}
+
bool LLAgent::hasPendingTeleportRequest()
{
return ((mTeleportRequest != NULL) &&
@@ -3989,6 +4039,12 @@ void LLAgent::startTeleportRequest()
void LLAgent::handleTeleportFinished()
{
LL_INFOS("Teleport") << "Agent handling teleport finished." << LL_ENDL;
+ if (mTPNeedsNeabyChatSeparator)
+ {
+ // parcel is ready at this point
+ addTPNearbyChatSeparator();
+ mTPNeedsNeabyChatSeparator = false;
+ }
clearTeleportRequest();
mTeleportCanceled.reset();
if (mIsMaturityRatingChangingDuringTeleport)
@@ -4051,6 +4107,44 @@ void LLAgent::handleTeleportFailed()
LLNotificationsUtil::add("PreferredMaturityChanged", args);
mIsMaturityRatingChangingDuringTeleport = false;
}
+
+ mTPNeedsNeabyChatSeparator = false;
+}
+
+/*static*/
+void LLAgent::addTPNearbyChatSeparator()
+{
+ LLViewerRegion* agent_region = gAgent.getRegion();
+ LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+ if (!agent_region || !agent_parcel)
+ {
+ return;
+ }
+
+ LLFloaterIMNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLFloaterIMNearbyChat>("nearby_chat");
+ if (nearby_chat)
+ {
+ std::string location_name;
+ LLAgentUI::ELocationFormat format = LLAgentUI::LOCATION_FORMAT_NO_MATURITY;
+
+ // Might be better to provide slurl to chat
+ if (!LLAgentUI::buildLocationString(location_name, format))
+ {
+ location_name = "Teleport to new region"; // Shouldn't happen
+ }
+
+ LLChat chat;
+ chat.mFromName = location_name;
+ chat.mMuted = FALSE;
+ chat.mFromID = LLUUID::null;
+ chat.mSourceType = CHAT_SOURCE_TELEPORT;
+ chat.mChatStyle = CHAT_STYLE_TELEPORT_SEP;
+ chat.mText = "";
+
+ LLSD args;
+ args["do_not_log"] = TRUE;
+ nearby_chat->addMessage(chat, true, args);
+ }
}
/*static*/