aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJonathan Freedman2010-10-29 23:12:51 -0400
committerJonathan Freedman2010-10-29 23:12:51 -0400
commitd219317074ae8ff1665118988cecb8168ae0085e (patch)
tree89a6b01925b24f83272ec36f0b6a9c378f235d59 /OpenSim/Region/CoreModules
parentMerge branch 'master' into mantis5110 (diff)
parentConfiguration of persistent baked textures and save/send delays. (diff)
downloadopensim-SC_OLD-d219317074ae8ff1665118988cecb8168ae0085e.zip
opensim-SC_OLD-d219317074ae8ff1665118988cecb8168ae0085e.tar.gz
opensim-SC_OLD-d219317074ae8ff1665118988cecb8168ae0085e.tar.bz2
opensim-SC_OLD-d219317074ae8ff1665118988cecb8168ae0085e.tar.xz
Merge branch 'master' into mantis5110
Conflicts: OpenSim/Region/Framework/Scenes/ScenePresence.cs
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/Chat/ChatModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs57
8 files changed, 317 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/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index d76ff47..4359c01 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
238 } 238 }
239 239
240 (scene as Scene).EventManager.TriggerOnChatToClients( 240 (scene as Scene).EventManager.TriggerOnChatToClients(
241 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 241 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
242 } 242 }
243 243
244 static private Vector3 CenterOfRegion = new Vector3(128, 128, 30); 244 static private Vector3 CenterOfRegion = new Vector3(128, 128, 30);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 5500557..046b05f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
143 if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 143 if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
144 { 144 {
145 LoadControlFile(filePath, data); 145 LoadControlFile(filePath, data);
146 } 146 }
147 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 147 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
148 { 148 {
149 if (LoadAsset(filePath, data)) 149 if (LoadAsset(filePath, data))
@@ -479,11 +479,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
479 /// <param name="path"></param> 479 /// <param name="path"></param>
480 /// <param name="data"></param> 480 /// <param name="data"></param>
481 protected void LoadControlFile(string path, byte[] data) 481 protected void LoadControlFile(string path, byte[] data)
482 { 482 {
483 XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data)); 483 XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data));
484 XElement archiveElement = doc.Element("archive"); 484 XElement archiveElement = doc.Element("archive");
485 int majorVersion = int.Parse(archiveElement.Attribute("major_version").Value); 485 int majorVersion = int.Parse(archiveElement.Attribute("major_version").Value);
486 int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value); 486 int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value);
487 string version = string.Format("{0}.{1}", majorVersion, minorVersion); 487 string version = string.Format("{0}.{1}", majorVersion, minorVersion);
488 488
489 if (majorVersion > MAX_MAJOR_VERSION) 489 if (majorVersion > MAX_MAJOR_VERSION)
@@ -492,7 +492,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
492 string.Format( 492 string.Format(
493 "The IAR you are trying to load has major version number of {0} but this version of OpenSim can only load IARs with major version number {1} and below", 493 "The IAR you are trying to load has major version number of {0} but this version of OpenSim can only load IARs with major version number {1} and below",
494 majorVersion, MAX_MAJOR_VERSION)); 494 majorVersion, MAX_MAJOR_VERSION));
495 } 495 }
496 496
497 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); 497 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
498 } 498 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 249a8b4..9080e1c 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -213,7 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
213 public void Execute() 213 public void Execute()
214 { 214 {
215 try 215 try
216 { 216 {
217 InventoryFolderBase inventoryFolder = null; 217 InventoryFolderBase inventoryFolder = null;
218 InventoryItemBase inventoryItem = null; 218 InventoryItemBase inventoryItem = null;
219 InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); 219 InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID);
@@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
277 // Write out control file. This has to be done first so that subsequent loaders will see this file first 277 // Write out control file. This has to be done first so that subsequent loaders will see this file first
278 // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this 278 // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
279 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); 279 m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
280 m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive."); 280 m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive.");
281 281
282 if (inventoryFolder != null) 282 if (inventoryFolder != null)
283 { 283 {
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/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index 1687d06..3182079 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -199,13 +199,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
199 { 199 {
200 majorVersion = 1; 200 majorVersion = 1;
201 minorVersion = 0; 201 minorVersion = 0;
202 } 202 }
203 */ 203 */
204 204
205 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); 205 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
206// if (majorVersion == 1) 206// if (majorVersion == 1)
207// { 207// {
208// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); 208// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
209// } 209// }
210 210
211 211
@@ -232,6 +232,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
232 sw.Close(); 232 sw.Close();
233 233
234 return s; 234 return s;
235 } 235 }
236 } 236 }
237} 237}
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index a6dc2ec..cea7c78 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -44,10 +44,8 @@ namespace OpenSim.Region.CoreModules
44 /// it is not based on ~06:00 == Sun Rise. Rather it is based on 00:00 being sun-rise. 44 /// it is not based on ~06:00 == Sun Rise. Rather it is based on 00:00 being sun-rise.
45 /// </summary> 45 /// </summary>
46 46
47
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 48
50
51 // 49 //
52 // Global Constants used to determine where in the sky the sun is 50 // Global Constants used to determine where in the sky the sun is
53 // 51 //
@@ -108,26 +106,25 @@ namespace OpenSim.Region.CoreModules
108 private Scene m_scene = null; 106 private Scene m_scene = null;
109 107
110 // Calculated Once in the lifetime of a region 108 // Calculated Once in the lifetime of a region
111 private long TicksToEpoch; // Elapsed time for 1/1/1970 109 private long TicksToEpoch; // Elapsed time for 1/1/1970
112 private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds 110 private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds
113 private uint SecondsPerYear; // Length of a virtual year in RW seconds 111 private uint SecondsPerYear; // Length of a virtual year in RW seconds
114 private double SunSpeed; // Rate of passage in radians/second 112 private double SunSpeed; // Rate of passage in radians/second
115 private double SeasonSpeed; // Rate of change for seasonal effects 113 private double SeasonSpeed; // Rate of change for seasonal effects
116 // private double HoursToRadians; // Rate of change for seasonal effects 114 // private double HoursToRadians; // Rate of change for seasonal effects
117 private long TicksUTCOffset = 0; // seconds offset from UTC 115 private long TicksUTCOffset = 0; // seconds offset from UTC
118 // Calculated every update 116 // Calculated every update
119 private float OrbitalPosition; // Orbital placement at a point in time 117 private float OrbitalPosition; // Orbital placement at a point in time
120 private double HorizonShift; // Axis offset to skew day and night 118 private double HorizonShift; // Axis offset to skew day and night
121 private double TotalDistanceTravelled; // Distance since beginning of time (in radians) 119 private double TotalDistanceTravelled; // Distance since beginning of time (in radians)
122 private double SeasonalOffset; // Seaonal variation of tilt 120 private double SeasonalOffset; // Seaonal variation of tilt
123 private float Magnitude; // Normal tilt 121 private float Magnitude; // Normal tilt
124 // private double VWTimeRatio; // VW time as a ratio of real time 122 // private double VWTimeRatio; // VW time as a ratio of real time
125 123
126 // Working values 124 // Working values
127 private Vector3 Position = Vector3.Zero; 125 private Vector3 Position = Vector3.Zero;
128 private Vector3 Velocity = Vector3.Zero; 126 private Vector3 Velocity = Vector3.Zero;
129 private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f); 127 private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f);
130
131 128
132 // Used to fix the sun in the sky so it doesn't move based on current time 129 // Used to fix the sun in the sky so it doesn't move based on current time
133 private bool m_SunFixed = false; 130 private bool m_SunFixed = false;
@@ -135,8 +132,6 @@ namespace OpenSim.Region.CoreModules
135 132
136 private const int TICKS_PER_SECOND = 10000000; 133 private const int TICKS_PER_SECOND = 10000000;
137 134
138
139
140 // Current time in elapsed seconds since Jan 1st 1970 135 // Current time in elapsed seconds since Jan 1st 1970
141 private ulong CurrentTime 136 private ulong CurrentTime
142 { 137 {
@@ -149,8 +144,6 @@ namespace OpenSim.Region.CoreModules
149 // Time in seconds since UTC to use to calculate sun position. 144 // Time in seconds since UTC to use to calculate sun position.
150 ulong PosTime = 0; 145 ulong PosTime = 0;
151 146
152
153
154 /// <summary> 147 /// <summary>
155 /// Calculate the sun's orbital position and its velocity. 148 /// Calculate the sun's orbital position and its velocity.
156 /// </summary> 149 /// </summary>
@@ -202,7 +195,6 @@ namespace OpenSim.Region.CoreModules
202 PosTime += (ulong)(((CurDayPercentage - 0.5) / .5) * NightSeconds); 195 PosTime += (ulong)(((CurDayPercentage - 0.5) / .5) * NightSeconds);
203 } 196 }
204 } 197 }
205
206 } 198 }
207 199
208 TotalDistanceTravelled = SunSpeed * PosTime; // distance measured in radians 200 TotalDistanceTravelled = SunSpeed * PosTime; // distance measured in radians
@@ -251,7 +243,6 @@ namespace OpenSim.Region.CoreModules
251 Velocity.X = 0; 243 Velocity.X = 0;
252 Velocity.Y = 0; 244 Velocity.Y = 0;
253 Velocity.Z = 0; 245 Velocity.Z = 0;
254
255 } 246 }
256 else 247 else
257 { 248 {
@@ -271,9 +262,7 @@ namespace OpenSim.Region.CoreModules
271 private float GetCurrentTimeAsLindenSunHour() 262 private float GetCurrentTimeAsLindenSunHour()
272 { 263 {
273 if (m_SunFixed) 264 if (m_SunFixed)
274 {
275 return m_SunFixedHour + 6; 265 return m_SunFixedHour + 6;
276 }
277 266
278 return GetCurrentSunHour() + 6.0f; 267 return GetCurrentSunHour() + 6.0f;
279 } 268 }
@@ -297,8 +286,6 @@ namespace OpenSim.Region.CoreModules
297 m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand); 286 m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand);
298 } 287 }
299 288
300
301
302 TimeZone local = TimeZone.CurrentTimeZone; 289 TimeZone local = TimeZone.CurrentTimeZone;
303 TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; 290 TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
304 m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset); 291 m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset);
@@ -325,13 +312,11 @@ namespace OpenSim.Region.CoreModules
325 // must hard code to ~.5 to match sun position in LL based viewers 312 // must hard code to ~.5 to match sun position in LL based viewers
326 m_HorizonShift = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night); 313 m_HorizonShift = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night);
327 314
328
329 // Scales the sun hours 0...12 vs 12...24, essentially makes daylight hours longer/shorter vs nighttime hours 315 // Scales the sun hours 0...12 vs 12...24, essentially makes daylight hours longer/shorter vs nighttime hours
330 m_DayTimeSunHourScale = config.Configs["Sun"].GetDouble("day_time_sun_hour_scale", d_DayTimeSunHourScale); 316 m_DayTimeSunHourScale = config.Configs["Sun"].GetDouble("day_time_sun_hour_scale", d_DayTimeSunHourScale);
331 317
332 // Update frequency in frames 318 // Update frequency in frames
333 m_UpdateInterval = config.Configs["Sun"].GetInt("update_interval", d_frame_mod); 319 m_UpdateInterval = config.Configs["Sun"].GetInt("update_interval", d_frame_mod);
334
335 } 320 }
336 catch (Exception e) 321 catch (Exception e)
337 { 322 {
@@ -391,10 +376,8 @@ namespace OpenSim.Region.CoreModules
391 } 376 }
392 377
393 scene.RegisterModuleInterface<ISunModule>(this); 378 scene.RegisterModuleInterface<ISunModule>(this);
394
395 } 379 }
396 380
397
398 public void PostInitialise() 381 public void PostInitialise()
399 { 382 {
400 } 383 }
@@ -402,7 +385,7 @@ namespace OpenSim.Region.CoreModules
402 public void Close() 385 public void Close()
403 { 386 {
404 ready = false; 387 ready = false;
405 388
406 // Remove our hooks 389 // Remove our hooks
407 m_scene.EventManager.OnFrame -= SunUpdate; 390 m_scene.EventManager.OnFrame -= SunUpdate;
408 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; 391 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
@@ -419,6 +402,7 @@ namespace OpenSim.Region.CoreModules
419 { 402 {
420 get { return false; } 403 get { return false; }
421 } 404 }
405
422 #endregion 406 #endregion
423 407
424 #region EventManager Events 408 #region EventManager Events
@@ -446,9 +430,7 @@ namespace OpenSim.Region.CoreModules
446 public void SunUpdate() 430 public void SunUpdate()
447 { 431 {
448 if (((m_frame++ % m_UpdateInterval) != 0) || !ready || m_SunFixed || !receivedEstateToolsSunUpdate) 432 if (((m_frame++ % m_UpdateInterval) != 0) || !ready || m_SunFixed || !receivedEstateToolsSunUpdate)
449 {
450 return; 433 return;
451 }
452 434
453 GenSunPos(); // Generate shared values once 435 GenSunPos(); // Generate shared values once
454 436
@@ -467,7 +449,7 @@ namespace OpenSim.Region.CoreModules
467 } 449 }
468 450
469 /// <summary> 451 /// <summary>
470 /// 452 ///
471 /// </summary> 453 /// </summary>
472 /// <param name="regionHandle"></param> 454 /// <param name="regionHandle"></param>
473 /// <param name="FixedTime">Is the sun's position fixed?</param> 455 /// <param name="FixedTime">Is the sun's position fixed?</param>
@@ -484,7 +466,6 @@ namespace OpenSim.Region.CoreModules
484 while (FixedSunHour < 0) 466 while (FixedSunHour < 0)
485 FixedSunHour += 24; 467 FixedSunHour += 24;
486 468
487
488 m_SunFixedHour = FixedSunHour; 469 m_SunFixedHour = FixedSunHour;
489 m_SunFixed = FixedSun; 470 m_SunFixed = FixedSun;
490 471
@@ -499,14 +480,12 @@ namespace OpenSim.Region.CoreModules
499 // When sun settings are updated, we should update all clients with new settings. 480 // When sun settings are updated, we should update all clients with new settings.
500 SunUpdateToAllClients(); 481 SunUpdateToAllClients();
501 482
502
503 m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString()); 483 m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString());
504 } 484 }
505 } 485 }
506 486
507 #endregion 487 #endregion
508 488
509
510 private void SunUpdateToAllClients() 489 private void SunUpdateToAllClients()
511 { 490 {
512 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 491 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
@@ -553,7 +532,6 @@ namespace OpenSim.Region.CoreModules
553 { 532 {
554 float ticksleftover = CurrentTime % SecondsPerSunCycle; 533 float ticksleftover = CurrentTime % SecondsPerSunCycle;
555 534
556
557 return (24.0f * (ticksleftover / SecondsPerSunCycle)); 535 return (24.0f * (ticksleftover / SecondsPerSunCycle));
558 } 536 }
559 537
@@ -666,7 +644,6 @@ namespace OpenSim.Region.CoreModules
666 644
667 // When sun settings are updated, we should update all clients with new settings. 645 // When sun settings are updated, we should update all clients with new settings.
668 SunUpdateToAllClients(); 646 SunUpdateToAllClients();
669
670 } 647 }
671 648
672 return Output; 649 return Output;