aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs357
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs57
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs4
8 files changed, 318 insertions, 144 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2a0c0b1..ad6b1de 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -124,13 +124,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
124 124
125 // Save avatar attachment information 125 // Save avatar attachment information
126 ScenePresence presence; 126 ScenePresence presence;
127 if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) 127 if (m_scene.AvatarService != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
128 { 128 {
129 m_log.Info( 129 m_log.Info(
130 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 130 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
131 + ", AttachmentPoint: " + AttachmentPt); 131 + ", AttachmentPoint: " + AttachmentPt);
132 132
133 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 133 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
134 } 134 }
135 } 135 }
136 } 136 }
@@ -382,8 +382,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
382 item = m_scene.InventoryService.GetItem(item); 382 item = m_scene.InventoryService.GetItem(item);
383 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); 383 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
384 384
385 if (m_scene.AvatarFactory != null) 385 if (m_scene.AvatarService != null)
386 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 386 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
387 } 387 }
388 } 388 }
389 389
@@ -405,10 +405,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
405 presence.Appearance.DetachAttachment(itemID); 405 presence.Appearance.DetachAttachment(itemID);
406 406
407 // Save avatar attachment information 407 // Save avatar attachment information
408 if (m_scene.AvatarFactory != null) 408 if (m_scene.AvatarService != null)
409 { 409 {
410 m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID); 410 m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
411 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 411 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
412 } 412 }
413 } 413 }
414 414
@@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
435 435
436 presence.Appearance.DetachAttachment(itemID); 436 presence.Appearance.DetachAttachment(itemID);
437 437
438 if (m_scene.AvatarFactory != null) 438 if (m_scene.AvatarService != null)
439 { 439 {
440 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 440 m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
441 } 441 }
442 part.ParentGroup.DetachToGround(); 442 part.ParentGroup.DetachToGround();
443 443
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 22c8937..5f8b4f6 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -32,58 +32,56 @@ using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34 34
35using System.Threading;
36using System.Timers;
37using System.Collections.Generic;
38
35using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
38 42
39namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory 43namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
40{ 44{
41 public class AvatarFactoryModule : IAvatarFactory, IRegionModule 45 public class AvatarFactoryModule : IRegionModule
42 { 46 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
44 private Scene m_scene = null; 49 private Scene m_scene = null;
45 private static readonly AvatarAppearance def = new AvatarAppearance();
46 50
47 public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance) 51 private int m_savetime = 5; // seconds to wait before saving changed appearance
48 { 52 private int m_sendtime = 2; // seconds to wait before sending changed appearance
49 AvatarData avatar = m_scene.AvatarService.GetAvatar(avatarId);
50 //if ((profile != null) && (profile.RootFolder != null))
51 if (avatar != null)
52 {
53 appearance = avatar.ToAvatarAppearance(avatarId);
54 return true;
55 }
56 53
57 m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId); 54 private int m_checkTime = 500; // milliseconds to wait between checks for appearance updates
58 appearance = CreateDefault(avatarId); 55 private System.Timers.Timer m_updateTimer = new System.Timers.Timer();
59 return false; 56 private Dictionary<UUID,long> m_savequeue = new Dictionary<UUID,long>();
60 } 57 private Dictionary<UUID,long> m_sendqueue = new Dictionary<UUID,long>();
61 58
62 private AvatarAppearance CreateDefault(UUID avatarId) 59 #region RegionModule Members
63 {
64 AvatarAppearance appearance = null;
65 AvatarWearable[] wearables;
66 byte[] visualParams;
67 GetDefaultAvatarAppearance(out wearables, out visualParams);
68 appearance = new AvatarAppearance(avatarId, wearables, visualParams);
69
70 return appearance;
71 }
72 60
73 public void Initialise(Scene scene, IConfigSource source) 61 public void Initialise(Scene scene, IConfigSource config)
74 { 62 {
75 scene.RegisterModuleInterface<IAvatarFactory>(this);
76 scene.EventManager.OnNewClient += NewClient; 63 scene.EventManager.OnNewClient += NewClient;
77 64
78 if (m_scene == null) 65 if (config != null)
79 { 66 {
80 m_scene = scene; 67 IConfig sconfig = config.Configs["Startup"];
68 if (sconfig != null)
69 {
70 m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime)));
71 m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
72 }
81 } 73 }
82 74
75 if (m_scene == null)
76 m_scene = scene;
83 } 77 }
84 78
85 public void PostInitialise() 79 public void PostInitialise()
86 { 80 {
81 m_updateTimer.Enabled = false;
82 m_updateTimer.AutoReset = true;
83 m_updateTimer.Interval = m_checkTime; // 500 milliseconds wait to start async ops
84 m_updateTimer.Elapsed += new ElapsedEventHandler(HandleAppearanceUpdateTimer);
87 } 85 }
88 86
89 public void Close() 87 public void Close()
@@ -102,6 +100,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
102 100
103 public void NewClient(IClientAPI client) 101 public void NewClient(IClientAPI client)
104 { 102 {
103 client.OnRequestWearables += SendWearables;
104 client.OnSetAppearance += SetAppearance;
105 client.OnAvatarNowWearing += AvatarIsWearing; 105 client.OnAvatarNowWearing += AvatarIsWearing;
106 } 106 }
107 107
@@ -110,42 +110,211 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
110 // client.OnAvatarNowWearing -= AvatarIsWearing; 110 // client.OnAvatarNowWearing -= AvatarIsWearing;
111 } 111 }
112 112
113 public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) 113 #endregion
114
115 /// <summary>
116 /// Set appearance data (textureentry and slider settings) received from the client
117 /// </summary>
118 /// <param name="texture"></param>
119 /// <param name="visualParam"></param>
120 public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
114 { 121 {
115 IInventoryService invService = m_scene.InventoryService; 122// DEBUG ON
123 m_log.WarnFormat("[AVFACTORY] SetAppearance for {0}",client.AgentId);
124// DEBUG OFF
116 125
117 if (invService.GetRootFolder(userID) != null) 126 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
127 if (sp == null)
118 { 128 {
119 for (int i = 0; i < 13; i++) 129 m_log.WarnFormat("[AVFACTORY] SetAppearance unable to find presence for {0}",client.AgentId);
130 return;
131 }
132
133 bool changed = false;
134
135 // Process the texture entry
136 if (textureEntry != null)
137 {
138 changed = sp.Appearance.SetTextureEntries(textureEntry);
139
140 for (int i = 0; i < BAKE_INDICES.Length; i++)
120 { 141 {
121 if (appearance.Wearables[i].ItemID == UUID.Zero) 142 int idx = BAKE_INDICES[i];
143 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
144 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
145 Util.FireAndForget(delegate(object o) { CheckBakedTextureAssets(client,face.TextureID,idx); });
146 }
147 }
148
149 // Process the visual params, this may change height as well
150 if (visualParams != null)
151 {
152 if (sp.Appearance.SetVisualParams(visualParams))
153 {
154 changed = true;
155 if (sp.Appearance.AvatarHeight > 0)
156 sp.SetHeight(sp.Appearance.AvatarHeight);
157 }
158 }
159
160 // If something changed in the appearance then queue an appearance save
161 if (changed)
162 QueueAppearanceSave(client.AgentId);
163
164 // And always queue up an appearance update to send out
165 QueueAppearanceSend(client.AgentId);
166
167 // Send the appearance back to the avatar
168 AvatarAppearance avp = sp.Appearance;
169 sp.ControllingClient.SendAvatarDataImmediate(sp);
170 sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
171 }
172
173 /// <summary>
174 /// Checks for the existance of a baked texture asset and
175 /// requests the viewer rebake if the asset is not found
176 /// </summary>
177 /// <param name="client"></param>
178 /// <param name="textureID"></param>
179 /// <param name="idx"></param>
180 private void CheckBakedTextureAssets(IClientAPI client, UUID textureID, int idx)
181 {
182 if (m_scene.AssetService.Get(textureID.ToString()) == null)
183 {
184 m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",
185 textureID,idx,client.Name);
186 client.SendRebakeAvatarTextures(textureID);
187 }
188 }
189
190 #region UpdateAppearanceTimer
191
192 public void QueueAppearanceSend(UUID agentid)
193 {
194// DEBUG ON
195 m_log.WarnFormat("[AVFACTORY] Queue appearance send for {0}",agentid);
196// DEBUG OFF
197
198 // 100 nanoseconds (ticks) we should wait
199 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 10000000);
200 lock (m_sendqueue)
201 {
202 m_sendqueue[agentid] = timestamp;
203 m_updateTimer.Start();
204 }
205 }
206
207 public void QueueAppearanceSave(UUID agentid)
208 {
209// DEBUG ON
210 m_log.WarnFormat("[AVFACTORY] Queue appearance save for {0}",agentid);
211// DEBUG OFF
212
213 // 100 nanoseconds (ticks) we should wait
214 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 10000000);
215 lock (m_savequeue)
216 {
217 m_savequeue[agentid] = timestamp;
218 m_updateTimer.Start();
219 }
220 }
221
222 private void HandleAppearanceSend(UUID agentid)
223 {
224 ScenePresence sp = m_scene.GetScenePresence(agentid);
225 if (sp == null)
226 {
227 m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid);
228 return;
229 }
230
231// DEBUG ON
232 m_log.WarnFormat("[AVFACTORY] Handle appearance send for {0}\n{1}",agentid,sp.Appearance.ToString());
233// DEBUG OFF
234
235 // Send the appearance to everyone in the scene
236 sp.SendAppearanceToAllOtherAgents();
237
238 // Send the appearance back to the avatar
239 AvatarAppearance avp = sp.Appearance;
240 sp.ControllingClient.SendAvatarDataImmediate(sp);
241 sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
242
243/*
244// this needs to be fixed, the flag should be on scene presence not the region module
245 // Start the animations if necessary
246 if (!m_startAnimationSet)
247 {
248 sp.Animator.UpdateMovementAnimations();
249 m_startAnimationSet = true;
250 }
251*/
252 }
253
254 private void HandleAppearanceSave(UUID agentid)
255 {
256 ScenePresence sp = m_scene.GetScenePresence(agentid);
257 if (sp == null)
258 {
259 m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid);
260 return;
261 }
262
263 m_scene.AvatarService.SetAppearance(agentid, sp.Appearance);
264 }
265
266 private void HandleAppearanceUpdateTimer(object sender, EventArgs ea)
267 {
268 long now = DateTime.Now.Ticks;
269
270 lock (m_sendqueue)
271 {
272 Dictionary<UUID,long> sends = new Dictionary<UUID,long>(m_sendqueue);
273 foreach (KeyValuePair<UUID,long> kvp in sends)
274 {
275 if (kvp.Value < now)
122 { 276 {
123 appearance.Wearables[i].AssetID = UUID.Zero; 277 Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); });
278 m_sendqueue.Remove(kvp.Key);
124 } 279 }
125 else 280 }
126 { 281 }
127 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID);
128 baseItem = invService.GetItem(baseItem);
129 282
130 if (baseItem != null) 283 lock (m_savequeue)
131 { 284 {
132 appearance.Wearables[i].AssetID = baseItem.AssetID; 285 Dictionary<UUID,long> saves = new Dictionary<UUID,long>(m_savequeue);
133 } 286 foreach (KeyValuePair<UUID,long> kvp in saves)
134 else 287 {
135 { 288 if (kvp.Value < now)
136 m_log.ErrorFormat( 289 {
137 "[APPEARANCE]: Can't find inventory item {0} for {1}, setting to default", 290 Util.FireAndForget(delegate(object o) { HandleAppearanceSave(kvp.Key); });
138 appearance.Wearables[i].ItemID, (WearableType)i); 291 m_savequeue.Remove(kvp.Key);
139
140 appearance.Wearables[i].AssetID = def.Wearables[i].AssetID;
141 }
142 } 292 }
143 } 293 }
144 } 294 }
145 else 295
296 if (m_savequeue.Count == 0 && m_sendqueue.Count == 0)
297 m_updateTimer.Stop();
298 }
299
300 #endregion
301
302 /// <summary>
303 /// Tell the client for this scene presence what items it should be wearing now
304 /// </summary>
305 public void SendWearables(IClientAPI client)
306 {
307 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
308 if (sp == null)
146 { 309 {
147 m_log.WarnFormat("[APPEARANCE]: user {0} has no inventory, appearance isn't going to work", userID); 310 m_log.WarnFormat("[AVFACTORY] SendWearables unable to find presence for {0}",client.AgentId);
311 return;
148 } 312 }
313
314// DEBUG ON
315 m_log.WarnFormat("[AVFACTORY]: Received request for wearables of {0}", client.AgentId);
316// DEBUG OFF
317 client.SendWearables(sp.Appearance.Wearables,sp.Appearance.Serial++);
149 } 318 }
150 319
151 /// <summary> 320 /// <summary>
@@ -153,65 +322,81 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
153 /// </summary> 322 /// </summary>
154 /// <param name="sender"></param> 323 /// <param name="sender"></param>
155 /// <param name="e"></param> 324 /// <param name="e"></param>
156 public void AvatarIsWearing(Object sender, AvatarWearingArgs e) 325 public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
157 { 326 {
158 m_log.DebugFormat("[APPEARANCE]: AvatarIsWearing"); 327 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
159 328 if (sp == null)
160 IClientAPI clientView = (IClientAPI)sender;
161 ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId);
162
163 if (sp == null)
164 { 329 {
165 m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event"); 330 m_log.WarnFormat("[AVFACTORY] AvatarIsWearing unable to find presence for {0}",client.AgentId);
166 return; 331 return;
167 } 332 }
333
334// DEBUG ON
335 m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}",client.AgentId);
336// DEBUG OFF
337
338 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance);
168 339
169 AvatarAppearance avatAppearance = sp.Appearance; 340 //if (!TryGetAvatarAppearance(client.AgentId, out avatAppearance))
170 //if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance))
171 //{ 341 //{
172 // m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); 342 // m_log.Warn("[AVFACTORY]: We didn't seem to find the appearance, falling back to ScenePresence");
173 // avatAppearance = sp.Appearance; 343 // avatAppearance = sp.Appearance;
174 //} 344 //}
175 345
176 //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); 346 //m_log.DebugFormat("[AVFACTORY]: Received wearables for {0}", client.Name);
177 347
178 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) 348 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
179 { 349 {
180 if (wear.Type < 13) 350 if (wear.Type < AvatarWearable.MAX_WEARABLES)
181 { 351 {
182 avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; 352 AvatarWearable newWearable = new AvatarWearable(wear.ItemID,UUID.Zero);
353 avatAppearance.SetWearable(wear.Type, newWearable);
183 } 354 }
184 } 355 }
185 356
186 SetAppearanceAssets(sp.UUID, ref avatAppearance); 357 SetAppearanceAssets(sp.UUID, ref avatAppearance);
187 AvatarData adata = new AvatarData(avatAppearance);
188 m_scene.AvatarService.SetAvatar(clientView.AgentId, adata);
189 358
359 m_scene.AvatarService.SetAppearance(client.AgentId, avatAppearance);
190 sp.Appearance = avatAppearance; 360 sp.Appearance = avatAppearance;
191 } 361 }
192 362
193 public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) 363 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
194 { 364 {
195 visualParams = GetDefaultVisualParams(); 365 IInventoryService invService = m_scene.InventoryService;
196 wearables = AvatarWearable.DefaultWearables;
197 }
198 366
199 public void UpdateDatabase(UUID user, AvatarAppearance appearance) 367 if (invService.GetRootFolder(userID) != null)
200 { 368 {
201 //m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); 369 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
202 AvatarData adata = new AvatarData(appearance); 370 {
203 m_scene.AvatarService.SetAvatar(user, adata); 371 if (appearance.Wearables[i].ItemID == UUID.Zero)
204 } 372 {
373 appearance.Wearables[i].AssetID = UUID.Zero;
374 }
375 else
376 {
377 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID);
378 baseItem = invService.GetItem(baseItem);
205 379
206 private static byte[] GetDefaultVisualParams() 380 if (baseItem != null)
207 { 381 {
208 byte[] visualParams; 382 appearance.Wearables[i].AssetID = baseItem.AssetID;
209 visualParams = new byte[218]; 383 }
210 for (int i = 0; i < 218; i++) 384 else
385 {
386 m_log.ErrorFormat(
387 "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
388 appearance.Wearables[i].ItemID, (WearableType)i);
389
390 appearance.Wearables[i].ItemID = UUID.Zero;
391 appearance.Wearables[i].AssetID = UUID.Zero;
392 }
393 }
394 }
395 }
396 else
211 { 397 {
212 visualParams[i] = 100; 398 m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
213 } 399 }
214 return visualParams;
215 } 400 }
216 } 401 }
217} 402}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 918fa04..fdc48c6 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -599,7 +599,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
599 try 599 try
600 { 600 {
601 601
602 XmlRpcResponse GridResp = GridReq.Send("http://" + reginfo.ExternalHostName + ":" + reginfo.HttpPort, 3000); 602 XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, 3000);
603 603
604 Hashtable responseData = (Hashtable)GridResp.Value; 604 Hashtable responseData = (Hashtable)GridResp.Value;
605 605
@@ -621,8 +621,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
621 } 621 }
622 catch (WebException e) 622 catch (WebException e)
623 { 623 {
624 m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to http://{0}:{1} the host didn't respond ({2})", 624 m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0}} the host didn't respond ({2})",
625 reginfo.ExternalHostName, reginfo.HttpPort, e.Message); 625 reginfo.ServerURI, e.Message);
626 } 626 }
627 627
628 return false; 628 return false;
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 38fff1c..925af3f 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -197,8 +197,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
197 sp.ControllingClient.SendTeleportFailed("Problem at destination"); 197 sp.ControllingClient.SendTeleportFailed("Problem at destination");
198 return; 198 return;
199 } 199 }
200 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}", 200 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} {2}@{3}",
201 finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID); 201 finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID, finalDestination.ServerURI);
202 202
203 // Check that these are not the same coordinates 203 // Check that these are not the same coordinates
204 if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX && 204 if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX &&
@@ -254,8 +254,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
254 } 254 }
255 255
256 m_log.DebugFormat( 256 m_log.DebugFormat(
257 "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}", 257 "[ENTITY TRANSFER MODULE]: Request Teleport to {0} ({1}) {2}/{3}",
258 reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position); 258 reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position);
259 259
260 uint newRegionX = (uint)(reg.RegionHandle >> 40); 260 uint newRegionX = (uint)(reg.RegionHandle >> 40);
261 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); 261 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
@@ -327,43 +327,21 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
327 327
328 // OK, it got this agent. Let's close some child agents 328 // OK, it got this agent. Let's close some child agents
329 sp.CloseChildAgents(newRegionX, newRegionY); 329 sp.CloseChildAgents(newRegionX, newRegionY);
330 330 IClientIPEndpoint ipepClient;
331 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) 331 if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
332 { 332 {
333 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); 333 //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
334
335 #region IP Translation for NAT 334 #region IP Translation for NAT
336 IClientIPEndpoint ipepClient; 335 // Uses ipepClient above
337 if (sp.ClientView.TryGet(out ipepClient)) 336 if (sp.ClientView.TryGet(out ipepClient))
338 { 337 {
339 capsPath 338 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
340 = "http://"
341 + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName)
342 + ":"
343 + finalDestination.HttpPort
344 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
345 }
346 else
347 {
348 capsPath
349 = "http://"
350 + finalDestination.ExternalHostName
351 + ":"
352 + finalDestination.HttpPort
353 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
354 } 339 }
355 #endregion 340 #endregion
341 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
356 342
357 if (eq != null) 343 if (eq != null)
358 { 344 {
359 #region IP Translation for NAT
360 // Uses ipepClient above
361 if (sp.ClientView.TryGet(out ipepClient))
362 {
363 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
364 }
365 #endregion
366
367 eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); 345 eq.EnableSimulator(destinationHandle, endPoint, sp.UUID);
368 346
369 // ES makes the client send a UseCircuitCode message to the destination, 347 // ES makes the client send a UseCircuitCode message to the destination,
@@ -382,8 +360,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
382 else 360 else
383 { 361 {
384 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); 362 agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
385 capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort 363 capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
386 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
387 } 364 }
388 365
389 // Expect avatar crossing is a heavy-duty function at the destination. 366 // Expect avatar crossing is a heavy-duty function at the destination.
@@ -516,8 +493,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
516 493
517 protected virtual void SetCallbackURL(AgentData agent, RegionInfo region) 494 protected virtual void SetCallbackURL(AgentData agent, RegionInfo region)
518 { 495 {
519 agent.CallbackURI = "http://" + region.ExternalHostName + ":" + region.HttpPort + 496 agent.CallbackURI = region.ServerURI + "agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/";
520 "/agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/"; 497 m_log.Debug("Set callback URL to " + agent.CallbackURI);
521 498
522 } 499 }
523 500
@@ -842,8 +819,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
842 cAgent.Position = pos; 819 cAgent.Position = pos;
843 if (isFlying) 820 if (isFlying)
844 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; 821 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
845 cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort + 822 cAgent.CallbackURI = m_scene.RegionInfo.ServerURI +
846 "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/"; 823 "agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/";
847 824
848 if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) 825 if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent))
849 { 826 {
@@ -868,10 +845,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
868 neighbourRegion.RegionHandle); 845 neighbourRegion.RegionHandle);
869 return agent; 846 return agent;
870 } 847 }
871 // TODO Should construct this behind a method 848 string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps);
872 string capsPath =
873 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
874 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
875 849
876 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); 850 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
877 851
@@ -1190,8 +1164,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1190 y = y / Constants.RegionSize; 1164 y = y / Constants.RegionSize;
1191 m_log.Info("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); 1165 m_log.Info("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
1192 1166
1193 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort 1167 string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath);
1194 + "/CAPS/" + a.CapsPath + "0000/";
1195 1168
1196 string reason = String.Empty; 1169 string reason = String.Empty;
1197 1170
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 1ac7508..7796a08 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -123,7 +123,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
123 if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) 123 if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
124 { 124 {
125 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); 125 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID);
126 return m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID); 126 GridRegion real_destination = m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID);
127 m_log.Debug("GetfinalDestination serveruri -> " + real_destination.ServerURI);
128 return real_destination;
127 } 129 }
128 return region; 130 return region;
129 } 131 }
@@ -149,6 +151,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
149 151
150 protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) 152 protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout)
151 { 153 {
154 m_log.Debug("CreateAgent " + reg.ServerURI + " " + finalDestination.ServerURI);
152 reason = string.Empty; 155 reason = string.Empty;
153 logout = false; 156 logout = false;
154 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); 157 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID);
@@ -235,6 +238,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
235 string url = aCircuit.ServiceURLs["HomeURI"].ToString(); 238 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
236 IUserAgentService security = new UserAgentServiceConnector(url); 239 IUserAgentService security = new UserAgentServiceConnector(url);
237 return security.VerifyClient(aCircuit.SessionID, token); 240 return security.VerifyClient(aCircuit.SessionID, token);
241 } else {
242 m_log.Debug("this gent does not have a HomeURI OH NO");
238 } 243 }
239 244
240 return false; 245 return false;
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index fd0e879..2dd7767 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -595,12 +595,12 @@ namespace OpenSim.Region.CoreModules.InterGrid
595 // DEPRECATED 595 // DEPRECATED
596 responseMap["seed_capability"] 596 responseMap["seed_capability"]
597 = OSD.FromString( 597 = OSD.FromString(
598 regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath)); 598 regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + "/" + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath));
599 599
600 // REPLACEMENT 600 // REPLACEMENT
601 responseMap["region_seed_capability"] 601 responseMap["region_seed_capability"]
602 = OSD.FromString( 602 = OSD.FromString(
603 regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath)); 603 regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + "/" + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath));
604 604
605 responseMap["rez_avatar"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath); 605 responseMap["rez_avatar"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath);
606 responseMap["rez_avatar/rez"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath); 606 responseMap["rez_avatar/rez"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs
index 47f19a3..9ee19f8 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
35using OpenSim.Server.Base; 36using OpenSim.Server.Base;
@@ -137,6 +138,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar
137 138
138 #region IAvatarService 139 #region IAvatarService
139 140
141 public AvatarAppearance GetAppearance(UUID userID)
142 {
143 return m_AvatarService.GetAppearance(userID);
144 }
145
146 public bool SetAppearance(UUID userID, AvatarAppearance appearance)
147 {
148 return m_AvatarService.SetAppearance(userID,appearance);
149 }
150
140 public AvatarData GetAvatar(UUID userID) 151 public AvatarData GetAvatar(UUID userID)
141 { 152 {
142 return m_AvatarService.GetAvatar(userID); 153 return m_AvatarService.GetAvatar(userID);
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index a182eea..fdbbccf 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -147,7 +147,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
147 147
148 string regionimage = "regionImage" + m_scene.RegionInfo.RegionID.ToString(); 148 string regionimage = "regionImage" + m_scene.RegionInfo.RegionID.ToString();
149 regionimage = regionimage.Replace("-", ""); 149 regionimage = regionimage.Replace("-", "");
150 m_log.Info("[WORLD MAP]: JPEG Map location: http://" + m_scene.RegionInfo.ExternalEndPoint.Address.ToString() + ":" + m_scene.RegionInfo.HttpPort.ToString() + "/index.php?method=" + regionimage); 150 m_log.Info("[WORLD MAP]: JPEG Map location: " + m_scene.RegionInfo.ServerURI + "/index.php?method=" + regionimage);
151 151
152 MainServer.Instance.AddHTTPHandler(regionimage, OnHTTPGetMapImage); 152 MainServer.Instance.AddHTTPHandler(regionimage, OnHTTPGetMapImage);
153 MainServer.Instance.AddLLSDHandler( 153 MainServer.Instance.AddLLSDHandler(
@@ -579,7 +579,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
579 579
580 if (mreg != null) 580 if (mreg != null)
581 { 581 {
582 httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString(); 582 httpserver = mreg.ServerURI + "MAP/MapItems/" + regionhandle.ToString();
583 lock (m_cachedRegionMapItemsAddress) 583 lock (m_cachedRegionMapItemsAddress)
584 { 584 {
585 if (!m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) 585 if (!m_cachedRegionMapItemsAddress.ContainsKey(regionhandle))