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 /OpenSim/Region/Modules | |
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.
Diffstat (limited to 'OpenSim/Region/Modules')
-rw-r--r-- | OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs | 186 |
1 files changed, 6 insertions, 180 deletions
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; |