diff options
Diffstat (limited to 'OpenSim')
146 files changed, 5342 insertions, 2512 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs index fd152c3..85e5cc6 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Capabilities.Handlers.GetTexture.Tests | |||
50 | TestHelpers.InMethod(); | 50 | TestHelpers.InMethod(); |
51 | 51 | ||
52 | // Overkill - we only really need the asset service, not a whole scene. | 52 | // Overkill - we only really need the asset service, not a whole scene. |
53 | Scene scene = SceneHelpers.SetupScene(); | 53 | Scene scene = new SceneHelpers().SetupScene(); |
54 | 54 | ||
55 | GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService); | 55 | GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService); |
56 | TestOSHttpRequest req = new TestOSHttpRequest(); | 56 | TestOSHttpRequest req = new TestOSHttpRequest(); |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index a22dc0a..20df234 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -163,54 +163,53 @@ namespace OpenSim.Data.MySQL | |||
163 | { | 163 | { |
164 | dbcon.Open(); | 164 | dbcon.Open(); |
165 | 165 | ||
166 | MySqlCommand cmd = | 166 | using (MySqlCommand cmd = |
167 | new MySqlCommand( | 167 | new MySqlCommand( |
168 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + | 168 | "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + |
169 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", | 169 | "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?CreatorID, ?data)", |
170 | dbcon); | 170 | dbcon)) |
171 | |||
172 | string assetName = asset.Name; | ||
173 | if (asset.Name.Length > 64) | ||
174 | { | ||
175 | assetName = asset.Name.Substring(0, 64); | ||
176 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); | ||
177 | } | ||
178 | |||
179 | string assetDescription = asset.Description; | ||
180 | if (asset.Description.Length > 64) | ||
181 | { | ||
182 | assetDescription = asset.Description.Substring(0, 64); | ||
183 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); | ||
184 | } | ||
185 | |||
186 | // need to ensure we dispose | ||
187 | try | ||
188 | { | 171 | { |
189 | using (cmd) | 172 | string assetName = asset.Name; |
173 | if (asset.Name.Length > 64) | ||
190 | { | 174 | { |
191 | // create unix epoch time | 175 | assetName = asset.Name.Substring(0, 64); |
192 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 176 | m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length + " to " + assetName.Length + " characters on add"); |
193 | cmd.Parameters.AddWithValue("?id", asset.ID); | 177 | } |
194 | cmd.Parameters.AddWithValue("?name", assetName); | 178 | |
195 | cmd.Parameters.AddWithValue("?description", assetDescription); | 179 | string assetDescription = asset.Description; |
196 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | 180 | if (asset.Description.Length > 64) |
197 | cmd.Parameters.AddWithValue("?local", asset.Local); | 181 | { |
198 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | 182 | assetDescription = asset.Description.Substring(0, 64); |
199 | cmd.Parameters.AddWithValue("?create_time", now); | 183 | m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length + " to " + assetDescription.Length + " characters on add"); |
200 | cmd.Parameters.AddWithValue("?access_time", now); | 184 | } |
201 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | 185 | |
202 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | 186 | try |
203 | cmd.Parameters.AddWithValue("?data", asset.Data); | 187 | { |
204 | cmd.ExecuteNonQuery(); | 188 | using (cmd) |
205 | cmd.Dispose(); | 189 | { |
206 | return true; | 190 | // create unix epoch time |
191 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | ||
192 | cmd.Parameters.AddWithValue("?id", asset.ID); | ||
193 | cmd.Parameters.AddWithValue("?name", assetName); | ||
194 | cmd.Parameters.AddWithValue("?description", assetDescription); | ||
195 | cmd.Parameters.AddWithValue("?assetType", asset.Type); | ||
196 | cmd.Parameters.AddWithValue("?local", asset.Local); | ||
197 | cmd.Parameters.AddWithValue("?temporary", asset.Temporary); | ||
198 | cmd.Parameters.AddWithValue("?create_time", now); | ||
199 | cmd.Parameters.AddWithValue("?access_time", now); | ||
200 | cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID); | ||
201 | cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); | ||
202 | cmd.Parameters.AddWithValue("?data", asset.Data); | ||
203 | cmd.ExecuteNonQuery(); | ||
204 | return true; | ||
205 | } | ||
206 | } | ||
207 | catch (Exception e) | ||
208 | { | ||
209 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", | ||
210 | asset.FullID, asset.Name, e.Message); | ||
211 | return false; | ||
207 | } | 212 | } |
208 | } | ||
209 | catch (Exception e) | ||
210 | { | ||
211 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", | ||
212 | asset.FullID, asset.Name, e.Message); | ||
213 | return false; | ||
214 | } | 213 | } |
215 | } | 214 | } |
216 | } | 215 | } |
@@ -223,33 +222,31 @@ namespace OpenSim.Data.MySQL | |||
223 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 222 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
224 | { | 223 | { |
225 | dbcon.Open(); | 224 | dbcon.Open(); |
226 | MySqlCommand cmd = | ||
227 | new MySqlCommand("update assets set access_time=?access_time where id=?id", | ||
228 | dbcon); | ||
229 | 225 | ||
230 | // need to ensure we dispose | 226 | using (MySqlCommand cmd |
231 | try | 227 | = new MySqlCommand("update assets set access_time=?access_time where id=?id", dbcon)) |
232 | { | 228 | { |
233 | using (cmd) | 229 | try |
234 | { | 230 | { |
235 | // create unix epoch time | 231 | using (cmd) |
236 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); | 232 | { |
237 | cmd.Parameters.AddWithValue("?id", asset.ID); | 233 | // create unix epoch time |
238 | cmd.Parameters.AddWithValue("?access_time", now); | 234 | int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); |
239 | cmd.ExecuteNonQuery(); | 235 | cmd.Parameters.AddWithValue("?id", asset.ID); |
240 | cmd.Dispose(); | 236 | cmd.Parameters.AddWithValue("?access_time", now); |
237 | cmd.ExecuteNonQuery(); | ||
238 | } | ||
239 | } | ||
240 | catch (Exception e) | ||
241 | { | ||
242 | m_log.ErrorFormat( | ||
243 | "[ASSETS DB]: " + | ||
244 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | ||
245 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | ||
241 | } | 246 | } |
242 | } | ||
243 | catch (Exception e) | ||
244 | { | ||
245 | m_log.ErrorFormat( | ||
246 | "[ASSETS DB]: " + | ||
247 | "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() | ||
248 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | ||
249 | } | 247 | } |
250 | } | 248 | } |
251 | } | 249 | } |
252 | |||
253 | } | 250 | } |
254 | 251 | ||
255 | /// <summary> | 252 | /// <summary> |
@@ -312,35 +309,41 @@ namespace OpenSim.Data.MySQL | |||
312 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 309 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
313 | { | 310 | { |
314 | dbcon.Open(); | 311 | dbcon.Open(); |
315 | MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", dbcon); | ||
316 | cmd.Parameters.AddWithValue("?start", start); | ||
317 | cmd.Parameters.AddWithValue("?count", count); | ||
318 | 312 | ||
319 | try | 313 | using (MySqlCommand cmd |
314 | = new MySqlCommand( | ||
315 | "SELECT name,description,assetType,temporary,id,asset_flags,CreatorID FROM assets LIMIT ?start, ?count", | ||
316 | dbcon)) | ||
320 | { | 317 | { |
321 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) | 318 | cmd.Parameters.AddWithValue("?start", start); |
319 | cmd.Parameters.AddWithValue("?count", count); | ||
320 | |||
321 | try | ||
322 | { | 322 | { |
323 | while (dbReader.Read()) | 323 | using (MySqlDataReader dbReader = cmd.ExecuteReader()) |
324 | { | 324 | { |
325 | AssetMetadata metadata = new AssetMetadata(); | 325 | while (dbReader.Read()) |
326 | metadata.Name = (string)dbReader["name"]; | 326 | { |
327 | metadata.Description = (string)dbReader["description"]; | 327 | AssetMetadata metadata = new AssetMetadata(); |
328 | metadata.Type = (sbyte)dbReader["assetType"]; | 328 | metadata.Name = (string)dbReader["name"]; |
329 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. | 329 | metadata.Description = (string)dbReader["description"]; |
330 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); | 330 | metadata.Type = (sbyte)dbReader["assetType"]; |
331 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | 331 | metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. |
332 | metadata.CreatorID = dbReader["CreatorID"].ToString(); | 332 | metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); |
333 | 333 | metadata.FullID = DBGuid.FromDB(dbReader["id"]); | |
334 | // Current SHA1s are not stored/computed. | 334 | metadata.CreatorID = dbReader["CreatorID"].ToString(); |
335 | metadata.SHA1 = new byte[] { }; | 335 | |
336 | 336 | // Current SHA1s are not stored/computed. | |
337 | retList.Add(metadata); | 337 | metadata.SHA1 = new byte[] { }; |
338 | |||
339 | retList.Add(metadata); | ||
340 | } | ||
338 | } | 341 | } |
339 | } | 342 | } |
340 | } | 343 | catch (Exception e) |
341 | catch (Exception e) | 344 | { |
342 | { | 345 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); |
343 | m_log.Error("[ASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); | 346 | } |
344 | } | 347 | } |
345 | } | 348 | } |
346 | } | 349 | } |
@@ -355,11 +358,12 @@ namespace OpenSim.Data.MySQL | |||
355 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 358 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
356 | { | 359 | { |
357 | dbcon.Open(); | 360 | dbcon.Open(); |
358 | MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon); | ||
359 | cmd.Parameters.AddWithValue("?id", id); | ||
360 | cmd.ExecuteNonQuery(); | ||
361 | 361 | ||
362 | cmd.Dispose(); | 362 | using (MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon)) |
363 | { | ||
364 | cmd.Parameters.AddWithValue("?id", id); | ||
365 | cmd.ExecuteNonQuery(); | ||
366 | } | ||
363 | } | 367 | } |
364 | } | 368 | } |
365 | 369 | ||
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 8d82f61..7627497 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -70,99 +70,106 @@ namespace OpenSim.Data.MySQL | |||
70 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 70 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
71 | { | 71 | { |
72 | dbcon.Open(); | 72 | dbcon.Open(); |
73 | MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon); | ||
74 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | ||
75 | |||
76 | IDataReader result = cmd.ExecuteReader(); | ||
77 | 73 | ||
78 | if (result.Read()) | 74 | using (MySqlCommand cmd |
75 | = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID", dbcon)) | ||
79 | { | 76 | { |
80 | ret.PrincipalID = principalID; | 77 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); |
81 | 78 | ||
82 | if (m_ColumnNames == null) | 79 | IDataReader result = cmd.ExecuteReader(); |
80 | |||
81 | if (result.Read()) | ||
83 | { | 82 | { |
84 | m_ColumnNames = new List<string>(); | 83 | ret.PrincipalID = principalID; |
85 | 84 | ||
86 | DataTable schemaTable = result.GetSchemaTable(); | 85 | CheckColumnNames(result); |
87 | foreach (DataRow row in schemaTable.Rows) | 86 | |
88 | m_ColumnNames.Add(row["ColumnName"].ToString()); | 87 | foreach (string s in m_ColumnNames) |
88 | { | ||
89 | if (s == "UUID") | ||
90 | continue; | ||
91 | |||
92 | ret.Data[s] = result[s].ToString(); | ||
93 | } | ||
94 | |||
95 | return ret; | ||
89 | } | 96 | } |
90 | 97 | else | |
91 | foreach (string s in m_ColumnNames) | ||
92 | { | 98 | { |
93 | if (s == "UUID") | 99 | return null; |
94 | continue; | ||
95 | |||
96 | ret.Data[s] = result[s].ToString(); | ||
97 | } | 100 | } |
98 | |||
99 | return ret; | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | return null; | ||
104 | } | 101 | } |
105 | } | 102 | } |
106 | } | 103 | } |
107 | 104 | ||
108 | public bool Store(AuthenticationData data) | 105 | private void CheckColumnNames(IDataReader result) |
109 | { | 106 | { |
110 | if (data.Data.ContainsKey("UUID")) | 107 | if (m_ColumnNames != null) |
111 | data.Data.Remove("UUID"); | 108 | return; |
112 | 109 | ||
113 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 110 | List<string> columnNames = new List<string>(); |
114 | |||
115 | MySqlCommand cmd = new MySqlCommand(); | ||
116 | 111 | ||
117 | string update = "update `"+m_Realm+"` set "; | 112 | DataTable schemaTable = result.GetSchemaTable(); |
118 | bool first = true; | 113 | foreach (DataRow row in schemaTable.Rows) |
119 | foreach (string field in fields) | 114 | columnNames.Add(row["ColumnName"].ToString()); |
120 | { | ||
121 | if (!first) | ||
122 | update += ", "; | ||
123 | update += "`" + field + "` = ?"+field; | ||
124 | 115 | ||
125 | first = false; | 116 | m_ColumnNames = columnNames; |
126 | 117 | } | |
127 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); | ||
128 | } | ||
129 | 118 | ||
130 | update += " where UUID = ?principalID"; | 119 | public bool Store(AuthenticationData data) |
120 | { | ||
121 | if (data.Data.ContainsKey("UUID")) | ||
122 | data.Data.Remove("UUID"); | ||
131 | 123 | ||
132 | cmd.CommandText = update; | 124 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
133 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); | ||
134 | 125 | ||
135 | if (ExecuteNonQuery(cmd) < 1) | 126 | using (MySqlCommand cmd = new MySqlCommand()) |
136 | { | 127 | { |
137 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + | 128 | string update = "update `"+m_Realm+"` set "; |
138 | String.Join("`, `", fields) + | 129 | bool first = true; |
139 | "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; | 130 | foreach (string field in fields) |
140 | 131 | { | |
141 | cmd.CommandText = insert; | 132 | if (!first) |
142 | 133 | update += ", "; | |
134 | update += "`" + field + "` = ?"+field; | ||
135 | |||
136 | first = false; | ||
137 | |||
138 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); | ||
139 | } | ||
140 | |||
141 | update += " where UUID = ?principalID"; | ||
142 | |||
143 | cmd.CommandText = update; | ||
144 | cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); | ||
145 | |||
143 | if (ExecuteNonQuery(cmd) < 1) | 146 | if (ExecuteNonQuery(cmd) < 1) |
144 | { | 147 | { |
145 | cmd.Dispose(); | 148 | string insert = "insert into `" + m_Realm + "` (`UUID`, `" + |
146 | return false; | 149 | String.Join("`, `", fields) + |
150 | "`) values (?principalID, ?" + String.Join(", ?", fields) + ")"; | ||
151 | |||
152 | cmd.CommandText = insert; | ||
153 | |||
154 | if (ExecuteNonQuery(cmd) < 1) | ||
155 | return false; | ||
147 | } | 156 | } |
148 | } | 157 | } |
149 | 158 | ||
150 | cmd.Dispose(); | ||
151 | |||
152 | return true; | 159 | return true; |
153 | } | 160 | } |
154 | 161 | ||
155 | public bool SetDataItem(UUID principalID, string item, string value) | 162 | public bool SetDataItem(UUID principalID, string item, string value) |
156 | { | 163 | { |
157 | MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + | 164 | using (MySqlCommand cmd |
158 | "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); | 165 | = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where UUID = ?UUID")) |
159 | 166 | { | |
160 | 167 | cmd.Parameters.AddWithValue("?"+item, value); | |
161 | cmd.Parameters.AddWithValue("?"+item, value); | 168 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); |
162 | cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); | 169 | |
163 | 170 | if (ExecuteNonQuery(cmd) > 0) | |
164 | if (ExecuteNonQuery(cmd) > 0) | 171 | return true; |
165 | return true; | 172 | } |
166 | 173 | ||
167 | return false; | 174 | return false; |
168 | } | 175 | } |
@@ -172,18 +179,18 @@ namespace OpenSim.Data.MySQL | |||
172 | if (System.Environment.TickCount - m_LastExpire > 30000) | 179 | if (System.Environment.TickCount - m_LastExpire > 30000) |
173 | DoExpire(); | 180 | DoExpire(); |
174 | 181 | ||
175 | MySqlCommand cmd = new MySqlCommand("insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))"); | 182 | using (MySqlCommand cmd |
176 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | 183 | = new MySqlCommand( |
177 | cmd.Parameters.AddWithValue("?token", token); | 184 | "insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))")) |
178 | cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); | ||
179 | |||
180 | if (ExecuteNonQuery(cmd) > 0) | ||
181 | { | 185 | { |
182 | cmd.Dispose(); | 186 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); |
183 | return true; | 187 | cmd.Parameters.AddWithValue("?token", token); |
188 | cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); | ||
189 | |||
190 | if (ExecuteNonQuery(cmd) > 0) | ||
191 | return true; | ||
184 | } | 192 | } |
185 | 193 | ||
186 | cmd.Dispose(); | ||
187 | return false; | 194 | return false; |
188 | } | 195 | } |
189 | 196 | ||
@@ -192,30 +199,29 @@ namespace OpenSim.Data.MySQL | |||
192 | if (System.Environment.TickCount - m_LastExpire > 30000) | 199 | if (System.Environment.TickCount - m_LastExpire > 30000) |
193 | DoExpire(); | 200 | DoExpire(); |
194 | 201 | ||
195 | MySqlCommand cmd = new MySqlCommand("update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()"); | 202 | using (MySqlCommand cmd |
196 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); | 203 | = new MySqlCommand( |
197 | cmd.Parameters.AddWithValue("?token", token); | 204 | "update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()")) |
198 | cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); | ||
199 | |||
200 | if (ExecuteNonQuery(cmd) > 0) | ||
201 | { | 205 | { |
202 | cmd.Dispose(); | 206 | cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); |
203 | return true; | 207 | cmd.Parameters.AddWithValue("?token", token); |
204 | } | 208 | cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString()); |
205 | 209 | ||
206 | cmd.Dispose(); | 210 | if (ExecuteNonQuery(cmd) > 0) |
211 | return true; | ||
212 | } | ||
207 | 213 | ||
208 | return false; | 214 | return false; |
209 | } | 215 | } |
210 | 216 | ||
211 | private void DoExpire() | 217 | private void DoExpire() |
212 | { | 218 | { |
213 | MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()"); | 219 | using (MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()")) |
214 | ExecuteNonQuery(cmd); | 220 | { |
215 | 221 | ExecuteNonQuery(cmd); | |
216 | cmd.Dispose(); | 222 | } |
217 | 223 | ||
218 | m_LastExpire = System.Environment.TickCount; | 224 | m_LastExpire = System.Environment.TickCount; |
219 | } | 225 | } |
220 | } | 226 | } |
221 | } | 227 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLAvatarData.cs b/OpenSim/Data/MySQL/MySQLAvatarData.cs index 8c841ab..6a2f5d8 100644 --- a/OpenSim/Data/MySQL/MySQLAvatarData.cs +++ b/OpenSim/Data/MySQL/MySQLAvatarData.cs | |||
@@ -52,14 +52,15 @@ namespace OpenSim.Data.MySQL | |||
52 | 52 | ||
53 | public bool Delete(UUID principalID, string name) | 53 | public bool Delete(UUID principalID, string name) |
54 | { | 54 | { |
55 | MySqlCommand cmd = new MySqlCommand(); | 55 | using (MySqlCommand cmd = new MySqlCommand()) |
56 | 56 | { | |
57 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); | 57 | cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = ?PrincipalID and `Name` = ?Name", m_Realm); |
58 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | 58 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); |
59 | cmd.Parameters.AddWithValue("?Name", name); | 59 | cmd.Parameters.AddWithValue("?Name", name); |
60 | 60 | ||
61 | if (ExecuteNonQuery(cmd) > 0) | 61 | if (ExecuteNonQuery(cmd) > 0) |
62 | return true; | 62 | return true; |
63 | } | ||
63 | 64 | ||
64 | return false; | 65 | return false; |
65 | } | 66 | } |
diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 130ba5e..3cd6b8f 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs | |||
@@ -49,34 +49,38 @@ namespace OpenSim.Data.MySQL | |||
49 | 49 | ||
50 | public bool Delete(string principalID, string friend) | 50 | public bool Delete(string principalID, string friend) |
51 | { | 51 | { |
52 | MySqlCommand cmd = new MySqlCommand(); | 52 | using (MySqlCommand cmd = new MySqlCommand()) |
53 | { | ||
54 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); | ||
55 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | ||
56 | cmd.Parameters.AddWithValue("?Friend", friend); | ||
53 | 57 | ||
54 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); | 58 | ExecuteNonQuery(cmd); |
55 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | 59 | } |
56 | cmd.Parameters.AddWithValue("?Friend", friend); | ||
57 | |||
58 | ExecuteNonQuery(cmd); | ||
59 | 60 | ||
60 | return true; | 61 | return true; |
61 | } | 62 | } |
62 | 63 | ||
63 | public FriendsData[] GetFriends(UUID principalID) | 64 | public FriendsData[] GetFriends(UUID principalID) |
64 | { | 65 | { |
65 | MySqlCommand cmd = new MySqlCommand(); | 66 | using (MySqlCommand cmd = new MySqlCommand()) |
66 | 67 | { | |
67 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); | 68 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); |
68 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | 69 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); |
69 | 70 | ||
70 | return DoQuery(cmd); | 71 | return DoQuery(cmd); |
72 | } | ||
71 | } | 73 | } |
72 | 74 | ||
73 | public FriendsData[] GetFriends(string principalID) | 75 | public FriendsData[] GetFriends(string principalID) |
74 | { | 76 | { |
75 | MySqlCommand cmd = new MySqlCommand(); | 77 | using (MySqlCommand cmd = new MySqlCommand()) |
78 | { | ||
79 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); | ||
80 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); | ||
76 | 81 | ||
77 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); | 82 | return DoQuery(cmd); |
78 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); | 83 | } |
79 | return DoQuery(cmd); | ||
80 | } | 84 | } |
81 | } | 85 | } |
82 | } | 86 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 786b955..86367a1 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -91,15 +91,17 @@ namespace OpenSim.Data.MySQL | |||
91 | if (m_ColumnNames != null) | 91 | if (m_ColumnNames != null) |
92 | return; | 92 | return; |
93 | 93 | ||
94 | m_ColumnNames = new List<string>(); | 94 | List<string> columnNames = new List<string>(); |
95 | 95 | ||
96 | DataTable schemaTable = reader.GetSchemaTable(); | 96 | DataTable schemaTable = reader.GetSchemaTable(); |
97 | foreach (DataRow row in schemaTable.Rows) | 97 | foreach (DataRow row in schemaTable.Rows) |
98 | { | 98 | { |
99 | if (row["ColumnName"] != null && | 99 | if (row["ColumnName"] != null && |
100 | (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) | 100 | (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) |
101 | m_ColumnNames.Add(row["ColumnName"].ToString()); | 101 | columnNames.Add(row["ColumnName"].ToString()); |
102 | } | 102 | } |
103 | |||
104 | m_ColumnNames = columnNames; | ||
103 | } | 105 | } |
104 | 106 | ||
105 | public virtual T[] Get(string field, string key) | 107 | public virtual T[] Get(string field, string key) |
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 1a634e5..e9b10f3 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs | |||
@@ -467,43 +467,43 @@ namespace OpenSim.Data.MySQL | |||
467 | { | 467 | { |
468 | dbcon.Open(); | 468 | dbcon.Open(); |
469 | 469 | ||
470 | MySqlCommand result = new MySqlCommand(sql, dbcon); | 470 | using (MySqlCommand result = new MySqlCommand(sql, dbcon)) |
471 | result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); | ||
472 | result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); | ||
473 | result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); | ||
474 | result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); | ||
475 | result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); | ||
476 | result.Parameters.AddWithValue("?inventoryName", itemName); | ||
477 | result.Parameters.AddWithValue("?inventoryDescription", itemDesc); | ||
478 | result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); | ||
479 | result.Parameters.AddWithValue("?inventoryCurrentPermissions", | ||
480 | item.CurrentPermissions.ToString()); | ||
481 | result.Parameters.AddWithValue("?invType", item.InvType); | ||
482 | result.Parameters.AddWithValue("?creatorID", item.CreatorId); | ||
483 | result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); | ||
484 | result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); | ||
485 | result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); | ||
486 | result.Parameters.AddWithValue("?salePrice", item.SalePrice); | ||
487 | result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); | ||
488 | result.Parameters.AddWithValue("?creationDate", item.CreationDate); | ||
489 | result.Parameters.AddWithValue("?groupID", item.GroupID); | ||
490 | result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); | ||
491 | result.Parameters.AddWithValue("?flags", item.Flags); | ||
492 | |||
493 | lock (m_dbLock) | ||
494 | { | 471 | { |
495 | result.ExecuteNonQuery(); | 472 | result.Parameters.AddWithValue("?inventoryID", item.ID.ToString()); |
473 | result.Parameters.AddWithValue("?assetID", item.AssetID.ToString()); | ||
474 | result.Parameters.AddWithValue("?assetType", item.AssetType.ToString()); | ||
475 | result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString()); | ||
476 | result.Parameters.AddWithValue("?avatarID", item.Owner.ToString()); | ||
477 | result.Parameters.AddWithValue("?inventoryName", itemName); | ||
478 | result.Parameters.AddWithValue("?inventoryDescription", itemDesc); | ||
479 | result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString()); | ||
480 | result.Parameters.AddWithValue("?inventoryCurrentPermissions", | ||
481 | item.CurrentPermissions.ToString()); | ||
482 | result.Parameters.AddWithValue("?invType", item.InvType); | ||
483 | result.Parameters.AddWithValue("?creatorID", item.CreatorId); | ||
484 | result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions); | ||
485 | result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions); | ||
486 | result.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions); | ||
487 | result.Parameters.AddWithValue("?salePrice", item.SalePrice); | ||
488 | result.Parameters.AddWithValue("?saleType", unchecked((sbyte)item.SaleType)); | ||
489 | result.Parameters.AddWithValue("?creationDate", item.CreationDate); | ||
490 | result.Parameters.AddWithValue("?groupID", item.GroupID); | ||
491 | result.Parameters.AddWithValue("?groupOwned", item.GroupOwned); | ||
492 | result.Parameters.AddWithValue("?flags", item.Flags); | ||
493 | |||
494 | lock (m_dbLock) | ||
495 | result.ExecuteNonQuery(); | ||
496 | |||
497 | result.Dispose(); | ||
496 | } | 498 | } |
497 | 499 | ||
498 | result.Dispose(); | 500 | using (MySqlCommand result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon)) |
499 | |||
500 | result = new MySqlCommand("update inventoryfolders set version=version+1 where folderID = ?folderID", dbcon); | ||
501 | result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); | ||
502 | lock (m_dbLock) | ||
503 | { | 501 | { |
504 | result.ExecuteNonQuery(); | 502 | result.Parameters.AddWithValue("?folderID", item.Folder.ToString()); |
503 | |||
504 | lock (m_dbLock) | ||
505 | result.ExecuteNonQuery(); | ||
505 | } | 506 | } |
506 | result.Dispose(); | ||
507 | } | 507 | } |
508 | } | 508 | } |
509 | catch (MySqlException e) | 509 | catch (MySqlException e) |
@@ -533,12 +533,12 @@ namespace OpenSim.Data.MySQL | |||
533 | { | 533 | { |
534 | dbcon.Open(); | 534 | dbcon.Open(); |
535 | 535 | ||
536 | MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon); | 536 | using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", dbcon)) |
537 | cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); | ||
538 | |||
539 | lock (m_dbLock) | ||
540 | { | 537 | { |
541 | cmd.ExecuteNonQuery(); | 538 | cmd.Parameters.AddWithValue("?uuid", itemID.ToString()); |
539 | |||
540 | lock (m_dbLock) | ||
541 | cmd.ExecuteNonQuery(); | ||
542 | } | 542 | } |
543 | } | 543 | } |
544 | } | 544 | } |
@@ -579,24 +579,26 @@ namespace OpenSim.Data.MySQL | |||
579 | { | 579 | { |
580 | dbcon.Open(); | 580 | dbcon.Open(); |
581 | 581 | ||
582 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | 582 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) |
583 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); | ||
584 | cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); | ||
585 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | ||
586 | cmd.Parameters.AddWithValue("?folderName", folderName); | ||
587 | cmd.Parameters.AddWithValue("?type", folder.Type); | ||
588 | cmd.Parameters.AddWithValue("?version", folder.Version); | ||
589 | |||
590 | try | ||
591 | { | 583 | { |
592 | lock (m_dbLock) | 584 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); |
585 | cmd.Parameters.AddWithValue("?agentID", folder.Owner.ToString()); | ||
586 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | ||
587 | cmd.Parameters.AddWithValue("?folderName", folderName); | ||
588 | cmd.Parameters.AddWithValue("?type", folder.Type); | ||
589 | cmd.Parameters.AddWithValue("?version", folder.Version); | ||
590 | |||
591 | try | ||
593 | { | 592 | { |
594 | cmd.ExecuteNonQuery(); | 593 | lock (m_dbLock) |
594 | { | ||
595 | cmd.ExecuteNonQuery(); | ||
596 | } | ||
597 | } | ||
598 | catch (Exception e) | ||
599 | { | ||
600 | m_log.Error(e.ToString()); | ||
595 | } | 601 | } |
596 | } | ||
597 | catch (Exception e) | ||
598 | { | ||
599 | m_log.Error(e.ToString()); | ||
600 | } | 602 | } |
601 | } | 603 | } |
602 | } | 604 | } |
@@ -624,20 +626,22 @@ namespace OpenSim.Data.MySQL | |||
624 | { | 626 | { |
625 | dbcon.Open(); | 627 | dbcon.Open(); |
626 | 628 | ||
627 | MySqlCommand cmd = new MySqlCommand(sql, dbcon); | 629 | using (MySqlCommand cmd = new MySqlCommand(sql, dbcon)) |
628 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); | ||
629 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | ||
630 | |||
631 | try | ||
632 | { | 630 | { |
633 | lock (m_dbLock) | 631 | cmd.Parameters.AddWithValue("?folderID", folder.ID.ToString()); |
632 | cmd.Parameters.AddWithValue("?parentFolderID", folder.ParentID.ToString()); | ||
633 | |||
634 | try | ||
634 | { | 635 | { |
635 | cmd.ExecuteNonQuery(); | 636 | lock (m_dbLock) |
637 | { | ||
638 | cmd.ExecuteNonQuery(); | ||
639 | } | ||
640 | } | ||
641 | catch (Exception e) | ||
642 | { | ||
643 | m_log.Error(e.ToString()); | ||
636 | } | 644 | } |
637 | } | ||
638 | catch (Exception e) | ||
639 | { | ||
640 | m_log.Error(e.ToString()); | ||
641 | } | 645 | } |
642 | } | 646 | } |
643 | } | 647 | } |
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index fc625f0..7808060 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs | |||
@@ -63,13 +63,14 @@ namespace OpenSim.Data.MySQL | |||
63 | 63 | ||
64 | public void LogoutRegionAgents(UUID regionID) | 64 | public void LogoutRegionAgents(UUID regionID) |
65 | { | 65 | { |
66 | MySqlCommand cmd = new MySqlCommand(); | 66 | using (MySqlCommand cmd = new MySqlCommand()) |
67 | 67 | { | |
68 | cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); | 68 | cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); |
69 | 69 | ||
70 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 70 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
71 | 71 | ||
72 | ExecuteNonQuery(cmd); | 72 | ExecuteNonQuery(cmd); |
73 | } | ||
73 | } | 74 | } |
74 | 75 | ||
75 | public bool ReportAgent(UUID sessionID, UUID regionID) | 76 | public bool ReportAgent(UUID sessionID, UUID regionID) |
@@ -81,17 +82,18 @@ namespace OpenSim.Data.MySQL | |||
81 | if (regionID == UUID.Zero) | 82 | if (regionID == UUID.Zero) |
82 | return false; | 83 | return false; |
83 | 84 | ||
84 | MySqlCommand cmd = new MySqlCommand(); | 85 | using (MySqlCommand cmd = new MySqlCommand()) |
85 | 86 | { | |
86 | cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); | 87 | cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, LastSeen=NOW() where `SessionID`=?SessionID", m_Realm); |
87 | 88 | ||
88 | cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); | 89 | cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); |
89 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); | 90 | cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); |
90 | 91 | ||
91 | if (ExecuteNonQuery(cmd) == 0) | 92 | if (ExecuteNonQuery(cmd) == 0) |
92 | return false; | 93 | return false; |
94 | } | ||
93 | 95 | ||
94 | return true; | 96 | return true; |
95 | } | 97 | } |
96 | } | 98 | } |
97 | } | 99 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index c20c392..0614879 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -162,17 +162,7 @@ namespace OpenSim.Data.MySQL | |||
162 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | 162 | ret.sizeX = Convert.ToInt32(result["sizeX"]); |
163 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | 163 | ret.sizeY = Convert.ToInt32(result["sizeY"]); |
164 | 164 | ||
165 | if (m_ColumnNames == null) | 165 | CheckColumnNames(result); |
166 | { | ||
167 | m_ColumnNames = new List<string>(); | ||
168 | |||
169 | DataTable schemaTable = result.GetSchemaTable(); | ||
170 | foreach (DataRow row in schemaTable.Rows) | ||
171 | { | ||
172 | if (row["ColumnName"] != null) | ||
173 | m_ColumnNames.Add(row["ColumnName"].ToString()); | ||
174 | } | ||
175 | } | ||
176 | 166 | ||
177 | foreach (string s in m_ColumnNames) | 167 | foreach (string s in m_ColumnNames) |
178 | { | 168 | { |
@@ -187,7 +177,11 @@ namespace OpenSim.Data.MySQL | |||
187 | if (s == "locY") | 177 | if (s == "locY") |
188 | continue; | 178 | continue; |
189 | 179 | ||
190 | ret.Data[s] = result[s].ToString(); | 180 | object value = result[s]; |
181 | if (value is DBNull) | ||
182 | ret.Data[s] = null; | ||
183 | else | ||
184 | ret.Data[s] = result[s].ToString(); | ||
191 | } | 185 | } |
192 | 186 | ||
193 | retList.Add(ret); | 187 | retList.Add(ret); |
@@ -198,6 +192,23 @@ namespace OpenSim.Data.MySQL | |||
198 | return retList; | 192 | return retList; |
199 | } | 193 | } |
200 | 194 | ||
195 | private void CheckColumnNames(IDataReader result) | ||
196 | { | ||
197 | if (m_ColumnNames != null) | ||
198 | return; | ||
199 | |||
200 | List<string> columnNames = new List<string>(); | ||
201 | |||
202 | DataTable schemaTable = result.GetSchemaTable(); | ||
203 | foreach (DataRow row in schemaTable.Rows) | ||
204 | { | ||
205 | if (row["ColumnName"] != null) | ||
206 | columnNames.Add(row["ColumnName"].ToString()); | ||
207 | } | ||
208 | |||
209 | m_ColumnNames = columnNames; | ||
210 | } | ||
211 | |||
201 | public bool Store(RegionData data) | 212 | public bool Store(RegionData data) |
202 | { | 213 | { |
203 | if (data.Data.ContainsKey("uuid")) | 214 | if (data.Data.ContainsKey("uuid")) |
@@ -318,11 +329,12 @@ namespace OpenSim.Data.MySQL | |||
318 | if (scopeID != UUID.Zero) | 329 | if (scopeID != UUID.Zero) |
319 | command += " and ScopeID = ?scopeID"; | 330 | command += " and ScopeID = ?scopeID"; |
320 | 331 | ||
321 | MySqlCommand cmd = new MySqlCommand(command); | 332 | using (MySqlCommand cmd = new MySqlCommand(command)) |
322 | 333 | { | |
323 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); | 334 | cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); |
324 | 335 | ||
325 | return RunCommand(cmd); | 336 | return RunCommand(cmd); |
337 | } | ||
326 | } | 338 | } |
327 | } | 339 | } |
328 | } | 340 | } \ No newline at end of file |
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 33c184f..89600db 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -129,119 +129,119 @@ namespace OpenSim.Data.MySQL | |||
129 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 129 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
130 | { | 130 | { |
131 | dbcon.Open(); | 131 | dbcon.Open(); |
132 | MySqlCommand cmd = dbcon.CreateCommand(); | ||
133 | 132 | ||
134 | foreach (SceneObjectPart prim in obj.Parts) | 133 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
135 | { | 134 | { |
136 | cmd.Parameters.Clear(); | 135 | foreach (SceneObjectPart prim in obj.Parts) |
136 | { | ||
137 | cmd.Parameters.Clear(); | ||
137 | 138 | ||
138 | cmd.CommandText = "replace into prims (" + | 139 | cmd.CommandText = "replace into prims (" + |
139 | "UUID, CreationDate, " + | 140 | "UUID, CreationDate, " + |
140 | "Name, Text, Description, " + | 141 | "Name, Text, Description, " + |
141 | "SitName, TouchName, ObjectFlags, " + | 142 | "SitName, TouchName, ObjectFlags, " + |
142 | "OwnerMask, NextOwnerMask, GroupMask, " + | 143 | "OwnerMask, NextOwnerMask, GroupMask, " + |
143 | "EveryoneMask, BaseMask, PositionX, " + | 144 | "EveryoneMask, BaseMask, PositionX, " + |
144 | "PositionY, PositionZ, GroupPositionX, " + | 145 | "PositionY, PositionZ, GroupPositionX, " + |
145 | "GroupPositionY, GroupPositionZ, VelocityX, " + | 146 | "GroupPositionY, GroupPositionZ, VelocityX, " + |
146 | "VelocityY, VelocityZ, AngularVelocityX, " + | 147 | "VelocityY, VelocityZ, AngularVelocityX, " + |
147 | "AngularVelocityY, AngularVelocityZ, " + | 148 | "AngularVelocityY, AngularVelocityZ, " + |
148 | "AccelerationX, AccelerationY, " + | 149 | "AccelerationX, AccelerationY, " + |
149 | "AccelerationZ, RotationX, " + | 150 | "AccelerationZ, RotationX, " + |
150 | "RotationY, RotationZ, " + | 151 | "RotationY, RotationZ, " + |
151 | "RotationW, SitTargetOffsetX, " + | 152 | "RotationW, SitTargetOffsetX, " + |
152 | "SitTargetOffsetY, SitTargetOffsetZ, " + | 153 | "SitTargetOffsetY, SitTargetOffsetZ, " + |
153 | "SitTargetOrientW, SitTargetOrientX, " + | 154 | "SitTargetOrientW, SitTargetOrientX, " + |
154 | "SitTargetOrientY, SitTargetOrientZ, " + | 155 | "SitTargetOrientY, SitTargetOrientZ, " + |
155 | "RegionUUID, CreatorID, " + | 156 | "RegionUUID, CreatorID, " + |
156 | "OwnerID, GroupID, " + | 157 | "OwnerID, GroupID, " + |
157 | "LastOwnerID, SceneGroupID, " + | 158 | "LastOwnerID, SceneGroupID, " + |
158 | "PayPrice, PayButton1, " + | 159 | "PayPrice, PayButton1, " + |
159 | "PayButton2, PayButton3, " + | 160 | "PayButton2, PayButton3, " + |
160 | "PayButton4, LoopedSound, " + | 161 | "PayButton4, LoopedSound, " + |
161 | "LoopedSoundGain, TextureAnimation, " + | 162 | "LoopedSoundGain, TextureAnimation, " + |
162 | "OmegaX, OmegaY, OmegaZ, " + | 163 | "OmegaX, OmegaY, OmegaZ, " + |
163 | "CameraEyeOffsetX, CameraEyeOffsetY, " + | 164 | "CameraEyeOffsetX, CameraEyeOffsetY, " + |
164 | "CameraEyeOffsetZ, CameraAtOffsetX, " + | 165 | "CameraEyeOffsetZ, CameraAtOffsetX, " + |
165 | "CameraAtOffsetY, CameraAtOffsetZ, " + | 166 | "CameraAtOffsetY, CameraAtOffsetZ, " + |
166 | "ForceMouselook, ScriptAccessPin, " + | 167 | "ForceMouselook, ScriptAccessPin, " + |
167 | "AllowedDrop, DieAtEdge, " + | 168 | "AllowedDrop, DieAtEdge, " + |
168 | "SalePrice, SaleType, " + | 169 | "SalePrice, SaleType, " + |
169 | "ColorR, ColorG, ColorB, ColorA, " + | 170 | "ColorR, ColorG, ColorB, ColorA, " + |
170 | "ParticleSystem, ClickAction, Material, " + | 171 | "ParticleSystem, ClickAction, Material, " + |
171 | "CollisionSound, CollisionSoundVolume, " + | 172 | "CollisionSound, CollisionSoundVolume, " + |
172 | "PassTouches, " + | 173 | "PassTouches, " + |
173 | "LinkNumber, MediaURL, KeyframeMotion, " + | 174 | "LinkNumber, MediaURL, KeyframeMotion, " + |
174 | "PhysicsShapeType, Density, GravityModifier, " + | 175 | "PhysicsShapeType, Density, GravityModifier, " + |
175 | "Friction, Restitution) values (" + "?UUID, " + | 176 | "Friction, Restitution) values (" + "?UUID, " + |
176 | "?CreationDate, ?Name, ?Text, " + | 177 | "?CreationDate, ?Name, ?Text, " + |
177 | "?Description, ?SitName, ?TouchName, " + | 178 | "?Description, ?SitName, ?TouchName, " + |
178 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + | 179 | "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + |
179 | "?GroupMask, ?EveryoneMask, ?BaseMask, " + | 180 | "?GroupMask, ?EveryoneMask, ?BaseMask, " + |
180 | "?PositionX, ?PositionY, ?PositionZ, " + | 181 | "?PositionX, ?PositionY, ?PositionZ, " + |
181 | "?GroupPositionX, ?GroupPositionY, " + | 182 | "?GroupPositionX, ?GroupPositionY, " + |
182 | "?GroupPositionZ, ?VelocityX, " + | 183 | "?GroupPositionZ, ?VelocityX, " + |
183 | "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + | 184 | "?VelocityY, ?VelocityZ, ?AngularVelocityX, " + |
184 | "?AngularVelocityY, ?AngularVelocityZ, " + | 185 | "?AngularVelocityY, ?AngularVelocityZ, " + |
185 | "?AccelerationX, ?AccelerationY, " + | 186 | "?AccelerationX, ?AccelerationY, " + |
186 | "?AccelerationZ, ?RotationX, " + | 187 | "?AccelerationZ, ?RotationX, " + |
187 | "?RotationY, ?RotationZ, " + | 188 | "?RotationY, ?RotationZ, " + |
188 | "?RotationW, ?SitTargetOffsetX, " + | 189 | "?RotationW, ?SitTargetOffsetX, " + |
189 | "?SitTargetOffsetY, ?SitTargetOffsetZ, " + | 190 | "?SitTargetOffsetY, ?SitTargetOffsetZ, " + |
190 | "?SitTargetOrientW, ?SitTargetOrientX, " + | 191 | "?SitTargetOrientW, ?SitTargetOrientX, " + |
191 | "?SitTargetOrientY, ?SitTargetOrientZ, " + | 192 | "?SitTargetOrientY, ?SitTargetOrientZ, " + |
192 | "?RegionUUID, ?CreatorID, ?OwnerID, " + | 193 | "?RegionUUID, ?CreatorID, ?OwnerID, " + |
193 | "?GroupID, ?LastOwnerID, ?SceneGroupID, " + | 194 | "?GroupID, ?LastOwnerID, ?SceneGroupID, " + |
194 | "?PayPrice, ?PayButton1, ?PayButton2, " + | 195 | "?PayPrice, ?PayButton1, ?PayButton2, " + |
195 | "?PayButton3, ?PayButton4, ?LoopedSound, " + | 196 | "?PayButton3, ?PayButton4, ?LoopedSound, " + |
196 | "?LoopedSoundGain, ?TextureAnimation, " + | 197 | "?LoopedSoundGain, ?TextureAnimation, " + |
197 | "?OmegaX, ?OmegaY, ?OmegaZ, " + | 198 | "?OmegaX, ?OmegaY, ?OmegaZ, " + |
198 | "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + | 199 | "?CameraEyeOffsetX, ?CameraEyeOffsetY, " + |
199 | "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + | 200 | "?CameraEyeOffsetZ, ?CameraAtOffsetX, " + |
200 | "?CameraAtOffsetY, ?CameraAtOffsetZ, " + | 201 | "?CameraAtOffsetY, ?CameraAtOffsetZ, " + |
201 | "?ForceMouselook, ?ScriptAccessPin, " + | 202 | "?ForceMouselook, ?ScriptAccessPin, " + |
202 | "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + | 203 | "?AllowedDrop, ?DieAtEdge, ?SalePrice, " + |
203 | "?SaleType, ?ColorR, ?ColorG, " + | 204 | "?SaleType, ?ColorR, ?ColorG, " + |
204 | "?ColorB, ?ColorA, ?ParticleSystem, " + | 205 | "?ColorB, ?ColorA, ?ParticleSystem, " + |
205 | "?ClickAction, ?Material, ?CollisionSound, " + | 206 | "?ClickAction, ?Material, ?CollisionSound, " + |
206 | "?CollisionSoundVolume, ?PassTouches, " + | 207 | "?CollisionSoundVolume, ?PassTouches, " + |
207 | "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + | 208 | "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + |
208 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + | 209 | "?PhysicsShapeType, ?Density, ?GravityModifier, " + |
209 | "?Friction, ?Restitution)"; | 210 | "?Friction, ?Restitution)"; |
210 | 211 | ||
211 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); | 212 | FillPrimCommand(cmd, prim, obj.UUID, regionUUID); |
212 | 213 | ||
213 | ExecuteNonQuery(cmd); | 214 | ExecuteNonQuery(cmd); |
214 | 215 | ||
215 | cmd.Parameters.Clear(); | 216 | cmd.Parameters.Clear(); |
216 | 217 | ||
217 | cmd.CommandText = "replace into primshapes (" + | 218 | cmd.CommandText = "replace into primshapes (" + |
218 | "UUID, Shape, ScaleX, ScaleY, " + | 219 | "UUID, Shape, ScaleX, ScaleY, " + |
219 | "ScaleZ, PCode, PathBegin, PathEnd, " + | 220 | "ScaleZ, PCode, PathBegin, PathEnd, " + |
220 | "PathScaleX, PathScaleY, PathShearX, " + | 221 | "PathScaleX, PathScaleY, PathShearX, " + |
221 | "PathShearY, PathSkew, PathCurve, " + | 222 | "PathShearY, PathSkew, PathCurve, " + |
222 | "PathRadiusOffset, PathRevolutions, " + | 223 | "PathRadiusOffset, PathRevolutions, " + |
223 | "PathTaperX, PathTaperY, PathTwist, " + | 224 | "PathTaperX, PathTaperY, PathTwist, " + |
224 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + | 225 | "PathTwistBegin, ProfileBegin, ProfileEnd, " + |
225 | "ProfileCurve, ProfileHollow, Texture, " + | 226 | "ProfileCurve, ProfileHollow, Texture, " + |
226 | "ExtraParams, State, Media) values (?UUID, " + | 227 | "ExtraParams, State, Media) values (?UUID, " + |
227 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + | 228 | "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " + |
228 | "?PCode, ?PathBegin, ?PathEnd, " + | 229 | "?PCode, ?PathBegin, ?PathEnd, " + |
229 | "?PathScaleX, ?PathScaleY, " + | 230 | "?PathScaleX, ?PathScaleY, " + |
230 | "?PathShearX, ?PathShearY, " + | 231 | "?PathShearX, ?PathShearY, " + |
231 | "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + | 232 | "?PathSkew, ?PathCurve, ?PathRadiusOffset, " + |
232 | "?PathRevolutions, ?PathTaperX, " + | 233 | "?PathRevolutions, ?PathTaperX, " + |
233 | "?PathTaperY, ?PathTwist, " + | 234 | "?PathTaperY, ?PathTwist, " + |
234 | "?PathTwistBegin, ?ProfileBegin, " + | 235 | "?PathTwistBegin, ?ProfileBegin, " + |
235 | "?ProfileEnd, ?ProfileCurve, " + | 236 | "?ProfileEnd, ?ProfileCurve, " + |
236 | "?ProfileHollow, ?Texture, ?ExtraParams, " + | 237 | "?ProfileHollow, ?Texture, ?ExtraParams, " + |
237 | "?State, ?Media)"; | 238 | "?State, ?Media)"; |
238 | 239 | ||
239 | FillShapeCommand(cmd, prim); | 240 | FillShapeCommand(cmd, prim); |
240 | 241 | ||
241 | ExecuteNonQuery(cmd); | 242 | ExecuteNonQuery(cmd); |
243 | } | ||
242 | } | 244 | } |
243 | |||
244 | cmd.Dispose(); | ||
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
@@ -1865,41 +1865,40 @@ namespace OpenSim.Data.MySQL | |||
1865 | { | 1865 | { |
1866 | RemoveItems(primID); | 1866 | RemoveItems(primID); |
1867 | 1867 | ||
1868 | if (items.Count == 0) | ||
1869 | return; | ||
1870 | |||
1868 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1871 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1869 | { | 1872 | { |
1870 | dbcon.Open(); | 1873 | dbcon.Open(); |
1871 | 1874 | ||
1872 | MySqlCommand cmd = dbcon.CreateCommand(); | 1875 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1873 | |||
1874 | if (items.Count == 0) | ||
1875 | return; | ||
1876 | |||
1877 | cmd.CommandText = "insert into primitems (" + | ||
1878 | "invType, assetType, name, " + | ||
1879 | "description, creationDate, nextPermissions, " + | ||
1880 | "currentPermissions, basePermissions, " + | ||
1881 | "everyonePermissions, groupPermissions, " + | ||
1882 | "flags, itemID, primID, assetID, " + | ||
1883 | "parentFolderID, creatorID, ownerID, " + | ||
1884 | "groupID, lastOwnerID) values (?invType, " + | ||
1885 | "?assetType, ?name, ?description, " + | ||
1886 | "?creationDate, ?nextPermissions, " + | ||
1887 | "?currentPermissions, ?basePermissions, " + | ||
1888 | "?everyonePermissions, ?groupPermissions, " + | ||
1889 | "?flags, ?itemID, ?primID, ?assetID, " + | ||
1890 | "?parentFolderID, ?creatorID, ?ownerID, " + | ||
1891 | "?groupID, ?lastOwnerID)"; | ||
1892 | |||
1893 | foreach (TaskInventoryItem item in items) | ||
1894 | { | 1876 | { |
1895 | cmd.Parameters.Clear(); | 1877 | cmd.CommandText = "insert into primitems (" + |
1896 | 1878 | "invType, assetType, name, " + | |
1897 | FillItemCommand(cmd, item); | 1879 | "description, creationDate, nextPermissions, " + |
1898 | 1880 | "currentPermissions, basePermissions, " + | |
1899 | ExecuteNonQuery(cmd); | 1881 | "everyonePermissions, groupPermissions, " + |
1882 | "flags, itemID, primID, assetID, " + | ||
1883 | "parentFolderID, creatorID, ownerID, " + | ||
1884 | "groupID, lastOwnerID) values (?invType, " + | ||
1885 | "?assetType, ?name, ?description, " + | ||
1886 | "?creationDate, ?nextPermissions, " + | ||
1887 | "?currentPermissions, ?basePermissions, " + | ||
1888 | "?everyonePermissions, ?groupPermissions, " + | ||
1889 | "?flags, ?itemID, ?primID, ?assetID, " + | ||
1890 | "?parentFolderID, ?creatorID, ?ownerID, " + | ||
1891 | "?groupID, ?lastOwnerID)"; | ||
1892 | |||
1893 | foreach (TaskInventoryItem item in items) | ||
1894 | { | ||
1895 | cmd.Parameters.Clear(); | ||
1896 | |||
1897 | FillItemCommand(cmd, item); | ||
1898 | |||
1899 | ExecuteNonQuery(cmd); | ||
1900 | } | ||
1900 | } | 1901 | } |
1901 | |||
1902 | cmd.Dispose(); | ||
1903 | } | 1902 | } |
1904 | } | 1903 | } |
1905 | } | 1904 | } |
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index a18ac66..4ff3175 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs | |||
@@ -66,38 +66,40 @@ namespace OpenSim.Data.MySQL | |||
66 | if (words.Length > 2) | 66 | if (words.Length > 2) |
67 | return new UserAccountData[0]; | 67 | return new UserAccountData[0]; |
68 | 68 | ||
69 | MySqlCommand cmd = new MySqlCommand(); | 69 | using (MySqlCommand cmd = new MySqlCommand()) |
70 | |||
71 | if (words.Length == 1) | ||
72 | { | ||
73 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm); | ||
74 | cmd.Parameters.AddWithValue("?search", words[0] + "%"); | ||
75 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | ||
76 | } | ||
77 | else | ||
78 | { | 70 | { |
79 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm); | 71 | if (words.Length == 1) |
80 | cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%"); | 72 | { |
81 | cmd.Parameters.AddWithValue("?searchLast", words[1] + "%"); | 73 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm); |
82 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | 74 | cmd.Parameters.AddWithValue("?search", words[0] + "%"); |
83 | } | 75 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); |
76 | } | ||
77 | else | ||
78 | { | ||
79 | cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm); | ||
80 | cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%"); | ||
81 | cmd.Parameters.AddWithValue("?searchLast", words[1] + "%"); | ||
82 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | ||
83 | } | ||
84 | 84 | ||
85 | return DoQuery(cmd); | 85 | return DoQuery(cmd); |
86 | } | ||
86 | } | 87 | } |
87 | 88 | ||
88 | public UserAccountData[] GetUsersWhere(UUID scopeID, string where) | 89 | public UserAccountData[] GetUsersWhere(UUID scopeID, string where) |
89 | { | 90 | { |
90 | MySqlCommand cmd = new MySqlCommand(); | 91 | using (MySqlCommand cmd = new MySqlCommand()) |
91 | |||
92 | if (scopeID != UUID.Zero) | ||
93 | { | 92 | { |
94 | where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")"; | 93 | if (scopeID != UUID.Zero) |
95 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | 94 | { |
96 | } | 95 | where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")"; |
96 | cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); | ||
97 | } | ||
97 | 98 | ||
98 | cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm); | 99 | cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm); |
99 | 100 | ||
100 | return DoQuery(cmd); | 101 | return DoQuery(cmd); |
102 | } | ||
101 | } | 103 | } |
102 | } | 104 | } |
103 | } | 105 | } |
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index c5d6b78..87bdacd 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs | |||
@@ -79,7 +79,11 @@ namespace OpenSim.Framework.Console | |||
79 | public List<CommandDelegate> fn; | 79 | public List<CommandDelegate> fn; |
80 | } | 80 | } |
81 | 81 | ||
82 | public const string GeneralHelpText = "For more information, type 'help <item>' where <item> is one of the following categories:"; | 82 | public const string GeneralHelpText |
83 | = "To enter an argument that contains spaces, surround the argument with double quotes.\nFor example, show object name \"My long object name\"\n"; | ||
84 | |||
85 | public const string ItemHelpText | ||
86 | = "For more information, type 'help <item>' where <item> is one of the following:"; | ||
83 | 87 | ||
84 | /// <value> | 88 | /// <value> |
85 | /// Commands organized by keyword in a tree | 89 | /// Commands organized by keyword in a tree |
@@ -108,7 +112,9 @@ namespace OpenSim.Framework.Console | |||
108 | // General help | 112 | // General help |
109 | if (helpParts.Count == 0) | 113 | if (helpParts.Count == 0) |
110 | { | 114 | { |
115 | help.Add(""); // Will become a newline. | ||
111 | help.Add(GeneralHelpText); | 116 | help.Add(GeneralHelpText); |
117 | help.Add(ItemHelpText); | ||
112 | help.AddRange(CollectModulesHelp(tree)); | 118 | help.AddRange(CollectModulesHelp(tree)); |
113 | } | 119 | } |
114 | else | 120 | else |
@@ -132,7 +138,7 @@ namespace OpenSim.Framework.Console | |||
132 | // Check modules first to see if we just need to display a list of those commands | 138 | // Check modules first to see if we just need to display a list of those commands |
133 | if (TryCollectModuleHelp(originalHelpRequest, help)) | 139 | if (TryCollectModuleHelp(originalHelpRequest, help)) |
134 | { | 140 | { |
135 | help.Insert(0, GeneralHelpText); | 141 | help.Insert(0, ItemHelpText); |
136 | return help; | 142 | return help; |
137 | } | 143 | } |
138 | 144 | ||
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 7c8626d..f65813b 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -296,6 +296,10 @@ namespace OpenSim.Framework.Console | |||
296 | matches[0].Groups["Category"].Value); | 296 | matches[0].Groups["Category"].Value); |
297 | System.Console.Write("]:"); | 297 | System.Console.Write("]:"); |
298 | } | 298 | } |
299 | else | ||
300 | { | ||
301 | outText = outText.Trim(); | ||
302 | } | ||
299 | } | 303 | } |
300 | 304 | ||
301 | if (level == "error") | 305 | if (level == "error") |
diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 142b783..9020761 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs | |||
@@ -346,7 +346,7 @@ namespace OpenSim.Framework | |||
346 | l_EstateManagers.Remove(avatarID); | 346 | l_EstateManagers.Remove(avatarID); |
347 | } | 347 | } |
348 | 348 | ||
349 | public bool IsEstateManager(UUID avatarID) | 349 | public bool IsEstateManagerOrOwner(UUID avatarID) |
350 | { | 350 | { |
351 | if (IsEstateOwner(avatarID)) | 351 | if (IsEstateOwner(avatarID)) |
352 | return true; | 352 | return true; |
@@ -368,7 +368,7 @@ namespace OpenSim.Framework | |||
368 | if (ban.BannedUserID == avatarID) | 368 | if (ban.BannedUserID == avatarID) |
369 | return true; | 369 | return true; |
370 | 370 | ||
371 | if (!IsEstateManager(avatarID) && !HasAccess(avatarID)) | 371 | if (!IsEstateManagerOrOwner(avatarID) && !HasAccess(avatarID)) |
372 | { | 372 | { |
373 | if (DenyMinors) | 373 | if (DenyMinors) |
374 | { | 374 | { |
@@ -411,7 +411,7 @@ namespace OpenSim.Framework | |||
411 | 411 | ||
412 | public bool HasAccess(UUID user) | 412 | public bool HasAccess(UUID user) |
413 | { | 413 | { |
414 | if (IsEstateManager(user)) | 414 | if (IsEstateManagerOrOwner(user)) |
415 | return true; | 415 | return true; |
416 | 416 | ||
417 | return l_EstateAccess.Contains(user); | 417 | return l_EstateAccess.Contains(user); |
diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs index 54fa275..455756d 100644 --- a/OpenSim/Framework/OSChatMessage.cs +++ b/OpenSim/Framework/OSChatMessage.cs | |||
@@ -51,10 +51,12 @@ namespace OpenSim.Framework | |||
51 | protected object m_senderObject; | 51 | protected object m_senderObject; |
52 | protected ChatTypeEnum m_type; | 52 | protected ChatTypeEnum m_type; |
53 | protected UUID m_fromID; | 53 | protected UUID m_fromID; |
54 | protected UUID m_toID; | ||
54 | 55 | ||
55 | public OSChatMessage() | 56 | public OSChatMessage() |
56 | { | 57 | { |
57 | m_position = new Vector3(); | 58 | m_position = new Vector3(); |
59 | m_toID = UUID.Zero; | ||
58 | } | 60 | } |
59 | 61 | ||
60 | /// <summary> | 62 | /// <summary> |
@@ -102,6 +104,15 @@ namespace OpenSim.Framework | |||
102 | set { m_from = value; } | 104 | set { m_from = value; } |
103 | } | 105 | } |
104 | 106 | ||
107 | /// <summary> | ||
108 | /// The name of the sender (needed for scripts) | ||
109 | /// </summary> | ||
110 | public string To | ||
111 | { | ||
112 | get { return m_from; } | ||
113 | set { m_from = value; } | ||
114 | } | ||
115 | |||
105 | #region IEventArgs Members | 116 | #region IEventArgs Members |
106 | 117 | ||
107 | /// TODO: Sender and SenderObject should just be Sender and of | 118 | /// TODO: Sender and SenderObject should just be Sender and of |
@@ -132,6 +143,15 @@ namespace OpenSim.Framework | |||
132 | } | 143 | } |
133 | 144 | ||
134 | /// <summary> | 145 | /// <summary> |
146 | /// The single recipient or all if not set. | ||
147 | /// </summary> | ||
148 | public UUID TargetUUID | ||
149 | { | ||
150 | get { return m_toID; } | ||
151 | set { m_toID = value; } | ||
152 | } | ||
153 | |||
154 | /// <summary> | ||
135 | /// | 155 | /// |
136 | /// </summary> | 156 | /// </summary> |
137 | public IScene Scene | 157 | public IScene Scene |
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index db4541e..537de7a 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs | |||
@@ -38,239 +38,189 @@ namespace OpenSim.Framework | |||
38 | public static class SLUtil | 38 | public static class SLUtil |
39 | { | 39 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | #region SL / file extension / content-type conversions | 42 | #region SL / file extension / content-type conversions |
43 | 43 | ||
44 | public static string SLAssetTypeToContentType(int assetType) | 44 | private class TypeMapping |
45 | { | 45 | { |
46 | switch ((AssetType)assetType) | 46 | private sbyte assetType; |
47 | private InventoryType inventoryType; | ||
48 | private string contentType; | ||
49 | private string contentType2; | ||
50 | private string extension; | ||
51 | |||
52 | public sbyte AssetTypeCode | ||
53 | { | ||
54 | get { return assetType; } | ||
55 | } | ||
56 | |||
57 | public object AssetType | ||
58 | { | ||
59 | get { | ||
60 | if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType)) | ||
61 | return (OpenMetaverse.AssetType)assetType; | ||
62 | else | ||
63 | return OpenMetaverse.AssetType.Unknown; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public InventoryType InventoryType | ||
68 | { | ||
69 | get { return inventoryType; } | ||
70 | } | ||
71 | |||
72 | public string ContentType | ||
73 | { | ||
74 | get { return contentType; } | ||
75 | } | ||
76 | |||
77 | public string ContentType2 | ||
78 | { | ||
79 | get { return contentType2; } | ||
80 | } | ||
81 | |||
82 | public string Extension | ||
83 | { | ||
84 | get { return extension; } | ||
85 | } | ||
86 | |||
87 | private TypeMapping(sbyte assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) | ||
88 | { | ||
89 | this.assetType = assetType; | ||
90 | this.inventoryType = inventoryType; | ||
91 | this.contentType = contentType; | ||
92 | this.contentType2 = contentType2; | ||
93 | this.extension = extension; | ||
94 | } | ||
95 | |||
96 | public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension) | ||
97 | : this((sbyte)assetType, inventoryType, contentType, contentType2, extension) | ||
98 | { | ||
99 | } | ||
100 | |||
101 | public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension) | ||
102 | : this((sbyte)assetType, inventoryType, contentType, null, extension) | ||
47 | { | 103 | { |
48 | case AssetType.Texture: | ||
49 | return "image/x-j2c"; | ||
50 | case AssetType.Sound: | ||
51 | return "audio/ogg"; | ||
52 | case AssetType.CallingCard: | ||
53 | return "application/vnd.ll.callingcard"; | ||
54 | case AssetType.Landmark: | ||
55 | return "application/vnd.ll.landmark"; | ||
56 | case AssetType.Clothing: | ||
57 | return "application/vnd.ll.clothing"; | ||
58 | case AssetType.Object: | ||
59 | return "application/vnd.ll.primitive"; | ||
60 | case AssetType.Notecard: | ||
61 | return "application/vnd.ll.notecard"; | ||
62 | case AssetType.Folder: | ||
63 | return "application/vnd.ll.folder"; | ||
64 | case AssetType.RootFolder: | ||
65 | return "application/vnd.ll.rootfolder"; | ||
66 | case AssetType.LSLText: | ||
67 | return "application/vnd.ll.lsltext"; | ||
68 | case AssetType.LSLBytecode: | ||
69 | return "application/vnd.ll.lslbyte"; | ||
70 | case AssetType.TextureTGA: | ||
71 | case AssetType.ImageTGA: | ||
72 | return "image/tga"; | ||
73 | case AssetType.Bodypart: | ||
74 | return "application/vnd.ll.bodypart"; | ||
75 | case AssetType.TrashFolder: | ||
76 | return "application/vnd.ll.trashfolder"; | ||
77 | case AssetType.SnapshotFolder: | ||
78 | return "application/vnd.ll.snapshotfolder"; | ||
79 | case AssetType.LostAndFoundFolder: | ||
80 | return "application/vnd.ll.lostandfoundfolder"; | ||
81 | case AssetType.SoundWAV: | ||
82 | return "audio/x-wav"; | ||
83 | case AssetType.ImageJPEG: | ||
84 | return "image/jpeg"; | ||
85 | case AssetType.Animation: | ||
86 | return "application/vnd.ll.animation"; | ||
87 | case AssetType.Gesture: | ||
88 | return "application/vnd.ll.gesture"; | ||
89 | case AssetType.Simstate: | ||
90 | return "application/x-metaverse-simstate"; | ||
91 | case AssetType.FavoriteFolder: | ||
92 | return "application/vnd.ll.favoritefolder"; | ||
93 | case AssetType.Link: | ||
94 | return "application/vnd.ll.link"; | ||
95 | case AssetType.LinkFolder: | ||
96 | return "application/vnd.ll.linkfolder"; | ||
97 | case AssetType.CurrentOutfitFolder: | ||
98 | return "application/vnd.ll.currentoutfitfolder"; | ||
99 | case AssetType.OutfitFolder: | ||
100 | return "application/vnd.ll.outfitfolder"; | ||
101 | case AssetType.MyOutfitsFolder: | ||
102 | return "application/vnd.ll.myoutfitsfolder"; | ||
103 | case AssetType.Unknown: | ||
104 | default: | ||
105 | return "application/octet-stream"; | ||
106 | } | 104 | } |
107 | } | 105 | } |
108 | 106 | ||
109 | public static string SLInvTypeToContentType(int invType) | 107 | /// <summary> |
108 | /// Maps between AssetType, InventoryType and Content-Type. | ||
109 | /// Where more than one possibility exists, the first one takes precedence. E.g.: | ||
110 | /// AssetType "AssetType.Texture" -> Content-Type "image-xj2c" | ||
111 | /// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture" | ||
112 | /// </summary> | ||
113 | private static TypeMapping[] MAPPINGS = new TypeMapping[] { | ||
114 | new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"), | ||
115 | new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"), | ||
116 | new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"), | ||
117 | new TypeMapping(AssetType.TextureTGA, InventoryType.Texture, "image/tga", "tga"), | ||
118 | new TypeMapping(AssetType.ImageTGA, InventoryType.Texture, "image/tga", "tga"), | ||
119 | new TypeMapping(AssetType.ImageJPEG, InventoryType.Texture, "image/jpeg", "jpg"), | ||
120 | new TypeMapping(AssetType.Sound, InventoryType.Sound, "audio/ogg", "application/ogg", "ogg"), | ||
121 | new TypeMapping(AssetType.SoundWAV, InventoryType.Sound, "audio/x-wav", "wav"), | ||
122 | new TypeMapping(AssetType.CallingCard, InventoryType.CallingCard, "application/vnd.ll.callingcard", "application/x-metaverse-callingcard", "callingcard"), | ||
123 | new TypeMapping(AssetType.Landmark, InventoryType.Landmark, "application/vnd.ll.landmark", "application/x-metaverse-landmark", "landmark"), | ||
124 | new TypeMapping(AssetType.Clothing, InventoryType.Wearable, "application/vnd.ll.clothing", "application/x-metaverse-clothing", "clothing"), | ||
125 | new TypeMapping(AssetType.Object, InventoryType.Object, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), | ||
126 | new TypeMapping(AssetType.Object, InventoryType.Attachment, "application/vnd.ll.primitive", "application/x-metaverse-primitive", "primitive"), | ||
127 | new TypeMapping(AssetType.Notecard, InventoryType.Notecard, "application/vnd.ll.notecard", "application/x-metaverse-notecard", "notecard"), | ||
128 | new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"), | ||
129 | new TypeMapping(AssetType.RootFolder, InventoryType.RootCategory, "application/vnd.ll.rootfolder", "rootfolder"), | ||
130 | new TypeMapping(AssetType.LSLText, InventoryType.LSL, "application/vnd.ll.lsltext", "application/x-metaverse-lsl", "lsl"), | ||
131 | new TypeMapping(AssetType.LSLBytecode, InventoryType.LSL, "application/vnd.ll.lslbyte", "application/x-metaverse-lso", "lso"), | ||
132 | new TypeMapping(AssetType.Bodypart, InventoryType.Wearable, "application/vnd.ll.bodypart", "application/x-metaverse-bodypart", "bodypart"), | ||
133 | new TypeMapping(AssetType.TrashFolder, InventoryType.Folder, "application/vnd.ll.trashfolder", "trashfolder"), | ||
134 | new TypeMapping(AssetType.SnapshotFolder, InventoryType.Folder, "application/vnd.ll.snapshotfolder", "snapshotfolder"), | ||
135 | new TypeMapping(AssetType.LostAndFoundFolder, InventoryType.Folder, "application/vnd.ll.lostandfoundfolder", "lostandfoundfolder"), | ||
136 | new TypeMapping(AssetType.Animation, InventoryType.Animation, "application/vnd.ll.animation", "application/x-metaverse-animation", "animation"), | ||
137 | new TypeMapping(AssetType.Gesture, InventoryType.Gesture, "application/vnd.ll.gesture", "application/x-metaverse-gesture", "gesture"), | ||
138 | new TypeMapping(AssetType.Simstate, InventoryType.Snapshot, "application/x-metaverse-simstate", "simstate"), | ||
139 | new TypeMapping(AssetType.FavoriteFolder, InventoryType.Unknown, "application/vnd.ll.favoritefolder", "favoritefolder"), | ||
140 | new TypeMapping(AssetType.Link, InventoryType.Unknown, "application/vnd.ll.link", "link"), | ||
141 | new TypeMapping(AssetType.LinkFolder, InventoryType.Unknown, "application/vnd.ll.linkfolder", "linkfolder"), | ||
142 | new TypeMapping(AssetType.CurrentOutfitFolder, InventoryType.Unknown, "application/vnd.ll.currentoutfitfolder", "currentoutfitfolder"), | ||
143 | new TypeMapping(AssetType.OutfitFolder, InventoryType.Unknown, "application/vnd.ll.outfitfolder", "outfitfolder"), | ||
144 | new TypeMapping(AssetType.MyOutfitsFolder, InventoryType.Unknown, "application/vnd.ll.myoutfitsfolder", "myoutfitsfolder"), | ||
145 | new TypeMapping(AssetType.Mesh, InventoryType.Mesh, "application/vnd.ll.mesh", "llm") | ||
146 | }; | ||
147 | |||
148 | private static Dictionary<sbyte, string> asset2Content; | ||
149 | private static Dictionary<sbyte, string> asset2Extension; | ||
150 | private static Dictionary<InventoryType, string> inventory2Content; | ||
151 | private static Dictionary<string, sbyte> content2Asset; | ||
152 | private static Dictionary<string, InventoryType> content2Inventory; | ||
153 | |||
154 | static SLUtil() | ||
110 | { | 155 | { |
111 | switch ((InventoryType)invType) | 156 | asset2Content = new Dictionary<sbyte, string>(); |
157 | asset2Extension = new Dictionary<sbyte, string>(); | ||
158 | inventory2Content = new Dictionary<InventoryType, string>(); | ||
159 | content2Asset = new Dictionary<string, sbyte>(); | ||
160 | content2Inventory = new Dictionary<string, InventoryType>(); | ||
161 | |||
162 | foreach (TypeMapping mapping in MAPPINGS) | ||
112 | { | 163 | { |
113 | case InventoryType.Animation: | 164 | sbyte assetType = mapping.AssetTypeCode; |
114 | return "application/vnd.ll.animation"; | 165 | if (!asset2Content.ContainsKey(assetType)) |
115 | case InventoryType.CallingCard: | 166 | asset2Content.Add(assetType, mapping.ContentType); |
116 | return "application/vnd.ll.callingcard"; | 167 | if (!asset2Extension.ContainsKey(assetType)) |
117 | case InventoryType.Folder: | 168 | asset2Extension.Add(assetType, mapping.Extension); |
118 | return "application/vnd.ll.folder"; | 169 | if (!inventory2Content.ContainsKey(mapping.InventoryType)) |
119 | case InventoryType.Gesture: | 170 | inventory2Content.Add(mapping.InventoryType, mapping.ContentType); |
120 | return "application/vnd.ll.gesture"; | 171 | if (!content2Asset.ContainsKey(mapping.ContentType)) |
121 | case InventoryType.Landmark: | 172 | content2Asset.Add(mapping.ContentType, assetType); |
122 | return "application/vnd.ll.landmark"; | 173 | if (!content2Inventory.ContainsKey(mapping.ContentType)) |
123 | case InventoryType.LSL: | 174 | content2Inventory.Add(mapping.ContentType, mapping.InventoryType); |
124 | return "application/vnd.ll.lsltext"; | 175 | |
125 | case InventoryType.Notecard: | 176 | if (mapping.ContentType2 != null) |
126 | return "application/vnd.ll.notecard"; | 177 | { |
127 | case InventoryType.Attachment: | 178 | if (!content2Asset.ContainsKey(mapping.ContentType2)) |
128 | case InventoryType.Object: | 179 | content2Asset.Add(mapping.ContentType2, assetType); |
129 | return "application/vnd.ll.primitive"; | 180 | if (!content2Inventory.ContainsKey(mapping.ContentType2)) |
130 | case InventoryType.Sound: | 181 | content2Inventory.Add(mapping.ContentType2, mapping.InventoryType); |
131 | return "audio/ogg"; | 182 | } |
132 | case InventoryType.Snapshot: | ||
133 | case InventoryType.Texture: | ||
134 | return "image/x-j2c"; | ||
135 | case InventoryType.Wearable: | ||
136 | return "application/vnd.ll.clothing"; | ||
137 | default: | ||
138 | return "application/octet-stream"; | ||
139 | } | 183 | } |
140 | } | 184 | } |
185 | |||
186 | public static string SLAssetTypeToContentType(int assetType) | ||
187 | { | ||
188 | string contentType; | ||
189 | if (!asset2Content.TryGetValue((sbyte)assetType, out contentType)) | ||
190 | contentType = asset2Content[(sbyte)AssetType.Unknown]; | ||
191 | return contentType; | ||
192 | } | ||
193 | |||
194 | public static string SLInvTypeToContentType(int invType) | ||
195 | { | ||
196 | string contentType; | ||
197 | if (!inventory2Content.TryGetValue((InventoryType)invType, out contentType)) | ||
198 | contentType = inventory2Content[InventoryType.Unknown]; | ||
199 | return contentType; | ||
200 | } | ||
141 | 201 | ||
142 | public static sbyte ContentTypeToSLAssetType(string contentType) | 202 | public static sbyte ContentTypeToSLAssetType(string contentType) |
143 | { | 203 | { |
144 | switch (contentType) | 204 | sbyte assetType; |
145 | { | 205 | if (!content2Asset.TryGetValue(contentType, out assetType)) |
146 | case "image/x-j2c": | 206 | assetType = (sbyte)AssetType.Unknown; |
147 | case "image/jp2": | 207 | return (sbyte)assetType; |
148 | return (sbyte)AssetType.Texture; | ||
149 | case "application/ogg": | ||
150 | case "audio/ogg": | ||
151 | return (sbyte)AssetType.Sound; | ||
152 | case "application/vnd.ll.callingcard": | ||
153 | case "application/x-metaverse-callingcard": | ||
154 | return (sbyte)AssetType.CallingCard; | ||
155 | case "application/vnd.ll.landmark": | ||
156 | case "application/x-metaverse-landmark": | ||
157 | return (sbyte)AssetType.Landmark; | ||
158 | case "application/vnd.ll.clothing": | ||
159 | case "application/x-metaverse-clothing": | ||
160 | return (sbyte)AssetType.Clothing; | ||
161 | case "application/vnd.ll.primitive": | ||
162 | case "application/x-metaverse-primitive": | ||
163 | return (sbyte)AssetType.Object; | ||
164 | case "application/vnd.ll.notecard": | ||
165 | case "application/x-metaverse-notecard": | ||
166 | return (sbyte)AssetType.Notecard; | ||
167 | case "application/vnd.ll.folder": | ||
168 | return (sbyte)AssetType.Folder; | ||
169 | case "application/vnd.ll.rootfolder": | ||
170 | return (sbyte)AssetType.RootFolder; | ||
171 | case "application/vnd.ll.lsltext": | ||
172 | case "application/x-metaverse-lsl": | ||
173 | return (sbyte)AssetType.LSLText; | ||
174 | case "application/vnd.ll.lslbyte": | ||
175 | case "application/x-metaverse-lso": | ||
176 | return (sbyte)AssetType.LSLBytecode; | ||
177 | case "image/tga": | ||
178 | // Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA | ||
179 | return (sbyte)AssetType.ImageTGA; | ||
180 | case "application/vnd.ll.bodypart": | ||
181 | case "application/x-metaverse-bodypart": | ||
182 | return (sbyte)AssetType.Bodypart; | ||
183 | case "application/vnd.ll.trashfolder": | ||
184 | return (sbyte)AssetType.TrashFolder; | ||
185 | case "application/vnd.ll.snapshotfolder": | ||
186 | return (sbyte)AssetType.SnapshotFolder; | ||
187 | case "application/vnd.ll.lostandfoundfolder": | ||
188 | return (sbyte)AssetType.LostAndFoundFolder; | ||
189 | case "audio/x-wav": | ||
190 | return (sbyte)AssetType.SoundWAV; | ||
191 | case "image/jpeg": | ||
192 | return (sbyte)AssetType.ImageJPEG; | ||
193 | case "application/vnd.ll.animation": | ||
194 | case "application/x-metaverse-animation": | ||
195 | return (sbyte)AssetType.Animation; | ||
196 | case "application/vnd.ll.gesture": | ||
197 | case "application/x-metaverse-gesture": | ||
198 | return (sbyte)AssetType.Gesture; | ||
199 | case "application/x-metaverse-simstate": | ||
200 | return (sbyte)AssetType.Simstate; | ||
201 | case "application/vnd.ll.favoritefolder": | ||
202 | return (sbyte)AssetType.FavoriteFolder; | ||
203 | case "application/vnd.ll.link": | ||
204 | return (sbyte)AssetType.Link; | ||
205 | case "application/vnd.ll.linkfolder": | ||
206 | return (sbyte)AssetType.LinkFolder; | ||
207 | case "application/vnd.ll.currentoutfitfolder": | ||
208 | return (sbyte)AssetType.CurrentOutfitFolder; | ||
209 | case "application/vnd.ll.outfitfolder": | ||
210 | return (sbyte)AssetType.OutfitFolder; | ||
211 | case "application/vnd.ll.myoutfitsfolder": | ||
212 | return (sbyte)AssetType.MyOutfitsFolder; | ||
213 | case "application/octet-stream": | ||
214 | default: | ||
215 | return (sbyte)AssetType.Unknown; | ||
216 | } | ||
217 | } | 208 | } |
218 | 209 | ||
219 | public static sbyte ContentTypeToSLInvType(string contentType) | 210 | public static sbyte ContentTypeToSLInvType(string contentType) |
220 | { | 211 | { |
221 | switch (contentType) | 212 | InventoryType invType; |
222 | { | 213 | if (!content2Inventory.TryGetValue(contentType, out invType)) |
223 | case "image/x-j2c": | 214 | invType = InventoryType.Unknown; |
224 | case "image/jp2": | 215 | return (sbyte)invType; |
225 | case "image/tga": | 216 | } |
226 | case "image/jpeg": | 217 | |
227 | return (sbyte)InventoryType.Texture; | 218 | public static string SLAssetTypeToExtension(int assetType) |
228 | case "application/ogg": | 219 | { |
229 | case "audio/ogg": | 220 | string extension; |
230 | case "audio/x-wav": | 221 | if (!asset2Extension.TryGetValue((sbyte)assetType, out extension)) |
231 | return (sbyte)InventoryType.Sound; | 222 | extension = asset2Extension[(sbyte)AssetType.Unknown]; |
232 | case "application/vnd.ll.callingcard": | 223 | return extension; |
233 | case "application/x-metaverse-callingcard": | ||
234 | return (sbyte)InventoryType.CallingCard; | ||
235 | case "application/vnd.ll.landmark": | ||
236 | case "application/x-metaverse-landmark": | ||
237 | return (sbyte)InventoryType.Landmark; | ||
238 | case "application/vnd.ll.clothing": | ||
239 | case "application/x-metaverse-clothing": | ||
240 | case "application/vnd.ll.bodypart": | ||
241 | case "application/x-metaverse-bodypart": | ||
242 | return (sbyte)InventoryType.Wearable; | ||
243 | case "application/vnd.ll.primitive": | ||
244 | case "application/x-metaverse-primitive": | ||
245 | return (sbyte)InventoryType.Object; | ||
246 | case "application/vnd.ll.notecard": | ||
247 | case "application/x-metaverse-notecard": | ||
248 | return (sbyte)InventoryType.Notecard; | ||
249 | case "application/vnd.ll.folder": | ||
250 | return (sbyte)InventoryType.Folder; | ||
251 | case "application/vnd.ll.rootfolder": | ||
252 | return (sbyte)InventoryType.RootCategory; | ||
253 | case "application/vnd.ll.lsltext": | ||
254 | case "application/x-metaverse-lsl": | ||
255 | case "application/vnd.ll.lslbyte": | ||
256 | case "application/x-metaverse-lso": | ||
257 | return (sbyte)InventoryType.LSL; | ||
258 | case "application/vnd.ll.trashfolder": | ||
259 | case "application/vnd.ll.snapshotfolder": | ||
260 | case "application/vnd.ll.lostandfoundfolder": | ||
261 | return (sbyte)InventoryType.Folder; | ||
262 | case "application/vnd.ll.animation": | ||
263 | case "application/x-metaverse-animation": | ||
264 | return (sbyte)InventoryType.Animation; | ||
265 | case "application/vnd.ll.gesture": | ||
266 | case "application/x-metaverse-gesture": | ||
267 | return (sbyte)InventoryType.Gesture; | ||
268 | case "application/x-metaverse-simstate": | ||
269 | return (sbyte)InventoryType.Snapshot; | ||
270 | case "application/octet-stream": | ||
271 | default: | ||
272 | return (sbyte)InventoryType.Unknown; | ||
273 | } | ||
274 | } | 224 | } |
275 | 225 | ||
276 | #endregion SL / file extension / content-type conversions | 226 | #endregion SL / file extension / content-type conversions |
@@ -377,4 +327,4 @@ namespace OpenSim.Framework | |||
377 | return output; | 327 | return output; |
378 | } | 328 | } |
379 | } | 329 | } |
380 | } \ No newline at end of file | 330 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index ad5af1f..63b9396 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -662,11 +662,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
662 | } | 662 | } |
663 | catch (IOException e) | 663 | catch (IOException e) |
664 | { | 664 | { |
665 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); | 665 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}{1}", e.Message, e.StackTrace); |
666 | } | 666 | } |
667 | catch (Exception e) | 667 | catch (Exception e) |
668 | { | 668 | { |
669 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e.StackTrace); | 669 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}{1}", e.Message, e.StackTrace); |
670 | SendHTML500(response); | 670 | SendHTML500(response); |
671 | } | 671 | } |
672 | finally | 672 | finally |
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs index 34a3f15..6fde488 100644 --- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs | |||
@@ -227,10 +227,10 @@ namespace OpenSim.Framework.Tests | |||
227 | es.AddEstateManager(UUID.Zero); | 227 | es.AddEstateManager(UUID.Zero); |
228 | 228 | ||
229 | es.AddEstateManager(bannedUserId); | 229 | es.AddEstateManager(bannedUserId); |
230 | Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't."); | 230 | Assert.IsTrue(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserId should be EstateManager but isn't."); |
231 | 231 | ||
232 | es.RemoveEstateManager(bannedUserId); | 232 | es.RemoveEstateManager(bannedUserId); |
233 | Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be"); | 233 | Assert.IsFalse(es.IsEstateManagerOrOwner(bannedUserId), "bannedUserID is estateManager but shouldn't be"); |
234 | 234 | ||
235 | Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); | 235 | Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); |
236 | 236 | ||
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index 1ca35df..f0d2a3f 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs | |||
@@ -214,16 +214,13 @@ namespace OpenSim.Framework.Tests | |||
214 | 214 | ||
215 | for (int i = 0; i < contenttypes.Length; i++) | 215 | for (int i = 0; i < contenttypes.Length; i++) |
216 | { | 216 | { |
217 | if (SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == 18) | 217 | int expected; |
218 | { | 218 | if (contenttypes[i] == "image/tga") |
219 | Assert.That(contenttypes[i] == "image/tga"); | 219 | expected = 12; // if we know only the content-type "image/tga", then we assume the asset type is TextureTGA; not ImageTGA |
220 | } | ||
221 | else | 220 | else |
222 | { | 221 | expected = assettypes[i]; |
223 | Assert.That(SLUtil.ContentTypeToSLAssetType(contenttypes[i]) == assettypes[i], | 222 | Assert.AreEqual(expected, SLUtil.ContentTypeToSLAssetType(contenttypes[i]), |
224 | "Expecting {0} but got {1}", assettypes[i], | 223 | String.Format("Incorrect AssetType mapped from Content-Type {0}", contenttypes[i])); |
225 | SLUtil.ContentTypeToSLAssetType(contenttypes[i])); | ||
226 | } | ||
227 | } | 224 | } |
228 | 225 | ||
229 | int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; | 226 | int[] inventorytypes = new int[] {-1,0,1,2,3,6,7,8,9,10,15,17,18,20}; |
@@ -237,7 +234,7 @@ namespace OpenSim.Framework.Tests | |||
237 | "application/vnd.ll.primitive", | 234 | "application/vnd.ll.primitive", |
238 | "application/vnd.ll.notecard", | 235 | "application/vnd.ll.notecard", |
239 | "application/vnd.ll.folder", | 236 | "application/vnd.ll.folder", |
240 | "application/octet-stream", | 237 | "application/vnd.ll.rootfolder", |
241 | "application/vnd.ll.lsltext", | 238 | "application/vnd.ll.lsltext", |
242 | "image/x-j2c", | 239 | "image/x-j2c", |
243 | "application/vnd.ll.primitive", | 240 | "application/vnd.ll.primitive", |
@@ -247,7 +244,8 @@ namespace OpenSim.Framework.Tests | |||
247 | 244 | ||
248 | for (int i=0;i<inventorytypes.Length;i++) | 245 | for (int i=0;i<inventorytypes.Length;i++) |
249 | { | 246 | { |
250 | Assert.That(SLUtil.SLInvTypeToContentType(inventorytypes[i]) == invcontenttypes[i], "Expected {0}, Got {1}", invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i])); | 247 | Assert.AreEqual(invcontenttypes[i], SLUtil.SLInvTypeToContentType(inventorytypes[i]), |
248 | String.Format("Incorrect Content-Type mapped from InventoryType {0}", inventorytypes[i])); | ||
251 | } | 249 | } |
252 | 250 | ||
253 | invcontenttypes = new string[] | 251 | invcontenttypes = new string[] |
@@ -280,7 +278,8 @@ namespace OpenSim.Framework.Tests | |||
280 | 278 | ||
281 | for (int i = 0; i < invtypes.Length; i++) | 279 | for (int i = 0; i < invtypes.Length; i++) |
282 | { | 280 | { |
283 | Assert.That(SLUtil.ContentTypeToSLInvType(invcontenttypes[i]) == invtypes[i], "Expected {0}, Got {1}", invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i])); | 281 | Assert.AreEqual(invtypes[i], SLUtil.ContentTypeToSLInvType(invcontenttypes[i]), |
282 | String.Format("Incorrect InventoryType mapped from Content-Type {0}", invcontenttypes[i])); | ||
284 | } | 283 | } |
285 | } | 284 | } |
286 | } | 285 | } |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index aac575c..11967c9 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -86,8 +86,7 @@ namespace OpenSim.Framework | |||
86 | return eplock; | 86 | return eplock; |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | |||
91 | #region JSONRequest | 90 | #region JSONRequest |
92 | 91 | ||
93 | /// <summary> | 92 | /// <summary> |
@@ -217,7 +216,9 @@ namespace OpenSim.Framework | |||
217 | reqnum,url,method,tickdiff,tickdata); | 216 | reqnum,url,method,tickdiff,tickdata); |
218 | } | 217 | } |
219 | 218 | ||
220 | m_log.DebugFormat("[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage); | 219 | m_log.DebugFormat( |
220 | "[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage); | ||
221 | |||
221 | return ErrorResponseMap(errorMessage); | 222 | return ErrorResponseMap(errorMessage); |
222 | } | 223 | } |
223 | 224 | ||
@@ -358,7 +359,8 @@ namespace OpenSim.Framework | |||
358 | reqnum,url,method,tickdiff,tickdata); | 359 | reqnum,url,method,tickdiff,tickdata); |
359 | } | 360 | } |
360 | 361 | ||
361 | m_log.WarnFormat("[WEB UTIL]: <{0}> form request failed: {1}",reqnum,errorMessage); | 362 | m_log.WarnFormat("[WEB UTIL]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage); |
363 | |||
362 | return ErrorResponseMap(errorMessage); | 364 | return ErrorResponseMap(errorMessage); |
363 | } | 365 | } |
364 | 366 | ||
@@ -772,12 +774,16 @@ namespace OpenSim.Framework | |||
772 | } | 774 | } |
773 | else | 775 | else |
774 | { | 776 | { |
775 | m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", verb, requestUrl, e.Status, e.Message); | 777 | m_log.ErrorFormat( |
778 | "[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", | ||
779 | verb, requestUrl, e.Status, e.Message); | ||
776 | } | 780 | } |
777 | } | 781 | } |
778 | catch (Exception e) | 782 | catch (Exception e) |
779 | { | 783 | { |
780 | m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e); | 784 | m_log.ErrorFormat( |
785 | "[ASYNC REQUEST]: Request {0} {1} failed with exception {2}{3}", | ||
786 | verb, requestUrl, e.Message, e.StackTrace); | ||
781 | } | 787 | } |
782 | 788 | ||
783 | // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); | 789 | // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); |
@@ -789,7 +795,8 @@ namespace OpenSim.Framework | |||
789 | catch (Exception e) | 795 | catch (Exception e) |
790 | { | 796 | { |
791 | m_log.ErrorFormat( | 797 | m_log.ErrorFormat( |
792 | "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}", verb, requestUrl, e); | 798 | "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}{3}", |
799 | verb, requestUrl, e.Message, e.StackTrace); | ||
793 | } | 800 | } |
794 | 801 | ||
795 | }, null); | 802 | }, null); |
@@ -842,7 +849,8 @@ namespace OpenSim.Framework | |||
842 | } | 849 | } |
843 | catch (Exception e) | 850 | catch (Exception e) |
844 | { | 851 | { |
845 | m_log.DebugFormat("[FORMS]: exception occured on sending request to {0}: " + e.ToString(), requestUrl); | 852 | m_log.DebugFormat( |
853 | "[FORMS]: exception occured {0} {1}: {2}{3}", verb, requestUrl, e.Message, e.StackTrace); | ||
846 | } | 854 | } |
847 | finally | 855 | finally |
848 | { | 856 | { |
@@ -868,7 +876,9 @@ namespace OpenSim.Framework | |||
868 | } | 876 | } |
869 | catch (Exception e) | 877 | catch (Exception e) |
870 | { | 878 | { |
871 | m_log.DebugFormat("[FORMS]: exception occured on receiving reply " + e.ToString()); | 879 | m_log.DebugFormat( |
880 | "[FORMS]: Exception occured on receiving {0} {1}: {2}{3}", | ||
881 | verb, requestUrl, e.Message, e.StackTrace); | ||
872 | } | 882 | } |
873 | finally | 883 | finally |
874 | { | 884 | { |
@@ -881,7 +891,7 @@ namespace OpenSim.Framework | |||
881 | catch (System.InvalidOperationException) | 891 | catch (System.InvalidOperationException) |
882 | { | 892 | { |
883 | // This is what happens when there is invalid XML | 893 | // This is what happens when there is invalid XML |
884 | m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving request"); | 894 | m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving {0} {1}", verb, requestUrl); |
885 | } | 895 | } |
886 | } | 896 | } |
887 | return respstring; | 897 | return respstring; |
@@ -946,7 +956,10 @@ namespace OpenSim.Framework | |||
946 | } | 956 | } |
947 | catch (Exception e) | 957 | catch (Exception e) |
948 | { | 958 | { |
949 | m_log.DebugFormat("[SynchronousRestObjectRequester]: exception in sending data to {0}: {1}", requestUrl, e); | 959 | m_log.DebugFormat( |
960 | "[SynchronousRestObjectRequester]: Exception in making request {0} {1}: {2}{3}", | ||
961 | verb, requestUrl, e.Message, e.StackTrace); | ||
962 | |||
950 | return deserial; | 963 | return deserial; |
951 | } | 964 | } |
952 | finally | 965 | finally |
@@ -968,7 +981,11 @@ namespace OpenSim.Framework | |||
968 | respStream.Close(); | 981 | respStream.Close(); |
969 | } | 982 | } |
970 | else | 983 | else |
971 | m_log.DebugFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb); | 984 | { |
985 | m_log.DebugFormat( | ||
986 | "[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", | ||
987 | verb, requestUrl); | ||
988 | } | ||
972 | } | 989 | } |
973 | } | 990 | } |
974 | catch (WebException e) | 991 | catch (WebException e) |
@@ -979,20 +996,24 @@ namespace OpenSim.Framework | |||
979 | return deserial; | 996 | return deserial; |
980 | else | 997 | else |
981 | m_log.ErrorFormat( | 998 | m_log.ErrorFormat( |
982 | "[SynchronousRestObjectRequester]: WebException {0} {1} {2} {3}", | 999 | "[SynchronousRestObjectRequester]: WebException for {0} {1} {2}: {3} {4}", |
983 | requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); | 1000 | verb, requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); |
984 | } | 1001 | } |
985 | catch (System.InvalidOperationException) | 1002 | catch (System.InvalidOperationException) |
986 | { | 1003 | { |
987 | // This is what happens when there is invalid XML | 1004 | // This is what happens when there is invalid XML |
988 | m_log.DebugFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString()); | 1005 | m_log.DebugFormat( |
1006 | "[SynchronousRestObjectRequester]: Invalid XML from {0} {1} {2}", | ||
1007 | verb, requestUrl, typeof(TResponse).ToString()); | ||
989 | } | 1008 | } |
990 | catch (Exception e) | 1009 | catch (Exception e) |
991 | { | 1010 | { |
992 | m_log.DebugFormat("[SynchronousRestObjectRequester]: Exception on response from {0} {1}", requestUrl, e); | 1011 | m_log.DebugFormat( |
1012 | "[SynchronousRestObjectRequester]: Exception on response from {0} {1}: {2}{3}", | ||
1013 | verb, requestUrl, e.Message, e.StackTrace); | ||
993 | } | 1014 | } |
994 | 1015 | ||
995 | return deserial; | 1016 | return deserial; |
996 | } | 1017 | } |
997 | } | 1018 | } |
998 | } | 1019 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index fb1e831..e4bd857 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -225,7 +225,7 @@ namespace OpenSim | |||
225 | /// </summary> | 225 | /// </summary> |
226 | private void RegisterConsoleCommands() | 226 | private void RegisterConsoleCommands() |
227 | { | 227 | { |
228 | m_console.Commands.AddCommand("Regions", false, "force update", | 228 | m_console.Commands.AddCommand("Objects", false, "force update", |
229 | "force update", | 229 | "force update", |
230 | "Force the update of all objects on clients", | 230 | "Force the update of all objects on clients", |
231 | HandleForceUpdate); | 231 | HandleForceUpdate); |
@@ -306,7 +306,7 @@ namespace OpenSim | |||
306 | + " If this is not given then the oar is saved to region.oar in the current directory.", | 306 | + " If this is not given then the oar is saved to region.oar in the current directory.", |
307 | SaveOar); | 307 | SaveOar); |
308 | 308 | ||
309 | m_console.Commands.AddCommand("Regions", false, "edit scale", | 309 | m_console.Commands.AddCommand("Objects", false, "edit scale", |
310 | "edit scale <name> <x> <y> <z>", | 310 | "edit scale <name> <x> <y> <z>", |
311 | "Change the scale of a named prim", HandleEditScale); | 311 | "Change the scale of a named prim", HandleEditScale); |
312 | 312 | ||
@@ -349,7 +349,7 @@ namespace OpenSim | |||
349 | "show ratings", | 349 | "show ratings", |
350 | "Show rating data", HandleShow); | 350 | "Show rating data", HandleShow); |
351 | 351 | ||
352 | m_console.Commands.AddCommand("Regions", false, "backup", | 352 | m_console.Commands.AddCommand("Objects", false, "backup", |
353 | "backup", | 353 | "backup", |
354 | "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", RunCommand); | 354 | "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", RunCommand); |
355 | 355 | ||
@@ -410,7 +410,7 @@ namespace OpenSim | |||
410 | "modules unload <name>", | 410 | "modules unload <name>", |
411 | "Unload a module", HandleModules); | 411 | "Unload a module", HandleModules); |
412 | 412 | ||
413 | m_console.Commands.AddCommand("Regions", false, "kill uuid", | 413 | m_console.Commands.AddCommand("Objects", false, "kill uuid", |
414 | "kill uuid <UUID>", | 414 | "kill uuid <UUID>", |
415 | "Kill an object by UUID", KillUUID); | 415 | "Kill an object by UUID", KillUUID); |
416 | } | 416 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ef6dedb..2c2d80a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -245,7 +245,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
245 | 245 | ||
246 | if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint)) | 246 | if (!m_Scene.CheckClient(m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint)) |
247 | { | 247 | { |
248 | m_log.DebugFormat("[CAPS]: Unauthorized CAPS client"); | 248 | m_log.DebugFormat( |
249 | "[CAPS]: Unauthorized CAPS client {0} from {1}", | ||
250 | m_HostCapsObj.AgentID, httpRequest.RemoteIPEndPoint); | ||
251 | |||
249 | return string.Empty; | 252 | return string.Empty; |
250 | } | 253 | } |
251 | 254 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index a5209b7..c25b58c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
60 | CapabilitiesModule capsModule = new CapabilitiesModule(); | 60 | CapabilitiesModule capsModule = new CapabilitiesModule(); |
61 | EventQueueGetModule eqgModule = new EventQueueGetModule(); | 61 | EventQueueGetModule eqgModule = new EventQueueGetModule(); |
62 | 62 | ||
63 | m_scene = SceneHelpers.SetupScene(); | 63 | m_scene = new SceneHelpers().SetupScene(); |
64 | SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); | 64 | SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); |
65 | } | 65 | } |
66 | 66 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 75f783b..dda4444 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -916,7 +916,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
916 | UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; | 916 | UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; |
917 | UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1]; | 917 | UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1]; |
918 | 918 | ||
919 | m_log.DebugFormat("[LLUDPSERVER]: Handling UseCircuitCode request from {0}", buffer.RemoteEndPoint); | 919 | m_log.DebugFormat( |
920 | "[LLUDPSERVER]: Handling UseCircuitCode request for circuit {0} from {1}", | ||
921 | uccp.CircuitCode.Code, buffer.RemoteEndPoint); | ||
920 | 922 | ||
921 | remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; | 923 | remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; |
922 | 924 | ||
@@ -1352,7 +1354,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1352 | } | 1354 | } |
1353 | else | 1355 | else |
1354 | { | 1356 | { |
1355 | m_log.DebugFormat("[LLUDPSERVER]: Dropping incoming {0} packet for dead client {1}", packet.Type, udpClient.AgentID); | 1357 | m_log.DebugFormat( |
1358 | "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", | ||
1359 | packet.Type, udpClient.AgentID, m_scene.RegionInfo.RegionName); | ||
1356 | } | 1360 | } |
1357 | } | 1361 | } |
1358 | 1362 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs index a575e36..1321470 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | |||
@@ -158,7 +158,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
158 | TestHelpers.InMethod(); | 158 | TestHelpers.InMethod(); |
159 | // XmlConfigurator.Configure(); | 159 | // XmlConfigurator.Configure(); |
160 | 160 | ||
161 | TestScene scene = SceneHelpers.SetupScene(); | 161 | TestScene scene = new SceneHelpers().SetupScene(); |
162 | uint myCircuitCode = 123456; | 162 | uint myCircuitCode = 123456; |
163 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); | 163 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); |
164 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); | 164 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index 1b68d68..221f02b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | |||
@@ -79,7 +79,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
79 | 79 | ||
80 | J2KDecoderModule j2kdm = new J2KDecoderModule(); | 80 | J2KDecoderModule j2kdm = new J2KDecoderModule(); |
81 | 81 | ||
82 | scene = SceneHelpers.SetupScene(); | 82 | scene = new SceneHelpers().SetupScene(); |
83 | SceneHelpers.SetupSceneModules(scene, j2kdm); | 83 | SceneHelpers.SetupSceneModules(scene, j2kdm); |
84 | 84 | ||
85 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); | 85 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); |
diff --git a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs index 5adb845..c91b25f 100644 --- a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs +++ b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.Asset.Tests | |||
65 | config.Configs["AssetCache"].Set("MemoryCacheEnabled", "true"); | 65 | config.Configs["AssetCache"].Set("MemoryCacheEnabled", "true"); |
66 | 66 | ||
67 | m_cache = new FlotsamAssetCache(); | 67 | m_cache = new FlotsamAssetCache(); |
68 | m_scene = SceneHelpers.SetupScene(); | 68 | m_scene = new SceneHelpers().SetupScene(); |
69 | SceneHelpers.SetupSceneModules(m_scene, config, m_cache); | 69 | SceneHelpers.SetupSceneModules(m_scene, config, m_cache); |
70 | } | 70 | } |
71 | 71 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 78ae5e9..69aa0ed 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -189,7 +189,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
189 | } | 189 | } |
190 | catch (Exception e) | 190 | catch (Exception e) |
191 | { | 191 | { |
192 | m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment: {0}{1}", e.Message, e.StackTrace); | 192 | UUID agentId = (sp.ControllingClient == null) ? (UUID)null : sp.ControllingClient.AgentId; |
193 | m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment with itemID {0}, assetID {1}, point {2} for {3}: {4}\n{5}", | ||
194 | attach.ItemID, attach.AssetID, p, agentId, e.Message, e.StackTrace); | ||
193 | } | 195 | } |
194 | } | 196 | } |
195 | } | 197 | } |
@@ -440,7 +442,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
440 | lock (sp.AttachmentsSyncLock) | 442 | lock (sp.AttachmentsSyncLock) |
441 | { | 443 | { |
442 | // Save avatar attachment information | 444 | // Save avatar attachment information |
443 | m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID); | 445 | // m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID); |
444 | 446 | ||
445 | bool changed = sp.Appearance.DetachAttachment(itemID); | 447 | bool changed = sp.Appearance.DetachAttachment(itemID); |
446 | if (changed && m_scene.AvatarFactory != null) | 448 | if (changed && m_scene.AvatarFactory != null) |
@@ -520,9 +522,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
520 | 522 | ||
521 | if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts())) | 523 | if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts())) |
522 | { | 524 | { |
523 | m_log.DebugFormat( | 525 | // m_log.DebugFormat( |
524 | "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", | 526 | // "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", |
525 | grp.UUID, grp.AttachmentPoint); | 527 | // grp.UUID, grp.AttachmentPoint); |
526 | 528 | ||
527 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | 529 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); |
528 | 530 | ||
@@ -553,12 +555,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
553 | } | 555 | } |
554 | grp.HasGroupChanged = false; // Prevent it being saved over and over | 556 | grp.HasGroupChanged = false; // Prevent it being saved over and over |
555 | } | 557 | } |
556 | else | 558 | // else |
557 | { | 559 | // { |
558 | m_log.DebugFormat( | 560 | // m_log.DebugFormat( |
559 | "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", | 561 | // "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", |
560 | grp.UUID, grp.AttachmentPoint); | 562 | // grp.UUID, grp.AttachmentPoint); |
561 | } | 563 | // } |
562 | } | 564 | } |
563 | 565 | ||
564 | /// <summary> | 566 | /// <summary> |
@@ -946,13 +948,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
946 | // Calls attach with a Zero position | 948 | // Calls attach with a Zero position |
947 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) | 949 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) |
948 | { | 950 | { |
949 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); | 951 | // m_log.Debug( |
952 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
953 | // + ", AttachmentPoint: " + AttachmentPt); | ||
950 | 954 | ||
951 | // Save avatar attachment information | 955 | // Save avatar attachment information |
952 | m_log.Debug( | 956 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); |
953 | "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
954 | + ", AttachmentPoint: " + AttachmentPt); | ||
955 | |||
956 | } | 957 | } |
957 | } | 958 | } |
958 | catch (Exception e) | 959 | catch (Exception e) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index bfe5e4a..42d07fd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
72 | config.AddConfig("Modules"); | 72 | config.AddConfig("Modules"); |
73 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | 73 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); |
74 | 74 | ||
75 | scene = SceneHelpers.SetupScene(); | 75 | scene = new SceneHelpers().SetupScene(); |
76 | m_attMod = new AttachmentsModule(); | 76 | m_attMod = new AttachmentsModule(); |
77 | SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); | 77 | SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); |
78 | } | 78 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 2bebd30..d98ea39 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
158 | // Process the baked texture array | 158 | // Process the baked texture array |
159 | if (textureEntry != null) | 159 | if (textureEntry != null) |
160 | { | 160 | { |
161 | m_log.InfoFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); | 161 | // m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); |
162 | 162 | ||
163 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | 163 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); |
164 | 164 | ||
@@ -208,7 +208,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
208 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 208 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
209 | if (sp == null) | 209 | if (sp == null) |
210 | { | 210 | { |
211 | m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); | 211 | // This is expected if the user has gone away. |
212 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); | ||
212 | return false; | 213 | return false; |
213 | } | 214 | } |
214 | 215 | ||
@@ -248,10 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
248 | 249 | ||
249 | if (bakedTextureFace == null) | 250 | if (bakedTextureFace == null) |
250 | { | 251 | { |
251 | m_log.WarnFormat( | 252 | // This can happen legitimately, since some baked textures might not exist |
252 | "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", | 253 | //m_log.WarnFormat( |
253 | bakeType, sp.Name, m_scene.RegionInfo.RegionName); | 254 | // "[AV FACTORY]: No texture ID set for {0} for {1} in {2} not found when trying to save permanently", |
254 | 255 | // bakeType, sp.Name, m_scene.RegionInfo.RegionName); | |
255 | continue; | 256 | continue; |
256 | } | 257 | } |
257 | 258 | ||
@@ -337,7 +338,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
337 | return false; | 338 | return false; |
338 | } | 339 | } |
339 | 340 | ||
340 | m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); | 341 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); |
341 | 342 | ||
342 | // If we only found default textures, then the appearance is not cached | 343 | // If we only found default textures, then the appearance is not cached |
343 | return (defonly ? false : true); | 344 | return (defonly ? false : true); |
@@ -417,7 +418,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
417 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | 418 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); |
418 | 419 | ||
419 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); | 420 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); |
420 | bakedTextures[bakeType] = faceTextures[ftIndex]; | 421 | Primitive.TextureEntryFace texture = faceTextures[ftIndex]; // this will be null if there's no such baked texture |
422 | bakedTextures[bakeType] = texture; | ||
421 | } | 423 | } |
422 | 424 | ||
423 | return bakedTextures; | 425 | return bakedTextures; |
@@ -482,7 +484,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
482 | ScenePresence sp = m_scene.GetScenePresence(agentid); | 484 | ScenePresence sp = m_scene.GetScenePresence(agentid); |
483 | if (sp == null) | 485 | if (sp == null) |
484 | { | 486 | { |
485 | m_log.WarnFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); | 487 | // This is expected if the user has gone away. |
488 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); | ||
486 | return; | 489 | return; |
487 | } | 490 | } |
488 | 491 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 11a0a86..848b3bf 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
53 | UUID userId = TestHelpers.ParseTail(0x1); | 53 | UUID userId = TestHelpers.ParseTail(0x1); |
54 | 54 | ||
55 | AvatarFactoryModule afm = new AvatarFactoryModule(); | 55 | AvatarFactoryModule afm = new AvatarFactoryModule(); |
56 | TestScene scene = SceneHelpers.SetupScene(); | 56 | TestScene scene = new SceneHelpers().SetupScene(); |
57 | SceneHelpers.SetupSceneModules(scene, afm); | 57 | SceneHelpers.SetupSceneModules(scene, afm); |
58 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); | 58 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); |
59 | 59 | ||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
81 | CoreAssetCache assetCache = new CoreAssetCache(); | 81 | CoreAssetCache assetCache = new CoreAssetCache(); |
82 | 82 | ||
83 | AvatarFactoryModule afm = new AvatarFactoryModule(); | 83 | AvatarFactoryModule afm = new AvatarFactoryModule(); |
84 | TestScene scene = SceneHelpers.SetupScene(assetCache); | 84 | TestScene scene = new SceneHelpers(assetCache).SetupScene(); |
85 | SceneHelpers.SetupSceneModules(scene, afm); | 85 | SceneHelpers.SetupSceneModules(scene, afm); |
86 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); | 86 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); |
87 | 87 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 4d8fb90..6ffc7e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -197,6 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
197 | string fromName = c.From; | 197 | string fromName = c.From; |
198 | string fromNamePrefix = ""; | 198 | string fromNamePrefix = ""; |
199 | UUID fromID = UUID.Zero; | 199 | UUID fromID = UUID.Zero; |
200 | UUID targetID = c.TargetUUID; | ||
200 | string message = c.Message; | 201 | string message = c.Message; |
201 | IScene scene = c.Scene; | 202 | IScene scene = c.Scene; |
202 | Vector3 fromPos = c.Position; | 203 | Vector3 fromPos = c.Position; |
@@ -235,17 +236,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
235 | message = message.Substring(0, 1000); | 236 | message = message.Substring(0, 1000); |
236 | 237 | ||
237 | // m_log.DebugFormat( | 238 | // m_log.DebugFormat( |
238 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", | 239 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", |
239 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); | 240 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); |
240 | 241 | ||
241 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 242 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
242 | 243 | ||
243 | foreach (Scene s in m_scenes) | 244 | foreach (Scene s in m_scenes) |
244 | { | 245 | { |
245 | // This should use ForEachClient, but clients don't have a position. | 246 | if (targetID == UUID.Zero) |
246 | // If camera is moved into client, then camera position can be used | 247 | { |
247 | s.ForEachRootScenePresence( | 248 | // This should use ForEachClient, but clients don't have a position. |
248 | delegate(ScenePresence presence) | 249 | // If camera is moved into client, then camera position can be used |
250 | s.ForEachRootScenePresence( | ||
251 | delegate(ScenePresence presence) | ||
252 | { | ||
253 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false)) | ||
254 | receiverIDs.Add(presence.UUID); | ||
255 | } | ||
256 | ); | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | // This is a send to a specific client eg from llRegionSayTo | ||
261 | // no need to check distance etc, jand send is as say | ||
262 | ScenePresence presence = s.GetScenePresence(targetID); | ||
263 | if (presence != null && !presence.IsChildAgent) | ||
249 | { | 264 | { |
250 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | 265 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
251 | if (Presencecheck != null) | 266 | if (Presencecheck != null) |
@@ -256,15 +271,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
256 | // objects on a parcel with access restrictions | 271 | // objects on a parcel with access restrictions |
257 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | 272 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) |
258 | { | 273 | { |
259 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType)) | 274 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType, false)) |
260 | receiverIDs.Add(presence.UUID); | 275 | receiverIDs.Add(presence.UUID); |
261 | } | 276 | } |
262 | } | 277 | } |
263 | |||
264 | } | 278 | } |
265 | ); | 279 | } |
266 | } | 280 | } |
267 | 281 | ||
268 | (scene as Scene).EventManager.TriggerOnChatToClients( | 282 | (scene as Scene).EventManager.TriggerOnChatToClients( |
269 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 283 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
270 | } | 284 | } |
@@ -344,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
344 | /// precondition</returns> | 358 | /// precondition</returns> |
345 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | 359 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, |
346 | UUID fromAgentID, string fromName, ChatTypeEnum type, | 360 | UUID fromAgentID, string fromName, ChatTypeEnum type, |
347 | string message, ChatSourceType src) | 361 | string message, ChatSourceType src, bool ignoreDistance) |
348 | { | 362 | { |
349 | // don't send stuff to child agents | 363 | // don't send stuff to child agents |
350 | if (presence.IsChildAgent) return false; | 364 | if (presence.IsChildAgent) return false; |
@@ -355,12 +369,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
355 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 369 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
356 | 370 | ||
357 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); | 371 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); |
358 | 372 | ||
359 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || | 373 | if (!ignoreDistance) |
360 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
361 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
362 | { | 374 | { |
363 | return false; | 375 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || |
376 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
377 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
378 | { | ||
379 | return false; | ||
380 | } | ||
364 | } | 381 | } |
365 | 382 | ||
366 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 383 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f64c161..fc6325d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -162,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | protected void InitModule(IConfigSource config) | 165 | protected virtual void InitModule(IConfigSource config) |
166 | { | 166 | { |
167 | IConfig friendsConfig = config.Configs["Friends"]; | 167 | IConfig friendsConfig = config.Configs["Friends"]; |
168 | if (friendsConfig != null) | 168 | if (friendsConfig != null) |
@@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
546 | } | 546 | } |
547 | } | 547 | } |
548 | 548 | ||
549 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 549 | protected virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
550 | { | 550 | { |
551 | if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) | 551 | if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) |
552 | { | 552 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 9a6d277..3728b85 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs | |||
@@ -50,6 +50,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
50 | { | 50 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private int m_levelHGFriends = 0; | ||
54 | |||
53 | IUserManagement m_uMan; | 55 | IUserManagement m_uMan; |
54 | public IUserManagement UserManagementModule | 56 | public IUserManagement UserManagementModule |
55 | { | 57 | { |
@@ -87,6 +89,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
87 | m_StatusNotifier = new HGStatusNotifier(this); | 89 | m_StatusNotifier = new HGStatusNotifier(this); |
88 | } | 90 | } |
89 | 91 | ||
92 | protected override void InitModule(IConfigSource config) | ||
93 | { | ||
94 | base.InitModule(config); | ||
95 | |||
96 | // Additionally to the base method | ||
97 | IConfig friendsConfig = config.Configs["HGFriendsModule"]; | ||
98 | if (friendsConfig != null) | ||
99 | { | ||
100 | m_levelHGFriends = friendsConfig.GetInt("LevelHGFriends", 0); | ||
101 | |||
102 | // TODO: read in all config variables pertaining to | ||
103 | // HG friendship permissions | ||
104 | } | ||
105 | } | ||
106 | |||
90 | #endregion | 107 | #endregion |
91 | 108 | ||
92 | #region IFriendsSimConnector | 109 | #region IFriendsSimConnector |
@@ -105,6 +122,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
105 | 122 | ||
106 | #endregion | 123 | #endregion |
107 | 124 | ||
125 | protected override void OnInstantMessage(IClientAPI client, GridInstantMessage im) | ||
126 | { | ||
127 | if ((InstantMessageDialog)im.dialog == InstantMessageDialog.FriendshipOffered) | ||
128 | { | ||
129 | // we got a friendship offer | ||
130 | UUID principalID = new UUID(im.fromAgentID); | ||
131 | UUID friendID = new UUID(im.toAgentID); | ||
132 | |||
133 | // Check if friendID is foreigner and if principalID has the permission | ||
134 | // to request friendships with foreigners. If not, return immediately. | ||
135 | if (!UserManagementModule.IsLocalGridUser(friendID)) | ||
136 | { | ||
137 | ScenePresence avatar = null; | ||
138 | ((Scene)client.Scene).TryGetScenePresence(principalID, out avatar); | ||
139 | |||
140 | if (avatar == null) | ||
141 | return; | ||
142 | |||
143 | if (avatar.UserLevel < m_levelHGFriends) | ||
144 | { | ||
145 | client.SendAgentAlertMessage("Unable to send friendship invitation to foreigner. Insufficient permissions.", false); | ||
146 | return; | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | |||
151 | base.OnInstantMessage(client, im); | ||
152 | } | ||
153 | |||
108 | protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders) | 154 | protected override void OnApproveFriendRequest(IClientAPI client, UUID friendID, List<UUID> callingCardFolders) |
109 | { | 155 | { |
110 | // Update the local cache. Yes, we need to do it right here | 156 | // Update the local cache. Yes, we need to do it right here |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs index 45b4264..7a197f7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs | |||
@@ -78,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests | |||
78 | config.AddConfig("FriendsService"); | 78 | config.AddConfig("FriendsService"); |
79 | config.Configs["FriendsService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 79 | config.Configs["FriendsService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
80 | 80 | ||
81 | m_scene = SceneHelpers.SetupScene(); | 81 | m_scene = new SceneHelpers().SetupScene(); |
82 | m_fm = new FriendsModule(); | 82 | m_fm = new FriendsModule(); |
83 | SceneHelpers.SetupSceneModules(m_scene, config, m_fm); | 83 | SceneHelpers.SetupSceneModules(m_scene, config, m_fm); |
84 | } | 84 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 8560c73..6587ead 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -39,6 +39,9 @@ using OpenSim.Framework.Serialization.External; | |||
39 | using OpenSim.Region.CoreModules.World.Archiver; | 39 | using OpenSim.Region.CoreModules.World.Archiver; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
42 | using Ionic.Zlib; | ||
43 | using GZipStream = Ionic.Zlib.GZipStream; | ||
44 | using CompressionMode = Ionic.Zlib.CompressionMode; | ||
42 | 45 | ||
43 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 46 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
44 | { | 47 | { |
@@ -91,7 +94,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
91 | /// Constructor | 94 | /// Constructor |
92 | /// </summary> | 95 | /// </summary> |
93 | public InventoryArchiveWriteRequest( | 96 | public InventoryArchiveWriteRequest( |
94 | Guid id, InventoryArchiverModule module, Scene scene, | 97 | Guid id, InventoryArchiverModule module, Scene scene, |
95 | UserAccount userInfo, string invPath, string savePath) | 98 | UserAccount userInfo, string invPath, string savePath) |
96 | : this( | 99 | : this( |
97 | id, | 100 | id, |
@@ -99,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
99 | scene, | 102 | scene, |
100 | userInfo, | 103 | userInfo, |
101 | invPath, | 104 | invPath, |
102 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) | 105 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress, CompressionLevel.BestCompression)) |
103 | { | 106 | { |
104 | } | 107 | } |
105 | 108 | ||
@@ -107,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
107 | /// Constructor | 110 | /// Constructor |
108 | /// </summary> | 111 | /// </summary> |
109 | public InventoryArchiveWriteRequest( | 112 | public InventoryArchiveWriteRequest( |
110 | Guid id, InventoryArchiverModule module, Scene scene, | 113 | Guid id, InventoryArchiverModule module, Scene scene, |
111 | UserAccount userInfo, string invPath, Stream saveStream) | 114 | UserAccount userInfo, string invPath, Stream saveStream) |
112 | { | 115 | { |
113 | m_id = id; | 116 | m_id = id; |
@@ -125,7 +128,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
125 | { | 128 | { |
126 | Exception reportedException = null; | 129 | Exception reportedException = null; |
127 | bool succeeded = true; | 130 | bool succeeded = true; |
128 | 131 | ||
129 | try | 132 | try |
130 | { | 133 | { |
131 | m_archiveWriter.Close(); | 134 | m_archiveWriter.Close(); |
@@ -146,6 +149,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
146 | 149 | ||
147 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService) | 150 | protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService) |
148 | { | 151 | { |
152 | if (options.ContainsKey("exclude")) | ||
153 | { | ||
154 | if (((List<String>)options["exclude"]).Contains(inventoryItem.Name) || | ||
155 | ((List<String>)options["exclude"]).Contains(inventoryItem.ID.ToString())) | ||
156 | { | ||
157 | if (options.ContainsKey("verbose")) | ||
158 | { | ||
159 | m_log.InfoFormat( | ||
160 | "[INVENTORY ARCHIVER]: Skipping inventory item {0} {1} at {2}", | ||
161 | inventoryItem.Name, inventoryItem.ID, path); | ||
162 | } | ||
163 | return; | ||
164 | } | ||
165 | } | ||
166 | |||
149 | if (options.ContainsKey("verbose")) | 167 | if (options.ContainsKey("verbose")) |
150 | m_log.InfoFormat( | 168 | m_log.InfoFormat( |
151 | "[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}", | 169 | "[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}", |
@@ -175,9 +193,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
175 | /// <param name="options"></param> | 193 | /// <param name="options"></param> |
176 | /// <param name="userAccountService"></param> | 194 | /// <param name="userAccountService"></param> |
177 | protected void SaveInvFolder( | 195 | protected void SaveInvFolder( |
178 | InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, | 196 | InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, |
179 | Dictionary<string, object> options, IUserAccountService userAccountService) | 197 | Dictionary<string, object> options, IUserAccountService userAccountService) |
180 | { | 198 | { |
199 | if (options.ContainsKey("excludefolders")) | ||
200 | { | ||
201 | if (((List<String>)options["excludefolders"]).Contains(inventoryFolder.Name) || | ||
202 | ((List<String>)options["excludefolders"]).Contains(inventoryFolder.ID.ToString())) | ||
203 | { | ||
204 | if (options.ContainsKey("verbose")) | ||
205 | { | ||
206 | m_log.InfoFormat( | ||
207 | "[INVENTORY ARCHIVER]: Skipping folder {0} at {1}", | ||
208 | inventoryFolder.Name, path); | ||
209 | } | ||
210 | return; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | if (options.ContainsKey("verbose")) | ||
215 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name); | ||
216 | |||
181 | if (saveThisFolderItself) | 217 | if (saveThisFolderItself) |
182 | { | 218 | { |
183 | path += CreateArchiveFolderName(inventoryFolder); | 219 | path += CreateArchiveFolderName(inventoryFolder); |
@@ -186,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
186 | m_archiveWriter.WriteDir(path); | 222 | m_archiveWriter.WriteDir(path); |
187 | } | 223 | } |
188 | 224 | ||
189 | InventoryCollection contents | 225 | InventoryCollection contents |
190 | = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); | 226 | = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); |
191 | 227 | ||
192 | foreach (InventoryFolderBase childFolder in contents.Folders) | 228 | foreach (InventoryFolderBase childFolder in contents.Folders) |
@@ -213,16 +249,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
213 | InventoryFolderBase inventoryFolder = null; | 249 | InventoryFolderBase inventoryFolder = null; |
214 | InventoryItemBase inventoryItem = null; | 250 | InventoryItemBase inventoryItem = null; |
215 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); | 251 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); |
216 | 252 | ||
217 | bool saveFolderContentsOnly = false; | 253 | bool saveFolderContentsOnly = false; |
218 | 254 | ||
219 | // Eliminate double slashes and any leading / on the path. | 255 | // Eliminate double slashes and any leading / on the path. |
220 | string[] components | 256 | string[] components |
221 | = m_invPath.Split( | 257 | = m_invPath.Split( |
222 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); | 258 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); |
223 | 259 | ||
224 | int maxComponentIndex = components.Length - 1; | 260 | int maxComponentIndex = components.Length - 1; |
225 | 261 | ||
226 | // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the | 262 | // If the path terminates with a STAR then later on we want to archive all nodes in the folder but not the |
227 | // folder itself. This may get more sophisicated later on | 263 | // folder itself. This may get more sophisicated later on |
228 | if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) | 264 | if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) |
@@ -230,13 +266,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
230 | saveFolderContentsOnly = true; | 266 | saveFolderContentsOnly = true; |
231 | maxComponentIndex--; | 267 | maxComponentIndex--; |
232 | } | 268 | } |
233 | 269 | ||
234 | m_invPath = String.Empty; | 270 | m_invPath = String.Empty; |
235 | for (int i = 0; i <= maxComponentIndex; i++) | 271 | for (int i = 0; i <= maxComponentIndex; i++) |
236 | { | 272 | { |
237 | m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER; | 273 | m_invPath += components[i] + InventoryFolderImpl.PATH_DELIMITER; |
238 | } | 274 | } |
239 | 275 | ||
240 | // Annoyingly Split actually returns the original string if the input string consists only of delimiters | 276 | // Annoyingly Split actually returns the original string if the input string consists only of delimiters |
241 | // Therefore if we still start with a / after the split, then we need the root folder | 277 | // Therefore if we still start with a / after the split, then we need the root folder |
242 | if (m_invPath.Length == 0) | 278 | if (m_invPath.Length == 0) |
@@ -246,25 +282,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
246 | else | 282 | else |
247 | { | 283 | { |
248 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); | 284 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); |
249 | List<InventoryFolderBase> candidateFolders | 285 | List<InventoryFolderBase> candidateFolders |
250 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); | 286 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); |
251 | if (candidateFolders.Count > 0) | 287 | if (candidateFolders.Count > 0) |
252 | inventoryFolder = candidateFolders[0]; | 288 | inventoryFolder = candidateFolders[0]; |
253 | } | 289 | } |
254 | 290 | ||
255 | // The path may point to an item instead | 291 | // The path may point to an item instead |
256 | if (inventoryFolder == null) | 292 | if (inventoryFolder == null) |
257 | inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); | 293 | inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); |
258 | 294 | ||
259 | if (null == inventoryFolder && null == inventoryItem) | 295 | if (null == inventoryFolder && null == inventoryItem) |
260 | { | 296 | { |
261 | // We couldn't find the path indicated | 297 | // We couldn't find the path indicated |
262 | string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); | 298 | string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); |
263 | Exception e = new InventoryArchiverException(errorMessage); | 299 | Exception e = new InventoryArchiverException(errorMessage); |
264 | m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e); | 300 | m_module.TriggerInventoryArchiveSaved(m_id, false, m_userInfo, m_invPath, m_saveStream, e); |
265 | throw e; | 301 | throw e; |
266 | } | 302 | } |
267 | 303 | ||
268 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 304 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
269 | 305 | ||
270 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive."); | 306 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Adding control file to archive."); |
@@ -278,10 +314,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
278 | { | 314 | { |
279 | m_log.DebugFormat( | 315 | m_log.DebugFormat( |
280 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", | 316 | "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", |
281 | inventoryFolder.Name, | 317 | inventoryFolder.Name, |
282 | inventoryFolder.ID, | 318 | inventoryFolder.ID, |
283 | m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); | 319 | m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); |
284 | 320 | ||
285 | //recurse through all dirs getting dirs and files | 321 | //recurse through all dirs getting dirs and files |
286 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService); | 322 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService); |
287 | } | 323 | } |
@@ -290,10 +326,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
290 | m_log.DebugFormat( | 326 | m_log.DebugFormat( |
291 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", | 327 | "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", |
292 | inventoryItem.Name, inventoryItem.ID, m_invPath); | 328 | inventoryItem.Name, inventoryItem.ID, m_invPath); |
293 | 329 | ||
294 | SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService); | 330 | SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService); |
295 | } | 331 | } |
296 | 332 | ||
297 | // Don't put all this profile information into the archive right now. | 333 | // Don't put all this profile information into the archive right now. |
298 | //SaveUsers(); | 334 | //SaveUsers(); |
299 | 335 | ||
@@ -352,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
352 | /// | 388 | /// |
353 | /// These names are prepended with an inventory folder's UUID so that more than one folder can have the | 389 | /// These names are prepended with an inventory folder's UUID so that more than one folder can have the |
354 | /// same name | 390 | /// same name |
355 | /// | 391 | /// |
356 | /// <param name="folder"></param> | 392 | /// <param name="folder"></param> |
357 | /// <returns></returns> | 393 | /// <returns></returns> |
358 | public static string CreateArchiveFolderName(InventoryFolderBase folder) | 394 | public static string CreateArchiveFolderName(InventoryFolderBase folder) |
@@ -366,7 +402,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
366 | /// | 402 | /// |
367 | /// These names are prepended with an inventory item's UUID so that more than one item can have the | 403 | /// These names are prepended with an inventory item's UUID so that more than one item can have the |
368 | /// same name | 404 | /// same name |
369 | /// | 405 | /// |
370 | /// <param name="item"></param> | 406 | /// <param name="item"></param> |
371 | /// <returns></returns> | 407 | /// <returns></returns> |
372 | public static string CreateArchiveItemName(InventoryItemBase item) | 408 | public static string CreateArchiveItemName(InventoryItemBase item) |
@@ -412,7 +448,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
412 | public string CreateControlFile(Dictionary<string, object> options) | 448 | public string CreateControlFile(Dictionary<string, object> options) |
413 | { | 449 | { |
414 | int majorVersion, minorVersion; | 450 | int majorVersion, minorVersion; |
415 | 451 | ||
416 | if (options.ContainsKey("home")) | 452 | if (options.ContainsKey("home")) |
417 | { | 453 | { |
418 | majorVersion = 1; | 454 | majorVersion = 1; |
@@ -422,10 +458,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
422 | { | 458 | { |
423 | majorVersion = 0; | 459 | majorVersion = 0; |
424 | minorVersion = 3; | 460 | minorVersion = 3; |
425 | } | 461 | } |
426 | 462 | ||
427 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); | 463 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); |
428 | 464 | ||
429 | StringWriter sw = new StringWriter(); | 465 | StringWriter sw = new StringWriter(); |
430 | XmlTextWriter xtw = new XmlTextWriter(sw); | 466 | XmlTextWriter xtw = new XmlTextWriter(sw); |
431 | xtw.Formatting = Formatting.Indented; | 467 | xtw.Formatting = Formatting.Indented; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ac22c3f..cf87010 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -47,18 +47,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
47 | public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule | 47 | public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule |
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | public string Name { get { return "Inventory Archiver Module"; } } | 51 | public string Name { get { return "Inventory Archiver Module"; } } |
52 | 52 | ||
53 | public bool IsSharedModule { get { return true; } } | 53 | public bool IsSharedModule { get { return true; } } |
54 | 54 | ||
55 | /// <value> | 55 | /// <value> |
56 | /// Enable or disable checking whether the iar user is actually logged in | 56 | /// Enable or disable checking whether the iar user is actually logged in |
57 | /// </value> | 57 | /// </value> |
58 | // public bool DisablePresenceChecks { get; set; } | 58 | // public bool DisablePresenceChecks { get; set; } |
59 | 59 | ||
60 | public event InventoryArchiveSaved OnInventoryArchiveSaved; | 60 | public event InventoryArchiveSaved OnInventoryArchiveSaved; |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// The file to load and save inventory if no filename has been specified | 63 | /// The file to load and save inventory if no filename has been specified |
64 | /// </summary> | 64 | /// </summary> |
@@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
68 | /// Pending save completions initiated from the console | 68 | /// Pending save completions initiated from the console |
69 | /// </value> | 69 | /// </value> |
70 | protected List<Guid> m_pendingConsoleSaves = new List<Guid>(); | 70 | protected List<Guid> m_pendingConsoleSaves = new List<Guid>(); |
71 | 71 | ||
72 | /// <value> | 72 | /// <value> |
73 | /// All scenes that this module knows about | 73 | /// All scenes that this module knows about |
74 | /// </value> | 74 | /// </value> |
@@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
106 | { | 106 | { |
107 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); | 107 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); |
108 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; | 108 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; |
109 | 109 | ||
110 | scene.AddCommand( | 110 | scene.AddCommand( |
111 | "Archiving", this, "load iar", | 111 | "Archiving", this, "load iar", |
112 | "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]", | 112 | "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]", |
@@ -119,11 +119,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
119 | + "<IAR path> is the filesystem path or URI from which to load the IAR." | 119 | + "<IAR path> is the filesystem path or URI from which to load the IAR." |
120 | + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), | 120 | + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), |
121 | HandleLoadInvConsoleCommand); | 121 | HandleLoadInvConsoleCommand); |
122 | 122 | ||
123 | scene.AddCommand( | 123 | scene.AddCommand( |
124 | "Archiving", this, "save iar", | 124 | "Archiving", this, "save iar", |
125 | "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-v|--verbose]", | 125 | "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-v|--verbose]", |
126 | "Save user inventory archive (IAR).", | 126 | "Save user inventory archive (IAR).", |
127 | "<first> is the user's first name.\n" | 127 | "<first> is the user's first name.\n" |
128 | + "<last> is the user's last name.\n" | 128 | + "<last> is the user's last name.\n" |
129 | + "<inventory path> is the path inside the user's inventory for the folder/item to be saved.\n" | 129 | + "<inventory path> is the path inside the user's inventory for the folder/item to be saved.\n" |
@@ -131,32 +131,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
131 | + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME) | 131 | + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME) |
132 | + "-h|--home=<url> adds the url of the profile service to the saved user information.\n" | 132 | + "-h|--home=<url> adds the url of the profile service to the saved user information.\n" |
133 | + "-c|--creators preserves information about foreign creators.\n" | 133 | + "-c|--creators preserves information about foreign creators.\n" |
134 | + "-e|--exclude=<name/uuid> don't save the inventory item in archive" + Environment.NewLine | ||
135 | + "-f|--excludefolder=<folder/uuid> don't save contents of the folder in archive" + Environment.NewLine | ||
134 | + "-v|--verbose extra debug messages.\n" | 136 | + "-v|--verbose extra debug messages.\n" |
135 | + "--noassets stops assets being saved to the IAR.", | 137 | + "--noassets stops assets being saved to the IAR.", |
136 | HandleSaveInvConsoleCommand); | 138 | HandleSaveInvConsoleCommand); |
137 | 139 | ||
138 | m_aScene = scene; | 140 | m_aScene = scene; |
139 | } | 141 | } |
140 | 142 | ||
141 | m_scenes[scene.RegionInfo.RegionID] = scene; | 143 | m_scenes[scene.RegionInfo.RegionID] = scene; |
142 | } | 144 | } |
143 | 145 | ||
144 | public void PostInitialise() {} | 146 | public void PostInitialise() {} |
145 | 147 | ||
146 | public void Close() {} | 148 | public void Close() {} |
147 | 149 | ||
148 | /// <summary> | 150 | /// <summary> |
149 | /// Trigger the inventory archive saved event. | 151 | /// Trigger the inventory archive saved event. |
150 | /// </summary> | 152 | /// </summary> |
151 | protected internal void TriggerInventoryArchiveSaved( | 153 | protected internal void TriggerInventoryArchiveSaved( |
152 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | 154 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, |
153 | Exception reportedException) | 155 | Exception reportedException) |
154 | { | 156 | { |
155 | InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; | 157 | InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; |
156 | if (handlerInventoryArchiveSaved != null) | 158 | if (handlerInventoryArchiveSaved != null) |
157 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); | 159 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); |
158 | } | 160 | } |
159 | 161 | ||
160 | public bool ArchiveInventory( | 162 | public bool ArchiveInventory( |
161 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) | 163 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) |
162 | { | 164 | { |
@@ -164,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
164 | } | 166 | } |
165 | 167 | ||
166 | public bool ArchiveInventory( | 168 | public bool ArchiveInventory( |
167 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, | 169 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, |
168 | Dictionary<string, object> options) | 170 | Dictionary<string, object> options) |
169 | { | 171 | { |
170 | if (m_scenes.Count > 0) | 172 | if (m_scenes.Count > 0) |
@@ -188,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
188 | 190 | ||
189 | return false; | 191 | return false; |
190 | } | 192 | } |
191 | 193 | ||
192 | return true; | 194 | return true; |
193 | // } | 195 | // } |
194 | // else | 196 | // else |
@@ -202,15 +204,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
202 | 204 | ||
203 | return false; | 205 | return false; |
204 | } | 206 | } |
205 | 207 | ||
206 | public bool ArchiveInventory( | 208 | public bool ArchiveInventory( |
207 | Guid id, string firstName, string lastName, string invPath, string pass, string savePath, | 209 | Guid id, string firstName, string lastName, string invPath, string pass, string savePath, |
208 | Dictionary<string, object> options) | 210 | Dictionary<string, object> options) |
209 | { | 211 | { |
210 | if (m_scenes.Count > 0) | 212 | if (m_scenes.Count > 0) |
211 | { | 213 | { |
212 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); | 214 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
213 | 215 | ||
214 | if (userInfo != null) | 216 | if (userInfo != null) |
215 | { | 217 | { |
216 | // if (CheckPresence(userInfo.PrincipalID)) | 218 | // if (CheckPresence(userInfo.PrincipalID)) |
@@ -228,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
228 | 230 | ||
229 | return false; | 231 | return false; |
230 | } | 232 | } |
231 | 233 | ||
232 | return true; | 234 | return true; |
233 | // } | 235 | // } |
234 | // else | 236 | // else |
@@ -239,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
239 | // } | 241 | // } |
240 | } | 242 | } |
241 | } | 243 | } |
242 | 244 | ||
243 | return false; | 245 | return false; |
244 | } | 246 | } |
245 | 247 | ||
@@ -247,9 +249,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
247 | { | 249 | { |
248 | return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); | 250 | return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); |
249 | } | 251 | } |
250 | 252 | ||
251 | public bool DearchiveInventory( | 253 | public bool DearchiveInventory( |
252 | string firstName, string lastName, string invPath, string pass, Stream loadStream, | 254 | string firstName, string lastName, string invPath, string pass, Stream loadStream, |
253 | Dictionary<string, object> options) | 255 | Dictionary<string, object> options) |
254 | { | 256 | { |
255 | if (m_scenes.Count > 0) | 257 | if (m_scenes.Count > 0) |
@@ -295,22 +297,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
295 | 297 | ||
296 | return false; | 298 | return false; |
297 | } | 299 | } |
298 | 300 | ||
299 | public bool DearchiveInventory( | 301 | public bool DearchiveInventory( |
300 | string firstName, string lastName, string invPath, string pass, string loadPath, | 302 | string firstName, string lastName, string invPath, string pass, string loadPath, |
301 | Dictionary<string, object> options) | 303 | Dictionary<string, object> options) |
302 | { | 304 | { |
303 | if (m_scenes.Count > 0) | 305 | if (m_scenes.Count > 0) |
304 | { | 306 | { |
305 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); | 307 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
306 | 308 | ||
307 | if (userInfo != null) | 309 | if (userInfo != null) |
308 | { | 310 | { |
309 | // if (CheckPresence(userInfo.PrincipalID)) | 311 | // if (CheckPresence(userInfo.PrincipalID)) |
310 | // { | 312 | // { |
311 | InventoryArchiveReadRequest request; | 313 | InventoryArchiveReadRequest request; |
312 | bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); | 314 | bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); |
313 | 315 | ||
314 | try | 316 | try |
315 | { | 317 | { |
316 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge); | 318 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge); |
@@ -324,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
324 | 326 | ||
325 | return false; | 327 | return false; |
326 | } | 328 | } |
327 | 329 | ||
328 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 330 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
329 | 331 | ||
330 | return true; | 332 | return true; |
@@ -340,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
340 | 342 | ||
341 | return false; | 343 | return false; |
342 | } | 344 | } |
343 | 345 | ||
344 | /// <summary> | 346 | /// <summary> |
345 | /// Load inventory from an inventory file archive | 347 | /// Load inventory from an inventory file archive |
346 | /// </summary> | 348 | /// </summary> |
@@ -351,26 +353,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
351 | { | 353 | { |
352 | Dictionary<string, object> options = new Dictionary<string, object>(); | 354 | Dictionary<string, object> options = new Dictionary<string, object>(); |
353 | OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); | 355 | OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); |
354 | 356 | ||
355 | List<string> mainParams = optionSet.Parse(cmdparams); | 357 | List<string> mainParams = optionSet.Parse(cmdparams); |
356 | 358 | ||
357 | if (mainParams.Count < 6) | 359 | if (mainParams.Count < 6) |
358 | { | 360 | { |
359 | m_log.Error( | 361 | m_log.Error( |
360 | "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); | 362 | "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); |
361 | return; | 363 | return; |
362 | } | 364 | } |
363 | 365 | ||
364 | string firstName = mainParams[2]; | 366 | string firstName = mainParams[2]; |
365 | string lastName = mainParams[3]; | 367 | string lastName = mainParams[3]; |
366 | string invPath = mainParams[4]; | 368 | string invPath = mainParams[4]; |
367 | string pass = mainParams[5]; | 369 | string pass = mainParams[5]; |
368 | string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); | 370 | string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); |
369 | 371 | ||
370 | m_log.InfoFormat( | 372 | m_log.InfoFormat( |
371 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", | 373 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", |
372 | loadPath, invPath, firstName, lastName); | 374 | loadPath, invPath, firstName, lastName); |
373 | 375 | ||
374 | if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) | 376 | if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) |
375 | m_log.InfoFormat( | 377 | m_log.InfoFormat( |
376 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", | 378 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", |
@@ -381,7 +383,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
381 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); | 383 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); |
382 | } | 384 | } |
383 | } | 385 | } |
384 | 386 | ||
385 | /// <summary> | 387 | /// <summary> |
386 | /// Save inventory to a file archive | 388 | /// Save inventory to a file archive |
387 | /// </summary> | 389 | /// </summary> |
@@ -398,6 +400,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
398 | ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; }); | 400 | ops.Add("v|verbose", delegate(string v) { options["verbose"] = v; }); |
399 | ops.Add("c|creators", delegate(string v) { options["creators"] = v; }); | 401 | ops.Add("c|creators", delegate(string v) { options["creators"] = v; }); |
400 | ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); | 402 | ops.Add("noassets", delegate(string v) { options["noassets"] = v != null; }); |
403 | ops.Add("e|exclude=", delegate(string v) | ||
404 | { | ||
405 | if (!options.ContainsKey("exclude")) | ||
406 | options["exclude"] = new List<String>(); | ||
407 | ((List<String>)options["exclude"]).Add(v); | ||
408 | }); | ||
409 | ops.Add("f|excludefolder=", delegate(string v) | ||
410 | { | ||
411 | if (!options.ContainsKey("excludefolders")) | ||
412 | options["excludefolders"] = new List<String>(); | ||
413 | ((List<String>)options["excludefolders"]).Add(v); | ||
414 | }); | ||
401 | 415 | ||
402 | List<string> mainParams = ops.Parse(cmdparams); | 416 | List<string> mainParams = ops.Parse(cmdparams); |
403 | 417 | ||
@@ -406,10 +420,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
406 | if (mainParams.Count < 6) | 420 | if (mainParams.Count < 6) |
407 | { | 421 | { |
408 | m_log.Error( | 422 | m_log.Error( |
409 | "[INVENTORY ARCHIVER]: usage is save iar [-h|--home=<url>] [--noassets] <first name> <last name> <inventory path> <user password> [<save file path>] [-c|--creators] [-v|--verbose]"); | 423 | "[INVENTORY ARCHIVER]: save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-v|--verbose]"); |
410 | return; | 424 | return; |
411 | } | 425 | } |
412 | 426 | ||
413 | if (options.ContainsKey("home")) | 427 | if (options.ContainsKey("home")) |
414 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -home option if you want to produce a compatible IAR"); | 428 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -home option if you want to produce a compatible IAR"); |
415 | 429 | ||
@@ -418,7 +432,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
418 | string invPath = mainParams[4]; | 432 | string invPath = mainParams[4]; |
419 | string pass = mainParams[5]; | 433 | string pass = mainParams[5]; |
420 | string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); | 434 | string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); |
421 | 435 | ||
422 | m_log.InfoFormat( | 436 | m_log.InfoFormat( |
423 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", | 437 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", |
424 | savePath, invPath, firstName, lastName); | 438 | savePath, invPath, firstName, lastName); |
@@ -433,9 +447,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
433 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); | 447 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", e.Message); |
434 | } | 448 | } |
435 | } | 449 | } |
436 | 450 | ||
437 | private void SaveInvConsoleCommandCompleted( | 451 | private void SaveInvConsoleCommandCompleted( |
438 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | 452 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, |
439 | Exception reportedException) | 453 | Exception reportedException) |
440 | { | 454 | { |
441 | lock (m_pendingConsoleSaves) | 455 | lock (m_pendingConsoleSaves) |
@@ -445,7 +459,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
445 | else | 459 | else |
446 | return; | 460 | return; |
447 | } | 461 | } |
448 | 462 | ||
449 | if (succeeded) | 463 | if (succeeded) |
450 | { | 464 | { |
451 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); | 465 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); |
@@ -453,11 +467,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
453 | else | 467 | else |
454 | { | 468 | { |
455 | m_log.ErrorFormat( | 469 | m_log.ErrorFormat( |
456 | "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}", | 470 | "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}", |
457 | userInfo.FirstName, userInfo.LastName, reportedException.Message); | 471 | userInfo.FirstName, userInfo.LastName, reportedException.Message); |
458 | } | 472 | } |
459 | } | 473 | } |
460 | 474 | ||
461 | /// <summary> | 475 | /// <summary> |
462 | /// Get user information for the given name. | 476 | /// Get user information for the given name. |
463 | /// </summary> | 477 | /// </summary> |
@@ -467,13 +481,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
467 | /// <returns></returns> | 481 | /// <returns></returns> |
468 | protected UserAccount GetUserInfo(string firstName, string lastName, string pass) | 482 | protected UserAccount GetUserInfo(string firstName, string lastName, string pass) |
469 | { | 483 | { |
470 | UserAccount account | 484 | UserAccount account |
471 | = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName); | 485 | = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName); |
472 | 486 | ||
473 | if (null == account) | 487 | if (null == account) |
474 | { | 488 | { |
475 | m_log.ErrorFormat( | 489 | m_log.ErrorFormat( |
476 | "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}", | 490 | "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}", |
477 | firstName, lastName); | 491 | firstName, lastName); |
478 | return null; | 492 | return null; |
479 | } | 493 | } |
@@ -488,7 +502,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
488 | else | 502 | else |
489 | { | 503 | { |
490 | m_log.ErrorFormat( | 504 | m_log.ErrorFormat( |
491 | "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", | 505 | "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", |
492 | firstName, lastName); | 506 | firstName, lastName); |
493 | return null; | 507 | return null; |
494 | } | 508 | } |
@@ -499,7 +513,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
499 | return null; | 513 | return null; |
500 | } | 514 | } |
501 | } | 515 | } |
502 | 516 | ||
503 | /// <summary> | 517 | /// <summary> |
504 | /// Notify the client of loaded nodes if they are logged in | 518 | /// Notify the client of loaded nodes if they are logged in |
505 | /// </summary> | 519 | /// </summary> |
@@ -508,22 +522,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
508 | { | 522 | { |
509 | if (loadedNodes.Count == 0) | 523 | if (loadedNodes.Count == 0) |
510 | return; | 524 | return; |
511 | 525 | ||
512 | foreach (Scene scene in m_scenes.Values) | 526 | foreach (Scene scene in m_scenes.Values) |
513 | { | 527 | { |
514 | ScenePresence user = scene.GetScenePresence(userInfo.PrincipalID); | 528 | ScenePresence user = scene.GetScenePresence(userInfo.PrincipalID); |
515 | 529 | ||
516 | if (user != null && !user.IsChildAgent) | 530 | if (user != null && !user.IsChildAgent) |
517 | { | 531 | { |
518 | foreach (InventoryNodeBase node in loadedNodes) | 532 | foreach (InventoryNodeBase node in loadedNodes) |
519 | { | 533 | { |
520 | // m_log.DebugFormat( | 534 | // m_log.DebugFormat( |
521 | // "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", | 535 | // "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", |
522 | // user.Name, node.Name); | 536 | // user.Name, node.Name); |
523 | 537 | ||
524 | user.ControllingClient.SendBulkUpdateInventory(node); | 538 | user.ControllingClient.SendBulkUpdateInventory(node); |
525 | } | 539 | } |
526 | 540 | ||
527 | break; | 541 | break; |
528 | } | 542 | } |
529 | } | 543 | } |
@@ -538,7 +552,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
538 | // { | 552 | // { |
539 | // if (DisablePresenceChecks) | 553 | // if (DisablePresenceChecks) |
540 | // return true; | 554 | // return true; |
541 | // | 555 | // |
542 | // foreach (Scene scene in m_scenes.Values) | 556 | // foreach (Scene scene in m_scenes.Values) |
543 | // { | 557 | // { |
544 | // ScenePresence p; | 558 | // ScenePresence p; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index 19ef571..90ae69d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | |||
@@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
100 | // log4net.Config.XmlConfigurator.Configure(); | 100 | // log4net.Config.XmlConfigurator.Configure(); |
101 | 101 | ||
102 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 102 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
103 | Scene scene = SceneHelpers.SetupScene(); | 103 | Scene scene = new SceneHelpers().SetupScene(); |
104 | SceneHelpers.SetupSceneModules(scene, archiverModule); | 104 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
105 | 105 | ||
106 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); | 106 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index e409c8e..b112b6d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
61 | SerialiserModule serialiserModule = new SerialiserModule(); | 61 | SerialiserModule serialiserModule = new SerialiserModule(); |
62 | m_archiverModule = new InventoryArchiverModule(); | 62 | m_archiverModule = new InventoryArchiverModule(); |
63 | 63 | ||
64 | m_scene = SceneHelpers.SetupScene(); | 64 | m_scene = new SceneHelpers().SetupScene(); |
65 | SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); | 65 | SceneHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); |
66 | } | 66 | } |
67 | 67 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs index 417c20c..6eb3605 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs | |||
@@ -62,7 +62,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
62 | 62 | ||
63 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 63 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
64 | 64 | ||
65 | Scene scene = SceneHelpers.SetupScene(); | 65 | Scene scene = new SceneHelpers().SetupScene(); |
66 | SceneHelpers.SetupSceneModules(scene, archiverModule); | 66 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
67 | 67 | ||
68 | // Create user | 68 | // Create user |
@@ -179,7 +179,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
179 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 179 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
180 | 180 | ||
181 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | 181 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene |
182 | Scene scene = SceneHelpers.SetupScene(); | 182 | Scene scene = new SceneHelpers().SetupScene(); |
183 | 183 | ||
184 | SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 184 | SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
185 | 185 | ||
@@ -222,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
222 | 222 | ||
223 | SerialiserModule serialiserModule = new SerialiserModule(); | 223 | SerialiserModule serialiserModule = new SerialiserModule(); |
224 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 224 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
225 | Scene scene = SceneHelpers.SetupScene(); | 225 | Scene scene = new SceneHelpers().SetupScene(); |
226 | SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 226 | SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
227 | 227 | ||
228 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); | 228 | UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); |
@@ -247,7 +247,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
247 | 247 | ||
248 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | 248 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
249 | 249 | ||
250 | Scene scene = SceneHelpers.SetupScene(); | 250 | Scene scene = new SceneHelpers().SetupScene(); |
251 | SceneHelpers.SetupSceneModules(scene, archiverModule); | 251 | SceneHelpers.SetupSceneModules(scene, archiverModule); |
252 | 252 | ||
253 | // Create user | 253 | // Create user |
@@ -326,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
326 | TestHelpers.InMethod(); | 326 | TestHelpers.InMethod(); |
327 | // log4net.Config.XmlConfigurator.Configure(); | 327 | // log4net.Config.XmlConfigurator.Configure(); |
328 | 328 | ||
329 | Scene scene = SceneHelpers.SetupScene(); | 329 | Scene scene = new SceneHelpers().SetupScene(); |
330 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); | 330 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); |
331 | 331 | ||
332 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); | 332 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
@@ -393,7 +393,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
393 | TestHelpers.InMethod(); | 393 | TestHelpers.InMethod(); |
394 | //log4net.Config.XmlConfigurator.Configure(); | 394 | //log4net.Config.XmlConfigurator.Configure(); |
395 | 395 | ||
396 | Scene scene = SceneHelpers.SetupScene(); | 396 | Scene scene = new SceneHelpers().SetupScene(); |
397 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); | 397 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); |
398 | 398 | ||
399 | string folder1ExistingName = "a"; | 399 | string folder1ExistingName = "a"; |
@@ -444,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
444 | TestHelpers.InMethod(); | 444 | TestHelpers.InMethod(); |
445 | // log4net.Config.XmlConfigurator.Configure(); | 445 | // log4net.Config.XmlConfigurator.Configure(); |
446 | 446 | ||
447 | Scene scene = SceneHelpers.SetupScene(); | 447 | Scene scene = new SceneHelpers().SetupScene(); |
448 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); | 448 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene); |
449 | 449 | ||
450 | string folder1ExistingName = "a"; | 450 | string folder1ExistingName = "a"; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index dcfdf8f..a889984 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -151,6 +151,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
151 | Scene scene = (Scene)(client.Scene); | 151 | Scene scene = (Scene)(client.Scene); |
152 | ScenePresence presence = scene.GetScenePresence(client.AgentId); | 152 | ScenePresence presence = scene.GetScenePresence(client.AgentId); |
153 | 153 | ||
154 | // Round up Z co-ordinate rather than round-down by casting. This stops tall avatars from being given | ||
155 | // a teleport Z co-ordinate by short avatars that drops them through or embeds them in thin floors on | ||
156 | // arrival. | ||
157 | // | ||
158 | // Ideally we would give the exact float position adjusting for the relative height of the two avatars | ||
159 | // but it looks like a float component isn't possible with a parcel ID. | ||
154 | UUID dest = Util.BuildFakeParcelID( | 160 | UUID dest = Util.BuildFakeParcelID( |
155 | scene.RegionInfo.RegionHandle, | 161 | scene.RegionInfo.RegionHandle, |
156 | (uint)presence.AbsolutePosition.X, | 162 | (uint)presence.AbsolutePosition.X, |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 2b790f4..07ea35e 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -61,8 +61,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
61 | set { m_MaxTransferDistance = value; } | 61 | set { m_MaxTransferDistance = value; } |
62 | } | 62 | } |
63 | 63 | ||
64 | private int m_levelHGTeleport = 0; | ||
65 | |||
66 | protected bool m_Enabled = false; | 64 | protected bool m_Enabled = false; |
67 | protected Scene m_aScene; | 65 | protected Scene m_aScene; |
68 | protected List<Scene> m_Scenes = new List<Scene>(); | 66 | protected List<Scene> m_Scenes = new List<Scene>(); |
@@ -106,7 +104,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
106 | if (transferConfig != null) | 104 | if (transferConfig != null) |
107 | { | 105 | { |
108 | MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); | 106 | MaxTransferDistance = transferConfig.GetInt("max_distance", 4095); |
109 | m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); | ||
110 | } | 107 | } |
111 | 108 | ||
112 | m_agentsInTransit = new List<UUID>(); | 109 | m_agentsInTransit = new List<UUID>(); |
@@ -164,6 +161,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
164 | 161 | ||
165 | public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) | 162 | public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) |
166 | { | 163 | { |
164 | if (sp.Scene.Permissions.IsGridGod(sp.UUID)) | ||
165 | { | ||
166 | // This user will be a God in the destination scene, too | ||
167 | teleportFlags |= (uint)TeleportFlags.Godlike; | ||
168 | } | ||
169 | |||
167 | if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) | 170 | if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) |
168 | return; | 171 | return; |
169 | 172 | ||
@@ -172,13 +175,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
172 | // Reset animations; the viewer does that in teleports. | 175 | // Reset animations; the viewer does that in teleports. |
173 | sp.Animator.ResetAnimations(); | 176 | sp.Animator.ResetAnimations(); |
174 | 177 | ||
178 | string destinationRegionName = "(not found)"; | ||
179 | |||
175 | try | 180 | try |
176 | { | 181 | { |
177 | if (regionHandle == sp.Scene.RegionInfo.RegionHandle) | 182 | if (regionHandle == sp.Scene.RegionInfo.RegionHandle) |
178 | { | 183 | { |
184 | destinationRegionName = sp.Scene.RegionInfo.RegionName; | ||
185 | |||
179 | m_log.DebugFormat( | 186 | m_log.DebugFormat( |
180 | "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", | 187 | "[ENTITY TRANSFER MODULE]: Teleport for {0} to {1} within {2}", |
181 | position, sp.Scene.RegionInfo.RegionName); | 188 | sp.Name, position, destinationRegionName); |
182 | 189 | ||
183 | // Teleport within the same region | 190 | // Teleport within the same region |
184 | if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) | 191 | if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) |
@@ -188,6 +195,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
188 | m_log.WarnFormat( | 195 | m_log.WarnFormat( |
189 | "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | 196 | "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", |
190 | position, sp.Name, sp.UUID, emergencyPos); | 197 | position, sp.Name, sp.UUID, emergencyPos); |
198 | |||
191 | position = emergencyPos; | 199 | position = emergencyPos; |
192 | } | 200 | } |
193 | 201 | ||
@@ -211,6 +219,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
211 | 219 | ||
212 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | 220 | sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); |
213 | sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags; | 221 | sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags; |
222 | sp.Velocity = Vector3.Zero; | ||
214 | sp.Teleport(position); | 223 | sp.Teleport(position); |
215 | 224 | ||
216 | foreach (SceneObjectGroup grp in sp.GetAttachments()) | 225 | foreach (SceneObjectGroup grp in sp.GetAttachments()) |
@@ -229,20 +238,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
229 | GridRegion finalDestination = GetFinalDestination(reg); | 238 | GridRegion finalDestination = GetFinalDestination(reg); |
230 | if (finalDestination == null) | 239 | if (finalDestination == null) |
231 | { | 240 | { |
232 | m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport agent."); | 241 | m_log.WarnFormat( |
242 | "[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport {0} {1}", | ||
243 | sp.Name, sp.UUID); | ||
244 | |||
233 | sp.ControllingClient.SendTeleportFailed("Problem at destination"); | 245 | sp.ControllingClient.SendTeleportFailed("Problem at destination"); |
234 | return; | 246 | return; |
235 | } | 247 | } |
236 | 248 | ||
237 | // check if HyperGrid teleport is allowed, based on user level | 249 | destinationRegionName = finalDestination.RegionName; |
238 | int flags = m_aScene.GridService.GetRegionFlags(sp.Scene.RegionInfo.ScopeID, reg.RegionID); | ||
239 | |||
240 | if (((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) && (sp.UserLevel < m_levelHGTeleport)) | ||
241 | { | ||
242 | m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Final destination link is non permitted hypergrid region. Unable to teleport agent."); | ||
243 | sp.ControllingClient.SendTeleportFailed("HyperGrid teleport not permitted"); | ||
244 | return; | ||
245 | } | ||
246 | 250 | ||
247 | uint curX = 0, curY = 0; | 251 | uint curX = 0, curY = 0; |
248 | Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY); | 252 | Utils.LongToUInts(sp.Scene.RegionInfo.RegionHandle, out curX, out curY); |
@@ -308,7 +312,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
308 | } | 312 | } |
309 | catch (Exception e) | 313 | catch (Exception e) |
310 | { | 314 | { |
311 | m_log.WarnFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0} {1}", e.Message, e.StackTrace); | 315 | m_log.ErrorFormat( |
316 | "[ENTITY TRANSFER MODULE]: Exception on teleport of {0} from {1}@{2} to {3}@{4}: {5}{6}", | ||
317 | sp.Name, sp.AbsolutePosition, sp.Scene.RegionInfo.RegionName, position, destinationRegionName, | ||
318 | e.Message, e.StackTrace); | ||
319 | |||
312 | sp.ControllingClient.SendTeleportFailed("Internal error"); | 320 | sp.ControllingClient.SendTeleportFailed("Internal error"); |
313 | } | 321 | } |
314 | } | 322 | } |
@@ -322,10 +330,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
322 | } | 330 | } |
323 | 331 | ||
324 | if (IsInTransit(sp.UUID)) // Avie is already on the way. Caller shouldn't do this. | 332 | if (IsInTransit(sp.UUID)) // Avie is already on the way. Caller shouldn't do this. |
333 | { | ||
334 | m_log.DebugFormat( | ||
335 | "[ENTITY TRANSFER MODULE]: Ignoring teleport request of {0} {1} to {2} ({3}) {4}/{5} - agent is already in transit.", | ||
336 | sp.Name, sp.UUID, reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); | ||
337 | |||
325 | return; | 338 | return; |
339 | } | ||
326 | 340 | ||
327 | m_log.DebugFormat( | 341 | m_log.DebugFormat( |
328 | "[ENTITY TRANSFER MODULE]: Request Teleport to {0} ({1}) {2}/{3}", | 342 | "[ENTITY TRANSFER MODULE]: Teleporting {0} {1} from {2} to {3} ({4}) {5}/{6}", |
343 | sp.Name, sp.UUID, sp.Scene.RegionInfo.RegionName, | ||
329 | reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); | 344 | reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); |
330 | 345 | ||
331 | uint newRegionX = (uint)(reg.RegionHandle >> 40); | 346 | uint newRegionX = (uint)(reg.RegionHandle >> 40); |
@@ -403,7 +418,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
403 | bool logout = false; | 418 | bool logout = false; |
404 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) | 419 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) |
405 | { | 420 | { |
406 | sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", | 421 | sp.ControllingClient.SendTeleportFailed(String.Format("Teleport refused: {0}", |
407 | reason)); | 422 | reason)); |
408 | return; | 423 | return; |
409 | } | 424 | } |
@@ -446,7 +461,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
446 | capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | 461 | capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); |
447 | } | 462 | } |
448 | 463 | ||
449 | |||
450 | SetInTransit(sp.UUID); | 464 | SetInTransit(sp.UUID); |
451 | 465 | ||
452 | // Let's send a full update of the agent. This is a synchronous call. | 466 | // Let's send a full update of the agent. This is a synchronous call. |
@@ -590,7 +604,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
590 | 604 | ||
591 | protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) | 605 | protected virtual void AgentHasMovedAway(ScenePresence sp, bool logout) |
592 | { | 606 | { |
593 | sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, true); | 607 | if (sp.Scene.AttachmentsModule != null) |
608 | sp.Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, true); | ||
594 | } | 609 | } |
595 | 610 | ||
596 | protected void KillEntity(Scene scene, uint localID) | 611 | protected void KillEntity(Scene scene, uint localID) |
@@ -663,7 +678,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
663 | 678 | ||
664 | public virtual bool TeleportHome(UUID id, IClientAPI client) | 679 | public virtual bool TeleportHome(UUID id, IClientAPI client) |
665 | { | 680 | { |
666 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); | 681 | m_log.DebugFormat( |
682 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); | ||
667 | 683 | ||
668 | //OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId); | 684 | //OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId); |
669 | GridUserInfo uinfo = m_aScene.GridUserService.GetGridUserInfo(client.AgentId.ToString()); | 685 | GridUserInfo uinfo = m_aScene.GridUserService.GetGridUserInfo(client.AgentId.ToString()); |
@@ -684,8 +700,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
684 | return false; | 700 | return false; |
685 | } | 701 | } |
686 | 702 | ||
687 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})", | 703 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Home region of {0} is {1} ({2}-{3})", |
688 | regionInfo.RegionName, regionInfo.RegionID, regionInfo.RegionLocX / Constants.RegionSize, regionInfo.RegionLocY / Constants.RegionSize); | 704 | client.Name, regionInfo.RegionName, regionInfo.RegionCoordX, regionInfo.RegionCoordY); |
689 | 705 | ||
690 | // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point... | 706 | // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point... |
691 | ((Scene)(client.Scene)).RequestTeleportLocation( | 707 | ((Scene)(client.Scene)).RequestTeleportLocation( |
@@ -1322,19 +1338,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1322 | // after a cross here | 1338 | // after a cross here |
1323 | Thread.Sleep(500); | 1339 | Thread.Sleep(500); |
1324 | 1340 | ||
1325 | Scene m_scene = sp.Scene; | 1341 | Scene scene = sp.Scene; |
1326 | 1342 | ||
1327 | uint x, y; | 1343 | m_log.DebugFormat( |
1328 | Utils.LongToUInts(reg.RegionHandle, out x, out y); | 1344 | "[ENTITY TRANSFER MODULE]: Informing {0} {1} about neighbour {2} {3} at ({4},{5})", |
1329 | x = x / Constants.RegionSize; | 1345 | sp.Name, sp.UUID, reg.RegionName, endPoint, reg.RegionCoordX, reg.RegionCoordY); |
1330 | y = y / Constants.RegionSize; | ||
1331 | m_log.Debug("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint + ")"); | ||
1332 | 1346 | ||
1333 | string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); | 1347 | string capsPath = reg.ServerURI + CapsUtil.GetCapsSeedPath(a.CapsPath); |
1334 | 1348 | ||
1335 | string reason = String.Empty; | 1349 | string reason = String.Empty; |
1336 | 1350 | ||
1337 | bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); | 1351 | bool regionAccepted = scene.SimulationService.CreateAgent(reg, a, (uint)TeleportFlags.Default, out reason); |
1338 | 1352 | ||
1339 | if (regionAccepted && newAgent) | 1353 | if (regionAccepted && newAgent) |
1340 | { | 1354 | { |
@@ -1351,7 +1365,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1351 | 1365 | ||
1352 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " + | 1366 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbour region {2} @ {3} " + |
1353 | "and EstablishAgentCommunication with seed cap {4}", | 1367 | "and EstablishAgentCommunication with seed cap {4}", |
1354 | m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); | 1368 | scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); |
1355 | 1369 | ||
1356 | eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); | 1370 | eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); |
1357 | eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); | 1371 | eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); |
@@ -1362,8 +1376,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1362 | // TODO: make Event Queue disablable! | 1376 | // TODO: make Event Queue disablable! |
1363 | } | 1377 | } |
1364 | 1378 | ||
1365 | m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); | 1379 | m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Completed inform {0} {1} about neighbour {2}", sp.Name, sp.UUID, endPoint); |
1366 | } | 1380 | } |
1381 | |||
1382 | if (!regionAccepted) | ||
1383 | m_log.WarnFormat( | ||
1384 | "[ENTITY TRANSFER MODULE]: Region {0} did not accept {1} {2}: {3}", | ||
1385 | reg.RegionName, sp.Name, sp.UUID, reason); | ||
1367 | } | 1386 | } |
1368 | 1387 | ||
1369 | /// <summary> | 1388 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 8b5ad23..a9ffd8f 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 51 | ||
52 | private bool m_Initialized = false; | 52 | private bool m_Initialized = false; |
53 | private int m_levelHGTeleport = 0; | ||
53 | 54 | ||
54 | private GatekeeperServiceConnector m_GatekeeperConnector; | 55 | private GatekeeperServiceConnector m_GatekeeperConnector; |
55 | 56 | ||
@@ -68,6 +69,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
68 | string name = moduleConfig.GetString("EntityTransferModule", ""); | 69 | string name = moduleConfig.GetString("EntityTransferModule", ""); |
69 | if (name == Name) | 70 | if (name == Name) |
70 | { | 71 | { |
72 | IConfig transferConfig = source.Configs["EntityTransfer"]; | ||
73 | if (transferConfig != null) | ||
74 | m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); | ||
75 | |||
71 | InitialiseCommon(source); | 76 | InitialiseCommon(source); |
72 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); | 77 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); |
73 | } | 78 | } |
@@ -164,6 +169,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
164 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | 169 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
165 | { | 170 | { |
166 | // this user is going to another grid | 171 | // this user is going to another grid |
172 | // check if HyperGrid teleport is allowed, based on user level | ||
173 | if (sp.UserLevel < m_levelHGTeleport) | ||
174 | { | ||
175 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); | ||
176 | reason = "Hypergrid teleport not allowed"; | ||
177 | return false; | ||
178 | } | ||
179 | |||
167 | if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) | 180 | if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) |
168 | { | 181 | { |
169 | string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); | 182 | string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); |
@@ -193,7 +206,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
193 | 206 | ||
194 | public override bool TeleportHome(UUID id, IClientAPI client) | 207 | public override bool TeleportHome(UUID id, IClientAPI client) |
195 | { | 208 | { |
196 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); | 209 | m_log.DebugFormat( |
210 | "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); | ||
197 | 211 | ||
198 | // Let's find out if this is a foreign user or a local user | 212 | // Let's find out if this is a foreign user or a local user |
199 | IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); | 213 | IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index e74310c..d6afaa9 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
65 | config.AddConfig("Modules"); | 65 | config.AddConfig("Modules"); |
66 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | 66 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); |
67 | 67 | ||
68 | m_scene = SceneHelpers.SetupScene(); | 68 | m_scene = new SceneHelpers().SetupScene(); |
69 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); | 69 | SceneHelpers.SetupSceneModules(m_scene, config, m_iam); |
70 | 70 | ||
71 | // Create user | 71 | // Create user |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 176c86d..8358bc0 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -308,56 +308,56 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
308 | /// <param name='msg'> | 308 | /// <param name='msg'> |
309 | /// Message. | 309 | /// Message. |
310 | /// </param> | 310 | /// </param> |
311 | public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) | 311 | public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) |
312 | { | 312 | { |
313 | error = null; | ||
314 | // Is id an avatar? | 313 | // Is id an avatar? |
315 | ScenePresence sp = m_scene.GetScenePresence(target); | 314 | ScenePresence sp = m_scene.GetScenePresence(target); |
316 | 315 | ||
317 | if (sp != null) | 316 | if (sp != null) |
318 | { | 317 | { |
319 | // Send message to avatar | 318 | // ignore if a child agent this is restricted to inside one region |
319 | if (sp.IsChildAgent) | ||
320 | return; | ||
321 | |||
322 | // Send message to the avatar. | ||
323 | // Channel zero only goes to the avatar | ||
324 | // non zero channel messages only go to the attachments | ||
320 | if (channel == 0) | 325 | if (channel == 0) |
321 | { | 326 | { |
322 | m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); | 327 | m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); |
323 | } | 328 | } |
324 | 329 | else | |
325 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
326 | |||
327 | if (attachments.Count == 0) | ||
328 | return true; | ||
329 | |||
330 | // Get uuid of attachments | ||
331 | List<UUID> targets = new List<UUID>(); | ||
332 | foreach (SceneObjectGroup sog in attachments) | ||
333 | { | 330 | { |
334 | if (!sog.IsDeleted) | 331 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
335 | targets.Add(sog.UUID); | 332 | if (attachments.Count == 0) |
336 | } | 333 | return; |
337 | 334 | ||
338 | // Need to check each attachment | 335 | // Get uuid of attachments |
339 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 336 | List<UUID> targets = new List<UUID>(); |
340 | { | 337 | foreach (SceneObjectGroup sog in attachments) |
341 | if (li.GetHostID().Equals(id)) | 338 | { |
342 | continue; | 339 | if (!sog.IsDeleted) |
340 | targets.Add(sog.UUID); | ||
341 | } | ||
343 | 342 | ||
344 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | 343 | // Need to check each attachment |
345 | continue; | 344 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
345 | { | ||
346 | if (li.GetHostID().Equals(id)) | ||
347 | continue; | ||
346 | 348 | ||
347 | if (targets.Contains(li.GetHostID())) | 349 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) |
348 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 350 | continue; |
349 | } | ||
350 | 351 | ||
351 | return true; | 352 | if (targets.Contains(li.GetHostID())) |
352 | } | 353 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
354 | } | ||
355 | } | ||
353 | 356 | ||
354 | // Need to toss an error here | 357 | return; |
355 | if (channel == 0) | ||
356 | { | ||
357 | error = "Cannot use llRegionSayTo to message objects on channel 0"; | ||
358 | return false; | ||
359 | } | 358 | } |
360 | 359 | ||
360 | // No avatar found so look for an object | ||
361 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 361 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
362 | { | 362 | { |
363 | // Dont process if this message is from yourself! | 363 | // Dont process if this message is from yourself! |
@@ -375,7 +375,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | return true; | 378 | return; |
379 | } | 379 | } |
380 | 380 | ||
381 | protected void QueueMessage(ListenerInfo li) | 381 | protected void QueueMessage(ListenerInfo li) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 3b862da..6cd077a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -149,9 +149,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
149 | lock (m_scenes) | 149 | lock (m_scenes) |
150 | m_scenes[scene.RegionInfo.RegionID] = scene; | 150 | m_scenes[scene.RegionInfo.RegionID] = scene; |
151 | 151 | ||
152 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); | 152 | scene.EventManager.OnLoginsEnabled += OnLoginsEnabled; |
153 | } | 153 | } |
154 | 154 | ||
155 | |||
155 | ///<summary> | 156 | ///<summary> |
156 | /// | 157 | /// |
157 | ///</summary> | 158 | ///</summary> |
@@ -166,9 +167,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
166 | 167 | ||
167 | #endregion ISharedRegionModule | 168 | #endregion ISharedRegionModule |
168 | 169 | ||
169 | void EventManager_OnPrimsLoaded(Scene s) | 170 | void OnLoginsEnabled(string regionName) |
170 | { | 171 | { |
171 | UploadMapTile(s); | 172 | Scene scene = null; |
173 | foreach (Scene s in m_scenes.Values) | ||
174 | if (s.RegionInfo.RegionName == regionName) | ||
175 | { | ||
176 | scene = s; | ||
177 | break; | ||
178 | } | ||
179 | if (scene != null) | ||
180 | UploadMapTile(scene); | ||
172 | } | 181 | } |
173 | 182 | ||
174 | 183 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 6e75692..de089f3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
191 | { | 191 | { |
192 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | 192 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
193 | { | 193 | { |
194 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); | 194 | // m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); |
195 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | 195 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); |
196 | } | 196 | } |
197 | } | 197 | } |
@@ -209,9 +209,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
209 | { | 209 | { |
210 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) | 210 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
211 | { | 211 | { |
212 | m_log.DebugFormat( | 212 | // m_log.DebugFormat( |
213 | "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", | 213 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", |
214 | s.RegionInfo.RegionName, destination.RegionHandle); | 214 | // s.RegionInfo.RegionName, destination.RegionHandle); |
215 | 215 | ||
216 | s.IncomingChildAgentDataUpdate(cAgentData); | 216 | s.IncomingChildAgentDataUpdate(cAgentData); |
217 | return true; | 217 | return true; |
@@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
280 | { | 280 | { |
281 | if (s.RegionInfo.RegionID == origin) | 281 | if (s.RegionInfo.RegionID == origin) |
282 | { | 282 | { |
283 | m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | 283 | // m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); |
284 | AgentTransferModule.AgentArrivedAtDestination(id); | 284 | AgentTransferModule.AgentArrivedAtDestination(id); |
285 | return true; | 285 | return true; |
286 | // return s.IncomingReleaseAgent(id); | 286 | // return s.IncomingReleaseAgent(id); |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 4d459bf..eabe46e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -40,6 +40,9 @@ using OpenSim.Framework.Serialization; | |||
40 | using OpenSim.Region.CoreModules.World.Terrain; | 40 | using OpenSim.Region.CoreModules.World.Terrain; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | using Ionic.Zlib; | ||
44 | using GZipStream = Ionic.Zlib.GZipStream; | ||
45 | using CompressionMode = Ionic.Zlib.CompressionMode; | ||
43 | 46 | ||
44 | namespace OpenSim.Region.CoreModules.World.Archiver | 47 | namespace OpenSim.Region.CoreModules.World.Archiver |
45 | { | 48 | { |
@@ -82,7 +85,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
82 | { | 85 | { |
83 | try | 86 | try |
84 | { | 87 | { |
85 | m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); | 88 | m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress, CompressionLevel.BestCompression); |
86 | } | 89 | } |
87 | catch (EntryPointNotFoundException e) | 90 | catch (EntryPointNotFoundException e) |
88 | { | 91 | { |
@@ -297,10 +300,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
297 | if (checkPermissions.Contains("T") && !canTransfer) | 300 | if (checkPermissions.Contains("T") && !canTransfer) |
298 | partPermitted = false; | 301 | partPermitted = false; |
299 | 302 | ||
303 | // If the user is the Creator of the object then it can always be included in the OAR | ||
304 | bool creator = (obj.CreatorID.Guid == user.Guid); | ||
305 | if (creator) | ||
306 | partPermitted = true; | ||
307 | |||
300 | //string name = (objGroup.PrimCount == 1) ? objGroup.Name : string.Format("{0} ({1}/{2})", obj.Name, primNumber, objGroup.PrimCount); | 308 | //string name = (objGroup.PrimCount == 1) ? objGroup.Name : string.Format("{0} ({1}/{2})", obj.Name, primNumber, objGroup.PrimCount); |
301 | //m_log.DebugFormat("[ARCHIVER]: Object permissions: {0}: Base={1:X4}, Owner={2:X4}, Everyone={3:X4}, permissionClass={4}, checkPermissions={5}, canCopy={6}, canTransfer={7}, permitted={8}", | 309 | //m_log.DebugFormat("[ARCHIVER]: Object permissions: {0}: Base={1:X4}, Owner={2:X4}, Everyone={3:X4}, permissionClass={4}, checkPermissions={5}, canCopy={6}, canTransfer={7}, creator={8}, permitted={9}", |
302 | // name, obj.BaseMask, obj.OwnerMask, obj.EveryoneMask, | 310 | // name, obj.BaseMask, obj.OwnerMask, obj.EveryoneMask, |
303 | // permissionClass, checkPermissions, canCopy, canTransfer, permitted); | 311 | // permissionClass, checkPermissions, canCopy, canTransfer, creator, partPermitted); |
304 | 312 | ||
305 | if (!partPermitted) | 313 | if (!partPermitted) |
306 | { | 314 | { |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 63f1363..053c6f5 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
68 | SerialiserModule serialiserModule = new SerialiserModule(); | 68 | SerialiserModule serialiserModule = new SerialiserModule(); |
69 | TerrainModule terrainModule = new TerrainModule(); | 69 | TerrainModule terrainModule = new TerrainModule(); |
70 | 70 | ||
71 | m_scene = SceneHelpers.SetupScene(); | 71 | m_scene = new SceneHelpers().SetupScene(); |
72 | SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); | 72 | SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); |
73 | } | 73 | } |
74 | 74 | ||
@@ -102,9 +102,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
102 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | 102 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); |
103 | Vector3 groupPosition = new Vector3(10, 20, 30); | 103 | Vector3 groupPosition = new Vector3(10, 20, 30); |
104 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | 104 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); |
105 | Vector3 offsetPosition = new Vector3(5, 10, 15); | 105 | // Vector3 offsetPosition = new Vector3(5, 10, 15); |
106 | 106 | ||
107 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; | 107 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, Vector3.Zero) { Name = partName }; |
108 | } | 108 | } |
109 | 109 | ||
110 | protected SceneObjectPart CreateSceneObjectPart2() | 110 | protected SceneObjectPart CreateSceneObjectPart2() |
@@ -463,7 +463,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
463 | SerialiserModule serialiserModule = new SerialiserModule(); | 463 | SerialiserModule serialiserModule = new SerialiserModule(); |
464 | TerrainModule terrainModule = new TerrainModule(); | 464 | TerrainModule terrainModule = new TerrainModule(); |
465 | 465 | ||
466 | TestScene scene2 = SceneHelpers.SetupScene(); | 466 | TestScene scene2 = new SceneHelpers().SetupScene(); |
467 | SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule); | 467 | SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule); |
468 | 468 | ||
469 | // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is | 469 | // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is |
@@ -607,7 +607,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
607 | SerialiserModule serialiserModule = new SerialiserModule(); | 607 | SerialiserModule serialiserModule = new SerialiserModule(); |
608 | TerrainModule terrainModule = new TerrainModule(); | 608 | TerrainModule terrainModule = new TerrainModule(); |
609 | 609 | ||
610 | Scene scene = SceneHelpers.SetupScene(); | 610 | Scene scene = new SceneHelpers().SetupScene(); |
611 | SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); | 611 | SceneHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); |
612 | 612 | ||
613 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); | 613 | m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 1e743c3..ddc2a07 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -168,12 +168,18 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
168 | sendRegionInfoPacketToAll(); | 168 | sendRegionInfoPacketToAll(); |
169 | } | 169 | } |
170 | 170 | ||
171 | public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, UUID texture) | 171 | public void setEstateTerrainBaseTexture(int level, UUID texture) |
172 | { | ||
173 | setEstateTerrainBaseTexture(null, level, texture); | ||
174 | sendRegionHandshakeToAll(); | ||
175 | } | ||
176 | |||
177 | public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture) | ||
172 | { | 178 | { |
173 | if (texture == UUID.Zero) | 179 | if (texture == UUID.Zero) |
174 | return; | 180 | return; |
175 | 181 | ||
176 | switch (corner) | 182 | switch (level) |
177 | { | 183 | { |
178 | case 0: | 184 | case 0: |
179 | Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture; | 185 | Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture; |
@@ -193,6 +199,11 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
193 | sendRegionInfoPacketToAll(); | 199 | sendRegionInfoPacketToAll(); |
194 | } | 200 | } |
195 | 201 | ||
202 | public void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue) | ||
203 | { | ||
204 | setEstateTerrainTextureHeights(null, corner, lowValue, highValue); | ||
205 | } | ||
206 | |||
196 | public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) | 207 | public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) |
197 | { | 208 | { |
198 | switch (corner) | 209 | switch (corner) |
@@ -987,7 +998,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
987 | { | 998 | { |
988 | RegionHandshakeArgs args = new RegionHandshakeArgs(); | 999 | RegionHandshakeArgs args = new RegionHandshakeArgs(); |
989 | 1000 | ||
990 | args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId); | 1001 | args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(remoteClient.AgentId); |
991 | if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) | 1002 | if (Scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && Scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId) |
992 | args.isEstateManager = true; | 1003 | args.isEstateManager = true; |
993 | 1004 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 02ac091..06d5587 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -1771,7 +1771,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1771 | 1771 | ||
1772 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); | 1772 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); |
1773 | 1773 | ||
1774 | targetAvatar.TeleportWithMomentum(pos); | 1774 | targetAvatar.TeleportWithMomentum(pos, null); |
1775 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | 1775 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); |
1776 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | 1776 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); |
1777 | 1777 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 509c4d7..16792b3 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -447,7 +447,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
447 | { | 447 | { |
448 | bool isMember; | 448 | bool isMember; |
449 | if (m_groupMemberCache.TryGetValue(avatar, out isMember)) | 449 | if (m_groupMemberCache.TryGetValue(avatar, out isMember)) |
450 | { | ||
451 | m_groupMemberCache.Update(avatar, isMember, m_groupMemberCacheTimeout); | ||
450 | return isMember; | 452 | return isMember; |
453 | } | ||
451 | 454 | ||
452 | IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | 455 | IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); |
453 | if (groupsModule == null) | 456 | if (groupsModule == null) |
@@ -484,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
484 | if (m_scene.Permissions.IsAdministrator(avatar)) | 487 | if (m_scene.Permissions.IsAdministrator(avatar)) |
485 | return false; | 488 | return false; |
486 | 489 | ||
487 | if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) | 490 | if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) |
488 | return false; | 491 | return false; |
489 | 492 | ||
490 | if (avatar == LandData.OwnerID) | 493 | if (avatar == LandData.OwnerID) |
@@ -514,7 +517,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
514 | if (m_scene.Permissions.IsAdministrator(avatar)) | 517 | if (m_scene.Permissions.IsAdministrator(avatar)) |
515 | return false; | 518 | return false; |
516 | 519 | ||
517 | if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar)) | 520 | if (m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(avatar)) |
518 | return false; | 521 | return false; |
519 | 522 | ||
520 | if (avatar == LandData.OwnerID) | 523 | if (avatar == LandData.OwnerID) |
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index e553ffa..b5ee4d2 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs | |||
@@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests | |||
64 | { | 64 | { |
65 | m_pcm = new PrimCountModule(); | 65 | m_pcm = new PrimCountModule(); |
66 | LandManagementModule lmm = new LandManagementModule(); | 66 | LandManagementModule lmm = new LandManagementModule(); |
67 | m_scene = SceneHelpers.SetupScene(); | 67 | m_scene = new SceneHelpers().SetupScene(); |
68 | SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm); | 68 | SceneHelpers.SetupSceneModules(m_scene, lmm, m_pcm); |
69 | 69 | ||
70 | int xParcelDivider = (int)Constants.RegionSize - 1; | 70 | int xParcelDivider = (int)Constants.RegionSize - 1; |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index f86c790..aa306c7 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | |||
@@ -225,7 +225,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
225 | int tc = 0; | 225 | int tc = 0; |
226 | double[,] hm = whichScene.Heightmap.GetDoubles(); | 226 | double[,] hm = whichScene.Heightmap.GetDoubles(); |
227 | tc = Environment.TickCount; | 227 | tc = Environment.TickCount; |
228 | m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); | 228 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); |
229 | EntityBase[] objs = whichScene.GetEntities(); | 229 | EntityBase[] objs = whichScene.GetEntities(); |
230 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); | 230 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); |
231 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); | 231 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); |
@@ -541,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
541 | g.Dispose(); | 541 | g.Dispose(); |
542 | } // lock entities objs | 542 | } // lock entities objs |
543 | 543 | ||
544 | m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); | 544 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); |
545 | return mapbmp; | 545 | return mapbmp; |
546 | } | 546 | } |
547 | 547 | ||
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs index eb1a27f..992bff3 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs | |||
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
54 | public void TerrainToBitmap(Bitmap mapbmp) | 54 | public void TerrainToBitmap(Bitmap mapbmp) |
55 | { | 55 | { |
56 | int tc = Environment.TickCount; | 56 | int tc = Environment.TickCount; |
57 | m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); | 57 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); |
58 | 58 | ||
59 | double[,] hm = m_scene.Heightmap.GetDoubles(); | 59 | double[,] hm = m_scene.Heightmap.GetDoubles(); |
60 | bool ShadowDebugContinue = true; | 60 | bool ShadowDebugContinue = true; |
@@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | 241 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index 1d2141e..d13c2ef 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | |||
@@ -278,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
278 | public void TerrainToBitmap(Bitmap mapbmp) | 278 | public void TerrainToBitmap(Bitmap mapbmp) |
279 | { | 279 | { |
280 | int tc = Environment.TickCount; | 280 | int tc = Environment.TickCount; |
281 | m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); | 281 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); |
282 | 282 | ||
283 | // These textures should be in the AssetCache anyway, as every client conneting to this | 283 | // These textures should be in the AssetCache anyway, as every client conneting to this |
284 | // region needs them. Except on start, when the map is recreated (before anyone connected), | 284 | // region needs them. Except on start, when the map is recreated (before anyone connected), |
@@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
412 | } | 412 | } |
413 | } | 413 | } |
414 | } | 414 | } |
415 | m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | 415 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | } | 418 | } |
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index 4326606..0545250 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests | |||
53 | public void SetUp() | 53 | public void SetUp() |
54 | { | 54 | { |
55 | m_module = new MoapModule(); | 55 | m_module = new MoapModule(); |
56 | m_scene = SceneHelpers.SetupScene(); | 56 | m_scene = new SceneHelpers().SetupScene(); |
57 | SceneHelpers.SetupSceneModules(m_scene, m_module); | 57 | SceneHelpers.SetupSceneModules(m_scene, m_module); |
58 | } | 58 | } |
59 | 59 | ||
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index f5a5c92..5e928f3 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | |||
@@ -78,45 +78,49 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
78 | m_scene = scene; | 78 | m_scene = scene; |
79 | m_console = MainConsole.Instance; | 79 | m_console = MainConsole.Instance; |
80 | 80 | ||
81 | m_console.Commands.AddCommand("Regions", false, "delete object owner", | 81 | m_console.Commands.AddCommand("Objects", false, "delete object owner", |
82 | "delete object owner <UUID>", | 82 | "delete object owner <UUID>", |
83 | "Delete a scene object by owner", HandleDeleteObject); | 83 | "Delete a scene object by owner", HandleDeleteObject); |
84 | m_console.Commands.AddCommand("Regions", false, "delete object creator", | 84 | |
85 | m_console.Commands.AddCommand("Objects", false, "delete object creator", | ||
85 | "delete object creator <UUID>", | 86 | "delete object creator <UUID>", |
86 | "Delete a scene object by creator", HandleDeleteObject); | 87 | "Delete a scene object by creator", HandleDeleteObject); |
87 | m_console.Commands.AddCommand("Regions", false, "delete object uuid", | 88 | |
89 | m_console.Commands.AddCommand("Objects", false, "delete object uuid", | ||
88 | "delete object uuid <UUID>", | 90 | "delete object uuid <UUID>", |
89 | "Delete a scene object by uuid", HandleDeleteObject); | 91 | "Delete a scene object by uuid", HandleDeleteObject); |
90 | m_console.Commands.AddCommand("Regions", false, "delete object name", | 92 | |
93 | m_console.Commands.AddCommand("Objects", false, "delete object name", | ||
91 | "delete object name <name>", | 94 | "delete object name <name>", |
92 | "Delete a scene object by name", HandleDeleteObject); | 95 | "Delete a scene object by name", HandleDeleteObject); |
93 | m_console.Commands.AddCommand("Regions", false, "delete object outside", | 96 | |
97 | m_console.Commands.AddCommand("Objects", false, "delete object outside", | ||
94 | "delete object outside", | 98 | "delete object outside", |
95 | "Delete all scene objects outside region boundaries", HandleDeleteObject); | 99 | "Delete all scene objects outside region boundaries", HandleDeleteObject); |
96 | 100 | ||
97 | m_console.Commands.AddCommand( | 101 | m_console.Commands.AddCommand( |
98 | "Regions", | 102 | "Objects", |
99 | false, | 103 | false, |
100 | "show object uuid", | 104 | "show object uuid", |
101 | "show object uuid <UUID>", | 105 | "show object uuid <UUID>", |
102 | "Show details of a scene object with the given UUID", HandleShowObjectByUuid); | 106 | "Show details of a scene object with the given UUID", HandleShowObjectByUuid); |
103 | 107 | ||
104 | m_console.Commands.AddCommand( | 108 | m_console.Commands.AddCommand( |
105 | "Regions", | 109 | "Objects", |
106 | false, | 110 | false, |
107 | "show object name", | 111 | "show object name", |
108 | "show object name <name>", | 112 | "show object name <name>", |
109 | "Show details of scene objects with the given name", HandleShowObjectByName); | 113 | "Show details of scene objects with the given name", HandleShowObjectByName); |
110 | 114 | ||
111 | m_console.Commands.AddCommand( | 115 | m_console.Commands.AddCommand( |
112 | "Regions", | 116 | "Objects", |
113 | false, | 117 | false, |
114 | "show part uuid", | 118 | "show part uuid", |
115 | "show part uuid <UUID>", | 119 | "show part uuid <UUID>", |
116 | "Show details of a scene object parts with the given UUID", HandleShowPartByUuid); | 120 | "Show details of a scene object parts with the given UUID", HandleShowPartByUuid); |
117 | 121 | ||
118 | m_console.Commands.AddCommand( | 122 | m_console.Commands.AddCommand( |
119 | "Regions", | 123 | "Objects", |
120 | false, | 124 | false, |
121 | "show part name", | 125 | "show part name", |
122 | "show part name <name>", | 126 | "show part name <name>", |
@@ -271,6 +275,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
271 | sb.AppendFormat("Description: {0}\n", so.Description); | 275 | sb.AppendFormat("Description: {0}\n", so.Description); |
272 | sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName); | 276 | sb.AppendFormat("Location: {0} @ {1}\n", so.AbsolutePosition, so.Scene.RegionInfo.RegionName); |
273 | sb.AppendFormat("Parts: {0}\n", so.PrimCount); | 277 | sb.AppendFormat("Parts: {0}\n", so.PrimCount); |
278 | sb.AppendFormat("Flags: {0}\n", so.RootPart.Flags); | ||
274 | 279 | ||
275 | return sb; | 280 | return sb; |
276 | } | 281 | } |
@@ -282,7 +287,8 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
282 | sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); | 287 | sb.AppendFormat("Location: {0} @ {1}\n", sop.AbsolutePosition, sop.ParentGroup.Scene.RegionInfo.RegionName); |
283 | sb.AppendFormat("Parent: {0}", | 288 | sb.AppendFormat("Parent: {0}", |
284 | sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); | 289 | sop.IsRoot ? "Is Root\n" : string.Format("{0} {1}\n", sop.ParentGroup.Name, sop.ParentGroup.UUID)); |
285 | sb.AppendFormat("Parts: {0}\n", !sop.IsRoot ? "1" : sop.ParentGroup.PrimCount.ToString());; | 290 | sb.AppendFormat("Link number: {0}\n", sop.LinkNum); |
291 | sb.AppendFormat("Flags: {0}\n", sop.Flags); | ||
286 | 292 | ||
287 | return sb; | 293 | return sb; |
288 | } | 294 | } |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 82ccaf8..190f63b 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -166,6 +166,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
166 | m_scene.Permissions.OnDeedParcel += CanDeedParcel; | 166 | m_scene.Permissions.OnDeedParcel += CanDeedParcel; |
167 | m_scene.Permissions.OnDeedObject += CanDeedObject; | 167 | m_scene.Permissions.OnDeedObject += CanDeedObject; |
168 | m_scene.Permissions.OnIsGod += IsGod; | 168 | m_scene.Permissions.OnIsGod += IsGod; |
169 | m_scene.Permissions.OnIsGridGod += IsGridGod; | ||
169 | m_scene.Permissions.OnIsAdministrator += IsAdministrator; | 170 | m_scene.Permissions.OnIsAdministrator += IsAdministrator; |
170 | m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; | 171 | m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; |
171 | m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED | 172 | m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED |
@@ -466,22 +467,34 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
466 | if (IsEstateManager(user) && m_RegionManagerIsGod) | 467 | if (IsEstateManager(user) && m_RegionManagerIsGod) |
467 | return true; | 468 | return true; |
468 | 469 | ||
470 | if (IsGridGod(user, null)) | ||
471 | return true; | ||
472 | |||
473 | return false; | ||
474 | } | ||
475 | |||
476 | /// <summary> | ||
477 | /// Is the given user a God throughout the grid (not just in the current scene)? | ||
478 | /// </summary> | ||
479 | /// <param name="user">The user</param> | ||
480 | /// <param name="scene">Unused, can be null</param> | ||
481 | /// <returns></returns> | ||
482 | protected bool IsGridGod(UUID user, Scene scene) | ||
483 | { | ||
484 | DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); | ||
485 | if (m_bypassPermissions) return m_bypassPermissionsValue; | ||
486 | |||
487 | if (user == UUID.Zero) return false; | ||
488 | |||
469 | if (m_allowGridGods) | 489 | if (m_allowGridGods) |
470 | { | 490 | { |
471 | ScenePresence sp = m_scene.GetScenePresence(user); | 491 | ScenePresence sp = m_scene.GetScenePresence(user); |
472 | if (sp != null) | 492 | if (sp != null) |
473 | { | 493 | return (sp.UserLevel >= 200); |
474 | if (sp.UserLevel >= 200) | ||
475 | return true; | ||
476 | return false; | ||
477 | } | ||
478 | 494 | ||
479 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user); | 495 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user); |
480 | if (account != null) | 496 | if (account != null) |
481 | { | 497 | return (account.UserLevel >= 200); |
482 | if (account.UserLevel >= 200) | ||
483 | return true; | ||
484 | } | ||
485 | } | 498 | } |
486 | 499 | ||
487 | return false; | 500 | return false; |
@@ -503,7 +516,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
503 | { | 516 | { |
504 | if (user == UUID.Zero) return false; | 517 | if (user == UUID.Zero) return false; |
505 | 518 | ||
506 | return m_scene.RegionInfo.EstateSettings.IsEstateManager(user); | 519 | return m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(user); |
507 | } | 520 | } |
508 | 521 | ||
509 | #endregion | 522 | #endregion |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index d1d2020..7825e3e 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -343,7 +343,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | |||
343 | public void Init() | 343 | public void Init() |
344 | { | 344 | { |
345 | m_serialiserModule = new SerialiserModule(); | 345 | m_serialiserModule = new SerialiserModule(); |
346 | m_scene = SceneHelpers.SetupScene(); | 346 | m_scene = new SceneHelpers().SetupScene(); |
347 | SceneHelpers.SetupSceneModules(m_scene, m_serialiserModule); | 347 | SceneHelpers.SetupSceneModules(m_scene, m_serialiserModule); |
348 | } | 348 | } |
349 | 349 | ||
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs index da81dc1..d78ade5 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/GenericSystemDrawing.cs | |||
@@ -59,28 +59,32 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
59 | /// <returns>A terrain channel generated from the image.</returns> | 59 | /// <returns>A terrain channel generated from the image.</returns> |
60 | public virtual ITerrainChannel LoadFile(string filename) | 60 | public virtual ITerrainChannel LoadFile(string filename) |
61 | { | 61 | { |
62 | return LoadBitmap(new Bitmap(filename)); | 62 | using (Bitmap b = new Bitmap(filename)) |
63 | return LoadBitmap(b); | ||
63 | } | 64 | } |
64 | 65 | ||
65 | public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h) | 66 | public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h) |
66 | { | 67 | { |
67 | Bitmap bitmap = new Bitmap(filename); | 68 | using (Bitmap bitmap = new Bitmap(filename)) |
68 | ITerrainChannel retval = new TerrainChannel(true); | ||
69 | |||
70 | for (int x = 0; x < retval.Width; x++) | ||
71 | { | 69 | { |
72 | for (int y = 0; y < retval.Height; y++) | 70 | ITerrainChannel retval = new TerrainChannel(true); |
71 | |||
72 | for (int x = 0; x < retval.Width; x++) | ||
73 | { | 73 | { |
74 | retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; | 74 | for (int y = 0; y < retval.Height; y++) |
75 | { | ||
76 | retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128; | ||
77 | } | ||
75 | } | 78 | } |
76 | } | ||
77 | 79 | ||
78 | return retval; | 80 | return retval; |
81 | } | ||
79 | } | 82 | } |
80 | 83 | ||
81 | public virtual ITerrainChannel LoadStream(Stream stream) | 84 | public virtual ITerrainChannel LoadStream(Stream stream) |
82 | { | 85 | { |
83 | return LoadBitmap(new Bitmap(stream)); | 86 | using (Bitmap b = new Bitmap(stream)) |
87 | return LoadBitmap(b); | ||
84 | } | 88 | } |
85 | 89 | ||
86 | protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap) | 90 | protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap) |
@@ -134,35 +138,53 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
134 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." | 138 | // "Saving the image to the same file it was constructed from is not allowed and throws an exception." |
135 | string tempName = Path.GetTempFileName(); | 139 | string tempName = Path.GetTempFileName(); |
136 | 140 | ||
137 | Bitmap entireBitmap = null; | 141 | Bitmap existingBitmap = null; |
138 | Bitmap thisBitmap = null; | 142 | Bitmap thisBitmap = null; |
139 | if (File.Exists(filename)) | 143 | Bitmap newBitmap = null; |
144 | |||
145 | try | ||
140 | { | 146 | { |
141 | File.Copy(filename, tempName, true); | 147 | if (File.Exists(filename)) |
142 | entireBitmap = new Bitmap(tempName); | 148 | { |
143 | if (entireBitmap.Width != fileWidth * regionSizeX || entireBitmap.Height != fileHeight * regionSizeY) | 149 | File.Copy(filename, tempName, true); |
150 | existingBitmap = new Bitmap(tempName); | ||
151 | if (existingBitmap.Width != fileWidth * regionSizeX || existingBitmap.Height != fileHeight * regionSizeY) | ||
152 | { | ||
153 | // old file, let's overwrite it | ||
154 | newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | newBitmap = existingBitmap; | ||
159 | } | ||
160 | } | ||
161 | else | ||
144 | { | 162 | { |
145 | // old file, let's overwrite it | 163 | newBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); |
146 | entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | ||
147 | } | 164 | } |
165 | |||
166 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); | ||
167 | // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); | ||
168 | for (int x = 0; x < regionSizeX; x++) | ||
169 | for (int y = 0; y < regionSizeY; y++) | ||
170 | newBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); | ||
171 | |||
172 | Save(newBitmap, filename); | ||
148 | } | 173 | } |
149 | else | 174 | finally |
150 | { | 175 | { |
151 | entireBitmap = new Bitmap(fileWidth * regionSizeX, fileHeight * regionSizeY); | 176 | if (existingBitmap != null) |
152 | } | 177 | existingBitmap.Dispose(); |
153 | 178 | ||
154 | thisBitmap = CreateGrayscaleBitmapFromMap(m_channel); | 179 | if (thisBitmap != null) |
155 | // Console.WriteLine("offsetX=" + offsetX + " offsetY=" + offsetY); | 180 | thisBitmap.Dispose(); |
156 | for (int x = 0; x < regionSizeX; x++) | ||
157 | for (int y = 0; y < regionSizeY; y++) | ||
158 | entireBitmap.SetPixel(x + offsetX * regionSizeX, y + (fileHeight - 1 - offsetY) * regionSizeY, thisBitmap.GetPixel(x, y)); | ||
159 | 181 | ||
160 | Save(entireBitmap, filename); | 182 | if (newBitmap != null) |
161 | thisBitmap.Dispose(); | 183 | newBitmap.Dispose(); |
162 | entireBitmap.Dispose(); | ||
163 | 184 | ||
164 | if (File.Exists(tempName)) | 185 | if (File.Exists(tempName)) |
165 | File.Delete(tempName); | 186 | File.Delete(tempName); |
187 | } | ||
166 | } | 188 | } |
167 | 189 | ||
168 | protected virtual void Save(Bitmap bmp, string filename) | 190 | protected virtual void Save(Bitmap bmp, string filename) |
@@ -226,16 +248,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
226 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> | 248 | /// <returns>A System.Drawing.Bitmap containing a coloured image</returns> |
227 | protected static Bitmap CreateBitmapFromMap(ITerrainChannel map) | 249 | protected static Bitmap CreateBitmapFromMap(ITerrainChannel map) |
228 | { | 250 | { |
229 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 251 | int pallete; |
230 | 252 | Bitmap bmp; | |
231 | int pallete = gradientmapLd.Height; | 253 | Color[] colours; |
232 | 254 | ||
233 | Bitmap bmp = new Bitmap(map.Width, map.Height); | 255 | using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png")) |
234 | Color[] colours = new Color[pallete]; | ||
235 | |||
236 | for (int i = 0; i < pallete; i++) | ||
237 | { | 256 | { |
238 | colours[i] = gradientmapLd.GetPixel(0, i); | 257 | pallete = gradientmapLd.Height; |
258 | |||
259 | bmp = new Bitmap(map.Width, map.Height); | ||
260 | colours = new Color[pallete]; | ||
261 | |||
262 | for (int i = 0; i < pallete; i++) | ||
263 | { | ||
264 | colours[i] = gradientmapLd.GetPixel(0, i); | ||
265 | } | ||
239 | } | 266 | } |
240 | 267 | ||
241 | for (int y = 0; y < map.Height; y++) | 268 | for (int y = 0; y < map.Height; y++) |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs index 699d67a..9cc767a 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/JPEG.cs | |||
@@ -99,16 +99,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
99 | 99 | ||
100 | private static Bitmap CreateBitmapFromMap(ITerrainChannel map) | 100 | private static Bitmap CreateBitmapFromMap(ITerrainChannel map) |
101 | { | 101 | { |
102 | Bitmap gradientmapLd = new Bitmap("defaultstripe.png"); | 102 | int pallete; |
103 | Bitmap bmp; | ||
104 | Color[] colours; | ||
103 | 105 | ||
104 | int pallete = gradientmapLd.Height; | 106 | using (Bitmap gradientmapLd = new Bitmap("defaultstripe.png")) |
105 | |||
106 | Bitmap bmp = new Bitmap(map.Width, map.Height); | ||
107 | Color[] colours = new Color[pallete]; | ||
108 | |||
109 | for (int i = 0; i < pallete; i++) | ||
110 | { | 107 | { |
111 | colours[i] = gradientmapLd.GetPixel(0, i); | 108 | pallete = gradientmapLd.Height; |
109 | |||
110 | bmp = new Bitmap(map.Width, map.Height); | ||
111 | colours = new Color[pallete]; | ||
112 | |||
113 | for (int i = 0; i < pallete; i++) | ||
114 | { | ||
115 | colours[i] = gradientmapLd.GetPixel(0, i); | ||
116 | } | ||
112 | } | 117 | } |
113 | 118 | ||
114 | for (int y = 0; y < map.Height; y++) | 119 | for (int y = 0; y < map.Height; y++) |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 32f4eea..8732ec0 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -174,7 +174,17 @@ namespace OpenSim.Region.Framework.Interfaces | |||
174 | /// If no inventory item has that name then an empty list is returned. | 174 | /// If no inventory item has that name then an empty list is returned. |
175 | /// </returns> | 175 | /// </returns> |
176 | List<TaskInventoryItem> GetInventoryItems(string name); | 176 | List<TaskInventoryItem> GetInventoryItems(string name); |
177 | 177 | ||
178 | /// <summary> | ||
179 | /// Get inventory items by type. | ||
180 | /// </summary> | ||
181 | /// <param type="name"></param> | ||
182 | /// <returns> | ||
183 | /// A list of inventory items of that type. | ||
184 | /// If no inventory items of that type then an empty list is returned. | ||
185 | /// </returns> | ||
186 | List<TaskInventoryItem> GetInventoryItems(InventoryType type); | ||
187 | |||
178 | /// <summary> | 188 | /// <summary> |
179 | /// Get the scene object referenced by an inventory item. | 189 | /// Get the scene object referenced by an inventory item. |
180 | /// </summary> | 190 | /// </summary> |
@@ -228,6 +238,16 @@ namespace OpenSim.Region.Framework.Interfaces | |||
228 | bool ContainsScripts(); | 238 | bool ContainsScripts(); |
229 | 239 | ||
230 | /// <summary> | 240 | /// <summary> |
241 | /// Returns the count of scripts contained | ||
242 | /// </summary></returns> | ||
243 | int ScriptCount(); | ||
244 | |||
245 | /// <summary> | ||
246 | /// Returns the count of running scripts contained | ||
247 | /// </summary></returns> | ||
248 | int RunningScriptCount(); | ||
249 | |||
250 | /// <summary> | ||
231 | /// Get the uuids of all items in this inventory | 251 | /// Get the uuids of all items in this inventory |
232 | /// </summary> | 252 | /// </summary> |
233 | /// <returns></returns> | 253 | /// <returns></returns> |
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs index 72e79ed..ca2ad94 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs | |||
@@ -47,5 +47,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
47 | void sendRegionHandshakeToAll(); | 47 | void sendRegionHandshakeToAll(); |
48 | void TriggerEstateInfoChange(); | 48 | void TriggerEstateInfoChange(); |
49 | void TriggerRegionInfoChange(); | 49 | void TriggerRegionInfoChange(); |
50 | |||
51 | void setEstateTerrainBaseTexture(int level, UUID texture); | ||
52 | void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue); | ||
50 | } | 53 | } |
51 | } | 54 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs new file mode 100644 index 0000000..baac6e8 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Framework.Interfaces | ||
33 | { | ||
34 | public delegate void TakeValueCallback(string s); | ||
35 | |||
36 | public interface IJsonStoreModule | ||
37 | { | ||
38 | bool CreateStore(string value, out UUID result); | ||
39 | bool DestroyStore(UUID storeID); | ||
40 | bool TestPath(UUID storeID, string path, bool useJson); | ||
41 | bool SetValue(UUID storeID, string path, string value, bool useJson); | ||
42 | bool RemoveValue(UUID storeID, string path); | ||
43 | bool GetValue(UUID storeID, string path, bool useJson, out string value); | ||
44 | |||
45 | void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); | ||
46 | void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index dc3ff89..b4dc3c3 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs | |||
@@ -135,6 +135,36 @@ namespace OpenSim.Region.Framework.Interfaces | |||
135 | bool Say(UUID agentID, Scene scene, string text); | 135 | bool Say(UUID agentID, Scene scene, string text); |
136 | 136 | ||
137 | /// <summary> | 137 | /// <summary> |
138 | /// Get the NPC to say something. | ||
139 | /// </summary> | ||
140 | /// <param name="agentID">The UUID of the NPC</param> | ||
141 | /// <param name="scene"></param> | ||
142 | /// <param name="text"></param> | ||
143 | /// <param name="channel"></param> | ||
144 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | ||
145 | bool Say(UUID agentID, Scene scene, string text, int channel); | ||
146 | |||
147 | /// <summary> | ||
148 | /// Get the NPC to shout something. | ||
149 | /// </summary> | ||
150 | /// <param name="agentID">The UUID of the NPC</param> | ||
151 | /// <param name="scene"></param> | ||
152 | /// <param name="text"></param> | ||
153 | /// <param name="channel"></param> | ||
154 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | ||
155 | bool Shout(UUID agentID, Scene scene, string text, int channel); | ||
156 | |||
157 | /// <summary> | ||
158 | /// Get the NPC to whisper something. | ||
159 | /// </summary> | ||
160 | /// <param name="agentID">The UUID of the NPC</param> | ||
161 | /// <param name="scene"></param> | ||
162 | /// <param name="text"></param> | ||
163 | /// <param name="channel"></param> | ||
164 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | ||
165 | bool Whisper(UUID agentID, Scene scene, string text, int channel); | ||
166 | |||
167 | /// <summary> | ||
138 | /// Sit the NPC. | 168 | /// Sit the NPC. |
139 | /// </summary> | 169 | /// </summary> |
140 | /// <param name="agentID"></param> | 170 | /// <param name="agentID"></param> |
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index ce66100..143af48 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -71,6 +71,12 @@ namespace OpenSim.Region.Framework.Interfaces | |||
71 | 71 | ||
72 | bool HasScript(UUID itemID, out bool running); | 72 | bool HasScript(UUID itemID, out bool running); |
73 | 73 | ||
74 | /// <summary> | ||
75 | /// Returns true if a script is running. | ||
76 | /// </summary> | ||
77 | /// <param name="itemID">The item ID of the script.</param> | ||
78 | bool GetScriptState(UUID itemID); | ||
79 | |||
74 | void SaveAllState(); | 80 | void SaveAllState(); |
75 | 81 | ||
76 | /// <summary> | 82 | /// <summary> |
@@ -79,6 +85,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
79 | void StartProcessing(); | 85 | void StartProcessing(); |
80 | 86 | ||
81 | /// <summary> | 87 | /// <summary> |
88 | /// Get the execution times of all scripts in the given array if they are currently running. | ||
89 | /// </summary> | ||
90 | /// <returns> | ||
91 | /// A float the value is a representative execution time in milliseconds of all scripts in that Array. | ||
92 | /// </returns> | ||
93 | float GetScriptExecutionTime(List<UUID> itemIDs); | ||
94 | |||
95 | /// <summary> | ||
82 | /// Get the execution times of all scripts in each object. | 96 | /// Get the execution times of all scripts in each object. |
83 | /// </summary> | 97 | /// </summary> |
84 | /// <returns> | 98 | /// <returns> |
@@ -87,4 +101,4 @@ namespace OpenSim.Region.Framework.Interfaces | |||
87 | /// </returns> | 101 | /// </returns> |
88 | Dictionary<uint, float> GetObjectScriptsExecutionTimes(); | 102 | Dictionary<uint, float> GetObjectScriptsExecutionTimes(); |
89 | } | 103 | } |
90 | } \ No newline at end of file | 104 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index e8e375e..4e74781 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs | |||
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
103 | /// <param name='msg'> | 103 | /// <param name='msg'> |
104 | /// Message. | 104 | /// Message. |
105 | /// </param> | 105 | /// </param> |
106 | bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); | 106 | void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg); |
107 | 107 | ||
108 | /// <summary> | 108 | /// <summary> |
109 | /// Are there any listen events ready to be dispatched? | 109 | /// Are there any listen events ready to be dispatched? |
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index f5623bd..14ae287 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -278,6 +278,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
278 | return "FALLDOWN"; | 278 | return "FALLDOWN"; |
279 | } | 279 | } |
280 | 280 | ||
281 | // Check if the user has stopped walking just now | ||
282 | if (CurrentMovementAnimation == "WALK" && (move == Vector3.Zero)) | ||
283 | return "STAND"; | ||
284 | |||
281 | return CurrentMovementAnimation; | 285 | return CurrentMovementAnimation; |
282 | } | 286 | } |
283 | 287 | ||
@@ -402,13 +406,16 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
402 | /// </summary> | 406 | /// </summary> |
403 | public void UpdateMovementAnimations() | 407 | public void UpdateMovementAnimations() |
404 | { | 408 | { |
405 | CurrentMovementAnimation = DetermineMovementAnimation(); | 409 | lock (m_animations) |
410 | { | ||
411 | CurrentMovementAnimation = DetermineMovementAnimation(); | ||
406 | 412 | ||
407 | // m_log.DebugFormat( | 413 | // m_log.DebugFormat( |
408 | // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", | 414 | // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", |
409 | // CurrentMovementAnimation, m_scenePresence.Name); | 415 | // CurrentMovementAnimation, m_scenePresence.Name); |
410 | 416 | ||
411 | TrySetMovementAnimation(CurrentMovementAnimation); | 417 | TrySetMovementAnimation(CurrentMovementAnimation); |
418 | } | ||
412 | } | 419 | } |
413 | 420 | ||
414 | public UUID[] GetAnimationArray() | 421 | public UUID[] GetAnimationArray() |
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index f678d07..834464b 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs | |||
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | 117 | ||
118 | private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) | 118 | private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) |
119 | { | 119 | { |
120 | m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop"); | 120 | // m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop"); |
121 | 121 | ||
122 | // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved | 122 | // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved |
123 | // in a culture where decimal points are commas and then reloaded in a culture which just treats them as | 123 | // in a culture where decimal points are commas and then reloaded in a culture which just treats them as |
@@ -147,9 +147,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
147 | { | 147 | { |
148 | x = m_inventoryDeletes.Dequeue(); | 148 | x = m_inventoryDeletes.Dequeue(); |
149 | 149 | ||
150 | m_log.DebugFormat( | 150 | // m_log.DebugFormat( |
151 | "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", | 151 | // "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", |
152 | left, x.action, x.objectGroups.Count); | 152 | // left, x.action, x.objectGroups.Count); |
153 | 153 | ||
154 | try | 154 | try |
155 | { | 155 | { |
@@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
185 | e.StackTrace); | 185 | e.StackTrace); |
186 | } | 186 | } |
187 | 187 | ||
188 | m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue."); | 188 | // m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue."); |
189 | 189 | ||
190 | return false; | 190 | return false; |
191 | } | 191 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 3ef1e29..cf68ff4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -38,8 +38,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
38 | { | 38 | { |
39 | public partial class Scene | 39 | public partial class Scene |
40 | { | 40 | { |
41 | |||
41 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 42 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
42 | UUID fromID, bool fromAgent, bool broadcast) | 43 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) |
43 | { | 44 | { |
44 | OSChatMessage args = new OSChatMessage(); | 45 | OSChatMessage args = new OSChatMessage(); |
45 | 46 | ||
@@ -63,14 +64,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
63 | } | 64 | } |
64 | 65 | ||
65 | args.From = fromName; | 66 | args.From = fromName; |
66 | //args. | 67 | args.TargetUUID = targetID; |
67 | 68 | ||
68 | if (broadcast) | 69 | if (broadcast) |
69 | EventManager.TriggerOnChatBroadcast(this, args); | 70 | EventManager.TriggerOnChatBroadcast(this, args); |
70 | else | 71 | else |
71 | EventManager.TriggerOnChatFromWorld(this, args); | 72 | EventManager.TriggerOnChatFromWorld(this, args); |
72 | } | 73 | } |
73 | 74 | ||
75 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | ||
76 | UUID fromID, bool fromAgent, bool broadcast) | ||
77 | { | ||
78 | SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast); | ||
79 | } | ||
80 | |||
74 | /// <summary> | 81 | /// <summary> |
75 | /// | 82 | /// |
76 | /// </summary> | 83 | /// </summary> |
@@ -108,6 +115,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
108 | { | 115 | { |
109 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); | 116 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); |
110 | } | 117 | } |
118 | /// <summary> | ||
119 | /// | ||
120 | /// </summary> | ||
121 | /// <param name="message"></param> | ||
122 | /// <param name="type"></param> | ||
123 | /// <param name="fromPos"></param> | ||
124 | /// <param name="fromName"></param> | ||
125 | /// <param name="fromAgentID"></param> | ||
126 | /// <param name="targetID"></param> | ||
127 | public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) | ||
128 | { | ||
129 | SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); | ||
130 | } | ||
111 | 131 | ||
112 | /// <summary> | 132 | /// <summary> |
113 | /// Invoked when the client requests a prim. | 133 | /// Invoked when the client requests a prim. |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index e1fedf4..535d87a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | |||
@@ -67,6 +67,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
67 | public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); | 67 | public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); |
68 | public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); | 68 | public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); |
69 | public delegate bool IsGodHandler(UUID user, Scene requestFromScene); | 69 | public delegate bool IsGodHandler(UUID user, Scene requestFromScene); |
70 | public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene); | ||
70 | public delegate bool IsAdministratorHandler(UUID user); | 71 | public delegate bool IsAdministratorHandler(UUID user); |
71 | public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); | 72 | public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); |
72 | public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); | 73 | public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); |
@@ -134,6 +135,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | public event RunConsoleCommandHandler OnRunConsoleCommand; | 135 | public event RunConsoleCommandHandler OnRunConsoleCommand; |
135 | public event IssueEstateCommandHandler OnIssueEstateCommand; | 136 | public event IssueEstateCommandHandler OnIssueEstateCommand; |
136 | public event IsGodHandler OnIsGod; | 137 | public event IsGodHandler OnIsGod; |
138 | public event IsGridGodHandler OnIsGridGod; | ||
137 | public event IsAdministratorHandler OnIsAdministrator; | 139 | public event IsAdministratorHandler OnIsAdministrator; |
138 | // public event EditParcelHandler OnEditParcel; | 140 | // public event EditParcelHandler OnEditParcel; |
139 | public event EditParcelPropertiesHandler OnEditParcelProperties; | 141 | public event EditParcelPropertiesHandler OnEditParcelProperties; |
@@ -728,6 +730,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | return true; | 730 | return true; |
729 | } | 731 | } |
730 | 732 | ||
733 | public bool IsGridGod(UUID user) | ||
734 | { | ||
735 | IsGridGodHandler handler = OnIsGridGod; | ||
736 | if (handler != null) | ||
737 | { | ||
738 | Delegate[] list = handler.GetInvocationList(); | ||
739 | foreach (IsGridGodHandler h in list) | ||
740 | { | ||
741 | if (h(user, m_scene) == false) | ||
742 | return false; | ||
743 | } | ||
744 | } | ||
745 | return true; | ||
746 | } | ||
747 | |||
731 | public bool IsAdministrator(UUID user) | 748 | public bool IsAdministrator(UUID user) |
732 | { | 749 | { |
733 | IsAdministratorHandler handler = OnIsAdministrator; | 750 | IsAdministratorHandler handler = OnIsAdministrator; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a9a4cda..ff2c46f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -103,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | public bool m_trustBinaries; | 103 | public bool m_trustBinaries; |
104 | public bool m_allowScriptCrossings; | 104 | public bool m_allowScriptCrossings; |
105 | public bool m_useFlySlow; | 105 | public bool m_useFlySlow; |
106 | public bool m_useTrashOnDelete = true; | ||
106 | 107 | ||
107 | /// <summary> | 108 | /// <summary> |
108 | /// Temporarily setting to trigger appearance resends at 60 second intervals. | 109 | /// Temporarily setting to trigger appearance resends at 60 second intervals. |
@@ -458,6 +459,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | { | 459 | { |
459 | if (m_simulationService == null) | 460 | if (m_simulationService == null) |
460 | m_simulationService = RequestModuleInterface<ISimulationService>(); | 461 | m_simulationService = RequestModuleInterface<ISimulationService>(); |
462 | |||
461 | return m_simulationService; | 463 | return m_simulationService; |
462 | } | 464 | } |
463 | } | 465 | } |
@@ -735,6 +737,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
735 | m_clampPrimSize = true; | 737 | m_clampPrimSize = true; |
736 | } | 738 | } |
737 | 739 | ||
740 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); | ||
738 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 741 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
739 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 742 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
740 | m_dontPersistBefore = | 743 | m_dontPersistBefore = |
@@ -833,13 +836,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
833 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 836 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
834 | } | 837 | } |
835 | 838 | ||
836 | /// <summary> | ||
837 | /// Mock constructor for scene group persistency unit tests. | ||
838 | /// SceneObjectGroup RegionId property is delegated to Scene. | ||
839 | /// </summary> | ||
840 | /// <param name="regInfo"></param> | ||
841 | public Scene(RegionInfo regInfo) | 839 | public Scene(RegionInfo regInfo) |
842 | { | 840 | { |
841 | PhysicalPrims = true; | ||
842 | CollidablePrims = true; | ||
843 | |||
843 | BordersLocked = true; | 844 | BordersLocked = true; |
844 | Border northBorder = new Border(); | 845 | Border northBorder = new Border(); |
845 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- | 846 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- |
@@ -866,8 +867,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
866 | m_eventManager = new EventManager(); | 867 | m_eventManager = new EventManager(); |
867 | 868 | ||
868 | m_permissions = new ScenePermissions(this); | 869 | m_permissions = new ScenePermissions(this); |
869 | |||
870 | // m_lastUpdate = Util.EnvironmentTickCount(); | ||
871 | } | 870 | } |
872 | 871 | ||
873 | #endregion | 872 | #endregion |
@@ -3382,8 +3381,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3382 | try | 3381 | try |
3383 | { | 3382 | { |
3384 | m_log.DebugFormat( | 3383 | m_log.DebugFormat( |
3385 | "[SCENE]: Removing {0} agent {1} from region {2}", | 3384 | "[SCENE]: Removing {0} agent {1} {2} from region {3}", |
3386 | (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName); | 3385 | (isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName); |
3387 | 3386 | ||
3388 | m_sceneGraph.removeUserCount(!isChildAgent); | 3387 | m_sceneGraph.removeUserCount(!isChildAgent); |
3389 | 3388 | ||
@@ -3981,41 +3980,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
3981 | return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); | 3980 | return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); |
3982 | } | 3981 | } |
3983 | 3982 | ||
3984 | /// <summary> | 3983 | // /// <summary> |
3985 | /// The Grid has requested that we log-off a user. Log them off. | 3984 | // /// The Grid has requested that we log-off a user. Log them off. |
3986 | /// </summary> | 3985 | // /// </summary> |
3987 | /// <param name="AvatarID">Unique ID of the avatar to log-off</param> | 3986 | // /// <param name="AvatarID">Unique ID of the avatar to log-off</param> |
3988 | /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> | 3987 | // /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> |
3989 | /// <param name="message">message to display to the user. Reason for being logged off</param> | 3988 | // /// <param name="message">message to display to the user. Reason for being logged off</param> |
3990 | public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) | 3989 | // public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) |
3991 | { | 3990 | // { |
3992 | ScenePresence loggingOffUser = GetScenePresence(AvatarID); | 3991 | // ScenePresence loggingOffUser = GetScenePresence(AvatarID); |
3993 | if (loggingOffUser != null) | 3992 | // if (loggingOffUser != null) |
3994 | { | 3993 | // { |
3995 | UUID localRegionSecret = UUID.Zero; | 3994 | // UUID localRegionSecret = UUID.Zero; |
3996 | bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); | 3995 | // bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); |
3997 | 3996 | // | |
3998 | // Region Secret is used here in case a new sessionid overwrites an old one on the user server. | 3997 | // // Region Secret is used here in case a new sessionid overwrites an old one on the user server. |
3999 | // Will update the user server in a few revisions to use it. | 3998 | // // Will update the user server in a few revisions to use it. |
4000 | 3999 | // | |
4001 | if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) | 4000 | // if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) |
4002 | { | 4001 | // { |
4003 | m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); | 4002 | // m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); |
4004 | loggingOffUser.ControllingClient.Kick(message); | 4003 | // loggingOffUser.ControllingClient.Kick(message); |
4005 | // Give them a second to receive the message! | 4004 | // // Give them a second to receive the message! |
4006 | Thread.Sleep(1000); | 4005 | // Thread.Sleep(1000); |
4007 | loggingOffUser.ControllingClient.Close(); | 4006 | // loggingOffUser.ControllingClient.Close(); |
4008 | } | 4007 | // } |
4009 | else | 4008 | // else |
4010 | { | 4009 | // { |
4011 | m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); | 4010 | // m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); |
4012 | } | 4011 | // } |
4013 | } | 4012 | // } |
4014 | else | 4013 | // else |
4015 | { | 4014 | // { |
4016 | m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); | 4015 | // m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); |
4017 | } | 4016 | // } |
4018 | } | 4017 | // } |
4019 | 4018 | ||
4020 | /// <summary> | 4019 | /// <summary> |
4021 | /// Triggered when an agent crosses into this sim. Also happens on initial login. | 4020 | /// Triggered when an agent crosses into this sim. Also happens on initial login. |
@@ -4071,7 +4070,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
4071 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4070 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4072 | if (nearestParcel == null) | 4071 | if (nearestParcel == null) |
4073 | { | 4072 | { |
4074 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); | 4073 | m_log.DebugFormat( |
4074 | "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel", | ||
4075 | cAgentData.AgentID, RegionInfo.RegionName); | ||
4076 | |||
4075 | return false; | 4077 | return false; |
4076 | } | 4078 | } |
4077 | 4079 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index b806d91..77e808e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -156,7 +156,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | // that the region position is cached or performance will degrade | 156 | // that the region position is cached or performance will degrade |
157 | Utils.LongToUInts(regionHandle, out x, out y); | 157 | Utils.LongToUInts(regionHandle, out x, out y); |
158 | GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | 158 | GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); |
159 | // bool v = true; | 159 | if (dest == null) |
160 | continue; | ||
161 | |||
160 | if (!simulatorList.Contains(dest.ServerURI)) | 162 | if (!simulatorList.Contains(dest.ServerURI)) |
161 | { | 163 | { |
162 | // we havent seen this simulator before, add it to the list | 164 | // we havent seen this simulator before, add it to the list |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index d4965ea..982913a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -101,6 +101,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | /// </summary> | 101 | /// </summary> |
102 | protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); | 102 | protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); |
103 | 103 | ||
104 | /// <summary> | ||
105 | /// Lock to prevent object group update, linking and delinking operations from running concurrently. | ||
106 | /// </summary> | ||
104 | private Object m_updateLock = new Object(); | 107 | private Object m_updateLock = new Object(); |
105 | 108 | ||
106 | #endregion | 109 | #endregion |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 76804d7..dce20c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2629,6 +2629,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2629 | /// <summary> | 2629 | /// <summary> |
2630 | /// Link the prims in a given group to this group | 2630 | /// Link the prims in a given group to this group |
2631 | /// </summary> | 2631 | /// </summary> |
2632 | /// <remarks> | ||
2633 | /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads. | ||
2634 | /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition. | ||
2635 | /// </remarks> | ||
2632 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> | 2636 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> |
2633 | public void LinkToGroup(SceneObjectGroup objectGroup) | 2637 | public void LinkToGroup(SceneObjectGroup objectGroup) |
2634 | { | 2638 | { |
@@ -2710,6 +2714,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2710 | } | 2714 | } |
2711 | 2715 | ||
2712 | linkPart.LinkNum = linkNum++; | 2716 | linkPart.LinkNum = linkNum++; |
2717 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2713 | 2718 | ||
2714 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2719 | SceneObjectPart[] ogParts = objectGroup.Parts; |
2715 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) | 2720 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) |
@@ -2761,6 +2766,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2761 | /// Delink the given prim from this group. The delinked prim is established as | 2766 | /// Delink the given prim from this group. The delinked prim is established as |
2762 | /// an independent SceneObjectGroup. | 2767 | /// an independent SceneObjectGroup. |
2763 | /// </summary> | 2768 | /// </summary> |
2769 | /// <remarks> | ||
2770 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2771 | /// condition. But currently there is no | ||
2772 | /// alternative method that does take a lonk to delink a single prim. | ||
2773 | /// </remarks> | ||
2764 | /// <param name="partID"></param> | 2774 | /// <param name="partID"></param> |
2765 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2775 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
2766 | public SceneObjectGroup DelinkFromGroup(uint partID) | 2776 | public SceneObjectGroup DelinkFromGroup(uint partID) |
@@ -2772,6 +2782,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2772 | /// Delink the given prim from this group. The delinked prim is established as | 2782 | /// Delink the given prim from this group. The delinked prim is established as |
2773 | /// an independent SceneObjectGroup. | 2783 | /// an independent SceneObjectGroup. |
2774 | /// </summary> | 2784 | /// </summary> |
2785 | /// <remarks> | ||
2786 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2787 | /// condition. But currently there is no | ||
2788 | /// alternative method that does take a lonk to delink a single prim. | ||
2789 | /// </remarks> | ||
2775 | /// <param name="partID"></param> | 2790 | /// <param name="partID"></param> |
2776 | /// <param name="sendEvents"></param> | 2791 | /// <param name="sendEvents"></param> |
2777 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2792 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
@@ -2797,6 +2812,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2797 | /// Delink the given prim from this group. The delinked prim is established as | 2812 | /// Delink the given prim from this group. The delinked prim is established as |
2798 | /// an independent SceneObjectGroup. | 2813 | /// an independent SceneObjectGroup. |
2799 | /// </summary> | 2814 | /// </summary> |
2815 | /// <remarks> | ||
2816 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2817 | /// condition. But currently there is no | ||
2818 | /// alternative method that does take a lonk to delink a single prim. | ||
2819 | /// </remarks> | ||
2800 | /// <param name="partID"></param> | 2820 | /// <param name="partID"></param> |
2801 | /// <param name="sendEvents"></param> | 2821 | /// <param name="sendEvents"></param> |
2802 | /// <returns>The object group of the newly delinked prim.</returns> | 2822 | /// <returns>The object group of the newly delinked prim.</returns> |
@@ -2930,6 +2950,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2930 | oldRot = part.RotationOffset; | 2950 | oldRot = part.RotationOffset; |
2931 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; | 2951 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2932 | part.RotationOffset = newRot; | 2952 | part.RotationOffset = newRot; |
2953 | |||
2954 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2933 | } | 2955 | } |
2934 | 2956 | ||
2935 | /// <summary> | 2957 | /// <summary> |
@@ -4140,7 +4162,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
4140 | for (int i = 0; i < parts.Length; i++) | 4162 | for (int i = 0; i < parts.Length; i++) |
4141 | parts[i].TriggerScriptChangedEvent(val); | 4163 | parts[i].TriggerScriptChangedEvent(val); |
4142 | } | 4164 | } |
4143 | 4165 | ||
4166 | /// <summary> | ||
4167 | /// Returns a count of the number of scripts in this groups parts. | ||
4168 | /// </summary> | ||
4169 | public int ScriptCount() | ||
4170 | { | ||
4171 | int count = 0; | ||
4172 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4173 | for (int i = 0; i < parts.Length; i++) | ||
4174 | count += parts[i].Inventory.ScriptCount(); | ||
4175 | |||
4176 | return count; | ||
4177 | } | ||
4178 | |||
4179 | /// <summary> | ||
4180 | /// A float the value is a representative execution time in milliseconds of all scripts in the link set. | ||
4181 | /// </summary> | ||
4182 | public float ScriptExecutionTime() | ||
4183 | { | ||
4184 | IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>(); | ||
4185 | |||
4186 | if (engines.Length == 0) // No engine at all | ||
4187 | return 0.0f; | ||
4188 | |||
4189 | float time = 0.0f; | ||
4190 | |||
4191 | // get all the scripts in all parts | ||
4192 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4193 | List<TaskInventoryItem> scripts = new List<TaskInventoryItem>(); | ||
4194 | for (int i = 0; i < parts.Length; i++) | ||
4195 | { | ||
4196 | scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); | ||
4197 | } | ||
4198 | // extract the UUIDs | ||
4199 | List<UUID> ids = new List<UUID>(scripts.Count); | ||
4200 | foreach (TaskInventoryItem script in scripts) | ||
4201 | { | ||
4202 | if (!ids.Contains(script.ItemID)) | ||
4203 | { | ||
4204 | ids.Add(script.ItemID); | ||
4205 | } | ||
4206 | } | ||
4207 | // Offer the list of script UUIDs to each engine found and accumulate the time | ||
4208 | foreach (IScriptModule e in engines) | ||
4209 | { | ||
4210 | if (e != null) | ||
4211 | { | ||
4212 | time += e.GetScriptExecutionTime(ids); | ||
4213 | } | ||
4214 | } | ||
4215 | return time; | ||
4216 | } | ||
4217 | |||
4218 | /// <summary> | ||
4219 | /// Returns a count of the number of running scripts in this groups parts. | ||
4220 | /// </summary> | ||
4221 | public int RunningScriptCount() | ||
4222 | { | ||
4223 | int count = 0; | ||
4224 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4225 | for (int i = 0; i < parts.Length; i++) | ||
4226 | count += parts[i].Inventory.RunningScriptCount(); | ||
4227 | |||
4228 | return count; | ||
4229 | } | ||
4230 | |||
4144 | public override string ToString() | 4231 | public override string ToString() |
4145 | { | 4232 | { |
4146 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); | 4233 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b0bc188..843c426 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2091,6 +2091,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2091 | /// <param name="isNew"></param> | 2091 | /// <param name="isNew"></param> |
2092 | public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) | 2092 | public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) |
2093 | { | 2093 | { |
2094 | if (ParentGroup.Scene == null) | ||
2095 | return; | ||
2096 | |||
2094 | if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) | 2097 | if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) |
2095 | return; | 2098 | return; |
2096 | 2099 | ||
@@ -4582,7 +4585,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4582 | // For now, we use the NINJA naming scheme for identifying joints. | 4585 | // For now, we use the NINJA naming scheme for identifying joints. |
4583 | // In the future, we can support other joint specification schemes such as a | 4586 | // In the future, we can support other joint specification schemes such as a |
4584 | // custom checkbox in the viewer GUI. | 4587 | // custom checkbox in the viewer GUI. |
4585 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4588 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4586 | { | 4589 | { |
4587 | string hingeString = "hingejoint"; | 4590 | string hingeString = "hingejoint"; |
4588 | return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); | 4591 | return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); |
@@ -4598,7 +4601,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4598 | // For now, we use the NINJA naming scheme for identifying joints. | 4601 | // For now, we use the NINJA naming scheme for identifying joints. |
4599 | // In the future, we can support other joint specification schemes such as a | 4602 | // In the future, we can support other joint specification schemes such as a |
4600 | // custom checkbox in the viewer GUI. | 4603 | // custom checkbox in the viewer GUI. |
4601 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4604 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4602 | { | 4605 | { |
4603 | string ballString = "balljoint"; | 4606 | string ballString = "balljoint"; |
4604 | return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); | 4607 | return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); |
@@ -4614,7 +4617,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4614 | // For now, we use the NINJA naming scheme for identifying joints. | 4617 | // For now, we use the NINJA naming scheme for identifying joints. |
4615 | // In the future, we can support other joint specification schemes such as a | 4618 | // In the future, we can support other joint specification schemes such as a |
4616 | // custom checkbox in the viewer GUI. | 4619 | // custom checkbox in the viewer GUI. |
4617 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4620 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4618 | { | 4621 | { |
4619 | return IsHingeJoint() || IsBallJoint(); | 4622 | return IsHingeJoint() || IsBallJoint(); |
4620 | } | 4623 | } |
@@ -4733,7 +4736,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4733 | } | 4736 | } |
4734 | } | 4737 | } |
4735 | } | 4738 | } |
4736 | |||
4737 | else // it already has a physical representation | 4739 | else // it already has a physical representation |
4738 | { | 4740 | { |
4739 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | 4741 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 959046a..a190efe 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -267,14 +267,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
267 | /// </summary> | 267 | /// </summary> |
268 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 268 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
269 | { | 269 | { |
270 | Items.LockItemsForRead(true); | 270 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
271 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 271 | foreach (TaskInventoryItem item in scripts) |
272 | Items.LockItemsForRead(false); | 272 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
273 | foreach (TaskInventoryItem item in items) | ||
274 | { | ||
275 | if ((int)InventoryType.LSL == item.InvType) | ||
276 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
277 | } | ||
278 | } | 273 | } |
279 | 274 | ||
280 | public ArrayList GetScriptErrors(UUID itemID) | 275 | public ArrayList GetScriptErrors(UUID itemID) |
@@ -305,17 +300,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
305 | /// </param> | 300 | /// </param> |
306 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 301 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
307 | { | 302 | { |
308 | Items.LockItemsForRead(true); | 303 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
309 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 304 | foreach (TaskInventoryItem item in scripts) |
310 | Items.LockItemsForRead(false); | ||
311 | |||
312 | foreach (TaskInventoryItem item in items) | ||
313 | { | 305 | { |
314 | if ((int)InventoryType.LSL == item.InvType) | 306 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
315 | { | 307 | m_part.RemoveScriptEvents(item.ItemID); |
316 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | ||
317 | m_part.RemoveScriptEvents(item.ItemID); | ||
318 | } | ||
319 | } | 308 | } |
320 | } | 309 | } |
321 | 310 | ||
@@ -1281,9 +1270,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | return true; | 1270 | return true; |
1282 | } | 1271 | } |
1283 | } | 1272 | } |
1273 | |||
1284 | return false; | 1274 | return false; |
1285 | } | 1275 | } |
1286 | 1276 | ||
1277 | /// <summary> | ||
1278 | /// Returns the count of scripts in this parts inventory. | ||
1279 | /// </summary> | ||
1280 | /// <returns></returns> | ||
1281 | public int ScriptCount() | ||
1282 | { | ||
1283 | int count = 0; | ||
1284 | Items.LockItemsForRead(true); | ||
1285 | foreach (TaskInventoryItem item in m_items.Values) | ||
1286 | { | ||
1287 | if (item.InvType == (int)InventoryType.LSL) | ||
1288 | { | ||
1289 | count++; | ||
1290 | } | ||
1291 | } | ||
1292 | Items.LockItemsForRead(false); | ||
1293 | return count; | ||
1294 | } | ||
1295 | /// <summary> | ||
1296 | /// Returns the count of running scripts in this parts inventory. | ||
1297 | /// </summary> | ||
1298 | /// <returns></returns> | ||
1299 | public int RunningScriptCount() | ||
1300 | { | ||
1301 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
1302 | if (engines.Length == 0) | ||
1303 | return 0; | ||
1304 | |||
1305 | int count = 0; | ||
1306 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1307 | |||
1308 | foreach (TaskInventoryItem item in scripts) | ||
1309 | { | ||
1310 | foreach (IScriptModule engine in engines) | ||
1311 | { | ||
1312 | if (engine != null) | ||
1313 | { | ||
1314 | if (engine.GetScriptState(item.ItemID)) | ||
1315 | { | ||
1316 | count++; | ||
1317 | } | ||
1318 | } | ||
1319 | } | ||
1320 | } | ||
1321 | return count; | ||
1322 | } | ||
1323 | |||
1287 | public List<UUID> GetInventoryList() | 1324 | public List<UUID> GetInventoryList() |
1288 | { | 1325 | { |
1289 | List<UUID> ret = new List<UUID>(); | 1326 | List<UUID> ret = new List<UUID>(); |
@@ -1298,22 +1335,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1298 | { | 1335 | { |
1299 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1336 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1300 | 1337 | ||
1301 | lock (m_items) | 1338 | Items.LockItemsForRead(true); |
1302 | ret = new List<TaskInventoryItem>(m_items.Values); | 1339 | ret = new List<TaskInventoryItem>(m_items.Values); |
1340 | Items.LockItemsForRead(false); | ||
1303 | 1341 | ||
1304 | return ret; | 1342 | return ret; |
1305 | } | 1343 | } |
1306 | 1344 | ||
1307 | public List<TaskInventoryItem> GetInventoryScripts() | 1345 | public List<TaskInventoryItem> GetInventoryItems(InventoryType type) |
1308 | { | 1346 | { |
1309 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1347 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1310 | 1348 | ||
1311 | lock (m_items) | 1349 | Items.LockItemsForRead(true); |
1312 | { | 1350 | |
1313 | foreach (TaskInventoryItem item in m_items.Values) | 1351 | foreach (TaskInventoryItem item in m_items.Values) |
1314 | if (item.InvType == (int)InventoryType.LSL) | 1352 | if (item.InvType == (int)type) |
1315 | ret.Add(item); | 1353 | ret.Add(item); |
1316 | } | 1354 | |
1355 | Items.LockItemsForRead(false); | ||
1317 | 1356 | ||
1318 | return ret; | 1357 | return ret; |
1319 | } | 1358 | } |
@@ -1335,35 +1374,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1335 | if (engines.Length == 0) // No engine at all | 1374 | if (engines.Length == 0) // No engine at all |
1336 | return ret; | 1375 | return ret; |
1337 | 1376 | ||
1338 | Items.LockItemsForRead(true); | 1377 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
1339 | foreach (TaskInventoryItem item in m_items.Values) | 1378 | |
1379 | foreach (TaskInventoryItem item in scripts) | ||
1340 | { | 1380 | { |
1341 | if (item.InvType == (int)InventoryType.LSL) | 1381 | foreach (IScriptModule e in engines) |
1342 | { | 1382 | { |
1343 | foreach (IScriptModule e in engines) | 1383 | if (e != null) |
1344 | { | 1384 | { |
1345 | if (e != null) | 1385 | string n = e.GetXMLState(item.ItemID); |
1386 | if (n != String.Empty) | ||
1346 | { | 1387 | { |
1347 | string n = e.GetXMLState(item.ItemID); | 1388 | if (oldIDs) |
1348 | if (n != String.Empty) | 1389 | { |
1390 | if (!ret.ContainsKey(item.OldItemID)) | ||
1391 | ret[item.OldItemID] = n; | ||
1392 | } | ||
1393 | else | ||
1349 | { | 1394 | { |
1350 | if (oldIDs) | 1395 | if (!ret.ContainsKey(item.ItemID)) |
1351 | { | 1396 | ret[item.ItemID] = n; |
1352 | if (!ret.ContainsKey(item.OldItemID)) | ||
1353 | ret[item.OldItemID] = n; | ||
1354 | } | ||
1355 | else | ||
1356 | { | ||
1357 | if (!ret.ContainsKey(item.ItemID)) | ||
1358 | ret[item.ItemID] = n; | ||
1359 | } | ||
1360 | break; | ||
1361 | } | 1397 | } |
1398 | break; | ||
1362 | } | 1399 | } |
1363 | } | 1400 | } |
1364 | } | 1401 | } |
1365 | } | 1402 | } |
1366 | Items.LockItemsForRead(false); | ||
1367 | return ret; | 1403 | return ret; |
1368 | } | 1404 | } |
1369 | 1405 | ||
@@ -1373,27 +1409,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1373 | if (engines.Length == 0) | 1409 | if (engines.Length == 0) |
1374 | return; | 1410 | return; |
1375 | 1411 | ||
1412 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1376 | 1413 | ||
1377 | Items.LockItemsForRead(true); | 1414 | foreach (TaskInventoryItem item in scripts) |
1378 | |||
1379 | foreach (TaskInventoryItem item in m_items.Values) | ||
1380 | { | 1415 | { |
1381 | if (item.InvType == (int)InventoryType.LSL) | 1416 | foreach (IScriptModule engine in engines) |
1382 | { | 1417 | { |
1383 | foreach (IScriptModule engine in engines) | 1418 | if (engine != null) |
1384 | { | 1419 | { |
1385 | if (engine != null) | 1420 | if (item.OwnerChanged) |
1386 | { | 1421 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); |
1387 | if (item.OwnerChanged) | 1422 | item.OwnerChanged = false; |
1388 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | 1423 | engine.ResumeScript(item.ItemID); |
1389 | item.OwnerChanged = false; | ||
1390 | engine.ResumeScript(item.ItemID); | ||
1391 | } | ||
1392 | } | 1424 | } |
1393 | } | 1425 | } |
1394 | } | 1426 | } |
1395 | |||
1396 | Items.LockItemsForRead(false); | ||
1397 | } | 1427 | } |
1398 | } | 1428 | } |
1399 | } | 1429 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 80f21ce..3452f90 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -45,6 +45,7 @@ using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags; | |||
45 | 45 | ||
46 | namespace OpenSim.Region.Framework.Scenes | 46 | namespace OpenSim.Region.Framework.Scenes |
47 | { | 47 | { |
48 | [Flags] | ||
48 | enum ScriptControlled : uint | 49 | enum ScriptControlled : uint |
49 | { | 50 | { |
50 | CONTROL_ZERO = 0, | 51 | CONTROL_ZERO = 0, |
@@ -1065,19 +1066,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1065 | /// <param name="pos"></param> | 1066 | /// <param name="pos"></param> |
1066 | public void Teleport(Vector3 pos) | 1067 | public void Teleport(Vector3 pos) |
1067 | { | 1068 | { |
1068 | bool isFlying = Flying; | 1069 | TeleportWithMomentum(pos, Vector3.Zero); |
1069 | RemoveFromPhysicalScene(); | ||
1070 | Velocity = Vector3.Zero; | ||
1071 | CheckLandingPoint(ref pos); | ||
1072 | AbsolutePosition = pos; | ||
1073 | AddToPhysicalScene(isFlying); | ||
1074 | |||
1075 | SendTerseUpdateToAllClients(); | ||
1076 | } | ||
1077 | |||
1078 | public void TeleportWithMomentum(Vector3 pos) | ||
1079 | { | ||
1080 | TeleportWithMomentum(pos, null); | ||
1081 | } | 1070 | } |
1082 | 1071 | ||
1083 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1072 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1264,7 +1253,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1264 | 1253 | ||
1265 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1254 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
1266 | { | 1255 | { |
1267 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); | 1256 | m_log.DebugFormat( |
1257 | "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}", | ||
1258 | client.Name, client.AgentId, m_callbackURI); | ||
1259 | |||
1268 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); | 1260 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); |
1269 | m_callbackURI = null; | 1261 | m_callbackURI = null; |
1270 | } | 1262 | } |
@@ -1339,7 +1331,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1339 | { | 1331 | { |
1340 | // m_log.DebugFormat( | 1332 | // m_log.DebugFormat( |
1341 | // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", | 1333 | // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", |
1342 | // Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); | 1334 | // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); |
1343 | 1335 | ||
1344 | if (IsChildAgent) | 1336 | if (IsChildAgent) |
1345 | { | 1337 | { |
@@ -1449,14 +1441,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1449 | } | 1441 | } |
1450 | } | 1442 | } |
1451 | 1443 | ||
1452 | lock (scriptedcontrols) | 1444 | uint flagsForScripts = (uint)flags; |
1453 | { | 1445 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1454 | if (scriptedcontrols.Count > 0) | ||
1455 | { | ||
1456 | SendControlToScripts((uint)flags); | ||
1457 | flags = RemoveIgnoredControls(flags, IgnoredControls); | ||
1458 | } | ||
1459 | } | ||
1460 | 1446 | ||
1461 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1447 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1462 | HandleAgentSitOnGround(); | 1448 | HandleAgentSitOnGround(); |
@@ -1470,6 +1456,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1470 | PhysicsActor actor = PhysicsActor; | 1456 | PhysicsActor actor = PhysicsActor; |
1471 | if (actor == null) | 1457 | if (actor == null) |
1472 | { | 1458 | { |
1459 | SendControlsToScripts(flagsForScripts); | ||
1473 | return; | 1460 | return; |
1474 | } | 1461 | } |
1475 | 1462 | ||
@@ -1549,7 +1536,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1549 | MovementFlag |= (byte)nudgehack; | 1536 | MovementFlag |= (byte)nudgehack; |
1550 | } | 1537 | } |
1551 | 1538 | ||
1552 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); | 1539 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); |
1553 | MovementFlag += (byte)(uint)DCF; | 1540 | MovementFlag += (byte)(uint)DCF; |
1554 | update_movementflag = true; | 1541 | update_movementflag = true; |
1555 | } | 1542 | } |
@@ -1562,7 +1549,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1562 | && ((MovementFlag & (byte)nudgehack) == nudgehack)) | 1549 | && ((MovementFlag & (byte)nudgehack) == nudgehack)) |
1563 | ) // This or is for Nudge forward | 1550 | ) // This or is for Nudge forward |
1564 | { | 1551 | { |
1565 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); | 1552 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); |
1566 | MovementFlag -= ((byte)(uint)DCF); | 1553 | MovementFlag -= ((byte)(uint)DCF); |
1567 | update_movementflag = true; | 1554 | update_movementflag = true; |
1568 | 1555 | ||
@@ -1643,8 +1630,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1643 | // } | 1630 | // } |
1644 | // } | 1631 | // } |
1645 | 1632 | ||
1646 | // if (update_movementflag && ParentID == 0) | 1633 | if (update_movementflag && ParentID == 0) |
1647 | // Animator.UpdateMovementAnimations(); | 1634 | Animator.UpdateMovementAnimations(); |
1635 | |||
1636 | SendControlsToScripts(flagsForScripts); | ||
1648 | } | 1637 | } |
1649 | 1638 | ||
1650 | m_scene.EventManager.TriggerOnClientMovement(this); | 1639 | m_scene.EventManager.TriggerOnClientMovement(this); |
@@ -3580,6 +3569,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
3580 | return m_attachments.Count > 0; | 3569 | return m_attachments.Count > 0; |
3581 | } | 3570 | } |
3582 | 3571 | ||
3572 | /// <summary> | ||
3573 | /// Returns the total count of scripts in all parts inventories. | ||
3574 | /// </summary> | ||
3575 | public int ScriptCount() | ||
3576 | { | ||
3577 | int count = 0; | ||
3578 | lock (m_attachments) | ||
3579 | { | ||
3580 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3581 | { | ||
3582 | if (gobj != null) | ||
3583 | { | ||
3584 | count += gobj.ScriptCount(); | ||
3585 | } | ||
3586 | } | ||
3587 | } | ||
3588 | return count; | ||
3589 | } | ||
3590 | |||
3591 | /// <summary> | ||
3592 | /// A float the value is a representative execution time in milliseconds of all scripts in all attachments. | ||
3593 | /// </summary> | ||
3594 | public float ScriptExecutionTime() | ||
3595 | { | ||
3596 | float time = 0.0f; | ||
3597 | lock (m_attachments) | ||
3598 | { | ||
3599 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3600 | { | ||
3601 | if (gobj != null) | ||
3602 | { | ||
3603 | time += gobj.ScriptExecutionTime(); | ||
3604 | } | ||
3605 | } | ||
3606 | } | ||
3607 | return time; | ||
3608 | } | ||
3609 | |||
3610 | /// <summary> | ||
3611 | /// Returns the total count of running scripts in all parts. | ||
3612 | /// </summary> | ||
3613 | public int RunningScriptCount() | ||
3614 | { | ||
3615 | int count = 0; | ||
3616 | lock (m_attachments) | ||
3617 | { | ||
3618 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3619 | { | ||
3620 | if (gobj != null) | ||
3621 | { | ||
3622 | count += gobj.RunningScriptCount(); | ||
3623 | } | ||
3624 | } | ||
3625 | } | ||
3626 | return count; | ||
3627 | } | ||
3628 | |||
3583 | public bool HasScriptedAttachments() | 3629 | public bool HasScriptedAttachments() |
3584 | { | 3630 | { |
3585 | lock (m_attachments) | 3631 | lock (m_attachments) |
@@ -3777,77 +3823,92 @@ namespace OpenSim.Region.Framework.Scenes | |||
3777 | } | 3823 | } |
3778 | } | 3824 | } |
3779 | 3825 | ||
3780 | internal void SendControlToScripts(uint flags) | 3826 | private void SendControlsToScripts(uint flags) |
3781 | { | 3827 | { |
3782 | ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; | 3828 | // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script |
3783 | 3829 | // (e.g., a walking script) checks which animation is active it will be the correct animation. | |
3784 | if (MouseDown) | 3830 | lock (scriptedcontrols) |
3785 | { | 3831 | { |
3786 | allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); | 3832 | if (scriptedcontrols.Count <= 0) |
3787 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) | 3833 | return; |
3834 | |||
3835 | ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; | ||
3836 | |||
3837 | if (MouseDown) | ||
3838 | { | ||
3839 | allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); | ||
3840 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) | ||
3841 | { | ||
3842 | allflags = ScriptControlled.CONTROL_ZERO; | ||
3843 | MouseDown = true; | ||
3844 | } | ||
3845 | } | ||
3846 | |||
3847 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) | ||
3788 | { | 3848 | { |
3789 | allflags = ScriptControlled.CONTROL_ZERO; | 3849 | allflags |= ScriptControlled.CONTROL_ML_LBUTTON; |
3790 | MouseDown = true; | 3850 | MouseDown = true; |
3791 | } | 3851 | } |
3792 | } | 3852 | |
3853 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) | ||
3854 | { | ||
3855 | allflags |= ScriptControlled.CONTROL_LBUTTON; | ||
3856 | MouseDown = true; | ||
3857 | } | ||
3858 | |||
3859 | // find all activated controls, whether the scripts are interested in them or not | ||
3860 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) | ||
3861 | { | ||
3862 | allflags |= ScriptControlled.CONTROL_FWD; | ||
3863 | } | ||
3864 | |||
3865 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) | ||
3866 | { | ||
3867 | allflags |= ScriptControlled.CONTROL_BACK; | ||
3868 | } | ||
3869 | |||
3870 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) | ||
3871 | { | ||
3872 | allflags |= ScriptControlled.CONTROL_UP; | ||
3873 | } | ||
3874 | |||
3875 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) | ||
3876 | { | ||
3877 | allflags |= ScriptControlled.CONTROL_DOWN; | ||
3878 | } | ||
3793 | 3879 | ||
3794 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) | 3880 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) |
3795 | { | 3881 | { |
3796 | allflags |= ScriptControlled.CONTROL_ML_LBUTTON; | 3882 | allflags |= ScriptControlled.CONTROL_LEFT; |
3797 | MouseDown = true; | 3883 | } |
3798 | } | 3884 | |
3799 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) | 3885 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) |
3800 | { | 3886 | { |
3801 | allflags |= ScriptControlled.CONTROL_LBUTTON; | 3887 | allflags |= ScriptControlled.CONTROL_RIGHT; |
3802 | MouseDown = true; | 3888 | } |
3803 | } | 3889 | |
3890 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | ||
3891 | { | ||
3892 | allflags |= ScriptControlled.CONTROL_ROT_RIGHT; | ||
3893 | } | ||
3894 | |||
3895 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | ||
3896 | { | ||
3897 | allflags |= ScriptControlled.CONTROL_ROT_LEFT; | ||
3898 | } | ||
3804 | 3899 | ||
3805 | // find all activated controls, whether the scripts are interested in them or not | 3900 | // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that |
3806 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) | 3901 | if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) |
3807 | { | ||
3808 | allflags |= ScriptControlled.CONTROL_FWD; | ||
3809 | } | ||
3810 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0) | ||
3811 | { | ||
3812 | allflags |= ScriptControlled.CONTROL_BACK; | ||
3813 | } | ||
3814 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0) | ||
3815 | { | ||
3816 | allflags |= ScriptControlled.CONTROL_UP; | ||
3817 | } | ||
3818 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0) | ||
3819 | { | ||
3820 | allflags |= ScriptControlled.CONTROL_DOWN; | ||
3821 | } | ||
3822 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0) | ||
3823 | { | ||
3824 | allflags |= ScriptControlled.CONTROL_LEFT; | ||
3825 | } | ||
3826 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0) | ||
3827 | { | ||
3828 | allflags |= ScriptControlled.CONTROL_RIGHT; | ||
3829 | } | ||
3830 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | ||
3831 | { | ||
3832 | allflags |= ScriptControlled.CONTROL_ROT_RIGHT; | ||
3833 | } | ||
3834 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | ||
3835 | { | ||
3836 | allflags |= ScriptControlled.CONTROL_ROT_LEFT; | ||
3837 | } | ||
3838 | // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that | ||
3839 | if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands) | ||
3840 | { | ||
3841 | lock (scriptedcontrols) | ||
3842 | { | 3902 | { |
3843 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) | 3903 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) |
3844 | { | 3904 | { |
3845 | UUID scriptUUID = kvp.Key; | 3905 | UUID scriptUUID = kvp.Key; |
3846 | ScriptControllers scriptControlData = kvp.Value; | 3906 | ScriptControllers scriptControlData = kvp.Value; |
3847 | 3907 | ||
3848 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us | 3908 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us |
3849 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle | 3909 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle |
3850 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits | 3910 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits |
3911 | |||
3851 | if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) | 3912 | if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) |
3852 | { | 3913 | { |
3853 | // only send if still pressed or just changed | 3914 | // only send if still pressed or just changed |
@@ -3855,9 +3916,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3855 | } | 3916 | } |
3856 | } | 3917 | } |
3857 | } | 3918 | } |
3919 | |||
3920 | LastCommands = allflags; | ||
3858 | } | 3921 | } |
3859 | |||
3860 | LastCommands = allflags; | ||
3861 | } | 3922 | } |
3862 | 3923 | ||
3863 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) | 3924 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) |
@@ -3937,7 +3998,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3937 | land.LandData.UserLocation != Vector3.Zero && | 3998 | land.LandData.UserLocation != Vector3.Zero && |
3938 | land.LandData.OwnerID != m_uuid && | 3999 | land.LandData.OwnerID != m_uuid && |
3939 | (!m_scene.Permissions.IsGod(m_uuid)) && | 4000 | (!m_scene.Permissions.IsGod(m_uuid)) && |
3940 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | 4001 | (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid))) |
3941 | { | 4002 | { |
3942 | float curr = Vector3.Distance(AbsolutePosition, pos); | 4003 | float curr = Vector3.Distance(AbsolutePosition, pos); |
3943 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | 4004 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) |
@@ -3957,7 +4018,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3957 | { | 4018 | { |
3958 | if (GodLevel < 200 && | 4019 | if (GodLevel < 200 && |
3959 | ((!m_scene.Permissions.IsGod(m_uuid) && | 4020 | ((!m_scene.Permissions.IsGod(m_uuid) && |
3960 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 4021 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
3961 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 4022 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
3962 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 4023 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
3963 | { | 4024 | { |
@@ -4031,7 +4092,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4031 | GodLevel < 200 && | 4092 | GodLevel < 200 && |
4032 | ((land.LandData.OwnerID != m_uuid && | 4093 | ((land.LandData.OwnerID != m_uuid && |
4033 | !m_scene.Permissions.IsGod(m_uuid) && | 4094 | !m_scene.Permissions.IsGod(m_uuid) && |
4034 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 4095 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
4035 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 4096 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
4036 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 4097 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
4037 | { | 4098 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs index ab6311b..4a21dc9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | ||
30 | using System.Text; | 31 | using System.Text; |
31 | using NUnit.Framework; | 32 | using NUnit.Framework; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
@@ -68,11 +69,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
68 | Vector3 position = new Vector3(200,200,21); | 69 | Vector3 position = new Vector3(200,200,21); |
69 | 70 | ||
70 | foreach (Border b in testborders) | 71 | foreach (Border b in testborders) |
71 | { | ||
72 | Assert.That(!b.TestCross(position)); | 72 | Assert.That(!b.TestCross(position)); |
73 | 73 | ||
74 | } | ||
75 | |||
76 | position = new Vector3(200,280,21); | 74 | position = new Vector3(200,280,21); |
77 | Assert.That(NorthBorder.TestCross(position)); | 75 | Assert.That(NorthBorder.TestCross(position)); |
78 | 76 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index a5d2b23..ea9fc93 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
45 | { | 45 | { |
46 | static public Random random; | 46 | static public Random random; |
47 | SceneObjectGroup found; | 47 | SceneObjectGroup found; |
48 | Scene scene = SceneHelpers.SetupScene(); | 48 | Scene scene = new SceneHelpers().SetupScene(); |
49 | 49 | ||
50 | [Test] | 50 | [Test] |
51 | public void T010_AddObjects() | 51 | public void T010_AddObjects() |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index 9a60e50..d23c965 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | |||
@@ -26,7 +26,9 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text; | ||
30 | using NUnit.Framework; | 32 | using NUnit.Framework; |
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -44,7 +46,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
44 | public void TestDuplicateObject() | 46 | public void TestDuplicateObject() |
45 | { | 47 | { |
46 | TestHelpers.InMethod(); | 48 | TestHelpers.InMethod(); |
47 | Scene scene = SceneHelpers.SetupScene(); | 49 | // TestHelpers.EnableLogging(); |
50 | |||
51 | Scene scene = new SceneHelpers().SetupScene(); | ||
48 | 52 | ||
49 | UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); | 53 | UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); |
50 | string part1Name = "part1"; | 54 | string part1Name = "part1"; |
@@ -82,6 +86,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
82 | Assert.That(dupePart1.PhysActor, Is.Not.Null); | 86 | Assert.That(dupePart1.PhysActor, Is.Not.Null); |
83 | Assert.That(dupePart2.PhysActor, Is.Not.Null); | 87 | Assert.That(dupePart2.PhysActor, Is.Not.Null); |
84 | */ | 88 | */ |
89 | |||
90 | // TestHelpers.DisableLogging(); | ||
85 | } | 91 | } |
86 | } | 92 | } |
87 | } \ No newline at end of file | 93 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 7737d8e..453e077 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
88 | { | 88 | { |
89 | TestHelpers.InMethod(); | 89 | TestHelpers.InMethod(); |
90 | 90 | ||
91 | Scene scene = SceneHelpers.SetupScene(); | 91 | Scene scene = new SceneHelpers().SetupScene(); |
92 | int partsToTestCount = 3; | 92 | int partsToTestCount = 3; |
93 | 93 | ||
94 | SceneObjectGroup so | 94 | SceneObjectGroup so |
@@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
118 | { | 118 | { |
119 | TestHelpers.InMethod(); | 119 | TestHelpers.InMethod(); |
120 | 120 | ||
121 | Scene scene = SceneHelpers.SetupScene(); | 121 | Scene scene = new SceneHelpers().SetupScene(); |
122 | 122 | ||
123 | string obj1Name = "Alfred"; | 123 | string obj1Name = "Alfred"; |
124 | string obj2Name = "Betty"; | 124 | string obj2Name = "Betty"; |
@@ -152,7 +152,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
152 | { | 152 | { |
153 | TestHelpers.InMethod(); | 153 | TestHelpers.InMethod(); |
154 | 154 | ||
155 | Scene scene = SceneHelpers.SetupScene(); | 155 | Scene scene = new SceneHelpers().SetupScene(); |
156 | int partsToTestCount = 3; | 156 | int partsToTestCount = 3; |
157 | 157 | ||
158 | SceneObjectGroup so | 158 | SceneObjectGroup so |
@@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
185 | { | 185 | { |
186 | TestHelpers.InMethod(); | 186 | TestHelpers.InMethod(); |
187 | 187 | ||
188 | TestScene scene = SceneHelpers.SetupScene(); | 188 | TestScene scene = new SceneHelpers().SetupScene(); |
189 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 189 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |
190 | scene.DeleteSceneObject(part.ParentGroup, false); | 190 | scene.DeleteSceneObject(part.ParentGroup, false); |
191 | 191 | ||
@@ -204,7 +204,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
204 | 204 | ||
205 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 205 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
206 | 206 | ||
207 | TestScene scene = SceneHelpers.SetupScene(); | 207 | TestScene scene = new SceneHelpers().SetupScene(); |
208 | 208 | ||
209 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | 209 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. |
210 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | 210 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 654b1a2..0076f41 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
61 | 61 | ||
62 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 62 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
63 | 63 | ||
64 | TestScene scene = SceneHelpers.SetupScene(); | 64 | TestScene scene = new SceneHelpers().SetupScene(); |
65 | IConfigSource configSource = new IniConfigSource(); | 65 | IConfigSource configSource = new IniConfigSource(); |
66 | IConfig config = configSource.AddConfig("Startup"); | 66 | IConfig config = configSource.AddConfig("Startup"); |
67 | config.Set("serverside_object_permissions", true); | 67 | config.Set("serverside_object_permissions", true); |
@@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
100 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 100 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
101 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); | 101 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); |
102 | 102 | ||
103 | TestScene scene = SceneHelpers.SetupScene(); | 103 | TestScene scene = new SceneHelpers().SetupScene(); |
104 | IConfigSource configSource = new IniConfigSource(); | 104 | IConfigSource configSource = new IniConfigSource(); |
105 | IConfig config = configSource.AddConfig("Startup"); | 105 | IConfig config = configSource.AddConfig("Startup"); |
106 | config.Set("serverside_object_permissions", true); | 106 | config.Set("serverside_object_permissions", true); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index be5b4a8..1add3dd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
55 | UUID ownerId = TestHelpers.ParseTail(0x1); | 55 | UUID ownerId = TestHelpers.ParseTail(0x1); |
56 | int nParts = 3; | 56 | int nParts = 3; |
57 | 57 | ||
58 | TestScene scene = SceneHelpers.SetupScene(); | 58 | TestScene scene = new SceneHelpers().SetupScene(); |
59 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10); | 59 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10); |
60 | scene.AddSceneObject(sog1); | 60 | scene.AddSceneObject(sog1); |
61 | scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId }); | 61 | scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId }); |
@@ -71,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
71 | 71 | ||
72 | bool debugtest = false; | 72 | bool debugtest = false; |
73 | 73 | ||
74 | Scene scene = SceneHelpers.SetupScene(); | 74 | Scene scene = new SceneHelpers().SetupScene(); |
75 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); | 75 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); |
76 | SceneObjectGroup grp1 = part1.ParentGroup; | 76 | SceneObjectGroup grp1 = part1.ParentGroup; |
77 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); | 77 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); |
@@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
153 | 153 | ||
154 | bool debugtest = false; | 154 | bool debugtest = false; |
155 | 155 | ||
156 | Scene scene = SceneHelpers.SetupScene(); | 156 | Scene scene = new SceneHelpers().SetupScene(); |
157 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); | 157 | SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); |
158 | SceneObjectGroup grp1 = part1.ParentGroup; | 158 | SceneObjectGroup grp1 = part1.ParentGroup; |
159 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); | 159 | SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); |
@@ -286,7 +286,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
286 | TestHelpers.InMethod(); | 286 | TestHelpers.InMethod(); |
287 | //log4net.Config.XmlConfigurator.Configure(); | 287 | //log4net.Config.XmlConfigurator.Configure(); |
288 | 288 | ||
289 | TestScene scene = SceneHelpers.SetupScene(); | 289 | TestScene scene = new SceneHelpers().SetupScene(); |
290 | 290 | ||
291 | string rootPartName = "rootpart"; | 291 | string rootPartName = "rootpart"; |
292 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); | 292 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); |
@@ -325,7 +325,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
325 | TestHelpers.InMethod(); | 325 | TestHelpers.InMethod(); |
326 | //log4net.Config.XmlConfigurator.Configure(); | 326 | //log4net.Config.XmlConfigurator.Configure(); |
327 | 327 | ||
328 | TestScene scene = SceneHelpers.SetupScene(); | 328 | TestScene scene = new SceneHelpers().SetupScene(); |
329 | 329 | ||
330 | string rootPartName = "rootpart"; | 330 | string rootPartName = "rootpart"; |
331 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); | 331 | UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index b49c6e7..0a94c19 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
52 | TestHelpers.InMethod(); | 52 | TestHelpers.InMethod(); |
53 | // log4net.Config.XmlConfigurator.Configure(); | 53 | // log4net.Config.XmlConfigurator.Configure(); |
54 | 54 | ||
55 | Scene scene = SceneHelpers.SetupScene(); | 55 | Scene scene = new SceneHelpers().SetupScene(); |
56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup; | 56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup; |
57 | 57 | ||
58 | g1.GroupResize(new Vector3(2, 3, 4)); | 58 | g1.GroupResize(new Vector3(2, 3, 4)); |
@@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
75 | TestHelpers.InMethod(); | 75 | TestHelpers.InMethod(); |
76 | //log4net.Config.XmlConfigurator.Configure(); | 76 | //log4net.Config.XmlConfigurator.Configure(); |
77 | 77 | ||
78 | Scene scene = SceneHelpers.SetupScene(); | 78 | Scene scene = new SceneHelpers().SetupScene(); |
79 | 79 | ||
80 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero); | 80 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero); |
81 | g1.RootPart.Scale = new Vector3(2, 3, 4); | 81 | g1.RootPart.Scale = new Vector3(2, 3, 4); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs index c582cf6..d2361f8 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
52 | // UUID itemId = TestHelpers.ParseTail(0x2); | 52 | // UUID itemId = TestHelpers.ParseTail(0x2); |
53 | string itemName = "Test Script Item"; | 53 | string itemName = "Test Script Item"; |
54 | 54 | ||
55 | Scene scene = SceneHelpers.SetupScene(); | 55 | Scene scene = new SceneHelpers().SetupScene(); |
56 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); | 56 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); |
57 | scene.AddNewSceneObject(so, true); | 57 | scene.AddNewSceneObject(so, true); |
58 | 58 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs new file mode 100644 index 0000000..6d255aa --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | |||
@@ -0,0 +1,154 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Threading; | ||
31 | using NUnit.Framework; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Tests.Common; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | |||
39 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) | ||
43 | /// </summary> | ||
44 | [TestFixture] | ||
45 | public class SceneObjectSpatialTests | ||
46 | { | ||
47 | TestScene m_scene; | ||
48 | UUID m_ownerId = TestHelpers.ParseTail(0x1); | ||
49 | |||
50 | [SetUp] | ||
51 | public void SetUp() | ||
52 | { | ||
53 | m_scene = new SceneHelpers().SetupScene(); | ||
54 | } | ||
55 | |||
56 | [Test] | ||
57 | public void TestGetSceneObjectGroupPosition() | ||
58 | { | ||
59 | TestHelpers.InMethod(); | ||
60 | |||
61 | Vector3 position = new Vector3(10, 20, 30); | ||
62 | |||
63 | SceneObjectGroup so | ||
64 | = SceneHelpers.CreateSceneObject(1, m_ownerId, "obj1", 0x10); | ||
65 | so.AbsolutePosition = position; | ||
66 | m_scene.AddNewSceneObject(so, false); | ||
67 | |||
68 | Assert.That(so.AbsolutePosition, Is.EqualTo(position)); | ||
69 | } | ||
70 | |||
71 | [Test] | ||
72 | public void TestGetRootPartPosition() | ||
73 | { | ||
74 | TestHelpers.InMethod(); | ||
75 | |||
76 | Vector3 partPosition = new Vector3(10, 20, 30); | ||
77 | |||
78 | SceneObjectGroup so | ||
79 | = SceneHelpers.CreateSceneObject(1, m_ownerId, "obj1", 0x10); | ||
80 | so.AbsolutePosition = partPosition; | ||
81 | m_scene.AddNewSceneObject(so, false); | ||
82 | |||
83 | Assert.That(so.RootPart.AbsolutePosition, Is.EqualTo(partPosition)); | ||
84 | Assert.That(so.RootPart.GroupPosition, Is.EqualTo(partPosition)); | ||
85 | Assert.That(so.RootPart.GetWorldPosition(), Is.EqualTo(partPosition)); | ||
86 | Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition)); | ||
87 | Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero)); | ||
88 | } | ||
89 | |||
90 | [Test] | ||
91 | public void TestGetChildPartPosition() | ||
92 | { | ||
93 | TestHelpers.InMethod(); | ||
94 | |||
95 | Vector3 rootPartPosition = new Vector3(10, 20, 30); | ||
96 | Vector3 childOffsetPosition = new Vector3(2, 3, 4); | ||
97 | |||
98 | SceneObjectGroup so | ||
99 | = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); | ||
100 | so.AbsolutePosition = rootPartPosition; | ||
101 | so.Parts[1].OffsetPosition = childOffsetPosition; | ||
102 | |||
103 | m_scene.AddNewSceneObject(so, false); | ||
104 | |||
105 | // Calculate child absolute position. | ||
106 | Vector3 childPosition = new Vector3(rootPartPosition + childOffsetPosition); | ||
107 | |||
108 | SceneObjectPart childPart = so.Parts[1]; | ||
109 | Assert.That(childPart.AbsolutePosition, Is.EqualTo(childPosition)); | ||
110 | Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); | ||
111 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | ||
112 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | ||
113 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | ||
114 | } | ||
115 | |||
116 | [Test] | ||
117 | public void TestGetChildPartPositionAfterObjectRotation() | ||
118 | { | ||
119 | TestHelpers.InMethod(); | ||
120 | |||
121 | Vector3 rootPartPosition = new Vector3(10, 20, 30); | ||
122 | Vector3 childOffsetPosition = new Vector3(2, 3, 4); | ||
123 | |||
124 | SceneObjectGroup so | ||
125 | = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); | ||
126 | so.AbsolutePosition = rootPartPosition; | ||
127 | so.Parts[1].OffsetPosition = childOffsetPosition; | ||
128 | |||
129 | m_scene.AddNewSceneObject(so, false); | ||
130 | |||
131 | so.UpdateGroupRotationR(Quaternion.CreateFromEulers(0, 0, -90 * Utils.DEG_TO_RAD)); | ||
132 | |||
133 | // Calculate child absolute position. | ||
134 | Vector3 rotatedChildOffsetPosition | ||
135 | = new Vector3(childOffsetPosition.Y, -childOffsetPosition.X, childOffsetPosition.Z); | ||
136 | |||
137 | Vector3 childPosition = new Vector3(rootPartPosition + rotatedChildOffsetPosition); | ||
138 | |||
139 | SceneObjectPart childPart = so.Parts[1]; | ||
140 | |||
141 | // FIXME: Should be childPosition after rotation? | ||
142 | Assert.That(childPart.AbsolutePosition, Is.EqualTo(rootPartPosition + childOffsetPosition)); | ||
143 | |||
144 | Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); | ||
145 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | ||
146 | |||
147 | // Relative to root part as (0, 0, 0) | ||
148 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | ||
149 | |||
150 | // Relative to root part as (0, 0, 0) | ||
151 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | ||
152 | } | ||
153 | } | ||
154 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 2a342d5..742c769 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using NUnit.Framework; | 31 | using NUnit.Framework; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
@@ -43,24 +44,141 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
43 | [TestFixture] | 44 | [TestFixture] |
44 | public class SceneObjectStatusTests | 45 | public class SceneObjectStatusTests |
45 | { | 46 | { |
47 | private TestScene m_scene; | ||
48 | private UUID m_ownerId = TestHelpers.ParseTail(0x1); | ||
49 | private SceneObjectGroup m_so1; | ||
50 | private SceneObjectGroup m_so2; | ||
51 | |||
52 | [SetUp] | ||
53 | public void Init() | ||
54 | { | ||
55 | m_scene = new SceneHelpers().SetupScene(); | ||
56 | m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10); | ||
57 | m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20); | ||
58 | } | ||
59 | |||
46 | [Test] | 60 | [Test] |
47 | public void TestSetPhantom() | 61 | public void TestSetPhantomSinglePrim() |
48 | { | 62 | { |
49 | TestHelpers.InMethod(); | 63 | TestHelpers.InMethod(); |
50 | 64 | ||
51 | // Scene scene = SceneSetupHelpers.SetupScene(); | 65 | m_scene.AddSceneObject(m_so1); |
52 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); | 66 | |
53 | SceneObjectPart rootPart = so.RootPart; | 67 | SceneObjectPart rootPart = m_so1.RootPart; |
54 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | 68 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); |
55 | 69 | ||
56 | so.ScriptSetPhantomStatus(true); | 70 | m_so1.ScriptSetPhantomStatus(true); |
57 | 71 | ||
58 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); | 72 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); |
59 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); | 73 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); |
60 | 74 | ||
61 | so.ScriptSetPhantomStatus(false); | 75 | m_so1.ScriptSetPhantomStatus(false); |
62 | 76 | ||
63 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | 77 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); |
64 | } | 78 | } |
79 | |||
80 | [Test] | ||
81 | public void TestSetPhysicsSinglePrim() | ||
82 | { | ||
83 | TestHelpers.InMethod(); | ||
84 | |||
85 | m_scene.AddSceneObject(m_so1); | ||
86 | |||
87 | SceneObjectPart rootPart = m_so1.RootPart; | ||
88 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
89 | |||
90 | m_so1.ScriptSetPhysicsStatus(true); | ||
91 | |||
92 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); | ||
93 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
94 | |||
95 | m_so1.ScriptSetPhysicsStatus(false); | ||
96 | |||
97 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
98 | } | ||
99 | |||
100 | [Test] | ||
101 | public void TestSetPhysicsLinkset() | ||
102 | { | ||
103 | TestHelpers.InMethod(); | ||
104 | |||
105 | m_scene.AddSceneObject(m_so1); | ||
106 | m_scene.AddSceneObject(m_so2); | ||
107 | |||
108 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
109 | |||
110 | m_so1.ScriptSetPhysicsStatus(true); | ||
111 | |||
112 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
113 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
114 | |||
115 | m_so1.ScriptSetPhysicsStatus(false); | ||
116 | |||
117 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
118 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); | ||
119 | |||
120 | m_so1.ScriptSetPhysicsStatus(true); | ||
121 | |||
122 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
123 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
124 | } | ||
125 | |||
126 | /// <summary> | ||
127 | /// Test that linking results in the correct physical status for all linkees. | ||
128 | /// </summary> | ||
129 | [Test] | ||
130 | public void TestLinkPhysicsBothPhysical() | ||
131 | { | ||
132 | TestHelpers.InMethod(); | ||
133 | |||
134 | m_scene.AddSceneObject(m_so1); | ||
135 | m_scene.AddSceneObject(m_so2); | ||
136 | |||
137 | m_so1.ScriptSetPhysicsStatus(true); | ||
138 | m_so2.ScriptSetPhysicsStatus(true); | ||
139 | |||
140 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
141 | |||
142 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
143 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
144 | } | ||
145 | |||
146 | /// <summary> | ||
147 | /// Test that linking results in the correct physical status for all linkees. | ||
148 | /// </summary> | ||
149 | [Test] | ||
150 | public void TestLinkPhysicsRootPhysicalOnly() | ||
151 | { | ||
152 | TestHelpers.InMethod(); | ||
153 | |||
154 | m_scene.AddSceneObject(m_so1); | ||
155 | m_scene.AddSceneObject(m_so2); | ||
156 | |||
157 | m_so1.ScriptSetPhysicsStatus(true); | ||
158 | |||
159 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
160 | |||
161 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
162 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Test that linking results in the correct physical status for all linkees. | ||
167 | /// </summary> | ||
168 | [Test] | ||
169 | public void TestLinkPhysicsChildPhysicalOnly() | ||
170 | { | ||
171 | TestHelpers.InMethod(); | ||
172 | |||
173 | m_scene.AddSceneObject(m_so1); | ||
174 | m_scene.AddSceneObject(m_so2); | ||
175 | |||
176 | m_so2.ScriptSetPhysicsStatus(true); | ||
177 | |||
178 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
179 | |||
180 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
181 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); | ||
182 | } | ||
65 | } | 183 | } |
66 | } \ No newline at end of file | 184 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index c13d82e..c7eaff9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
58 | 58 | ||
59 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 59 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
60 | 60 | ||
61 | TestScene scene = SceneHelpers.SetupScene(); | 61 | TestScene scene = new SceneHelpers().SetupScene(); |
62 | IConfigSource configSource = new IniConfigSource(); | 62 | IConfigSource configSource = new IniConfigSource(); |
63 | 63 | ||
64 | IConfig startupConfig = configSource.AddConfig("Startup"); | 64 | IConfig startupConfig = configSource.AddConfig("Startup"); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs index ed9b179..2e46377 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs | |||
@@ -67,10 +67,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
67 | public void Init() | 67 | public void Init() |
68 | { | 68 | { |
69 | TestHelpers.InMethod(); | 69 | TestHelpers.InMethod(); |
70 | 70 | ||
71 | scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | 71 | SceneHelpers sh = new SceneHelpers(); |
72 | scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | 72 | |
73 | scene3 = SceneHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); | 73 | scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); |
74 | scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | ||
75 | scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); | ||
74 | 76 | ||
75 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | 77 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); |
76 | interregionComms.Initialise(new IniConfigSource()); | 78 | interregionComms.Initialise(new IniConfigSource()); |
@@ -101,7 +103,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
101 | TestHelpers.InMethod(); | 103 | TestHelpers.InMethod(); |
102 | // log4net.Config.XmlConfigurator.Configure(); | 104 | // log4net.Config.XmlConfigurator.Configure(); |
103 | 105 | ||
104 | TestScene scene = SceneHelpers.SetupScene(); | 106 | TestScene scene = new SceneHelpers().SetupScene(); |
105 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | 107 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
106 | 108 | ||
107 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); | 109 | Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); |
@@ -126,7 +128,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
126 | IConfig config = configSource.AddConfig("Modules"); | 128 | IConfig config = configSource.AddConfig("Modules"); |
127 | config.Set("SimulationServices", "LocalSimulationConnectorModule"); | 129 | config.Set("SimulationServices", "LocalSimulationConnectorModule"); |
128 | 130 | ||
129 | TestScene scene = SceneHelpers.SetupScene(); | 131 | TestScene scene = new SceneHelpers().SetupScene(); |
130 | SceneHelpers.SetupSceneModules(scene, configSource, lsc); | 132 | SceneHelpers.SetupSceneModules(scene, configSource, lsc); |
131 | 133 | ||
132 | UUID agentId = TestHelpers.ParseTail(0x01); | 134 | UUID agentId = TestHelpers.ParseTail(0x01); |
@@ -176,8 +178,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
176 | 178 | ||
177 | // UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 179 | // UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
178 | 180 | ||
179 | TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); | 181 | TestScene myScene1 = new SceneHelpers().SetupScene("Neighbour y", UUID.Random(), 1000, 1000); |
180 | TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); | 182 | TestScene myScene2 = new SceneHelpers().SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); |
181 | 183 | ||
182 | IConfigSource configSource = new IniConfigSource(); | 184 | IConfigSource configSource = new IniConfigSource(); |
183 | IConfig config = configSource.AddConfig("Startup"); | 185 | IConfig config = configSource.AddConfig("Startup"); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs index 89f8007..646e5fa 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
59 | TestHelpers.InMethod(); | 59 | TestHelpers.InMethod(); |
60 | // log4net.Config.XmlConfigurator.Configure(); | 60 | // log4net.Config.XmlConfigurator.Configure(); |
61 | 61 | ||
62 | TestScene scene = SceneHelpers.SetupScene(); | 62 | TestScene scene = new SceneHelpers().SetupScene(); |
63 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | 63 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
64 | sp.Flying = true; | 64 | sp.Flying = true; |
65 | sp.PhysicsCollisionUpdate(new CollisionEventUpdate()); | 65 | sp.PhysicsCollisionUpdate(new CollisionEventUpdate()); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs index cfea10d..1d1ff88 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs | |||
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
64 | [SetUp] | 64 | [SetUp] |
65 | public void Init() | 65 | public void Init() |
66 | { | 66 | { |
67 | m_scene = SceneHelpers.SetupScene(); | 67 | m_scene = new SceneHelpers().SetupScene(); |
68 | } | 68 | } |
69 | 69 | ||
70 | [Test] | 70 | [Test] |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index b7b8db4..313e350 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
50 | [SetUp] | 50 | [SetUp] |
51 | public void Init() | 51 | public void Init() |
52 | { | 52 | { |
53 | m_scene = SceneHelpers.SetupScene(); | 53 | m_scene = new SceneHelpers().SetupScene(); |
54 | m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); | 54 | m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
55 | } | 55 | } |
56 | 56 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index bebc10c..c750cc5 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -33,11 +33,13 @@ using OpenMetaverse; | |||
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
36 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
38 | using OpenSim.Tests.Common; | 39 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 40 | using OpenSim.Tests.Common.Mock; |
40 | using System.Threading; | 41 | using System.IO; |
42 | using System.Text; | ||
41 | 43 | ||
42 | namespace OpenSim.Region.Framework.Scenes.Tests | 44 | namespace OpenSim.Region.Framework.Scenes.Tests |
43 | { | 45 | { |
@@ -47,145 +49,93 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
47 | [TestFixture] | 49 | [TestFixture] |
48 | public class ScenePresenceTeleportTests | 50 | public class ScenePresenceTeleportTests |
49 | { | 51 | { |
50 | /// <summary> | 52 | [Test] |
51 | /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. | 53 | public void TestSameRegionTeleport() |
52 | /// </summary> | ||
53 | /// Does not yet do what is says on the tin. | ||
54 | /// Commenting for now | ||
55 | //[Test, LongRunning] | ||
56 | public void TestSimpleNotNeighboursTeleport() | ||
57 | { | 54 | { |
58 | TestHelpers.InMethod(); | 55 | TestHelpers.InMethod(); |
59 | ThreadRunResults results = new ThreadRunResults(); | 56 | // log4net.Config.XmlConfigurator.Configure(); |
60 | results.Result = false; | ||
61 | results.Message = "Test did not run"; | ||
62 | TestRunning testClass = new TestRunning(results); | ||
63 | 57 | ||
64 | Thread testThread = new Thread(testClass.run); | 58 | EntityTransferModule etm = new EntityTransferModule(); |
65 | 59 | ||
66 | // Seems kind of redundant to start a thread and then join it, however.. We need to protect against | 60 | IConfigSource config = new IniConfigSource(); |
67 | // A thread abort exception in the simulator code. | 61 | config.AddConfig("Modules"); |
68 | testThread.Start(); | 62 | // Not strictly necessary since FriendsModule assumes it is the default (!) |
69 | testThread.Join(); | 63 | config.Configs["Modules"].Set("EntityTransferModule", etm.Name); |
70 | 64 | ||
71 | Assert.That(testClass.results.Result, Is.EqualTo(true), testClass.results.Message); | 65 | TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
72 | // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); | 66 | SceneHelpers.SetupSceneModules(scene, config, etm); |
73 | } | ||
74 | 67 | ||
75 | [TearDown] | 68 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
76 | public void TearDown() | 69 | Vector3 teleportLookAt = new Vector3(20, 21, 22); |
77 | { | ||
78 | try | ||
79 | { | ||
80 | if (MainServer.Instance != null) MainServer.Instance.Stop(); | ||
81 | } | ||
82 | catch (NullReferenceException) | ||
83 | { } | ||
84 | } | ||
85 | 70 | ||
86 | } | 71 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
72 | sp.AbsolutePosition = new Vector3(30, 31, 32); | ||
73 | scene.RequestTeleportLocation( | ||
74 | sp.ControllingClient, | ||
75 | scene.RegionInfo.RegionHandle, | ||
76 | teleportPosition, | ||
77 | teleportLookAt, | ||
78 | (uint)TeleportFlags.ViaLocation); | ||
87 | 79 | ||
88 | public class ThreadRunResults | 80 | Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition)); |
89 | { | ||
90 | public bool Result = false; | ||
91 | public string Message = string.Empty; | ||
92 | } | ||
93 | 81 | ||
94 | public class TestRunning | 82 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
95 | { | 83 | // position instead). |
96 | public ThreadRunResults results; | 84 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
97 | public TestRunning(ThreadRunResults t) | ||
98 | { | ||
99 | results = t; | ||
100 | } | 85 | } |
101 | public void run(object o) | 86 | |
87 | [Test] | ||
88 | public void TestSameSimulatorSeparatedRegionsTeleport() | ||
102 | { | 89 | { |
103 | 90 | TestHelpers.InMethod(); | |
104 | //results.Result = true; | 91 | // log4net.Config.XmlConfigurator.Configure(); |
105 | log4net.Config.XmlConfigurator.Configure(); | 92 | |
106 | 93 | UUID userId = TestHelpers.ParseTail(0x1); | |
107 | UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); | 94 | |
108 | UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); | 95 | EntityTransferModule etm = new EntityTransferModule(); |
109 | 96 | LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); | |
110 | // shared module | 97 | |
111 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | 98 | IConfigSource config = new IniConfigSource(); |
112 | 99 | config.AddConfig("Modules"); | |
113 | 100 | // Not strictly necessary since FriendsModule assumes it is the default (!) | |
114 | Scene sceneB = SceneHelpers.SetupScene("sceneB", sceneBId, 1010, 1010); | 101 | config.Configs["Modules"].Set("EntityTransferModule", etm.Name); |
115 | SceneHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); | 102 | config.Configs["Modules"].Set("SimulationServices", lscm.Name); |
116 | sceneB.RegisterRegionWithGrid(); | 103 | |
117 | 104 | SceneHelpers sh = new SceneHelpers(); | |
118 | Scene sceneA = SceneHelpers.SetupScene("sceneA", sceneAId, 1000, 1000); | 105 | TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); |
119 | SceneHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); | 106 | TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000); |
120 | sceneA.RegisterRegionWithGrid(); | 107 | |
121 | 108 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, etm, lscm); | |
122 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); | 109 | |
123 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(sceneA, agentId).ControllingClient; | 110 | Vector3 teleportPosition = new Vector3(10, 11, 12); |
124 | 111 | Vector3 teleportLookAt = new Vector3(20, 21, 22); | |
125 | ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>(); | 112 | |
126 | 113 | ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId); | |
127 | results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl); | 114 | sp.AbsolutePosition = new Vector3(30, 31, 32); |
128 | 115 | ||
129 | if (!results.Result) | 116 | // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole |
130 | { | 117 | // UDP stack (?) |
131 | results.Message = "Incorrect caps object path set up in sceneA"; | 118 | ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB; |
132 | return; | 119 | |
133 | } | 120 | sceneA.RequestTeleportLocation( |
134 | 121 | sp.ControllingClient, | |
135 | /* | 122 | sceneB.RegionInfo.RegionHandle, |
136 | Assert.That( | 123 | teleportPosition, |
137 | sceneACapsModule.GetCapsPath(agentId), | 124 | teleportLookAt, |
138 | Is.EqualTo(client.CapsSeedUrl), | 125 | (uint)TeleportFlags.ViaLocation); |
139 | "Incorrect caps object path set up in sceneA"); | 126 | |
140 | */ | 127 | Assert.That(sceneA.GetScenePresence(userId), Is.Null); |
141 | // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used. | 128 | |
142 | 129 | ScenePresence sceneBSp = sceneB.GetScenePresence(userId); | |
143 | 130 | Assert.That(sceneBSp, Is.Not.Null); | |
144 | client.TeleportTargetScene = sceneB; | 131 | Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName)); |
145 | client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40)); | 132 | Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition)); |
146 | 133 | ||
147 | results.Result = (sceneB.GetScenePresence(agentId) != null); | 134 | // TODO: Add assertions to check correct circuit details in both scenes. |
148 | if (!results.Result) | 135 | |
149 | { | 136 | // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera |
150 | results.Message = "Client does not have an agent in sceneB"; | 137 | // position instead). |
151 | return; | 138 | // Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt)); |
152 | } | ||
153 | |||
154 | //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB"); | ||
155 | |||
156 | //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA"); | ||
157 | |||
158 | results.Result = (sceneA.GetScenePresence(agentId) == null); | ||
159 | if (!results.Result) | ||
160 | { | ||
161 | results.Message = "Client still had an agent in sceneA"; | ||
162 | return; | ||
163 | } | ||
164 | |||
165 | ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>(); | ||
166 | |||
167 | |||
168 | results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + | ||
169 | "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl); | ||
170 | if (!results.Result) | ||
171 | { | ||
172 | results.Message = "Incorrect caps object path set up in sceneB"; | ||
173 | return; | ||
174 | } | ||
175 | |||
176 | // Temporary assertion - caps url construction should at least be doable through a method. | ||
177 | /* | ||
178 | Assert.That( | ||
179 | "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/", | ||
180 | Is.EqualTo(client.CapsSeedUrl), | ||
181 | "Incorrect caps object path set up in sceneB"); | ||
182 | */ | ||
183 | // This assertion will currently fail since we don't remove the caps paths when no longer needed | ||
184 | //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path"); | ||
185 | |||
186 | // TODO: Check that more of everything is as it should be | ||
187 | |||
188 | // TODO: test what happens if we try to teleport to a region that doesn't exist | ||
189 | } | 139 | } |
190 | } | 140 | } |
191 | } | 141 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index 5c9a77d..d722a09 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
60 | { | 60 | { |
61 | TestHelpers.InMethod(); | 61 | TestHelpers.InMethod(); |
62 | 62 | ||
63 | Scene scene = SceneHelpers.SetupScene(); | 63 | Scene scene = new SceneHelpers().SetupScene(); |
64 | scene.Update(1); | 64 | scene.Update(1); |
65 | 65 | ||
66 | Assert.That(scene.Frame, Is.EqualTo(1)); | 66 | Assert.That(scene.Frame, Is.EqualTo(1)); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 55c80f5..d15141b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Tests | |||
58 | TestHelpers.InMethod(); | 58 | TestHelpers.InMethod(); |
59 | // log4net.Config.XmlConfigurator.Configure(); | 59 | // log4net.Config.XmlConfigurator.Configure(); |
60 | 60 | ||
61 | Scene scene = SceneHelpers.SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
63 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 63 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
64 | SceneObjectPart sop1 = sog1.RootPart; | 64 | SceneObjectPart sop1 = sog1.RootPart; |
@@ -81,7 +81,7 @@ namespace OpenSim.Region.Framework.Tests | |||
81 | TestHelpers.InMethod(); | 81 | TestHelpers.InMethod(); |
82 | // log4net.Config.XmlConfigurator.Configure(); | 82 | // log4net.Config.XmlConfigurator.Configure(); |
83 | 83 | ||
84 | Scene scene = SceneHelpers.SetupScene(); | 84 | Scene scene = new SceneHelpers().SetupScene(); |
85 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 85 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
86 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 86 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
87 | SceneObjectPart sop1 = sog1.RootPart; | 87 | SceneObjectPart sop1 = sog1.RootPart; |
@@ -124,7 +124,7 @@ namespace OpenSim.Region.Framework.Tests | |||
124 | TestHelpers.InMethod(); | 124 | TestHelpers.InMethod(); |
125 | // log4net.Config.XmlConfigurator.Configure(); | 125 | // log4net.Config.XmlConfigurator.Configure(); |
126 | 126 | ||
127 | Scene scene = SceneHelpers.SetupScene(); | 127 | Scene scene = new SceneHelpers().SetupScene(); |
128 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 128 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
129 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 129 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
130 | SceneObjectPart sop1 = sog1.RootPart; | 130 | SceneObjectPart sop1 = sog1.RootPart; |
@@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Tests | |||
153 | TestHelpers.InMethod(); | 153 | TestHelpers.InMethod(); |
154 | // log4net.Config.XmlConfigurator.Configure(); | 154 | // log4net.Config.XmlConfigurator.Configure(); |
155 | 155 | ||
156 | Scene scene = SceneHelpers.SetupScene(); | 156 | Scene scene = new SceneHelpers().SetupScene(); |
157 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 157 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
158 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); | 158 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); |
159 | SceneObjectPart sop1 = sog1.RootPart; | 159 | SceneObjectPart sop1 = sog1.RootPart; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs index 55fc1e7..44d2d45 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Tests | |||
58 | TestHelpers.InMethod(); | 58 | TestHelpers.InMethod(); |
59 | // log4net.Config.XmlConfigurator.Configure(); | 59 | // log4net.Config.XmlConfigurator.Configure(); |
60 | 60 | ||
61 | Scene scene = SceneHelpers.SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); | 62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); |
63 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); | 63 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); |
64 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); | 64 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); |
@@ -85,7 +85,7 @@ namespace OpenSim.Region.Framework.Tests | |||
85 | TestHelpers.InMethod(); | 85 | TestHelpers.InMethod(); |
86 | // log4net.Config.XmlConfigurator.Configure(); | 86 | // log4net.Config.XmlConfigurator.Configure(); |
87 | 87 | ||
88 | Scene scene = SceneHelpers.SetupScene(); | 88 | Scene scene = new SceneHelpers().SetupScene(); |
89 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); | 89 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); |
90 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); | 90 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); |
91 | InventoryFolderBase folder1 | 91 | InventoryFolderBase folder1 |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index d9fe87c..198e487 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
47 | public void Init() | 47 | public void Init() |
48 | { | 48 | { |
49 | // FIXME: We don't need a full scene here - it would be enough to set up the asset service. | 49 | // FIXME: We don't need a full scene here - it would be enough to set up the asset service. |
50 | Scene scene = SceneHelpers.SetupScene(); | 50 | Scene scene = new SceneHelpers().SetupScene(); |
51 | m_assetService = scene.AssetService; | 51 | m_assetService = scene.AssetService; |
52 | m_uuidGatherer = new UuidGatherer(m_assetService); | 52 | m_uuidGatherer = new UuidGatherer(m_assetService); |
53 | } | 53 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs index e68f9d0..2602050 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs | |||
@@ -58,6 +58,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends | |||
58 | private Scene m_scene; | 58 | private Scene m_scene; |
59 | private IFriendsModule m_friendsModule; | 59 | private IFriendsModule m_friendsModule; |
60 | private IUserManagement m_userManagementModule; | 60 | private IUserManagement m_userManagementModule; |
61 | private IPresenceService m_presenceService; | ||
61 | 62 | ||
62 | // private IAvatarFactoryModule m_avatarFactory; | 63 | // private IAvatarFactoryModule m_avatarFactory; |
63 | 64 | ||
@@ -99,8 +100,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends | |||
99 | 100 | ||
100 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 101 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
101 | m_userManagementModule = m_scene.RequestModuleInterface<IUserManagement>(); | 102 | m_userManagementModule = m_scene.RequestModuleInterface<IUserManagement>(); |
103 | m_presenceService = m_scene.RequestModuleInterface<IPresenceService>(); | ||
102 | 104 | ||
103 | if (m_friendsModule != null && m_userManagementModule != null) | 105 | if (m_friendsModule != null && m_userManagementModule != null && m_presenceService != null) |
104 | { | 106 | { |
105 | m_scene.AddCommand( | 107 | m_scene.AddCommand( |
106 | "Friends", this, "friends show", | 108 | "Friends", this, "friends show", |
@@ -162,7 +164,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends | |||
162 | 164 | ||
163 | MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId); | 165 | MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId); |
164 | 166 | ||
165 | MainConsole.Instance.OutputFormat("UUID, Name, MyFlags, TheirFlags"); | 167 | MainConsole.Instance.OutputFormat( |
168 | "{0,-36} {1,-36} {2,-7} {3,7} {4,10}", "UUID", "Name", "Status", "MyFlags", "TheirFlags"); | ||
166 | 169 | ||
167 | foreach (FriendInfo friend in friends) | 170 | foreach (FriendInfo friend in friends) |
168 | { | 171 | { |
@@ -175,14 +178,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends | |||
175 | 178 | ||
176 | UUID friendId; | 179 | UUID friendId; |
177 | string friendName; | 180 | string friendName; |
181 | string onlineText; | ||
178 | 182 | ||
179 | if (UUID.TryParse(friend.Friend, out friendId)) | 183 | if (UUID.TryParse(friend.Friend, out friendId)) |
180 | friendName = m_userManagementModule.GetUserName(friendId); | 184 | friendName = m_userManagementModule.GetUserName(friendId); |
181 | else | 185 | else |
182 | friendName = friend.Friend; | 186 | friendName = friend.Friend; |
183 | 187 | ||
188 | OpenSim.Services.Interfaces.PresenceInfo[] pi = m_presenceService.GetAgents(new string[] { friend.Friend }); | ||
189 | if (pi.Length > 0) | ||
190 | onlineText = "online"; | ||
191 | else | ||
192 | onlineText = "offline"; | ||
193 | |||
184 | MainConsole.Instance.OutputFormat( | 194 | MainConsole.Instance.OutputFormat( |
185 | "{0} {1} {2} {3}", friend.Friend, friendName, friend.MyFlags, friend.TheirFlags); | 195 | "{0,-36} {1,-36} {2,-7} {3,-7} {4,-10}", |
196 | friend.Friend, friendName, onlineText, friend.MyFlags, friend.TheirFlags); | ||
186 | } | 197 | } |
187 | } | 198 | } |
188 | } | 199 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 130513d..5d57f70 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | |||
@@ -1401,9 +1401,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1401 | { | 1401 | { |
1402 | response = WebUtil.PostToService(m_groupsServerURI, requestArgs); | 1402 | response = WebUtil.PostToService(m_groupsServerURI, requestArgs); |
1403 | } | 1403 | } |
1404 | catch (Exception e) | 1404 | catch (Exception) |
1405 | { | 1405 | { |
1406 | m_log.InfoFormat("[SIMIAN GROUPS CONNECTOR] request failed {0}",CacheKey); | 1406 | m_log.ErrorFormat("[SIMIAN GROUPS CONNECTOR]: request failed {0}", CacheKey); |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | // and cache the response | 1409 | // and cache the response |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index d2f6327..ac638f1 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests | |||
50 | TestHelpers.InMethod(); | 50 | TestHelpers.InMethod(); |
51 | // log4net.Config.XmlConfigurator.Configure(); | 51 | // log4net.Config.XmlConfigurator.Configure(); |
52 | 52 | ||
53 | TestScene scene = SceneHelpers.SetupScene(); | 53 | TestScene scene = new SceneHelpers().SetupScene(); |
54 | IConfigSource configSource = new IniConfigSource(); | 54 | IConfigSource configSource = new IniConfigSource(); |
55 | IConfig config = configSource.AddConfig("Groups"); | 55 | IConfig config = configSource.AddConfig("Groups"); |
56 | config.Set("Enabled", true); | 56 | config.Set("Enabled", true); |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs new file mode 100644 index 0000000..34894ba --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs | |||
@@ -0,0 +1,500 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
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 OpenSim 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 | using Mono.Addins; | ||
28 | |||
29 | using System; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using System.Text; | ||
33 | using System.Net; | ||
34 | using System.Net.Sockets; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using System.Collections.Generic; | ||
43 | using System.Text.RegularExpressions; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | ||
46 | { | ||
47 | public class JsonStore | ||
48 | { | ||
49 | private static readonly ILog m_log = | ||
50 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private OSD m_ValueStore; | ||
53 | |||
54 | protected class TakeValueCallbackClass | ||
55 | { | ||
56 | public string Path { get; set; } | ||
57 | public bool UseJson { get; set; } | ||
58 | public TakeValueCallback Callback { get; set; } | ||
59 | |||
60 | public TakeValueCallbackClass(string spath, bool usejson, TakeValueCallback cback) | ||
61 | { | ||
62 | Path = spath; | ||
63 | UseJson = usejson; | ||
64 | Callback = cback; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | protected List<TakeValueCallbackClass> m_TakeStore; | ||
69 | protected List<TakeValueCallbackClass> m_ReadStore; | ||
70 | |||
71 | |||
72 | // ----------------------------------------------------------------- | ||
73 | /// <summary> | ||
74 | /// | ||
75 | /// </summary> | ||
76 | // ----------------------------------------------------------------- | ||
77 | public JsonStore() : this("") {} | ||
78 | |||
79 | public JsonStore(string value) | ||
80 | { | ||
81 | m_TakeStore = new List<TakeValueCallbackClass>(); | ||
82 | m_ReadStore = new List<TakeValueCallbackClass>(); | ||
83 | |||
84 | if (String.IsNullOrEmpty(value)) | ||
85 | m_ValueStore = new OSDMap(); | ||
86 | else | ||
87 | m_ValueStore = OSDParser.DeserializeJson(value); | ||
88 | } | ||
89 | |||
90 | // ----------------------------------------------------------------- | ||
91 | /// <summary> | ||
92 | /// | ||
93 | /// </summary> | ||
94 | // ----------------------------------------------------------------- | ||
95 | public bool TestPath(string expr, bool useJson) | ||
96 | { | ||
97 | Stack<string> path = ParsePathExpression(expr); | ||
98 | OSD result = ProcessPathExpression(m_ValueStore,path); | ||
99 | |||
100 | if (result == null) | ||
101 | return false; | ||
102 | |||
103 | if (useJson || result.Type == OSDType.String) | ||
104 | return true; | ||
105 | |||
106 | return false; | ||
107 | } | ||
108 | |||
109 | // ----------------------------------------------------------------- | ||
110 | /// <summary> | ||
111 | /// | ||
112 | /// </summary> | ||
113 | // ----------------------------------------------------------------- | ||
114 | public bool GetValue(string expr, out string value, bool useJson) | ||
115 | { | ||
116 | Stack<string> path = ParsePathExpression(expr); | ||
117 | OSD result = ProcessPathExpression(m_ValueStore,path); | ||
118 | return ConvertOutputValue(result,out value,useJson); | ||
119 | } | ||
120 | |||
121 | |||
122 | // ----------------------------------------------------------------- | ||
123 | /// <summary> | ||
124 | /// | ||
125 | /// </summary> | ||
126 | // ----------------------------------------------------------------- | ||
127 | public bool RemoveValue(string expr) | ||
128 | { | ||
129 | return SetValueFromExpression(expr,null); | ||
130 | } | ||
131 | |||
132 | // ----------------------------------------------------------------- | ||
133 | /// <summary> | ||
134 | /// | ||
135 | /// </summary> | ||
136 | // ----------------------------------------------------------------- | ||
137 | public bool SetValue(string expr, string value, bool useJson) | ||
138 | { | ||
139 | OSD ovalue = useJson ? OSDParser.DeserializeJson(value) : new OSDString(value); | ||
140 | return SetValueFromExpression(expr,ovalue); | ||
141 | } | ||
142 | |||
143 | // ----------------------------------------------------------------- | ||
144 | /// <summary> | ||
145 | /// | ||
146 | /// </summary> | ||
147 | // ----------------------------------------------------------------- | ||
148 | public bool TakeValue(string expr, bool useJson, TakeValueCallback cback) | ||
149 | { | ||
150 | Stack<string> path = ParsePathExpression(expr); | ||
151 | string pexpr = PathExpressionToKey(path); | ||
152 | |||
153 | OSD result = ProcessPathExpression(m_ValueStore,path); | ||
154 | if (result == null) | ||
155 | { | ||
156 | m_TakeStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); | ||
157 | return false; | ||
158 | } | ||
159 | |||
160 | string value = String.Empty; | ||
161 | if (! ConvertOutputValue(result,out value,useJson)) | ||
162 | { | ||
163 | // the structure does not match the request so i guess we'll wait | ||
164 | m_TakeStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | SetValueFromExpression(expr,null); | ||
169 | cback(value); | ||
170 | |||
171 | return true; | ||
172 | } | ||
173 | |||
174 | // ----------------------------------------------------------------- | ||
175 | /// <summary> | ||
176 | /// | ||
177 | /// </summary> | ||
178 | // ----------------------------------------------------------------- | ||
179 | public bool ReadValue(string expr, bool useJson, TakeValueCallback cback) | ||
180 | { | ||
181 | Stack<string> path = ParsePathExpression(expr); | ||
182 | string pexpr = PathExpressionToKey(path); | ||
183 | |||
184 | OSD result = ProcessPathExpression(m_ValueStore,path); | ||
185 | if (result == null) | ||
186 | { | ||
187 | m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); | ||
188 | return false; | ||
189 | } | ||
190 | |||
191 | string value = String.Empty; | ||
192 | if (! ConvertOutputValue(result,out value,useJson)) | ||
193 | { | ||
194 | // the structure does not match the request so i guess we'll wait | ||
195 | m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); | ||
196 | return false; | ||
197 | } | ||
198 | |||
199 | cback(value); | ||
200 | |||
201 | return true; | ||
202 | } | ||
203 | |||
204 | // ----------------------------------------------------------------- | ||
205 | /// <summary> | ||
206 | /// | ||
207 | /// </summary> | ||
208 | // ----------------------------------------------------------------- | ||
209 | protected bool SetValueFromExpression(string expr, OSD ovalue) | ||
210 | { | ||
211 | Stack<string> path = ParsePathExpression(expr); | ||
212 | if (path.Count == 0) | ||
213 | { | ||
214 | m_ValueStore = ovalue; | ||
215 | return true; | ||
216 | } | ||
217 | |||
218 | string pkey = path.Pop(); | ||
219 | string pexpr = PathExpressionToKey(path); | ||
220 | if (pexpr != "") | ||
221 | pexpr += "."; | ||
222 | |||
223 | OSD result = ProcessPathExpression(m_ValueStore,path); | ||
224 | if (result == null) | ||
225 | return false; | ||
226 | |||
227 | Regex aPattern = new Regex("\\[([0-9]+|\\+)\\]"); | ||
228 | MatchCollection amatches = aPattern.Matches(pkey,0); | ||
229 | |||
230 | if (amatches.Count > 0) | ||
231 | { | ||
232 | if (result.Type != OSDType.Array) | ||
233 | return false; | ||
234 | |||
235 | OSDArray amap = result as OSDArray; | ||
236 | |||
237 | Match match = amatches[0]; | ||
238 | GroupCollection groups = match.Groups; | ||
239 | string akey = groups[1].Value; | ||
240 | |||
241 | if (akey == "+") | ||
242 | { | ||
243 | string npkey = String.Format("[{0}]",amap.Count); | ||
244 | |||
245 | amap.Add(ovalue); | ||
246 | InvokeNextCallback(pexpr + npkey); | ||
247 | return true; | ||
248 | } | ||
249 | |||
250 | int aval = Convert.ToInt32(akey); | ||
251 | if (0 <= aval && aval < amap.Count) | ||
252 | { | ||
253 | if (ovalue == null) | ||
254 | amap.RemoveAt(aval); | ||
255 | else | ||
256 | { | ||
257 | amap[aval] = ovalue; | ||
258 | InvokeNextCallback(pexpr + pkey); | ||
259 | } | ||
260 | return true; | ||
261 | } | ||
262 | |||
263 | return false; | ||
264 | } | ||
265 | |||
266 | Regex hPattern = new Regex("{([^}]+)}"); | ||
267 | MatchCollection hmatches = hPattern.Matches(pkey,0); | ||
268 | |||
269 | if (hmatches.Count > 0) | ||
270 | { | ||
271 | Match match = hmatches[0]; | ||
272 | GroupCollection groups = match.Groups; | ||
273 | string hkey = groups[1].Value; | ||
274 | |||
275 | if (result is OSDMap) | ||
276 | { | ||
277 | OSDMap hmap = result as OSDMap; | ||
278 | if (ovalue != null) | ||
279 | { | ||
280 | hmap[hkey] = ovalue; | ||
281 | InvokeNextCallback(pexpr + pkey); | ||
282 | } | ||
283 | else if (hmap.ContainsKey(hkey)) | ||
284 | hmap.Remove(hkey); | ||
285 | |||
286 | return true; | ||
287 | } | ||
288 | |||
289 | return false; | ||
290 | } | ||
291 | |||
292 | // Shouldn't get here if the path was checked correctly | ||
293 | m_log.WarnFormat("[JsonStore] invalid path expression"); | ||
294 | return false; | ||
295 | } | ||
296 | |||
297 | // ----------------------------------------------------------------- | ||
298 | /// <summary> | ||
299 | /// | ||
300 | /// </summary> | ||
301 | // ----------------------------------------------------------------- | ||
302 | protected bool InvokeNextCallback(string pexpr) | ||
303 | { | ||
304 | // Process all of the reads that match the expression first | ||
305 | List<TakeValueCallbackClass> reads = | ||
306 | m_ReadStore.FindAll(delegate(TakeValueCallbackClass tb) { return pexpr.StartsWith(tb.Path); }); | ||
307 | |||
308 | foreach (TakeValueCallbackClass readcb in reads) | ||
309 | { | ||
310 | m_ReadStore.Remove(readcb); | ||
311 | ReadValue(readcb.Path,readcb.UseJson,readcb.Callback); | ||
312 | } | ||
313 | |||
314 | // Process one take next | ||
315 | TakeValueCallbackClass takecb = | ||
316 | m_TakeStore.Find(delegate(TakeValueCallbackClass tb) { return pexpr.StartsWith(tb.Path); }); | ||
317 | |||
318 | if (takecb != null) | ||
319 | { | ||
320 | m_TakeStore.Remove(takecb); | ||
321 | TakeValue(takecb.Path,takecb.UseJson,takecb.Callback); | ||
322 | |||
323 | return true; | ||
324 | } | ||
325 | |||
326 | return false; | ||
327 | } | ||
328 | |||
329 | // ----------------------------------------------------------------- | ||
330 | /// <summary> | ||
331 | /// Parse the path expression and put the components into a stack. We | ||
332 | /// use a stack because we process the path in inverse order later | ||
333 | /// </summary> | ||
334 | // ----------------------------------------------------------------- | ||
335 | protected static Stack<string> ParsePathExpression(string path) | ||
336 | { | ||
337 | Stack<string> m_path = new Stack<string>(); | ||
338 | |||
339 | // add front and rear separators | ||
340 | path = "." + path + "."; | ||
341 | |||
342 | // add separators for quoted paths | ||
343 | Regex pass1 = new Regex("{[^}]+}"); | ||
344 | path = pass1.Replace(path,".$0.",-1,0); | ||
345 | |||
346 | // add separators for array references | ||
347 | Regex pass2 = new Regex("(\\[[0-9]+\\]|\\[\\+\\])"); | ||
348 | path = pass2.Replace(path,".$0.",-1,0); | ||
349 | |||
350 | // add quotes to bare identifier | ||
351 | Regex pass3 = new Regex("\\.([a-zA-Z]+)"); | ||
352 | path = pass3.Replace(path,".{$1}",-1,0); | ||
353 | |||
354 | // remove extra separators | ||
355 | Regex pass4 = new Regex("\\.+"); | ||
356 | path = pass4.Replace(path,".",-1,0); | ||
357 | |||
358 | Regex validate = new Regex("^\\.(({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])\\.)+$"); | ||
359 | if (validate.IsMatch(path)) | ||
360 | { | ||
361 | Regex parser = new Regex("\\.({[^}]+}|\\[[0-9]+\\]|\\[\\+\\]+)"); | ||
362 | MatchCollection matches = parser.Matches(path,0); | ||
363 | foreach (Match match in matches) | ||
364 | m_path.Push(match.Groups[1].Value); | ||
365 | } | ||
366 | |||
367 | return m_path; | ||
368 | } | ||
369 | |||
370 | // ----------------------------------------------------------------- | ||
371 | /// <summary> | ||
372 | /// | ||
373 | /// </summary> | ||
374 | /// <param>path is a stack where the top level of the path is at the bottom of the stack</param> | ||
375 | // ----------------------------------------------------------------- | ||
376 | protected static OSD ProcessPathExpression(OSD map, Stack<string> path) | ||
377 | { | ||
378 | if (path.Count == 0) | ||
379 | return map; | ||
380 | |||
381 | string pkey = path.Pop(); | ||
382 | |||
383 | OSD rmap = ProcessPathExpression(map,path); | ||
384 | if (rmap == null) | ||
385 | return null; | ||
386 | |||
387 | // ---------- Check for an array index ---------- | ||
388 | Regex aPattern = new Regex("\\[([0-9]+)\\]"); | ||
389 | MatchCollection amatches = aPattern.Matches(pkey,0); | ||
390 | |||
391 | if (amatches.Count > 0) | ||
392 | { | ||
393 | if (rmap.Type != OSDType.Array) | ||
394 | { | ||
395 | m_log.WarnFormat("[JsonStore] wrong type for key {2}, expecting {0}, got {1}",OSDType.Array,rmap.Type,pkey); | ||
396 | return null; | ||
397 | } | ||
398 | |||
399 | OSDArray amap = rmap as OSDArray; | ||
400 | |||
401 | Match match = amatches[0]; | ||
402 | GroupCollection groups = match.Groups; | ||
403 | string akey = groups[1].Value; | ||
404 | int aval = Convert.ToInt32(akey); | ||
405 | |||
406 | if (aval < amap.Count) | ||
407 | return (OSD) amap[aval]; | ||
408 | |||
409 | return null; | ||
410 | } | ||
411 | |||
412 | // ---------- Check for a hash index ---------- | ||
413 | Regex hPattern = new Regex("{([^}]+)}"); | ||
414 | MatchCollection hmatches = hPattern.Matches(pkey,0); | ||
415 | |||
416 | if (hmatches.Count > 0) | ||
417 | { | ||
418 | if (rmap.Type != OSDType.Map) | ||
419 | { | ||
420 | m_log.WarnFormat("[JsonStore] wrong type for key {2}, expecting {0}, got {1}",OSDType.Map,rmap.Type,pkey); | ||
421 | return null; | ||
422 | } | ||
423 | |||
424 | OSDMap hmap = rmap as OSDMap; | ||
425 | |||
426 | Match match = hmatches[0]; | ||
427 | GroupCollection groups = match.Groups; | ||
428 | string hkey = groups[1].Value; | ||
429 | |||
430 | if (hmap.ContainsKey(hkey)) | ||
431 | return (OSD) hmap[hkey]; | ||
432 | |||
433 | return null; | ||
434 | } | ||
435 | |||
436 | // Shouldn't get here if the path was checked correctly | ||
437 | m_log.WarnFormat("[JsonStore] Path type (unknown) does not match the structure"); | ||
438 | return null; | ||
439 | } | ||
440 | |||
441 | // ----------------------------------------------------------------- | ||
442 | /// <summary> | ||
443 | /// | ||
444 | /// </summary> | ||
445 | // ----------------------------------------------------------------- | ||
446 | protected static bool ConvertOutputValue(OSD result, out string value, bool useJson) | ||
447 | { | ||
448 | value = String.Empty; | ||
449 | |||
450 | // If we couldn't process the path | ||
451 | if (result == null) | ||
452 | return false; | ||
453 | |||
454 | if (useJson) | ||
455 | { | ||
456 | // The path pointed to an intermediate hash structure | ||
457 | if (result.Type == OSDType.Map) | ||
458 | { | ||
459 | value = OSDParser.SerializeJsonString(result as OSDMap); | ||
460 | return true; | ||
461 | } | ||
462 | |||
463 | // The path pointed to an intermediate hash structure | ||
464 | if (result.Type == OSDType.Array) | ||
465 | { | ||
466 | value = OSDParser.SerializeJsonString(result as OSDArray); | ||
467 | return true; | ||
468 | } | ||
469 | |||
470 | value = "'" + result.AsString() + "'"; | ||
471 | return true; | ||
472 | } | ||
473 | |||
474 | if (result.Type == OSDType.String) | ||
475 | { | ||
476 | value = result.AsString(); | ||
477 | return true; | ||
478 | } | ||
479 | |||
480 | return false; | ||
481 | } | ||
482 | |||
483 | // ----------------------------------------------------------------- | ||
484 | /// <summary> | ||
485 | /// | ||
486 | /// </summary> | ||
487 | // ----------------------------------------------------------------- | ||
488 | protected static string PathExpressionToKey(Stack<string> path) | ||
489 | { | ||
490 | if (path.Count == 0) | ||
491 | return ""; | ||
492 | |||
493 | string pkey = ""; | ||
494 | foreach (string k in path) | ||
495 | pkey = (pkey == "") ? k : (k + "." + pkey); | ||
496 | |||
497 | return pkey; | ||
498 | } | ||
499 | } | ||
500 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs new file mode 100644 index 0000000..311531c --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | |||
@@ -0,0 +1,430 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
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 OpenSim 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 | using Mono.Addins; | ||
28 | |||
29 | using System; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using System.Text; | ||
33 | using System.Net; | ||
34 | using System.Net.Sockets; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using System.Collections.Generic; | ||
43 | using System.Text.RegularExpressions; | ||
44 | |||
45 | |||
46 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | ||
47 | { | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreModule")] | ||
49 | |||
50 | public class JsonStoreModule : INonSharedRegionModule, IJsonStoreModule | ||
51 | { | ||
52 | private static readonly ILog m_log = | ||
53 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | private IConfig m_config = null; | ||
56 | private bool m_enabled = false; | ||
57 | private Scene m_scene = null; | ||
58 | |||
59 | private Dictionary<UUID,JsonStore> m_JsonValueStore; | ||
60 | private UUID m_sharedStore; | ||
61 | |||
62 | #region IRegionModule Members | ||
63 | |||
64 | // ----------------------------------------------------------------- | ||
65 | /// <summary> | ||
66 | /// Name of this shared module is it's class name | ||
67 | /// </summary> | ||
68 | // ----------------------------------------------------------------- | ||
69 | public string Name | ||
70 | { | ||
71 | get { return this.GetType().Name; } | ||
72 | } | ||
73 | |||
74 | // ----------------------------------------------------------------- | ||
75 | /// <summary> | ||
76 | /// Initialise this shared module | ||
77 | /// </summary> | ||
78 | /// <param name="scene">this region is getting initialised</param> | ||
79 | /// <param name="source">nini config, we are not using this</param> | ||
80 | // ----------------------------------------------------------------- | ||
81 | public void Initialise(IConfigSource config) | ||
82 | { | ||
83 | try | ||
84 | { | ||
85 | if ((m_config = config.Configs["JsonStore"]) == null) | ||
86 | { | ||
87 | // There is no configuration, the module is disabled | ||
88 | // m_log.InfoFormat("[JsonStore] no configuration info"); | ||
89 | return; | ||
90 | } | ||
91 | |||
92 | m_enabled = m_config.GetBoolean("Enabled", m_enabled); | ||
93 | } | ||
94 | catch (Exception e) | ||
95 | { | ||
96 | m_log.ErrorFormat("[JsonStore] initialization error: {0}",e.Message); | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | if (m_enabled) | ||
101 | m_log.DebugFormat("[JsonStore] module is enabled"); | ||
102 | } | ||
103 | |||
104 | // ----------------------------------------------------------------- | ||
105 | /// <summary> | ||
106 | /// everything is loaded, perform post load configuration | ||
107 | /// </summary> | ||
108 | // ----------------------------------------------------------------- | ||
109 | public void PostInitialise() | ||
110 | { | ||
111 | } | ||
112 | |||
113 | // ----------------------------------------------------------------- | ||
114 | /// <summary> | ||
115 | /// Nothing to do on close | ||
116 | /// </summary> | ||
117 | // ----------------------------------------------------------------- | ||
118 | public void Close() | ||
119 | { | ||
120 | } | ||
121 | |||
122 | // ----------------------------------------------------------------- | ||
123 | /// <summary> | ||
124 | /// </summary> | ||
125 | // ----------------------------------------------------------------- | ||
126 | public void AddRegion(Scene scene) | ||
127 | { | ||
128 | if (m_enabled) | ||
129 | { | ||
130 | m_scene = scene; | ||
131 | m_scene.RegisterModuleInterface<IJsonStoreModule>(this); | ||
132 | |||
133 | m_sharedStore = UUID.Zero; | ||
134 | m_JsonValueStore = new Dictionary<UUID,JsonStore>(); | ||
135 | m_JsonValueStore.Add(m_sharedStore,new JsonStore("")); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | // ----------------------------------------------------------------- | ||
140 | /// <summary> | ||
141 | /// </summary> | ||
142 | // ----------------------------------------------------------------- | ||
143 | public void RemoveRegion(Scene scene) | ||
144 | { | ||
145 | // need to remove all references to the scene in the subscription | ||
146 | // list to enable full garbage collection of the scene object | ||
147 | } | ||
148 | |||
149 | // ----------------------------------------------------------------- | ||
150 | /// <summary> | ||
151 | /// Called when all modules have been added for a region. This is | ||
152 | /// where we hook up events | ||
153 | /// </summary> | ||
154 | // ----------------------------------------------------------------- | ||
155 | public void RegionLoaded(Scene scene) | ||
156 | { | ||
157 | if (m_enabled) {} | ||
158 | } | ||
159 | |||
160 | /// ----------------------------------------------------------------- | ||
161 | /// <summary> | ||
162 | /// </summary> | ||
163 | // ----------------------------------------------------------------- | ||
164 | public Type ReplaceableInterface | ||
165 | { | ||
166 | get { return null; } | ||
167 | } | ||
168 | |||
169 | #endregion | ||
170 | |||
171 | #region ScriptInvocationInteface | ||
172 | |||
173 | // ----------------------------------------------------------------- | ||
174 | /// <summary> | ||
175 | /// | ||
176 | /// </summary> | ||
177 | // ----------------------------------------------------------------- | ||
178 | public bool CreateStore(string value, out UUID result) | ||
179 | { | ||
180 | result = UUID.Zero; | ||
181 | |||
182 | if (! m_enabled) return false; | ||
183 | |||
184 | UUID uuid = UUID.Random(); | ||
185 | JsonStore map = null; | ||
186 | |||
187 | try | ||
188 | { | ||
189 | map = new JsonStore(value); | ||
190 | } | ||
191 | catch (Exception e) | ||
192 | { | ||
193 | m_log.InfoFormat("[JsonStore] Unable to initialize store from {0}; {1}",value,e.Message); | ||
194 | return false; | ||
195 | } | ||
196 | |||
197 | lock (m_JsonValueStore) | ||
198 | m_JsonValueStore.Add(uuid,map); | ||
199 | |||
200 | result = uuid; | ||
201 | return true; | ||
202 | } | ||
203 | |||
204 | // ----------------------------------------------------------------- | ||
205 | /// <summary> | ||
206 | /// | ||
207 | /// </summary> | ||
208 | // ----------------------------------------------------------------- | ||
209 | public bool DestroyStore(UUID storeID) | ||
210 | { | ||
211 | if (! m_enabled) return false; | ||
212 | |||
213 | lock (m_JsonValueStore) | ||
214 | m_JsonValueStore.Remove(storeID); | ||
215 | |||
216 | return true; | ||
217 | } | ||
218 | |||
219 | // ----------------------------------------------------------------- | ||
220 | /// <summary> | ||
221 | /// | ||
222 | /// </summary> | ||
223 | // ----------------------------------------------------------------- | ||
224 | public bool TestPath(UUID storeID, string path, bool useJson) | ||
225 | { | ||
226 | if (! m_enabled) return false; | ||
227 | |||
228 | JsonStore map = null; | ||
229 | lock (m_JsonValueStore) | ||
230 | { | ||
231 | if (! m_JsonValueStore.TryGetValue(storeID,out map)) | ||
232 | { | ||
233 | m_log.InfoFormat("[JsonStore] Missing store {0}",storeID); | ||
234 | return true; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | try | ||
239 | { | ||
240 | lock (map) | ||
241 | return map.TestPath(path,useJson); | ||
242 | } | ||
243 | catch (Exception e) | ||
244 | { | ||
245 | m_log.InfoFormat("[JsonStore] Path test failed for {0} in {1}; {2}",path,storeID,e.Message); | ||
246 | } | ||
247 | |||
248 | return false; | ||
249 | } | ||
250 | |||
251 | // ----------------------------------------------------------------- | ||
252 | /// <summary> | ||
253 | /// | ||
254 | /// </summary> | ||
255 | // ----------------------------------------------------------------- | ||
256 | public bool SetValue(UUID storeID, string path, string value, bool useJson) | ||
257 | { | ||
258 | if (! m_enabled) return false; | ||
259 | |||
260 | JsonStore map = null; | ||
261 | lock (m_JsonValueStore) | ||
262 | { | ||
263 | if (! m_JsonValueStore.TryGetValue(storeID,out map)) | ||
264 | { | ||
265 | m_log.InfoFormat("[JsonStore] Missing store {0}",storeID); | ||
266 | return false; | ||
267 | } | ||
268 | } | ||
269 | |||
270 | try | ||
271 | { | ||
272 | lock (map) | ||
273 | if (map.SetValue(path,value,useJson)) | ||
274 | return true; | ||
275 | } | ||
276 | catch (Exception e) | ||
277 | { | ||
278 | m_log.InfoFormat("[JsonStore] Unable to assign {0} to {1} in {2}; {3}",value,path,storeID,e.Message); | ||
279 | } | ||
280 | |||
281 | return false; | ||
282 | } | ||
283 | |||
284 | // ----------------------------------------------------------------- | ||
285 | /// <summary> | ||
286 | /// | ||
287 | /// </summary> | ||
288 | // ----------------------------------------------------------------- | ||
289 | public bool RemoveValue(UUID storeID, string path) | ||
290 | { | ||
291 | if (! m_enabled) return false; | ||
292 | |||
293 | JsonStore map = null; | ||
294 | lock (m_JsonValueStore) | ||
295 | { | ||
296 | if (! m_JsonValueStore.TryGetValue(storeID,out map)) | ||
297 | { | ||
298 | m_log.InfoFormat("[JsonStore] Missing store {0}",storeID); | ||
299 | return false; | ||
300 | } | ||
301 | } | ||
302 | |||
303 | try | ||
304 | { | ||
305 | lock (map) | ||
306 | if (map.RemoveValue(path)) | ||
307 | return true; | ||
308 | } | ||
309 | catch (Exception e) | ||
310 | { | ||
311 | m_log.InfoFormat("[JsonStore] Unable to remove {0} in {1}; {2}",path,storeID,e.Message); | ||
312 | } | ||
313 | |||
314 | return false; | ||
315 | } | ||
316 | |||
317 | // ----------------------------------------------------------------- | ||
318 | /// <summary> | ||
319 | /// | ||
320 | /// </summary> | ||
321 | // ----------------------------------------------------------------- | ||
322 | public bool GetValue(UUID storeID, string path, bool useJson, out string value) | ||
323 | { | ||
324 | value = String.Empty; | ||
325 | |||
326 | if (! m_enabled) return false; | ||
327 | |||
328 | JsonStore map = null; | ||
329 | lock (m_JsonValueStore) | ||
330 | { | ||
331 | if (! m_JsonValueStore.TryGetValue(storeID,out map)) | ||
332 | return false; | ||
333 | } | ||
334 | |||
335 | try | ||
336 | { | ||
337 | lock (map) | ||
338 | { | ||
339 | return map.GetValue(path, out value, useJson); | ||
340 | } | ||
341 | } | ||
342 | catch (Exception e) | ||
343 | { | ||
344 | m_log.InfoFormat("[JsonStore] unable to retrieve value; {0}",e.Message); | ||
345 | } | ||
346 | |||
347 | return false; | ||
348 | } | ||
349 | |||
350 | // ----------------------------------------------------------------- | ||
351 | /// <summary> | ||
352 | /// | ||
353 | /// </summary> | ||
354 | // ----------------------------------------------------------------- | ||
355 | public void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback) | ||
356 | { | ||
357 | if (! m_enabled) | ||
358 | { | ||
359 | cback(String.Empty); | ||
360 | return; | ||
361 | } | ||
362 | |||
363 | JsonStore map = null; | ||
364 | lock (m_JsonValueStore) | ||
365 | { | ||
366 | if (! m_JsonValueStore.TryGetValue(storeID,out map)) | ||
367 | { | ||
368 | cback(String.Empty); | ||
369 | return; | ||
370 | } | ||
371 | } | ||
372 | |||
373 | try | ||
374 | { | ||
375 | lock (map) | ||
376 | { | ||
377 | map.TakeValue(path, useJson, cback); | ||
378 | return; | ||
379 | } | ||
380 | } | ||
381 | catch (Exception e) | ||
382 | { | ||
383 | m_log.InfoFormat("[JsonStore] unable to retrieve value; {0}",e.ToString()); | ||
384 | } | ||
385 | |||
386 | cback(String.Empty); | ||
387 | } | ||
388 | |||
389 | // ----------------------------------------------------------------- | ||
390 | /// <summary> | ||
391 | /// | ||
392 | /// </summary> | ||
393 | // ----------------------------------------------------------------- | ||
394 | public void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback) | ||
395 | { | ||
396 | if (! m_enabled) | ||
397 | { | ||
398 | cback(String.Empty); | ||
399 | return; | ||
400 | } | ||
401 | |||
402 | JsonStore map = null; | ||
403 | lock (m_JsonValueStore) | ||
404 | { | ||
405 | if (! m_JsonValueStore.TryGetValue(storeID,out map)) | ||
406 | { | ||
407 | cback(String.Empty); | ||
408 | return; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | try | ||
413 | { | ||
414 | lock (map) | ||
415 | { | ||
416 | map.ReadValue(path, useJson, cback); | ||
417 | return; | ||
418 | } | ||
419 | } | ||
420 | catch (Exception e) | ||
421 | { | ||
422 | m_log.InfoFormat("[JsonStore] unable to retrieve value; {0}",e.ToString()); | ||
423 | } | ||
424 | |||
425 | cback(String.Empty); | ||
426 | } | ||
427 | |||
428 | #endregion | ||
429 | } | ||
430 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs new file mode 100644 index 0000000..4949097 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -0,0 +1,499 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
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 OpenSim 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 | using Mono.Addins; | ||
28 | |||
29 | using System; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using System.Text; | ||
33 | using System.Net; | ||
34 | using System.Net.Sockets; | ||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using OpenMetaverse; | ||
38 | using OpenMetaverse.StructuredData; | ||
39 | using OpenSim.Framework; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using System.Collections.Generic; | ||
43 | using System.Text.RegularExpressions; | ||
44 | |||
45 | namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | ||
46 | { | ||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreScriptModule")] | ||
48 | |||
49 | public class JsonStoreScriptModule : INonSharedRegionModule | ||
50 | { | ||
51 | private static readonly ILog m_log = | ||
52 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | private IConfig m_config = null; | ||
55 | private bool m_enabled = false; | ||
56 | private Scene m_scene = null; | ||
57 | |||
58 | private IScriptModuleComms m_comms; | ||
59 | private IJsonStoreModule m_store; | ||
60 | |||
61 | #region IRegionModule Members | ||
62 | |||
63 | // ----------------------------------------------------------------- | ||
64 | /// <summary> | ||
65 | /// Name of this shared module is it's class name | ||
66 | /// </summary> | ||
67 | // ----------------------------------------------------------------- | ||
68 | public string Name | ||
69 | { | ||
70 | get { return this.GetType().Name; } | ||
71 | } | ||
72 | |||
73 | // ----------------------------------------------------------------- | ||
74 | /// <summary> | ||
75 | /// Initialise this shared module | ||
76 | /// </summary> | ||
77 | /// <param name="scene">this region is getting initialised</param> | ||
78 | /// <param name="source">nini config, we are not using this</param> | ||
79 | // ----------------------------------------------------------------- | ||
80 | public void Initialise(IConfigSource config) | ||
81 | { | ||
82 | try | ||
83 | { | ||
84 | if ((m_config = config.Configs["JsonStore"]) == null) | ||
85 | { | ||
86 | // There is no configuration, the module is disabled | ||
87 | // m_log.InfoFormat("[JsonStoreScripts] no configuration info"); | ||
88 | return; | ||
89 | } | ||
90 | |||
91 | m_enabled = m_config.GetBoolean("Enabled", m_enabled); | ||
92 | } | ||
93 | catch (Exception e) | ||
94 | { | ||
95 | m_log.ErrorFormat("[JsonStoreScripts] initialization error: {0}",e.Message); | ||
96 | return; | ||
97 | } | ||
98 | |||
99 | if (m_enabled) | ||
100 | m_log.DebugFormat("[JsonStoreScripts] module is enabled"); | ||
101 | } | ||
102 | |||
103 | // ----------------------------------------------------------------- | ||
104 | /// <summary> | ||
105 | /// everything is loaded, perform post load configuration | ||
106 | /// </summary> | ||
107 | // ----------------------------------------------------------------- | ||
108 | public void PostInitialise() | ||
109 | { | ||
110 | } | ||
111 | |||
112 | // ----------------------------------------------------------------- | ||
113 | /// <summary> | ||
114 | /// Nothing to do on close | ||
115 | /// </summary> | ||
116 | // ----------------------------------------------------------------- | ||
117 | public void Close() | ||
118 | { | ||
119 | } | ||
120 | |||
121 | // ----------------------------------------------------------------- | ||
122 | /// <summary> | ||
123 | /// </summary> | ||
124 | // ----------------------------------------------------------------- | ||
125 | public void AddRegion(Scene scene) | ||
126 | { | ||
127 | } | ||
128 | |||
129 | // ----------------------------------------------------------------- | ||
130 | /// <summary> | ||
131 | /// </summary> | ||
132 | // ----------------------------------------------------------------- | ||
133 | public void RemoveRegion(Scene scene) | ||
134 | { | ||
135 | // need to remove all references to the scene in the subscription | ||
136 | // list to enable full garbage collection of the scene object | ||
137 | } | ||
138 | |||
139 | // ----------------------------------------------------------------- | ||
140 | /// <summary> | ||
141 | /// Called when all modules have been added for a region. This is | ||
142 | /// where we hook up events | ||
143 | /// </summary> | ||
144 | // ----------------------------------------------------------------- | ||
145 | public void RegionLoaded(Scene scene) | ||
146 | { | ||
147 | if (m_enabled) | ||
148 | { | ||
149 | m_scene = scene; | ||
150 | m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>(); | ||
151 | if (m_comms == null) | ||
152 | { | ||
153 | m_log.ErrorFormat("[JsonStoreScripts] ScriptModuleComms interface not defined"); | ||
154 | m_enabled = false; | ||
155 | return; | ||
156 | } | ||
157 | |||
158 | m_store = m_scene.RequestModuleInterface<IJsonStoreModule>(); | ||
159 | if (m_store == null) | ||
160 | { | ||
161 | m_log.ErrorFormat("[JsonStoreScripts] JsonModule interface not defined"); | ||
162 | m_enabled = false; | ||
163 | return; | ||
164 | } | ||
165 | |||
166 | try | ||
167 | { | ||
168 | m_comms.RegisterScriptInvocation(this,"JsonCreateStore"); | ||
169 | m_comms.RegisterScriptInvocation(this,"JsonDestroyStore"); | ||
170 | |||
171 | m_comms.RegisterScriptInvocation(this,"JsonReadNotecard"); | ||
172 | m_comms.RegisterScriptInvocation(this,"JsonWriteNotecard"); | ||
173 | |||
174 | m_comms.RegisterScriptInvocation(this,"JsonTestPath"); | ||
175 | m_comms.RegisterScriptInvocation(this,"JsonTestPathJson"); | ||
176 | |||
177 | m_comms.RegisterScriptInvocation(this,"JsonGetValue"); | ||
178 | m_comms.RegisterScriptInvocation(this,"JsonGetValueJson"); | ||
179 | |||
180 | m_comms.RegisterScriptInvocation(this,"JsonTakeValue"); | ||
181 | m_comms.RegisterScriptInvocation(this,"JsonTakeValueJson"); | ||
182 | |||
183 | m_comms.RegisterScriptInvocation(this,"JsonReadValue"); | ||
184 | m_comms.RegisterScriptInvocation(this,"JsonReadValueJson"); | ||
185 | |||
186 | m_comms.RegisterScriptInvocation(this,"JsonSetValue"); | ||
187 | m_comms.RegisterScriptInvocation(this,"JsonSetValueJson"); | ||
188 | |||
189 | m_comms.RegisterScriptInvocation(this,"JsonRemoveValue"); | ||
190 | } | ||
191 | catch (Exception e) | ||
192 | { | ||
193 | // See http://opensimulator.org/mantis/view.php?id=5971 for more information | ||
194 | m_log.WarnFormat("[JsonStroreScripts] script method registration failed; {0}",e.Message); | ||
195 | m_enabled = false; | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | |||
200 | /// ----------------------------------------------------------------- | ||
201 | /// <summary> | ||
202 | /// </summary> | ||
203 | // ----------------------------------------------------------------- | ||
204 | public Type ReplaceableInterface | ||
205 | { | ||
206 | get { return null; } | ||
207 | } | ||
208 | |||
209 | #endregion | ||
210 | |||
211 | #region ScriptInvocationInteface | ||
212 | // ----------------------------------------------------------------- | ||
213 | /// <summary> | ||
214 | /// | ||
215 | /// </summary> | ||
216 | // ----------------------------------------------------------------- | ||
217 | protected void GenerateRuntimeError(string msg) | ||
218 | { | ||
219 | throw new Exception("JsonStore Runtime Error: " + msg); | ||
220 | } | ||
221 | |||
222 | // ----------------------------------------------------------------- | ||
223 | /// <summary> | ||
224 | /// | ||
225 | /// </summary> | ||
226 | // ----------------------------------------------------------------- | ||
227 | protected UUID JsonCreateStore(UUID hostID, UUID scriptID, string value) | ||
228 | { | ||
229 | UUID uuid = UUID.Zero; | ||
230 | if (! m_store.CreateStore(value, out uuid)) | ||
231 | GenerateRuntimeError("Failed to create Json store"); | ||
232 | |||
233 | return uuid; | ||
234 | } | ||
235 | |||
236 | // ----------------------------------------------------------------- | ||
237 | /// <summary> | ||
238 | /// | ||
239 | /// </summary> | ||
240 | // ----------------------------------------------------------------- | ||
241 | protected int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID) | ||
242 | { | ||
243 | return m_store.DestroyStore(storeID) ? 1 : 0; | ||
244 | } | ||
245 | |||
246 | // ----------------------------------------------------------------- | ||
247 | /// <summary> | ||
248 | /// | ||
249 | /// </summary> | ||
250 | // ----------------------------------------------------------------- | ||
251 | protected UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) | ||
252 | { | ||
253 | UUID reqID = UUID.Random(); | ||
254 | Util.FireAndForget(delegate(object o) { DoJsonReadNotecard(reqID,hostID,scriptID,storeID,path,assetID); }); | ||
255 | return reqID; | ||
256 | } | ||
257 | |||
258 | // ----------------------------------------------------------------- | ||
259 | /// <summary> | ||
260 | /// | ||
261 | /// </summary> | ||
262 | // ----------------------------------------------------------------- | ||
263 | protected UUID JsonWriteNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string name) | ||
264 | { | ||
265 | UUID reqID = UUID.Random(); | ||
266 | Util.FireAndForget(delegate(object o) { DoJsonWriteNotecard(reqID,hostID,scriptID,storeID,path,name); }); | ||
267 | return reqID; | ||
268 | } | ||
269 | |||
270 | // ----------------------------------------------------------------- | ||
271 | /// <summary> | ||
272 | /// | ||
273 | /// </summary> | ||
274 | // ----------------------------------------------------------------- | ||
275 | protected int JsonTestPath(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
276 | { | ||
277 | return m_store.TestPath(storeID,path,false) ? 1 : 0; | ||
278 | } | ||
279 | |||
280 | protected int JsonTestPathJson(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
281 | { | ||
282 | return m_store.TestPath(storeID,path,true) ? 1 : 0; | ||
283 | } | ||
284 | |||
285 | // ----------------------------------------------------------------- | ||
286 | /// <summary> | ||
287 | /// | ||
288 | /// </summary> | ||
289 | // ----------------------------------------------------------------- | ||
290 | protected int JsonSetValue(UUID hostID, UUID scriptID, UUID storeID, string path, string value) | ||
291 | { | ||
292 | return m_store.SetValue(storeID,path,value,false) ? 1 : 0; | ||
293 | } | ||
294 | |||
295 | protected int JsonSetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value) | ||
296 | { | ||
297 | return m_store.SetValue(storeID,path,value,true) ? 1 : 0; | ||
298 | } | ||
299 | |||
300 | // ----------------------------------------------------------------- | ||
301 | /// <summary> | ||
302 | /// | ||
303 | /// </summary> | ||
304 | // ----------------------------------------------------------------- | ||
305 | protected int JsonRemoveValue(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
306 | { | ||
307 | return m_store.RemoveValue(storeID,path) ? 1 : 0; | ||
308 | } | ||
309 | |||
310 | // ----------------------------------------------------------------- | ||
311 | /// <summary> | ||
312 | /// | ||
313 | /// </summary> | ||
314 | // ----------------------------------------------------------------- | ||
315 | protected string JsonGetValue(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
316 | { | ||
317 | string value = String.Empty; | ||
318 | m_store.GetValue(storeID,path,false,out value); | ||
319 | return value; | ||
320 | } | ||
321 | |||
322 | protected string JsonGetValueJson(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
323 | { | ||
324 | string value = String.Empty; | ||
325 | m_store.GetValue(storeID,path,true, out value); | ||
326 | return value; | ||
327 | } | ||
328 | |||
329 | // ----------------------------------------------------------------- | ||
330 | /// <summary> | ||
331 | /// | ||
332 | /// </summary> | ||
333 | // ----------------------------------------------------------------- | ||
334 | protected UUID JsonTakeValue(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
335 | { | ||
336 | UUID reqID = UUID.Random(); | ||
337 | Util.FireAndForget(delegate(object o) { DoJsonTakeValue(scriptID,reqID,storeID,path,false); }); | ||
338 | return reqID; | ||
339 | } | ||
340 | |||
341 | protected UUID JsonTakeValueJson(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
342 | { | ||
343 | UUID reqID = UUID.Random(); | ||
344 | Util.FireAndForget(delegate(object o) { DoJsonTakeValue(scriptID,reqID,storeID,path,true); }); | ||
345 | return reqID; | ||
346 | } | ||
347 | |||
348 | private void DoJsonTakeValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson) | ||
349 | { | ||
350 | try | ||
351 | { | ||
352 | m_store.TakeValue(storeID,path,useJson,delegate(string value) { DispatchValue(scriptID,reqID,value); }); | ||
353 | return; | ||
354 | } | ||
355 | catch (Exception e) | ||
356 | { | ||
357 | m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); | ||
358 | } | ||
359 | |||
360 | DispatchValue(scriptID,reqID,String.Empty); | ||
361 | } | ||
362 | |||
363 | |||
364 | // ----------------------------------------------------------------- | ||
365 | /// <summary> | ||
366 | /// | ||
367 | /// </summary> | ||
368 | // ----------------------------------------------------------------- | ||
369 | protected UUID JsonReadValue(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
370 | { | ||
371 | UUID reqID = UUID.Random(); | ||
372 | Util.FireAndForget(delegate(object o) { DoJsonReadValue(scriptID,reqID,storeID,path,false); }); | ||
373 | return reqID; | ||
374 | } | ||
375 | |||
376 | protected UUID JsonReadValueJson(UUID hostID, UUID scriptID, UUID storeID, string path) | ||
377 | { | ||
378 | UUID reqID = UUID.Random(); | ||
379 | Util.FireAndForget(delegate(object o) { DoJsonReadValue(scriptID,reqID,storeID,path,true); }); | ||
380 | return reqID; | ||
381 | } | ||
382 | |||
383 | private void DoJsonReadValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson) | ||
384 | { | ||
385 | try | ||
386 | { | ||
387 | m_store.ReadValue(storeID,path,useJson,delegate(string value) { DispatchValue(scriptID,reqID,value); }); | ||
388 | return; | ||
389 | } | ||
390 | catch (Exception e) | ||
391 | { | ||
392 | m_log.InfoFormat("[JsonStoreScripts] unable to retrieve value; {0}",e.ToString()); | ||
393 | } | ||
394 | |||
395 | DispatchValue(scriptID,reqID,String.Empty); | ||
396 | } | ||
397 | |||
398 | #endregion | ||
399 | |||
400 | // ----------------------------------------------------------------- | ||
401 | /// <summary> | ||
402 | /// | ||
403 | /// </summary> | ||
404 | // ----------------------------------------------------------------- | ||
405 | protected void DispatchValue(UUID scriptID, UUID reqID, string value) | ||
406 | { | ||
407 | m_comms.DispatchReply(scriptID,1,value,reqID.ToString()); | ||
408 | } | ||
409 | |||
410 | // ----------------------------------------------------------------- | ||
411 | /// <summary> | ||
412 | /// | ||
413 | /// </summary> | ||
414 | // ----------------------------------------------------------------- | ||
415 | private void DoJsonReadNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID) | ||
416 | { | ||
417 | AssetBase a = m_scene.AssetService.Get(assetID.ToString()); | ||
418 | if (a == null) | ||
419 | GenerateRuntimeError(String.Format("Unable to find notecard asset {0}",assetID)); | ||
420 | |||
421 | if (a.Type != (sbyte)AssetType.Notecard) | ||
422 | GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID)); | ||
423 | |||
424 | m_log.DebugFormat("[JsonStoreScripts] read notecard in context {0}",storeID); | ||
425 | |||
426 | try | ||
427 | { | ||
428 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
429 | string jsondata = SLUtil.ParseNotecardToString(enc.GetString(a.Data)); | ||
430 | int result = m_store.SetValue(storeID,path,jsondata,true) ? 1 : 0; | ||
431 | m_comms.DispatchReply(scriptID,result,"",reqID.ToString()); | ||
432 | return; | ||
433 | } | ||
434 | catch (Exception e) | ||
435 | { | ||
436 | m_log.WarnFormat("[JsonStoreScripts] Json parsing failed; {0}",e.Message); | ||
437 | } | ||
438 | |||
439 | GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString())); | ||
440 | m_comms.DispatchReply(scriptID,0,"",reqID.ToString()); | ||
441 | } | ||
442 | |||
443 | // ----------------------------------------------------------------- | ||
444 | /// <summary> | ||
445 | /// | ||
446 | /// </summary> | ||
447 | // ----------------------------------------------------------------- | ||
448 | private void DoJsonWriteNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string name) | ||
449 | { | ||
450 | string data; | ||
451 | if (! m_store.GetValue(storeID,path,true, out data)) | ||
452 | { | ||
453 | m_comms.DispatchReply(scriptID,0,UUID.Zero.ToString(),reqID.ToString()); | ||
454 | return; | ||
455 | } | ||
456 | |||
457 | SceneObjectPart host = m_scene.GetSceneObjectPart(hostID); | ||
458 | |||
459 | // Create new asset | ||
460 | UUID assetID = UUID.Random(); | ||
461 | AssetBase asset = new AssetBase(assetID, name, (sbyte)AssetType.Notecard, host.OwnerID.ToString()); | ||
462 | asset.Description = "Json store"; | ||
463 | |||
464 | int textLength = data.Length; | ||
465 | data = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " | ||
466 | + textLength.ToString() + "\n" + data + "}\n"; | ||
467 | |||
468 | asset.Data = Util.UTF8.GetBytes(data); | ||
469 | m_scene.AssetService.Store(asset); | ||
470 | |||
471 | // Create Task Entry | ||
472 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
473 | |||
474 | taskItem.ResetIDs(host.UUID); | ||
475 | taskItem.ParentID = host.UUID; | ||
476 | taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch(); | ||
477 | taskItem.Name = asset.Name; | ||
478 | taskItem.Description = asset.Description; | ||
479 | taskItem.Type = (int)AssetType.Notecard; | ||
480 | taskItem.InvType = (int)InventoryType.Notecard; | ||
481 | taskItem.OwnerID = host.OwnerID; | ||
482 | taskItem.CreatorID = host.OwnerID; | ||
483 | taskItem.BasePermissions = (uint)PermissionMask.All; | ||
484 | taskItem.CurrentPermissions = (uint)PermissionMask.All; | ||
485 | taskItem.EveryonePermissions = 0; | ||
486 | taskItem.NextPermissions = (uint)PermissionMask.All; | ||
487 | taskItem.GroupID = host.GroupID; | ||
488 | taskItem.GroupPermissions = 0; | ||
489 | taskItem.Flags = 0; | ||
490 | taskItem.PermsGranter = UUID.Zero; | ||
491 | taskItem.PermsMask = 0; | ||
492 | taskItem.AssetID = asset.FullID; | ||
493 | |||
494 | host.Inventory.AddInventoryItem(taskItem, false); | ||
495 | |||
496 | m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); | ||
497 | } | ||
498 | } | ||
499 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 922eaaf..d192309 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
68 | public Vector3 WorldPosition | 68 | public Vector3 WorldPosition |
69 | { | 69 | { |
70 | get { return GetSP().AbsolutePosition; } | 70 | get { return GetSP().AbsolutePosition; } |
71 | set { GetSP().TeleportWithMomentum(value); } | 71 | set { GetSP().Teleport(value); } |
72 | } | 72 | } |
73 | 73 | ||
74 | public bool IsChildAgent | 74 | public bool IsChildAgent |
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index cab30de..74a85e2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | |||
@@ -38,7 +38,7 @@ using OpenMetaverse; | |||
38 | using System.Linq; | 38 | using System.Linq; |
39 | using System.Linq.Expressions; | 39 | using System.Linq.Expressions; |
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms | 41 | namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms |
42 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] |
44 | class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms | 44 | class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index c3335f0..c9c12c6 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -76,22 +76,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
76 | 76 | ||
77 | public void Say(string message) | 77 | public void Say(string message) |
78 | { | 78 | { |
79 | SendOnChatFromClient(message, ChatTypeEnum.Say); | 79 | SendOnChatFromClient(0, message, ChatTypeEnum.Say); |
80 | } | 80 | } |
81 | 81 | ||
82 | public void Shout(string message) | 82 | public void Say(int channel, string message) |
83 | { | 83 | { |
84 | SendOnChatFromClient(message, ChatTypeEnum.Shout); | 84 | SendOnChatFromClient(channel, message, ChatTypeEnum.Say); |
85 | } | 85 | } |
86 | 86 | ||
87 | public void Whisper(string message) | 87 | public void Shout(int channel, string message) |
88 | { | 88 | { |
89 | SendOnChatFromClient(message, ChatTypeEnum.Whisper); | 89 | SendOnChatFromClient(channel, message, ChatTypeEnum.Shout); |
90 | } | ||
91 | |||
92 | public void Whisper(int channel, string message) | ||
93 | { | ||
94 | SendOnChatFromClient(channel, message, ChatTypeEnum.Whisper); | ||
90 | } | 95 | } |
91 | 96 | ||
92 | public void Broadcast(string message) | 97 | public void Broadcast(string message) |
93 | { | 98 | { |
94 | SendOnChatFromClient(message, ChatTypeEnum.Broadcast); | 99 | SendOnChatFromClient(0, message, ChatTypeEnum.Broadcast); |
95 | } | 100 | } |
96 | 101 | ||
97 | public void GiveMoney(UUID target, int amount) | 102 | public void GiveMoney(UUID target, int amount) |
@@ -146,10 +151,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
146 | 151 | ||
147 | #region Internal Functions | 152 | #region Internal Functions |
148 | 153 | ||
149 | private void SendOnChatFromClient(string message, ChatTypeEnum chatType) | 154 | private void SendOnChatFromClient(int channel, string message, ChatTypeEnum chatType) |
150 | { | 155 | { |
151 | OSChatMessage chatFromClient = new OSChatMessage(); | 156 | OSChatMessage chatFromClient = new OSChatMessage(); |
152 | chatFromClient.Channel = 0; | 157 | chatFromClient.Channel = channel; |
153 | chatFromClient.From = Name; | 158 | chatFromClient.From = Name; |
154 | chatFromClient.Message = message; | 159 | chatFromClient.Message = message; |
155 | chatFromClient.Position = StartPos; | 160 | chatFromClient.Position = StartPos; |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index ebf5e84..9c77b59 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -155,18 +155,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
155 | ScenePresence sp; | 155 | ScenePresence sp; |
156 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 156 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
157 | { | 157 | { |
158 | m_log.DebugFormat( | ||
159 | "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); | ||
160 | |||
161 | sp.CompleteMovement(npcAvatar, false); | 158 | sp.CompleteMovement(npcAvatar, false); |
162 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | 159 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); |
160 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); | ||
163 | } | 161 | } |
164 | else | ||
165 | { | ||
166 | m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); | ||
167 | npcAvatar.AgentId = UUID.Zero; | ||
168 | } | ||
169 | |||
170 | } | 162 | } |
171 | ev.Set(); | 163 | ev.Set(); |
172 | }); | 164 | }); |
@@ -221,6 +213,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
221 | 213 | ||
222 | public bool Say(UUID agentID, Scene scene, string text) | 214 | public bool Say(UUID agentID, Scene scene, string text) |
223 | { | 215 | { |
216 | return Say(agentID, scene, text, 0); | ||
217 | } | ||
218 | |||
219 | public bool Say(UUID agentID, Scene scene, string text, int channel) | ||
220 | { | ||
224 | lock (m_avatars) | 221 | lock (m_avatars) |
225 | { | 222 | { |
226 | if (m_avatars.ContainsKey(agentID)) | 223 | if (m_avatars.ContainsKey(agentID)) |
@@ -228,7 +225,25 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
228 | ScenePresence sp; | 225 | ScenePresence sp; |
229 | scene.TryGetScenePresence(agentID, out sp); | 226 | scene.TryGetScenePresence(agentID, out sp); |
230 | 227 | ||
231 | m_avatars[agentID].Say(text); | 228 | m_avatars[agentID].Say(channel, text); |
229 | |||
230 | return true; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | return false; | ||
235 | } | ||
236 | |||
237 | public bool Shout(UUID agentID, Scene scene, string text, int channel) | ||
238 | { | ||
239 | lock (m_avatars) | ||
240 | { | ||
241 | if (m_avatars.ContainsKey(agentID)) | ||
242 | { | ||
243 | ScenePresence sp; | ||
244 | scene.TryGetScenePresence(agentID, out sp); | ||
245 | |||
246 | m_avatars[agentID].Shout(channel, text); | ||
232 | 247 | ||
233 | return true; | 248 | return true; |
234 | } | 249 | } |
@@ -255,6 +270,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
255 | return false; | 270 | return false; |
256 | } | 271 | } |
257 | 272 | ||
273 | public bool Whisper(UUID agentID, Scene scene, string text, int channel) | ||
274 | { | ||
275 | lock (m_avatars) | ||
276 | { | ||
277 | if (m_avatars.ContainsKey(agentID)) | ||
278 | { | ||
279 | ScenePresence sp; | ||
280 | scene.TryGetScenePresence(agentID, out sp); | ||
281 | |||
282 | m_avatars[agentID].Whisper(channel, text); | ||
283 | |||
284 | return true; | ||
285 | } | ||
286 | } | ||
287 | |||
288 | return false; | ||
289 | } | ||
290 | |||
258 | public bool Stand(UUID agentID, Scene scene) | 291 | public bool Stand(UUID agentID, Scene scene) |
259 | { | 292 | { |
260 | lock (m_avatars) | 293 | lock (m_avatars) |
@@ -308,7 +341,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
308 | scene.RemoveClient(agentID, false); | 341 | scene.RemoveClient(agentID, false); |
309 | m_avatars.Remove(agentID); | 342 | m_avatars.Remove(agentID); |
310 | 343 | ||
311 | // m_log.DebugFormat("[NPC MODULE]: Removed {0} {1}", agentID, av.Name); | 344 | m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); |
312 | return true; | 345 | return true; |
313 | } | 346 | } |
314 | } | 347 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index eea0b2e..a39257e 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -85,7 +85,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
85 | m_attMod = new AttachmentsModule(); | 85 | m_attMod = new AttachmentsModule(); |
86 | m_npcMod = new NPCModule(); | 86 | m_npcMod = new NPCModule(); |
87 | 87 | ||
88 | m_scene = SceneHelpers.SetupScene(); | 88 | m_scene = new SceneHelpers().SetupScene(); |
89 | SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); | 89 | SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); |
90 | } | 90 | } |
91 | 91 | ||
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs index b1a3ff9..e43136a 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs | |||
@@ -36,13 +36,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
36 | { | 36 | { |
37 | public class BasicActor : PhysicsActor | 37 | public class BasicActor : PhysicsActor |
38 | { | 38 | { |
39 | private Vector3 _position; | ||
40 | private Vector3 _velocity; | ||
41 | private Vector3 _acceleration; | ||
42 | private Vector3 _size; | 39 | private Vector3 _size; |
43 | private Vector3 m_rotationalVelocity; | ||
44 | private bool flying; | ||
45 | private bool iscolliding; | ||
46 | 40 | ||
47 | public BasicActor(Vector3 size) | 41 | public BasicActor(Vector3 size) |
48 | { | 42 | { |
@@ -55,11 +49,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
55 | set { return; } | 49 | set { return; } |
56 | } | 50 | } |
57 | 51 | ||
58 | public override Vector3 RotationalVelocity | 52 | public override Vector3 RotationalVelocity { get; set; } |
59 | { | ||
60 | get { return m_rotationalVelocity; } | ||
61 | set { m_rotationalVelocity = value; } | ||
62 | } | ||
63 | 53 | ||
64 | public override bool SetAlwaysRun | 54 | public override bool SetAlwaysRun |
65 | { | 55 | { |
@@ -105,17 +95,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
105 | set { return; } | 95 | set { return; } |
106 | } | 96 | } |
107 | 97 | ||
108 | public override bool Flying | 98 | public override bool Flying { get; set; } |
109 | { | ||
110 | get { return flying; } | ||
111 | set { flying = value; } | ||
112 | } | ||
113 | 99 | ||
114 | public override bool IsColliding | 100 | public override bool IsColliding { get; set; } |
115 | { | ||
116 | get { return iscolliding; } | ||
117 | set { iscolliding = value; } | ||
118 | } | ||
119 | 101 | ||
120 | public override bool CollidingGround | 102 | public override bool CollidingGround |
121 | { | 103 | { |
@@ -134,11 +116,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
134 | get { return false; } | 116 | get { return false; } |
135 | } | 117 | } |
136 | 118 | ||
137 | public override Vector3 Position | 119 | public override Vector3 Position { get; set; } |
138 | { | ||
139 | get { return _position; } | ||
140 | set { _position = value; } | ||
141 | } | ||
142 | 120 | ||
143 | public override Vector3 Size | 121 | public override Vector3 Size |
144 | { | 122 | { |
@@ -206,11 +184,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
206 | get { return Vector3.Zero; } | 184 | get { return Vector3.Zero; } |
207 | } | 185 | } |
208 | 186 | ||
209 | public override Vector3 Velocity | 187 | public override Vector3 Velocity { get; set; } |
210 | { | ||
211 | get { return _velocity; } | ||
212 | set { _velocity = value; } | ||
213 | } | ||
214 | 188 | ||
215 | public override Vector3 Torque | 189 | public override Vector3 Torque |
216 | { | 190 | { |
@@ -230,11 +204,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
230 | set { } | 204 | set { } |
231 | } | 205 | } |
232 | 206 | ||
233 | public override Vector3 Acceleration | 207 | public override Vector3 Acceleration { get; set; } |
234 | { | ||
235 | get { return _acceleration; } | ||
236 | set { _acceleration = value; } | ||
237 | } | ||
238 | 208 | ||
239 | public override bool Kinematic | 209 | public override bool Kinematic |
240 | { | 210 | { |
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs new file mode 100644 index 0000000..b89eeed --- /dev/null +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPrim.cs | |||
@@ -0,0 +1,314 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.Physics.Manager; | ||
34 | |||
35 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin | ||
36 | { | ||
37 | public class BasicPhysicsPrim : PhysicsActor | ||
38 | { | ||
39 | private Vector3 _size; | ||
40 | private PrimitiveBaseShape _shape; | ||
41 | |||
42 | public BasicPhysicsPrim( | ||
43 | string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape) | ||
44 | { | ||
45 | Name = name; | ||
46 | LocalID = localId; | ||
47 | Position = position; | ||
48 | Size = size; | ||
49 | Orientation = orientation; | ||
50 | Shape = shape; | ||
51 | } | ||
52 | |||
53 | public override int PhysicsActorType | ||
54 | { | ||
55 | get { return (int) ActorTypes.Agent; } | ||
56 | set { return; } | ||
57 | } | ||
58 | |||
59 | public override Vector3 RotationalVelocity { get; set; } | ||
60 | |||
61 | public override bool SetAlwaysRun | ||
62 | { | ||
63 | get { return false; } | ||
64 | set { return; } | ||
65 | } | ||
66 | |||
67 | public override uint LocalID | ||
68 | { | ||
69 | set { return; } | ||
70 | } | ||
71 | |||
72 | public override bool Grabbed | ||
73 | { | ||
74 | set { return; } | ||
75 | } | ||
76 | |||
77 | public override bool Selected | ||
78 | { | ||
79 | set { return; } | ||
80 | } | ||
81 | |||
82 | public override float Buoyancy | ||
83 | { | ||
84 | get { return 0f; } | ||
85 | set { return; } | ||
86 | } | ||
87 | |||
88 | public override bool FloatOnWater | ||
89 | { | ||
90 | set { return; } | ||
91 | } | ||
92 | |||
93 | public override bool IsPhysical | ||
94 | { | ||
95 | get { return false; } | ||
96 | set { return; } | ||
97 | } | ||
98 | |||
99 | public override bool ThrottleUpdates | ||
100 | { | ||
101 | get { return false; } | ||
102 | set { return; } | ||
103 | } | ||
104 | |||
105 | public override bool Flying { get; set; } | ||
106 | |||
107 | public override bool IsColliding { get; set; } | ||
108 | |||
109 | public override bool CollidingGround | ||
110 | { | ||
111 | get { return false; } | ||
112 | set { return; } | ||
113 | } | ||
114 | |||
115 | public override bool CollidingObj | ||
116 | { | ||
117 | get { return false; } | ||
118 | set { return; } | ||
119 | } | ||
120 | |||
121 | public override bool Stopped | ||
122 | { | ||
123 | get { return false; } | ||
124 | } | ||
125 | |||
126 | public override Vector3 Position { get; set; } | ||
127 | |||
128 | public override Vector3 Size | ||
129 | { | ||
130 | get { return _size; } | ||
131 | set { | ||
132 | _size = value; | ||
133 | _size.Z = _size.Z / 2.0f; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | public override PrimitiveBaseShape Shape | ||
138 | { | ||
139 | set { _shape = value; } | ||
140 | } | ||
141 | |||
142 | public override float Mass | ||
143 | { | ||
144 | get { return 0f; } | ||
145 | } | ||
146 | |||
147 | public override Vector3 Force | ||
148 | { | ||
149 | get { return Vector3.Zero; } | ||
150 | set { return; } | ||
151 | } | ||
152 | |||
153 | public override int VehicleType | ||
154 | { | ||
155 | get { return 0; } | ||
156 | set { return; } | ||
157 | } | ||
158 | |||
159 | public override void VehicleFloatParam(int param, float value) | ||
160 | { | ||
161 | |||
162 | } | ||
163 | |||
164 | public override void VehicleVectorParam(int param, Vector3 value) | ||
165 | { | ||
166 | |||
167 | } | ||
168 | |||
169 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
170 | { | ||
171 | |||
172 | } | ||
173 | |||
174 | public override void VehicleFlags(int param, bool remove) | ||
175 | { | ||
176 | |||
177 | } | ||
178 | |||
179 | public override void SetVolumeDetect(int param) | ||
180 | { | ||
181 | |||
182 | } | ||
183 | |||
184 | public override Vector3 CenterOfMass | ||
185 | { | ||
186 | get { return Vector3.Zero; } | ||
187 | } | ||
188 | |||
189 | public override Vector3 GeometricCenter | ||
190 | { | ||
191 | get { return Vector3.Zero; } | ||
192 | } | ||
193 | |||
194 | public override Vector3 Velocity { get; set; } | ||
195 | |||
196 | public override Vector3 Torque | ||
197 | { | ||
198 | get { return Vector3.Zero; } | ||
199 | set { return; } | ||
200 | } | ||
201 | |||
202 | public override float CollisionScore | ||
203 | { | ||
204 | get { return 0f; } | ||
205 | set { } | ||
206 | } | ||
207 | |||
208 | public override Quaternion Orientation { get; set; } | ||
209 | |||
210 | public override Vector3 Acceleration { get; set; } | ||
211 | |||
212 | public override bool Kinematic | ||
213 | { | ||
214 | get { return true; } | ||
215 | set { } | ||
216 | } | ||
217 | |||
218 | public override void link(PhysicsActor obj) | ||
219 | { | ||
220 | } | ||
221 | |||
222 | public override void delink() | ||
223 | { | ||
224 | } | ||
225 | |||
226 | public override void LockAngularMotion(Vector3 axis) | ||
227 | { | ||
228 | } | ||
229 | |||
230 | public override void AddForce(Vector3 force, bool pushforce) | ||
231 | { | ||
232 | } | ||
233 | |||
234 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
235 | { | ||
236 | } | ||
237 | |||
238 | public override void SetMomentum(Vector3 momentum) | ||
239 | { | ||
240 | } | ||
241 | |||
242 | public override void CrossingFailure() | ||
243 | { | ||
244 | } | ||
245 | |||
246 | public override Vector3 PIDTarget | ||
247 | { | ||
248 | set { return; } | ||
249 | } | ||
250 | |||
251 | public override bool PIDActive | ||
252 | { | ||
253 | set { return; } | ||
254 | } | ||
255 | |||
256 | public override float PIDTau | ||
257 | { | ||
258 | set { return; } | ||
259 | } | ||
260 | |||
261 | public override float PIDHoverHeight | ||
262 | { | ||
263 | set { return; } | ||
264 | } | ||
265 | |||
266 | public override bool PIDHoverActive | ||
267 | { | ||
268 | set { return; } | ||
269 | } | ||
270 | |||
271 | public override PIDHoverType PIDHoverType | ||
272 | { | ||
273 | set { return; } | ||
274 | } | ||
275 | |||
276 | public override float PIDHoverTau | ||
277 | { | ||
278 | set { return; } | ||
279 | } | ||
280 | |||
281 | public override Quaternion APIDTarget | ||
282 | { | ||
283 | set { return; } | ||
284 | } | ||
285 | |||
286 | public override bool APIDActive | ||
287 | { | ||
288 | set { return; } | ||
289 | } | ||
290 | |||
291 | public override float APIDStrength | ||
292 | { | ||
293 | set { return; } | ||
294 | } | ||
295 | |||
296 | public override float APIDDamping | ||
297 | { | ||
298 | set { return; } | ||
299 | } | ||
300 | |||
301 | public override void SubscribeEvents(int ms) | ||
302 | { | ||
303 | } | ||
304 | |||
305 | public override void UnSubscribeEvents() | ||
306 | { | ||
307 | } | ||
308 | |||
309 | public override bool SubscribedEvents() | ||
310 | { | ||
311 | return false; | ||
312 | } | ||
313 | } | ||
314 | } | ||
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs index 2e14216..f5826ed 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs | |||
@@ -34,9 +34,17 @@ using OpenSim.Region.Physics.Manager; | |||
34 | 34 | ||
35 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin | 35 | namespace OpenSim.Region.Physics.BasicPhysicsPlugin |
36 | { | 36 | { |
37 | /// <summary> | ||
38 | /// This is an incomplete extremely basic physics implementation | ||
39 | /// </summary> | ||
40 | /// <remarks> | ||
41 | /// Not useful for anything at the moment apart from some regression testing in other components where some form | ||
42 | /// of physics plugin is needed. | ||
43 | /// </remarks> | ||
37 | public class BasicScene : PhysicsScene | 44 | public class BasicScene : PhysicsScene |
38 | { | 45 | { |
39 | private List<BasicActor> _actors = new List<BasicActor>(); | 46 | private List<BasicActor> _actors = new List<BasicActor>(); |
47 | private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>(); | ||
40 | private float[] _heightMap; | 48 | private float[] _heightMap; |
41 | 49 | ||
42 | //protected internal string sceneIdentifier; | 50 | //protected internal string sceneIdentifier; |
@@ -50,10 +58,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
50 | { | 58 | { |
51 | } | 59 | } |
52 | 60 | ||
53 | public override void Dispose() | 61 | public override void Dispose() {} |
62 | |||
63 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
64 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) | ||
54 | { | 65 | { |
66 | BasicPhysicsPrim prim = new BasicPhysicsPrim(primName, localid, position, size, rotation, pbs); | ||
67 | prim.IsPhysical = isPhysical; | ||
68 | |||
69 | _prims.Add(prim); | ||
55 | 70 | ||
71 | return prim; | ||
56 | } | 72 | } |
73 | |||
57 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | 74 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) |
58 | { | 75 | { |
59 | BasicActor act = new BasicActor(size); | 76 | BasicActor act = new BasicActor(size); |
@@ -63,30 +80,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
63 | return act; | 80 | return act; |
64 | } | 81 | } |
65 | 82 | ||
66 | public override void RemovePrim(PhysicsActor prim) | 83 | public override void RemovePrim(PhysicsActor actor) |
67 | { | 84 | { |
85 | BasicPhysicsPrim prim = (BasicPhysicsPrim)actor; | ||
86 | if (_prims.Contains(prim)) | ||
87 | _prims.Remove(prim); | ||
68 | } | 88 | } |
69 | 89 | ||
70 | public override void RemoveAvatar(PhysicsActor actor) | 90 | public override void RemoveAvatar(PhysicsActor actor) |
71 | { | 91 | { |
72 | BasicActor act = (BasicActor) actor; | 92 | BasicActor act = (BasicActor)actor; |
73 | if (_actors.Contains(act)) | 93 | if (_actors.Contains(act)) |
74 | { | ||
75 | _actors.Remove(act); | 94 | _actors.Remove(act); |
76 | } | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation) | ||
81 | { | ||
82 | return null; | ||
83 | } | ||
84 | */ | ||
85 | |||
86 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
87 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) | ||
88 | { | ||
89 | return null; | ||
90 | } | 95 | } |
91 | 96 | ||
92 | public override void AddPhysicsActorTaint(PhysicsActor prim) | 97 | public override void AddPhysicsActorTaint(PhysicsActor prim) |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 6f37347..a41c856 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -156,7 +156,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
156 | /// </summary> | 156 | /// </summary> |
157 | public IntPtr m_targetSpace = IntPtr.Zero; | 157 | public IntPtr m_targetSpace = IntPtr.Zero; |
158 | 158 | ||
159 | /// <summary> | ||
160 | /// The prim geometry, used for collision detection. | ||
161 | /// </summary> | ||
162 | /// <remarks> | ||
163 | /// This is never null except for a brief period when the geometry needs to be replaced (due to resizing or | ||
164 | /// mesh change) or when the physical prim is being removed from the scene. | ||
165 | /// </remarks> | ||
159 | public IntPtr prim_geom { get; private set; } | 166 | public IntPtr prim_geom { get; private set; } |
167 | |||
160 | public IntPtr _triMeshData { get; private set; } | 168 | public IntPtr _triMeshData { get; private set; } |
161 | 169 | ||
162 | private IntPtr _linkJointGroup = IntPtr.Zero; | 170 | private IntPtr _linkJointGroup = IntPtr.Zero; |
@@ -325,14 +333,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
325 | { | 333 | { |
326 | prim_geom = geom; | 334 | prim_geom = geom; |
327 | //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); | 335 | //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); |
328 | if (prim_geom != IntPtr.Zero) | ||
329 | { | ||
330 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
331 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
332 | 336 | ||
333 | _parent_scene.geom_name_map[prim_geom] = Name; | 337 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); |
334 | _parent_scene.actor_name_map[prim_geom] = this; | 338 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
335 | } | 339 | |
340 | _parent_scene.geom_name_map[prim_geom] = Name; | ||
341 | _parent_scene.actor_name_map[prim_geom] = this; | ||
336 | 342 | ||
337 | if (childPrim) | 343 | if (childPrim) |
338 | { | 344 | { |
@@ -765,11 +771,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
765 | m_collisionCategories &= ~CollisionCategories.Body; | 771 | m_collisionCategories &= ~CollisionCategories.Body; |
766 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); | 772 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); |
767 | 773 | ||
768 | if (prim_geom != IntPtr.Zero) | 774 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); |
769 | { | 775 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
770 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
771 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
772 | } | ||
773 | 776 | ||
774 | d.BodyDestroy(Body); | 777 | d.BodyDestroy(Body); |
775 | lock (childrenPrim) | 778 | lock (childrenPrim) |
@@ -793,11 +796,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
793 | m_collisionCategories &= ~CollisionCategories.Body; | 796 | m_collisionCategories &= ~CollisionCategories.Body; |
794 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); | 797 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); |
795 | 798 | ||
796 | if (prim_geom != IntPtr.Zero) | 799 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); |
797 | { | 800 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
798 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
799 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
800 | } | ||
801 | 801 | ||
802 | Body = IntPtr.Zero; | 802 | Body = IntPtr.Zero; |
803 | } | 803 | } |
@@ -864,10 +864,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
864 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | 864 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); |
865 | try | 865 | try |
866 | { | 866 | { |
867 | if (prim_geom == IntPtr.Zero) | 867 | SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); |
868 | { | ||
869 | SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); | ||
870 | } | ||
871 | } | 868 | } |
872 | catch (AccessViolationException) | 869 | catch (AccessViolationException) |
873 | { | 870 | { |
@@ -890,73 +887,67 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
890 | #if SPAM | 887 | #if SPAM |
891 | Console.WriteLine("ZProcessTaints for " + Name); | 888 | Console.WriteLine("ZProcessTaints for " + Name); |
892 | #endif | 889 | #endif |
890 | |||
891 | // This must be processed as the very first taint so that later operations have a prim_geom to work with | ||
892 | // if this is a new prim. | ||
893 | if (m_taintadd) | 893 | if (m_taintadd) |
894 | { | ||
895 | changeadd(); | 894 | changeadd(); |
896 | } | ||
897 | |||
898 | if (prim_geom != IntPtr.Zero) | ||
899 | { | ||
900 | if (!_position.ApproxEquals(m_taintposition, 0f)) | ||
901 | changemove(); | ||
902 | 895 | ||
903 | if (m_taintrot != _orientation) | 896 | if (!_position.ApproxEquals(m_taintposition, 0f)) |
904 | { | 897 | changemove(); |
905 | if (childPrim && IsPhysical) // For physical child prim... | 898 | |
906 | { | 899 | if (m_taintrot != _orientation) |
907 | rotate(); | 900 | { |
908 | // KF: ODE will also rotate the parent prim! | 901 | if (childPrim && IsPhysical) // For physical child prim... |
909 | // so rotate the root back to where it was | 902 | { |
910 | OdePrim parent = (OdePrim)_parent; | 903 | rotate(); |
911 | parent.rotate(); | 904 | // KF: ODE will also rotate the parent prim! |
912 | } | 905 | // so rotate the root back to where it was |
913 | else | 906 | OdePrim parent = (OdePrim)_parent; |
914 | { | 907 | parent.rotate(); |
915 | //Just rotate the prim | ||
916 | rotate(); | ||
917 | } | ||
918 | } | 908 | } |
919 | 909 | else | |
920 | if (m_taintPhysics != IsPhysical && !(m_taintparent != _parent)) | 910 | { |
921 | changePhysicsStatus(); | 911 | //Just rotate the prim |
912 | rotate(); | ||
913 | } | ||
914 | } | ||
915 | |||
916 | if (m_taintPhysics != IsPhysical && !(m_taintparent != _parent)) | ||
917 | changePhysicsStatus(); | ||
922 | 918 | ||
923 | if (!_size.ApproxEquals(m_taintsize, 0f)) | 919 | if (!_size.ApproxEquals(m_taintsize, 0f)) |
924 | changesize(); | 920 | changesize(); |
925 | 921 | ||
926 | if (m_taintshape) | 922 | if (m_taintshape) |
927 | changeshape(); | 923 | changeshape(); |
928 | 924 | ||
929 | if (m_taintforce) | 925 | if (m_taintforce) |
930 | changeAddForce(); | 926 | changeAddForce(); |
931 | 927 | ||
932 | if (m_taintaddangularforce) | 928 | if (m_taintaddangularforce) |
933 | changeAddAngularForce(); | 929 | changeAddAngularForce(); |
934 | 930 | ||
935 | if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f)) | 931 | if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f)) |
936 | changeSetTorque(); | 932 | changeSetTorque(); |
937 | 933 | ||
938 | if (m_taintdisable) | 934 | if (m_taintdisable) |
939 | changedisable(); | 935 | changedisable(); |
940 | 936 | ||
941 | if (m_taintselected != m_isSelected) | 937 | if (m_taintselected != m_isSelected) |
942 | changeSelectedStatus(); | 938 | changeSelectedStatus(); |
943 | 939 | ||
944 | if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) | 940 | if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f)) |
945 | changevelocity(); | 941 | changevelocity(); |
946 | 942 | ||
947 | if (m_taintparent != _parent) | 943 | if (m_taintparent != _parent) |
948 | changelink(); | 944 | changelink(); |
949 | 945 | ||
950 | if (m_taintCollidesWater != m_collidesWater) | 946 | if (m_taintCollidesWater != m_collidesWater) |
951 | changefloatonwater(); | 947 | changefloatonwater(); |
952 | 948 | ||
953 | if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) | 949 | if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) |
954 | changeAngularLock(); | 950 | changeAngularLock(); |
955 | } | ||
956 | else | ||
957 | { | ||
958 | m_log.ErrorFormat("[PHYSICS]: The scene reused a disposed PhysActor for {0}! *waves finger*, Don't be evil. A couple of things can cause this. An improper prim breakdown(be sure to set prim_geom to zero after d.GeomDestroy! An improper buildup (creating the geom failed). Or, the Scene Reused a physics actor after disposing it.)", Name); | ||
959 | } | ||
960 | } | 951 | } |
961 | 952 | ||
962 | /// <summary> | 953 | /// <summary> |
@@ -1052,150 +1043,146 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1052 | /// <param name="prim">Child prim</param> | 1043 | /// <param name="prim">Child prim</param> |
1053 | private void AddChildPrim(OdePrim prim) | 1044 | private void AddChildPrim(OdePrim prim) |
1054 | { | 1045 | { |
1055 | //Console.WriteLine("AddChildPrim " + Name); | 1046 | if (LocalID == prim.LocalID) |
1056 | if (LocalID != prim.LocalID) | 1047 | return; |
1048 | |||
1049 | if (Body == IntPtr.Zero) | ||
1057 | { | 1050 | { |
1058 | if (Body == IntPtr.Zero) | 1051 | Body = d.BodyCreate(_parent_scene.world); |
1052 | setMass(); | ||
1053 | } | ||
1054 | |||
1055 | lock (childrenPrim) | ||
1056 | { | ||
1057 | if (childrenPrim.Contains(prim)) | ||
1058 | return; | ||
1059 | |||
1060 | // m_log.DebugFormat( | ||
1061 | // "[ODE PRIM]: Linking prim {0} {1} to {2} {3}", prim.Name, prim.LocalID, Name, LocalID); | ||
1062 | |||
1063 | childrenPrim.Add(prim); | ||
1064 | |||
1065 | foreach (OdePrim prm in childrenPrim) | ||
1059 | { | 1066 | { |
1060 | Body = d.BodyCreate(_parent_scene.world); | 1067 | d.Mass m2; |
1061 | setMass(); | 1068 | d.MassSetZero(out m2); |
1069 | d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); | ||
1070 | |||
1071 | d.Quaternion quat = new d.Quaternion(); | ||
1072 | quat.W = prm._orientation.W; | ||
1073 | quat.X = prm._orientation.X; | ||
1074 | quat.Y = prm._orientation.Y; | ||
1075 | quat.Z = prm._orientation.Z; | ||
1076 | |||
1077 | d.Matrix3 mat = new d.Matrix3(); | ||
1078 | d.RfromQ(out mat, ref quat); | ||
1079 | d.MassRotate(ref m2, ref mat); | ||
1080 | d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z); | ||
1081 | d.MassAdd(ref pMass, ref m2); | ||
1062 | } | 1082 | } |
1063 | if (Body != IntPtr.Zero) | 1083 | |
1084 | foreach (OdePrim prm in childrenPrim) | ||
1064 | { | 1085 | { |
1065 | lock (childrenPrim) | 1086 | prm.m_collisionCategories |= CollisionCategories.Body; |
1066 | { | 1087 | prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); |
1067 | if (!childrenPrim.Contains(prim)) | ||
1068 | { | ||
1069 | //Console.WriteLine("childrenPrim.Add " + prim); | ||
1070 | childrenPrim.Add(prim); | ||
1071 | |||
1072 | foreach (OdePrim prm in childrenPrim) | ||
1073 | { | ||
1074 | d.Mass m2; | ||
1075 | d.MassSetZero(out m2); | ||
1076 | d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); | ||
1077 | |||
1078 | d.Quaternion quat = new d.Quaternion(); | ||
1079 | quat.W = prm._orientation.W; | ||
1080 | quat.X = prm._orientation.X; | ||
1081 | quat.Y = prm._orientation.Y; | ||
1082 | quat.Z = prm._orientation.Z; | ||
1083 | |||
1084 | d.Matrix3 mat = new d.Matrix3(); | ||
1085 | d.RfromQ(out mat, ref quat); | ||
1086 | d.MassRotate(ref m2, ref mat); | ||
1087 | d.MassTranslate(ref m2, Position.X - prm.Position.X, Position.Y - prm.Position.Y, Position.Z - prm.Position.Z); | ||
1088 | d.MassAdd(ref pMass, ref m2); | ||
1089 | } | ||
1090 | |||
1091 | foreach (OdePrim prm in childrenPrim) | ||
1092 | { | ||
1093 | prm.m_collisionCategories |= CollisionCategories.Body; | ||
1094 | prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | ||
1095 | 1088 | ||
1096 | if (prm.prim_geom == IntPtr.Zero) | ||
1097 | { | ||
1098 | m_log.WarnFormat( | ||
1099 | "[PHYSICS]: Unable to link one of the linkset elements {0} for parent {1}. No geom yet", | ||
1100 | prm.Name, prim.Name); | ||
1101 | continue; | ||
1102 | } | ||
1103 | //Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name); | 1089 | //Console.WriteLine(" GeomSetCategoryBits 1: " + prm.prim_geom + " - " + (int)prm.m_collisionCategories + " for " + Name); |
1104 | d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); | 1090 | d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); |
1105 | d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); | 1091 | d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); |
1106 | |||
1107 | 1092 | ||
1108 | d.Quaternion quat = new d.Quaternion(); | 1093 | d.Quaternion quat = new d.Quaternion(); |
1109 | quat.W = prm._orientation.W; | 1094 | quat.W = prm._orientation.W; |
1110 | quat.X = prm._orientation.X; | 1095 | quat.X = prm._orientation.X; |
1111 | quat.Y = prm._orientation.Y; | 1096 | quat.Y = prm._orientation.Y; |
1112 | quat.Z = prm._orientation.Z; | 1097 | quat.Z = prm._orientation.Z; |
1113 | 1098 | ||
1114 | d.Matrix3 mat = new d.Matrix3(); | 1099 | d.Matrix3 mat = new d.Matrix3(); |
1115 | d.RfromQ(out mat, ref quat); | 1100 | d.RfromQ(out mat, ref quat); |
1116 | if (Body != IntPtr.Zero) | 1101 | if (Body != IntPtr.Zero) |
1117 | { | 1102 | { |
1118 | d.GeomSetBody(prm.prim_geom, Body); | 1103 | d.GeomSetBody(prm.prim_geom, Body); |
1119 | prm.childPrim = true; | 1104 | prm.childPrim = true; |
1120 | d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z); | 1105 | d.GeomSetOffsetWorldPosition(prm.prim_geom, prm.Position.X , prm.Position.Y, prm.Position.Z); |
1121 | //d.GeomSetOffsetPosition(prim.prim_geom, | 1106 | //d.GeomSetOffsetPosition(prim.prim_geom, |
1122 | // (Position.X - prm.Position.X) - pMass.c.X, | 1107 | // (Position.X - prm.Position.X) - pMass.c.X, |
1123 | // (Position.Y - prm.Position.Y) - pMass.c.Y, | 1108 | // (Position.Y - prm.Position.Y) - pMass.c.Y, |
1124 | // (Position.Z - prm.Position.Z) - pMass.c.Z); | 1109 | // (Position.Z - prm.Position.Z) - pMass.c.Z); |
1125 | d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); | 1110 | d.GeomSetOffsetWorldRotation(prm.prim_geom, ref mat); |
1126 | //d.GeomSetOffsetRotation(prm.prim_geom, ref mat); | 1111 | //d.GeomSetOffsetRotation(prm.prim_geom, ref mat); |
1127 | d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); | 1112 | d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); |
1128 | d.BodySetMass(Body, ref pMass); | 1113 | d.BodySetMass(Body, ref pMass); |
1129 | } | 1114 | } |
1130 | else | 1115 | else |
1131 | { | 1116 | { |
1132 | m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name); | 1117 | m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name); |
1133 | } | 1118 | } |
1134 | 1119 | ||
1135 | prm.m_interpenetrationcount = 0; | 1120 | prm.m_interpenetrationcount = 0; |
1136 | prm.m_collisionscore = 0; | 1121 | prm.m_collisionscore = 0; |
1137 | prm.m_disabled = false; | 1122 | prm.m_disabled = false; |
1138 | 1123 | ||
1139 | // The body doesn't already have a finite rotation mode set here | 1124 | // The body doesn't already have a finite rotation mode set here |
1140 | if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) | 1125 | if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) |
1141 | { | 1126 | { |
1142 | prm.createAMotor(m_angularlock); | 1127 | prm.createAMotor(m_angularlock); |
1143 | } | 1128 | } |
1144 | prm.Body = Body; | 1129 | prm.Body = Body; |
1145 | _parent_scene.ActivatePrim(prm); | 1130 | _parent_scene.ActivatePrim(prm); |
1146 | } | 1131 | } |
1147 | 1132 | ||
1148 | m_collisionCategories |= CollisionCategories.Body; | 1133 | m_collisionCategories |= CollisionCategories.Body; |
1149 | m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | 1134 | m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); |
1150 | 1135 | ||
1151 | //Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + Name); | 1136 | //Console.WriteLine("GeomSetCategoryBits 2: " + prim_geom + " - " + (int)m_collisionCategories + " for " + Name); |
1152 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | 1137 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); |
1153 | //Console.WriteLine(" Post GeomSetCategoryBits 2"); | 1138 | //Console.WriteLine(" Post GeomSetCategoryBits 2"); |
1154 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | 1139 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
1155 | |||
1156 | d.Quaternion quat2 = new d.Quaternion(); | ||
1157 | quat2.W = _orientation.W; | ||
1158 | quat2.X = _orientation.X; | ||
1159 | quat2.Y = _orientation.Y; | ||
1160 | quat2.Z = _orientation.Z; | ||
1161 | |||
1162 | d.Matrix3 mat2 = new d.Matrix3(); | ||
1163 | d.RfromQ(out mat2, ref quat2); | ||
1164 | d.GeomSetBody(prim_geom, Body); | ||
1165 | d.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z); | ||
1166 | //d.GeomSetOffsetPosition(prim.prim_geom, | ||
1167 | // (Position.X - prm.Position.X) - pMass.c.X, | ||
1168 | // (Position.Y - prm.Position.Y) - pMass.c.Y, | ||
1169 | // (Position.Z - prm.Position.Z) - pMass.c.Z); | ||
1170 | //d.GeomSetOffsetRotation(prim_geom, ref mat2); | ||
1171 | d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); | ||
1172 | d.BodySetMass(Body, ref pMass); | ||
1173 | |||
1174 | d.BodySetAutoDisableFlag(Body, true); | ||
1175 | d.BodySetAutoDisableSteps(Body, body_autodisable_frames); | ||
1176 | 1140 | ||
1177 | m_interpenetrationcount = 0; | 1141 | d.Quaternion quat2 = new d.Quaternion(); |
1178 | m_collisionscore = 0; | 1142 | quat2.W = _orientation.W; |
1179 | m_disabled = false; | 1143 | quat2.X = _orientation.X; |
1144 | quat2.Y = _orientation.Y; | ||
1145 | quat2.Z = _orientation.Z; | ||
1180 | 1146 | ||
1181 | // The body doesn't already have a finite rotation mode set here | 1147 | d.Matrix3 mat2 = new d.Matrix3(); |
1182 | if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) | 1148 | d.RfromQ(out mat2, ref quat2); |
1183 | { | 1149 | d.GeomSetBody(prim_geom, Body); |
1184 | createAMotor(m_angularlock); | 1150 | d.GeomSetOffsetWorldPosition(prim_geom, Position.X - pMass.c.X, Position.Y - pMass.c.Y, Position.Z - pMass.c.Z); |
1185 | } | 1151 | //d.GeomSetOffsetPosition(prim.prim_geom, |
1186 | d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); | 1152 | // (Position.X - prm.Position.X) - pMass.c.X, |
1187 | if (m_vehicle.Type != Vehicle.TYPE_NONE) | 1153 | // (Position.Y - prm.Position.Y) - pMass.c.Y, |
1188 | m_vehicle.Enable(Body, _parent_scene); | 1154 | // (Position.Z - prm.Position.Z) - pMass.c.Z); |
1155 | //d.GeomSetOffsetRotation(prim_geom, ref mat2); | ||
1156 | d.MassTranslate(ref pMass, -pMass.c.X, -pMass.c.Y, -pMass.c.Z); | ||
1157 | d.BodySetMass(Body, ref pMass); | ||
1189 | 1158 | ||
1190 | _parent_scene.ActivatePrim(this); | 1159 | d.BodySetAutoDisableFlag(Body, true); |
1191 | } | 1160 | d.BodySetAutoDisableSteps(Body, body_autodisable_frames); |
1192 | } | 1161 | |
1162 | m_interpenetrationcount = 0; | ||
1163 | m_collisionscore = 0; | ||
1164 | m_disabled = false; | ||
1165 | |||
1166 | // The body doesn't already have a finite rotation mode set here | ||
1167 | if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) | ||
1168 | { | ||
1169 | createAMotor(m_angularlock); | ||
1193 | } | 1170 | } |
1171 | |||
1172 | d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); | ||
1173 | |||
1174 | if (m_vehicle.Type != Vehicle.TYPE_NONE) | ||
1175 | m_vehicle.Enable(Body, _parent_scene); | ||
1176 | |||
1177 | _parent_scene.ActivatePrim(this); | ||
1194 | } | 1178 | } |
1195 | } | 1179 | } |
1196 | 1180 | ||
1197 | private void ChildSetGeom(OdePrim odePrim) | 1181 | private void ChildSetGeom(OdePrim odePrim) |
1198 | { | 1182 | { |
1183 | // m_log.DebugFormat( | ||
1184 | // "[ODE PRIM]: ChildSetGeom {0} {1} for {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID); | ||
1185 | |||
1199 | //if (IsPhysical && Body != IntPtr.Zero) | 1186 | //if (IsPhysical && Body != IntPtr.Zero) |
1200 | lock (childrenPrim) | 1187 | lock (childrenPrim) |
1201 | { | 1188 | { |
@@ -1210,12 +1197,14 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1210 | //prm.childPrim = false; | 1197 | //prm.childPrim = false; |
1211 | } | 1198 | } |
1212 | } | 1199 | } |
1200 | |||
1213 | disableBody(); | 1201 | disableBody(); |
1214 | 1202 | ||
1215 | if (Body != IntPtr.Zero) | 1203 | // Spurious - Body == IntPtr.Zero after disableBody() |
1216 | { | 1204 | // if (Body != IntPtr.Zero) |
1217 | _parent_scene.DeactivatePrim(this); | 1205 | // { |
1218 | } | 1206 | // _parent_scene.DeactivatePrim(this); |
1207 | // } | ||
1219 | 1208 | ||
1220 | lock (childrenPrim) | 1209 | lock (childrenPrim) |
1221 | { | 1210 | { |
@@ -1229,6 +1218,9 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1229 | 1218 | ||
1230 | private void ChildDelink(OdePrim odePrim) | 1219 | private void ChildDelink(OdePrim odePrim) |
1231 | { | 1220 | { |
1221 | // m_log.DebugFormat( | ||
1222 | // "[ODE PRIM]: Delinking prim {0} {1} from {2} {3}", odePrim.Name, odePrim.LocalID, Name, LocalID); | ||
1223 | |||
1232 | // Okay, we have a delinked child.. need to rebuild the body. | 1224 | // Okay, we have a delinked child.. need to rebuild the body. |
1233 | lock (childrenPrim) | 1225 | lock (childrenPrim) |
1234 | { | 1226 | { |
@@ -1243,6 +1235,7 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1243 | //prm.childPrim = false; | 1235 | //prm.childPrim = false; |
1244 | } | 1236 | } |
1245 | } | 1237 | } |
1238 | |||
1246 | disableBody(); | 1239 | disableBody(); |
1247 | 1240 | ||
1248 | lock (childrenPrim) | 1241 | lock (childrenPrim) |
@@ -1251,10 +1244,11 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1251 | childrenPrim.Remove(odePrim); | 1244 | childrenPrim.Remove(odePrim); |
1252 | } | 1245 | } |
1253 | 1246 | ||
1254 | if (Body != IntPtr.Zero) | 1247 | // Spurious - Body == IntPtr.Zero after disableBody() |
1255 | { | 1248 | // if (Body != IntPtr.Zero) |
1256 | _parent_scene.DeactivatePrim(this); | 1249 | // { |
1257 | } | 1250 | // _parent_scene.DeactivatePrim(this); |
1251 | // } | ||
1258 | 1252 | ||
1259 | lock (childrenPrim) | 1253 | lock (childrenPrim) |
1260 | { | 1254 | { |
@@ -1303,11 +1297,8 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1303 | disableBodySoft(); | 1297 | disableBodySoft(); |
1304 | } | 1298 | } |
1305 | 1299 | ||
1306 | if (prim_geom != IntPtr.Zero) | 1300 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); |
1307 | { | 1301 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
1308 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1309 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1310 | } | ||
1311 | 1302 | ||
1312 | if (IsPhysical) | 1303 | if (IsPhysical) |
1313 | { | 1304 | { |
@@ -1328,11 +1319,8 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1328 | if (m_collidesWater) | 1319 | if (m_collidesWater) |
1329 | m_collisionFlags |= CollisionCategories.Water; | 1320 | m_collisionFlags |= CollisionCategories.Water; |
1330 | 1321 | ||
1331 | if (prim_geom != IntPtr.Zero) | 1322 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); |
1332 | { | 1323 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
1333 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1334 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1335 | } | ||
1336 | 1324 | ||
1337 | if (IsPhysical) | 1325 | if (IsPhysical) |
1338 | { | 1326 | { |
@@ -1472,6 +1460,9 @@ Console.WriteLine("CreateGeom:"); | |||
1472 | } | 1460 | } |
1473 | else | 1461 | else |
1474 | { | 1462 | { |
1463 | m_log.WarnFormat( | ||
1464 | "[ODE PRIM]: Called RemoveGeom() on {0} {1} where geometry was already null.", Name, LocalID); | ||
1465 | |||
1475 | return false; | 1466 | return false; |
1476 | } | 1467 | } |
1477 | } | 1468 | } |
@@ -1505,16 +1496,13 @@ Console.WriteLine("changeadd 1"); | |||
1505 | #endif | 1496 | #endif |
1506 | CreateGeom(m_targetSpace, mesh); | 1497 | CreateGeom(m_targetSpace, mesh); |
1507 | 1498 | ||
1508 | if (prim_geom != IntPtr.Zero) | 1499 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
1509 | { | 1500 | d.Quaternion myrot = new d.Quaternion(); |
1510 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 1501 | myrot.X = _orientation.X; |
1511 | d.Quaternion myrot = new d.Quaternion(); | 1502 | myrot.Y = _orientation.Y; |
1512 | myrot.X = _orientation.X; | 1503 | myrot.Z = _orientation.Z; |
1513 | myrot.Y = _orientation.Y; | 1504 | myrot.W = _orientation.W; |
1514 | myrot.Z = _orientation.Z; | 1505 | d.GeomSetQuaternion(prim_geom, ref myrot); |
1515 | myrot.W = _orientation.W; | ||
1516 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
1517 | } | ||
1518 | 1506 | ||
1519 | if (IsPhysical && Body == IntPtr.Zero) | 1507 | if (IsPhysical && Body == IntPtr.Zero) |
1520 | enableBody(); | 1508 | enableBody(); |
@@ -1579,24 +1567,20 @@ Console.WriteLine(" JointCreateFixed"); | |||
1579 | //m_log.Debug("[BUG]: race!"); | 1567 | //m_log.Debug("[BUG]: race!"); |
1580 | //} | 1568 | //} |
1581 | } | 1569 | } |
1582 | else | ||
1583 | { | ||
1584 | // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); | ||
1585 | // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); | ||
1586 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1587 | 1570 | ||
1588 | IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); | 1571 | // string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); |
1589 | m_targetSpace = tempspace; | 1572 | // int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); |
1573 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1574 | |||
1575 | IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); | ||
1576 | m_targetSpace = tempspace; | ||
1590 | 1577 | ||
1591 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1578 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); |
1592 | if (prim_geom != IntPtr.Zero) | 1579 | |
1593 | { | 1580 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
1594 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
1595 | 1581 | ||
1596 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1582 | // _parent_scene.waitForSpaceUnlock(m_targetSpace); |
1597 | d.SpaceAdd(m_targetSpace, prim_geom); | 1583 | d.SpaceAdd(m_targetSpace, prim_geom); |
1598 | } | ||
1599 | } | ||
1600 | 1584 | ||
1601 | changeSelectedStatus(); | 1585 | changeSelectedStatus(); |
1602 | 1586 | ||
@@ -2047,18 +2031,16 @@ Console.WriteLine(" JointCreateFixed"); | |||
2047 | { | 2031 | { |
2048 | m_collidesWater = m_taintCollidesWater; | 2032 | m_collidesWater = m_taintCollidesWater; |
2049 | 2033 | ||
2050 | if (prim_geom != IntPtr.Zero) | 2034 | if (m_collidesWater) |
2051 | { | 2035 | { |
2052 | if (m_collidesWater) | 2036 | m_collisionFlags |= CollisionCategories.Water; |
2053 | { | ||
2054 | m_collisionFlags |= CollisionCategories.Water; | ||
2055 | } | ||
2056 | else | ||
2057 | { | ||
2058 | m_collisionFlags &= ~CollisionCategories.Water; | ||
2059 | } | ||
2060 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
2061 | } | 2037 | } |
2038 | else | ||
2039 | { | ||
2040 | m_collisionFlags &= ~CollisionCategories.Water; | ||
2041 | } | ||
2042 | |||
2043 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
2062 | } | 2044 | } |
2063 | 2045 | ||
2064 | /// <summary> | 2046 | /// <summary> |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 842ff91..409b27b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs | |||
@@ -2226,7 +2226,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2226 | /// <param name="prim"></param> | 2226 | /// <param name="prim"></param> |
2227 | internal void RemovePrimThreadLocked(OdePrim prim) | 2227 | internal void RemovePrimThreadLocked(OdePrim prim) |
2228 | { | 2228 | { |
2229 | //Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName); | 2229 | // m_log.DebugFormat("[ODE SCENE]: Removing physical prim {0} {1}", prim.Name, prim.LocalID); |
2230 | |||
2230 | lock (prim) | 2231 | lock (prim) |
2231 | { | 2232 | { |
2232 | RemoveCollisionEventReporting(prim); | 2233 | RemoveCollisionEventReporting(prim); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs index 47ed6ba..684138f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs | |||
@@ -29,42 +29,43 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | ||
32 | using OpenSim.Region.ScriptEngine.Interfaces; | 33 | using OpenSim.Region.ScriptEngine.Interfaces; |
33 | 34 | ||
34 | namespace OpenSim.Region.ScriptEngine.Shared.Api | 35 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
35 | { | 36 | { |
36 | public class ApiManager | 37 | public class ApiManager |
37 | { | 38 | { |
39 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
40 | |||
38 | private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); | 41 | private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); |
39 | 42 | ||
40 | public string[] GetApis() | 43 | public string[] GetApis() |
41 | { | 44 | { |
42 | if (m_Apis.Count > 0) | 45 | if (m_Apis.Count <= 0) |
43 | { | 46 | { |
44 | List<string> l = new List<string>(m_Apis.Keys); | 47 | Assembly a = Assembly.GetExecutingAssembly(); |
45 | return l.ToArray(); | ||
46 | } | ||
47 | 48 | ||
48 | Assembly a = Assembly.GetExecutingAssembly(); | 49 | Type[] types = a.GetExportedTypes(); |
49 | 50 | ||
50 | Type[] types = a.GetExportedTypes(); | 51 | foreach (Type t in types) |
51 | |||
52 | foreach (Type t in types) | ||
53 | { | ||
54 | string name = t.ToString(); | ||
55 | int idx = name.LastIndexOf('.'); | ||
56 | if (idx != -1) | ||
57 | name = name.Substring(idx+1); | ||
58 | |||
59 | if (name.EndsWith("_Api")) | ||
60 | { | 52 | { |
61 | name = name.Substring(0, name.Length - 4); | 53 | string name = t.ToString(); |
62 | m_Apis[name] = t; | 54 | int idx = name.LastIndexOf('.'); |
55 | if (idx != -1) | ||
56 | name = name.Substring(idx+1); | ||
57 | |||
58 | if (name.EndsWith("_Api")) | ||
59 | { | ||
60 | name = name.Substring(0, name.Length - 4); | ||
61 | m_Apis[name] = t; | ||
62 | } | ||
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | List<string> ret = new List<string>(m_Apis.Keys); | 66 | // m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count); |
67 | return ret.ToArray(); | 67 | |
68 | return new List<string>(m_Apis.Keys).ToArray(); | ||
68 | } | 69 | } |
69 | 70 | ||
70 | public IScriptApi CreateApi(string api) | 71 | public IScriptApi CreateApi(string api) |
@@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
76 | return ret; | 77 | return ret; |
77 | } | 78 | } |
78 | } | 79 | } |
79 | } | 80 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0c28bf5..2a2ef57 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -89,7 +89,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
89 | protected IScriptEngine m_ScriptEngine; | 89 | protected IScriptEngine m_ScriptEngine; |
90 | protected SceneObjectPart m_host; | 90 | protected SceneObjectPart m_host; |
91 | protected uint m_localID; | 91 | protected uint m_localID; |
92 | |||
93 | /// <summary> | ||
94 | /// The UUID of the item that hosts this script | ||
95 | /// </summary> | ||
92 | protected UUID m_itemID; | 96 | protected UUID m_itemID; |
97 | |||
93 | protected bool throwErrorOnNotImplemented = true; | 98 | protected bool throwErrorOnNotImplemented = true; |
94 | protected AsyncCommandManager AsyncCommands = null; | 99 | protected AsyncCommandManager AsyncCommands = null; |
95 | protected float m_ScriptDelayFactor = 1.0f; | 100 | protected float m_ScriptDelayFactor = 1.0f; |
@@ -336,28 +341,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
336 | } | 341 | } |
337 | } | 342 | } |
338 | 343 | ||
339 | protected UUID InventorySelf() | 344 | /// <summary> |
345 | /// Get the inventory item that hosts ourselves. | ||
346 | /// </summary> | ||
347 | /// <remarks> | ||
348 | /// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need | ||
349 | /// to keep looking ourselves up. | ||
350 | /// </remarks> | ||
351 | /// <returns></returns> | ||
352 | protected TaskInventoryItem GetSelfInventoryItem() | ||
340 | { | 353 | { |
341 | UUID invItemID = new UUID(); | 354 | TaskInventoryItem invItem = null; |
355 | |||
342 | bool unlock = false; | 356 | bool unlock = false; |
343 | if (!m_host.TaskInventory.IsReadLockedByMe()) | 357 | if (!m_host.TaskInventory.IsReadLockedByMe()) |
344 | { | 358 | { |
345 | m_host.TaskInventory.LockItemsForRead(true); | 359 | m_host.TaskInventory.LockItemsForRead(true); |
346 | unlock = true; | 360 | unlock = true; |
347 | } | 361 | } |
348 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 362 | |
349 | { | 363 | invItem = m_host.TaskInventory[m_itemID]; |
350 | if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) | 364 | |
351 | { | ||
352 | invItemID = inv.Key; | ||
353 | break; | ||
354 | } | ||
355 | } | ||
356 | if (unlock) | 365 | if (unlock) |
357 | { | 366 | { |
358 | m_host.TaskInventory.LockItemsForRead(false); | 367 | m_host.TaskInventory.LockItemsForRead(false); |
359 | } | 368 | } |
360 | return invItemID; | 369 | |
370 | return invItem; | ||
361 | } | 371 | } |
362 | 372 | ||
363 | protected UUID InventoryKey(string name, int type) | 373 | protected UUID InventoryKey(string name, int type) |
@@ -941,20 +951,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
941 | 951 | ||
942 | public void llRegionSayTo(string target, int channel, string msg) | 952 | public void llRegionSayTo(string target, int channel, string msg) |
943 | { | 953 | { |
944 | string error = String.Empty; | ||
945 | |||
946 | if (msg.Length > 1023) | 954 | if (msg.Length > 1023) |
947 | msg = msg.Substring(0, 1023); | 955 | msg = msg.Substring(0, 1023); |
948 | 956 | ||
949 | m_host.AddScriptLPS(1); | 957 | m_host.AddScriptLPS(1); |
950 | 958 | ||
959 | if (channel == ScriptBaseClass.DEBUG_CHANNEL) | ||
960 | { | ||
961 | return; | ||
962 | } | ||
963 | |||
951 | UUID TargetID; | 964 | UUID TargetID; |
952 | UUID.TryParse(target, out TargetID); | 965 | UUID.TryParse(target, out TargetID); |
953 | 966 | ||
954 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 967 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
955 | if (wComm != null) | 968 | if (wComm != null) |
956 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) | 969 | wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg); |
957 | LSLError(error); | ||
958 | } | 970 | } |
959 | 971 | ||
960 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 972 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
@@ -1910,6 +1922,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1910 | rgb.y = texcolor.G; | 1922 | rgb.y = texcolor.G; |
1911 | rgb.z = texcolor.B; | 1923 | rgb.z = texcolor.B; |
1912 | return rgb; | 1924 | return rgb; |
1925 | |||
1913 | } | 1926 | } |
1914 | else | 1927 | else |
1915 | { | 1928 | { |
@@ -2948,15 +2961,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2948 | 2961 | ||
2949 | public LSL_Integer llGiveMoney(string destination, int amount) | 2962 | public LSL_Integer llGiveMoney(string destination, int amount) |
2950 | { | 2963 | { |
2951 | UUID invItemID=InventorySelf(); | ||
2952 | if (invItemID == UUID.Zero) | ||
2953 | return 0; | ||
2954 | |||
2955 | m_host.AddScriptLPS(1); | 2964 | m_host.AddScriptLPS(1); |
2956 | 2965 | ||
2957 | m_host.TaskInventory.LockItemsForRead(true); | 2966 | TaskInventoryItem item = GetSelfInventoryItem(); |
2958 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | ||
2959 | m_host.TaskInventory.LockItemsForRead(false); | ||
2960 | 2967 | ||
2961 | if (item.PermsGranter == UUID.Zero) | 2968 | if (item.PermsGranter == UUID.Zero) |
2962 | return 0; | 2969 | return 0; |
@@ -3210,19 +3217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3210 | 3217 | ||
3211 | public void llTakeControls(int controls, int accept, int pass_on) | 3218 | public void llTakeControls(int controls, int accept, int pass_on) |
3212 | { | 3219 | { |
3213 | TaskInventoryItem item; | 3220 | TaskInventoryItem item = GetSelfInventoryItem(); |
3214 | |||
3215 | m_host.TaskInventory.LockItemsForRead(true); | ||
3216 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3217 | { | ||
3218 | m_host.TaskInventory.LockItemsForRead(false); | ||
3219 | return; | ||
3220 | } | ||
3221 | else | ||
3222 | { | ||
3223 | item = m_host.TaskInventory[InventorySelf()]; | ||
3224 | } | ||
3225 | m_host.TaskInventory.LockItemsForRead(false); | ||
3226 | 3221 | ||
3227 | if (item.PermsGranter != UUID.Zero) | 3222 | if (item.PermsGranter != UUID.Zero) |
3228 | { | 3223 | { |
@@ -3242,26 +3237,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3242 | 3237 | ||
3243 | public void llReleaseControls() | 3238 | public void llReleaseControls() |
3244 | { | 3239 | { |
3245 | TaskInventoryItem item; | ||
3246 | |||
3247 | m_host.TaskInventory.LockItemsForRead(true); | ||
3248 | lock (m_host.TaskInventory) | ||
3249 | { | ||
3250 | |||
3251 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3252 | { | ||
3253 | m_host.TaskInventory.LockItemsForRead(false); | ||
3254 | return; | ||
3255 | } | ||
3256 | else | ||
3257 | { | ||
3258 | item = m_host.TaskInventory[InventorySelf()]; | ||
3259 | } | ||
3260 | } | ||
3261 | m_host.TaskInventory.LockItemsForRead(false); | ||
3262 | |||
3263 | m_host.AddScriptLPS(1); | 3240 | m_host.AddScriptLPS(1); |
3264 | 3241 | ||
3242 | TaskInventoryItem item = GetSelfInventoryItem(); | ||
3243 | |||
3265 | if (item.PermsGranter != UUID.Zero) | 3244 | if (item.PermsGranter != UUID.Zero) |
3266 | { | 3245 | { |
3267 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); | 3246 | ScenePresence presence = World.GetScenePresence(item.PermsGranter); |
@@ -3286,86 +3265,77 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3286 | m_UrlModule.ReleaseURL(url); | 3265 | m_UrlModule.ReleaseURL(url); |
3287 | } | 3266 | } |
3288 | 3267 | ||
3289 | public void llAttachToAvatar(int attachment) | 3268 | /// <summary> |
3269 | /// Attach the object containing this script to the avatar that owns it. | ||
3270 | /// </summary> | ||
3271 | /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param> | ||
3272 | /// <returns>true if the attach suceeded, false if it did not</returns> | ||
3273 | public bool AttachToAvatar(int attachmentPoint) | ||
3290 | { | 3274 | { |
3291 | m_host.AddScriptLPS(1); | 3275 | SceneObjectGroup grp = m_host.ParentGroup; |
3292 | 3276 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | |
3293 | TaskInventoryItem item; | ||
3294 | 3277 | ||
3295 | m_host.TaskInventory.LockItemsForRead(true); | 3278 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3296 | 3279 | ||
3297 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | 3280 | if (attachmentsModule != null) |
3298 | { | 3281 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false); |
3299 | m_host.TaskInventory.LockItemsForRead(false); | ||
3300 | return; | ||
3301 | } | ||
3302 | else | 3282 | else |
3303 | { | 3283 | return false; |
3304 | item = m_host.TaskInventory[InventorySelf()]; | 3284 | } |
3305 | } | ||
3306 | |||
3307 | m_host.TaskInventory.LockItemsForRead(false); | ||
3308 | 3285 | ||
3309 | if (item.PermsGranter != m_host.OwnerID) | 3286 | /// <summary> |
3310 | return; | 3287 | /// Detach the object containing this script from the avatar it is attached to. |
3288 | /// </summary> | ||
3289 | /// <remarks> | ||
3290 | /// Nothing happens if the object is not attached. | ||
3291 | /// </remarks> | ||
3292 | public void DetachFromAvatar() | ||
3293 | { | ||
3294 | Util.FireAndForget(DetachWrapper, m_host); | ||
3295 | } | ||
3311 | 3296 | ||
3312 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | 3297 | private void DetachWrapper(object o) |
3313 | { | 3298 | { |
3314 | SceneObjectGroup grp = m_host.ParentGroup; | 3299 | SceneObjectPart host = (SceneObjectPart)o; |
3315 | 3300 | ||
3316 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3301 | SceneObjectGroup grp = host.ParentGroup; |
3302 | UUID itemID = grp.FromItemID; | ||
3303 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | ||
3317 | 3304 | ||
3318 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3305 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3319 | if (attachmentsModule != null) | 3306 | if (attachmentsModule != null) |
3320 | attachmentsModule.AttachObject(presence, grp, (uint)attachment, false); | 3307 | attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); |
3321 | } | ||
3322 | } | 3308 | } |
3323 | 3309 | ||
3324 | public void llDetachFromAvatar() | 3310 | public void llAttachToAvatar(int attachmentPoint) |
3325 | { | 3311 | { |
3326 | m_host.AddScriptLPS(1); | 3312 | m_host.AddScriptLPS(1); |
3327 | 3313 | ||
3328 | if (m_host.ParentGroup.AttachmentPoint == 0) | 3314 | TaskInventoryItem item = GetSelfInventoryItem(); |
3329 | return; | ||
3330 | 3315 | ||
3331 | TaskInventoryItem item; | ||
3332 | |||
3333 | m_host.TaskInventory.LockItemsForRead(true); | ||
3334 | |||
3335 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3336 | { | ||
3337 | m_host.TaskInventory.LockItemsForRead(false); | ||
3338 | return; | ||
3339 | } | ||
3340 | else | ||
3341 | { | ||
3342 | item = m_host.TaskInventory[InventorySelf()]; | ||
3343 | } | ||
3344 | m_host.TaskInventory.LockItemsForRead(false); | 3316 | m_host.TaskInventory.LockItemsForRead(false); |
3345 | 3317 | ||
3346 | |||
3347 | if (item.PermsGranter != m_host.OwnerID) | 3318 | if (item.PermsGranter != m_host.OwnerID) |
3348 | return; | 3319 | return; |
3349 | 3320 | ||
3350 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | 3321 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) |
3351 | { | 3322 | AttachToAvatar(attachmentPoint); |
3352 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | ||
3353 | if (attachmentsModule != null) | ||
3354 | Util.FireAndForget(DetachWrapper, m_host); | ||
3355 | } | ||
3356 | } | 3323 | } |
3357 | 3324 | ||
3358 | private void DetachWrapper(object o) | 3325 | public void llDetachFromAvatar() |
3359 | { | 3326 | { |
3360 | SceneObjectPart host = (SceneObjectPart)o; | 3327 | m_host.AddScriptLPS(1); |
3361 | 3328 | ||
3362 | SceneObjectGroup grp = host.ParentGroup; | 3329 | if (m_host.ParentGroup.AttachmentPoint == 0) |
3363 | UUID itemID = grp.FromItemID; | 3330 | return; |
3364 | ScenePresence presence = World.GetScenePresence(host.OwnerID); | ||
3365 | 3331 | ||
3366 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3332 | TaskInventoryItem item = GetSelfInventoryItem(); |
3367 | if (attachmentsModule != null) | 3333 | |
3368 | attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); | 3334 | if (item.PermsGranter != m_host.OwnerID) |
3335 | return; | ||
3336 | |||
3337 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) | ||
3338 | DetachFromAvatar(); | ||
3369 | } | 3339 | } |
3370 | 3340 | ||
3371 | public void llTakeCamera(string avatar) | 3341 | public void llTakeCamera(string avatar) |
@@ -3523,6 +3493,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3523 | return m_host.UUID.ToString(); | 3493 | return m_host.UUID.ToString(); |
3524 | } | 3494 | } |
3525 | 3495 | ||
3496 | public LSL_Key llGenerateKey() | ||
3497 | { | ||
3498 | m_host.AddScriptLPS(1); | ||
3499 | return UUID.Random().ToString(); | ||
3500 | } | ||
3501 | |||
3526 | public void llSetBuoyancy(double buoyancy) | 3502 | public void llSetBuoyancy(double buoyancy) |
3527 | { | 3503 | { |
3528 | m_host.AddScriptLPS(1); | 3504 | m_host.AddScriptLPS(1); |
@@ -3622,23 +3598,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3622 | { | 3598 | { |
3623 | m_host.AddScriptLPS(1); | 3599 | m_host.AddScriptLPS(1); |
3624 | 3600 | ||
3625 | UUID invItemID = InventorySelf(); | 3601 | TaskInventoryItem item = GetSelfInventoryItem(); |
3626 | if (invItemID == UUID.Zero) | ||
3627 | return; | ||
3628 | |||
3629 | TaskInventoryItem item; | ||
3630 | 3602 | ||
3631 | m_host.TaskInventory.LockItemsForRead(true); | ||
3632 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3633 | { | ||
3634 | m_host.TaskInventory.LockItemsForRead(false); | ||
3635 | return; | ||
3636 | } | ||
3637 | else | ||
3638 | { | ||
3639 | item = m_host.TaskInventory[InventorySelf()]; | ||
3640 | } | ||
3641 | m_host.TaskInventory.LockItemsForRead(false); | ||
3642 | if (item.PermsGranter == UUID.Zero) | 3603 | if (item.PermsGranter == UUID.Zero) |
3643 | return; | 3604 | return; |
3644 | 3605 | ||
@@ -3662,24 +3623,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3662 | { | 3623 | { |
3663 | m_host.AddScriptLPS(1); | 3624 | m_host.AddScriptLPS(1); |
3664 | 3625 | ||
3665 | UUID invItemID=InventorySelf(); | 3626 | TaskInventoryItem item = GetSelfInventoryItem(); |
3666 | if (invItemID == UUID.Zero) | ||
3667 | return; | ||
3668 | |||
3669 | TaskInventoryItem item; | ||
3670 | |||
3671 | m_host.TaskInventory.LockItemsForRead(true); | ||
3672 | if (!m_host.TaskInventory.ContainsKey(InventorySelf())) | ||
3673 | { | ||
3674 | m_host.TaskInventory.LockItemsForRead(false); | ||
3675 | return; | ||
3676 | } | ||
3677 | else | ||
3678 | { | ||
3679 | item = m_host.TaskInventory[InventorySelf()]; | ||
3680 | } | ||
3681 | m_host.TaskInventory.LockItemsForRead(false); | ||
3682 | |||
3683 | 3627 | ||
3684 | if (item.PermsGranter == UUID.Zero) | 3628 | if (item.PermsGranter == UUID.Zero) |
3685 | return; | 3629 | return; |
@@ -3734,30 +3678,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3734 | 3678 | ||
3735 | public void llRequestPermissions(string agent, int perm) | 3679 | public void llRequestPermissions(string agent, int perm) |
3736 | { | 3680 | { |
3737 | UUID agentID = new UUID(); | 3681 | UUID agentID; |
3738 | 3682 | ||
3739 | if (!UUID.TryParse(agent, out agentID)) | 3683 | if (!UUID.TryParse(agent, out agentID)) |
3740 | return; | 3684 | return; |
3741 | 3685 | ||
3742 | UUID invItemID = InventorySelf(); | 3686 | TaskInventoryItem item = GetSelfInventoryItem(); |
3743 | |||
3744 | if (invItemID == UUID.Zero) | ||
3745 | return; // Not in a prim? How?? | ||
3746 | |||
3747 | TaskInventoryItem item; | ||
3748 | |||
3749 | |||
3750 | m_host.TaskInventory.LockItemsForRead(true); | ||
3751 | if (!m_host.TaskInventory.ContainsKey(invItemID)) | ||
3752 | { | ||
3753 | m_host.TaskInventory.LockItemsForRead(false); | ||
3754 | return; | ||
3755 | } | ||
3756 | else | ||
3757 | { | ||
3758 | item = m_host.TaskInventory[invItemID]; | ||
3759 | } | ||
3760 | m_host.TaskInventory.LockItemsForRead(false); | ||
3761 | 3687 | ||
3762 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions | 3688 | if (agentID == UUID.Zero || perm == 0) // Releasing permissions |
3763 | { | 3689 | { |
@@ -3791,8 +3717,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3791 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3717 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3792 | { | 3718 | { |
3793 | m_host.TaskInventory.LockItemsForWrite(true); | 3719 | m_host.TaskInventory.LockItemsForWrite(true); |
3794 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3720 | m_host.TaskInventory[m_itemID].PermsGranter = agentID; |
3795 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3721 | m_host.TaskInventory[m_itemID].PermsMask = perm; |
3796 | m_host.TaskInventory.LockItemsForWrite(false); | 3722 | m_host.TaskInventory.LockItemsForWrite(false); |
3797 | 3723 | ||
3798 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3724 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
@@ -3830,8 +3756,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3830 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms | 3756 | if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms |
3831 | { | 3757 | { |
3832 | m_host.TaskInventory.LockItemsForWrite(true); | 3758 | m_host.TaskInventory.LockItemsForWrite(true); |
3833 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3759 | m_host.TaskInventory[m_itemID].PermsGranter = agentID; |
3834 | m_host.TaskInventory[invItemID].PermsMask = perm; | 3760 | m_host.TaskInventory[m_itemID].PermsMask = perm; |
3835 | m_host.TaskInventory.LockItemsForWrite(false); | 3761 | m_host.TaskInventory.LockItemsForWrite(false); |
3836 | 3762 | ||
3837 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3763 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
@@ -3855,8 +3781,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3855 | if (!m_waitingForScriptAnswer) | 3781 | if (!m_waitingForScriptAnswer) |
3856 | { | 3782 | { |
3857 | m_host.TaskInventory.LockItemsForWrite(true); | 3783 | m_host.TaskInventory.LockItemsForWrite(true); |
3858 | m_host.TaskInventory[invItemID].PermsGranter = agentID; | 3784 | m_host.TaskInventory[m_itemID].PermsGranter = agentID; |
3859 | m_host.TaskInventory[invItemID].PermsMask = 0; | 3785 | m_host.TaskInventory[m_itemID].PermsMask = 0; |
3860 | m_host.TaskInventory.LockItemsForWrite(false); | 3786 | m_host.TaskInventory.LockItemsForWrite(false); |
3861 | 3787 | ||
3862 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; | 3788 | presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; |
@@ -3864,7 +3790,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3864 | } | 3790 | } |
3865 | 3791 | ||
3866 | presence.ControllingClient.SendScriptQuestion( | 3792 | presence.ControllingClient.SendScriptQuestion( |
3867 | m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); | 3793 | m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm); |
3868 | 3794 | ||
3869 | return; | 3795 | return; |
3870 | } | 3796 | } |
@@ -3881,23 +3807,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3881 | if (taskID != m_host.UUID) | 3807 | if (taskID != m_host.UUID) |
3882 | return; | 3808 | return; |
3883 | 3809 | ||
3884 | UUID invItemID = InventorySelf(); | 3810 | client.OnScriptAnswer -= handleScriptAnswer; |
3885 | 3811 | m_waitingForScriptAnswer = false; | |
3886 | if (invItemID == UUID.Zero) | ||
3887 | return; | ||
3888 | |||
3889 | client.OnScriptAnswer-=handleScriptAnswer; | ||
3890 | m_waitingForScriptAnswer=false; | ||
3891 | 3812 | ||
3892 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) | 3813 | if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) |
3893 | llReleaseControls(); | 3814 | llReleaseControls(); |
3894 | 3815 | ||
3895 | |||
3896 | m_host.TaskInventory.LockItemsForWrite(true); | 3816 | m_host.TaskInventory.LockItemsForWrite(true); |
3897 | m_host.TaskInventory[invItemID].PermsMask = answer; | 3817 | m_host.TaskInventory[m_itemID].PermsMask = answer; |
3898 | m_host.TaskInventory.LockItemsForWrite(false); | 3818 | m_host.TaskInventory.LockItemsForWrite(false); |
3899 | 3819 | ||
3900 | |||
3901 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( | 3820 | m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( |
3902 | "run_time_permissions", new Object[] { | 3821 | "run_time_permissions", new Object[] { |
3903 | new LSL_Integer(answer) }, | 3822 | new LSL_Integer(answer) }, |
@@ -3908,41 +3827,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3908 | { | 3827 | { |
3909 | m_host.AddScriptLPS(1); | 3828 | m_host.AddScriptLPS(1); |
3910 | 3829 | ||
3911 | m_host.TaskInventory.LockItemsForRead(true); | 3830 | return GetSelfInventoryItem().PermsGranter.ToString(); |
3912 | |||
3913 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
3914 | { | ||
3915 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
3916 | { | ||
3917 | m_host.TaskInventory.LockItemsForRead(false); | ||
3918 | return item.PermsGranter.ToString(); | ||
3919 | } | ||
3920 | } | ||
3921 | m_host.TaskInventory.LockItemsForRead(false); | ||
3922 | |||
3923 | return UUID.Zero.ToString(); | ||
3924 | } | 3831 | } |
3925 | 3832 | ||
3926 | public LSL_Integer llGetPermissions() | 3833 | public LSL_Integer llGetPermissions() |
3927 | { | 3834 | { |
3928 | m_host.AddScriptLPS(1); | 3835 | m_host.AddScriptLPS(1); |
3929 | 3836 | ||
3930 | m_host.TaskInventory.LockItemsForRead(true); | 3837 | int perms = GetSelfInventoryItem().PermsMask; |
3931 | 3838 | ||
3932 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 3839 | if (m_automaticLinkPermission) |
3933 | { | 3840 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; |
3934 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
3935 | { | ||
3936 | int perms = item.PermsMask; | ||
3937 | if (m_automaticLinkPermission) | ||
3938 | perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; | ||
3939 | m_host.TaskInventory.LockItemsForRead(false); | ||
3940 | return perms; | ||
3941 | } | ||
3942 | } | ||
3943 | m_host.TaskInventory.LockItemsForRead(false); | ||
3944 | 3841 | ||
3945 | return 0; | 3842 | return perms; |
3946 | } | 3843 | } |
3947 | 3844 | ||
3948 | public LSL_Integer llGetLinkNumber() | 3845 | public LSL_Integer llGetLinkNumber() |
@@ -3980,17 +3877,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3980 | public void llCreateLink(string target, int parent) | 3877 | public void llCreateLink(string target, int parent) |
3981 | { | 3878 | { |
3982 | m_host.AddScriptLPS(1); | 3879 | m_host.AddScriptLPS(1); |
3983 | UUID invItemID = InventorySelf(); | 3880 | |
3984 | UUID targetID; | 3881 | UUID targetID; |
3985 | 3882 | ||
3986 | if (!UUID.TryParse(target, out targetID)) | 3883 | if (!UUID.TryParse(target, out targetID)) |
3987 | return; | 3884 | return; |
3988 | 3885 | ||
3989 | TaskInventoryItem item; | 3886 | TaskInventoryItem item = GetSelfInventoryItem(); |
3990 | m_host.TaskInventory.LockItemsForRead(true); | 3887 | |
3991 | item = m_host.TaskInventory[invItemID]; | ||
3992 | m_host.TaskInventory.LockItemsForRead(false); | ||
3993 | |||
3994 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3888 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
3995 | && !m_automaticLinkPermission) | 3889 | && !m_automaticLinkPermission) |
3996 | { | 3890 | { |
@@ -4045,18 +3939,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4045 | public void llBreakLink(int linknum) | 3939 | public void llBreakLink(int linknum) |
4046 | { | 3940 | { |
4047 | m_host.AddScriptLPS(1); | 3941 | m_host.AddScriptLPS(1); |
4048 | UUID invItemID = InventorySelf(); | ||
4049 | 3942 | ||
4050 | m_host.TaskInventory.LockItemsForRead(true); | 3943 | if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4051 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 3944 | && !m_automaticLinkPermission) |
4052 | && !m_automaticLinkPermission) | 3945 | { |
4053 | { | 3946 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); |
4054 | ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); | 3947 | return; |
4055 | m_host.TaskInventory.LockItemsForRead(false); | 3948 | } |
4056 | return; | 3949 | |
4057 | } | ||
4058 | m_host.TaskInventory.LockItemsForRead(false); | ||
4059 | |||
4060 | if (linknum < ScriptBaseClass.LINK_THIS) | 3950 | if (linknum < ScriptBaseClass.LINK_THIS) |
4061 | return; | 3951 | return; |
4062 | 3952 | ||
@@ -4155,12 +4045,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4155 | { | 4045 | { |
4156 | m_host.AddScriptLPS(1); | 4046 | m_host.AddScriptLPS(1); |
4157 | 4047 | ||
4158 | UUID invItemID = InventorySelf(); | 4048 | TaskInventoryItem item = GetSelfInventoryItem(); |
4159 | |||
4160 | TaskInventoryItem item; | ||
4161 | m_host.TaskInventory.LockItemsForRead(true); | ||
4162 | item = m_host.TaskInventory[invItemID]; | ||
4163 | m_host.TaskInventory.LockItemsForRead(false); | ||
4164 | 4049 | ||
4165 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 | 4050 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 |
4166 | && !m_automaticLinkPermission) | 4051 | && !m_automaticLinkPermission) |
@@ -5033,22 +4918,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5033 | 4918 | ||
5034 | public LSL_String llGetScriptName() | 4919 | public LSL_String llGetScriptName() |
5035 | { | 4920 | { |
5036 | string result = String.Empty; | ||
5037 | |||
5038 | m_host.AddScriptLPS(1); | 4921 | m_host.AddScriptLPS(1); |
5039 | 4922 | ||
5040 | m_host.TaskInventory.LockItemsForRead(true); | 4923 | TaskInventoryItem item = GetSelfInventoryItem(); |
5041 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
5042 | { | ||
5043 | if (item.Type == 10 && item.ItemID == m_itemID) | ||
5044 | { | ||
5045 | result = item.Name!=null?item.Name:String.Empty; | ||
5046 | break; | ||
5047 | } | ||
5048 | } | ||
5049 | m_host.TaskInventory.LockItemsForRead(false); | ||
5050 | 4924 | ||
5051 | return result; | 4925 | return item.Name != null ? item.Name : String.Empty; |
5052 | } | 4926 | } |
5053 | 4927 | ||
5054 | public LSL_Integer llGetLinkNumberOfSides(int link) | 4928 | public LSL_Integer llGetLinkNumberOfSides(int link) |
@@ -6248,7 +6122,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6248 | if (m_host.OwnerID == land.LandData.OwnerID) | 6122 | if (m_host.OwnerID == land.LandData.OwnerID) |
6249 | { | 6123 | { |
6250 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); | 6124 | Vector3 pos = World.GetNearestAllowedPosition(presence, land); |
6251 | presence.TeleportWithMomentum(pos); | 6125 | presence.TeleportWithMomentum(pos, null); |
6252 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); | 6126 | presence.ControllingClient.SendAlertMessage("You have been ejected from this land"); |
6253 | } | 6127 | } |
6254 | } | 6128 | } |
@@ -9991,7 +9865,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9991 | // child agents have a mass of 1.0 | 9865 | // child agents have a mass of 1.0 |
9992 | return 1; | 9866 | return 1; |
9993 | else | 9867 | else |
9994 | return avatar.GetMass(); | 9868 | return (double)avatar.GetMass(); |
9995 | } | 9869 | } |
9996 | catch (KeyNotFoundException) | 9870 | catch (KeyNotFoundException) |
9997 | { | 9871 | { |
@@ -10434,22 +10308,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10434 | public LSL_Vector llGetCameraPos() | 10308 | public LSL_Vector llGetCameraPos() |
10435 | { | 10309 | { |
10436 | m_host.AddScriptLPS(1); | 10310 | m_host.AddScriptLPS(1); |
10437 | UUID invItemID = InventorySelf(); | ||
10438 | 10311 | ||
10439 | if (invItemID == UUID.Zero) | 10312 | TaskInventoryItem item = GetSelfInventoryItem(); |
10440 | return new LSL_Vector(); | ||
10441 | 10313 | ||
10442 | m_host.TaskInventory.LockItemsForRead(true); | 10314 | if (item.PermsGranter == UUID.Zero) |
10443 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 10315 | return new LSL_Vector(); |
10444 | { | ||
10445 | m_host.TaskInventory.LockItemsForRead(false); | ||
10446 | return new LSL_Vector(); | ||
10447 | } | ||
10448 | 10316 | ||
10449 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | 10317 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
10450 | { | 10318 | { |
10451 | ShoutError("No permissions to track the camera"); | 10319 | ShoutError("No permissions to track the camera"); |
10452 | m_host.TaskInventory.LockItemsForRead(false); | ||
10453 | return new LSL_Vector(); | 10320 | return new LSL_Vector(); |
10454 | } | 10321 | } |
10455 | m_host.TaskInventory.LockItemsForRead(false); | 10322 | m_host.TaskInventory.LockItemsForRead(false); |
@@ -10466,20 +10333,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10466 | public LSL_Rotation llGetCameraRot() | 10333 | public LSL_Rotation llGetCameraRot() |
10467 | { | 10334 | { |
10468 | m_host.AddScriptLPS(1); | 10335 | m_host.AddScriptLPS(1); |
10469 | UUID invItemID = InventorySelf(); | ||
10470 | if (invItemID == UUID.Zero) | ||
10471 | return new LSL_Rotation(); | ||
10472 | 10336 | ||
10473 | m_host.TaskInventory.LockItemsForRead(true); | 10337 | TaskInventoryItem item = GetSelfInventoryItem(); |
10474 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | 10338 | |
10475 | { | 10339 | if (item.PermsGranter == UUID.Zero) |
10476 | m_host.TaskInventory.LockItemsForRead(false); | 10340 | return new LSL_Rotation(); |
10477 | return new LSL_Rotation(); | 10341 | |
10478 | } | 10342 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) |
10479 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
10480 | { | 10343 | { |
10481 | ShoutError("No permissions to track the camera"); | 10344 | ShoutError("No permissions to track the camera"); |
10482 | m_host.TaskInventory.LockItemsForRead(false); | ||
10483 | return new LSL_Rotation(); | 10345 | return new LSL_Rotation(); |
10484 | } | 10346 | } |
10485 | m_host.TaskInventory.LockItemsForRead(false); | 10347 | m_host.TaskInventory.LockItemsForRead(false); |
@@ -10667,30 +10529,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10667 | { | 10529 | { |
10668 | m_host.AddScriptLPS(1); | 10530 | m_host.AddScriptLPS(1); |
10669 | 10531 | ||
10670 | // our key in the object we are in | ||
10671 | UUID invItemID = InventorySelf(); | ||
10672 | if (invItemID == UUID.Zero) return; | ||
10673 | |||
10674 | // the object we are in | 10532 | // the object we are in |
10675 | UUID objectID = m_host.ParentUUID; | 10533 | UUID objectID = m_host.ParentUUID; |
10676 | if (objectID == UUID.Zero) return; | 10534 | if (objectID == UUID.Zero) |
10535 | return; | ||
10536 | |||
10537 | TaskInventoryItem item = GetSelfInventoryItem(); | ||
10677 | 10538 | ||
10678 | UUID agentID; | ||
10679 | m_host.TaskInventory.LockItemsForRead(true); | ||
10680 | // we need the permission first, to know which avatar we want to set the camera for | 10539 | // we need the permission first, to know which avatar we want to set the camera for |
10681 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | 10540 | UUID agentID = item.PermsGranter; |
10682 | 10541 | ||
10683 | if (agentID == UUID.Zero) | 10542 | if (agentID == UUID.Zero) |
10684 | { | ||
10685 | m_host.TaskInventory.LockItemsForRead(false); | ||
10686 | return; | 10543 | return; |
10687 | } | 10544 | |
10688 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | 10545 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) |
10689 | { | ||
10690 | m_host.TaskInventory.LockItemsForRead(false); | ||
10691 | return; | 10546 | return; |
10692 | } | ||
10693 | m_host.TaskInventory.LockItemsForRead(false); | ||
10694 | 10547 | ||
10695 | ScenePresence presence = World.GetScenePresence(agentID); | 10548 | ScenePresence presence = World.GetScenePresence(agentID); |
10696 | 10549 | ||
@@ -10732,34 +10585,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10732 | { | 10585 | { |
10733 | m_host.AddScriptLPS(1); | 10586 | m_host.AddScriptLPS(1); |
10734 | 10587 | ||
10735 | // our key in the object we are in | ||
10736 | UUID invItemID=InventorySelf(); | ||
10737 | if (invItemID == UUID.Zero) return; | ||
10738 | |||
10739 | // the object we are in | 10588 | // the object we are in |
10740 | UUID objectID = m_host.ParentUUID; | 10589 | UUID objectID = m_host.ParentUUID; |
10741 | if (objectID == UUID.Zero) return; | 10590 | if (objectID == UUID.Zero) |
10591 | return; | ||
10592 | |||
10593 | TaskInventoryItem item = GetSelfInventoryItem(); | ||
10742 | 10594 | ||
10743 | // we need the permission first, to know which avatar we want to clear the camera for | 10595 | // we need the permission first, to know which avatar we want to clear the camera for |
10744 | UUID agentID; | 10596 | UUID agentID = item.PermsGranter; |
10745 | m_host.TaskInventory.LockItemsForRead(true); | 10597 | |
10746 | agentID = m_host.TaskInventory[invItemID].PermsGranter; | ||
10747 | if (agentID == UUID.Zero) | 10598 | if (agentID == UUID.Zero) |
10748 | { | ||
10749 | m_host.TaskInventory.LockItemsForRead(false); | ||
10750 | return; | 10599 | return; |
10751 | } | 10600 | |
10752 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) | 10601 | if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) |
10753 | { | ||
10754 | m_host.TaskInventory.LockItemsForRead(false); | ||
10755 | return; | 10602 | return; |
10756 | } | ||
10757 | m_host.TaskInventory.LockItemsForRead(false); | ||
10758 | 10603 | ||
10759 | ScenePresence presence = World.GetScenePresence(agentID); | 10604 | ScenePresence presence = World.GetScenePresence(agentID); |
10760 | 10605 | ||
10761 | // we are not interested in child-agents | 10606 | // we are not interested in child-agents |
10762 | if (presence.IsChildAgent) return; | 10607 | if (presence.IsChildAgent) |
10608 | return; | ||
10763 | 10609 | ||
10764 | presence.ControllingClient.SendClearFollowCamProperties(objectID); | 10610 | presence.ControllingClient.SendClearFollowCamProperties(objectID); |
10765 | } | 10611 | } |
@@ -11183,19 +11029,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11183 | break; | 11029 | break; |
11184 | // For the following 8 see the Object version below | 11030 | // For the following 8 see the Object version below |
11185 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | 11031 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: |
11186 | ret.Add(new LSL_Integer(0)); | 11032 | ret.Add(new LSL_Integer(av.RunningScriptCount())); |
11187 | break; | 11033 | break; |
11188 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | 11034 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: |
11189 | ret.Add(new LSL_Integer(0)); | 11035 | ret.Add(new LSL_Integer(av.ScriptCount())); |
11190 | break; | 11036 | break; |
11191 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | 11037 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: |
11192 | ret.Add(new LSL_Integer(0)); | 11038 | ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384)); |
11193 | break; | 11039 | break; |
11194 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | 11040 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: |
11195 | ret.Add(new LSL_Float(0)); | 11041 | ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f)); |
11196 | break; | 11042 | break; |
11197 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | 11043 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: |
11198 | ret.Add(new LSL_Integer(0)); | 11044 | ret.Add(new LSL_Integer(1)); |
11199 | break; | 11045 | break; |
11200 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11046 | case ScriptBaseClass.OBJECT_SERVER_COST: |
11201 | ret.Add(new LSL_Float(0)); | 11047 | ret.Add(new LSL_Float(0)); |
@@ -11247,43 +11093,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11247 | case ScriptBaseClass.OBJECT_CREATOR: | 11093 | case ScriptBaseClass.OBJECT_CREATOR: |
11248 | ret.Add(new LSL_String(obj.CreatorID.ToString())); | 11094 | ret.Add(new LSL_String(obj.CreatorID.ToString())); |
11249 | break; | 11095 | break; |
11250 | // The following 8 I have intentionaly coded to return zero. They are part of | ||
11251 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11252 | // to OpenSim, required figures (cpu/memory usage) are not currently tracked | ||
11253 | // I have intentionally left these all at zero rather than return possibly | ||
11254 | // missleading numbers | ||
11255 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: | 11096 | case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: |
11256 | // in SL this currently includes crashed scripts | 11097 | ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount())); |
11257 | ret.Add(new LSL_Integer(0)); | ||
11258 | break; | 11098 | break; |
11259 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: | 11099 | case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: |
11260 | ret.Add(new LSL_Integer(0)); | 11100 | ret.Add(new LSL_Integer(obj.ParentGroup.ScriptCount())); |
11261 | break; | 11101 | break; |
11262 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: | 11102 | case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: |
11263 | // The value returned in SL for mono scripts is 65536 * number of active scripts | 11103 | // The value returned in SL for mono scripts is 65536 * number of active scripts |
11264 | ret.Add(new LSL_Integer(0)); | 11104 | // and 16384 * number of active scripts for LSO. since llGetFreememory |
11105 | // is coded to give the LSO value use it here | ||
11106 | ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384)); | ||
11265 | break; | 11107 | break; |
11266 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: | 11108 | case ScriptBaseClass.OBJECT_SCRIPT_TIME: |
11267 | // Average cpu time per simulator frame expended on all scripts in the objetc | 11109 | // Average cpu time in seconds per simulator frame expended on all scripts in the object |
11268 | ret.Add(new LSL_Float(0)); | 11110 | ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f)); |
11269 | break; | 11111 | break; |
11270 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: | 11112 | case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: |
11271 | // according to the SL wiki A prim or linkset will have prim | 11113 | // according to the SL wiki A prim or linkset will have prim |
11272 | // equivalent of the number of prims in a linkset if it does not | 11114 | // equivalent of the number of prims in a linkset if it does not |
11273 | // contain a mesh anywhere in the link set or is not a normal prim | 11115 | // contain a mesh anywhere in the link set or is not a normal prim |
11274 | // The value returned in SL for normal prims is prim count | 11116 | // The value returned in SL for normal prims is prim count |
11275 | ret.Add(new LSL_Integer(0)); | 11117 | ret.Add(new LSL_Integer(obj.ParentGroup.PrimCount)); |
11276 | break; | 11118 | break; |
11119 | // The following 3 costs I have intentionaly coded to return zero. They are part of | ||
11120 | // "Land Impact" calculations. These calculations are probably not applicable | ||
11121 | // to OpenSim and are not yet complete in SL | ||
11277 | case ScriptBaseClass.OBJECT_SERVER_COST: | 11122 | case ScriptBaseClass.OBJECT_SERVER_COST: |
11278 | // The value returned in SL for normal prims is prim count | 11123 | // The linden calculation is here |
11124 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Server_Weight | ||
11125 | // The value returned in SL for normal prims looks like the prim count | ||
11279 | ret.Add(new LSL_Float(0)); | 11126 | ret.Add(new LSL_Float(0)); |
11280 | break; | 11127 | break; |
11281 | case ScriptBaseClass.OBJECT_STREAMING_COST: | 11128 | case ScriptBaseClass.OBJECT_STREAMING_COST: |
11282 | // The value returned in SL for normal prims is prim count * 0.06 | 11129 | // The linden calculation is here |
11130 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_Streaming_Cost | ||
11131 | // The value returned in SL for normal prims looks like the prim count * 0.06 | ||
11283 | ret.Add(new LSL_Float(0)); | 11132 | ret.Add(new LSL_Float(0)); |
11284 | break; | 11133 | break; |
11285 | case ScriptBaseClass.OBJECT_PHYSICS_COST: | 11134 | case ScriptBaseClass.OBJECT_PHYSICS_COST: |
11286 | // The value returned in SL for normal prims is prim count | 11135 | // The linden calculation is here |
11136 | // http://wiki.secondlife.com/wiki/Mesh/Mesh_physics | ||
11137 | // The value returned in SL for normal prims looks like the prim count | ||
11287 | ret.Add(new LSL_Float(0)); | 11138 | ret.Add(new LSL_Float(0)); |
11288 | break; | 11139 | break; |
11289 | default: | 11140 | default: |
@@ -12038,7 +11889,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12038 | bool isAccount = false; | 11889 | bool isAccount = false; |
12039 | bool isGroup = false; | 11890 | bool isGroup = false; |
12040 | 11891 | ||
12041 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManager(m_host.OwnerID)) | 11892 | if (!estate.IsEstateOwner(m_host.OwnerID) || !estate.IsEstateManagerOrOwner(m_host.OwnerID)) |
12042 | return 0; | 11893 | return 0; |
12043 | 11894 | ||
12044 | UUID id = new UUID(); | 11895 | UUID id = new UUID(); |
@@ -12100,35 +11951,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12100 | return 1; | 11951 | return 1; |
12101 | } | 11952 | } |
12102 | 11953 | ||
12103 | #region Not Implemented | 11954 | public LSL_Integer llGetMemoryLimit() |
12104 | // | 11955 | { |
12105 | // Listing the unimplemented lsl functions here, please move | 11956 | m_host.AddScriptLPS(1); |
12106 | // them from this region as they are completed | 11957 | // The value returned for LSO scripts in SL |
12107 | // | 11958 | return 16384; |
11959 | } | ||
12108 | 11960 | ||
12109 | public void llGetEnv(LSL_String name) | 11961 | public LSL_Integer llSetMemoryLimit(LSL_Integer limit) |
12110 | { | 11962 | { |
12111 | m_host.AddScriptLPS(1); | 11963 | m_host.AddScriptLPS(1); |
12112 | NotImplemented("llGetEnv"); | 11964 | // Treat as an LSO script |
11965 | return ScriptBaseClass.FALSE; | ||
12113 | } | 11966 | } |
12114 | 11967 | ||
12115 | public void llGetSPMaxMemory() | 11968 | public LSL_Integer llGetSPMaxMemory() |
12116 | { | 11969 | { |
12117 | m_host.AddScriptLPS(1); | 11970 | m_host.AddScriptLPS(1); |
12118 | NotImplemented("llGetSPMaxMemory"); | 11971 | // The value returned for LSO scripts in SL |
11972 | return 16384; | ||
12119 | } | 11973 | } |
12120 | 11974 | ||
12121 | public virtual LSL_Integer llGetUsedMemory() | 11975 | public virtual LSL_Integer llGetUsedMemory() |
12122 | { | 11976 | { |
12123 | m_host.AddScriptLPS(1); | 11977 | m_host.AddScriptLPS(1); |
12124 | NotImplemented("llGetUsedMemory"); | 11978 | // The value returned for LSO scripts in SL |
12125 | return 0; | 11979 | return 16384; |
12126 | } | 11980 | } |
12127 | 11981 | ||
12128 | public void llScriptProfiler(LSL_Integer flags) | 11982 | public void llScriptProfiler(LSL_Integer flags) |
12129 | { | 11983 | { |
12130 | m_host.AddScriptLPS(1); | 11984 | m_host.AddScriptLPS(1); |
12131 | //NotImplemented("llScriptProfiler"); | 11985 | // This does nothing for LSO scripts in SL |
11986 | } | ||
11987 | |||
11988 | #region Not Implemented | ||
11989 | // | ||
11990 | // Listing the unimplemented lsl functions here, please move | ||
11991 | // them from this region as they are completed | ||
11992 | // | ||
11993 | |||
11994 | public void llGetEnv(LSL_String name) | ||
11995 | { | ||
11996 | m_host.AddScriptLPS(1); | ||
11997 | NotImplemented("llGetEnv"); | ||
12132 | } | 11998 | } |
12133 | 11999 | ||
12134 | public void llSetSoundQueueing(int queue) | 12000 | public void llSetSoundQueueing(int queue) |
@@ -12208,8 +12074,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12208 | 12074 | ||
12209 | try | 12075 | try |
12210 | { | 12076 | { |
12211 | UUID invItemID=InventorySelf(); | 12077 | TaskInventoryItem item = GetSelfInventoryItem(); |
12212 | if (invItemID == UUID.Zero) | 12078 | if (item == null) |
12213 | { | 12079 | { |
12214 | replydata = "SERVICE_ERROR"; | 12080 | replydata = "SERVICE_ERROR"; |
12215 | return; | 12081 | return; |
@@ -12217,10 +12083,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12217 | 12083 | ||
12218 | m_host.AddScriptLPS(1); | 12084 | m_host.AddScriptLPS(1); |
12219 | 12085 | ||
12220 | m_host.TaskInventory.LockItemsForRead(true); | ||
12221 | TaskInventoryItem item = m_host.TaskInventory[invItemID]; | ||
12222 | m_host.TaskInventory.LockItemsForRead(false); | ||
12223 | |||
12224 | if (item.PermsGranter == UUID.Zero) | 12086 | if (item.PermsGranter == UUID.Zero) |
12225 | { | 12087 | { |
12226 | replydata = "MISSING_PERMISSION_DEBIT"; | 12088 | replydata = "MISSING_PERMISSION_DEBIT"; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 77a784d..df20126 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -449,7 +449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
449 | LSShoutError("LightShare functions are not enabled."); | 449 | LSShoutError("LightShare functions are not enabled."); |
450 | return 0; | 450 | return 0; |
451 | } | 451 | } |
452 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 452 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
453 | { | 453 | { |
454 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 454 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
455 | return 0; | 455 | return 0; |
@@ -477,7 +477,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
477 | LSShoutError("LightShare functions are not enabled."); | 477 | LSShoutError("LightShare functions are not enabled."); |
478 | return; | 478 | return; |
479 | } | 479 | } |
480 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 480 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
481 | { | 481 | { |
482 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); | 482 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
483 | return; | 483 | return; |
@@ -500,7 +500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
500 | LSShoutError("LightShare functions are not enabled."); | 500 | LSShoutError("LightShare functions are not enabled."); |
501 | return 0; | 501 | return 0; |
502 | } | 502 | } |
503 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | 503 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) |
504 | { | 504 | { |
505 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); | 505 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); |
506 | return 0; | 506 | return 0; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 0dc2aa2..60568a8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -218,6 +218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | /// <summary> | ||
222 | /// Initialize the LSL interface. | ||
223 | /// </summary> | ||
224 | /// <remarks> | ||
225 | /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no | ||
226 | /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from | ||
227 | /// ScriptInstance. | ||
228 | /// </remarks> | ||
221 | private void InitLSL() | 229 | private void InitLSL() |
222 | { | 230 | { |
223 | if (m_LSL_Api != null) | 231 | if (m_LSL_Api != null) |
@@ -352,7 +360,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
352 | 360 | ||
353 | UUID ownerID = ti.OwnerID; | 361 | UUID ownerID = ti.OwnerID; |
354 | 362 | ||
355 | //OSSL only may be used if objet is in the same group as the parcel | 363 | //OSSL only may be used if object is in the same group as the parcel |
356 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) | 364 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) |
357 | { | 365 | { |
358 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); | 366 | ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); |
@@ -378,7 +386,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
378 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) | 386 | if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER")) |
379 | { | 387 | { |
380 | //Only Estate Managers may use the function | 388 | //Only Estate Managers may use the function |
381 | if (World.RegionInfo.EstateSettings.IsEstateManager(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) | 389 | if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID) |
382 | { | 390 | { |
383 | return; | 391 | return; |
384 | } | 392 | } |
@@ -730,11 +738,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
730 | 738 | ||
731 | m_host.AddScriptLPS(1); | 739 | m_host.AddScriptLPS(1); |
732 | 740 | ||
741 | // For safety, we add another permission check here, and don't rely only on the standard OSSL permissions | ||
733 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 742 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) |
734 | { | 743 | { |
735 | MainConsole.Instance.RunCommand(command); | 744 | MainConsole.Instance.RunCommand(command); |
736 | return true; | 745 | return true; |
737 | } | 746 | } |
747 | |||
738 | return false; | 748 | return false; |
739 | } | 749 | } |
740 | 750 | ||
@@ -1186,12 +1196,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1186 | CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); | 1196 | CheckThreatLevel(ThreatLevel.High, "osSetRegionWaterHeight"); |
1187 | 1197 | ||
1188 | m_host.AddScriptLPS(1); | 1198 | m_host.AddScriptLPS(1); |
1189 | //Check to make sure that the script's owner is the estate manager/master | 1199 | |
1190 | //World.Permissions.GenericEstatePermission( | 1200 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); |
1191 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1192 | { | ||
1193 | World.EventManager.TriggerRequestChangeWaterHeight((float)height); | ||
1194 | } | ||
1195 | } | 1201 | } |
1196 | 1202 | ||
1197 | /// <summary> | 1203 | /// <summary> |
@@ -1202,27 +1208,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1202 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> | 1208 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> |
1203 | public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) | 1209 | public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour) |
1204 | { | 1210 | { |
1205 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetRegionSunSettings"); | 1211 | CheckThreatLevel(ThreatLevel.High, "osSetRegionSunSettings"); |
1206 | 1212 | ||
1207 | m_host.AddScriptLPS(1); | 1213 | m_host.AddScriptLPS(1); |
1208 | //Check to make sure that the script's owner is the estate manager/master | ||
1209 | //World.Permissions.GenericEstatePermission( | ||
1210 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1211 | { | ||
1212 | while (sunHour > 24.0) | ||
1213 | sunHour -= 24.0; | ||
1214 | 1214 | ||
1215 | while (sunHour < 0) | 1215 | while (sunHour > 24.0) |
1216 | sunHour += 24.0; | 1216 | sunHour -= 24.0; |
1217 | 1217 | ||
1218 | while (sunHour < 0) | ||
1219 | sunHour += 24.0; | ||
1218 | 1220 | ||
1219 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; | 1221 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; |
1220 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 | 1222 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 |
1221 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; | 1223 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; |
1222 | World.RegionInfo.RegionSettings.Save(); | 1224 | World.RegionInfo.RegionSettings.Save(); |
1223 | 1225 | ||
1224 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); | 1226 | World.EventManager.TriggerEstateToolsSunUpdate( |
1225 | } | 1227 | World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour); |
1226 | } | 1228 | } |
1227 | 1229 | ||
1228 | /// <summary> | 1230 | /// <summary> |
@@ -1232,26 +1234,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1232 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> | 1234 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> |
1233 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) | 1235 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) |
1234 | { | 1236 | { |
1235 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); | 1237 | CheckThreatLevel(ThreatLevel.High, "osSetEstateSunSettings"); |
1236 | 1238 | ||
1237 | m_host.AddScriptLPS(1); | 1239 | m_host.AddScriptLPS(1); |
1238 | //Check to make sure that the script's owner is the estate manager/master | ||
1239 | //World.Permissions.GenericEstatePermission( | ||
1240 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
1241 | { | ||
1242 | while (sunHour > 24.0) | ||
1243 | sunHour -= 24.0; | ||
1244 | 1240 | ||
1245 | while (sunHour < 0) | 1241 | while (sunHour > 24.0) |
1246 | sunHour += 24.0; | 1242 | sunHour -= 24.0; |
1247 | 1243 | ||
1248 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; | 1244 | while (sunHour < 0) |
1249 | World.RegionInfo.EstateSettings.SunPosition = sunHour; | 1245 | sunHour += 24.0; |
1250 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
1251 | World.RegionInfo.EstateSettings.Save(); | ||
1252 | 1246 | ||
1253 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | 1247 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; |
1254 | } | 1248 | World.RegionInfo.EstateSettings.SunPosition = sunHour; |
1249 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
1250 | World.RegionInfo.EstateSettings.Save(); | ||
1251 | |||
1252 | World.EventManager.TriggerEstateToolsSunUpdate( | ||
1253 | World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | ||
1255 | } | 1254 | } |
1256 | 1255 | ||
1257 | /// <summary> | 1256 | /// <summary> |
@@ -1627,7 +1626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1627 | 1626 | ||
1628 | public Object osParseJSONNew(string JSON) | 1627 | public Object osParseJSONNew(string JSON) |
1629 | { | 1628 | { |
1630 | CheckThreatLevel(ThreatLevel.None, "osParseJSON"); | 1629 | CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); |
1631 | 1630 | ||
1632 | m_host.AddScriptLPS(1); | 1631 | m_host.AddScriptLPS(1); |
1633 | 1632 | ||
@@ -2555,7 +2554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2555 | 2554 | ||
2556 | public void osNpcStopMoveToTarget(LSL_Key npc) | 2555 | public void osNpcStopMoveToTarget(LSL_Key npc) |
2557 | { | 2556 | { |
2558 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | 2557 | CheckThreatLevel(ThreatLevel.High, "osNpcStopMoveToTarget"); |
2559 | m_host.AddScriptLPS(1); | 2558 | m_host.AddScriptLPS(1); |
2560 | 2559 | ||
2561 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2560 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
@@ -2572,6 +2571,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2572 | 2571 | ||
2573 | public void osNpcSay(LSL_Key npc, string message) | 2572 | public void osNpcSay(LSL_Key npc, string message) |
2574 | { | 2573 | { |
2574 | osNpcSay(npc, 0, message); | ||
2575 | } | ||
2576 | |||
2577 | public void osNpcSay(LSL_Key npc, int channel, string message) | ||
2578 | { | ||
2575 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | 2579 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); |
2576 | m_host.AddScriptLPS(1); | 2580 | m_host.AddScriptLPS(1); |
2577 | 2581 | ||
@@ -2583,7 +2587,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2583 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2587 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) |
2584 | return; | 2588 | return; |
2585 | 2589 | ||
2586 | module.Say(npcId, World, message); | 2590 | module.Say(npcId, World, message, channel); |
2591 | } | ||
2592 | } | ||
2593 | |||
2594 | public void osNpcShout(LSL_Key npc, int channel, string message) | ||
2595 | { | ||
2596 | CheckThreatLevel(ThreatLevel.High, "osNpcShout"); | ||
2597 | m_host.AddScriptLPS(1); | ||
2598 | |||
2599 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2600 | if (module != null) | ||
2601 | { | ||
2602 | UUID npcId = new UUID(npc.m_string); | ||
2603 | |||
2604 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2605 | return; | ||
2606 | |||
2607 | module.Shout(npcId, World, message, channel); | ||
2587 | } | 2608 | } |
2588 | } | 2609 | } |
2589 | 2610 | ||
@@ -2684,6 +2705,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2684 | } | 2705 | } |
2685 | } | 2706 | } |
2686 | 2707 | ||
2708 | public void osNpcWhisper(LSL_Key npc, int channel, string message) | ||
2709 | { | ||
2710 | CheckThreatLevel(ThreatLevel.High, "osNpcWhisper"); | ||
2711 | m_host.AddScriptLPS(1); | ||
2712 | |||
2713 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2714 | if (module != null) | ||
2715 | { | ||
2716 | UUID npcId = new UUID(npc.m_string); | ||
2717 | |||
2718 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2719 | return; | ||
2720 | |||
2721 | module.Whisper(npcId, World, message, channel); | ||
2722 | } | ||
2723 | } | ||
2724 | |||
2687 | /// <summary> | 2725 | /// <summary> |
2688 | /// Save the current appearance of the script owner permanently to the named notecard. | 2726 | /// Save the current appearance of the script owner permanently to the named notecard. |
2689 | /// </summary> | 2727 | /// </summary> |
@@ -2835,21 +2873,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2835 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); | 2873 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); |
2836 | m_host.AddScriptLPS(1); | 2874 | m_host.AddScriptLPS(1); |
2837 | 2875 | ||
2838 | if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) | 2876 | World.ForEachRootScenePresence(delegate(ScenePresence sp) |
2839 | { | 2877 | { |
2840 | World.ForEachRootScenePresence(delegate(ScenePresence sp) | 2878 | if (sp.Firstname == FirstName && sp.Lastname == SurName) |
2841 | { | 2879 | { |
2842 | if (sp.Firstname == FirstName && sp.Lastname == SurName) | 2880 | // kick client... |
2843 | { | 2881 | if (alert != null) |
2844 | // kick client... | 2882 | sp.ControllingClient.Kick(alert); |
2845 | if (alert != null) | ||
2846 | sp.ControllingClient.Kick(alert); | ||
2847 | 2883 | ||
2848 | // ...and close on our side | 2884 | // ...and close on our side |
2849 | sp.Scene.IncomingCloseAgent(sp.UUID); | 2885 | sp.Scene.IncomingCloseAgent(sp.UUID); |
2850 | } | 2886 | } |
2851 | }); | 2887 | }); |
2852 | } | ||
2853 | } | 2888 | } |
2854 | 2889 | ||
2855 | public void osCauseDamage(string avatar, double damage) | 2890 | public void osCauseDamage(string avatar, double damage) |
@@ -3095,5 +3130,80 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3095 | 3130 | ||
3096 | return ScriptBaseClass.TRUE; | 3131 | return ScriptBaseClass.TRUE; |
3097 | } | 3132 | } |
3133 | |||
3134 | /// <summary> | ||
3135 | /// Sets terrain estate texture | ||
3136 | /// </summary> | ||
3137 | /// <param name="level"></param> | ||
3138 | /// <param name="texture"></param> | ||
3139 | /// <returns></returns> | ||
3140 | public void osSetTerrainTexture(int level, LSL_Key texture) | ||
3141 | { | ||
3142 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture"); | ||
3143 | |||
3144 | m_host.AddScriptLPS(1); | ||
3145 | //Check to make sure that the script's owner is the estate manager/master | ||
3146 | //World.Permissions.GenericEstatePermission( | ||
3147 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3148 | { | ||
3149 | if (level < 0 || level > 3) | ||
3150 | return; | ||
3151 | |||
3152 | UUID textureID = new UUID(); | ||
3153 | if (!UUID.TryParse(texture, out textureID)) | ||
3154 | return; | ||
3155 | |||
3156 | // estate module is required | ||
3157 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3158 | if (estate != null) | ||
3159 | estate.setEstateTerrainBaseTexture(level, textureID); | ||
3160 | } | ||
3161 | } | ||
3162 | |||
3163 | /// <summary> | ||
3164 | /// Sets terrain heights of estate | ||
3165 | /// </summary> | ||
3166 | /// <param name="corner"></param> | ||
3167 | /// <param name="low"></param> | ||
3168 | /// <param name="high"></param> | ||
3169 | /// <returns></returns> | ||
3170 | public void osSetTerrainTextureHeight(int corner, double low, double high) | ||
3171 | { | ||
3172 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight"); | ||
3173 | |||
3174 | m_host.AddScriptLPS(1); | ||
3175 | //Check to make sure that the script's owner is the estate manager/master | ||
3176 | //World.Permissions.GenericEstatePermission( | ||
3177 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
3178 | { | ||
3179 | if (corner < 0 || corner > 3) | ||
3180 | return; | ||
3181 | |||
3182 | // estate module is required | ||
3183 | IEstateModule estate = World.RequestModuleInterface<IEstateModule>(); | ||
3184 | if (estate != null) | ||
3185 | estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); | ||
3186 | } | ||
3187 | } | ||
3188 | |||
3189 | public void osForceAttachToAvatar(int attachmentPoint) | ||
3190 | { | ||
3191 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); | ||
3192 | |||
3193 | m_host.AddScriptLPS(1); | ||
3194 | |||
3195 | InitLSL(); | ||
3196 | ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); | ||
3197 | } | ||
3198 | |||
3199 | public void osForceDetachFromAvatar() | ||
3200 | { | ||
3201 | CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); | ||
3202 | |||
3203 | m_host.AddScriptLPS(1); | ||
3204 | |||
3205 | InitLSL(); | ||
3206 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); | ||
3207 | } | ||
3098 | } | 3208 | } |
3099 | } | 3209 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 1373971..19f3ce1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
308 | } | 308 | } |
309 | SceneObjectPart SensePoint = ts.host; | 309 | SceneObjectPart SensePoint = ts.host; |
310 | 310 | ||
311 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 311 | Vector3 fromRegionPos = SensePoint.GetWorldPosition(); |
312 | 312 | ||
313 | // pre define some things to avoid repeated definitions in the loop body | 313 | // pre define some things to avoid repeated definitions in the loop body |
314 | Vector3 toRegionPos; | 314 | Vector3 toRegionPos; |
@@ -323,13 +323,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
323 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | 323 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! |
324 | if (SensePoint.ParentGroup.IsAttachment) | 324 | if (SensePoint.ParentGroup.IsAttachment) |
325 | { | 325 | { |
326 | // In attachments, the sensor cone always orients with the | 326 | // In attachments, rotate the sensor cone with the |
327 | // avatar rotation. This may include a nonzero elevation if | 327 | // avatar rotation. This may include a nonzero elevation if |
328 | // in mouselook. | 328 | // in mouselook. |
329 | // This will not include the rotation and position of the | ||
330 | // attachment point (e.g. your head when a sensor is in your | ||
331 | // hair attached to your scull. Your hair will turn with | ||
332 | // your head but the sensor will stay with your (global) | ||
333 | // avatar rotation and position. | ||
334 | // Position of a sensor in a child prim attached to an avatar | ||
335 | // will be still wrong. | ||
329 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 336 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
330 | fromRegionPos = avatar.AbsolutePosition; | 337 | fromRegionPos = avatar.AbsolutePosition; |
331 | q = avatar.Rotation; | 338 | q = avatar.Rotation; |
332 | } | 339 | } |
340 | |||
333 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 341 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
334 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 342 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
335 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 343 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
@@ -441,14 +449,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
441 | return sensedEntities; | 449 | return sensedEntities; |
442 | 450 | ||
443 | SceneObjectPart SensePoint = ts.host; | 451 | SceneObjectPart SensePoint = ts.host; |
444 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 452 | Vector3 fromRegionPos = SensePoint.GetWorldPosition(); |
445 | 453 | ||
446 | Quaternion q = SensePoint.RotationOffset; | 454 | Quaternion q = SensePoint.GetWorldRotation(); |
447 | if (SensePoint.ParentGroup.IsAttachment) | 455 | if (SensePoint.ParentGroup.IsAttachment) |
448 | { | 456 | { |
449 | // In attachments, the sensor cone always orients with the | 457 | // In attachments, rotate the sensor cone with the |
450 | // avatar rotation. This may include a nonzero elevation if | 458 | // avatar rotation. This may include a nonzero elevation if |
451 | // in mouselook. | 459 | // in mouselook. |
460 | // This will not include the rotation and position of the | ||
461 | // attachment point (e.g. your head when a sensor is in your | ||
462 | // hair attached to your scull. Your hair will turn with | ||
463 | // your head but the sensor will stay with your (global) | ||
464 | // avatar rotation and position. | ||
465 | // Position of a sensor in a child prim attached to an avatar | ||
466 | // will be still wrong. | ||
452 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 467 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
453 | if (avatar == null) | 468 | if (avatar == null) |
454 | return sensedEntities; | 469 | return sensedEntities; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 5c528977..2ecc455 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -105,6 +105,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
105 | LSL_Integer llFloor(double f); | 105 | LSL_Integer llFloor(double f); |
106 | void llForceMouselook(int mouselook); | 106 | void llForceMouselook(int mouselook); |
107 | LSL_Float llFrand(double mag); | 107 | LSL_Float llFrand(double mag); |
108 | LSL_Key llGenerateKey(); | ||
108 | LSL_Vector llGetAccel(); | 109 | LSL_Vector llGetAccel(); |
109 | LSL_Integer llGetAgentInfo(string id); | 110 | LSL_Integer llGetAgentInfo(string id); |
110 | LSL_String llGetAgentLanguage(string id); | 111 | LSL_String llGetAgentLanguage(string id); |
@@ -149,7 +150,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
149 | LSL_Rotation llGetLocalRot(); | 150 | LSL_Rotation llGetLocalRot(); |
150 | LSL_Float llGetMass(); | 151 | LSL_Float llGetMass(); |
151 | LSL_Float llGetMassMKS(); | 152 | LSL_Float llGetMassMKS(); |
152 | void llGetNextEmail(string address, string subject); | 153 | LSL_Integer llGetMemoryLimit(); |
154 | void llGetNextEmail(string address, string subject); | ||
153 | LSL_String llGetNotecardLine(string name, int line); | 155 | LSL_String llGetNotecardLine(string name, int line); |
154 | LSL_Key llGetNumberOfNotecardLines(string name); | 156 | LSL_Key llGetNumberOfNotecardLines(string name); |
155 | LSL_Integer llGetNumberOfPrims(); | 157 | LSL_Integer llGetNumberOfPrims(); |
@@ -187,6 +189,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
187 | LSL_String llGetScriptName(); | 189 | LSL_String llGetScriptName(); |
188 | LSL_Integer llGetScriptState(string name); | 190 | LSL_Integer llGetScriptState(string name); |
189 | LSL_String llGetSimulatorHostname(); | 191 | LSL_String llGetSimulatorHostname(); |
192 | LSL_Integer llGetSPMaxMemory(); | ||
190 | LSL_Integer llGetStartParameter(); | 193 | LSL_Integer llGetStartParameter(); |
191 | LSL_Integer llGetStatus(int status); | 194 | LSL_Integer llGetStatus(int status); |
192 | LSL_String llGetSubString(string src, int start, int end); | 195 | LSL_String llGetSubString(string src, int start, int end); |
@@ -322,6 +325,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
322 | void llSay(int channelID, string text); | 325 | void llSay(int channelID, string text); |
323 | void llScaleTexture(double u, double v, int face); | 326 | void llScaleTexture(double u, double v, int face); |
324 | LSL_Integer llScriptDanger(LSL_Vector pos); | 327 | LSL_Integer llScriptDanger(LSL_Vector pos); |
328 | void llScriptProfiler(LSL_Integer flag); | ||
325 | LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); | 329 | LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata); |
326 | void llSensor(string name, string id, int type, double range, double arc); | 330 | void llSensor(string name, string id, int type, double range, double arc); |
327 | void llSensorRemove(); | 331 | void llSensorRemove(); |
@@ -345,6 +349,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
345 | void llSetLinkTexture(int linknumber, string texture, int face); | 349 | void llSetLinkTexture(int linknumber, string texture, int face); |
346 | void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); | 350 | void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate); |
347 | void llSetLocalRot(LSL_Rotation rot); | 351 | void llSetLocalRot(LSL_Rotation rot); |
352 | LSL_Integer llSetMemoryLimit(LSL_Integer limit); | ||
348 | void llSetObjectDesc(string desc); | 353 | void llSetObjectDesc(string desc); |
349 | void llSetObjectName(string name); | 354 | void llSetObjectName(string name); |
350 | void llSetObjectPermMask(int mask, int value); | 355 | void llSetObjectPermMask(int mask, int value); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 444a681..7382495 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
98 | void osAvatarPlayAnimation(string avatar, string animation); | 98 | void osAvatarPlayAnimation(string avatar, string animation); |
99 | void osAvatarStopAnimation(string avatar, string animation); | 99 | void osAvatarStopAnimation(string avatar, string animation); |
100 | 100 | ||
101 | // Attachment commands | ||
102 | |||
103 | /// <summary> | ||
104 | /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH | ||
105 | /// </summary> | ||
106 | /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param> | ||
107 | void osForceAttachToAvatar(int attachment); | ||
108 | |||
109 | /// <summary> | ||
110 | /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH | ||
111 | /// </summary> | ||
112 | /// <remarks>Nothing happens if the object is not attached.</remarks> | ||
113 | void osForceDetachFromAvatar(); | ||
114 | |||
101 | //texture draw functions | 115 | //texture draw functions |
102 | string osMovePen(string drawList, int x, int y); | 116 | string osMovePen(string drawList, int x, int y); |
103 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); | 117 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); |
@@ -203,11 +217,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
203 | void osNpcSetRot(LSL_Key npc, rotation rot); | 217 | void osNpcSetRot(LSL_Key npc, rotation rot); |
204 | void osNpcStopMoveToTarget(LSL_Key npc); | 218 | void osNpcStopMoveToTarget(LSL_Key npc); |
205 | void osNpcSay(key npc, string message); | 219 | void osNpcSay(key npc, string message); |
220 | void osNpcSay(key npc, int channel, string message); | ||
221 | void osNpcShout(key npc, int channel, string message); | ||
206 | void osNpcSit(key npc, key target, int options); | 222 | void osNpcSit(key npc, key target, int options); |
207 | void osNpcStand(LSL_Key npc); | 223 | void osNpcStand(LSL_Key npc); |
208 | void osNpcRemove(key npc); | 224 | void osNpcRemove(key npc); |
209 | void osNpcPlayAnimation(LSL_Key npc, string animation); | 225 | void osNpcPlayAnimation(LSL_Key npc, string animation); |
210 | void osNpcStopAnimation(LSL_Key npc, string animation); | 226 | void osNpcStopAnimation(LSL_Key npc, string animation); |
227 | void osNpcWhisper(key npc, int channel, string message); | ||
211 | 228 | ||
212 | LSL_Key osOwnerSaveAppearance(string notecard); | 229 | LSL_Key osOwnerSaveAppearance(string notecard); |
213 | LSL_Key osAgentSaveAppearance(key agentId, string notecard); | 230 | LSL_Key osAgentSaveAppearance(key agentId, string notecard); |
@@ -234,5 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
234 | 251 | ||
235 | LSL_Integer osInviteToGroup(LSL_Key agentId); | 252 | LSL_Integer osInviteToGroup(LSL_Key agentId); |
236 | LSL_Integer osEjectFromGroup(LSL_Key agentId); | 253 | LSL_Integer osEjectFromGroup(LSL_Key agentId); |
254 | |||
255 | void osSetTerrainTexture(int level, LSL_Key texture); | ||
256 | void osSetTerrainTextureHeight(int corner, double low, double high); | ||
237 | } | 257 | } |
238 | } | 258 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 6246b57..23b4336 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -383,6 +383,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
383 | public const int PRIM_SCULPT_FLAG_INVERT = 64; | 383 | public const int PRIM_SCULPT_FLAG_INVERT = 64; |
384 | public const int PRIM_SCULPT_FLAG_MIRROR = 128; | 384 | public const int PRIM_SCULPT_FLAG_MIRROR = 128; |
385 | 385 | ||
386 | public const int PROFILE_NONE = 0; | ||
387 | public const int PROFILE_SCRIPT_MEMORY = 1; | ||
388 | |||
386 | public const int MASK_BASE = 0; | 389 | public const int MASK_BASE = 0; |
387 | public const int MASK_OWNER = 1; | 390 | public const int MASK_OWNER = 1; |
388 | public const int MASK_GROUP = 2; | 391 | public const int MASK_GROUP = 2; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 70c5fcd..8db4006 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -376,6 +376,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
376 | return m_LSL_Functions.llFrand(mag); | 376 | return m_LSL_Functions.llFrand(mag); |
377 | } | 377 | } |
378 | 378 | ||
379 | public LSL_Key llGenerateKey() | ||
380 | { | ||
381 | return m_LSL_Functions.llGenerateKey(); | ||
382 | } | ||
383 | |||
379 | public LSL_Vector llGetAccel() | 384 | public LSL_Vector llGetAccel() |
380 | { | 385 | { |
381 | return m_LSL_Functions.llGetAccel(); | 386 | return m_LSL_Functions.llGetAccel(); |
@@ -586,6 +591,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
586 | return m_LSL_Functions.llGetMassMKS(); | 591 | return m_LSL_Functions.llGetMassMKS(); |
587 | } | 592 | } |
588 | 593 | ||
594 | public LSL_Integer llGetMemoryLimit() | ||
595 | { | ||
596 | return m_LSL_Functions.llGetMemoryLimit(); | ||
597 | } | ||
598 | |||
589 | public void llGetNextEmail(string address, string subject) | 599 | public void llGetNextEmail(string address, string subject) |
590 | { | 600 | { |
591 | m_LSL_Functions.llGetNextEmail(address, subject); | 601 | m_LSL_Functions.llGetNextEmail(address, subject); |
@@ -776,6 +786,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
776 | return m_LSL_Functions.llGetSimulatorHostname(); | 786 | return m_LSL_Functions.llGetSimulatorHostname(); |
777 | } | 787 | } |
778 | 788 | ||
789 | public LSL_Integer llGetSPMaxMemory() | ||
790 | { | ||
791 | return m_LSL_Functions.llGetSPMaxMemory(); | ||
792 | } | ||
793 | |||
779 | public LSL_Integer llGetStartParameter() | 794 | public LSL_Integer llGetStartParameter() |
780 | { | 795 | { |
781 | return m_LSL_Functions.llGetStartParameter(); | 796 | return m_LSL_Functions.llGetStartParameter(); |
@@ -1445,6 +1460,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1445 | return m_LSL_Functions.llScriptDanger(pos); | 1460 | return m_LSL_Functions.llScriptDanger(pos); |
1446 | } | 1461 | } |
1447 | 1462 | ||
1463 | public void llScriptProfiler(LSL_Integer flags) | ||
1464 | { | ||
1465 | m_LSL_Functions.llScriptProfiler(flags); | ||
1466 | } | ||
1467 | |||
1448 | public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) | 1468 | public LSL_Key llSendRemoteData(string channel, string dest, int idata, string sdata) |
1449 | { | 1469 | { |
1450 | return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); | 1470 | return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); |
@@ -1555,6 +1575,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1555 | m_LSL_Functions.llSetLocalRot(rot); | 1575 | m_LSL_Functions.llSetLocalRot(rot); |
1556 | } | 1576 | } |
1557 | 1577 | ||
1578 | public LSL_Integer llSetMemoryLimit(LSL_Integer limit) | ||
1579 | { | ||
1580 | return m_LSL_Functions.llSetMemoryLimit(limit); | ||
1581 | } | ||
1582 | |||
1558 | public void llSetObjectDesc(string desc) | 1583 | public void llSetObjectDesc(string desc) |
1559 | { | 1584 | { |
1560 | m_LSL_Functions.llSetObjectDesc(desc); | 1585 | m_LSL_Functions.llSetObjectDesc(desc); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 680cefb4..d230662 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
289 | m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); | 289 | m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); |
290 | } | 290 | } |
291 | 291 | ||
292 | // Avatar functions | ||
292 | 293 | ||
293 | //Texture Draw functions | 294 | public void osForceAttachToAvatar(int attachmentPoint) |
295 | { | ||
296 | m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); | ||
297 | } | ||
298 | |||
299 | public void osForceDetachFromAvatar() | ||
300 | { | ||
301 | m_OSSL_Functions.osForceDetachFromAvatar(); | ||
302 | } | ||
303 | |||
304 | // Texture Draw functions | ||
294 | 305 | ||
295 | public string osMovePen(string drawList, int x, int y) | 306 | public string osMovePen(string drawList, int x, int y) |
296 | { | 307 | { |
@@ -569,6 +580,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
569 | m_OSSL_Functions.osNpcSay(npc, message); | 580 | m_OSSL_Functions.osNpcSay(npc, message); |
570 | } | 581 | } |
571 | 582 | ||
583 | public void osNpcSay(key npc, int channel, string message) | ||
584 | { | ||
585 | m_OSSL_Functions.osNpcSay(npc, channel, message); | ||
586 | } | ||
587 | |||
588 | |||
589 | public void osNpcShout(key npc, int channel, string message) | ||
590 | { | ||
591 | m_OSSL_Functions.osNpcShout(npc, channel, message); | ||
592 | } | ||
593 | |||
572 | public void osNpcSit(LSL_Key npc, LSL_Key target, int options) | 594 | public void osNpcSit(LSL_Key npc, LSL_Key target, int options) |
573 | { | 595 | { |
574 | m_OSSL_Functions.osNpcSit(npc, target, options); | 596 | m_OSSL_Functions.osNpcSit(npc, target, options); |
@@ -594,6 +616,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
594 | m_OSSL_Functions.osNpcStopAnimation(npc, animation); | 616 | m_OSSL_Functions.osNpcStopAnimation(npc, animation); |
595 | } | 617 | } |
596 | 618 | ||
619 | public void osNpcWhisper(key npc, int channel, string message) | ||
620 | { | ||
621 | m_OSSL_Functions.osNpcWhisper(npc, channel, message); | ||
622 | } | ||
623 | |||
597 | public LSL_Key osOwnerSaveAppearance(string notecard) | 624 | public LSL_Key osOwnerSaveAppearance(string notecard) |
598 | { | 625 | { |
599 | return m_OSSL_Functions.osOwnerSaveAppearance(notecard); | 626 | return m_OSSL_Functions.osOwnerSaveAppearance(notecard); |
@@ -878,5 +905,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
878 | { | 905 | { |
879 | return m_OSSL_Functions.osEjectFromGroup(agentId); | 906 | return m_OSSL_Functions.osEjectFromGroup(agentId); |
880 | } | 907 | } |
908 | |||
909 | public void osSetTerrainTexture(int level, LSL_Key texture) | ||
910 | { | ||
911 | m_OSSL_Functions.osSetTerrainTexture(level, texture); | ||
912 | } | ||
913 | |||
914 | public void osSetTerrainTextureHeight(int corner, double low, double high) | ||
915 | { | ||
916 | m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high); | ||
917 | } | ||
881 | } | 918 | } |
882 | } | 919 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index ff1f277..0f763f1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
964 | public IScriptApi GetApi(string name) | 964 | public IScriptApi GetApi(string name) |
965 | { | 965 | { |
966 | if (m_Apis.ContainsKey(name)) | 966 | if (m_Apis.ContainsKey(name)) |
967 | { | ||
968 | // m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName); | ||
969 | |||
967 | return m_Apis[name]; | 970 | return m_Apis[name]; |
971 | } | ||
972 | |||
973 | // m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName); | ||
974 | |||
968 | return null; | 975 | return null; |
969 | } | 976 | } |
970 | 977 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index e2d0db2..49266e9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
63 | IConfig config = initConfigSource.AddConfig("XEngine"); | 63 | IConfig config = initConfigSource.AddConfig("XEngine"); |
64 | config.Set("Enabled", "true"); | 64 | config.Set("Enabled", "true"); |
65 | 65 | ||
66 | m_scene = SceneHelpers.SetupScene(); | 66 | m_scene = new SceneHelpers().SetupScene(); |
67 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | 67 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); |
68 | 68 | ||
69 | m_engine = new XEngine.XEngine(); | 69 | m_engine = new XEngine.XEngine(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 9cf9258..92a63bf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
58 | IConfig config = initConfigSource.AddConfig("XEngine"); | 58 | IConfig config = initConfigSource.AddConfig("XEngine"); |
59 | config.Set("Enabled", "true"); | 59 | config.Set("Enabled", "true"); |
60 | 60 | ||
61 | Scene scene = SceneHelpers.SetupScene(); | 61 | Scene scene = new SceneHelpers().SetupScene(); |
62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); | 62 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |
63 | 63 | ||
64 | XEngine.XEngine engine = new XEngine.XEngine(); | 64 | XEngine.XEngine engine = new XEngine.XEngine(); |
@@ -261,7 +261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
261 | TestHelpers.InMethod(); | 261 | TestHelpers.InMethod(); |
262 | 262 | ||
263 | // Create Prim1. | 263 | // Create Prim1. |
264 | Scene scene = SceneHelpers.SetupScene(); | 264 | Scene scene = new SceneHelpers().SetupScene(); |
265 | string obj1Name = "Prim1"; | 265 | string obj1Name = "Prim1"; |
266 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | 266 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); |
267 | SceneObjectPart part1 = | 267 | SceneObjectPart part1 = |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index 7573dff..c51227b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | |||
@@ -67,7 +67,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
67 | config = initConfigSource.AddConfig("NPC"); | 67 | config = initConfigSource.AddConfig("NPC"); |
68 | config.Set("Enabled", "true"); | 68 | config.Set("Enabled", "true"); |
69 | 69 | ||
70 | m_scene = SceneHelpers.SetupScene(); | 70 | m_scene = new SceneHelpers().SetupScene(); |
71 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); | 71 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); |
72 | 72 | ||
73 | m_engine = new XEngine.XEngine(); | 73 | m_engine = new XEngine.XEngine(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 9d9fc51..9c36108 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
68 | config = initConfigSource.AddConfig("NPC"); | 68 | config = initConfigSource.AddConfig("NPC"); |
69 | config.Set("Enabled", "true"); | 69 | config.Set("Enabled", "true"); |
70 | 70 | ||
71 | m_scene = SceneHelpers.SetupScene(); | 71 | m_scene = new SceneHelpers().SetupScene(); |
72 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); | 72 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); |
73 | 73 | ||
74 | m_engine = new XEngine.XEngine(); | 74 | m_engine = new XEngine.XEngine(); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index 7d7bd82..a3f848c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | |||
@@ -73,7 +73,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
73 | // to AssemblyResolver.OnAssemblyResolve fails. | 73 | // to AssemblyResolver.OnAssemblyResolve fails. |
74 | xEngineConfig.Set("AppDomainLoading", "false"); | 74 | xEngineConfig.Set("AppDomainLoading", "false"); |
75 | 75 | ||
76 | m_scene = SceneHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, null, configSource); | 76 | m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); |
77 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); | 77 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); |
78 | m_scene.StartScripts(); | 78 | m_scene.StartScripts(); |
79 | } | 79 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 1e0f01f..eeb125e 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1089,11 +1089,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1089 | 1089 | ||
1090 | AppDomain sandbox; | 1090 | AppDomain sandbox; |
1091 | if (m_AppDomainLoading) | 1091 | if (m_AppDomainLoading) |
1092 | { | ||
1092 | sandbox = AppDomain.CreateDomain( | 1093 | sandbox = AppDomain.CreateDomain( |
1093 | m_Scene.RegionInfo.RegionID.ToString(), | 1094 | m_Scene.RegionInfo.RegionID.ToString(), |
1094 | evidence, appSetup); | 1095 | evidence, appSetup); |
1096 | m_AppDomains[appDomain].AssemblyResolve += | ||
1097 | new ResolveEventHandler( | ||
1098 | AssemblyResolver.OnAssemblyResolve); | ||
1099 | } | ||
1095 | else | 1100 | else |
1101 | { | ||
1096 | sandbox = AppDomain.CurrentDomain; | 1102 | sandbox = AppDomain.CurrentDomain; |
1103 | } | ||
1097 | 1104 | ||
1098 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | 1105 | //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); |
1099 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | 1106 | //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); |
@@ -1105,9 +1112,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1105 | 1112 | ||
1106 | m_AppDomains[appDomain] = sandbox; | 1113 | m_AppDomains[appDomain] = sandbox; |
1107 | 1114 | ||
1108 | m_AppDomains[appDomain].AssemblyResolve += | ||
1109 | new ResolveEventHandler( | ||
1110 | AssemblyResolver.OnAssemblyResolve); | ||
1111 | m_DomainScripts[appDomain] = new List<UUID>(); | 1115 | m_DomainScripts[appDomain] = new List<UUID>(); |
1112 | } | 1116 | } |
1113 | catch (Exception e) | 1117 | catch (Exception e) |
@@ -1898,9 +1902,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1898 | // if there already exists a file at that location, it may be locked. | 1902 | // if there already exists a file at that location, it may be locked. |
1899 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | 1903 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); |
1900 | } | 1904 | } |
1905 | |||
1906 | string textpath = path + ".text"; | ||
1901 | try | 1907 | try |
1902 | { | 1908 | { |
1903 | using (FileStream fs = File.Create(path + ".text")) | 1909 | using (FileStream fs = File.Create(textpath)) |
1904 | { | 1910 | { |
1905 | using (StreamWriter sw = new StreamWriter(fs)) | 1911 | using (StreamWriter sw = new StreamWriter(fs)) |
1906 | { | 1912 | { |
@@ -1913,7 +1919,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1913 | catch (IOException ex) | 1919 | catch (IOException ex) |
1914 | { | 1920 | { |
1915 | // if there already exists a file at that location, it may be locked. | 1921 | // if there already exists a file at that location, it may be locked. |
1916 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); | 1922 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", textpath, ex.Message); |
1917 | } | 1923 | } |
1918 | } | 1924 | } |
1919 | } | 1925 | } |
@@ -1962,7 +1968,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1962 | catch (IOException ex) | 1968 | catch (IOException ex) |
1963 | { | 1969 | { |
1964 | // if there already exists a file at that location, it may be locked. | 1970 | // if there already exists a file at that location, it may be locked. |
1965 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); | 1971 | m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", mappath, ex.Message); |
1966 | } | 1972 | } |
1967 | } | 1973 | } |
1968 | 1974 | ||
@@ -1997,45 +2003,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1997 | if (!topScripts.ContainsKey(si.LocalID)) | 2003 | if (!topScripts.ContainsKey(si.LocalID)) |
1998 | topScripts[si.RootLocalID] = 0; | 2004 | topScripts[si.RootLocalID] = 0; |
1999 | 2005 | ||
2000 | // long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | 2006 | topScripts[si.RootLocalID] += CalculateAdjustedExectionTime(si, tickNow); |
2001 | // float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond); | 2007 | } |
2002 | 2008 | } | |
2003 | // Execution time of the script adjusted by it's measurement period to make scripts started at | ||
2004 | // different times comparable. | ||
2005 | // float adjustedExecutionTime | ||
2006 | // = (float)si.MeasurementPeriodExecutionTime | ||
2007 | // / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod) | ||
2008 | // / TimeSpan.TicksPerMillisecond; | ||
2009 | |||
2010 | long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
2011 | |||
2012 | // Avoid divide by zerp | ||
2013 | if (ticksElapsed == 0) | ||
2014 | ticksElapsed = 1; | ||
2015 | 2009 | ||
2016 | // Scale execution time to the ideal 55 fps frame time for these reasons. | 2010 | return topScripts; |
2017 | // | 2011 | } |
2018 | // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no | ||
2019 | // 'script execution time per frame', which is the original purpose of this value. | ||
2020 | // | ||
2021 | // 2) Giving the raw execution times is misleading since scripts start at different times, making | ||
2022 | // it impossible to compare scripts. | ||
2023 | // | ||
2024 | // 3) Scaling the raw execution time to the time that the script has been running is better but | ||
2025 | // is still misleading since a script that has just been rezzed may appear to have been running | ||
2026 | // for much longer. | ||
2027 | // | ||
2028 | // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect | ||
2029 | // since the figure does not represent actual execution time and very hard running scripts will | ||
2030 | // never exceed 18ms (though this is a very high number for script execution so is a warning sign). | ||
2031 | float adjustedExecutionTime | ||
2032 | = ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; | ||
2033 | 2012 | ||
2034 | topScripts[si.RootLocalID] += adjustedExecutionTime; | 2013 | public float GetScriptExecutionTime(List<UUID> itemIDs) |
2014 | { | ||
2015 | if (itemIDs == null|| itemIDs.Count == 0) | ||
2016 | { | ||
2017 | return 0.0f; | ||
2018 | } | ||
2019 | float time = 0.0f; | ||
2020 | long tickNow = Util.EnvironmentTickCount(); | ||
2021 | IScriptInstance si; | ||
2022 | // Calculate the time for all scripts that this engine is executing | ||
2023 | // Ignore any others | ||
2024 | foreach (UUID id in itemIDs) | ||
2025 | { | ||
2026 | si = GetInstance(id); | ||
2027 | if (si != null && si.Running) | ||
2028 | { | ||
2029 | time += CalculateAdjustedExectionTime(si, tickNow); | ||
2035 | } | 2030 | } |
2036 | } | 2031 | } |
2032 | return time; | ||
2033 | } | ||
2037 | 2034 | ||
2038 | return topScripts; | 2035 | private float CalculateAdjustedExectionTime(IScriptInstance si, long tickNow) |
2036 | { | ||
2037 | long ticksElapsed = tickNow - si.MeasurementPeriodTickStart; | ||
2038 | |||
2039 | // Avoid divide by zero | ||
2040 | if (ticksElapsed == 0) | ||
2041 | ticksElapsed = 1; | ||
2042 | |||
2043 | // Scale execution time to the ideal 55 fps frame time for these reasons. | ||
2044 | // | ||
2045 | // 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no | ||
2046 | // 'script execution time per frame', which is the original purpose of this value. | ||
2047 | // | ||
2048 | // 2) Giving the raw execution times is misleading since scripts start at different times, making | ||
2049 | // it impossible to compare scripts. | ||
2050 | // | ||
2051 | // 3) Scaling the raw execution time to the time that the script has been running is better but | ||
2052 | // is still misleading since a script that has just been rezzed may appear to have been running | ||
2053 | // for much longer. | ||
2054 | // | ||
2055 | // 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect | ||
2056 | // since the figure does not represent actual execution time and very hard running scripts will | ||
2057 | // never exceed 18ms (though this is a very high number for script execution so is a warning sign). | ||
2058 | return ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f; | ||
2039 | } | 2059 | } |
2040 | 2060 | ||
2041 | public void SuspendScript(UUID itemID) | 2061 | public void SuspendScript(UUID itemID) |
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index b9ba4bc..4248035 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -90,7 +90,7 @@ namespace OpenSim.Region.UserStatistics | |||
90 | 90 | ||
91 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); | 91 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); |
92 | dbConn.Open(); | 92 | dbConn.Open(); |
93 | CheckAndUpdateDatabase(dbConn); | 93 | CreateTables(dbConn); |
94 | 94 | ||
95 | Prototype_distributor protodep = new Prototype_distributor(); | 95 | Prototype_distributor protodep = new Prototype_distributor(); |
96 | Updater_distributor updatedep = new Updater_distributor(); | 96 | Updater_distributor updatedep = new Updater_distributor(); |
@@ -131,7 +131,7 @@ namespace OpenSim.Region.UserStatistics | |||
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | public void ReceiveClassicSimStatsPacket(SimStats stats) | 134 | private void ReceiveClassicSimStatsPacket(SimStats stats) |
135 | { | 135 | { |
136 | if (!enabled) | 136 | if (!enabled) |
137 | { | 137 | { |
@@ -163,7 +163,7 @@ namespace OpenSim.Region.UserStatistics | |||
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | public Hashtable HandleUnknownCAPSRequest(Hashtable request) | 166 | private Hashtable HandleUnknownCAPSRequest(Hashtable request) |
167 | { | 167 | { |
168 | //string regpath = request["uri"].ToString(); | 168 | //string regpath = request["uri"].ToString(); |
169 | int response_code = 200; | 169 | int response_code = 200; |
@@ -178,7 +178,7 @@ namespace OpenSim.Region.UserStatistics | |||
178 | return responsedata; | 178 | return responsedata; |
179 | } | 179 | } |
180 | 180 | ||
181 | public Hashtable HandleStatsRequest(Hashtable request) | 181 | private Hashtable HandleStatsRequest(Hashtable request) |
182 | { | 182 | { |
183 | lastHit = System.Environment.TickCount; | 183 | lastHit = System.Environment.TickCount; |
184 | Hashtable responsedata = new Hashtable(); | 184 | Hashtable responsedata = new Hashtable(); |
@@ -237,36 +237,12 @@ namespace OpenSim.Region.UserStatistics | |||
237 | 237 | ||
238 | return responsedata; | 238 | return responsedata; |
239 | } | 239 | } |
240 | |||
241 | public void CheckAndUpdateDatabase(SqliteConnection db) | ||
242 | { | ||
243 | lock (db) | ||
244 | { | ||
245 | // TODO: FIXME: implement stats migrations | ||
246 | const string SQL = @"SELECT * FROM migrations LIMIT 1"; | ||
247 | |||
248 | using (SqliteCommand cmd = new SqliteCommand(SQL, db)) | ||
249 | { | ||
250 | try | ||
251 | { | ||
252 | cmd.ExecuteNonQuery(); | ||
253 | } | ||
254 | catch (SqliteSyntaxException) | ||
255 | { | ||
256 | CreateTables(db); | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | 240 | ||
262 | public void CreateTables(SqliteConnection db) | 241 | private void CreateTables(SqliteConnection db) |
263 | { | 242 | { |
264 | using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) | 243 | using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) |
265 | { | 244 | { |
266 | createcmd.ExecuteNonQuery(); | 245 | createcmd.ExecuteNonQuery(); |
267 | |||
268 | createcmd.CommandText = SQL_MIGRA_TABLE_CREATE; | ||
269 | createcmd.ExecuteNonQuery(); | ||
270 | } | 246 | } |
271 | } | 247 | } |
272 | 248 | ||
@@ -301,7 +277,7 @@ namespace OpenSim.Region.UserStatistics | |||
301 | get { return true; } | 277 | get { return true; } |
302 | } | 278 | } |
303 | 279 | ||
304 | public void OnRegisterCaps(UUID agentID, Caps caps) | 280 | private void OnRegisterCaps(UUID agentID, Caps caps) |
305 | { | 281 | { |
306 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 282 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
307 | 283 | ||
@@ -316,7 +292,7 @@ namespace OpenSim.Region.UserStatistics | |||
316 | })); | 292 | })); |
317 | } | 293 | } |
318 | 294 | ||
319 | public void OnDeRegisterCaps(UUID agentID, Caps caps) | 295 | private void OnDeRegisterCaps(UUID agentID, Caps caps) |
320 | { | 296 | { |
321 | } | 297 | } |
322 | 298 | ||
@@ -336,7 +312,7 @@ namespace OpenSim.Region.UserStatistics | |||
336 | } | 312 | } |
337 | } | 313 | } |
338 | 314 | ||
339 | public void OnMakeRootAgent(ScenePresence agent) | 315 | private void OnMakeRootAgent(ScenePresence agent) |
340 | { | 316 | { |
341 | UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); | 317 | UUID regionUUID = GetRegionUUIDFromHandle(agent.RegionHandle); |
342 | 318 | ||
@@ -365,11 +341,11 @@ namespace OpenSim.Region.UserStatistics | |||
365 | } | 341 | } |
366 | } | 342 | } |
367 | 343 | ||
368 | public void OnMakeChildAgent(ScenePresence agent) | 344 | private void OnMakeChildAgent(ScenePresence agent) |
369 | { | 345 | { |
370 | } | 346 | } |
371 | 347 | ||
372 | public void OnClientClosed(UUID agentID, Scene scene) | 348 | private void OnClientClosed(UUID agentID, Scene scene) |
373 | { | 349 | { |
374 | lock (m_sessions) | 350 | lock (m_sessions) |
375 | { | 351 | { |
@@ -380,7 +356,7 @@ namespace OpenSim.Region.UserStatistics | |||
380 | } | 356 | } |
381 | } | 357 | } |
382 | 358 | ||
383 | public string readLogLines(int amount) | 359 | private string readLogLines(int amount) |
384 | { | 360 | { |
385 | Encoding encoding = Encoding.ASCII; | 361 | Encoding encoding = Encoding.ASCII; |
386 | int sizeOfChar = encoding.GetByteCount("\n"); | 362 | int sizeOfChar = encoding.GetByteCount("\n"); |
@@ -418,7 +394,7 @@ namespace OpenSim.Region.UserStatistics | |||
418 | return encoding.GetString(buffer); | 394 | return encoding.GetString(buffer); |
419 | } | 395 | } |
420 | 396 | ||
421 | public UUID GetRegionUUIDFromHandle(ulong regionhandle) | 397 | private UUID GetRegionUUIDFromHandle(ulong regionhandle) |
422 | { | 398 | { |
423 | lock (m_scenes) | 399 | lock (m_scenes) |
424 | { | 400 | { |
@@ -441,17 +417,17 @@ namespace OpenSim.Region.UserStatistics | |||
441 | /// <param name="agentID"></param> | 417 | /// <param name="agentID"></param> |
442 | /// <param name="caps"></param> | 418 | /// <param name="caps"></param> |
443 | /// <returns></returns> | 419 | /// <returns></returns> |
444 | public string ViewerStatsReport(string request, string path, string param, | 420 | private string ViewerStatsReport(string request, string path, string param, |
445 | UUID agentID, Caps caps) | 421 | UUID agentID, Caps caps) |
446 | { | 422 | { |
447 | // m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); | 423 | // m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); |
448 | 424 | ||
449 | UpdateUserStats(ParseViewerStats(request,agentID), dbConn); | 425 | UpdateUserStats(ParseViewerStats(request, agentID), dbConn); |
450 | 426 | ||
451 | return String.Empty; | 427 | return String.Empty; |
452 | } | 428 | } |
453 | 429 | ||
454 | public UserSessionID ParseViewerStats(string request, UUID agentID) | 430 | private UserSessionID ParseViewerStats(string request, UUID agentID) |
455 | { | 431 | { |
456 | UserSessionID uid = new UserSessionID(); | 432 | UserSessionID uid = new UserSessionID(); |
457 | UserSessionData usd; | 433 | UserSessionData usd; |
@@ -592,14 +568,14 @@ namespace OpenSim.Region.UserStatistics | |||
592 | return uid; | 568 | return uid; |
593 | } | 569 | } |
594 | 570 | ||
595 | public void UpdateUserStats(UserSessionID uid, SqliteConnection db) | 571 | private void UpdateUserStats(UserSessionID uid, SqliteConnection db) |
596 | { | 572 | { |
597 | if (uid.session_id == UUID.Zero) | 573 | if (uid.session_id == UUID.Zero) |
598 | return; | 574 | return; |
599 | 575 | ||
600 | lock (db) | 576 | lock (db) |
601 | { | 577 | { |
602 | using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_UPDATE, db)) | 578 | using (SqliteCommand updatecmd = new SqliteCommand(SQL_STATS_TABLE_INSERT, db)) |
603 | { | 579 | { |
604 | updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); | 580 | updatecmd.Parameters.Add(new SqliteParameter(":session_id", uid.session_data.session_id.ToString())); |
605 | updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); | 581 | updatecmd.Parameters.Add(new SqliteParameter(":agent_id", uid.session_data.agent_id.ToString())); |
@@ -648,44 +624,26 @@ namespace OpenSim.Region.UserStatistics | |||
648 | updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped)); | 624 | updatecmd.Parameters.Add(new SqliteParameter(":f_dropped", uid.session_data.f_dropped)); |
649 | updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends)); | 625 | updatecmd.Parameters.Add(new SqliteParameter(":f_failed_resends", uid.session_data.f_failed_resends)); |
650 | updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid)); | 626 | updatecmd.Parameters.Add(new SqliteParameter(":f_invalid", uid.session_data.f_invalid)); |
651 | |||
652 | updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit)); | 627 | updatecmd.Parameters.Add(new SqliteParameter(":f_off_circuit", uid.session_data.f_off_circuit)); |
653 | updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent)); | 628 | updatecmd.Parameters.Add(new SqliteParameter(":f_resent", uid.session_data.f_resent)); |
654 | updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); | 629 | updatecmd.Parameters.Add(new SqliteParameter(":f_send_packet", uid.session_data.f_send_packet)); |
655 | |||
656 | updatecmd.Parameters.Add(new SqliteParameter(":session_key", uid.session_data.session_id.ToString())); | ||
657 | updatecmd.Parameters.Add(new SqliteParameter(":agent_key", uid.session_data.agent_id.ToString())); | ||
658 | updatecmd.Parameters.Add(new SqliteParameter(":region_key", uid.session_data.region_id.ToString())); | ||
659 | 630 | ||
660 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); | 631 | // StringBuilder parameters = new StringBuilder(); |
661 | 632 | // SqliteParameterCollection spc = updatecmd.Parameters; | |
662 | int result = updatecmd.ExecuteNonQuery(); | 633 | // foreach (SqliteParameter sp in spc) |
663 | 634 | // parameters.AppendFormat("{0}={1},", sp.ParameterName, sp.Value); | |
664 | if (result == 0) | 635 | // |
665 | { | 636 | // m_log.DebugFormat("[WEB STATS MODULE]: Parameters {0}", parameters); |
666 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats insert for {0}", uid.session_data.agent_id); | ||
667 | 637 | ||
668 | updatecmd.CommandText = SQL_STATS_TABLE_INSERT; | 638 | // m_log.DebugFormat("[WEB STATS MODULE]: Database stats update for {0}", uid.session_data.agent_id); |
669 | 639 | ||
670 | try | 640 | updatecmd.ExecuteNonQuery(); |
671 | { | ||
672 | updatecmd.ExecuteNonQuery(); | ||
673 | } | ||
674 | catch (Exception e) | ||
675 | { | ||
676 | m_log.WarnFormat( | ||
677 | "[WEB STATS MODULE]: failed to write stats for {0}, storage Execution Exception {1}{2}", | ||
678 | uid.session_data.agent_id, e.Message, e.StackTrace); | ||
679 | } | ||
680 | } | ||
681 | } | 641 | } |
682 | } | 642 | } |
683 | } | 643 | } |
684 | 644 | ||
685 | #region SQL | 645 | #region SQL |
686 | private const string SQL_MIGRA_TABLE_CREATE = @"create table migrations(name varchar(100), version int)"; | 646 | private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE IF NOT EXISTS stats_session_data ( |
687 | |||
688 | private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE stats_session_data ( | ||
689 | session_id VARCHAR(36) NOT NULL PRIMARY KEY, | 647 | session_id VARCHAR(36) NOT NULL PRIMARY KEY, |
690 | agent_id VARCHAR(36) NOT NULL DEFAULT '', | 648 | agent_id VARCHAR(36) NOT NULL DEFAULT '', |
691 | region_id VARCHAR(36) NOT NULL DEFAULT '', | 649 | region_id VARCHAR(36) NOT NULL DEFAULT '', |
@@ -735,11 +693,11 @@ namespace OpenSim.Region.UserStatistics | |||
735 | f_send_packet INT NOT NULL DEFAULT '0' | 693 | f_send_packet INT NOT NULL DEFAULT '0' |
736 | );"; | 694 | );"; |
737 | 695 | ||
738 | private const string SQL_STATS_TABLE_INSERT = @"INSERT INTO stats_session_data ( | 696 | private const string SQL_STATS_TABLE_INSERT = @"INSERT OR REPLACE INTO stats_session_data ( |
739 | session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view, | 697 | session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view, |
740 | mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping, | 698 | mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping, |
741 | regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram, | 699 | regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram, |
742 | d_object_kb, d_texture_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_invalid, f_off_circuit, | 700 | d_object_kb, d_texture_kb, d_world_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_off_circuit, |
743 | f_resent, f_send_packet | 701 | f_resent, f_send_packet |
744 | ) | 702 | ) |
745 | VALUES | 703 | VALUES |
@@ -747,62 +705,13 @@ VALUES | |||
747 | :session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view, | 705 | :session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view, |
748 | :mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping, | 706 | :mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping, |
749 | :regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram, | 707 | :regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram, |
750 | :d_object_kb, :d_texture_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_invalid, :f_off_circuit, | 708 | :d_object_kb, :d_texture_kb, :d_world_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_off_circuit, |
751 | :f_resent, :f_send_packet | 709 | :f_resent, :f_send_packet |
752 | ) | 710 | ) |
753 | "; | 711 | "; |
754 | 712 | ||
755 | private const string SQL_STATS_TABLE_UPDATE = @" | 713 | #endregion |
756 | UPDATE stats_session_data | 714 | |
757 | set session_id=:session_id, | ||
758 | agent_id=:agent_id, | ||
759 | region_id=:region_id, | ||
760 | last_updated=:last_updated, | ||
761 | remote_ip=:remote_ip, | ||
762 | name_f=:name_f, | ||
763 | name_l=:name_l, | ||
764 | avg_agents_in_view=:avg_agents_in_view, | ||
765 | min_agents_in_view=:min_agents_in_view, | ||
766 | max_agents_in_view=:max_agents_in_view, | ||
767 | mode_agents_in_view=:mode_agents_in_view, | ||
768 | avg_fps=:avg_fps, | ||
769 | min_fps=:min_fps, | ||
770 | max_fps=:max_fps, | ||
771 | mode_fps=:mode_fps, | ||
772 | a_language=:a_language, | ||
773 | mem_use=:mem_use, | ||
774 | meters_traveled=:meters_traveled, | ||
775 | avg_ping=:avg_ping, | ||
776 | min_ping=:min_ping, | ||
777 | max_ping=:max_ping, | ||
778 | mode_ping=:mode_ping, | ||
779 | regions_visited=:regions_visited, | ||
780 | run_time=:run_time, | ||
781 | avg_sim_fps=:avg_sim_fps, | ||
782 | min_sim_fps=:min_sim_fps, | ||
783 | max_sim_fps=:max_sim_fps, | ||
784 | mode_sim_fps=:mode_sim_fps, | ||
785 | start_time=:start_time, | ||
786 | client_version=:client_version, | ||
787 | s_cpu=:s_cpu, | ||
788 | s_gpu=:s_gpu, | ||
789 | s_os=:s_os, | ||
790 | s_ram=:s_ram, | ||
791 | d_object_kb=:d_object_kb, | ||
792 | d_texture_kb=:d_texture_kb, | ||
793 | d_world_kb=:d_world_kb, | ||
794 | n_in_kb=:n_in_kb, | ||
795 | n_in_pk=:n_in_pk, | ||
796 | n_out_kb=:n_out_kb, | ||
797 | n_out_pk=:n_out_pk, | ||
798 | f_dropped=:f_dropped, | ||
799 | f_failed_resends=:f_failed_resends, | ||
800 | f_invalid=:f_invalid, | ||
801 | f_off_circuit=:f_off_circuit, | ||
802 | f_resent=:f_resent, | ||
803 | f_send_packet=:f_send_packet | ||
804 | WHERE session_id=:session_key AND agent_id=:agent_key AND region_id=:region_key"; | ||
805 | #endregion | ||
806 | } | 715 | } |
807 | 716 | ||
808 | public static class UserSessionUtil | 717 | public static class UserSessionUtil |
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 8effdd2..0cc2a4b 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -117,7 +117,10 @@ namespace OpenSim.Server.Base | |||
117 | catch (Exception e) | 117 | catch (Exception e) |
118 | { | 118 | { |
119 | if (!(e is System.MissingMethodException)) | 119 | if (!(e is System.MissingMethodException)) |
120 | m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); | 120 | { |
121 | m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}", | ||
122 | interfaceName, dllName, e.InnerException == null ? e.Message : e.InnerException.Message); | ||
123 | } | ||
121 | return null; | 124 | return null; |
122 | } | 125 | } |
123 | 126 | ||
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index 75dd711..4a61969 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | |||
@@ -33,17 +33,24 @@ using System.Xml; | |||
33 | 33 | ||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenMetaverse; | ||
36 | 37 | ||
38 | using OpenSim.Framework; | ||
37 | using OpenSim.Server.Base; | 39 | using OpenSim.Server.Base; |
38 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
39 | using OpenSim.Framework.Servers.HttpServer; | 41 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenSim.Server.Handlers.Base; | 42 | using OpenSim.Server.Handlers.Base; |
41 | 43 | ||
44 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
45 | |||
42 | namespace OpenSim.Server.Handlers.MapImage | 46 | namespace OpenSim.Server.Handlers.MapImage |
43 | { | 47 | { |
44 | public class MapAddServiceConnector : ServiceConnector | 48 | public class MapAddServiceConnector : ServiceConnector |
45 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
46 | private IMapImageService m_MapService; | 52 | private IMapImageService m_MapService; |
53 | private IGridService m_GridService; | ||
47 | private string m_ConfigName = "MapImageService"; | 54 | private string m_ConfigName = "MapImageService"; |
48 | 55 | ||
49 | public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) : | 56 | public MapAddServiceConnector(IConfigSource config, IHttpServer server, string configName) : |
@@ -53,16 +60,27 @@ namespace OpenSim.Server.Handlers.MapImage | |||
53 | if (serverConfig == null) | 60 | if (serverConfig == null) |
54 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); | 61 | throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); |
55 | 62 | ||
56 | string gridService = serverConfig.GetString("LocalServiceModule", | 63 | string mapService = serverConfig.GetString("LocalServiceModule", |
57 | String.Empty); | 64 | String.Empty); |
58 | 65 | ||
59 | if (gridService == String.Empty) | 66 | if (mapService == String.Empty) |
60 | throw new Exception("No LocalServiceModule in config file"); | 67 | throw new Exception("No LocalServiceModule in config file"); |
61 | 68 | ||
62 | Object[] args = new Object[] { config }; | 69 | Object[] args = new Object[] { config }; |
63 | m_MapService = ServerUtils.LoadPlugin<IMapImageService>(gridService, args); | 70 | m_MapService = ServerUtils.LoadPlugin<IMapImageService>(mapService, args); |
71 | |||
72 | string gridService = serverConfig.GetString("GridService", String.Empty); | ||
73 | if (gridService != string.Empty) | ||
74 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | ||
75 | |||
76 | if (m_GridService != null) | ||
77 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is ON"); | ||
78 | else | ||
79 | m_log.InfoFormat("[MAP IMAGE HANDLER]: GridService check is OFF"); | ||
80 | |||
81 | bool proxy = serverConfig.GetBoolean("HasProxy", false); | ||
82 | server.AddStreamHandler(new MapServerPostHandler(m_MapService, m_GridService, proxy)); | ||
64 | 83 | ||
65 | server.AddStreamHandler(new MapServerPostHandler(m_MapService)); | ||
66 | } | 84 | } |
67 | } | 85 | } |
68 | 86 | ||
@@ -70,11 +88,15 @@ namespace OpenSim.Server.Handlers.MapImage | |||
70 | { | 88 | { |
71 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 89 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
72 | private IMapImageService m_MapService; | 90 | private IMapImageService m_MapService; |
91 | private IGridService m_GridService; | ||
92 | bool m_Proxy; | ||
73 | 93 | ||
74 | public MapServerPostHandler(IMapImageService service) : | 94 | public MapServerPostHandler(IMapImageService service, IGridService grid, bool proxy) : |
75 | base("POST", "/map") | 95 | base("POST", "/map") |
76 | { | 96 | { |
77 | m_MapService = service; | 97 | m_MapService = service; |
98 | m_GridService = grid; | ||
99 | m_Proxy = proxy; | ||
78 | } | 100 | } |
79 | 101 | ||
80 | public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 102 | public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
@@ -105,6 +127,27 @@ namespace OpenSim.Server.Handlers.MapImage | |||
105 | // if (request.ContainsKey("TYPE")) | 127 | // if (request.ContainsKey("TYPE")) |
106 | // type = request["TYPE"].ToString(); | 128 | // type = request["TYPE"].ToString(); |
107 | 129 | ||
130 | if (m_GridService != null) | ||
131 | { | ||
132 | System.Net.IPAddress ipAddr = GetCallerIP(httpRequest); | ||
133 | GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize); | ||
134 | if (r != null) | ||
135 | { | ||
136 | if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString()) | ||
137 | { | ||
138 | m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be trying to impersonate region in IP {1}", ipAddr, r.ExternalEndPoint.Address); | ||
139 | return FailureResult("IP address of caller does not match IP address of registered region"); | ||
140 | } | ||
141 | |||
142 | } | ||
143 | else | ||
144 | { | ||
145 | m_log.WarnFormat("[MAP IMAGE HANDLER]: IP address {0} may be rogue. Region not found at coordinates {1}-{2}", | ||
146 | ipAddr, x, y); | ||
147 | return FailureResult("Region not found at given coordinates"); | ||
148 | } | ||
149 | } | ||
150 | |||
108 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); | 151 | byte[] data = Convert.FromBase64String(request["DATA"].ToString()); |
109 | 152 | ||
110 | string reason = string.Empty; | 153 | string reason = string.Empty; |
@@ -183,5 +226,31 @@ namespace OpenSim.Server.Handlers.MapImage | |||
183 | 226 | ||
184 | return ms.ToArray(); | 227 | return ms.ToArray(); |
185 | } | 228 | } |
229 | |||
230 | private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) | ||
231 | { | ||
232 | if (!m_Proxy) | ||
233 | return request.RemoteIPEndPoint.Address; | ||
234 | |||
235 | // We're behind a proxy | ||
236 | string xff = "X-Forwarded-For"; | ||
237 | string xffValue = request.Headers[xff.ToLower()]; | ||
238 | if (xffValue == null || (xffValue != null && xffValue == string.Empty)) | ||
239 | xffValue = request.Headers[xff]; | ||
240 | |||
241 | if (xffValue == null || (xffValue != null && xffValue == string.Empty)) | ||
242 | { | ||
243 | m_log.WarnFormat("[MAP IMAGE HANDLER]: No XFF header"); | ||
244 | return request.RemoteIPEndPoint.Address; | ||
245 | } | ||
246 | |||
247 | System.Net.IPEndPoint ep = Util.GetClientIPFromXFF(xffValue); | ||
248 | if (ep != null) | ||
249 | return ep.Address; | ||
250 | |||
251 | // Oops | ||
252 | return request.RemoteIPEndPoint.Address; | ||
253 | } | ||
254 | |||
186 | } | 255 | } |
187 | } | 256 | } |
diff --git a/OpenSim/Services/AvatarService/AvatarService.cs b/OpenSim/Services/AvatarService/AvatarService.cs index c59a9e0..423c781 100644 --- a/OpenSim/Services/AvatarService/AvatarService.cs +++ b/OpenSim/Services/AvatarService/AvatarService.cs | |||
@@ -93,7 +93,7 @@ namespace OpenSim.Services.AvatarService | |||
93 | if (kvp.Key.StartsWith("_")) | 93 | if (kvp.Key.StartsWith("_")) |
94 | count++; | 94 | count++; |
95 | 95 | ||
96 | m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count); | 96 | // m_log.DebugFormat("[AVATAR SERVICE]: SetAvatar for {0}, attachs={1}", principalID, count); |
97 | m_Database.Delete("PrincipalID", principalID.ToString()); | 97 | m_Database.Delete("PrincipalID", principalID.ToString()); |
98 | 98 | ||
99 | AvatarBaseData av = new AvatarBaseData(); | 99 | AvatarBaseData av = new AvatarBaseData(); |
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index 7deaf95..f982cc1 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -116,29 +116,36 @@ namespace OpenSim.Services.Connectors | |||
116 | } | 116 | } |
117 | else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure")) | 117 | else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure")) |
118 | { | 118 | { |
119 | m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString()); | 119 | m_log.ErrorFormat( |
120 | "[GRID CONNECTOR]: Registration failed: {0} when contacting {1}", replyData["Message"], uri); | ||
121 | |||
120 | return replyData["Message"].ToString(); | 122 | return replyData["Message"].ToString(); |
121 | } | 123 | } |
122 | else if (!replyData.ContainsKey("Result")) | 124 | else if (!replyData.ContainsKey("Result")) |
123 | { | 125 | { |
124 | m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field"); | 126 | m_log.ErrorFormat( |
127 | "[GRID CONNECTOR]: reply data does not contain result field when contacting {0}", uri); | ||
125 | } | 128 | } |
126 | else | 129 | else |
127 | { | 130 | { |
128 | m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); | 131 | m_log.ErrorFormat( |
129 | return "Unexpected result "+replyData["Result"].ToString(); | 132 | "[GRID CONNECTOR]: unexpected result {0} when contacting {1}", replyData["Result"], uri); |
133 | |||
134 | return "Unexpected result " + replyData["Result"].ToString(); | ||
130 | } | 135 | } |
131 | |||
132 | } | 136 | } |
133 | else | 137 | else |
134 | m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); | 138 | { |
139 | m_log.ErrorFormat( | ||
140 | "[GRID CONNECTOR]: RegisterRegion received null reply when contacting grid server at {0}", uri); | ||
141 | } | ||
135 | } | 142 | } |
136 | catch (Exception e) | 143 | catch (Exception e) |
137 | { | 144 | { |
138 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message); | 145 | m_log.ErrorFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message); |
139 | } | 146 | } |
140 | 147 | ||
141 | return "Error communicating with grid service"; | 148 | return string.Format("Error communicating with the grid service at {0}", uri); |
142 | } | 149 | } |
143 | 150 | ||
144 | public bool DeregisterRegion(UUID regionID) | 151 | public bool DeregisterRegion(UUID regionID) |
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index bc0bc54..4cd933c 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -154,17 +154,32 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
154 | 154 | ||
155 | UUID mapTile = m_HGMapImage; | 155 | UUID mapTile = m_HGMapImage; |
156 | string filename = string.Empty; | 156 | string filename = string.Empty; |
157 | Bitmap bitmap = null; | 157 | |
158 | try | 158 | try |
159 | { | 159 | { |
160 | WebClient c = new WebClient(); | 160 | WebClient c = new WebClient(); |
161 | //m_log.Debug("JPEG: " + imageURL); | 161 | //m_log.Debug("JPEG: " + imageURL); |
162 | string name = regionID.ToString(); | 162 | string name = regionID.ToString(); |
163 | filename = Path.Combine(storagePath, name + ".jpg"); | 163 | filename = Path.Combine(storagePath, name + ".jpg"); |
164 | c.DownloadFile(imageURL, filename); | 164 | m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename); |
165 | bitmap = new Bitmap(filename); | 165 | if (!File.Exists(filename)) |
166 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | 166 | { |
167 | byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); | 167 | m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading..."); |
168 | c.DownloadFile(imageURL, filename); | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: using cached image"); | ||
173 | } | ||
174 | |||
175 | byte[] imageData = null; | ||
176 | |||
177 | using (Bitmap bitmap = new Bitmap(filename)) | ||
178 | { | ||
179 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
180 | imageData = OpenJPEG.EncodeFromImage(bitmap, true); | ||
181 | } | ||
182 | |||
168 | AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); | 183 | AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); |
169 | 184 | ||
170 | // !!! for now | 185 | // !!! for now |
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index b6ec558..53fbea6 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs | |||
@@ -107,9 +107,8 @@ namespace OpenSim.Services.HypergridService | |||
107 | public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) | 107 | public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) |
108 | { | 108 | { |
109 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 109 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); |
110 | XInventoryFolder root = GetRootXFolder(principalID); | ||
111 | 110 | ||
112 | List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); | 111 | List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID); |
113 | if (tree == null || (tree != null && tree.Count == 0)) | 112 | if (tree == null || (tree != null && tree.Count == 0)) |
114 | return null; | 113 | return null; |
115 | 114 | ||
@@ -119,7 +118,7 @@ namespace OpenSim.Services.HypergridService | |||
119 | folders.Add(ConvertToOpenSim(x)); | 118 | folders.Add(ConvertToOpenSim(x)); |
120 | } | 119 | } |
121 | 120 | ||
122 | SetAsRootFolder(suitcase, root); | 121 | SetAsNormalFolder(suitcase); |
123 | folders.Add(ConvertToOpenSim(suitcase)); | 122 | folders.Add(ConvertToOpenSim(suitcase)); |
124 | 123 | ||
125 | return folders; | 124 | return folders; |
@@ -134,12 +133,11 @@ namespace OpenSim.Services.HypergridService | |||
134 | userInventory.Items = new List<InventoryItemBase>(); | 133 | userInventory.Items = new List<InventoryItemBase>(); |
135 | 134 | ||
136 | XInventoryFolder suitcase = GetSuitcaseXFolder(userID); | 135 | XInventoryFolder suitcase = GetSuitcaseXFolder(userID); |
137 | XInventoryFolder root = GetRootXFolder(userID); | ||
138 | 136 | ||
139 | List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); | 137 | List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID); |
140 | if (tree == null || (tree != null && tree.Count == 0)) | 138 | if (tree == null || (tree != null && tree.Count == 0)) |
141 | { | 139 | { |
142 | SetAsRootFolder(suitcase, root); | 140 | SetAsNormalFolder(suitcase); |
143 | userInventory.Folders.Add(ConvertToOpenSim(suitcase)); | 141 | userInventory.Folders.Add(ConvertToOpenSim(suitcase)); |
144 | return userInventory; | 142 | return userInventory; |
145 | } | 143 | } |
@@ -164,7 +162,7 @@ namespace OpenSim.Services.HypergridService | |||
164 | userInventory.Items.AddRange(items); | 162 | userInventory.Items.AddRange(items); |
165 | } | 163 | } |
166 | 164 | ||
167 | SetAsRootFolder(suitcase, root); | 165 | SetAsNormalFolder(suitcase); |
168 | userInventory.Folders.Add(ConvertToOpenSim(suitcase)); | 166 | userInventory.Folders.Add(ConvertToOpenSim(suitcase)); |
169 | 167 | ||
170 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items", | 168 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items", |
@@ -175,14 +173,13 @@ namespace OpenSim.Services.HypergridService | |||
175 | public override InventoryFolderBase GetRootFolder(UUID principalID) | 173 | public override InventoryFolderBase GetRootFolder(UUID principalID) |
176 | { | 174 | { |
177 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); | 175 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); |
178 | if (m_Database == null) | ||
179 | m_log.ErrorFormat("[XXX]: m_Database is NULL!"); | ||
180 | 176 | ||
181 | // Let's find out the local root folder | 177 | // Let's find out the local root folder |
182 | XInventoryFolder root = GetRootXFolder(principalID); ; | 178 | XInventoryFolder root = GetRootXFolder(principalID); ; |
183 | if (root == null) | 179 | if (root == null) |
184 | { | 180 | { |
185 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); | 181 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID); |
182 | return null; | ||
186 | } | 183 | } |
187 | 184 | ||
188 | // Warp! Root folder for travelers is the suitcase folder | 185 | // Warp! Root folder for travelers is the suitcase folder |
@@ -202,7 +199,7 @@ namespace OpenSim.Services.HypergridService | |||
202 | CreateSystemFolders(principalID, suitcase.folderID); | 199 | CreateSystemFolders(principalID, suitcase.folderID); |
203 | } | 200 | } |
204 | 201 | ||
205 | SetAsRootFolder(suitcase, root); | 202 | SetAsNormalFolder(suitcase); |
206 | 203 | ||
207 | return ConvertToOpenSim(suitcase); | 204 | return ConvertToOpenSim(suitcase); |
208 | } | 205 | } |
@@ -271,9 +268,8 @@ namespace OpenSim.Services.HypergridService | |||
271 | public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID) | 268 | public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID) |
272 | { | 269 | { |
273 | InventoryCollection coll = null; | 270 | InventoryCollection coll = null; |
274 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | ||
275 | 271 | ||
276 | if (!IsWithinSuitcaseTree(folderID, suitcase)) | 272 | if (!IsWithinSuitcaseTree(principalID, folderID)) |
277 | return new InventoryCollection(); | 273 | return new InventoryCollection(); |
278 | 274 | ||
279 | coll = base.GetFolderContent(principalID, folderID); | 275 | coll = base.GetFolderContent(principalID, folderID); |
@@ -290,9 +286,7 @@ namespace OpenSim.Services.HypergridService | |||
290 | { | 286 | { |
291 | // Let's do a bit of sanity checking, more than the base service does | 287 | // Let's do a bit of sanity checking, more than the base service does |
292 | // make sure the given folder exists under the suitcase tree of this user | 288 | // make sure the given folder exists under the suitcase tree of this user |
293 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | 289 | if (!IsWithinSuitcaseTree(principalID, folderID)) |
294 | |||
295 | if (!IsWithinSuitcaseTree(folderID, suitcase)) | ||
296 | return new List<InventoryItemBase>(); | 290 | return new List<InventoryItemBase>(); |
297 | 291 | ||
298 | return base.GetFolderItems(principalID, folderID); | 292 | return base.GetFolderItems(principalID, folderID); |
@@ -303,21 +297,27 @@ namespace OpenSim.Services.HypergridService | |||
303 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID); | 297 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID); |
304 | // Let's do a bit of sanity checking, more than the base service does | 298 | // Let's do a bit of sanity checking, more than the base service does |
305 | // make sure the given folder's parent folder exists under the suitcase tree of this user | 299 | // make sure the given folder's parent folder exists under the suitcase tree of this user |
306 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); | ||
307 | 300 | ||
308 | if (!IsWithinSuitcaseTree(folder.ParentID, suitcase)) | 301 | if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) |
309 | return false; | 302 | return false; |
310 | 303 | ||
311 | // OK, it's legit | 304 | // OK, it's legit |
312 | return base.AddFolder(folder); | 305 | if (base.AddFolder(folder)) |
306 | { | ||
307 | List<XInventoryFolder> tree; | ||
308 | if (m_SuitcaseTrees.TryGetValue(folder.Owner, out tree)) | ||
309 | tree.Add(ConvertFromOpenSim(folder)); | ||
310 | |||
311 | return true; | ||
312 | } | ||
313 | |||
314 | return false; | ||
313 | } | 315 | } |
314 | 316 | ||
315 | public override bool UpdateFolder(InventoryFolderBase folder) | 317 | public override bool UpdateFolder(InventoryFolderBase folder) |
316 | { | 318 | { |
317 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); | ||
318 | |||
319 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); | 319 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); |
320 | if (!IsWithinSuitcaseTree(folder.ID, suitcase)) | 320 | if (!IsWithinSuitcaseTree(folder.Owner, folder.ID)) |
321 | { | 321 | { |
322 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); | 322 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); |
323 | return false; | 323 | return false; |
@@ -329,9 +329,8 @@ namespace OpenSim.Services.HypergridService | |||
329 | 329 | ||
330 | public override bool MoveFolder(InventoryFolderBase folder) | 330 | public override bool MoveFolder(InventoryFolderBase folder) |
331 | { | 331 | { |
332 | XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); | 332 | if (!IsWithinSuitcaseTree(folder.Owner, folder.ID) || |
333 | 333 | !IsWithinSuitcaseTree(folder.Owner, folder.ParentID)) | |
334 | if (!IsWithinSuitcaseTree(folder.ID, suitcase) || !IsWithinSuitcaseTree(folder.ParentID, suitcase)) | ||
335 | return false; | 334 | return false; |
336 | 335 | ||
337 | return base.MoveFolder(folder); | 336 | return base.MoveFolder(folder); |
@@ -353,9 +352,7 @@ namespace OpenSim.Services.HypergridService | |||
353 | { | 352 | { |
354 | // Let's do a bit of sanity checking, more than the base service does | 353 | // Let's do a bit of sanity checking, more than the base service does |
355 | // make sure the given folder's parent folder exists under the suitcase tree of this user | 354 | // make sure the given folder's parent folder exists under the suitcase tree of this user |
356 | XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); | 355 | if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) |
357 | |||
358 | if (!IsWithinSuitcaseTree(item.Folder, suitcase)) | ||
359 | return false; | 356 | return false; |
360 | 357 | ||
361 | // OK, it's legit | 358 | // OK, it's legit |
@@ -365,9 +362,7 @@ namespace OpenSim.Services.HypergridService | |||
365 | 362 | ||
366 | public override bool UpdateItem(InventoryItemBase item) | 363 | public override bool UpdateItem(InventoryItemBase item) |
367 | { | 364 | { |
368 | XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); | 365 | if (!IsWithinSuitcaseTree(item.Owner, item.Folder)) |
369 | |||
370 | if (!IsWithinSuitcaseTree(item.Folder, suitcase)) | ||
371 | return false; | 366 | return false; |
372 | 367 | ||
373 | return base.UpdateItem(item); | 368 | return base.UpdateItem(item); |
@@ -377,9 +372,7 @@ namespace OpenSim.Services.HypergridService | |||
377 | { | 372 | { |
378 | // Principal is b0rked. *sigh* | 373 | // Principal is b0rked. *sigh* |
379 | 374 | ||
380 | XInventoryFolder suitcase = GetSuitcaseXFolder(items[0].Owner); | 375 | if (!IsWithinSuitcaseTree(items[0].Owner, items[0].Folder)) |
381 | |||
382 | if (!IsWithinSuitcaseTree(items[0].Folder, suitcase)) | ||
383 | return false; | 376 | return false; |
384 | 377 | ||
385 | return base.MoveItems(principalID, items); | 378 | return base.MoveItems(principalID, items); |
@@ -400,15 +393,8 @@ namespace OpenSim.Services.HypergridService | |||
400 | item.Name, item.ID, item.Folder); | 393 | item.Name, item.ID, item.Folder); |
401 | return null; | 394 | return null; |
402 | } | 395 | } |
403 | XInventoryFolder suitcase = GetSuitcaseXFolder(it.Owner); | ||
404 | if (suitcase == null) | ||
405 | { | ||
406 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Root or Suitcase are null for user {0}", | ||
407 | it.Owner); | ||
408 | return null; | ||
409 | } | ||
410 | 396 | ||
411 | if (!IsWithinSuitcaseTree(it.Folder, suitcase)) | 397 | if (!IsWithinSuitcaseTree(it.Owner, it.Folder)) |
412 | { | 398 | { |
413 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", | 399 | m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", |
414 | it.Name, it.Folder); | 400 | it.Name, it.Folder); |
@@ -431,9 +417,7 @@ namespace OpenSim.Services.HypergridService | |||
431 | 417 | ||
432 | if (f != null) | 418 | if (f != null) |
433 | { | 419 | { |
434 | XInventoryFolder suitcase = GetSuitcaseXFolder(f.Owner); | 420 | if (!IsWithinSuitcaseTree(f.Owner, f.ID)) |
435 | |||
436 | if (!IsWithinSuitcaseTree(f.ID, suitcase)) | ||
437 | return null; | 421 | return null; |
438 | } | 422 | } |
439 | 423 | ||
@@ -481,22 +465,37 @@ namespace OpenSim.Services.HypergridService | |||
481 | 465 | ||
482 | if (folders != null && folders.Length > 0) | 466 | if (folders != null && folders.Length > 0) |
483 | return folders[0]; | 467 | return folders[0]; |
468 | |||
469 | // check to see if we have the old Suitcase folder | ||
470 | folders = m_Database.GetFolders( | ||
471 | new string[] { "agentID", "folderName", "parentFolderID" }, | ||
472 | new string[] { principalID.ToString(), "My Suitcase", UUID.Zero.ToString() }); | ||
473 | if (folders != null && folders.Length > 0) | ||
474 | { | ||
475 | // Move it to under the root folder | ||
476 | XInventoryFolder root = GetRootXFolder(principalID); | ||
477 | folders[0].parentFolderID = root.folderID; | ||
478 | folders[0].type = 100; | ||
479 | m_Database.StoreFolder(folders[0]); | ||
480 | return folders[0]; | ||
481 | } | ||
482 | |||
484 | return null; | 483 | return null; |
485 | } | 484 | } |
486 | 485 | ||
487 | private void SetAsRootFolder(XInventoryFolder suitcase, XInventoryFolder root) | 486 | private void SetAsNormalFolder(XInventoryFolder suitcase) |
488 | { | 487 | { |
489 | suitcase.type = (short)AssetType.Folder; | 488 | suitcase.type = (short)AssetType.Folder; |
490 | } | 489 | } |
491 | 490 | ||
492 | private List<XInventoryFolder> GetFolderTree(UUID folder) | 491 | private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder) |
493 | { | 492 | { |
494 | List<XInventoryFolder> t = null; | 493 | List<XInventoryFolder> t = null; |
495 | if (m_SuitcaseTrees.TryGetValue(folder, out t)) | 494 | if (m_SuitcaseTrees.TryGetValue(principalID, out t)) |
496 | return t; | 495 | return t; |
497 | 496 | ||
498 | t = GetFolderTreeRecursive(folder); | 497 | t = GetFolderTreeRecursive(folder); |
499 | m_SuitcaseTrees.AddOrUpdate(folder, t, 120); | 498 | m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes |
500 | return t; | 499 | return t; |
501 | } | 500 | } |
502 | 501 | ||
@@ -528,11 +527,18 @@ namespace OpenSim.Services.HypergridService | |||
528 | /// <param name="root"></param> | 527 | /// <param name="root"></param> |
529 | /// <param name="suitcase"></param> | 528 | /// <param name="suitcase"></param> |
530 | /// <returns></returns> | 529 | /// <returns></returns> |
531 | private bool IsWithinSuitcaseTree(UUID folderID, XInventoryFolder suitcase) | 530 | private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID) |
532 | { | 531 | { |
532 | XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); | ||
533 | if (suitcase == null) | ||
534 | { | ||
535 | m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID); | ||
536 | return false; | ||
537 | } | ||
538 | |||
533 | List<XInventoryFolder> tree = new List<XInventoryFolder>(); | 539 | List<XInventoryFolder> tree = new List<XInventoryFolder>(); |
534 | tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder | 540 | tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder |
535 | tree.AddRange(GetFolderTree(suitcase.folderID)); | 541 | tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); |
536 | XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) | 542 | XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) |
537 | { | 543 | { |
538 | if (fl.folderID == folderID) return true; | 544 | if (fl.folderID == folderID) return true; |
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 079bcb1..2953cb5 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs | |||
@@ -355,7 +355,31 @@ namespace OpenSim.Services.LLLoginService | |||
355 | 355 | ||
356 | private void SetDefaultValues() | 356 | private void SetDefaultValues() |
357 | { | 357 | { |
358 | DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; | 358 | TimeZoneInfo gridTimeZone; |
359 | |||
360 | // Disabled for now pending making timezone a config value, which can at some point have a default of | ||
361 | // a ; separated list of possible timezones. | ||
362 | // The problem here is that US/Pacific (or even the Olsen America/Los_Angeles) is not universal across | ||
363 | // windows, mac and various distributions of linux, introducing another element of consistency. | ||
364 | // The server operator needs to be able to control this setting | ||
365 | // try | ||
366 | // { | ||
367 | // // First try to fetch DST from Pacific Standard Time, because this is | ||
368 | // // the one expected by the viewer. "US/Pacific" is the string to search | ||
369 | // // on linux and mac, and should work also on Windows (to confirm) | ||
370 | // gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific"); | ||
371 | // } | ||
372 | // catch (Exception e) | ||
373 | // { | ||
374 | // m_log.WarnFormat( | ||
375 | // "[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time", | ||
376 | // e.Message); | ||
377 | |||
378 | gridTimeZone = TimeZoneInfo.Local; | ||
379 | // } | ||
380 | |||
381 | DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; | ||
382 | |||
359 | StipendSinceLogin = "N"; | 383 | StipendSinceLogin = "N"; |
360 | Gendered = "Y"; | 384 | Gendered = "Y"; |
361 | EverLoggedIn = "Y"; | 385 | EverLoggedIn = "Y"; |
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 318758d..8e54707 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs | |||
@@ -58,57 +58,67 @@ namespace OpenSim.Tests.Common | |||
58 | /// </summary> | 58 | /// </summary> |
59 | public class SceneHelpers | 59 | public class SceneHelpers |
60 | { | 60 | { |
61 | public static TestScene SetupScene() | 61 | private AgentCircuitManager m_acm = new AgentCircuitManager(); |
62 | private ISimulationDataService m_simDataService | ||
63 | = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); | ||
64 | private IEstateDataService m_estateDataService; | ||
65 | |||
66 | private LocalAssetServicesConnector m_assetService; | ||
67 | private LocalAuthenticationServicesConnector m_authenticationService; | ||
68 | private LocalInventoryServicesConnector m_inventoryService; | ||
69 | private LocalGridServicesConnector m_gridService; | ||
70 | private LocalUserAccountServicesConnector m_userAccountService; | ||
71 | private LocalPresenceServicesConnector m_presenceService; | ||
72 | |||
73 | private CoreAssetCache m_cache; | ||
74 | |||
75 | public SceneHelpers() : this(null) {} | ||
76 | |||
77 | public SceneHelpers(CoreAssetCache cache) | ||
62 | { | 78 | { |
63 | return SetupScene(null); | 79 | m_assetService = StartAssetService(cache); |
80 | m_authenticationService = StartAuthenticationService(); | ||
81 | m_inventoryService = StartInventoryService(); | ||
82 | m_gridService = StartGridService(); | ||
83 | m_userAccountService = StartUserAccountService(); | ||
84 | m_presenceService = StartPresenceService(); | ||
85 | |||
86 | m_inventoryService.PostInitialise(); | ||
87 | m_assetService.PostInitialise(); | ||
88 | m_userAccountService.PostInitialise(); | ||
89 | m_presenceService.PostInitialise(); | ||
90 | |||
91 | m_cache = cache; | ||
64 | } | 92 | } |
65 | 93 | ||
66 | /// <summary> | 94 | /// <summary> |
67 | /// Set up a test scene | 95 | /// Set up a test scene |
68 | /// </summary> | 96 | /// </summary> |
69 | /// <remarks> | 97 | /// <remarks> |
70 | /// Automatically starts service threads, as would the normal runtime. | 98 | /// Automatically starts services, as would the normal runtime. |
71 | /// </remarks> | 99 | /// </remarks> |
72 | /// <returns></returns> | 100 | /// <returns></returns> |
73 | public static TestScene SetupScene(CoreAssetCache cache) | 101 | public TestScene SetupScene() |
74 | { | 102 | { |
75 | return SetupScene("Unit test region", UUID.Random(), 1000, 1000, cache); | 103 | return SetupScene("Unit test region", UUID.Random(), 1000, 1000); |
76 | } | 104 | } |
77 | 105 | ||
78 | public static TestScene SetupScene(string name, UUID id, uint x, uint y) | 106 | public TestScene SetupScene(string name, UUID id, uint x, uint y) |
79 | { | ||
80 | return SetupScene(name, id, x, y, null); | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions | ||
85 | /// or a different, to get a brand new scene with new shared region modules. | ||
86 | /// </summary> | ||
87 | /// <param name="name">Name of the region</param> | ||
88 | /// <param name="id">ID of the region</param> | ||
89 | /// <param name="x">X co-ordinate of the region</param> | ||
90 | /// <param name="y">Y co-ordinate of the region</param> | ||
91 | /// <param name="cache"></param> | ||
92 | /// <returns></returns> | ||
93 | public static TestScene SetupScene( | ||
94 | string name, UUID id, uint x, uint y, CoreAssetCache cache) | ||
95 | { | 107 | { |
96 | return SetupScene(name, id, x, y, cache, new IniConfigSource()); | 108 | return SetupScene(name, id, x, y, new IniConfigSource()); |
97 | } | 109 | } |
98 | 110 | ||
99 | /// <summary> | 111 | /// <summary> |
100 | /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions | 112 | /// Set up a scene. |
101 | /// or a different, to get a brand new scene with new shared region modules. | ||
102 | /// </summary> | 113 | /// </summary> |
103 | /// <param name="name">Name of the region</param> | 114 | /// <param name="name">Name of the region</param> |
104 | /// <param name="id">ID of the region</param> | 115 | /// <param name="id">ID of the region</param> |
105 | /// <param name="x">X co-ordinate of the region</param> | 116 | /// <param name="x">X co-ordinate of the region</param> |
106 | /// <param name="y">Y co-ordinate of the region</param> | 117 | /// <param name="y">Y co-ordinate of the region</param> |
107 | /// <param name="cache"></param> | ||
108 | /// <param name="configSource"></param> | 118 | /// <param name="configSource"></param> |
109 | /// <returns></returns> | 119 | /// <returns></returns> |
110 | public static TestScene SetupScene( | 120 | public TestScene SetupScene( |
111 | string name, UUID id, uint x, uint y, CoreAssetCache cache, IConfigSource configSource) | 121 | string name, UUID id, uint x, uint y, IConfigSource configSource) |
112 | { | 122 | { |
113 | Console.WriteLine("Setting up test scene {0}", name); | 123 | Console.WriteLine("Setting up test scene {0}", name); |
114 | 124 | ||
@@ -119,30 +129,47 @@ namespace OpenSim.Tests.Common | |||
119 | regInfo.RegionName = name; | 129 | regInfo.RegionName = name; |
120 | regInfo.RegionID = id; | 130 | regInfo.RegionID = id; |
121 | 131 | ||
122 | AgentCircuitManager acm = new AgentCircuitManager(); | ||
123 | SceneCommunicationService scs = new SceneCommunicationService(); | 132 | SceneCommunicationService scs = new SceneCommunicationService(); |
124 | 133 | ||
125 | ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); | ||
126 | IEstateDataService estateDataService = null; | ||
127 | |||
128 | TestScene testScene = new TestScene( | 134 | TestScene testScene = new TestScene( |
129 | regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null); | 135 | regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null); |
130 | 136 | ||
131 | IRegionModule godsModule = new GodsModule(); | 137 | IRegionModule godsModule = new GodsModule(); |
132 | godsModule.Initialise(testScene, new IniConfigSource()); | 138 | godsModule.Initialise(testScene, new IniConfigSource()); |
133 | testScene.AddModule(godsModule.Name, godsModule); | 139 | testScene.AddModule(godsModule.Name, godsModule); |
134 | 140 | ||
135 | LocalAssetServicesConnector assetService = StartAssetService(testScene, cache); | 141 | // Add scene to services |
136 | StartAuthenticationService(testScene); | 142 | m_assetService.AddRegion(testScene); |
137 | LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); | 143 | |
138 | StartGridService(testScene); | 144 | if (m_cache != null) |
139 | LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); | 145 | { |
140 | LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); | 146 | m_cache.AddRegion(testScene); |
141 | 147 | m_cache.RegionLoaded(testScene); | |
142 | inventoryService.PostInitialise(); | 148 | testScene.AddRegionModule(m_cache.Name, m_cache); |
143 | assetService.PostInitialise(); | 149 | } |
144 | userAccountService.PostInitialise(); | 150 | |
145 | presenceService.PostInitialise(); | 151 | m_assetService.RegionLoaded(testScene); |
152 | testScene.AddRegionModule(m_assetService.Name, m_assetService); | ||
153 | |||
154 | m_authenticationService.AddRegion(testScene); | ||
155 | m_authenticationService.RegionLoaded(testScene); | ||
156 | testScene.AddRegionModule(m_authenticationService.Name, m_authenticationService); | ||
157 | |||
158 | m_inventoryService.AddRegion(testScene); | ||
159 | m_inventoryService.RegionLoaded(testScene); | ||
160 | testScene.AddRegionModule(m_inventoryService.Name, m_inventoryService); | ||
161 | |||
162 | m_gridService.AddRegion(testScene); | ||
163 | m_gridService.RegionLoaded(testScene); | ||
164 | testScene.AddRegionModule(m_gridService.Name, m_gridService); | ||
165 | |||
166 | m_userAccountService.AddRegion(testScene); | ||
167 | m_userAccountService.RegionLoaded(testScene); | ||
168 | testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService); | ||
169 | |||
170 | m_presenceService.AddRegion(testScene); | ||
171 | m_presenceService.RegionLoaded(testScene); | ||
172 | testScene.AddRegionModule(m_presenceService.Name, m_presenceService); | ||
146 | 173 | ||
147 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); | 174 | testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); |
148 | testScene.SetModuleInterfaces(); | 175 | testScene.SetModuleInterfaces(); |
@@ -153,7 +180,7 @@ namespace OpenSim.Tests.Common | |||
153 | PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); | 180 | PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); |
154 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); | 181 | physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); |
155 | testScene.PhysicsScene | 182 | testScene.PhysicsScene |
156 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); | 183 | = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); |
157 | 184 | ||
158 | testScene.RegionInfo.EstateSettings = new EstateSettings(); | 185 | testScene.RegionInfo.EstateSettings = new EstateSettings(); |
159 | testScene.LoginsDisabled = false; | 186 | testScene.LoginsDisabled = false; |
@@ -162,19 +189,17 @@ namespace OpenSim.Tests.Common | |||
162 | return testScene; | 189 | return testScene; |
163 | } | 190 | } |
164 | 191 | ||
165 | private static LocalAssetServicesConnector StartAssetService(Scene testScene, CoreAssetCache cache) | 192 | private static LocalAssetServicesConnector StartAssetService(CoreAssetCache cache) |
166 | { | 193 | { |
167 | LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); | ||
168 | IConfigSource config = new IniConfigSource(); | 194 | IConfigSource config = new IniConfigSource(); |
169 | |||
170 | config.AddConfig("Modules"); | 195 | config.AddConfig("Modules"); |
171 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); | 196 | config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); |
172 | config.AddConfig("AssetService"); | 197 | config.AddConfig("AssetService"); |
173 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); | 198 | config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); |
174 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 199 | config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
175 | 200 | ||
201 | LocalAssetServicesConnector assetService = new LocalAssetServicesConnector(); | ||
176 | assetService.Initialise(config); | 202 | assetService.Initialise(config); |
177 | assetService.AddRegion(testScene); | ||
178 | 203 | ||
179 | if (cache != null) | 204 | if (cache != null) |
180 | { | 205 | { |
@@ -184,56 +209,43 @@ namespace OpenSim.Tests.Common | |||
184 | cacheConfig.AddConfig("AssetCache"); | 209 | cacheConfig.AddConfig("AssetCache"); |
185 | 210 | ||
186 | cache.Initialise(cacheConfig); | 211 | cache.Initialise(cacheConfig); |
187 | cache.AddRegion(testScene); | ||
188 | cache.RegionLoaded(testScene); | ||
189 | testScene.AddRegionModule(cache.Name, cache); | ||
190 | } | 212 | } |
191 | |||
192 | assetService.RegionLoaded(testScene); | ||
193 | testScene.AddRegionModule(assetService.Name, assetService); | ||
194 | 213 | ||
195 | return assetService; | 214 | return assetService; |
196 | } | 215 | } |
197 | 216 | ||
198 | private static void StartAuthenticationService(Scene testScene) | 217 | private static LocalAuthenticationServicesConnector StartAuthenticationService() |
199 | { | 218 | { |
200 | ISharedRegionModule service = new LocalAuthenticationServicesConnector(); | ||
201 | IConfigSource config = new IniConfigSource(); | 219 | IConfigSource config = new IniConfigSource(); |
202 | |||
203 | config.AddConfig("Modules"); | 220 | config.AddConfig("Modules"); |
204 | config.AddConfig("AuthenticationService"); | 221 | config.AddConfig("AuthenticationService"); |
205 | config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); | 222 | config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); |
206 | config.Configs["AuthenticationService"].Set( | 223 | config.Configs["AuthenticationService"].Set( |
207 | "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); | 224 | "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); |
208 | config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 225 | config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
209 | 226 | ||
227 | LocalAuthenticationServicesConnector service = new LocalAuthenticationServicesConnector(); | ||
210 | service.Initialise(config); | 228 | service.Initialise(config); |
211 | service.AddRegion(testScene); | 229 | |
212 | service.RegionLoaded(testScene); | 230 | return service; |
213 | testScene.AddRegionModule(service.Name, service); | ||
214 | //m_authenticationService = service; | ||
215 | } | 231 | } |
216 | 232 | ||
217 | private static LocalInventoryServicesConnector StartInventoryService(Scene testScene) | 233 | private static LocalInventoryServicesConnector StartInventoryService() |
218 | { | 234 | { |
219 | LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); | ||
220 | |||
221 | IConfigSource config = new IniConfigSource(); | 235 | IConfigSource config = new IniConfigSource(); |
222 | config.AddConfig("Modules"); | 236 | config.AddConfig("Modules"); |
223 | config.AddConfig("InventoryService"); | 237 | config.AddConfig("InventoryService"); |
224 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); | 238 | config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); |
225 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); | 239 | config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); |
226 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); | 240 | config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); |
227 | 241 | ||
242 | LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector(); | ||
228 | inventoryService.Initialise(config); | 243 | inventoryService.Initialise(config); |
229 | inventoryService.AddRegion(testScene); | ||
230 | inventoryService.RegionLoaded(testScene); | ||
231 | testScene.AddRegionModule(inventoryService.Name, inventoryService); | ||
232 | 244 | ||
233 | return inventoryService; | 245 | return inventoryService; |
234 | } | 246 | } |
235 | 247 | ||
236 | private static LocalGridServicesConnector StartGridService(Scene testScene) | 248 | private static LocalGridServicesConnector StartGridService() |
237 | { | 249 | { |
238 | IConfigSource config = new IniConfigSource(); | 250 | IConfigSource config = new IniConfigSource(); |
239 | config.AddConfig("Modules"); | 251 | config.AddConfig("Modules"); |
@@ -245,8 +257,6 @@ namespace OpenSim.Tests.Common | |||
245 | 257 | ||
246 | LocalGridServicesConnector gridService = new LocalGridServicesConnector(); | 258 | LocalGridServicesConnector gridService = new LocalGridServicesConnector(); |
247 | gridService.Initialise(config); | 259 | gridService.Initialise(config); |
248 | gridService.AddRegion(testScene); | ||
249 | gridService.RegionLoaded(testScene); | ||
250 | 260 | ||
251 | return gridService; | 261 | return gridService; |
252 | } | 262 | } |
@@ -256,7 +266,7 @@ namespace OpenSim.Tests.Common | |||
256 | /// </summary> | 266 | /// </summary> |
257 | /// <param name="testScene"></param> | 267 | /// <param name="testScene"></param> |
258 | /// <returns></returns> | 268 | /// <returns></returns> |
259 | private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) | 269 | private static LocalUserAccountServicesConnector StartUserAccountService() |
260 | { | 270 | { |
261 | IConfigSource config = new IniConfigSource(); | 271 | IConfigSource config = new IniConfigSource(); |
262 | config.AddConfig("Modules"); | 272 | config.AddConfig("Modules"); |
@@ -268,10 +278,6 @@ namespace OpenSim.Tests.Common | |||
268 | 278 | ||
269 | LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); | 279 | LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); |
270 | userAccountService.Initialise(config); | 280 | userAccountService.Initialise(config); |
271 | |||
272 | userAccountService.AddRegion(testScene); | ||
273 | userAccountService.RegionLoaded(testScene); | ||
274 | testScene.AddRegionModule(userAccountService.Name, userAccountService); | ||
275 | 281 | ||
276 | return userAccountService; | 282 | return userAccountService; |
277 | } | 283 | } |
@@ -280,7 +286,7 @@ namespace OpenSim.Tests.Common | |||
280 | /// Start a presence service | 286 | /// Start a presence service |
281 | /// </summary> | 287 | /// </summary> |
282 | /// <param name="testScene"></param> | 288 | /// <param name="testScene"></param> |
283 | private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) | 289 | private static LocalPresenceServicesConnector StartPresenceService() |
284 | { | 290 | { |
285 | IConfigSource config = new IniConfigSource(); | 291 | IConfigSource config = new IniConfigSource(); |
286 | config.AddConfig("Modules"); | 292 | config.AddConfig("Modules"); |
@@ -292,10 +298,6 @@ namespace OpenSim.Tests.Common | |||
292 | 298 | ||
293 | LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); | 299 | LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); |
294 | presenceService.Initialise(config); | 300 | presenceService.Initialise(config); |
295 | |||
296 | presenceService.AddRegion(testScene); | ||
297 | presenceService.RegionLoaded(testScene); | ||
298 | testScene.AddRegionModule(presenceService.Name, presenceService); | ||
299 | 301 | ||
300 | return presenceService; | 302 | return presenceService; |
301 | } | 303 | } |
@@ -313,19 +315,51 @@ namespace OpenSim.Tests.Common | |||
313 | /// <summary> | 315 | /// <summary> |
314 | /// Setup modules for a scene. | 316 | /// Setup modules for a scene. |
315 | /// </summary> | 317 | /// </summary> |
316 | /// <param name="scene"></param> | 318 | /// <remarks> |
319 | /// If called directly, then all the modules must be shared modules. | ||
320 | /// </remarks> | ||
321 | /// <param name="scenes"></param> | ||
317 | /// <param name="config"></param> | 322 | /// <param name="config"></param> |
318 | /// <param name="modules"></param> | 323 | /// <param name="modules"></param> |
319 | public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) | 324 | public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) |
320 | { | 325 | { |
326 | SetupSceneModules(new Scene[] { scene }, config, modules); | ||
327 | } | ||
328 | |||
329 | /// <summary> | ||
330 | /// Setup modules for a scene using their default settings. | ||
331 | /// </summary> | ||
332 | /// <param name="scenes"></param> | ||
333 | /// <param name="modules"></param> | ||
334 | public static void SetupSceneModules(Scene[] scenes, params object[] modules) | ||
335 | { | ||
336 | SetupSceneModules(scenes, new IniConfigSource(), modules); | ||
337 | } | ||
338 | |||
339 | /// <summary> | ||
340 | /// Setup modules for scenes. | ||
341 | /// </summary> | ||
342 | /// <remarks> | ||
343 | /// If called directly, then all the modules must be shared modules. | ||
344 | /// </remarks> | ||
345 | /// <param name="scenes"></param> | ||
346 | /// <param name="config"></param> | ||
347 | /// <param name="modules"></param> | ||
348 | public static void SetupSceneModules(Scene[] scenes, IConfigSource config, params object[] modules) | ||
349 | { | ||
321 | List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); | 350 | List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); |
322 | foreach (object module in modules) | 351 | foreach (object module in modules) |
323 | { | 352 | { |
324 | if (module is IRegionModule) | 353 | if (module is IRegionModule) |
325 | { | 354 | { |
326 | IRegionModule m = (IRegionModule)module; | 355 | IRegionModule m = (IRegionModule)module; |
327 | m.Initialise(scene, config); | 356 | |
328 | scene.AddModule(m.Name, m); | 357 | foreach (Scene scene in scenes) |
358 | { | ||
359 | m.Initialise(scene, config); | ||
360 | scene.AddModule(m.Name, m); | ||
361 | } | ||
362 | |||
329 | m.PostInitialise(); | 363 | m.PostInitialise(); |
330 | } | 364 | } |
331 | else if (module is IRegionModuleBase) | 365 | else if (module is IRegionModuleBase) |
@@ -345,15 +379,19 @@ namespace OpenSim.Tests.Common | |||
345 | 379 | ||
346 | foreach (IRegionModuleBase module in newModules) | 380 | foreach (IRegionModuleBase module in newModules) |
347 | { | 381 | { |
348 | module.AddRegion(scene); | 382 | foreach (Scene scene in scenes) |
349 | scene.AddRegionModule(module.Name, module); | 383 | { |
384 | module.AddRegion(scene); | ||
385 | scene.AddRegionModule(module.Name, module); | ||
386 | } | ||
350 | } | 387 | } |
351 | 388 | ||
352 | // RegionLoaded is fired after all modules have been appropriately added to all scenes | 389 | // RegionLoaded is fired after all modules have been appropriately added to all scenes |
353 | foreach (IRegionModuleBase module in newModules) | 390 | foreach (IRegionModuleBase module in newModules) |
354 | module.RegionLoaded(scene); | 391 | foreach (Scene scene in scenes) |
392 | module.RegionLoaded(scene); | ||
355 | 393 | ||
356 | scene.SetModuleInterfaces(); | 394 | foreach (Scene scene in scenes) { scene.SetModuleInterfaces(); } |
357 | } | 395 | } |
358 | 396 | ||
359 | /// <summary> | 397 | /// <summary> |
diff --git a/OpenSim/Tests/Common/Mock/TestLandChannel.cs b/OpenSim/Tests/Common/Mock/TestLandChannel.cs index 0e4dfb9..4b4d52d 100644 --- a/OpenSim/Tests/Common/Mock/TestLandChannel.cs +++ b/OpenSim/Tests/Common/Mock/TestLandChannel.cs | |||
@@ -46,6 +46,14 @@ namespace OpenSim.Tests.Common.Mock | |||
46 | { | 46 | { |
47 | m_scene = scene; | 47 | m_scene = scene; |
48 | m_parcels = new List<ILandObject>(); | 48 | m_parcels = new List<ILandObject>(); |
49 | SetupDefaultParcel(); | ||
50 | } | ||
51 | |||
52 | private void SetupDefaultParcel() | ||
53 | { | ||
54 | ILandObject obj = new LandObject(UUID.Zero, false, m_scene); | ||
55 | obj.LandData.Name = "Your Parcel"; | ||
56 | m_parcels.Add(obj); | ||
49 | } | 57 | } |
50 | 58 | ||
51 | public List<ILandObject> ParcelsNearPoint(Vector3 position) | 59 | public List<ILandObject> ParcelsNearPoint(Vector3 position) |
@@ -63,11 +71,7 @@ namespace OpenSim.Tests.Common.Mock | |||
63 | m_parcels.Clear(); | 71 | m_parcels.Clear(); |
64 | 72 | ||
65 | if (setupDefaultParcel) | 73 | if (setupDefaultParcel) |
66 | { | 74 | SetupDefaultParcel(); |
67 | ILandObject obj = new LandObject(UUID.Zero, false, m_scene); | ||
68 | obj.LandData.Name = "Your Parcel"; | ||
69 | m_parcels.Add(obj); | ||
70 | } | ||
71 | } | 75 | } |
72 | 76 | ||
73 | protected ILandObject GetNoLand() | 77 | protected ILandObject GetNoLand() |
@@ -102,6 +106,5 @@ namespace OpenSim.Tests.Common.Mock | |||
102 | 106 | ||
103 | public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} | 107 | public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} |
104 | public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} | 108 | public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id) {} |
105 | |||
106 | } | 109 | } |
107 | } | 110 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs index ced06de..5030d4b 100644 --- a/OpenSim/Tests/Common/TestHelpers.cs +++ b/OpenSim/Tests/Common/TestHelpers.cs | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Diagnostics; | 29 | using System.Diagnostics; |
30 | using System.IO; | ||
31 | using System.Text; | ||
30 | using NUnit.Framework; | 32 | using NUnit.Framework; |
31 | using OpenMetaverse; | 33 | using OpenMetaverse; |
32 | 34 | ||
@@ -34,6 +36,37 @@ namespace OpenSim.Tests.Common | |||
34 | { | 36 | { |
35 | public class TestHelpers | 37 | public class TestHelpers |
36 | { | 38 | { |
39 | private static Stream EnableLoggingConfigStream | ||
40 | = new MemoryStream( | ||
41 | Encoding.UTF8.GetBytes( | ||
42 | @"<log4net> | ||
43 | <!-- A1 is set to be a ConsoleAppender --> | ||
44 | <appender name=""A1"" type=""log4net.Appender.ConsoleAppender""> | ||
45 | |||
46 | <!-- A1 uses PatternLayout --> | ||
47 | <layout type=""log4net.Layout.PatternLayout""> | ||
48 | <!-- Print the date in ISO 8601 format --> | ||
49 | <conversionPattern value=""%date [%thread] %-5level %logger %ndc - %message%newline"" /> | ||
50 | </layout> | ||
51 | </appender> | ||
52 | |||
53 | <!-- Set root logger level to DEBUG and its only appender to A1 --> | ||
54 | <root> | ||
55 | <level value=""DEBUG"" /> | ||
56 | <appender-ref ref=""A1"" /> | ||
57 | </root> | ||
58 | </log4net>")); | ||
59 | |||
60 | private static Stream DisableLoggingConfigStream | ||
61 | = new MemoryStream( | ||
62 | Encoding.UTF8.GetBytes( | ||
63 | // "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>"))); | ||
64 | //"<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>"))); | ||
65 | //"<configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>"))); | ||
66 | //"<configuration><log4net><root></root></log4net></configuration>"))); | ||
67 | //"<configuration><log4net><root/></log4net></configuration>"))); | ||
68 | "<log4net><root/></log4net>")); | ||
69 | |||
37 | public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) | 70 | public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) |
38 | { | 71 | { |
39 | try | 72 | try |
@@ -58,6 +91,19 @@ namespace OpenSim.Tests.Common | |||
58 | Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); | 91 | Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); |
59 | } | 92 | } |
60 | 93 | ||
94 | public static void EnableLogging() | ||
95 | { | ||
96 | log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream); | ||
97 | } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Disable logging whilst running the tests. | ||
101 | /// </summary> | ||
102 | public static void DisableLogging() | ||
103 | { | ||
104 | log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream); | ||
105 | } | ||
106 | |||
61 | /// <summary> | 107 | /// <summary> |
62 | /// Parse tail section into full UUID. | 108 | /// Parse tail section into full UUID. |
63 | /// </summary> | 109 | /// </summary> |
diff --git a/OpenSim/Tests/Torture/NPCTortureTests.cs b/OpenSim/Tests/Torture/NPCTortureTests.cs index 0224505..731df68 100644 --- a/OpenSim/Tests/Torture/NPCTortureTests.cs +++ b/OpenSim/Tests/Torture/NPCTortureTests.cs | |||
@@ -98,7 +98,7 @@ namespace OpenSim.Tests.Torture | |||
98 | umm = new UserManagementModule(); | 98 | umm = new UserManagementModule(); |
99 | am = new AttachmentsModule(); | 99 | am = new AttachmentsModule(); |
100 | 100 | ||
101 | scene = SceneHelpers.SetupScene(); | 101 | scene = new SceneHelpers().SetupScene(); |
102 | SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule()); | 102 | SceneHelpers.SetupSceneModules(scene, config, afm, umm, am, new BasicInventoryAccessModule(), new NPCModule()); |
103 | } | 103 | } |
104 | 104 | ||
diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs index d0d2199..195d47b 100644 --- a/OpenSim/Tests/Torture/ObjectTortureTests.cs +++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs | |||
@@ -126,7 +126,7 @@ namespace OpenSim.Tests.Torture | |||
126 | // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage | 126 | // Using a local variable for scene, at least on mono 2.6.7, means that it's much more likely to be garbage |
127 | // collected when we teardown this test. If it's done in a member variable, even if that is subsequently | 127 | // collected when we teardown this test. If it's done in a member variable, even if that is subsequently |
128 | // nulled out, the garbage collect can be delayed. | 128 | // nulled out, the garbage collect can be delayed. |
129 | TestScene scene = SceneHelpers.SetupScene(); | 129 | TestScene scene = new SceneHelpers().SetupScene(); |
130 | 130 | ||
131 | // Process process = Process.GetCurrentProcess(); | 131 | // Process process = Process.GetCurrentProcess(); |
132 | // long startProcessMemory = process.PrivateMemorySize64; | 132 | // long startProcessMemory = process.PrivateMemorySize64; |
diff --git a/OpenSim/Tests/Torture/ScriptTortureTests.cs b/OpenSim/Tests/Torture/ScriptTortureTests.cs index 2ef55b3..24f278f 100644 --- a/OpenSim/Tests/Torture/ScriptTortureTests.cs +++ b/OpenSim/Tests/Torture/ScriptTortureTests.cs | |||
@@ -84,7 +84,7 @@ namespace OpenSim.Tests.Torture | |||
84 | // to AssemblyResolver.OnAssemblyResolve fails. | 84 | // to AssemblyResolver.OnAssemblyResolve fails. |
85 | xEngineConfig.Set("AppDomainLoading", "false"); | 85 | xEngineConfig.Set("AppDomainLoading", "false"); |
86 | 86 | ||
87 | m_scene = SceneHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, null, configSource); | 87 | m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); |
88 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); | 88 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); |
89 | 89 | ||
90 | m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 90 | m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; |