From c4c8d45f6051a00fc1e702642c371283c62c2983 Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Fri, 3 Jun 2011 05:39:35 +0000 Subject: [PATCH] RAD-269: Implement support for llMapDestination() ScriptTeleportRequest Packet gives us coordinates as offset from agents current position git-svn-id: https://radegast.googlecode.com/svn/trunk@885 f7a694da-4d33-11de-9ad6-1127a62b9fcd --- Radegast/GUI/Consoles/MapConsole.cs | 42 +++++++++++++++++++++++++++--------- Radegast/GUI/Consoles/TabsConsole.cs | 9 ++++---- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/Radegast/GUI/Consoles/MapConsole.cs b/Radegast/GUI/Consoles/MapConsole.cs index 66ce6f3..40b9dc9 100644 --- a/Radegast/GUI/Consoles/MapConsole.cs +++ b/Radegast/GUI/Consoles/MapConsole.cs @@ -121,11 +121,6 @@ namespace Radegast zoomTracker.Value = newval; } - void mmap_MapTargetChanged(object sender, MapTargetChangedEventArgs e) - { - throw new NotImplementedException(); - } - void map_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { map.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(map_DocumentCompleted); @@ -223,6 +218,31 @@ namespace Radegast btnTeleport.Enabled = false; } + public void CenterOnGlobalPos(float gx, float gy, float z) + { + txtRegion.Text = string.Empty; + + nudX.Value = (int)gx % 256; + nudY.Value = (int)gy % 256; + nudZ.Value = (int)z; + + uint rx = (uint)(gx / 256); + uint ry = (uint)(gy / 256); + + ulong hndle = Utils.UIntsToLong(rx * 256, ry * 256); + targetRegionHandle = hndle; + + foreach (KeyValuePair kvp in regionHandles) + { + if (kvp.Value == hndle) + { + txtRegion.Text = kvp.Key; + btnTeleport.Enabled = true; + } + } + mmap.CenterMap(rx, ry, (uint)gx % 256, (uint)gy % 256, true); + } + #endregion #region NetworkEvents @@ -302,10 +322,11 @@ namespace Radegast return; } - if (e.Region.RegionHandle == friendRegionHandle) + if (e.Region.RegionHandle == targetRegionHandle) { txtRegion.Text = e.Region.Name; - friendRegionHandle = 0; + btnTeleport.Enabled = true; + targetRegionHandle = 0; } if (!string.IsNullOrEmpty(txtRegion.Text) @@ -560,7 +581,7 @@ namespace Radegast #region Map friends FriendInfo mapFriend = null; - ulong friendRegionHandle = 0; + ulong targetRegionHandle = 0; void Friends_FriendFoundReply(object sender, FriendFoundReplyEventArgs e) { @@ -579,7 +600,7 @@ namespace Radegast nudX.Value = (int)e.Location.X; nudY.Value = (int)e.Location.Y; nudZ.Value = (int)e.Location.Z; - friendRegionHandle = e.RegionHandle; + targetRegionHandle = e.RegionHandle; uint x, y; Utils.LongToUInts(e.RegionHandle, out x, out y); x /= 256; @@ -590,6 +611,7 @@ namespace Radegast if (kvp.Value == hndle) { txtRegion.Text = kvp.Key; + btnTeleport.Enabled = true; } } mmap.CenterMap(x, y, (uint)e.Location.X, (uint)e.Location.Y, true); @@ -601,7 +623,7 @@ namespace Radegast mapFriend = client.Friends.FriendList.Find((FriendInfo f) => { return f.Name == ddOnlineFriends.SelectedItem.ToString(); }); if (mapFriend != null) { - friendRegionHandle = 0; + targetRegionHandle = 0; client.Friends.MapFriend(mapFriend.UUID); } } diff --git a/Radegast/GUI/Consoles/TabsConsole.cs b/Radegast/GUI/Consoles/TabsConsole.cs index 7d9c826..875b8d8 100644 --- a/Radegast/GUI/Consoles/TabsConsole.cs +++ b/Radegast/GUI/Consoles/TabsConsole.cs @@ -214,11 +214,10 @@ namespace Radegast if (TabExists("map")) { Tabs["map"].Select(); - ((MapConsole)Tabs["map"].Control).DisplayLocation( - Utils.BytesToString(msg.Data.SimName), - (int)msg.Data.SimPosition.X, - (int)msg.Data.SimPosition.Y, - (int)msg.Data.SimPosition.Z); + ((MapConsole)Tabs["map"].Control).CenterOnGlobalPos( + (float)(client.Self.GlobalPosition.X - client.Self.SimPosition.X) + msg.Data.SimPosition.X, + (float)(client.Self.GlobalPosition.Y - client.Self.SimPosition.Y) + msg.Data.SimPosition.Y, + msg.Data.SimPosition.Z); } } -- 2.11.0