aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Modules
diff options
context:
space:
mode:
authorSean Dague2008-05-22 20:07:31 +0000
committerSean Dague2008-05-22 20:07:31 +0000
commit1c49752a44e3ee251cf1422072088e27d0cc8408 (patch)
tree5d8821407409b314f806da9fb50429625fb6f538 /OpenSim/Region/Modules
parentchange to how initial terrain data is sent. Instead of sending the 64 packets... (diff)
downloadopensim-SC_OLD-1c49752a44e3ee251cf1422072088e27d0cc8408.zip
opensim-SC_OLD-1c49752a44e3ee251cf1422072088e27d0cc8408.tar.gz
opensim-SC_OLD-1c49752a44e3ee251cf1422072088e27d0cc8408.tar.bz2
opensim-SC_OLD-1c49752a44e3ee251cf1422072088e27d0cc8408.tar.xz
don't trust appearance assetid, instead do an inventory
lookup any time we get it from the server. This should preventent unwearable appearance.
Diffstat (limited to 'OpenSim/Region/Modules')
-rw-r--r--OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs83
1 files changed, 52 insertions, 31 deletions
diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
index 4b8eee7..e66113d 100644
--- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
@@ -46,20 +46,25 @@ namespace OpenSim.Region.Modules.AvatarFactory
46 { 46 {
47 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 Scene m_scene = null; 48 private Scene m_scene = null;
49 private static readonly AvatarAppearance def = new AvatarAppearance();
49 50
50 public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance) 51 public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance)
51 { 52 {
52 appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId); 53 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(avatarId);
53 if (appearance != null) 54 if ((profile != null) && (profile.RootFolder != null))
54 { 55 {
55 m_log.InfoFormat("[APPEARANCE] found : {0}", appearance.ToString()); 56 appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId);
56 return true; 57 if (appearance != null)
57 } 58 {
58 else 59 SetAppearanceAssets(profile, ref appearance);
59 { 60 m_log.InfoFormat("[APPEARANCE] found : {0}", appearance.ToString());
60 m_log.InfoFormat("[APPEARANCE] appearance not found for {0}", avatarId.ToString()); 61 return true;
61 return false; 62 }
62 } 63 }
64
65 appearance = CreateDefault(avatarId);
66 m_log.InfoFormat("[APPEARANCE] appearance not found for {0}, creating default", avatarId.ToString());
67 return false;
63 } 68 }
64 69
65 private AvatarAppearance CreateDefault(LLUUID avatarId) 70 private AvatarAppearance CreateDefault(LLUUID avatarId)
@@ -113,6 +118,41 @@ namespace OpenSim.Region.Modules.AvatarFactory
113 // client.OnAvatarNowWearing -= AvatarIsWearing; 118 // client.OnAvatarNowWearing -= AvatarIsWearing;
114 } 119 }
115 120
121
122 public void SetAppearanceAssets(CachedUserInfo profile, ref AvatarAppearance appearance)
123 {
124 if (profile.RootFolder != null)
125 {
126 for (int i = 0; i < 13; i++)
127 {
128 if (appearance.Wearables[i].ItemID == LLUUID.Zero)
129 {
130 appearance.Wearables[i].AssetID = LLUUID.Zero;
131 }
132 else
133 {
134 LLUUID assetId;
135
136 InventoryItemBase baseItem = profile.RootFolder.FindItem(appearance.Wearables[i].ItemID);
137
138 if (baseItem != null)
139 {
140 appearance.Wearables[i].AssetID = baseItem.AssetID;
141 }
142 else
143 {
144 m_log.ErrorFormat("[APPEARANCE] Can't find inventory item {0}, setting to default", appearance.Wearables[i].ItemID);
145 appearance.Wearables[i].AssetID = def.Wearables[i].AssetID;
146 }
147 }
148 }
149 }
150 else
151 {
152 m_log.Error("[APPEARANCE] you have no inventory, appearance stuff isn't going to work");
153 }
154 }
155
116 public void AvatarIsWearing(Object sender, AvatarWearingArgs e) 156 public void AvatarIsWearing(Object sender, AvatarWearingArgs e)
117 { 157 {
118 IClientAPI clientView = (IClientAPI)sender; 158 IClientAPI clientView = (IClientAPI)sender;
@@ -138,30 +178,11 @@ namespace OpenSim.Region.Modules.AvatarFactory
138 { 178 {
139 if (wear.Type < 13) 179 if (wear.Type < 13)
140 { 180 {
141 if (wear.ItemID == LLUUID.Zero) 181 avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
142 {
143 avatAppearance.Wearables[wear.Type].ItemID = LLUUID.Zero;
144 avatAppearance.Wearables[wear.Type].AssetID = LLUUID.Zero;
145 }
146 else
147 {
148 LLUUID assetId;
149
150 InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID);
151
152 if (baseItem != null)
153 {
154 assetId = baseItem.AssetID;
155 avatAppearance.Wearables[wear.Type].AssetID = assetId;
156 avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
157 }
158 else
159 {
160 m_log.ErrorFormat("[APPEARANCE] Can't find inventory item {0}, not wearing", wear.ItemID);
161 }
162 }
163 } 182 }
164 } 183 }
184 SetAppearanceAssets(profile, ref avatAppearance);
185
165 m_scene.CommsManager.UserService.UpdateUserAppearance(clientView.AgentId, avatAppearance); 186 m_scene.CommsManager.UserService.UpdateUserAppearance(clientView.AgentId, avatAppearance);
166 avatar.Appearance = avatAppearance; 187 avatar.Appearance = avatAppearance;
167 } 188 }