diff options
author | Jonathan Freedman | 2010-10-29 23:12:51 -0400 |
---|---|---|
committer | Jonathan Freedman | 2010-10-29 23:12:51 -0400 |
commit | d219317074ae8ff1665118988cecb8168ae0085e (patch) | |
tree | 89a6b01925b24f83272ec36f0b6a9c378f235d59 /OpenSim/Region/CoreModules/Avatar | |
parent | Merge branch 'master' into mantis5110 (diff) | |
parent | Configuration of persistent baked textures and save/send delays. (diff) | |
download | opensim-SC-d219317074ae8ff1665118988cecb8168ae0085e.zip opensim-SC-d219317074ae8ff1665118988cecb8168ae0085e.tar.gz opensim-SC-d219317074ae8ff1665118988cecb8168ae0085e.tar.bz2 opensim-SC-d219317074ae8ff1665118988cecb8168ae0085e.tar.xz |
Merge branch 'master' into mantis5110
Conflicts:
OpenSim/Region/Framework/Scenes/ScenePresence.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
5 files changed, 286 insertions, 101 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; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | 34 | ||
35 | using System.Threading; | ||
36 | using System.Timers; | ||
37 | using System.Collections.Generic; | ||
38 | |||
35 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
38 | 42 | ||
39 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | 43 | namespace 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 | { |