Feature Touchup: Add backup destination to Emergency Teleport out of region within last 20 seconds before restart feature

Falls back if first landmark is not in inventory or invalid, region is offline, or the current region is your location
Item drop target is right below the original one in System->Security prefs.

Thanks again to the citizens of Fluffy for enduring these restart tests.
This commit is contained in:
Inusaito Sayori
2014-05-21 19:07:11 -04:00
parent c684987908
commit bfbbcad8e5
5 changed files with 54 additions and 3 deletions

View File

@@ -745,5 +745,16 @@
<key>Value</key>
<string/>
</map>
<key>EmergencyTeleportLandmarkBackup</key>
<map>
<key>Comment</key>
<string>UUID of the landmark to teleport to in the last twenty seconds before a region will restart if you're already in the region of EmergencyTeleportLandmark or if EmergencyTeleportLandmark is set but canot be found, empty is none.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string/>
</map>
</map>
</llsd>

View File

@@ -198,6 +198,7 @@ void LLPrefsAscentSys::refreshValues()
mRestartMinimized = gSavedSettings.getBOOL("LiruRegionRestartMinimized");
mRestartSound = gSavedSettings.getString("UISndRestart");
mLandmark = gSavedPerAccountSettings.getString("EmergencyTeleportLandmark");
mLandmarkBackup = gSavedPerAccountSettings.getString("EmergencyTeleportLandmarkBackup");
//Build -------------------------------------------------------------------------------
mAlpha = gSavedSettings.getF32("EmeraldBuildPrefs_Alpha");
@@ -329,6 +330,7 @@ void LLPrefsAscentSys::cancel()
gSavedSettings.setBOOL("LiruRegionRestartMinimized", mRestartMinimized);
gSavedSettings.setString("UISndRestart", mRestartSound);
gSavedPerAccountSettings.setString("EmergencyTeleportLandmark", mLandmark);
gSavedPerAccountSettings.setString("EmergencyTeleportLandmarkBackup", mLandmarkBackup);
//Build -------------------------------------------------------------------------------
gSavedSettings.setF32("EmeraldBuildPrefs_Alpha", mAlpha);

View File

@@ -112,6 +112,7 @@ private:
F32 mNumScriptDiff;
std::string mRestartSound;
std::string mLandmark;
std::string mLandmarkBackup;
//Build -------------------------------------------------------------------------------
F32 mAlpha;

View File

@@ -37,14 +37,49 @@
// <singu> For emergency teleports
#include "llinventorymodel.h"
#include "lllandmarklist.h"
#include "llviewerregion.h"
#include "llworldmap.h"
void emergency_teleport()
{
static const LLCachedControl<std::string> landmark(gSavedPerAccountSettings, "EmergencyTeleportLandmark");
if (landmark().empty()) return;
const LLUUID id(landmark);
LLUUID id(landmark);
if (id.isNull()) return;
if (LLViewerInventoryItem* item = gInventory.getItem(id))
gAgent.teleportViaLandmark(item->getAssetUUID());
bool use_backup = false;
LLViewerInventoryItem* item = gInventory.getItem(id);
if (item)
{
if (LLLandmark* lm = gLandmarkList.getAsset(item->getAssetUUID()))
{
if (LLViewerRegion* region = gAgent.getRegion())
use_backup = !lm->getRegionID(id) || id == region->getRegionID(); // LM's Region id null or same as current region
if (!use_backup)
{
LLVector3d pos_global;
if (lm->getGlobalPos(pos_global))
{
if (LLSimInfo* sim_info = LLWorldMap::instance().simInfoFromPosGlobal(pos_global))
{
use_backup = sim_info->isDown();
}
}
else use_backup = true; // No coords, this will fail!
}
}
else use_backup = true;
}
else use_backup = true;
if (use_backup) // Something is wrong with the first provided landmark, fallback.
{
static const LLCachedControl<std::string> landmark(gSavedPerAccountSettings, "EmergencyTeleportLandmarkBackup");
if (landmark().empty()) return;
if (!id.set(landmark)) return;
if (!(item = gInventory.getItem(id))) return;
}
gAgent.teleportViaLandmark(item->getAssetUUID());
}
// </singu>

View File

@@ -99,6 +99,8 @@
<check_box bottom_delta="-20" left="10" follows="top" label="Auto-minimize region restart notice" name="region_restart_minimized" control_name="LiruRegionRestartMinimized" tool_tip="Useful for sim owners and people who need to pack up before leaving"/>
<text name="EmergencyTeleportDesc" left="14" bottom_delta="-12" follows="top">Drop a landmark below to autoteleport there in the last 20 seconds before region restarts</text>
<drop_target control_name="EmergencyTeleportLandmark" bottom_delta="-8" left="15" height="17" name="emergency_teleport_landmark_drop" width="430"/>
<text name="EmergencyTeleportBackupDesc" halign="center" width="432" left="14" bottom_delta="-26" follows="top">Drop a backup landmark to autoteleport to below, should you already be at the above</text>
<drop_target control_name="EmergencyTeleportLandmarkBackup" bottom_delta="-8" left="15" height="17" name="emergency_teleport_landmark_backup_drop" width="430"/>
<text bottom_delta="-26" follows="top" name="UISndRestartText">Sound played when regions will restart:</text>
<line_editor bottom_delta="-6" left_delta="222" follows="top" width="209" height="16" name="UISndRestart" tool_tip="Empty for no sound to play"/>
</panel>