aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs16
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs347
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs11
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs38
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs172
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs15
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs16
12 files changed, 356 insertions, 282 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 74ad485..14f923d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
79 public event DeRezObject OnDeRezObject; 79 public event DeRezObject OnDeRezObject;
80 public event ModifyTerrain OnModifyTerrain; 80 public event ModifyTerrain OnModifyTerrain;
81 public event Action<IClientAPI> OnRegionHandShakeReply; 81 public event Action<IClientAPI> OnRegionHandShakeReply;
82 public event GenericCall2 OnRequestWearables; 82 public event GenericCall1 OnRequestWearables;
83 public event SetAppearance OnSetAppearance; 83 public event SetAppearance OnSetAppearance;
84 public event AvatarNowWearing OnAvatarNowWearing; 84 public event AvatarNowWearing OnAvatarNowWearing;
85 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 85 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@@ -5647,11 +5647,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5647 5647
5648 private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack) 5648 private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
5649 { 5649 {
5650 GenericCall2 handlerRequestWearables = OnRequestWearables; 5650 GenericCall1 handlerRequestWearables = OnRequestWearables;
5651 5651
5652 if (handlerRequestWearables != null) 5652 if (handlerRequestWearables != null)
5653 { 5653 {
5654 handlerRequestWearables(); 5654 handlerRequestWearables(sender);
5655 } 5655 }
5656 5656
5657 Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData; 5657 Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
@@ -5694,7 +5694,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5694 if (appear.ObjectData.TextureEntry.Length > 1) 5694 if (appear.ObjectData.TextureEntry.Length > 1)
5695 te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); 5695 te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
5696 5696
5697 handlerSetAppearance(te, visualparams); 5697 handlerSetAppearance(sender, te, visualparams);
5698 } 5698 }
5699 catch (Exception e) 5699 catch (Exception e)
5700 { 5700 {
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..903e94b 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -32,58 +32,46 @@ 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 static readonly int m_savetime = 5; // seconds to wait before saving changed appearance
48 { 52 private static readonly 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 static readonly 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 source)
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 (m_scene == null)
79 {
80 m_scene = scene; 66 m_scene = scene;
81 }
82
83 } 67 }
84 68
85 public void PostInitialise() 69 public void PostInitialise()
86 { 70 {
71 m_updateTimer.Enabled = false;
72 m_updateTimer.AutoReset = true;
73 m_updateTimer.Interval = m_checkTime; // 500 milliseconds wait to start async ops
74 m_updateTimer.Elapsed += new ElapsedEventHandler(HandleAppearanceUpdateTimer);
87 } 75 }
88 76
89 public void Close() 77 public void Close()
@@ -102,6 +90,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
102 90
103 public void NewClient(IClientAPI client) 91 public void NewClient(IClientAPI client)
104 { 92 {
93 client.OnRequestWearables += SendWearables;
94 client.OnSetAppearance += SetAppearance;
105 client.OnAvatarNowWearing += AvatarIsWearing; 95 client.OnAvatarNowWearing += AvatarIsWearing;
106 } 96 }
107 97
@@ -110,42 +100,211 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
110 // client.OnAvatarNowWearing -= AvatarIsWearing; 100 // client.OnAvatarNowWearing -= AvatarIsWearing;
111 } 101 }
112 102
113 public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) 103 #endregion
104
105 /// <summary>
106 /// Set appearance data (textureentry and slider settings) received from the client
107 /// </summary>
108 /// <param name="texture"></param>
109 /// <param name="visualParam"></param>
110 public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
114 { 111 {
115 IInventoryService invService = m_scene.InventoryService; 112// DEBUG ON
113 m_log.WarnFormat("[AVFACTORY] SetAppearance for {0}",client.AgentId);
114// DEBUG OFF
116 115
117 if (invService.GetRootFolder(userID) != null) 116 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
117 if (sp == null)
118 { 118 {
119 for (int i = 0; i < 13; i++) 119 m_log.WarnFormat("[AVFACTORY] SetAppearance unable to find presence for {0}",client.AgentId);
120 return;
121 }
122
123 bool changed = false;
124
125 // Process the texture entry
126 if (textureEntry != null)
127 {
128 changed = sp.Appearance.SetTextureEntries(textureEntry);
129
130 for (int i = 0; i < BAKE_INDICES.Length; i++)
120 { 131 {
121 if (appearance.Wearables[i].ItemID == UUID.Zero) 132 int idx = BAKE_INDICES[i];
133 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
134 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
135 Util.FireAndForget(delegate(object o) { CheckBakedTextureAssets(client,face.TextureID,idx); });
136 }
137 }
138
139 // Process the visual params, this may change height as well
140 if (visualParams != null)
141 {
142 if (sp.Appearance.SetVisualParams(visualParams))
143 {
144 changed = true;
145 if (sp.Appearance.AvatarHeight > 0)
146 sp.SetHeight(sp.Appearance.AvatarHeight);
147 }
148 }
149
150 // If something changed in the appearance then queue an appearance save
151 if (changed)
152 QueueAppearanceSave(client.AgentId);
153
154 // And always queue up an appearance update to send out
155 QueueAppearanceSend(client.AgentId);
156
157 // Send the appearance back to the avatar
158 AvatarAppearance avp = sp.Appearance;
159 sp.ControllingClient.SendAvatarDataImmediate(sp);
160 sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
161 }
162
163 /// <summary>
164 /// Checks for the existance of a baked texture asset and
165 /// requests the viewer rebake if the asset is not found
166 /// </summary>
167 /// <param name="client"></param>
168 /// <param name="textureID"></param>
169 /// <param name="idx"></param>
170 private void CheckBakedTextureAssets(IClientAPI client, UUID textureID, int idx)
171 {
172 if (m_scene.AssetService.Get(textureID.ToString()) == null)
173 {
174 m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",
175 textureID,idx,client.Name);
176 client.SendRebakeAvatarTextures(textureID);
177 }
178 }
179
180 #region UpdateAppearanceTimer
181
182 public void QueueAppearanceSend(UUID agentid)
183 {
184// DEBUG ON
185 m_log.WarnFormat("[AVFACTORY] Queue appearance send for {0}",agentid);
186// DEBUG OFF
187
188 // 100 nanoseconds (ticks) we should wait
189 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 10000000);
190 lock (m_sendqueue)
191 {
192 m_sendqueue[agentid] = timestamp;
193 m_updateTimer.Start();
194 }
195 }
196
197 public void QueueAppearanceSave(UUID agentid)
198 {
199// DEBUG ON
200 m_log.WarnFormat("[AVFACTORY] Queue appearance save for {0}",agentid);
201// DEBUG OFF
202
203 // 100 nanoseconds (ticks) we should wait
204 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 10000000);
205 lock (m_savequeue)
206 {
207 m_savequeue[agentid] = timestamp;
208 m_updateTimer.Start();
209 }
210 }
211
212 private void HandleAppearanceSend(UUID agentid)
213 {
214 ScenePresence sp = m_scene.GetScenePresence(agentid);
215 if (sp == null)
216 {
217 m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid);
218 return;
219 }
220
221// DEBUG ON
222 m_log.WarnFormat("[AVFACTORY] Handle appearance send for {0}\n{1}",agentid,sp.Appearance.ToString());
223// DEBUG OFF
224
225 // Send the appearance to everyone in the scene
226 sp.SendAppearanceToAllOtherAgents();
227
228 // Send the appearance back to the avatar
229 AvatarAppearance avp = sp.Appearance;
230 sp.ControllingClient.SendAvatarDataImmediate(sp);
231 sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
232
233/*
234// this needs to be fixed, the flag should be on scene presence not the region module
235 // Start the animations if necessary
236 if (!m_startAnimationSet)
237 {
238 sp.Animator.UpdateMovementAnimations();
239 m_startAnimationSet = true;
240 }
241*/
242 }
243
244 private void HandleAppearanceSave(UUID agentid)
245 {
246 ScenePresence sp = m_scene.GetScenePresence(agentid);
247 if (sp == null)
248 {
249 m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid);
250 return;
251 }
252
253 m_scene.AvatarService.SetAppearance(agentid, sp.Appearance);
254 }
255
256 private void HandleAppearanceUpdateTimer(object sender, EventArgs ea)
257 {
258 long now = DateTime.Now.Ticks;
259
260 lock (m_sendqueue)
261 {
262 Dictionary<UUID,long> sends = new Dictionary<UUID,long>(m_sendqueue);
263 foreach (KeyValuePair<UUID,long> kvp in sends)
264 {
265 if (kvp.Value < now)
122 { 266 {
123 appearance.Wearables[i].AssetID = UUID.Zero; 267 Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); });
268 m_sendqueue.Remove(kvp.Key);
124 } 269 }
125 else 270 }
126 { 271 }
127 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID);
128 baseItem = invService.GetItem(baseItem);
129 272
130 if (baseItem != null) 273 lock (m_savequeue)
131 { 274 {
132 appearance.Wearables[i].AssetID = baseItem.AssetID; 275 Dictionary<UUID,long> saves = new Dictionary<UUID,long>(m_savequeue);
133 } 276 foreach (KeyValuePair<UUID,long> kvp in saves)
134 else 277 {
135 { 278 if (kvp.Value < now)
136 m_log.ErrorFormat( 279 {
137 "[APPEARANCE]: Can't find inventory item {0} for {1}, setting to default", 280 Util.FireAndForget(delegate(object o) { HandleAppearanceSave(kvp.Key); });
138 appearance.Wearables[i].ItemID, (WearableType)i); 281 m_savequeue.Remove(kvp.Key);
139
140 appearance.Wearables[i].AssetID = def.Wearables[i].AssetID;
141 }
142 } 282 }
143 } 283 }
144 } 284 }
145 else 285
286 if (m_savequeue.Count == 0 && m_sendqueue.Count == 0)
287 m_updateTimer.Stop();
288 }
289
290 #endregion
291
292 /// <summary>
293 /// Tell the client for this scene presence what items it should be wearing now
294 /// </summary>
295 public void SendWearables(IClientAPI client)
296 {
297 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
298 if (sp == null)
146 { 299 {
147 m_log.WarnFormat("[APPEARANCE]: user {0} has no inventory, appearance isn't going to work", userID); 300 m_log.WarnFormat("[AVFACTORY] SendWearables unable to find presence for {0}",client.AgentId);
301 return;
148 } 302 }
303
304// DEBUG ON
305 m_log.WarnFormat("[AVFACTORY]: Received request for wearables of {0}", client.AgentId);
306// DEBUG OFF
307 client.SendWearables(sp.Appearance.Wearables,sp.Appearance.Serial++);
149 } 308 }
150 309
151 /// <summary> 310 /// <summary>
@@ -153,65 +312,81 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
153 /// </summary> 312 /// </summary>
154 /// <param name="sender"></param> 313 /// <param name="sender"></param>
155 /// <param name="e"></param> 314 /// <param name="e"></param>
156 public void AvatarIsWearing(Object sender, AvatarWearingArgs e) 315 public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
157 { 316 {
158 m_log.DebugFormat("[APPEARANCE]: AvatarIsWearing"); 317 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
159 318 if (sp == null)
160 IClientAPI clientView = (IClientAPI)sender;
161 ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId);
162
163 if (sp == null)
164 { 319 {
165 m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event"); 320 m_log.WarnFormat("[AVFACTORY] AvatarIsWearing unable to find presence for {0}",client.AgentId);
166 return; 321 return;
167 } 322 }
323
324// DEBUG ON
325 m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}",client.AgentId);
326// DEBUG OFF
168 327
169 AvatarAppearance avatAppearance = sp.Appearance; 328 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance);
170 //if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) 329
330 //if (!TryGetAvatarAppearance(client.AgentId, out avatAppearance))
171 //{ 331 //{
172 // m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); 332 // m_log.Warn("[AVFACTORY]: We didn't seem to find the appearance, falling back to ScenePresence");
173 // avatAppearance = sp.Appearance; 333 // avatAppearance = sp.Appearance;
174 //} 334 //}
175 335
176 //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); 336 //m_log.DebugFormat("[AVFACTORY]: Received wearables for {0}", client.Name);
177 337
178 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) 338 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
179 { 339 {
180 if (wear.Type < 13) 340 if (wear.Type < AvatarWearable.MAX_WEARABLES)
181 { 341 {
182 avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; 342 AvatarWearable newWearable = new AvatarWearable(wear.ItemID,UUID.Zero);
343 avatAppearance.SetWearable(wear.Type, newWearable);
183 } 344 }
184 } 345 }
185 346
186 SetAppearanceAssets(sp.UUID, ref avatAppearance); 347 SetAppearanceAssets(sp.UUID, ref avatAppearance);
187 AvatarData adata = new AvatarData(avatAppearance);
188 m_scene.AvatarService.SetAvatar(clientView.AgentId, adata);
189 348
349 m_scene.AvatarService.SetAppearance(client.AgentId, avatAppearance);
190 sp.Appearance = avatAppearance; 350 sp.Appearance = avatAppearance;
191 } 351 }
192 352
193 public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) 353 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
194 { 354 {
195 visualParams = GetDefaultVisualParams(); 355 IInventoryService invService = m_scene.InventoryService;
196 wearables = AvatarWearable.DefaultWearables;
197 }
198 356
199 public void UpdateDatabase(UUID user, AvatarAppearance appearance) 357 if (invService.GetRootFolder(userID) != null)
200 { 358 {
201 //m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); 359 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
202 AvatarData adata = new AvatarData(appearance); 360 {
203 m_scene.AvatarService.SetAvatar(user, adata); 361 if (appearance.Wearables[i].ItemID == UUID.Zero)
204 } 362 {
363 appearance.Wearables[i].AssetID = UUID.Zero;
364 }
365 else
366 {
367 InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i].ItemID, userID);
368 baseItem = invService.GetItem(baseItem);
205 369
206 private static byte[] GetDefaultVisualParams() 370 if (baseItem != null)
207 { 371 {
208 byte[] visualParams; 372 appearance.Wearables[i].AssetID = baseItem.AssetID;
209 visualParams = new byte[218]; 373 }
210 for (int i = 0; i < 218; i++) 374 else
375 {
376 m_log.ErrorFormat(
377 "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
378 appearance.Wearables[i].ItemID, (WearableType)i);
379
380 appearance.Wearables[i].ItemID = UUID.Zero;
381 appearance.Wearables[i].AssetID = UUID.Zero;
382 }
383 }
384 }
385 }
386 else
211 { 387 {
212 visualParams[i] = 100; 388 m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
213 } 389 }
214 return visualParams;
215 } 390 }
216 } 391 }
217} 392}
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/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 268612e..f128aa2 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.Examples.SimpleModule
82 82
83 public event DeRezObject OnDeRezObject; 83 public event DeRezObject OnDeRezObject;
84 public event Action<IClientAPI> OnRegionHandShakeReply; 84 public event Action<IClientAPI> OnRegionHandShakeReply;
85 public event GenericCall2 OnRequestWearables; 85 public event GenericCall1 OnRequestWearables;
86 public event GenericCall1 OnCompleteMovementToRegion; 86 public event GenericCall1 OnCompleteMovementToRegion;
87 public event UpdateAgent OnPreAgentUpdate; 87 public event UpdateAgent OnPreAgentUpdate;
88 public event UpdateAgent OnAgentUpdate; 88 public event UpdateAgent OnAgentUpdate;
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs
deleted file mode 100644
index c967f30..0000000
--- a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenMetaverse;
29using OpenSim.Framework;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 public interface IAvatarFactory
34 {
35 bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance);
36 void UpdateDatabase(UUID userID, AvatarAppearance avatAppearance);
37 }
38}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f0ae45e..6367fcf 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -119,7 +119,6 @@ namespace OpenSim.Region.Framework.Scenes
119 119
120 protected IXMLRPC m_xmlrpcModule; 120 protected IXMLRPC m_xmlrpcModule;
121 protected IWorldComm m_worldCommModule; 121 protected IWorldComm m_worldCommModule;
122 protected IAvatarFactory m_AvatarFactory;
123 protected IConfigSource m_config; 122 protected IConfigSource m_config;
124 protected IRegionSerialiserModule m_serialiser; 123 protected IRegionSerialiserModule m_serialiser;
125 protected IDialogModule m_dialogModule; 124 protected IDialogModule m_dialogModule;
@@ -399,11 +398,6 @@ namespace OpenSim.Region.Framework.Scenes
399 398
400 public IAttachmentsModule AttachmentsModule { get; set; } 399 public IAttachmentsModule AttachmentsModule { get; set; }
401 400
402 public IAvatarFactory AvatarFactory
403 {
404 get { return m_AvatarFactory; }
405 }
406
407 public ICapabilitiesModule CapsModule 401 public ICapabilitiesModule CapsModule
408 { 402 {
409 get { return m_capsModule; } 403 get { return m_capsModule; }
@@ -1159,7 +1153,6 @@ namespace OpenSim.Region.Framework.Scenes
1159 m_xmlrpcModule = RequestModuleInterface<IXMLRPC>(); 1153 m_xmlrpcModule = RequestModuleInterface<IXMLRPC>();
1160 m_worldCommModule = RequestModuleInterface<IWorldComm>(); 1154 m_worldCommModule = RequestModuleInterface<IWorldComm>();
1161 XferManager = RequestModuleInterface<IXfer>(); 1155 XferManager = RequestModuleInterface<IXfer>();
1162 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1163 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); 1156 AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
1164 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1157 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1165 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1158 m_dialogModule = RequestModuleInterface<IDialogModule>();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 13d9964..f828a2d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -75,7 +75,6 @@ namespace OpenSim.Region.Framework.Scenes
75 75
76 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 76 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
77 77
78 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
79// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); 78// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
80 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); 79 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
81 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); 80 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@@ -137,8 +136,6 @@ namespace OpenSim.Region.Framework.Scenes
137 136
138 private SendCourseLocationsMethod m_sendCourseLocationsMethod; 137 private SendCourseLocationsMethod m_sendCourseLocationsMethod;
139 138
140 private bool m_startAnimationSet;
141
142 //private Vector3 m_requestedSitOffset = new Vector3(); 139 //private Vector3 m_requestedSitOffset = new Vector3();
143 140
144 private Vector3 m_LastFinitePos; 141 private Vector3 m_LastFinitePos;
@@ -713,13 +710,14 @@ namespace OpenSim.Region.Framework.Scenes
713 SetDirectionVectors(); 710 SetDirectionVectors();
714 } 711 }
715 712
713/*
716 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, 714 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
717 AvatarWearable[] wearables) 715 AvatarWearable[] wearables)
718 : this(client, world, reginfo) 716 : this(client, world, reginfo)
719 { 717 {
720 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); 718 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
721 } 719 }
722 720*/
723 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 721 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
724 : this(client, world, reginfo) 722 : this(client, world, reginfo)
725 { 723 {
@@ -733,8 +731,6 @@ namespace OpenSim.Region.Framework.Scenes
733 731
734 public void RegisterToEvents() 732 public void RegisterToEvents()
735 { 733 {
736 m_controllingClient.OnRequestWearables += SendWearables;
737 m_controllingClient.OnSetAppearance += SetAppearance;
738 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; 734 m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
739 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; 735 //m_controllingClient.OnCompleteMovementToRegion += SendInitialData;
740 m_controllingClient.OnAgentUpdate += HandleAgentUpdate; 736 m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
@@ -1068,7 +1064,7 @@ namespace OpenSim.Region.Framework.Scenes
1068 /// <summary> 1064 /// <summary>
1069 /// Sets avatar height in the phyiscs plugin 1065 /// Sets avatar height in the phyiscs plugin
1070 /// </summary> 1066 /// </summary>
1071 internal void SetHeight(float height) 1067 public void SetHeight(float height)
1072 { 1068 {
1073 m_avHeight = height; 1069 m_avHeight = height;
1074 if (PhysicsActor != null && !IsChildAgent) 1070 if (PhysicsActor != null && !IsChildAgent)
@@ -1133,7 +1129,6 @@ namespace OpenSim.Region.Framework.Scenes
1133 if (friendsModule != null) 1129 if (friendsModule != null)
1134 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1130 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1135 } 1131 }
1136
1137 } 1132 }
1138 1133
1139 /// <summary> 1134 /// <summary>
@@ -2392,9 +2387,12 @@ namespace OpenSim.Region.Framework.Scenes
2392 if (m_appearance.Texture == null) 2387 if (m_appearance.Texture == null)
2393 return; 2388 return;
2394 2389
2395 Vector3 pos = m_pos; 2390 if (IsChildAgent)
2396 pos.Z += m_appearance.HipOffset; 2391 {
2397 2392 m_log.WarnFormat("[SCENEPRESENCE] A child agent is attempting to send out avatar data");
2393 return;
2394 }
2395
2398 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); 2396 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this);
2399 m_scene.StatsReporter.AddAgentUpdates(1); 2397 m_scene.StatsReporter.AddAgentUpdates(1);
2400 } 2398 }
@@ -2437,6 +2435,12 @@ namespace OpenSim.Region.Framework.Scenes
2437 m_perfMonMS = Util.EnvironmentTickCount(); 2435 m_perfMonMS = Util.EnvironmentTickCount();
2438 2436
2439 // only send update from root agents to other clients; children are only "listening posts" 2437 // only send update from root agents to other clients; children are only "listening posts"
2438 if (IsChildAgent)
2439 {
2440 m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent");
2441 return;
2442 }
2443
2440 int count = 0; 2444 int count = 0;
2441 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 2445 m_scene.ForEachScenePresence(delegate(ScenePresence sp)
2442 { 2446 {
@@ -2460,29 +2464,20 @@ namespace OpenSim.Region.Framework.Scenes
2460 // the inventory arrives 2464 // the inventory arrives
2461 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2465 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2462 2466
2463 Vector3 pos = m_pos;
2464 pos.Z += m_appearance.HipOffset;
2465
2466 m_controllingClient.SendAvatarDataImmediate(this); 2467 m_controllingClient.SendAvatarDataImmediate(this);
2468 m_controllingClient.SendAppearance(m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes());
2467 2469
2468 SendInitialFullUpdateToAllClients(); 2470 SendInitialFullUpdateToAllClients();
2469 } 2471 }
2470 2472
2471 /// <summary> 2473 /// <summary>
2472 /// Tell the client for this scene presence what items it should be wearing now
2473 /// </summary>
2474 public void SendWearables()
2475 {
2476 m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name);
2477
2478 ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2479 }
2480
2481 /// <summary>
2482 /// 2474 ///
2483 /// </summary> 2475 /// </summary>
2484 public void SendAppearanceToAllOtherAgents() 2476 public void SendAppearanceToAllOtherAgents()
2485 { 2477 {
2478// DEBUG ON
2479 m_log.WarnFormat("[SP] Send appearance from {0} to all other agents",m_uuid);
2480// DEBUG OFF
2486 m_perfMonMS = Util.EnvironmentTickCount(); 2481 m_perfMonMS = Util.EnvironmentTickCount();
2487 2482
2488 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2483 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
@@ -2502,87 +2497,13 @@ namespace OpenSim.Region.Framework.Scenes
2502 /// <param name="avatar"></param> 2497 /// <param name="avatar"></param>
2503 public void SendAppearanceToOtherAgent(ScenePresence avatar) 2498 public void SendAppearanceToOtherAgent(ScenePresence avatar)
2504 { 2499 {
2500// DEBUG ON
2501 m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2502// DEBUG OFF
2505 avatar.ControllingClient.SendAppearance( 2503 avatar.ControllingClient.SendAppearance(
2506 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); 2504 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
2507 } 2505 }
2508 2506
2509 /// <summary>
2510 /// Set appearance data (textureentry and slider settings) received from the client
2511 /// </summary>
2512 /// <param name="texture"></param>
2513 /// <param name="visualParam"></param>
2514 public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
2515 {
2516 if (m_physicsActor != null)
2517 {
2518 if (!IsChildAgent)
2519 {
2520 // This may seem like it's redundant, remove the avatar from the physics scene
2521 // just to add it back again, but it saves us from having to update
2522 // 3 variables 10 times a second.
2523 bool flyingTemp = m_physicsActor.Flying;
2524 RemoveFromPhysicalScene();
2525 //m_scene.PhysicsScene.RemoveAvatar(m_physicsActor);
2526
2527 //PhysicsActor = null;
2528
2529 AddToPhysicalScene(flyingTemp);
2530 }
2531 }
2532
2533 #region Bake Cache Check
2534
2535 if (textureEntry != null)
2536 {
2537 for (int i = 0; i < BAKE_INDICES.Length; i++)
2538 {
2539 int j = BAKE_INDICES[i];
2540 Primitive.TextureEntryFace face = textureEntry.FaceTextures[j];
2541
2542 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
2543 {
2544 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
2545 {
2546 m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name);
2547 this.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
2548 }
2549 }
2550 }
2551
2552 }
2553
2554
2555 #endregion Bake Cache Check
2556
2557 m_appearance.SetAppearance(textureEntry, visualParams);
2558 if (m_appearance.AvatarHeight > 0)
2559 SetHeight(m_appearance.AvatarHeight);
2560
2561 // This is not needed, because only the transient data changed
2562 //AvatarData adata = new AvatarData(m_appearance);
2563 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2564
2565 SendAppearanceToAllOtherAgents();
2566 if (!m_startAnimationSet)
2567 {
2568 Animator.UpdateMovementAnimations();
2569 m_startAnimationSet = true;
2570 }
2571
2572 Vector3 pos = m_pos;
2573 pos.Z += m_appearance.HipOffset;
2574
2575 m_controllingClient.SendAvatarDataImmediate(this);
2576 }
2577
2578 public void SetWearable(int wearableId, AvatarWearable wearable)
2579 {
2580 m_appearance.SetWearable(wearableId, wearable);
2581 AvatarData adata = new AvatarData(m_appearance);
2582 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2583 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2584 }
2585
2586 // Because appearance setting is in a module, we actually need 2507 // Because appearance setting is in a module, we actually need
2587 // to give it access to our appearance directly, otherwise we 2508 // to give it access to our appearance directly, otherwise we
2588 // get a synchronization issue. 2509 // get a synchronization issue.
@@ -2976,6 +2897,9 @@ namespace OpenSim.Region.Framework.Scenes
2976 2897
2977 public void CopyTo(AgentData cAgent) 2898 public void CopyTo(AgentData cAgent)
2978 { 2899 {
2900// DEBUG ON
2901 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYTO");
2902// DEBUG OFF
2979 cAgent.AgentID = UUID; 2903 cAgent.AgentID = UUID;
2980 cAgent.RegionID = Scene.RegionInfo.RegionID; 2904 cAgent.RegionID = Scene.RegionInfo.RegionID;
2981 2905
@@ -3015,6 +2939,9 @@ namespace OpenSim.Region.Framework.Scenes
3015 2939
3016 cAgent.AlwaysRun = m_setAlwaysRun; 2940 cAgent.AlwaysRun = m_setAlwaysRun;
3017 2941
2942 cAgent.Appearance = new AvatarAppearance(m_appearance);
2943
2944/*
3018 try 2945 try
3019 { 2946 {
3020 // We might not pass the Wearables in all cases... 2947 // We might not pass the Wearables in all cases...
@@ -3054,14 +2981,14 @@ namespace OpenSim.Region.Framework.Scenes
3054 { 2981 {
3055 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count); 2982 //m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
3056 int i = 0; 2983 int i = 0;
3057 AttachmentData[] attachs = new AttachmentData[attPoints.Count]; 2984 AvatarAttachment[] attachs = new AvatarAttachment[attPoints.Count];
3058 foreach (int point in attPoints) 2985 foreach (int point in attPoints)
3059 { 2986 {
3060 attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point)); 2987 attachs[i++] = new AvatarAttachment(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
3061 } 2988 }
3062 cAgent.Attachments = attachs; 2989 cAgent.Attachments = attachs;
3063 } 2990 }
3064 2991*/
3065 lock (scriptedcontrols) 2992 lock (scriptedcontrols)
3066 { 2993 {
3067 ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; 2994 ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
@@ -3088,6 +3015,9 @@ namespace OpenSim.Region.Framework.Scenes
3088 3015
3089 public void CopyFrom(AgentData cAgent) 3016 public void CopyFrom(AgentData cAgent)
3090 { 3017 {
3018// DEBUG ON
3019 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
3020// DEBUG OFF
3091 m_originRegionID = cAgent.RegionID; 3021 m_originRegionID = cAgent.RegionID;
3092 3022
3093 m_callbackURI = cAgent.CallbackURI; 3023 m_callbackURI = cAgent.CallbackURI;
@@ -3113,6 +3043,9 @@ namespace OpenSim.Region.Framework.Scenes
3113 m_godLevel = cAgent.GodLevel; 3043 m_godLevel = cAgent.GodLevel;
3114 m_setAlwaysRun = cAgent.AlwaysRun; 3044 m_setAlwaysRun = cAgent.AlwaysRun;
3115 3045
3046 m_appearance = new AvatarAppearance(cAgent.Appearance);
3047
3048/*
3116 uint i = 0; 3049 uint i = 0;
3117 try 3050 try
3118 { 3051 {
@@ -3125,15 +3058,17 @@ namespace OpenSim.Region.Framework.Scenes
3125 UUID assetId = cAgent.Wearables[n + 1]; 3058 UUID assetId = cAgent.Wearables[n + 1];
3126 wears[i++] = new AvatarWearable(itemId, assetId); 3059 wears[i++] = new AvatarWearable(itemId, assetId);
3127 } 3060 }
3128 m_appearance.Wearables = wears; 3061 // m_appearance.Wearables = wears;
3129 Primitive.TextureEntry te; 3062 Primitive.TextureEntry textures = null;
3130 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) 3063 if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1)
3131 te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); 3064 textures = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length);
3132 else 3065
3133 te = AvatarAppearance.GetDefaultTexture(); 3066 byte[] visuals = null;
3134 if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) 3067
3135 cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); 3068 if ((cAgent.VisualParams != null) && (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT))
3136 m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); 3069 visuals = (byte[])cAgent.VisualParams.Clone();
3070
3071 m_appearance = new AvatarAppearance(cAgent.AgentID,wears,textures,visuals);
3137 } 3072 }
3138 catch (Exception e) 3073 catch (Exception e)
3139 { 3074 {
@@ -3146,14 +3081,14 @@ namespace OpenSim.Region.Framework.Scenes
3146 if (cAgent.Attachments != null) 3081 if (cAgent.Attachments != null)
3147 { 3082 {
3148 m_appearance.ClearAttachments(); 3083 m_appearance.ClearAttachments();
3149 foreach (AttachmentData att in cAgent.Attachments) 3084 foreach (AvatarAttachment att in cAgent.Attachments)
3150 { 3085 {
3151 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID); 3086 m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
3152 } 3087 }
3153 } 3088 }
3154 } 3089 }
3155 catch { } 3090 catch { }
3156 3091*/
3157 try 3092 try
3158 { 3093 {
3159 lock (scriptedcontrols) 3094 lock (scriptedcontrols)
@@ -3722,15 +3657,16 @@ namespace OpenSim.Region.Framework.Scenes
3722 return; 3657 return;
3723 } 3658 }
3724 3659
3725 List<int> attPoints = m_appearance.GetAttachedPoints(); 3660 List<AvatarAttachment> attachments = m_appearance.GetAttachments();
3726 foreach (int p in attPoints) 3661 foreach (AvatarAttachment attach in attachments)
3727 { 3662 {
3728 if (m_isDeleted) 3663 if (m_isDeleted)
3729 return; 3664 return;
3730 3665
3731 UUID itemID = m_appearance.GetAttachedItem(p); 3666 int p = attach.AttachPoint;
3667 UUID itemID = attach.ItemID;
3732 3668
3733 //UUID assetID = m_appearance.GetAttachedAsset(p); 3669 //UUID assetID = attach.AssetID;
3734 // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down 3670 // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
3735 // But they're not used anyway, the item is being looked up for now, so let's proceed. 3671 // But they're not used anyway, the item is being looked up for now, so let's proceed.
3736 //if (UUID.Zero == assetID) 3672 //if (UUID.Zero == assetID)
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 159af79..fc17192 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -676,7 +676,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
676 public event TeleportLandmarkRequest OnTeleportLandmarkRequest; 676 public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
677 public event DeRezObject OnDeRezObject; 677 public event DeRezObject OnDeRezObject;
678 public event Action<IClientAPI> OnRegionHandShakeReply; 678 public event Action<IClientAPI> OnRegionHandShakeReply;
679 public event GenericCall2 OnRequestWearables; 679 public event GenericCall1 OnRequestWearables;
680 public event GenericCall1 OnCompleteMovementToRegion; 680 public event GenericCall1 OnCompleteMovementToRegion;
681 public event UpdateAgent OnPreAgentUpdate; 681 public event UpdateAgent OnPreAgentUpdate;
682 public event UpdateAgent OnAgentUpdate; 682 public event UpdateAgent OnAgentUpdate;
@@ -899,7 +899,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
899 Scene scene = (Scene)Scene; 899 Scene scene = (Scene)Scene;
900 AvatarAppearance appearance; 900 AvatarAppearance appearance;
901 scene.GetAvatarAppearance(this, out appearance); 901 scene.GetAvatarAppearance(this, out appearance);
902 OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); 902 OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone());
903 } 903 }
904 904
905 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) 905 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
index 0786bd9..922eaaf 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
@@ -29,6 +29,7 @@ using System.Collections;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Security; 30using System.Security;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
34 35
@@ -81,16 +82,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
81 get { 82 get {
82 List<IAvatarAttachment> attachments = new List<IAvatarAttachment>(); 83 List<IAvatarAttachment> attachments = new List<IAvatarAttachment>();
83 84
84 Hashtable internalAttachments = GetSP().Appearance.GetAttachments(); 85 List<AvatarAttachment> internalAttachments = GetSP().Appearance.GetAttachments();
85 if (internalAttachments != null) 86 foreach (AvatarAttachment attach in internalAttachments)
86 { 87 {
87 foreach (DictionaryEntry element in internalAttachments) 88 attachments.Add(new SPAvatarAttachment(m_rootScene, this, attach.AttachPoint,
88 { 89 new UUID(attach.ItemID),
89 Hashtable attachInfo = (Hashtable)element.Value; 90 new UUID(attach.AssetID), m_security));
90 attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int) element.Key,
91 new UUID((string) attachInfo["item"]),
92 new UUID((string) attachInfo["asset"]), m_security));
93 }
94 } 91 }
95 92
96 return attachments.ToArray(); 93 return attachments.ToArray();
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index fae12b6..6928c4e 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -188,7 +188,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
188 188
189 public event DeRezObject OnDeRezObject; 189 public event DeRezObject OnDeRezObject;
190 public event Action<IClientAPI> OnRegionHandShakeReply; 190 public event Action<IClientAPI> OnRegionHandShakeReply;
191 public event GenericCall2 OnRequestWearables; 191 public event GenericCall1 OnRequestWearables;
192 public event GenericCall1 OnCompleteMovementToRegion; 192 public event GenericCall1 OnCompleteMovementToRegion;
193 public event UpdateAgent OnPreAgentUpdate; 193 public event UpdateAgent OnPreAgentUpdate;
194 public event UpdateAgent OnAgentUpdate; 194 public event UpdateAgent OnAgentUpdate;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index ab0be77..c471636 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -64,15 +64,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
64 if (m_appearanceCache.ContainsKey(target)) 64 if (m_appearanceCache.ContainsKey(target))
65 return m_appearanceCache[target]; 65 return m_appearanceCache[target];
66 66
67 AvatarData adata = scene.AvatarService.GetAvatar(target); 67 AvatarAppearance appearance = scene.AvatarService.GetAppearance(target);
68 if (adata != null) 68 if (appearance != null)
69 { 69 {
70 AvatarAppearance x = adata.ToAvatarAppearance(target); 70 m_appearanceCache.Add(target, appearance);
71 71 return appearance;
72 m_appearanceCache.Add(target, x);
73
74 return x;
75 } 72 }
73
76 return new AvatarAppearance(); 74 return new AvatarAppearance();
77 } 75 }
78 76
@@ -169,7 +167,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
169 { 167 {
170 AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene); 168 AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene);
171 169
172 sp.SetAppearance(x.Texture, (byte[])x.VisualParams.Clone()); 170 sp.Appearance.SetTextureEntries(x.Texture);
171 sp.Appearance.SetVisualParams((byte[])x.VisualParams.Clone());
172 sp.SendAppearanceToAllOtherAgents();
173 } 173 }
174 174
175 m_avatars.Add(npcAvatar.AgentId, npcAvatar); 175 m_avatars.Add(npcAvatar.AgentId, npcAvatar);