diff options
author | Sean Dague | 2008-05-21 20:18:40 +0000 |
---|---|---|
committer | Sean Dague | 2008-05-21 20:18:40 +0000 |
commit | 9389429ed3de0c67e8e708a34c3820ff4f9e8ca0 (patch) | |
tree | 11819e3770ba083baa441c04851a4ad22869c5b7 | |
parent | this removes use of the mapper for wearables, and I can confirm things (diff) | |
download | opensim-SC_OLD-9389429ed3de0c67e8e708a34c3820ff4f9e8ca0.zip opensim-SC_OLD-9389429ed3de0c67e8e708a34c3820ff4f9e8ca0.tar.gz opensim-SC_OLD-9389429ed3de0c67e8e708a34c3820ff4f9e8ca0.tar.bz2 opensim-SC_OLD-9389429ed3de0c67e8e708a34c3820ff4f9e8ca0.tar.xz |
Clean out some crufty in AvatarFactoryModule
Fix RequestUpdateInventoryItem so that asset changes
generate a new asset, which is needed for editing
appearance to do the right thing. Persistant appearance
seems to work after this, except you need to rebake textures
some times.
3 files changed, 18 insertions, 193 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 81e19e6..f2185ab 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -347,6 +347,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
347 | 347 | ||
348 | if (asset != null && asset.FullID == assetID) | 348 | if (asset != null && asset.FullID == assetID) |
349 | { | 349 | { |
350 | // Assets never get updated, new ones get created | ||
351 | asset.FullID = LLUUID.Random(); | ||
350 | asset.Name = item.Name; | 352 | asset.Name = item.Name; |
351 | asset.Description = item.Description; | 353 | asset.Description = item.Description; |
352 | asset.InvType = (sbyte) item.InvType; | 354 | asset.InvType = (sbyte) item.InvType; |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index f70eb45..1aa800a 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -1456,17 +1456,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1456 | 1456 | ||
1457 | SendFullUpdateToAllClients(); | 1457 | SendFullUpdateToAllClients(); |
1458 | SendAppearanceToAllOtherAgents(); | 1458 | SendAppearanceToAllOtherAgents(); |
1459 | SendOwnAppearance(); | 1459 | } |
1460 | } | ||
1461 | |||
1462 | |||
1463 | public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable) | ||
1464 | { | ||
1465 | m_log.Info("[APPEARANCE] Setting wearable with client, wearableid, wearable"); | ||
1466 | m_appearance.SetWearable(wearableId, wearable); | ||
1467 | m_scene.CommsManager.UserService.UpdateUserAppearance(client.AgentId, m_appearance); | ||
1468 | client.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | ||
1469 | } | ||
1470 | 1460 | ||
1471 | /// <summary> | 1461 | /// <summary> |
1472 | /// | 1462 | /// |
@@ -1476,6 +1466,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
1476 | { | 1466 | { |
1477 | m_log.Info("[APPEARANCE] Sending Own Appearance"); | 1467 | m_log.Info("[APPEARANCE] Sending Own Appearance"); |
1478 | ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | 1468 | ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); |
1469 | ControllingClient.SendAppearance( | ||
1470 | m_appearance.Owner, | ||
1471 | m_appearance.VisualParams, | ||
1472 | m_appearance.Texture.ToBytes() | ||
1473 | ); | ||
1479 | } | 1474 | } |
1480 | 1475 | ||
1481 | /// <summary> | 1476 | /// <summary> |
@@ -1483,6 +1478,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1483 | /// </summary> | 1478 | /// </summary> |
1484 | public void SendAppearanceToAllOtherAgents() | 1479 | public void SendAppearanceToAllOtherAgents() |
1485 | { | 1480 | { |
1481 | m_log.Info("[APPEARANCE] Sending Appearance to All Other Agents"); | ||
1486 | m_perfMonMS=System.Environment.TickCount; | 1482 | m_perfMonMS=System.Environment.TickCount; |
1487 | 1483 | ||
1488 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 1484 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
@@ -1506,7 +1502,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1506 | 1502 | ||
1507 | public void SetAppearance(byte[] texture, List<byte> visualParam) | 1503 | public void SetAppearance(byte[] texture, List<byte> visualParam) |
1508 | { | 1504 | { |
1509 | m_log.Warn("[APPEARANCE] Setting Appearance"); | 1505 | m_log.Info("[APPEARANCE] Setting Appearance"); |
1510 | m_appearance.SetAppearance(texture, visualParam); | 1506 | m_appearance.SetAppearance(texture, visualParam); |
1511 | SetHeight(m_appearance.AvatarHeight); | 1507 | SetHeight(m_appearance.AvatarHeight); |
1512 | m_scene.CommsManager.UserService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 1508 | m_scene.CommsManager.UserService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); |
@@ -1517,9 +1513,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
1517 | 1513 | ||
1518 | public void SetWearable(int wearableId, AvatarWearable wearable) | 1514 | public void SetWearable(int wearableId, AvatarWearable wearable) |
1519 | { | 1515 | { |
1520 | m_log.Warn("[APPEARANCE] Setting Wearable"); | 1516 | m_log.Info("[APPEARANCE] Setting Wearable"); |
1521 | m_appearance.SetWearable(wearableId, wearable); | 1517 | m_appearance.SetWearable(wearableId, wearable); |
1522 | m_scene.CommsManager.UserService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 1518 | m_scene.CommsManager.UserService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); |
1519 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | ||
1523 | } | 1520 | } |
1524 | 1521 | ||
1525 | // Because appearance setting is in a module, we actually need | 1522 | // Because appearance setting is in a module, we actually need |
diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs index 5c5cb17..0b75e89 100644 --- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -46,22 +46,13 @@ 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 readonly Dictionary<LLUUID, AvatarAppearance> m_avatarsAppearance = new Dictionary<LLUUID, AvatarAppearance>(); | ||
50 | |||
51 | private bool m_enablePersist = false; | ||
52 | private string m_connectionString; | ||
53 | private bool m_configured = false; | ||
54 | private BaseDatabaseConnector m_databaseMapper; | ||
55 | private AppearanceTableMapper m_appearanceMapper; | ||
56 | |||
57 | private Dictionary<LLUUID, EventWaitHandle> m_fetchesInProgress = new Dictionary<LLUUID, EventWaitHandle>(); | ||
58 | private object m_syncLock = new object(); | ||
59 | 49 | ||
60 | public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance) | 50 | public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance) |
61 | { | 51 | { |
62 | appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId); | 52 | appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId); |
63 | if (appearance != null) | 53 | if (appearance != null) |
64 | { | 54 | { |
55 | m_log.InfoFormat("[APPEARANCE] found : {0}", appearance.ToString()); | ||
65 | return true; | 56 | return true; |
66 | } | 57 | } |
67 | else | 58 | else |
@@ -69,112 +60,6 @@ namespace OpenSim.Region.Modules.AvatarFactory | |||
69 | m_log.InfoFormat("[APPEARANCE] appearance not found for {0}", avatarId.ToString()); | 60 | m_log.InfoFormat("[APPEARANCE] appearance not found for {0}", avatarId.ToString()); |
70 | return false; | 61 | return false; |
71 | } | 62 | } |
72 | |||
73 | // //should only let one thread at a time do this part | ||
74 | // EventWaitHandle waitHandle = null; | ||
75 | // bool fetchInProgress = false; | ||
76 | // lock (m_syncLock) | ||
77 | // { | ||
78 | // appearance = CheckCache(avatarId); | ||
79 | // if (appearance != null) | ||
80 | // { | ||
81 | // return true; | ||
82 | // } | ||
83 | |||
84 | // //not in cache so check to see if another thread is already fetching it | ||
85 | // if (m_fetchesInProgress.TryGetValue(avatarId, out waitHandle)) | ||
86 | // { | ||
87 | // fetchInProgress = true; | ||
88 | // } | ||
89 | // else | ||
90 | // { | ||
91 | // fetchInProgress = false; | ||
92 | |||
93 | // //no thread already fetching this appearance, so add a wait handle to list | ||
94 | // //for any following threads that want the same appearance | ||
95 | // waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); | ||
96 | // m_fetchesInProgress.Add(avatarId, waitHandle); | ||
97 | // } | ||
98 | // } | ||
99 | |||
100 | // if (fetchInProgress) | ||
101 | // { | ||
102 | // waitHandle.WaitOne(); | ||
103 | // appearance = CheckCache(avatarId); | ||
104 | // if (appearance != null) | ||
105 | // { | ||
106 | // waitHandle = null; | ||
107 | // return true; | ||
108 | // } | ||
109 | // else | ||
110 | // { | ||
111 | // waitHandle = null; | ||
112 | // return false; | ||
113 | // } | ||
114 | // } | ||
115 | // else | ||
116 | // { | ||
117 | // // BUG: !? (Reduced from 5000 to 500 by Adam) | ||
118 | // Thread.Sleep(500); //why is this here? | ||
119 | |||
120 | // //this is the first thread to request this appearance | ||
121 | // //so let it check the db and if not found then create a default appearance | ||
122 | // //and add that to the cache | ||
123 | // appearance = CheckDatabase(avatarId); | ||
124 | // if (appearance != null) | ||
125 | // { | ||
126 | // //appearance has now been added to cache so lets pulse any waiting threads | ||
127 | // lock (m_syncLock) | ||
128 | // { | ||
129 | // m_fetchesInProgress.Remove(avatarId); | ||
130 | // waitHandle.Set(); | ||
131 | // } | ||
132 | // // waitHandle.Close(); | ||
133 | // waitHandle = null; | ||
134 | // return true; | ||
135 | // } | ||
136 | |||
137 | // //not found a appearance for the user, so create a new default one | ||
138 | // appearance = CreateDefault(avatarId); | ||
139 | // if (appearance != null) | ||
140 | // { | ||
141 | // //update database | ||
142 | // if (m_enablePersist) | ||
143 | // { | ||
144 | // m_appearanceMapper.Add(avatarId.UUID, appearance); | ||
145 | // } | ||
146 | |||
147 | // //add appearance to dictionary cache | ||
148 | // lock (m_avatarsAppearance) | ||
149 | // { | ||
150 | // m_avatarsAppearance[avatarId] = appearance; | ||
151 | // } | ||
152 | |||
153 | // //appearance has now been added to cache so lets pulse any waiting threads | ||
154 | // lock (m_syncLock) | ||
155 | // { | ||
156 | // m_fetchesInProgress.Remove(avatarId); | ||
157 | // waitHandle.Set(); | ||
158 | // } | ||
159 | // // waitHandle.Close(); | ||
160 | // waitHandle = null; | ||
161 | // return true; | ||
162 | // } | ||
163 | // else | ||
164 | // { | ||
165 | // //something went wrong, so release the wait handle and remove it | ||
166 | // //all waiting threads will fail to find cached appearance | ||
167 | // //but its better for them to fail than wait for ever | ||
168 | // lock (m_syncLock) | ||
169 | // { | ||
170 | // m_fetchesInProgress.Remove(avatarId); | ||
171 | // waitHandle.Set(); | ||
172 | // } | ||
173 | // //waitHandle.Close(); | ||
174 | // waitHandle = null; | ||
175 | // return false; | ||
176 | // } | ||
177 | // } | ||
178 | } | 63 | } |
179 | 64 | ||
180 | private AvatarAppearance CreateDefault(LLUUID avatarId) | 65 | private AvatarAppearance CreateDefault(LLUUID avatarId) |
@@ -188,37 +73,6 @@ namespace OpenSim.Region.Modules.AvatarFactory | |||
188 | return appearance; | 73 | return appearance; |
189 | } | 74 | } |
190 | 75 | ||
191 | private AvatarAppearance CheckDatabase(LLUUID avatarId) | ||
192 | { | ||
193 | AvatarAppearance appearance = null; | ||
194 | if (m_enablePersist) | ||
195 | { | ||
196 | if (m_appearanceMapper.TryGetValue(avatarId.UUID, out appearance)) | ||
197 | { | ||
198 | appearance.VisualParams = GetDefaultVisualParams(); | ||
199 | appearance.Texture = AvatarAppearance.GetDefaultTexture(); | ||
200 | lock (m_avatarsAppearance) | ||
201 | { | ||
202 | m_avatarsAppearance[avatarId] = appearance; | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | return appearance; | ||
207 | } | ||
208 | |||
209 | private AvatarAppearance CheckCache(LLUUID avatarId) | ||
210 | { | ||
211 | AvatarAppearance appearance = null; | ||
212 | lock (m_avatarsAppearance) | ||
213 | { | ||
214 | if (m_avatarsAppearance.ContainsKey(avatarId)) | ||
215 | { | ||
216 | appearance = m_avatarsAppearance[avatarId]; | ||
217 | } | ||
218 | } | ||
219 | return appearance; | ||
220 | } | ||
221 | |||
222 | public void Initialise(Scene scene, IConfigSource source) | 76 | public void Initialise(Scene scene, IConfigSource source) |
223 | { | 77 | { |
224 | scene.RegisterModuleInterface<IAvatarFactory>(this); | 78 | scene.RegisterModuleInterface<IAvatarFactory>(this); |
@@ -229,31 +83,6 @@ namespace OpenSim.Region.Modules.AvatarFactory | |||
229 | m_scene = scene; | 83 | m_scene = scene; |
230 | } | 84 | } |
231 | 85 | ||
232 | // if (!m_configured) | ||
233 | // { | ||
234 | // m_configured = true; | ||
235 | // try | ||
236 | // { | ||
237 | // m_enablePersist = source.Configs["Startup"].GetBoolean("appearance_persist", false); | ||
238 | // } | ||
239 | // catch (Exception) | ||
240 | // { | ||
241 | // } | ||
242 | // if (m_enablePersist) | ||
243 | // { | ||
244 | // m_connectionString = source.Configs["Startup"].GetString("appearance_connection_string", ""); | ||
245 | |||
246 | // string mapperTypeStr = source.Configs["Startup"].GetString("appearance_database", "MySQL"); | ||
247 | |||
248 | // DataMapperFactory.MAPPER_TYPE mapperType = | ||
249 | // (DataMapperFactory.MAPPER_TYPE) | ||
250 | // Enum.Parse(typeof (DataMapperFactory.MAPPER_TYPE), mapperTypeStr); | ||
251 | |||
252 | // m_databaseMapper = DataMapperFactory.GetDataBaseMapper(mapperType, m_connectionString); | ||
253 | |||
254 | // m_appearanceMapper = new AppearanceTableMapper(m_databaseMapper, "AvatarAppearance"); | ||
255 | // } | ||
256 | // } | ||
257 | } | 86 | } |
258 | 87 | ||
259 | public void PostInitialise() | 88 | public void PostInitialise() |
@@ -338,20 +167,17 @@ namespace OpenSim.Region.Modules.AvatarFactory | |||
338 | } | 167 | } |
339 | } | 168 | } |
340 | 169 | ||
341 | public void UpdateDatabase(LLUUID userID, AvatarAppearance avatAppearance) | ||
342 | { | ||
343 | if (m_enablePersist) | ||
344 | { | ||
345 | m_appearanceMapper.Update(userID.UUID, avatAppearance); | ||
346 | } | ||
347 | } | ||
348 | |||
349 | public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) | 170 | public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) |
350 | { | 171 | { |
351 | visualParams = GetDefaultVisualParams(); | 172 | visualParams = GetDefaultVisualParams(); |
352 | wearables = AvatarWearable.DefaultWearables; | 173 | wearables = AvatarWearable.DefaultWearables; |
353 | } | 174 | } |
354 | 175 | ||
176 | public void UpdateDatabase(LLUUID user, AvatarAppearance appearance) | ||
177 | { | ||
178 | m_scene.CommsManager.UserService.UpdateUserAppearance(user, appearance); | ||
179 | } | ||
180 | |||
355 | private static byte[] GetDefaultVisualParams() | 181 | private static byte[] GetDefaultVisualParams() |
356 | { | 182 | { |
357 | byte[] visualParams; | 183 | byte[] visualParams; |