diff options
author | John Hurliman | 2009-10-05 17:38:27 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-05 17:38:27 -0700 |
commit | 7ddb6fbced5f2a98aa0201e354987ebc32adf7d2 (patch) | |
tree | 903b87112e7f851218e7b3d41c681f1b8f512af2 /OpenSim | |
parent | Beginning work on the new LLUDP implementation (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-7ddb6fbced5f2a98aa0201e354987ebc32adf7d2.zip opensim-SC-7ddb6fbced5f2a98aa0201e354987ebc32adf7d2.tar.gz opensim-SC-7ddb6fbced5f2a98aa0201e354987ebc32adf7d2.tar.bz2 opensim-SC-7ddb6fbced5f2a98aa0201e354987ebc32adf7d2.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim into htb-throttle
Diffstat (limited to 'OpenSim')
32 files changed, 2107 insertions, 1617 deletions
diff --git a/OpenSim/Client/Linden/LLProxyLoginModule.cs b/OpenSim/Client/Linden/LLProxyLoginModule.cs index 195feaf..f9cb3a9 100644 --- a/OpenSim/Client/Linden/LLProxyLoginModule.cs +++ b/OpenSim/Client/Linden/LLProxyLoginModule.cs | |||
@@ -148,8 +148,8 @@ namespace OpenSim.Client.Linden | |||
148 | protected void AddHttpHandlers() | 148 | protected void AddHttpHandlers() |
149 | { | 149 | { |
150 | //we will add our handlers to the first scene we received, as all scenes share a http server. But will this ever change? | 150 | //we will add our handlers to the first scene we received, as all scenes share a http server. But will this ever change? |
151 | MainServer.Instance.AddXmlRPCHandler("expect_user", ExpectUser); | 151 | MainServer.Instance.AddXmlRPCHandler("expect_user", ExpectUser, false); |
152 | MainServer.Instance.AddXmlRPCHandler("logoff_user", LogOffUser); | 152 | MainServer.Instance.AddXmlRPCHandler("logoff_user", LogOffUser, false); |
153 | } | 153 | } |
154 | 154 | ||
155 | protected void AddScene(Scene scene) | 155 | protected void AddScene(Scene scene) |
diff --git a/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs b/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs index 099faea..9a17e47 100644 --- a/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAuthenticationData.cs | |||
@@ -43,6 +43,7 @@ namespace OpenSim.Data.MSSQL | |||
43 | private List<string> m_ColumnNames = null; | 43 | private List<string> m_ColumnNames = null; |
44 | private int m_LastExpire = 0; | 44 | private int m_LastExpire = 0; |
45 | private string m_ConnectionString; | 45 | private string m_ConnectionString; |
46 | private MSSQLManager m_database; | ||
46 | 47 | ||
47 | public MSSQLAuthenticationData(string connectionString, string realm) | 48 | public MSSQLAuthenticationData(string connectionString, string realm) |
48 | { | 49 | { |
@@ -61,12 +62,12 @@ namespace OpenSim.Data.MSSQL | |||
61 | AuthenticationData ret = new AuthenticationData(); | 62 | AuthenticationData ret = new AuthenticationData(); |
62 | ret.Data = new Dictionary<string, object>(); | 63 | ret.Data = new Dictionary<string, object>(); |
63 | 64 | ||
64 | string sql = string.Format("select * from '{0}' where UUID = @principalID", m_Realm); | 65 | string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); |
65 | 66 | ||
66 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 67 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
67 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 68 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
68 | { | 69 | { |
69 | cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); | 70 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); |
70 | conn.Open(); | 71 | conn.Open(); |
71 | using (SqlDataReader result = cmd.ExecuteReader()) | 72 | using (SqlDataReader result = cmd.ExecuteReader()) |
72 | { | 73 | { |
@@ -108,34 +109,33 @@ namespace OpenSim.Data.MSSQL | |||
108 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 109 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
109 | using (SqlCommand cmd = new SqlCommand()) | 110 | using (SqlCommand cmd = new SqlCommand()) |
110 | { | 111 | { |
111 | updateBuilder.AppendFormat("update '{0}' set ", m_Realm); | 112 | updateBuilder.AppendFormat("update {0} set ", m_Realm); |
112 | 113 | ||
113 | bool first = true; | 114 | bool first = true; |
114 | foreach (string field in fields) | 115 | foreach (string field in fields) |
115 | { | 116 | { |
116 | if (!first) | 117 | if (!first) |
117 | updateBuilder.Append(", "); | 118 | updateBuilder.Append(", "); |
118 | updateBuilder.AppendFormat("'{0}' = @{0}",field); | 119 | updateBuilder.AppendFormat("{0} = @{0}",field); |
119 | 120 | ||
120 | first = false; | 121 | first = false; |
121 | 122 | cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field])); | |
122 | cmd.Parameters.AddWithValue("@" + field, data.Data[field]); | ||
123 | } | 123 | } |
124 | 124 | ||
125 | updateBuilder.Append(" where UUID = @principalID"); | 125 | updateBuilder.Append(" where UUID = @principalID"); |
126 | 126 | ||
127 | cmd.CommandText = updateBuilder.ToString(); | 127 | cmd.CommandText = updateBuilder.ToString(); |
128 | cmd.Connection = conn; | 128 | cmd.Connection = conn; |
129 | 129 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID)); | |
130 | cmd.Parameters.AddWithValue("@principalID", data.PrincipalID.ToString()); | 130 | |
131 | conn.Open(); | 131 | conn.Open(); |
132 | if (cmd.ExecuteNonQuery() < 1) | 132 | if (cmd.ExecuteNonQuery() < 1) |
133 | { | 133 | { |
134 | StringBuilder insertBuilder = new StringBuilder(); | 134 | StringBuilder insertBuilder = new StringBuilder(); |
135 | 135 | ||
136 | insertBuilder.AppendFormat("insert into '{0}' ('UUID', '", m_Realm); | 136 | insertBuilder.AppendFormat("insert into {0} (UUID, ", m_Realm); |
137 | insertBuilder.Append(String.Join("', '", fields)); | 137 | insertBuilder.Append(String.Join(", ", fields)); |
138 | insertBuilder.Append("') values (@principalID, @"); | 138 | insertBuilder.Append(") values ( @principalID, @"); |
139 | insertBuilder.Append(String.Join(", @", fields)); | 139 | insertBuilder.Append(String.Join(", @", fields)); |
140 | insertBuilder.Append(")"); | 140 | insertBuilder.Append(")"); |
141 | 141 | ||
@@ -152,12 +152,11 @@ namespace OpenSim.Data.MSSQL | |||
152 | 152 | ||
153 | public bool SetDataItem(UUID principalID, string item, string value) | 153 | public bool SetDataItem(UUID principalID, string item, string value) |
154 | { | 154 | { |
155 | string sql = string.Format("update '{0}' set '{1}' = @{1} where UUID = @UUID", m_Realm, item); | 155 | string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); |
156 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 156 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
157 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 157 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
158 | { | 158 | { |
159 | cmd.Parameters.AddWithValue("@" + item, value); | 159 | cmd.Parameters.Add(m_database.CreateParameter("@" + item, value)); |
160 | cmd.Parameters.AddWithValue("@UUID", principalID.ToString()); | ||
161 | conn.Open(); | 160 | conn.Open(); |
162 | if (cmd.ExecuteNonQuery() > 0) | 161 | if (cmd.ExecuteNonQuery() > 0) |
163 | return true; | 162 | return true; |
@@ -173,9 +172,9 @@ namespace OpenSim.Data.MSSQL | |||
173 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 172 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
174 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 173 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
175 | { | 174 | { |
176 | cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); | 175 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); |
177 | cmd.Parameters.AddWithValue("@token", token); | 176 | cmd.Parameters.Add(m_database.CreateParameter("@token", token)); |
178 | cmd.Parameters.AddWithValue("@lifetime", lifetime.ToString()); | 177 | cmd.Parameters.Add(m_database.CreateParameter("@lifetime", lifetime)); |
179 | conn.Open(); | 178 | conn.Open(); |
180 | 179 | ||
181 | if (cmd.ExecuteNonQuery() > 0) | 180 | if (cmd.ExecuteNonQuery() > 0) |
@@ -194,9 +193,9 @@ namespace OpenSim.Data.MSSQL | |||
194 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 193 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
195 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 194 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
196 | { | 195 | { |
197 | cmd.Parameters.AddWithValue("@principalID", principalID.ToString()); | 196 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); |
198 | cmd.Parameters.AddWithValue("@token", token); | 197 | cmd.Parameters.Add(m_database.CreateParameter("@token", token)); |
199 | cmd.Parameters.AddWithValue("@lifetime", lifetime.ToString()); | 198 | cmd.Parameters.Add(m_database.CreateParameter("@lifetime", lifetime)); |
200 | conn.Open(); | 199 | conn.Open(); |
201 | 200 | ||
202 | if (cmd.ExecuteNonQuery() > 0) | 201 | if (cmd.ExecuteNonQuery() > 0) |
diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs new file mode 100644 index 0000000..e2ae5cb --- /dev/null +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | |||
@@ -0,0 +1,1531 @@ | |||
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 System.Data; | ||
31 | using System.Data.SqlClient; | ||
32 | using System.Drawing; | ||
33 | using System.IO; | ||
34 | using System.Reflection; | ||
35 | using log4net; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | |||
41 | namespace OpenSim.Data.MSSQL | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// A MSSQL Interface for the Region Server. | ||
45 | /// </summary> | ||
46 | public class MSSQLRegionDataStore : IRegionDataStore | ||
47 | { | ||
48 | private const string _migrationStore = "RegionStore"; | ||
49 | |||
50 | // private static FileSystemDataStore Instance = new FileSystemDataStore(); | ||
51 | private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | /// <summary> | ||
54 | /// The database manager | ||
55 | /// </summary> | ||
56 | private MSSQLManager _Database; | ||
57 | |||
58 | /// <summary> | ||
59 | /// Initialises the region datastore | ||
60 | /// </summary> | ||
61 | /// <param name="connectionString">The connection string.</param> | ||
62 | public void Initialise(string connectionString) | ||
63 | { | ||
64 | if (!string.IsNullOrEmpty(connectionString)) | ||
65 | { | ||
66 | _Database = new MSSQLManager(connectionString); | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | IniFile iniFile = new IniFile("mssql_connection.ini"); | ||
71 | string settingDataSource = iniFile.ParseFileReadValue("data_source"); | ||
72 | string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog"); | ||
73 | string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info"); | ||
74 | string settingUserId = iniFile.ParseFileReadValue("user_id"); | ||
75 | string settingPassword = iniFile.ParseFileReadValue("password"); | ||
76 | |||
77 | _Database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); | ||
78 | } | ||
79 | |||
80 | //Migration settings | ||
81 | _Database.CheckMigration(_migrationStore); | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// Dispose the database | ||
86 | /// </summary> | ||
87 | public void Dispose() { } | ||
88 | |||
89 | #region SceneObjectGroup region for loading and Store of the scene. | ||
90 | |||
91 | /// <summary> | ||
92 | /// Loads the objects present in the region. | ||
93 | /// </summary> | ||
94 | /// <param name="regionUUID">The region UUID.</param> | ||
95 | /// <returns></returns> | ||
96 | public List<SceneObjectGroup> LoadObjects(UUID regionUUID) | ||
97 | { | ||
98 | UUID lastGroupID = UUID.Zero; | ||
99 | |||
100 | Dictionary<UUID, SceneObjectPart> prims = new Dictionary<UUID, SceneObjectPart>(); | ||
101 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); | ||
102 | SceneObjectGroup grp = null; | ||
103 | |||
104 | |||
105 | string query = "SELECT *, " + | ||
106 | "sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " + | ||
107 | "FROM prims " + | ||
108 | "LEFT JOIN primshapes ON prims.UUID = primshapes.UUID " + | ||
109 | "WHERE RegionUUID = @RegionUUID " + | ||
110 | "ORDER BY SceneGroupID asc, sort asc, LinkNumber asc"; | ||
111 | |||
112 | using (AutoClosingSqlCommand command = _Database.Query(query)) | ||
113 | { | ||
114 | command.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | ||
115 | |||
116 | using (SqlDataReader reader = command.ExecuteReader()) | ||
117 | { | ||
118 | while (reader.Read()) | ||
119 | { | ||
120 | SceneObjectPart sceneObjectPart = BuildPrim(reader); | ||
121 | if (reader["Shape"] is DBNull) | ||
122 | sceneObjectPart.Shape = PrimitiveBaseShape.Default; | ||
123 | else | ||
124 | sceneObjectPart.Shape = BuildShape(reader); | ||
125 | |||
126 | prims[sceneObjectPart.UUID] = sceneObjectPart; | ||
127 | |||
128 | UUID groupID = new UUID((Guid)reader["SceneGroupID"]); | ||
129 | |||
130 | if (groupID != lastGroupID) // New SOG | ||
131 | { | ||
132 | if (grp != null) | ||
133 | objects[grp.UUID] = grp; | ||
134 | |||
135 | lastGroupID = groupID; | ||
136 | |||
137 | // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are | ||
138 | // recorded as the root prim (for which the UUID must equal the persisted group UUID). In | ||
139 | // this case, force the UUID to be the same as the group UUID so that at least these can be | ||
140 | // deleted (we need to change the UUID so that any other prims in the linkset can also be | ||
141 | // deleted). | ||
142 | if (sceneObjectPart.UUID != groupID && groupID != UUID.Zero) | ||
143 | { | ||
144 | _Log.WarnFormat( | ||
145 | "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", | ||
146 | sceneObjectPart.Name, sceneObjectPart.UUID, sceneObjectPart.GroupPosition, groupID); | ||
147 | |||
148 | sceneObjectPart.UUID = groupID; | ||
149 | } | ||
150 | |||
151 | grp = new SceneObjectGroup(sceneObjectPart); | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | // Black magic to preserve link numbers | ||
156 | // Why is this needed, fix this in AddPart method. | ||
157 | int link = sceneObjectPart.LinkNum; | ||
158 | |||
159 | grp.AddPart(sceneObjectPart); | ||
160 | |||
161 | if (link != 0) | ||
162 | sceneObjectPart.LinkNum = link; | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | |||
168 | if (grp != null) | ||
169 | objects[grp.UUID] = grp; | ||
170 | |||
171 | // Instead of attempting to LoadItems on every prim, | ||
172 | // most of which probably have no items... get a | ||
173 | // list from DB of all prims which have items and | ||
174 | // LoadItems only on those | ||
175 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | ||
176 | string qry = "select distinct primID from primitems"; | ||
177 | using (AutoClosingSqlCommand command = _Database.Query(qry)) | ||
178 | { | ||
179 | using (SqlDataReader itemReader = command.ExecuteReader()) | ||
180 | { | ||
181 | while (itemReader.Read()) | ||
182 | { | ||
183 | if (!(itemReader["primID"] is DBNull)) | ||
184 | { | ||
185 | UUID primID = new UUID(itemReader["primID"].ToString()); | ||
186 | if (prims.ContainsKey(primID)) | ||
187 | { | ||
188 | primsWithInventory.Add(prims[primID]); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | LoadItems(primsWithInventory); | ||
196 | |||
197 | _Log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); | ||
198 | |||
199 | return new List<SceneObjectGroup>(objects.Values); | ||
200 | } | ||
201 | |||
202 | /// <summary> | ||
203 | /// Load in the prim's persisted inventory. | ||
204 | /// </summary> | ||
205 | /// <param name="allPrims">all prims with inventory on a region</param> | ||
206 | private void LoadItems(List<SceneObjectPart> allPrimsWithInventory) | ||
207 | { | ||
208 | |||
209 | using (AutoClosingSqlCommand command = _Database.Query("SELECT * FROM primitems WHERE PrimID = @PrimID")) | ||
210 | { | ||
211 | foreach (SceneObjectPart objectPart in allPrimsWithInventory) | ||
212 | { | ||
213 | command.Parameters.Clear(); | ||
214 | command.Parameters.Add(_Database.CreateParameter("@PrimID", objectPart.UUID)); | ||
215 | |||
216 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | ||
217 | |||
218 | using (SqlDataReader reader = command.ExecuteReader()) | ||
219 | { | ||
220 | while (reader.Read()) | ||
221 | { | ||
222 | TaskInventoryItem item = BuildItem(reader); | ||
223 | |||
224 | item.ParentID = objectPart.UUID; // Values in database are | ||
225 | // often wrong | ||
226 | inventory.Add(item); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | objectPart.Inventory.RestoreInventoryItems(inventory); | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | |||
235 | /// <summary> | ||
236 | /// Stores all object's details apart from inventory | ||
237 | /// </summary> | ||
238 | /// <param name="obj"></param> | ||
239 | /// <param name="regionUUID"></param> | ||
240 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) | ||
241 | { | ||
242 | _Log.InfoFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count); | ||
243 | |||
244 | using (SqlConnection conn = _Database.DatabaseConnection()) | ||
245 | { | ||
246 | SqlTransaction transaction = conn.BeginTransaction(); | ||
247 | |||
248 | try | ||
249 | { | ||
250 | foreach (SceneObjectPart sceneObjectPart in obj.Children.Values) | ||
251 | { | ||
252 | //Update prim | ||
253 | using (SqlCommand sqlCommand = conn.CreateCommand()) | ||
254 | { | ||
255 | sqlCommand.Transaction = transaction; | ||
256 | try | ||
257 | { | ||
258 | StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | ||
259 | } | ||
260 | catch (SqlException sqlEx) | ||
261 | { | ||
262 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | ||
263 | throw; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | //Update primshapes | ||
268 | using (SqlCommand sqlCommand = conn.CreateCommand()) | ||
269 | { | ||
270 | sqlCommand.Transaction = transaction; | ||
271 | try | ||
272 | { | ||
273 | StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | ||
274 | } | ||
275 | catch (SqlException sqlEx) | ||
276 | { | ||
277 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | ||
278 | throw; | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | |||
283 | transaction.Commit(); | ||
284 | } | ||
285 | catch (Exception ex) | ||
286 | { | ||
287 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message); | ||
288 | try | ||
289 | { | ||
290 | transaction.Rollback(); | ||
291 | } | ||
292 | catch (Exception ex2) | ||
293 | { | ||
294 | //Show error | ||
295 | _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message); | ||
296 | |||
297 | } | ||
298 | } | ||
299 | } | ||
300 | |||
301 | } | ||
302 | |||
303 | /// <summary> | ||
304 | /// Stores the prim of the sceneobjectpart. | ||
305 | /// </summary> | ||
306 | /// <param name="sceneObjectPart">The sceneobjectpart or prim.</param> | ||
307 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | ||
308 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | ||
309 | /// <param name="regionUUID">The region UUID.</param> | ||
310 | private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | ||
311 | { | ||
312 | //Big query to update or insert a new prim. | ||
313 | //Note for SQL Server 2008 this could be simplified | ||
314 | string queryPrims = @" | ||
315 | IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID) | ||
316 | BEGIN | ||
317 | UPDATE prims SET | ||
318 | CreationDate = @CreationDate, Name = @Name, Text = @Text, Description = @Description, SitName = @SitName, | ||
319 | TouchName = @TouchName, ObjectFlags = @ObjectFlags, OwnerMask = @OwnerMask, NextOwnerMask = @NextOwnerMask, GroupMask = @GroupMask, | ||
320 | EveryoneMask = @EveryoneMask, BaseMask = @BaseMask, PositionX = @PositionX, PositionY = @PositionY, PositionZ = @PositionZ, | ||
321 | GroupPositionX = @GroupPositionX, GroupPositionY = @GroupPositionY, GroupPositionZ = @GroupPositionZ, VelocityX = @VelocityX, | ||
322 | VelocityY = @VelocityY, VelocityZ = @VelocityZ, AngularVelocityX = @AngularVelocityX, AngularVelocityY = @AngularVelocityY, | ||
323 | AngularVelocityZ = @AngularVelocityZ, AccelerationX = @AccelerationX, AccelerationY = @AccelerationY, | ||
324 | AccelerationZ = @AccelerationZ, RotationX = @RotationX, RotationY = @RotationY, RotationZ = @RotationZ, RotationW = @RotationW, | ||
325 | SitTargetOffsetX = @SitTargetOffsetX, SitTargetOffsetY = @SitTargetOffsetY, SitTargetOffsetZ = @SitTargetOffsetZ, | ||
326 | SitTargetOrientW = @SitTargetOrientW, SitTargetOrientX = @SitTargetOrientX, SitTargetOrientY = @SitTargetOrientY, | ||
327 | SitTargetOrientZ = @SitTargetOrientZ, RegionUUID = @RegionUUID, CreatorID = @CreatorID, OwnerID = @OwnerID, GroupID = @GroupID, | ||
328 | LastOwnerID = @LastOwnerID, SceneGroupID = @SceneGroupID, PayPrice = @PayPrice, PayButton1 = @PayButton1, PayButton2 = @PayButton2, | ||
329 | PayButton3 = @PayButton3, PayButton4 = @PayButton4, LoopedSound = @LoopedSound, LoopedSoundGain = @LoopedSoundGain, | ||
330 | TextureAnimation = @TextureAnimation, OmegaX = @OmegaX, OmegaY = @OmegaY, OmegaZ = @OmegaZ, CameraEyeOffsetX = @CameraEyeOffsetX, | ||
331 | CameraEyeOffsetY = @CameraEyeOffsetY, CameraEyeOffsetZ = @CameraEyeOffsetZ, CameraAtOffsetX = @CameraAtOffsetX, | ||
332 | CameraAtOffsetY = @CameraAtOffsetY, CameraAtOffsetZ = @CameraAtOffsetZ, ForceMouselook = @ForceMouselook, | ||
333 | ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice, | ||
334 | SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem, | ||
335 | ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches, | ||
336 | LinkNumber = @LinkNumber | ||
337 | WHERE UUID = @UUID | ||
338 | END | ||
339 | ELSE | ||
340 | BEGIN | ||
341 | INSERT INTO | ||
342 | prims ( | ||
343 | UUID, CreationDate, Name, Text, Description, SitName, TouchName, ObjectFlags, OwnerMask, NextOwnerMask, GroupMask, | ||
344 | EveryoneMask, BaseMask, PositionX, PositionY, PositionZ, GroupPositionX, GroupPositionY, GroupPositionZ, VelocityX, | ||
345 | VelocityY, VelocityZ, AngularVelocityX, AngularVelocityY, AngularVelocityZ, AccelerationX, AccelerationY, AccelerationZ, | ||
346 | RotationX, RotationY, RotationZ, RotationW, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, | ||
347 | SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, RegionUUID, CreatorID, OwnerID, GroupID, LastOwnerID, SceneGroupID, | ||
348 | PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX, | ||
349 | OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, | ||
350 | ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, | ||
351 | ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber | ||
352 | ) VALUES ( | ||
353 | @UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask, | ||
354 | @EveryoneMask, @BaseMask, @PositionX, @PositionY, @PositionZ, @GroupPositionX, @GroupPositionY, @GroupPositionZ, @VelocityX, | ||
355 | @VelocityY, @VelocityZ, @AngularVelocityX, @AngularVelocityY, @AngularVelocityZ, @AccelerationX, @AccelerationY, @AccelerationZ, | ||
356 | @RotationX, @RotationY, @RotationZ, @RotationW, @SitTargetOffsetX, @SitTargetOffsetY, @SitTargetOffsetZ, @SitTargetOrientW, | ||
357 | @SitTargetOrientX, @SitTargetOrientY, @SitTargetOrientZ, @RegionUUID, @CreatorID, @OwnerID, @GroupID, @LastOwnerID, @SceneGroupID, | ||
358 | @PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX, | ||
359 | @OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ, | ||
360 | @ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA, | ||
361 | @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber | ||
362 | ) | ||
363 | END"; | ||
364 | |||
365 | //Set commandtext. | ||
366 | sqlCommand.CommandText = queryPrims; | ||
367 | //Add parameters | ||
368 | sqlCommand.Parameters.AddRange(CreatePrimParameters(sceneObjectPart, sceneGroupID, regionUUID)); | ||
369 | |||
370 | //Execute the query. If it fails then error is trapped in calling function | ||
371 | sqlCommand.ExecuteNonQuery(); | ||
372 | } | ||
373 | |||
374 | /// <summary> | ||
375 | /// Stores the scene object prim shapes. | ||
376 | /// </summary> | ||
377 | /// <param name="sceneObjectPart">The sceneobjectpart containing prim shape.</param> | ||
378 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | ||
379 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | ||
380 | /// <param name="regionUUID">The region UUID.</param> | ||
381 | private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | ||
382 | { | ||
383 | //Big query to or insert or update primshapes | ||
384 | //Note for SQL Server 2008 this can be simplified | ||
385 | string queryPrimShapes = @" | ||
386 | IF EXISTS (SELECT UUID FROM primshapes WHERE UUID = @UUID) | ||
387 | BEGIN | ||
388 | UPDATE primshapes SET | ||
389 | Shape = @Shape, ScaleX = @ScaleX, ScaleY = @ScaleY, ScaleZ = @ScaleZ, PCode = @PCode, PathBegin = @PathBegin, | ||
390 | PathEnd = @PathEnd, PathScaleX = @PathScaleX, PathScaleY = @PathScaleY, PathShearX = @PathShearX, PathShearY = @PathShearY, | ||
391 | PathSkew = @PathSkew, PathCurve = @PathCurve, PathRadiusOffset = @PathRadiusOffset, PathRevolutions = @PathRevolutions, | ||
392 | PathTaperX = @PathTaperX, PathTaperY = @PathTaperY, PathTwist = @PathTwist, PathTwistBegin = @PathTwistBegin, | ||
393 | ProfileBegin = @ProfileBegin, ProfileEnd = @ProfileEnd, ProfileCurve = @ProfileCurve, ProfileHollow = @ProfileHollow, | ||
394 | Texture = @Texture, ExtraParams = @ExtraParams, State = @State | ||
395 | WHERE UUID = @UUID | ||
396 | END | ||
397 | ELSE | ||
398 | BEGIN | ||
399 | INSERT INTO | ||
400 | primshapes ( | ||
401 | UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, | ||
402 | PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, | ||
403 | ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State | ||
404 | ) VALUES ( | ||
405 | @UUID, @Shape, @ScaleX, @ScaleY, @ScaleZ, @PCode, @PathBegin, @PathEnd, @PathScaleX, @PathScaleY, @PathShearX, @PathShearY, | ||
406 | @PathSkew, @PathCurve, @PathRadiusOffset, @PathRevolutions, @PathTaperX, @PathTaperY, @PathTwist, @PathTwistBegin, @ProfileBegin, | ||
407 | @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State | ||
408 | ) | ||
409 | END"; | ||
410 | |||
411 | //Set commandtext. | ||
412 | sqlCommand.CommandText = queryPrimShapes; | ||
413 | |||
414 | //Add parameters | ||
415 | sqlCommand.Parameters.AddRange(CreatePrimShapeParameters(sceneObjectPart, sceneGroupID, regionUUID)); | ||
416 | |||
417 | //Execute the query. If it fails then error is trapped in calling function | ||
418 | sqlCommand.ExecuteNonQuery(); | ||
419 | |||
420 | } | ||
421 | |||
422 | /// <summary> | ||
423 | /// Removes a object from the database. | ||
424 | /// Meaning removing it from tables Prims, PrimShapes and PrimItems | ||
425 | /// </summary> | ||
426 | /// <param name="objectID">id of scenegroup</param> | ||
427 | /// <param name="regionUUID">regionUUID (is this used anyway</param> | ||
428 | public void RemoveObject(UUID objectID, UUID regionUUID) | ||
429 | { | ||
430 | _Log.InfoFormat("[MSSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID); | ||
431 | |||
432 | //Remove from prims and primsitem table | ||
433 | string sqlPrims = "DELETE FROM PRIMS WHERE SceneGroupID = @objectID"; | ||
434 | string sqlPrimItems = "DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | ||
435 | string sqlPrimShapes = "DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | ||
436 | |||
437 | lock (_Database) | ||
438 | { | ||
439 | //Using the non transaction mode. | ||
440 | using (AutoClosingSqlCommand cmd = _Database.Query(sqlPrimShapes)) | ||
441 | { | ||
442 | cmd.Parameters.Add(_Database.CreateParameter("objectID", objectID)); | ||
443 | cmd.ExecuteNonQuery(); | ||
444 | |||
445 | cmd.CommandText = sqlPrimItems; | ||
446 | cmd.ExecuteNonQuery(); | ||
447 | |||
448 | cmd.CommandText = sqlPrims; | ||
449 | cmd.ExecuteNonQuery(); | ||
450 | } | ||
451 | } | ||
452 | } | ||
453 | |||
454 | /// <summary> | ||
455 | /// Store the inventory of a prim. Warning deletes everything first and then adds all again. | ||
456 | /// </summary> | ||
457 | /// <param name="primID"></param> | ||
458 | /// <param name="items"></param> | ||
459 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) | ||
460 | { | ||
461 | //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID); | ||
462 | |||
463 | //Statement from MySQL section! | ||
464 | // For now, we're just going to crudely remove all the previous inventory items | ||
465 | // no matter whether they have changed or not, and replace them with the current set. | ||
466 | |||
467 | //Delete everything from PrimID | ||
468 | //TODO add index on PrimID in DB, if not already exist | ||
469 | using (AutoClosingSqlCommand cmd = _Database.Query("DELETE PRIMITEMS WHERE primID = @primID")) | ||
470 | { | ||
471 | cmd.Parameters.Add(_Database.CreateParameter("@primID", primID)); | ||
472 | cmd.ExecuteNonQuery(); | ||
473 | } | ||
474 | |||
475 | string sql = | ||
476 | @"INSERT INTO primitems ( | ||
477 | itemID,primID,assetID,parentFolderID,invType,assetType,name,description,creationDate,creatorID,ownerID,lastOwnerID,groupID, | ||
478 | nextPermissions,currentPermissions,basePermissions,everyonePermissions,groupPermissions,flags) | ||
479 | VALUES (@itemID,@primID,@assetID,@parentFolderID,@invType,@assetType,@name,@description,@creationDate,@creatorID,@ownerID, | ||
480 | @lastOwnerID,@groupID,@nextPermissions,@currentPermissions,@basePermissions,@everyonePermissions,@groupPermissions,@flags)"; | ||
481 | |||
482 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
483 | { | ||
484 | foreach (TaskInventoryItem taskItem in items) | ||
485 | { | ||
486 | cmd.Parameters.AddRange(CreatePrimInventoryParameters(taskItem)); | ||
487 | cmd.ExecuteNonQuery(); | ||
488 | |||
489 | cmd.Parameters.Clear(); | ||
490 | } | ||
491 | } | ||
492 | } | ||
493 | |||
494 | #endregion | ||
495 | |||
496 | /// <summary> | ||
497 | /// Loads the terrain map. | ||
498 | /// </summary> | ||
499 | /// <param name="regionID">regionID.</param> | ||
500 | /// <returns></returns> | ||
501 | public double[,] LoadTerrain(UUID regionID) | ||
502 | { | ||
503 | double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | ||
504 | terrain.Initialize(); | ||
505 | |||
506 | string sql = "select top 1 RegionUUID, Revision, Heightfield from terrain where RegionUUID = @RegionUUID order by Revision desc"; | ||
507 | |||
508 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
509 | { | ||
510 | // MySqlParameter param = new MySqlParameter(); | ||
511 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
512 | |||
513 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
514 | { | ||
515 | int rev; | ||
516 | if (reader.Read()) | ||
517 | { | ||
518 | MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]); | ||
519 | BinaryReader br = new BinaryReader(str); | ||
520 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
521 | { | ||
522 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
523 | { | ||
524 | terrain[x, y] = br.ReadDouble(); | ||
525 | } | ||
526 | } | ||
527 | rev = (int)reader["Revision"]; | ||
528 | } | ||
529 | else | ||
530 | { | ||
531 | _Log.Info("[REGION DB]: No terrain found for region"); | ||
532 | return null; | ||
533 | } | ||
534 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); | ||
535 | } | ||
536 | } | ||
537 | |||
538 | return terrain; | ||
539 | } | ||
540 | |||
541 | /// <summary> | ||
542 | /// Stores the terrain map to DB. | ||
543 | /// </summary> | ||
544 | /// <param name="terrain">terrain map data.</param> | ||
545 | /// <param name="regionID">regionID.</param> | ||
546 | public void StoreTerrain(double[,] terrain, UUID regionID) | ||
547 | { | ||
548 | int revision = Util.UnixTimeSinceEpoch(); | ||
549 | |||
550 | //Delete old terrain map | ||
551 | string sql = "delete from terrain where RegionUUID=@RegionUUID"; | ||
552 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
553 | { | ||
554 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
555 | cmd.ExecuteNonQuery(); | ||
556 | } | ||
557 | |||
558 | sql = "insert into terrain(RegionUUID, Revision, Heightfield) values(@RegionUUID, @Revision, @Heightfield)"; | ||
559 | |||
560 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
561 | { | ||
562 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
563 | cmd.Parameters.Add(_Database.CreateParameter("@Revision", revision)); | ||
564 | cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", serializeTerrain(terrain))); | ||
565 | cmd.ExecuteNonQuery(); | ||
566 | } | ||
567 | |||
568 | _Log.Info("[REGION DB]: Stored terrain revision r " + revision); | ||
569 | } | ||
570 | |||
571 | /// <summary> | ||
572 | /// Loads all the land objects of a region. | ||
573 | /// </summary> | ||
574 | /// <param name="regionUUID">The region UUID.</param> | ||
575 | /// <returns></returns> | ||
576 | public List<LandData> LoadLandObjects(UUID regionUUID) | ||
577 | { | ||
578 | List<LandData> LandDataForRegion = new List<LandData>(); | ||
579 | |||
580 | string sql = "select * from land where RegionUUID = @RegionUUID"; | ||
581 | |||
582 | //Retrieve all land data from region | ||
583 | using (AutoClosingSqlCommand cmdLandData = _Database.Query(sql)) | ||
584 | { | ||
585 | cmdLandData.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionUUID)); | ||
586 | |||
587 | using (SqlDataReader readerLandData = cmdLandData.ExecuteReader()) | ||
588 | { | ||
589 | while (readerLandData.Read()) | ||
590 | { | ||
591 | LandDataForRegion.Add(BuildLandData(readerLandData)); | ||
592 | } | ||
593 | } | ||
594 | } | ||
595 | |||
596 | //Retrieve all accesslist data for all landdata | ||
597 | foreach (LandData LandData in LandDataForRegion) | ||
598 | { | ||
599 | sql = "select * from landaccesslist where LandUUID = @LandUUID"; | ||
600 | using (AutoClosingSqlCommand cmdAccessList = _Database.Query(sql)) | ||
601 | { | ||
602 | cmdAccessList.Parameters.Add(_Database.CreateParameter("@LandUUID", LandData.GlobalID)); | ||
603 | using (SqlDataReader readerAccessList = cmdAccessList.ExecuteReader()) | ||
604 | { | ||
605 | while (readerAccessList.Read()) | ||
606 | { | ||
607 | LandData.ParcelAccessList.Add(BuildLandAccessData(readerAccessList)); | ||
608 | } | ||
609 | } | ||
610 | } | ||
611 | } | ||
612 | |||
613 | //Return data | ||
614 | return LandDataForRegion; | ||
615 | } | ||
616 | |||
617 | /// <summary> | ||
618 | /// Stores land object with landaccess list. | ||
619 | /// </summary> | ||
620 | /// <param name="parcel">parcel data.</param> | ||
621 | public void StoreLandObject(ILandObject parcel) | ||
622 | { | ||
623 | //As this is only one record in land table I just delete all and then add a new record. | ||
624 | //As the delete landaccess is already in the mysql code | ||
625 | |||
626 | //Delete old values | ||
627 | RemoveLandObject(parcel.LandData.GlobalID); | ||
628 | |||
629 | //Insert new values | ||
630 | string sql = @"INSERT INTO [land] | ||
631 | ([UUID],[RegionUUID],[LocalLandID],[Bitmap],[Name],[Description],[OwnerUUID],[IsGroupOwned],[Area],[AuctionID],[Category],[ClaimDate],[ClaimPrice],[GroupUUID],[SalePrice],[LandStatus],[LandFlags],[LandingType],[MediaAutoScale],[MediaTextureUUID],[MediaURL],[MusicURL],[PassHours],[PassPrice],[SnapshotUUID],[UserLocationX],[UserLocationY],[UserLocationZ],[UserLookAtX],[UserLookAtY],[UserLookAtZ],[AuthbuyerID],[OtherCleanTime],[Dwell]) | ||
632 | VALUES | ||
633 | (@UUID,@RegionUUID,@LocalLandID,@Bitmap,@Name,@Description,@OwnerUUID,@IsGroupOwned,@Area,@AuctionID,@Category,@ClaimDate,@ClaimPrice,@GroupUUID,@SalePrice,@LandStatus,@LandFlags,@LandingType,@MediaAutoScale,@MediaTextureUUID,@MediaURL,@MusicURL,@PassHours,@PassPrice,@SnapshotUUID,@UserLocationX,@UserLocationY,@UserLocationZ,@UserLookAtX,@UserLookAtY,@UserLookAtZ,@AuthbuyerID,@OtherCleanTime,@Dwell)"; | ||
634 | |||
635 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
636 | { | ||
637 | cmd.Parameters.AddRange(CreateLandParameters(parcel.LandData, parcel.RegionUUID)); | ||
638 | |||
639 | cmd.ExecuteNonQuery(); | ||
640 | } | ||
641 | |||
642 | sql = "INSERT INTO [landaccesslist] ([LandUUID],[AccessUUID],[Flags]) VALUES (@LandUUID,@AccessUUID,@Flags)"; | ||
643 | |||
644 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
645 | { | ||
646 | foreach (ParcelManager.ParcelAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) | ||
647 | { | ||
648 | cmd.Parameters.AddRange(CreateLandAccessParameters(parcelAccessEntry, parcel.RegionUUID)); | ||
649 | |||
650 | cmd.ExecuteNonQuery(); | ||
651 | cmd.Parameters.Clear(); | ||
652 | } | ||
653 | } | ||
654 | } | ||
655 | |||
656 | /// <summary> | ||
657 | /// Removes a land object from DB. | ||
658 | /// </summary> | ||
659 | /// <param name="globalID">UUID of landobject</param> | ||
660 | public void RemoveLandObject(UUID globalID) | ||
661 | { | ||
662 | using (AutoClosingSqlCommand cmd = _Database.Query("delete from land where UUID=@UUID")) | ||
663 | { | ||
664 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | ||
665 | cmd.ExecuteNonQuery(); | ||
666 | } | ||
667 | |||
668 | using (AutoClosingSqlCommand cmd = _Database.Query("delete from landaccesslist where LandUUID=@UUID")) | ||
669 | { | ||
670 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | ||
671 | cmd.ExecuteNonQuery(); | ||
672 | } | ||
673 | } | ||
674 | |||
675 | /// <summary> | ||
676 | /// Loads the settings of a region. | ||
677 | /// </summary> | ||
678 | /// <param name="regionUUID">The region UUID.</param> | ||
679 | /// <returns></returns> | ||
680 | public RegionSettings LoadRegionSettings(UUID regionUUID) | ||
681 | { | ||
682 | string sql = "select * from regionsettings where regionUUID = @regionUUID"; | ||
683 | RegionSettings regionSettings; | ||
684 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
685 | { | ||
686 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | ||
687 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
688 | { | ||
689 | if (reader.Read()) | ||
690 | { | ||
691 | regionSettings = BuildRegionSettings(reader); | ||
692 | regionSettings.OnSave += StoreRegionSettings; | ||
693 | |||
694 | return regionSettings; | ||
695 | } | ||
696 | } | ||
697 | } | ||
698 | |||
699 | //If comes here then there is now region setting for that region | ||
700 | regionSettings = new RegionSettings(); | ||
701 | regionSettings.RegionUUID = regionUUID; | ||
702 | regionSettings.OnSave += StoreRegionSettings; | ||
703 | |||
704 | //Store new values | ||
705 | StoreNewRegionSettings(regionSettings); | ||
706 | |||
707 | return regionSettings; | ||
708 | } | ||
709 | |||
710 | /// <summary> | ||
711 | /// Store region settings, need to check if the check is really necesary. If we can make something for creating new region. | ||
712 | /// </summary> | ||
713 | /// <param name="regionSettings">region settings.</param> | ||
714 | public void StoreRegionSettings(RegionSettings regionSettings) | ||
715 | { | ||
716 | //Little check if regionUUID already exist in DB | ||
717 | string regionUUID; | ||
718 | using (AutoClosingSqlCommand cmd = _Database.Query("SELECT regionUUID FROM regionsettings WHERE regionUUID = @regionUUID")) | ||
719 | { | ||
720 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionSettings.RegionUUID)); | ||
721 | regionUUID = cmd.ExecuteScalar().ToString(); | ||
722 | } | ||
723 | |||
724 | if (string.IsNullOrEmpty(regionUUID)) | ||
725 | { | ||
726 | StoreNewRegionSettings(regionSettings); | ||
727 | } | ||
728 | else | ||
729 | { | ||
730 | //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB | ||
731 | string sql = | ||
732 | @"UPDATE [regionsettings] SET [block_terraform] = @block_terraform ,[block_fly] = @block_fly ,[allow_damage] = @allow_damage | ||
733 | ,[restrict_pushing] = @restrict_pushing ,[allow_land_resell] = @allow_land_resell ,[allow_land_join_divide] = @allow_land_join_divide | ||
734 | ,[block_show_in_search] = @block_show_in_search ,[agent_limit] = @agent_limit ,[object_bonus] = @object_bonus ,[maturity] = @maturity | ||
735 | ,[disable_scripts] = @disable_scripts ,[disable_collisions] = @disable_collisions ,[disable_physics] = @disable_physics | ||
736 | ,[terrain_texture_1] = @terrain_texture_1 ,[terrain_texture_2] = @terrain_texture_2 ,[terrain_texture_3] = @terrain_texture_3 | ||
737 | ,[terrain_texture_4] = @terrain_texture_4 ,[elevation_1_nw] = @elevation_1_nw ,[elevation_2_nw] = @elevation_2_nw | ||
738 | ,[elevation_1_ne] = @elevation_1_ne ,[elevation_2_ne] = @elevation_2_ne ,[elevation_1_se] = @elevation_1_se ,[elevation_2_se] = @elevation_2_se | ||
739 | ,[elevation_1_sw] = @elevation_1_sw ,[elevation_2_sw] = @elevation_2_sw ,[water_height] = @water_height ,[terrain_raise_limit] = @terrain_raise_limit | ||
740 | ,[terrain_lower_limit] = @terrain_lower_limit ,[use_estate_sun] = @use_estate_sun ,[fixed_sun] = @fixed_sun ,[sun_position] = @sun_position | ||
741 | ,[covenant] = @covenant , [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_datetime] = @loaded_creation_datetime, [loaded_creation_id] = @loaded_creation_id | ||
742 | WHERE [regionUUID] = @regionUUID"; | ||
743 | |||
744 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
745 | { | ||
746 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | ||
747 | |||
748 | cmd.ExecuteNonQuery(); | ||
749 | } | ||
750 | } | ||
751 | } | ||
752 | |||
753 | public void Shutdown() | ||
754 | { | ||
755 | //Not used?? | ||
756 | } | ||
757 | |||
758 | #region Private Methods | ||
759 | |||
760 | /// <summary> | ||
761 | /// Serializes the terrain data for storage in DB. | ||
762 | /// </summary> | ||
763 | /// <param name="val">terrain data</param> | ||
764 | /// <returns></returns> | ||
765 | private static Array serializeTerrain(double[,] val) | ||
766 | { | ||
767 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double)); | ||
768 | BinaryWriter bw = new BinaryWriter(str); | ||
769 | |||
770 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
771 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
772 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
773 | { | ||
774 | double height = val[x, y]; | ||
775 | if (height == 0.0) | ||
776 | height = double.Epsilon; | ||
777 | |||
778 | bw.Write(height); | ||
779 | } | ||
780 | |||
781 | return str.ToArray(); | ||
782 | } | ||
783 | |||
784 | /// <summary> | ||
785 | /// Stores new regionsettings. | ||
786 | /// </summary> | ||
787 | /// <param name="regionSettings">The region settings.</param> | ||
788 | private void StoreNewRegionSettings(RegionSettings regionSettings) | ||
789 | { | ||
790 | string sql = @"INSERT INTO [regionsettings] | ||
791 | ([regionUUID],[block_terraform],[block_fly],[allow_damage],[restrict_pushing],[allow_land_resell],[allow_land_join_divide], | ||
792 | [block_show_in_search],[agent_limit],[object_bonus],[maturity],[disable_scripts],[disable_collisions],[disable_physics], | ||
793 | [terrain_texture_1],[terrain_texture_2],[terrain_texture_3],[terrain_texture_4],[elevation_1_nw],[elevation_2_nw],[elevation_1_ne], | ||
794 | [elevation_2_ne],[elevation_1_se],[elevation_2_se],[elevation_1_sw],[elevation_2_sw],[water_height],[terrain_raise_limit], | ||
795 | [terrain_lower_limit],[use_estate_sun],[fixed_sun],[sun_position],[covenant],[sunvectorx], [sunvectory], [sunvectorz],[Sandbox], [loaded_creation_datetime], [loaded_creation_id] | ||
796 | ) | ||
797 | VALUES | ||
798 | (@regionUUID,@block_terraform,@block_fly,@allow_damage,@restrict_pushing,@allow_land_resell,@allow_land_join_divide, | ||
799 | @block_show_in_search,@agent_limit,@object_bonus,@maturity,@disable_scripts,@disable_collisions,@disable_physics, | ||
800 | @terrain_texture_1,@terrain_texture_2,@terrain_texture_3,@terrain_texture_4,@elevation_1_nw,@elevation_2_nw,@elevation_1_ne, | ||
801 | @elevation_2_ne,@elevation_1_se,@elevation_2_se,@elevation_1_sw,@elevation_2_sw,@water_height,@terrain_raise_limit, | ||
802 | @terrain_lower_limit,@use_estate_sun,@fixed_sun,@sun_position,@covenant,@sunvectorx,@sunvectory, @sunvectorz, @Sandbox, @loaded_creation_datetime, @loaded_creation_id)"; | ||
803 | |||
804 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
805 | { | ||
806 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | ||
807 | cmd.ExecuteNonQuery(); | ||
808 | } | ||
809 | } | ||
810 | |||
811 | #region Private DataRecord conversion methods | ||
812 | |||
813 | /// <summary> | ||
814 | /// Builds the region settings from a datarecod. | ||
815 | /// </summary> | ||
816 | /// <param name="row">datarecord with regionsettings.</param> | ||
817 | /// <returns></returns> | ||
818 | private static RegionSettings BuildRegionSettings(IDataRecord row) | ||
819 | { | ||
820 | //TODO change this is some more generic code so we doesnt have to change it every time a new field is added? | ||
821 | RegionSettings newSettings = new RegionSettings(); | ||
822 | |||
823 | newSettings.RegionUUID = new UUID((Guid)row["regionUUID"]); | ||
824 | newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); | ||
825 | newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); | ||
826 | newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); | ||
827 | newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); | ||
828 | newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); | ||
829 | newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); | ||
830 | newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); | ||
831 | newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); | ||
832 | newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); | ||
833 | newSettings.Maturity = Convert.ToInt32(row["maturity"]); | ||
834 | newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); | ||
835 | newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); | ||
836 | newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); | ||
837 | newSettings.TerrainTexture1 = new UUID((Guid)row["terrain_texture_1"]); | ||
838 | newSettings.TerrainTexture2 = new UUID((Guid)row["terrain_texture_2"]); | ||
839 | newSettings.TerrainTexture3 = new UUID((Guid)row["terrain_texture_3"]); | ||
840 | newSettings.TerrainTexture4 = new UUID((Guid)row["terrain_texture_4"]); | ||
841 | newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); | ||
842 | newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); | ||
843 | newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); | ||
844 | newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); | ||
845 | newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); | ||
846 | newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); | ||
847 | newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); | ||
848 | newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); | ||
849 | newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); | ||
850 | newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); | ||
851 | newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); | ||
852 | newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); | ||
853 | newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); | ||
854 | newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); | ||
855 | newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); | ||
856 | newSettings.SunVector = new Vector3( | ||
857 | Convert.ToSingle(row["sunvectorx"]), | ||
858 | Convert.ToSingle(row["sunvectory"]), | ||
859 | Convert.ToSingle(row["sunvectorz"]) | ||
860 | ); | ||
861 | newSettings.Covenant = new UUID((Guid)row["covenant"]); | ||
862 | |||
863 | newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); | ||
864 | |||
865 | if (row["loaded_creation_id"] is DBNull) | ||
866 | newSettings.LoadedCreationID = ""; | ||
867 | else | ||
868 | newSettings.LoadedCreationID = (String)row["loaded_creation_id"]; | ||
869 | return newSettings; | ||
870 | } | ||
871 | |||
872 | /// <summary> | ||
873 | /// Builds the land data from a datarecord. | ||
874 | /// </summary> | ||
875 | /// <param name="row">datarecord with land data</param> | ||
876 | /// <returns></returns> | ||
877 | private static LandData BuildLandData(IDataRecord row) | ||
878 | { | ||
879 | LandData newData = new LandData(); | ||
880 | |||
881 | newData.GlobalID = new UUID((Guid)row["UUID"]); | ||
882 | newData.LocalID = Convert.ToInt32(row["LocalLandID"]); | ||
883 | |||
884 | // Bitmap is a byte[512] | ||
885 | newData.Bitmap = (Byte[])row["Bitmap"]; | ||
886 | |||
887 | newData.Name = (string)row["Name"]; | ||
888 | newData.Description = (string)row["Description"]; | ||
889 | newData.OwnerID = new UUID((Guid)row["OwnerUUID"]); | ||
890 | newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); | ||
891 | newData.Area = Convert.ToInt32(row["Area"]); | ||
892 | newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented | ||
893 | newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]); | ||
894 | //Enum libsecondlife.Parcel.ParcelCategory | ||
895 | newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); | ||
896 | newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); | ||
897 | newData.GroupID = new UUID((Guid)row["GroupUUID"]); | ||
898 | newData.SalePrice = Convert.ToInt32(row["SalePrice"]); | ||
899 | newData.Status = (ParcelStatus)Convert.ToInt32(row["LandStatus"]); | ||
900 | //Enum. libsecondlife.Parcel.ParcelStatus | ||
901 | newData.Flags = Convert.ToUInt32(row["LandFlags"]); | ||
902 | newData.LandingType = Convert.ToByte(row["LandingType"]); | ||
903 | newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); | ||
904 | newData.MediaID = new UUID((Guid)row["MediaTextureUUID"]); | ||
905 | newData.MediaURL = (string)row["MediaURL"]; | ||
906 | newData.MusicURL = (string)row["MusicURL"]; | ||
907 | newData.PassHours = Convert.ToSingle(row["PassHours"]); | ||
908 | newData.PassPrice = Convert.ToInt32(row["PassPrice"]); | ||
909 | |||
910 | // UUID authedbuyer; | ||
911 | // UUID snapshotID; | ||
912 | // | ||
913 | // if (UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer)) | ||
914 | // newData.AuthBuyerID = authedbuyer; | ||
915 | // | ||
916 | // if (UUID.TryParse((string)row["SnapshotUUID"], out snapshotID)) | ||
917 | // newData.SnapshotID = snapshotID; | ||
918 | newData.AuthBuyerID = new UUID((Guid) row["AuthBuyerID"]); | ||
919 | newData.SnapshotID = new UUID((Guid)row["SnapshotUUID"]); | ||
920 | |||
921 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); | ||
922 | newData.Dwell = Convert.ToInt32(row["Dwell"]); | ||
923 | |||
924 | try | ||
925 | { | ||
926 | newData.UserLocation = | ||
927 | new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), | ||
928 | Convert.ToSingle(row["UserLocationZ"])); | ||
929 | newData.UserLookAt = | ||
930 | new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), | ||
931 | Convert.ToSingle(row["UserLookAtZ"])); | ||
932 | } | ||
933 | catch (InvalidCastException) | ||
934 | { | ||
935 | newData.UserLocation = Vector3.Zero; | ||
936 | newData.UserLookAt = Vector3.Zero; | ||
937 | _Log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); | ||
938 | } | ||
939 | |||
940 | newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); | ||
941 | |||
942 | return newData; | ||
943 | } | ||
944 | |||
945 | /// <summary> | ||
946 | /// Builds the landaccess data from a data record. | ||
947 | /// </summary> | ||
948 | /// <param name="row">datarecord with landaccess data</param> | ||
949 | /// <returns></returns> | ||
950 | private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataRecord row) | ||
951 | { | ||
952 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
953 | entry.AgentID = new UUID((Guid)row["AccessUUID"]); | ||
954 | entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]); | ||
955 | entry.Time = new DateTime(); | ||
956 | return entry; | ||
957 | } | ||
958 | |||
959 | /// <summary> | ||
960 | /// Builds the prim from a datarecord. | ||
961 | /// </summary> | ||
962 | /// <param name="primRow">datarecord</param> | ||
963 | /// <returns></returns> | ||
964 | private static SceneObjectPart BuildPrim(IDataRecord primRow) | ||
965 | { | ||
966 | SceneObjectPart prim = new SceneObjectPart(); | ||
967 | |||
968 | prim.UUID = new UUID((Guid)primRow["UUID"]); | ||
969 | // explicit conversion of integers is required, which sort | ||
970 | // of sucks. No idea if there is a shortcut here or not. | ||
971 | prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]); | ||
972 | prim.Name = (string)primRow["Name"]; | ||
973 | // various text fields | ||
974 | prim.Text = (string)primRow["Text"]; | ||
975 | prim.Color = Color.FromArgb(Convert.ToInt32(primRow["ColorA"]), | ||
976 | Convert.ToInt32(primRow["ColorR"]), | ||
977 | Convert.ToInt32(primRow["ColorG"]), | ||
978 | Convert.ToInt32(primRow["ColorB"])); | ||
979 | prim.Description = (string)primRow["Description"]; | ||
980 | prim.SitName = (string)primRow["SitName"]; | ||
981 | prim.TouchName = (string)primRow["TouchName"]; | ||
982 | // permissions | ||
983 | prim.ObjectFlags = Convert.ToUInt32(primRow["ObjectFlags"]); | ||
984 | prim.CreatorID = new UUID((Guid)primRow["CreatorID"]); | ||
985 | prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); | ||
986 | prim.GroupID = new UUID((Guid)primRow["GroupID"]); | ||
987 | prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); | ||
988 | prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]); | ||
989 | prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]); | ||
990 | prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]); | ||
991 | prim.EveryoneMask = Convert.ToUInt32(primRow["EveryoneMask"]); | ||
992 | prim.BaseMask = Convert.ToUInt32(primRow["BaseMask"]); | ||
993 | // vectors | ||
994 | prim.OffsetPosition = new Vector3( | ||
995 | Convert.ToSingle(primRow["PositionX"]), | ||
996 | Convert.ToSingle(primRow["PositionY"]), | ||
997 | Convert.ToSingle(primRow["PositionZ"])); | ||
998 | |||
999 | prim.GroupPosition = new Vector3( | ||
1000 | Convert.ToSingle(primRow["GroupPositionX"]), | ||
1001 | Convert.ToSingle(primRow["GroupPositionY"]), | ||
1002 | Convert.ToSingle(primRow["GroupPositionZ"])); | ||
1003 | |||
1004 | prim.Velocity = new Vector3( | ||
1005 | Convert.ToSingle(primRow["VelocityX"]), | ||
1006 | Convert.ToSingle(primRow["VelocityY"]), | ||
1007 | Convert.ToSingle(primRow["VelocityZ"])); | ||
1008 | |||
1009 | prim.AngularVelocity = new Vector3( | ||
1010 | Convert.ToSingle(primRow["AngularVelocityX"]), | ||
1011 | Convert.ToSingle(primRow["AngularVelocityY"]), | ||
1012 | Convert.ToSingle(primRow["AngularVelocityZ"])); | ||
1013 | |||
1014 | prim.Acceleration = new Vector3( | ||
1015 | Convert.ToSingle(primRow["AccelerationX"]), | ||
1016 | Convert.ToSingle(primRow["AccelerationY"]), | ||
1017 | Convert.ToSingle(primRow["AccelerationZ"])); | ||
1018 | |||
1019 | // quaternions | ||
1020 | prim.RotationOffset = new Quaternion( | ||
1021 | Convert.ToSingle(primRow["RotationX"]), | ||
1022 | Convert.ToSingle(primRow["RotationY"]), | ||
1023 | Convert.ToSingle(primRow["RotationZ"]), | ||
1024 | Convert.ToSingle(primRow["RotationW"])); | ||
1025 | |||
1026 | prim.SitTargetPositionLL = new Vector3( | ||
1027 | Convert.ToSingle(primRow["SitTargetOffsetX"]), | ||
1028 | Convert.ToSingle(primRow["SitTargetOffsetY"]), | ||
1029 | Convert.ToSingle(primRow["SitTargetOffsetZ"])); | ||
1030 | |||
1031 | prim.SitTargetOrientationLL = new Quaternion( | ||
1032 | Convert.ToSingle(primRow["SitTargetOrientX"]), | ||
1033 | Convert.ToSingle(primRow["SitTargetOrientY"]), | ||
1034 | Convert.ToSingle(primRow["SitTargetOrientZ"]), | ||
1035 | Convert.ToSingle(primRow["SitTargetOrientW"])); | ||
1036 | |||
1037 | prim.PayPrice[0] = Convert.ToInt32(primRow["PayPrice"]); | ||
1038 | prim.PayPrice[1] = Convert.ToInt32(primRow["PayButton1"]); | ||
1039 | prim.PayPrice[2] = Convert.ToInt32(primRow["PayButton2"]); | ||
1040 | prim.PayPrice[3] = Convert.ToInt32(primRow["PayButton3"]); | ||
1041 | prim.PayPrice[4] = Convert.ToInt32(primRow["PayButton4"]); | ||
1042 | |||
1043 | prim.Sound = new UUID((Guid)primRow["LoopedSound"]); | ||
1044 | prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]); | ||
1045 | prim.SoundFlags = 1; // If it's persisted at all, it's looped | ||
1046 | |||
1047 | if (!(primRow["TextureAnimation"] is DBNull)) | ||
1048 | prim.TextureAnimation = (Byte[])primRow["TextureAnimation"]; | ||
1049 | if (!(primRow["ParticleSystem"] is DBNull)) | ||
1050 | prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; | ||
1051 | |||
1052 | prim.RotationalVelocity = new Vector3( | ||
1053 | Convert.ToSingle(primRow["OmegaX"]), | ||
1054 | Convert.ToSingle(primRow["OmegaY"]), | ||
1055 | Convert.ToSingle(primRow["OmegaZ"])); | ||
1056 | |||
1057 | prim.SetCameraEyeOffset(new Vector3( | ||
1058 | Convert.ToSingle(primRow["CameraEyeOffsetX"]), | ||
1059 | Convert.ToSingle(primRow["CameraEyeOffsetY"]), | ||
1060 | Convert.ToSingle(primRow["CameraEyeOffsetZ"]) | ||
1061 | )); | ||
1062 | |||
1063 | prim.SetCameraAtOffset(new Vector3( | ||
1064 | Convert.ToSingle(primRow["CameraAtOffsetX"]), | ||
1065 | Convert.ToSingle(primRow["CameraAtOffsetY"]), | ||
1066 | Convert.ToSingle(primRow["CameraAtOffsetZ"]) | ||
1067 | )); | ||
1068 | |||
1069 | if (Convert.ToInt16(primRow["ForceMouselook"]) != 0) | ||
1070 | prim.SetForceMouselook(true); | ||
1071 | |||
1072 | prim.ScriptAccessPin = Convert.ToInt32(primRow["ScriptAccessPin"]); | ||
1073 | |||
1074 | if (Convert.ToInt16(primRow["AllowedDrop"]) != 0) | ||
1075 | prim.AllowedDrop = true; | ||
1076 | |||
1077 | if (Convert.ToInt16(primRow["DieAtEdge"]) != 0) | ||
1078 | prim.DIE_AT_EDGE = true; | ||
1079 | |||
1080 | prim.SalePrice = Convert.ToInt32(primRow["SalePrice"]); | ||
1081 | prim.ObjectSaleType = Convert.ToByte(primRow["SaleType"]); | ||
1082 | |||
1083 | prim.Material = Convert.ToByte(primRow["Material"]); | ||
1084 | |||
1085 | if (!(primRow["ClickAction"] is DBNull)) | ||
1086 | prim.ClickAction = Convert.ToByte(primRow["ClickAction"]); | ||
1087 | |||
1088 | prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]); | ||
1089 | prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); | ||
1090 | if (Convert.ToInt16(primRow["PassTouches"]) != 0) | ||
1091 | prim.PassTouches = true; | ||
1092 | prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]); | ||
1093 | |||
1094 | return prim; | ||
1095 | } | ||
1096 | |||
1097 | /// <summary> | ||
1098 | /// Builds the prim shape from a datarecord. | ||
1099 | /// </summary> | ||
1100 | /// <param name="shapeRow">The row.</param> | ||
1101 | /// <returns></returns> | ||
1102 | private static PrimitiveBaseShape BuildShape(IDataRecord shapeRow) | ||
1103 | { | ||
1104 | PrimitiveBaseShape baseShape = new PrimitiveBaseShape(); | ||
1105 | |||
1106 | baseShape.Scale = new Vector3( | ||
1107 | Convert.ToSingle(shapeRow["ScaleX"]), | ||
1108 | Convert.ToSingle(shapeRow["ScaleY"]), | ||
1109 | Convert.ToSingle(shapeRow["ScaleZ"])); | ||
1110 | |||
1111 | // paths | ||
1112 | baseShape.PCode = Convert.ToByte(shapeRow["PCode"]); | ||
1113 | baseShape.PathBegin = Convert.ToUInt16(shapeRow["PathBegin"]); | ||
1114 | baseShape.PathEnd = Convert.ToUInt16(shapeRow["PathEnd"]); | ||
1115 | baseShape.PathScaleX = Convert.ToByte(shapeRow["PathScaleX"]); | ||
1116 | baseShape.PathScaleY = Convert.ToByte(shapeRow["PathScaleY"]); | ||
1117 | baseShape.PathShearX = Convert.ToByte(shapeRow["PathShearX"]); | ||
1118 | baseShape.PathShearY = Convert.ToByte(shapeRow["PathShearY"]); | ||
1119 | baseShape.PathSkew = Convert.ToSByte(shapeRow["PathSkew"]); | ||
1120 | baseShape.PathCurve = Convert.ToByte(shapeRow["PathCurve"]); | ||
1121 | baseShape.PathRadiusOffset = Convert.ToSByte(shapeRow["PathRadiusOffset"]); | ||
1122 | baseShape.PathRevolutions = Convert.ToByte(shapeRow["PathRevolutions"]); | ||
1123 | baseShape.PathTaperX = Convert.ToSByte(shapeRow["PathTaperX"]); | ||
1124 | baseShape.PathTaperY = Convert.ToSByte(shapeRow["PathTaperY"]); | ||
1125 | baseShape.PathTwist = Convert.ToSByte(shapeRow["PathTwist"]); | ||
1126 | baseShape.PathTwistBegin = Convert.ToSByte(shapeRow["PathTwistBegin"]); | ||
1127 | // profile | ||
1128 | baseShape.ProfileBegin = Convert.ToUInt16(shapeRow["ProfileBegin"]); | ||
1129 | baseShape.ProfileEnd = Convert.ToUInt16(shapeRow["ProfileEnd"]); | ||
1130 | baseShape.ProfileCurve = Convert.ToByte(shapeRow["ProfileCurve"]); | ||
1131 | baseShape.ProfileHollow = Convert.ToUInt16(shapeRow["ProfileHollow"]); | ||
1132 | |||
1133 | byte[] textureEntry = (byte[])shapeRow["Texture"]; | ||
1134 | baseShape.TextureEntry = textureEntry; | ||
1135 | |||
1136 | baseShape.ExtraParams = (byte[])shapeRow["ExtraParams"]; | ||
1137 | |||
1138 | try | ||
1139 | { | ||
1140 | baseShape.State = Convert.ToByte(shapeRow["State"]); | ||
1141 | } | ||
1142 | catch (InvalidCastException) | ||
1143 | { | ||
1144 | } | ||
1145 | |||
1146 | return baseShape; | ||
1147 | } | ||
1148 | |||
1149 | /// <summary> | ||
1150 | /// Build a prim inventory item from the persisted data. | ||
1151 | /// </summary> | ||
1152 | /// <param name="inventoryRow"></param> | ||
1153 | /// <returns></returns> | ||
1154 | private static TaskInventoryItem BuildItem(IDataRecord inventoryRow) | ||
1155 | { | ||
1156 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
1157 | |||
1158 | taskItem.ItemID = new UUID((Guid)inventoryRow["itemID"]); | ||
1159 | taskItem.ParentPartID = new UUID((Guid)inventoryRow["primID"]); | ||
1160 | taskItem.AssetID = new UUID((Guid)inventoryRow["assetID"]); | ||
1161 | taskItem.ParentID = new UUID((Guid)inventoryRow["parentFolderID"]); | ||
1162 | |||
1163 | taskItem.InvType = Convert.ToInt32(inventoryRow["invType"]); | ||
1164 | taskItem.Type = Convert.ToInt32(inventoryRow["assetType"]); | ||
1165 | |||
1166 | taskItem.Name = (string)inventoryRow["name"]; | ||
1167 | taskItem.Description = (string)inventoryRow["description"]; | ||
1168 | taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); | ||
1169 | taskItem.CreatorID = new UUID((Guid)inventoryRow["creatorID"]); | ||
1170 | taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]); | ||
1171 | taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]); | ||
1172 | taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]); | ||
1173 | |||
1174 | taskItem.NextPermissions = Convert.ToUInt32(inventoryRow["nextPermissions"]); | ||
1175 | taskItem.CurrentPermissions = Convert.ToUInt32(inventoryRow["currentPermissions"]); | ||
1176 | taskItem.BasePermissions = Convert.ToUInt32(inventoryRow["basePermissions"]); | ||
1177 | taskItem.EveryonePermissions = Convert.ToUInt32(inventoryRow["everyonePermissions"]); | ||
1178 | taskItem.GroupPermissions = Convert.ToUInt32(inventoryRow["groupPermissions"]); | ||
1179 | taskItem.Flags = Convert.ToUInt32(inventoryRow["flags"]); | ||
1180 | |||
1181 | return taskItem; | ||
1182 | } | ||
1183 | |||
1184 | #endregion | ||
1185 | |||
1186 | #region Create parameters methods | ||
1187 | |||
1188 | /// <summary> | ||
1189 | /// Creates the prim inventory parameters. | ||
1190 | /// </summary> | ||
1191 | /// <param name="taskItem">item in inventory.</param> | ||
1192 | /// <returns></returns> | ||
1193 | private SqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem) | ||
1194 | { | ||
1195 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1196 | |||
1197 | parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID)); | ||
1198 | parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID)); | ||
1199 | parameters.Add(_Database.CreateParameter("assetID", taskItem.AssetID)); | ||
1200 | parameters.Add(_Database.CreateParameter("parentFolderID", taskItem.ParentID)); | ||
1201 | parameters.Add(_Database.CreateParameter("invType", taskItem.InvType)); | ||
1202 | parameters.Add(_Database.CreateParameter("assetType", taskItem.Type)); | ||
1203 | |||
1204 | parameters.Add(_Database.CreateParameter("name", taskItem.Name)); | ||
1205 | parameters.Add(_Database.CreateParameter("description", taskItem.Description)); | ||
1206 | parameters.Add(_Database.CreateParameter("creationDate", taskItem.CreationDate)); | ||
1207 | parameters.Add(_Database.CreateParameter("creatorID", taskItem.CreatorID)); | ||
1208 | parameters.Add(_Database.CreateParameter("ownerID", taskItem.OwnerID)); | ||
1209 | parameters.Add(_Database.CreateParameter("lastOwnerID", taskItem.LastOwnerID)); | ||
1210 | parameters.Add(_Database.CreateParameter("groupID", taskItem.GroupID)); | ||
1211 | parameters.Add(_Database.CreateParameter("nextPermissions", taskItem.NextPermissions)); | ||
1212 | parameters.Add(_Database.CreateParameter("currentPermissions", taskItem.CurrentPermissions)); | ||
1213 | parameters.Add(_Database.CreateParameter("basePermissions", taskItem.BasePermissions)); | ||
1214 | parameters.Add(_Database.CreateParameter("everyonePermissions", taskItem.EveryonePermissions)); | ||
1215 | parameters.Add(_Database.CreateParameter("groupPermissions", taskItem.GroupPermissions)); | ||
1216 | parameters.Add(_Database.CreateParameter("flags", taskItem.Flags)); | ||
1217 | |||
1218 | return parameters.ToArray(); | ||
1219 | } | ||
1220 | |||
1221 | /// <summary> | ||
1222 | /// Creates the region setting parameters. | ||
1223 | /// </summary> | ||
1224 | /// <param name="settings">regionsettings.</param> | ||
1225 | /// <returns></returns> | ||
1226 | private SqlParameter[] CreateRegionSettingParameters(RegionSettings settings) | ||
1227 | { | ||
1228 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1229 | |||
1230 | parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID)); | ||
1231 | parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform)); | ||
1232 | parameters.Add(_Database.CreateParameter("block_fly", settings.BlockFly)); | ||
1233 | parameters.Add(_Database.CreateParameter("allow_damage", settings.AllowDamage)); | ||
1234 | parameters.Add(_Database.CreateParameter("restrict_pushing", settings.RestrictPushing)); | ||
1235 | parameters.Add(_Database.CreateParameter("allow_land_resell", settings.AllowLandResell)); | ||
1236 | parameters.Add(_Database.CreateParameter("allow_land_join_divide", settings.AllowLandJoinDivide)); | ||
1237 | parameters.Add(_Database.CreateParameter("block_show_in_search", settings.BlockShowInSearch)); | ||
1238 | parameters.Add(_Database.CreateParameter("agent_limit", settings.AgentLimit)); | ||
1239 | parameters.Add(_Database.CreateParameter("object_bonus", settings.ObjectBonus)); | ||
1240 | parameters.Add(_Database.CreateParameter("maturity", settings.Maturity)); | ||
1241 | parameters.Add(_Database.CreateParameter("disable_scripts", settings.DisableScripts)); | ||
1242 | parameters.Add(_Database.CreateParameter("disable_collisions", settings.DisableCollisions)); | ||
1243 | parameters.Add(_Database.CreateParameter("disable_physics", settings.DisablePhysics)); | ||
1244 | parameters.Add(_Database.CreateParameter("terrain_texture_1", settings.TerrainTexture1)); | ||
1245 | parameters.Add(_Database.CreateParameter("terrain_texture_2", settings.TerrainTexture2)); | ||
1246 | parameters.Add(_Database.CreateParameter("terrain_texture_3", settings.TerrainTexture3)); | ||
1247 | parameters.Add(_Database.CreateParameter("terrain_texture_4", settings.TerrainTexture4)); | ||
1248 | parameters.Add(_Database.CreateParameter("elevation_1_nw", settings.Elevation1NW)); | ||
1249 | parameters.Add(_Database.CreateParameter("elevation_2_nw", settings.Elevation2NW)); | ||
1250 | parameters.Add(_Database.CreateParameter("elevation_1_ne", settings.Elevation1NE)); | ||
1251 | parameters.Add(_Database.CreateParameter("elevation_2_ne", settings.Elevation2NE)); | ||
1252 | parameters.Add(_Database.CreateParameter("elevation_1_se", settings.Elevation1SE)); | ||
1253 | parameters.Add(_Database.CreateParameter("elevation_2_se", settings.Elevation2SE)); | ||
1254 | parameters.Add(_Database.CreateParameter("elevation_1_sw", settings.Elevation1SW)); | ||
1255 | parameters.Add(_Database.CreateParameter("elevation_2_sw", settings.Elevation2SW)); | ||
1256 | parameters.Add(_Database.CreateParameter("water_height", settings.WaterHeight)); | ||
1257 | parameters.Add(_Database.CreateParameter("terrain_raise_limit", settings.TerrainRaiseLimit)); | ||
1258 | parameters.Add(_Database.CreateParameter("terrain_lower_limit", settings.TerrainLowerLimit)); | ||
1259 | parameters.Add(_Database.CreateParameter("use_estate_sun", settings.UseEstateSun)); | ||
1260 | parameters.Add(_Database.CreateParameter("sandbox", settings.Sandbox)); | ||
1261 | parameters.Add(_Database.CreateParameter("fixed_sun", settings.FixedSun)); | ||
1262 | parameters.Add(_Database.CreateParameter("sun_position", settings.SunPosition)); | ||
1263 | parameters.Add(_Database.CreateParameter("sunvectorx", settings.SunVector.X)); | ||
1264 | parameters.Add(_Database.CreateParameter("sunvectory", settings.SunVector.Y)); | ||
1265 | parameters.Add(_Database.CreateParameter("sunvectorz", settings.SunVector.Z)); | ||
1266 | parameters.Add(_Database.CreateParameter("covenant", settings.Covenant)); | ||
1267 | parameters.Add(_Database.CreateParameter("Loaded_Creation_DateTime", settings.LoadedCreationDateTime)); | ||
1268 | parameters.Add(_Database.CreateParameter("Loaded_Creation_ID", settings.LoadedCreationID)); | ||
1269 | |||
1270 | return parameters.ToArray(); | ||
1271 | } | ||
1272 | |||
1273 | /// <summary> | ||
1274 | /// Creates the land parameters. | ||
1275 | /// </summary> | ||
1276 | /// <param name="land">land parameters.</param> | ||
1277 | /// <param name="regionUUID">region UUID.</param> | ||
1278 | /// <returns></returns> | ||
1279 | private SqlParameter[] CreateLandParameters(LandData land, UUID regionUUID) | ||
1280 | { | ||
1281 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1282 | |||
1283 | parameters.Add(_Database.CreateParameter("UUID", land.GlobalID)); | ||
1284 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | ||
1285 | parameters.Add(_Database.CreateParameter("LocalLandID", land.LocalID)); | ||
1286 | |||
1287 | // Bitmap is a byte[512] | ||
1288 | parameters.Add(_Database.CreateParameter("Bitmap", land.Bitmap)); | ||
1289 | |||
1290 | parameters.Add(_Database.CreateParameter("Name", land.Name)); | ||
1291 | parameters.Add(_Database.CreateParameter("Description", land.Description)); | ||
1292 | parameters.Add(_Database.CreateParameter("OwnerUUID", land.OwnerID)); | ||
1293 | parameters.Add(_Database.CreateParameter("IsGroupOwned", land.IsGroupOwned)); | ||
1294 | parameters.Add(_Database.CreateParameter("Area", land.Area)); | ||
1295 | parameters.Add(_Database.CreateParameter("AuctionID", land.AuctionID)); //Unemplemented | ||
1296 | parameters.Add(_Database.CreateParameter("Category", (int)land.Category)); //Enum libsecondlife.Parcel.ParcelCategory | ||
1297 | parameters.Add(_Database.CreateParameter("ClaimDate", land.ClaimDate)); | ||
1298 | parameters.Add(_Database.CreateParameter("ClaimPrice", land.ClaimPrice)); | ||
1299 | parameters.Add(_Database.CreateParameter("GroupUUID", land.GroupID)); | ||
1300 | parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice)); | ||
1301 | parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus | ||
1302 | parameters.Add(_Database.CreateParameter("LandFlags", land.Flags)); | ||
1303 | parameters.Add(_Database.CreateParameter("LandingType", land.LandingType)); | ||
1304 | parameters.Add(_Database.CreateParameter("MediaAutoScale", land.MediaAutoScale)); | ||
1305 | parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID)); | ||
1306 | parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL)); | ||
1307 | parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL)); | ||
1308 | parameters.Add(_Database.CreateParameter("PassHours", land.PassHours)); | ||
1309 | parameters.Add(_Database.CreateParameter("PassPrice", land.PassPrice)); | ||
1310 | parameters.Add(_Database.CreateParameter("SnapshotUUID", land.SnapshotID)); | ||
1311 | parameters.Add(_Database.CreateParameter("UserLocationX", land.UserLocation.X)); | ||
1312 | parameters.Add(_Database.CreateParameter("UserLocationY", land.UserLocation.Y)); | ||
1313 | parameters.Add(_Database.CreateParameter("UserLocationZ", land.UserLocation.Z)); | ||
1314 | parameters.Add(_Database.CreateParameter("UserLookAtX", land.UserLookAt.X)); | ||
1315 | parameters.Add(_Database.CreateParameter("UserLookAtY", land.UserLookAt.Y)); | ||
1316 | parameters.Add(_Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z)); | ||
1317 | parameters.Add(_Database.CreateParameter("AuthBuyerID", land.AuthBuyerID)); | ||
1318 | parameters.Add(_Database.CreateParameter("OtherCleanTime", land.OtherCleanTime)); | ||
1319 | parameters.Add(_Database.CreateParameter("Dwell", land.Dwell)); | ||
1320 | |||
1321 | return parameters.ToArray(); | ||
1322 | } | ||
1323 | |||
1324 | /// <summary> | ||
1325 | /// Creates the land access parameters. | ||
1326 | /// </summary> | ||
1327 | /// <param name="parcelAccessEntry">parcel access entry.</param> | ||
1328 | /// <param name="parcelID">parcel ID.</param> | ||
1329 | /// <returns></returns> | ||
1330 | private SqlParameter[] CreateLandAccessParameters(ParcelManager.ParcelAccessEntry parcelAccessEntry, UUID parcelID) | ||
1331 | { | ||
1332 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1333 | |||
1334 | parameters.Add(_Database.CreateParameter("LandUUID", parcelID)); | ||
1335 | parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID)); | ||
1336 | parameters.Add(_Database.CreateParameter("Flags", parcelAccessEntry.Flags)); | ||
1337 | |||
1338 | return parameters.ToArray(); | ||
1339 | } | ||
1340 | |||
1341 | /// <summary> | ||
1342 | /// Creates the prim parameters for storing in DB. | ||
1343 | /// </summary> | ||
1344 | /// <param name="prim">Basic data of SceneObjectpart prim.</param> | ||
1345 | /// <param name="sceneGroupID">The scenegroup ID.</param> | ||
1346 | /// <param name="regionUUID">The region ID.</param> | ||
1347 | /// <returns></returns> | ||
1348 | private SqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | ||
1349 | { | ||
1350 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1351 | |||
1352 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | ||
1353 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | ||
1354 | parameters.Add(_Database.CreateParameter("CreationDate", prim.CreationDate)); | ||
1355 | parameters.Add(_Database.CreateParameter("Name", prim.Name)); | ||
1356 | parameters.Add(_Database.CreateParameter("SceneGroupID", sceneGroupID)); | ||
1357 | // the UUID of the root part for this SceneObjectGroup | ||
1358 | // various text fields | ||
1359 | parameters.Add(_Database.CreateParameter("Text", prim.Text)); | ||
1360 | parameters.Add(_Database.CreateParameter("ColorR", prim.Color.R)); | ||
1361 | parameters.Add(_Database.CreateParameter("ColorG", prim.Color.G)); | ||
1362 | parameters.Add(_Database.CreateParameter("ColorB", prim.Color.B)); | ||
1363 | parameters.Add(_Database.CreateParameter("ColorA", prim.Color.A)); | ||
1364 | parameters.Add(_Database.CreateParameter("Description", prim.Description)); | ||
1365 | parameters.Add(_Database.CreateParameter("SitName", prim.SitName)); | ||
1366 | parameters.Add(_Database.CreateParameter("TouchName", prim.TouchName)); | ||
1367 | // permissions | ||
1368 | parameters.Add(_Database.CreateParameter("ObjectFlags", prim.ObjectFlags)); | ||
1369 | parameters.Add(_Database.CreateParameter("CreatorID", prim.CreatorID)); | ||
1370 | parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID)); | ||
1371 | parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID)); | ||
1372 | parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID)); | ||
1373 | parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask)); | ||
1374 | parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask)); | ||
1375 | parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask)); | ||
1376 | parameters.Add(_Database.CreateParameter("EveryoneMask", prim.EveryoneMask)); | ||
1377 | parameters.Add(_Database.CreateParameter("BaseMask", prim.BaseMask)); | ||
1378 | // vectors | ||
1379 | parameters.Add(_Database.CreateParameter("PositionX", prim.OffsetPosition.X)); | ||
1380 | parameters.Add(_Database.CreateParameter("PositionY", prim.OffsetPosition.Y)); | ||
1381 | parameters.Add(_Database.CreateParameter("PositionZ", prim.OffsetPosition.Z)); | ||
1382 | parameters.Add(_Database.CreateParameter("GroupPositionX", prim.GroupPosition.X)); | ||
1383 | parameters.Add(_Database.CreateParameter("GroupPositionY", prim.GroupPosition.Y)); | ||
1384 | parameters.Add(_Database.CreateParameter("GroupPositionZ", prim.GroupPosition.Z)); | ||
1385 | parameters.Add(_Database.CreateParameter("VelocityX", prim.Velocity.X)); | ||
1386 | parameters.Add(_Database.CreateParameter("VelocityY", prim.Velocity.Y)); | ||
1387 | parameters.Add(_Database.CreateParameter("VelocityZ", prim.Velocity.Z)); | ||
1388 | parameters.Add(_Database.CreateParameter("AngularVelocityX", prim.AngularVelocity.X)); | ||
1389 | parameters.Add(_Database.CreateParameter("AngularVelocityY", prim.AngularVelocity.Y)); | ||
1390 | parameters.Add(_Database.CreateParameter("AngularVelocityZ", prim.AngularVelocity.Z)); | ||
1391 | parameters.Add(_Database.CreateParameter("AccelerationX", prim.Acceleration.X)); | ||
1392 | parameters.Add(_Database.CreateParameter("AccelerationY", prim.Acceleration.Y)); | ||
1393 | parameters.Add(_Database.CreateParameter("AccelerationZ", prim.Acceleration.Z)); | ||
1394 | // quaternions | ||
1395 | parameters.Add(_Database.CreateParameter("RotationX", prim.RotationOffset.X)); | ||
1396 | parameters.Add(_Database.CreateParameter("RotationY", prim.RotationOffset.Y)); | ||
1397 | parameters.Add(_Database.CreateParameter("RotationZ", prim.RotationOffset.Z)); | ||
1398 | parameters.Add(_Database.CreateParameter("RotationW", prim.RotationOffset.W)); | ||
1399 | |||
1400 | // Sit target | ||
1401 | Vector3 sitTargetPos = prim.SitTargetPositionLL; | ||
1402 | parameters.Add(_Database.CreateParameter("SitTargetOffsetX", sitTargetPos.X)); | ||
1403 | parameters.Add(_Database.CreateParameter("SitTargetOffsetY", sitTargetPos.Y)); | ||
1404 | parameters.Add(_Database.CreateParameter("SitTargetOffsetZ", sitTargetPos.Z)); | ||
1405 | |||
1406 | Quaternion sitTargetOrient = prim.SitTargetOrientationLL; | ||
1407 | parameters.Add(_Database.CreateParameter("SitTargetOrientW", sitTargetOrient.W)); | ||
1408 | parameters.Add(_Database.CreateParameter("SitTargetOrientX", sitTargetOrient.X)); | ||
1409 | parameters.Add(_Database.CreateParameter("SitTargetOrientY", sitTargetOrient.Y)); | ||
1410 | parameters.Add(_Database.CreateParameter("SitTargetOrientZ", sitTargetOrient.Z)); | ||
1411 | |||
1412 | parameters.Add(_Database.CreateParameter("PayPrice", prim.PayPrice[0])); | ||
1413 | parameters.Add(_Database.CreateParameter("PayButton1", prim.PayPrice[1])); | ||
1414 | parameters.Add(_Database.CreateParameter("PayButton2", prim.PayPrice[2])); | ||
1415 | parameters.Add(_Database.CreateParameter("PayButton3", prim.PayPrice[3])); | ||
1416 | parameters.Add(_Database.CreateParameter("PayButton4", prim.PayPrice[4])); | ||
1417 | |||
1418 | if ((prim.SoundFlags & 1) != 0) // Looped | ||
1419 | { | ||
1420 | parameters.Add(_Database.CreateParameter("LoopedSound", prim.Sound)); | ||
1421 | parameters.Add(_Database.CreateParameter("LoopedSoundGain", prim.SoundGain)); | ||
1422 | } | ||
1423 | else | ||
1424 | { | ||
1425 | parameters.Add(_Database.CreateParameter("LoopedSound", UUID.Zero)); | ||
1426 | parameters.Add(_Database.CreateParameter("LoopedSoundGain", 0.0f)); | ||
1427 | } | ||
1428 | |||
1429 | parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation)); | ||
1430 | parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem)); | ||
1431 | |||
1432 | parameters.Add(_Database.CreateParameter("OmegaX", prim.RotationalVelocity.X)); | ||
1433 | parameters.Add(_Database.CreateParameter("OmegaY", prim.RotationalVelocity.Y)); | ||
1434 | parameters.Add(_Database.CreateParameter("OmegaZ", prim.RotationalVelocity.Z)); | ||
1435 | |||
1436 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X)); | ||
1437 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y)); | ||
1438 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetZ", prim.GetCameraEyeOffset().Z)); | ||
1439 | |||
1440 | parameters.Add(_Database.CreateParameter("CameraAtOffsetX", prim.GetCameraAtOffset().X)); | ||
1441 | parameters.Add(_Database.CreateParameter("CameraAtOffsetY", prim.GetCameraAtOffset().Y)); | ||
1442 | parameters.Add(_Database.CreateParameter("CameraAtOffsetZ", prim.GetCameraAtOffset().Z)); | ||
1443 | |||
1444 | if (prim.GetForceMouselook()) | ||
1445 | parameters.Add(_Database.CreateParameter("ForceMouselook", 1)); | ||
1446 | else | ||
1447 | parameters.Add(_Database.CreateParameter("ForceMouselook", 0)); | ||
1448 | |||
1449 | parameters.Add(_Database.CreateParameter("ScriptAccessPin", prim.ScriptAccessPin)); | ||
1450 | |||
1451 | if (prim.AllowedDrop) | ||
1452 | parameters.Add(_Database.CreateParameter("AllowedDrop", 1)); | ||
1453 | else | ||
1454 | parameters.Add(_Database.CreateParameter("AllowedDrop", 0)); | ||
1455 | |||
1456 | if (prim.DIE_AT_EDGE) | ||
1457 | parameters.Add(_Database.CreateParameter("DieAtEdge", 1)); | ||
1458 | else | ||
1459 | parameters.Add(_Database.CreateParameter("DieAtEdge", 0)); | ||
1460 | |||
1461 | parameters.Add(_Database.CreateParameter("SalePrice", prim.SalePrice)); | ||
1462 | parameters.Add(_Database.CreateParameter("SaleType", prim.ObjectSaleType)); | ||
1463 | |||
1464 | byte clickAction = prim.ClickAction; | ||
1465 | parameters.Add(_Database.CreateParameter("ClickAction", clickAction)); | ||
1466 | |||
1467 | parameters.Add(_Database.CreateParameter("Material", prim.Material)); | ||
1468 | |||
1469 | parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); | ||
1470 | parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); | ||
1471 | if (prim.PassTouches) | ||
1472 | parameters.Add(_Database.CreateParameter("PassTouches", 1)); | ||
1473 | else | ||
1474 | parameters.Add(_Database.CreateParameter("PassTouches", 0)); | ||
1475 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); | ||
1476 | |||
1477 | return parameters.ToArray(); | ||
1478 | } | ||
1479 | |||
1480 | /// <summary> | ||
1481 | /// Creates the primshape parameters for stroing in DB. | ||
1482 | /// </summary> | ||
1483 | /// <param name="prim">Basic data of SceneObjectpart prim.</param> | ||
1484 | /// <param name="sceneGroupID">The scene group ID.</param> | ||
1485 | /// <param name="regionUUID">The region UUID.</param> | ||
1486 | /// <returns></returns> | ||
1487 | private SqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | ||
1488 | { | ||
1489 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1490 | |||
1491 | PrimitiveBaseShape s = prim.Shape; | ||
1492 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | ||
1493 | // shape is an enum | ||
1494 | parameters.Add(_Database.CreateParameter("Shape", 0)); | ||
1495 | // vectors | ||
1496 | parameters.Add(_Database.CreateParameter("ScaleX", s.Scale.X)); | ||
1497 | parameters.Add(_Database.CreateParameter("ScaleY", s.Scale.Y)); | ||
1498 | parameters.Add(_Database.CreateParameter("ScaleZ", s.Scale.Z)); | ||
1499 | // paths | ||
1500 | parameters.Add(_Database.CreateParameter("PCode", s.PCode)); | ||
1501 | parameters.Add(_Database.CreateParameter("PathBegin", s.PathBegin)); | ||
1502 | parameters.Add(_Database.CreateParameter("PathEnd", s.PathEnd)); | ||
1503 | parameters.Add(_Database.CreateParameter("PathScaleX", s.PathScaleX)); | ||
1504 | parameters.Add(_Database.CreateParameter("PathScaleY", s.PathScaleY)); | ||
1505 | parameters.Add(_Database.CreateParameter("PathShearX", s.PathShearX)); | ||
1506 | parameters.Add(_Database.CreateParameter("PathShearY", s.PathShearY)); | ||
1507 | parameters.Add(_Database.CreateParameter("PathSkew", s.PathSkew)); | ||
1508 | parameters.Add(_Database.CreateParameter("PathCurve", s.PathCurve)); | ||
1509 | parameters.Add(_Database.CreateParameter("PathRadiusOffset", s.PathRadiusOffset)); | ||
1510 | parameters.Add(_Database.CreateParameter("PathRevolutions", s.PathRevolutions)); | ||
1511 | parameters.Add(_Database.CreateParameter("PathTaperX", s.PathTaperX)); | ||
1512 | parameters.Add(_Database.CreateParameter("PathTaperY", s.PathTaperY)); | ||
1513 | parameters.Add(_Database.CreateParameter("PathTwist", s.PathTwist)); | ||
1514 | parameters.Add(_Database.CreateParameter("PathTwistBegin", s.PathTwistBegin)); | ||
1515 | // profile | ||
1516 | parameters.Add(_Database.CreateParameter("ProfileBegin", s.ProfileBegin)); | ||
1517 | parameters.Add(_Database.CreateParameter("ProfileEnd", s.ProfileEnd)); | ||
1518 | parameters.Add(_Database.CreateParameter("ProfileCurve", s.ProfileCurve)); | ||
1519 | parameters.Add(_Database.CreateParameter("ProfileHollow", s.ProfileHollow)); | ||
1520 | parameters.Add(_Database.CreateParameter("Texture", s.TextureEntry)); | ||
1521 | parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams)); | ||
1522 | parameters.Add(_Database.CreateParameter("State", s.State)); | ||
1523 | |||
1524 | return parameters.ToArray(); | ||
1525 | } | ||
1526 | |||
1527 | #endregion | ||
1528 | |||
1529 | #endregion | ||
1530 | } | ||
1531 | } | ||
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index 6318c09..78d7fd0 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs | |||
@@ -13,7 +13,7 @@ | |||
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
@@ -43,1489 +43,269 @@ namespace OpenSim.Data.MSSQL | |||
43 | /// <summary> | 43 | /// <summary> |
44 | /// A MSSQL Interface for the Region Server. | 44 | /// A MSSQL Interface for the Region Server. |
45 | /// </summary> | 45 | /// </summary> |
46 | public class MSSQLRegionDataStore : IRegionDataStore | 46 | public class MSSQLRegionData : IRegionData |
47 | { | 47 | { |
48 | private const string _migrationStore = "RegionStore"; | 48 | private string m_Realm; |
49 | private List<string> m_ColumnNames = null; | ||
50 | private string m_ConnectionString; | ||
51 | private MSSQLManager m_database; | ||
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | 53 | ||
50 | // private static FileSystemDataStore Instance = new FileSystemDataStore(); | 54 | public MSSQLRegionData(string connectionString, string realm) |
51 | private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | /// <summary> | ||
54 | /// The database manager | ||
55 | /// </summary> | ||
56 | private MSSQLManager _Database; | ||
57 | |||
58 | /// <summary> | ||
59 | /// Initialises the region datastore | ||
60 | /// </summary> | ||
61 | /// <param name="connectionString">The connection string.</param> | ||
62 | public void Initialise(string connectionString) | ||
63 | { | 55 | { |
64 | if (!string.IsNullOrEmpty(connectionString)) | 56 | m_Realm = realm; |
65 | { | 57 | m_ConnectionString = connectionString; |
66 | _Database = new MSSQLManager(connectionString); | 58 | m_database = new MSSQLManager(connectionString); |
67 | } | ||
68 | else | ||
69 | { | ||
70 | IniFile iniFile = new IniFile("mssql_connection.ini"); | ||
71 | string settingDataSource = iniFile.ParseFileReadValue("data_source"); | ||
72 | string settingInitialCatalog = iniFile.ParseFileReadValue("initial_catalog"); | ||
73 | string settingPersistSecurityInfo = iniFile.ParseFileReadValue("persist_security_info"); | ||
74 | string settingUserId = iniFile.ParseFileReadValue("user_id"); | ||
75 | string settingPassword = iniFile.ParseFileReadValue("password"); | ||
76 | |||
77 | _Database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); | ||
78 | } | ||
79 | |||
80 | //Migration settings | ||
81 | _Database.CheckMigration(_migrationStore); | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
85 | /// Dispose the database | ||
86 | /// </summary> | ||
87 | public void Dispose() { } | ||
88 | |||
89 | #region SceneObjectGroup region for loading and Store of the scene. | ||
90 | |||
91 | /// <summary> | ||
92 | /// Loads the objects present in the region. | ||
93 | /// </summary> | ||
94 | /// <param name="regionUUID">The region UUID.</param> | ||
95 | /// <returns></returns> | ||
96 | public List<SceneObjectGroup> LoadObjects(UUID regionUUID) | ||
97 | { | ||
98 | UUID lastGroupID = UUID.Zero; | ||
99 | |||
100 | Dictionary<UUID, SceneObjectPart> prims = new Dictionary<UUID, SceneObjectPart>(); | ||
101 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); | ||
102 | SceneObjectGroup grp = null; | ||
103 | |||
104 | |||
105 | string query = "SELECT *, " + | ||
106 | "sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " + | ||
107 | "FROM prims " + | ||
108 | "LEFT JOIN primshapes ON prims.UUID = primshapes.UUID " + | ||
109 | "WHERE RegionUUID = @RegionUUID " + | ||
110 | "ORDER BY SceneGroupID asc, sort asc, LinkNumber asc"; | ||
111 | |||
112 | using (AutoClosingSqlCommand command = _Database.Query(query)) | ||
113 | { | ||
114 | command.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | ||
115 | |||
116 | using (SqlDataReader reader = command.ExecuteReader()) | ||
117 | { | ||
118 | while (reader.Read()) | ||
119 | { | ||
120 | SceneObjectPart sceneObjectPart = BuildPrim(reader); | ||
121 | if (reader["Shape"] is DBNull) | ||
122 | sceneObjectPart.Shape = PrimitiveBaseShape.Default; | ||
123 | else | ||
124 | sceneObjectPart.Shape = BuildShape(reader); | ||
125 | |||
126 | prims[sceneObjectPart.UUID] = sceneObjectPart; | ||
127 | |||
128 | UUID groupID = new UUID((Guid)reader["SceneGroupID"]); | ||
129 | 59 | ||
130 | if (groupID != lastGroupID) // New SOG | 60 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
131 | { | ||
132 | if (grp != null) | ||
133 | objects[grp.UUID] = grp; | ||
134 | |||
135 | lastGroupID = groupID; | ||
136 | |||
137 | // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are | ||
138 | // recorded as the root prim (for which the UUID must equal the persisted group UUID). In | ||
139 | // this case, force the UUID to be the same as the group UUID so that at least these can be | ||
140 | // deleted (we need to change the UUID so that any other prims in the linkset can also be | ||
141 | // deleted). | ||
142 | if (sceneObjectPart.UUID != groupID && groupID != UUID.Zero) | ||
143 | { | ||
144 | _Log.WarnFormat( | ||
145 | "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", | ||
146 | sceneObjectPart.Name, sceneObjectPart.UUID, sceneObjectPart.GroupPosition, groupID); | ||
147 | |||
148 | sceneObjectPart.UUID = groupID; | ||
149 | } | ||
150 | |||
151 | grp = new SceneObjectGroup(sceneObjectPart); | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | // Black magic to preserve link numbers | ||
156 | // Why is this needed, fix this in AddPart method. | ||
157 | int link = sceneObjectPart.LinkNum; | ||
158 | |||
159 | grp.AddPart(sceneObjectPart); | ||
160 | |||
161 | if (link != 0) | ||
162 | sceneObjectPart.LinkNum = link; | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | |||
168 | if (grp != null) | ||
169 | objects[grp.UUID] = grp; | ||
170 | |||
171 | // Instead of attempting to LoadItems on every prim, | ||
172 | // most of which probably have no items... get a | ||
173 | // list from DB of all prims which have items and | ||
174 | // LoadItems only on those | ||
175 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | ||
176 | string qry = "select distinct primID from primitems"; | ||
177 | using (AutoClosingSqlCommand command = _Database.Query(qry)) | ||
178 | { | 61 | { |
179 | using (SqlDataReader itemReader = command.ExecuteReader()) | 62 | conn.Open(); |
180 | { | 63 | Migration m = new Migration(conn, GetType().Assembly, "GridStore"); |
181 | while (itemReader.Read()) | 64 | m.Update(); |
182 | { | 65 | } |
183 | if (!(itemReader["primID"] is DBNull)) | 66 | } |
184 | { | ||
185 | UUID primID = new UUID(itemReader["primID"].ToString()); | ||
186 | if (prims.ContainsKey(primID)) | ||
187 | { | ||
188 | primsWithInventory.Add(prims[primID]); | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | LoadItems(primsWithInventory); | ||
196 | |||
197 | _Log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); | ||
198 | 67 | ||
199 | return new List<SceneObjectGroup>(objects.Values); | 68 | public List<RegionData> Get(string regionName, UUID scopeID) |
200 | } | ||
201 | |||
202 | /// <summary> | ||
203 | /// Load in the prim's persisted inventory. | ||
204 | /// </summary> | ||
205 | /// <param name="allPrims">all prims with inventory on a region</param> | ||
206 | private void LoadItems(List<SceneObjectPart> allPrimsWithInventory) | ||
207 | { | 69 | { |
208 | 70 | string sql = "select * from ["+m_Realm+"] where regionName like @regionName"; | |
209 | using (AutoClosingSqlCommand command = _Database.Query("SELECT * FROM primitems WHERE PrimID = @PrimID")) | 71 | if (scopeID != UUID.Zero) |
72 | sql += " and ScopeID = @scopeID"; | ||
73 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
74 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
210 | { | 75 | { |
211 | foreach (SceneObjectPart objectPart in allPrimsWithInventory) | 76 | cmd.Parameters.Add(m_database.CreateParameter("@regionName", regionName)); |
212 | { | 77 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); |
213 | command.Parameters.Clear(); | 78 | conn.Open(); |
214 | command.Parameters.Add(_Database.CreateParameter("@PrimID", objectPart.UUID)); | 79 | return RunCommand(cmd); |
215 | |||
216 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | ||
217 | |||
218 | using (SqlDataReader reader = command.ExecuteReader()) | ||
219 | { | ||
220 | while (reader.Read()) | ||
221 | { | ||
222 | TaskInventoryItem item = BuildItem(reader); | ||
223 | |||
224 | item.ParentID = objectPart.UUID; // Values in database are | ||
225 | // often wrong | ||
226 | inventory.Add(item); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | objectPart.Inventory.RestoreInventoryItems(inventory); | ||
231 | } | ||
232 | } | 80 | } |
233 | } | 81 | } |
234 | 82 | ||
235 | /// <summary> | 83 | public RegionData Get(int posX, int posY, UUID scopeID) |
236 | /// Stores all object's details apart from inventory | ||
237 | /// </summary> | ||
238 | /// <param name="obj"></param> | ||
239 | /// <param name="regionUUID"></param> | ||
240 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) | ||
241 | { | 84 | { |
242 | _Log.InfoFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count); | 85 | string sql = "select * from ["+m_Realm+"] where locX = @posX and locY = @posY"; |
86 | if (scopeID != UUID.Zero) | ||
87 | sql += " and ScopeID = @scopeID"; | ||
243 | 88 | ||
244 | using (SqlConnection conn = _Database.DatabaseConnection()) | 89 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
90 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
245 | { | 91 | { |
246 | SqlTransaction transaction = conn.BeginTransaction(); | 92 | cmd.Parameters.Add(m_database.CreateParameter("@posX", posX.ToString())); |
247 | 93 | cmd.Parameters.Add(m_database.CreateParameter("@posY", posY.ToString())); | |
248 | try | 94 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); |
249 | { | 95 | conn.Open(); |
250 | foreach (SceneObjectPart sceneObjectPart in obj.Children.Values) | 96 | List<RegionData> ret = RunCommand(cmd); |
251 | { | 97 | if (ret.Count == 0) |
252 | //Update prim | 98 | return null; |
253 | using (SqlCommand sqlCommand = conn.CreateCommand()) | 99 | |
254 | { | 100 | return ret[0]; |
255 | sqlCommand.Transaction = transaction; | 101 | } |
256 | try | ||
257 | { | ||
258 | StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | ||
259 | } | ||
260 | catch (SqlException sqlEx) | ||
261 | { | ||
262 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | ||
263 | throw; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | //Update primshapes | ||
268 | using (SqlCommand sqlCommand = conn.CreateCommand()) | ||
269 | { | ||
270 | sqlCommand.Transaction = transaction; | ||
271 | try | ||
272 | { | ||
273 | StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | ||
274 | } | ||
275 | catch (SqlException sqlEx) | ||
276 | { | ||
277 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | ||
278 | throw; | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | |||
283 | transaction.Commit(); | ||
284 | } | ||
285 | catch (Exception ex) | ||
286 | { | ||
287 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message); | ||
288 | try | ||
289 | { | ||
290 | transaction.Rollback(); | ||
291 | } | ||
292 | catch (Exception ex2) | ||
293 | { | ||
294 | //Show error | ||
295 | _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message); | ||
296 | |||
297 | } | ||
298 | } | ||
299 | } | ||
300 | |||
301 | } | 102 | } |
302 | 103 | ||
303 | /// <summary> | 104 | public RegionData Get(UUID regionID, UUID scopeID) |
304 | /// Stores the prim of the sceneobjectpart. | ||
305 | /// </summary> | ||
306 | /// <param name="sceneObjectPart">The sceneobjectpart or prim.</param> | ||
307 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | ||
308 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | ||
309 | /// <param name="regionUUID">The region UUID.</param> | ||
310 | private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | ||
311 | { | 105 | { |
312 | //Big query to update or insert a new prim. | 106 | string sql = "select * from ["+m_Realm+"] where uuid = @regionID"; |
313 | //Note for SQL Server 2008 this could be simplified | 107 | if (scopeID != UUID.Zero) |
314 | string queryPrims = @" | 108 | sql += " and ScopeID = @scopeID"; |
315 | IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID) | 109 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
316 | BEGIN | 110 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
317 | UPDATE prims SET | ||
318 | CreationDate = @CreationDate, Name = @Name, Text = @Text, Description = @Description, SitName = @SitName, | ||
319 | TouchName = @TouchName, ObjectFlags = @ObjectFlags, OwnerMask = @OwnerMask, NextOwnerMask = @NextOwnerMask, GroupMask = @GroupMask, | ||
320 | EveryoneMask = @EveryoneMask, BaseMask = @BaseMask, PositionX = @PositionX, PositionY = @PositionY, PositionZ = @PositionZ, | ||
321 | GroupPositionX = @GroupPositionX, GroupPositionY = @GroupPositionY, GroupPositionZ = @GroupPositionZ, VelocityX = @VelocityX, | ||
322 | VelocityY = @VelocityY, VelocityZ = @VelocityZ, AngularVelocityX = @AngularVelocityX, AngularVelocityY = @AngularVelocityY, | ||
323 | AngularVelocityZ = @AngularVelocityZ, AccelerationX = @AccelerationX, AccelerationY = @AccelerationY, | ||
324 | AccelerationZ = @AccelerationZ, RotationX = @RotationX, RotationY = @RotationY, RotationZ = @RotationZ, RotationW = @RotationW, | ||
325 | SitTargetOffsetX = @SitTargetOffsetX, SitTargetOffsetY = @SitTargetOffsetY, SitTargetOffsetZ = @SitTargetOffsetZ, | ||
326 | SitTargetOrientW = @SitTargetOrientW, SitTargetOrientX = @SitTargetOrientX, SitTargetOrientY = @SitTargetOrientY, | ||
327 | SitTargetOrientZ = @SitTargetOrientZ, RegionUUID = @RegionUUID, CreatorID = @CreatorID, OwnerID = @OwnerID, GroupID = @GroupID, | ||
328 | LastOwnerID = @LastOwnerID, SceneGroupID = @SceneGroupID, PayPrice = @PayPrice, PayButton1 = @PayButton1, PayButton2 = @PayButton2, | ||
329 | PayButton3 = @PayButton3, PayButton4 = @PayButton4, LoopedSound = @LoopedSound, LoopedSoundGain = @LoopedSoundGain, | ||
330 | TextureAnimation = @TextureAnimation, OmegaX = @OmegaX, OmegaY = @OmegaY, OmegaZ = @OmegaZ, CameraEyeOffsetX = @CameraEyeOffsetX, | ||
331 | CameraEyeOffsetY = @CameraEyeOffsetY, CameraEyeOffsetZ = @CameraEyeOffsetZ, CameraAtOffsetX = @CameraAtOffsetX, | ||
332 | CameraAtOffsetY = @CameraAtOffsetY, CameraAtOffsetZ = @CameraAtOffsetZ, ForceMouselook = @ForceMouselook, | ||
333 | ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice, | ||
334 | SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem, | ||
335 | ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches, | ||
336 | LinkNumber = @LinkNumber | ||
337 | WHERE UUID = @UUID | ||
338 | END | ||
339 | ELSE | ||
340 | BEGIN | ||
341 | INSERT INTO | ||
342 | prims ( | ||
343 | UUID, CreationDate, Name, Text, Description, SitName, TouchName, ObjectFlags, OwnerMask, NextOwnerMask, GroupMask, | ||
344 | EveryoneMask, BaseMask, PositionX, PositionY, PositionZ, GroupPositionX, GroupPositionY, GroupPositionZ, VelocityX, | ||
345 | VelocityY, VelocityZ, AngularVelocityX, AngularVelocityY, AngularVelocityZ, AccelerationX, AccelerationY, AccelerationZ, | ||
346 | RotationX, RotationY, RotationZ, RotationW, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, | ||
347 | SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, RegionUUID, CreatorID, OwnerID, GroupID, LastOwnerID, SceneGroupID, | ||
348 | PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX, | ||
349 | OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, | ||
350 | ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, | ||
351 | ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber | ||
352 | ) VALUES ( | ||
353 | @UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask, | ||
354 | @EveryoneMask, @BaseMask, @PositionX, @PositionY, @PositionZ, @GroupPositionX, @GroupPositionY, @GroupPositionZ, @VelocityX, | ||
355 | @VelocityY, @VelocityZ, @AngularVelocityX, @AngularVelocityY, @AngularVelocityZ, @AccelerationX, @AccelerationY, @AccelerationZ, | ||
356 | @RotationX, @RotationY, @RotationZ, @RotationW, @SitTargetOffsetX, @SitTargetOffsetY, @SitTargetOffsetZ, @SitTargetOrientW, | ||
357 | @SitTargetOrientX, @SitTargetOrientY, @SitTargetOrientZ, @RegionUUID, @CreatorID, @OwnerID, @GroupID, @LastOwnerID, @SceneGroupID, | ||
358 | @PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX, | ||
359 | @OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ, | ||
360 | @ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA, | ||
361 | @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber | ||
362 | ) | ||
363 | END"; | ||
364 | |||
365 | //Set commandtext. | ||
366 | sqlCommand.CommandText = queryPrims; | ||
367 | //Add parameters | ||
368 | sqlCommand.Parameters.AddRange(CreatePrimParameters(sceneObjectPart, sceneGroupID, regionUUID)); | ||
369 | |||
370 | //Execute the query. If it fails then error is trapped in calling function | ||
371 | sqlCommand.ExecuteNonQuery(); | ||
372 | } | ||
373 | |||
374 | /// <summary> | ||
375 | /// Stores the scene object prim shapes. | ||
376 | /// </summary> | ||
377 | /// <param name="sceneObjectPart">The sceneobjectpart containing prim shape.</param> | ||
378 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | ||
379 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | ||
380 | /// <param name="regionUUID">The region UUID.</param> | ||
381 | private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | ||
382 | { | ||
383 | //Big query to or insert or update primshapes | ||
384 | //Note for SQL Server 2008 this can be simplified | ||
385 | string queryPrimShapes = @" | ||
386 | IF EXISTS (SELECT UUID FROM primshapes WHERE UUID = @UUID) | ||
387 | BEGIN | ||
388 | UPDATE primshapes SET | ||
389 | Shape = @Shape, ScaleX = @ScaleX, ScaleY = @ScaleY, ScaleZ = @ScaleZ, PCode = @PCode, PathBegin = @PathBegin, | ||
390 | PathEnd = @PathEnd, PathScaleX = @PathScaleX, PathScaleY = @PathScaleY, PathShearX = @PathShearX, PathShearY = @PathShearY, | ||
391 | PathSkew = @PathSkew, PathCurve = @PathCurve, PathRadiusOffset = @PathRadiusOffset, PathRevolutions = @PathRevolutions, | ||
392 | PathTaperX = @PathTaperX, PathTaperY = @PathTaperY, PathTwist = @PathTwist, PathTwistBegin = @PathTwistBegin, | ||
393 | ProfileBegin = @ProfileBegin, ProfileEnd = @ProfileEnd, ProfileCurve = @ProfileCurve, ProfileHollow = @ProfileHollow, | ||
394 | Texture = @Texture, ExtraParams = @ExtraParams, State = @State | ||
395 | WHERE UUID = @UUID | ||
396 | END | ||
397 | ELSE | ||
398 | BEGIN | ||
399 | INSERT INTO | ||
400 | primshapes ( | ||
401 | UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, | ||
402 | PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, | ||
403 | ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State | ||
404 | ) VALUES ( | ||
405 | @UUID, @Shape, @ScaleX, @ScaleY, @ScaleZ, @PCode, @PathBegin, @PathEnd, @PathScaleX, @PathScaleY, @PathShearX, @PathShearY, | ||
406 | @PathSkew, @PathCurve, @PathRadiusOffset, @PathRevolutions, @PathTaperX, @PathTaperY, @PathTwist, @PathTwistBegin, @ProfileBegin, | ||
407 | @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State | ||
408 | ) | ||
409 | END"; | ||
410 | |||
411 | //Set commandtext. | ||
412 | sqlCommand.CommandText = queryPrimShapes; | ||
413 | |||
414 | //Add parameters | ||
415 | sqlCommand.Parameters.AddRange(CreatePrimShapeParameters(sceneObjectPart, sceneGroupID, regionUUID)); | ||
416 | |||
417 | //Execute the query. If it fails then error is trapped in calling function | ||
418 | sqlCommand.ExecuteNonQuery(); | ||
419 | |||
420 | } | ||
421 | |||
422 | /// <summary> | ||
423 | /// Removes a object from the database. | ||
424 | /// Meaning removing it from tables Prims, PrimShapes and PrimItems | ||
425 | /// </summary> | ||
426 | /// <param name="objectID">id of scenegroup</param> | ||
427 | /// <param name="regionUUID">regionUUID (is this used anyway</param> | ||
428 | public void RemoveObject(UUID objectID, UUID regionUUID) | ||
429 | { | ||
430 | _Log.InfoFormat("[MSSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID); | ||
431 | |||
432 | //Remove from prims and primsitem table | ||
433 | string sqlPrims = "DELETE FROM PRIMS WHERE SceneGroupID = @objectID"; | ||
434 | string sqlPrimItems = "DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | ||
435 | string sqlPrimShapes = "DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | ||
436 | |||
437 | lock (_Database) | ||
438 | { | 111 | { |
439 | //Using the non transaction mode. | 112 | cmd.Parameters.Add(m_database.CreateParameter("@regionID", regionID)); |
440 | using (AutoClosingSqlCommand cmd = _Database.Query(sqlPrimShapes)) | 113 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); |
441 | { | 114 | conn.Open(); |
442 | cmd.Parameters.Add(_Database.CreateParameter("objectID", objectID)); | 115 | List<RegionData> ret = RunCommand(cmd); |
443 | cmd.ExecuteNonQuery(); | 116 | if (ret.Count == 0) |
444 | 117 | return null; | |
445 | cmd.CommandText = sqlPrimItems; | 118 | |
446 | cmd.ExecuteNonQuery(); | 119 | return ret[0]; |
447 | |||
448 | cmd.CommandText = sqlPrims; | ||
449 | cmd.ExecuteNonQuery(); | ||
450 | } | ||
451 | } | 120 | } |
452 | } | 121 | } |
453 | 122 | ||
454 | /// <summary> | 123 | public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID) |
455 | /// Store the inventory of a prim. Warning deletes everything first and then adds all again. | ||
456 | /// </summary> | ||
457 | /// <param name="primID"></param> | ||
458 | /// <param name="items"></param> | ||
459 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) | ||
460 | { | 124 | { |
461 | //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID); | 125 | string sql = "select * from ["+m_Realm+"] where locX between @startX and @endX and locY between @startY and @endY"; |
462 | 126 | if (scopeID != UUID.Zero) | |
463 | //Statement from MySQL section! | 127 | sql += " and ScopeID = @scopeID"; |
464 | // For now, we're just going to crudely remove all the previous inventory items | ||
465 | // no matter whether they have changed or not, and replace them with the current set. | ||
466 | 128 | ||
467 | //Delete everything from PrimID | 129 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
468 | //TODO add index on PrimID in DB, if not already exist | 130 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
469 | using (AutoClosingSqlCommand cmd = _Database.Query("DELETE PRIMITEMS WHERE primID = @primID")) | ||
470 | { | 131 | { |
471 | cmd.Parameters.Add(_Database.CreateParameter("@primID", primID)); | 132 | cmd.Parameters.Add(m_database.CreateParameter("@startX", startX.ToString())); |
472 | cmd.ExecuteNonQuery(); | 133 | cmd.Parameters.Add(m_database.CreateParameter("@startY", startY.ToString())); |
473 | } | 134 | cmd.Parameters.Add(m_database.CreateParameter("@endX", endX.ToString())); |
474 | 135 | cmd.Parameters.Add(m_database.CreateParameter("@endY", endY.ToString())); | |
475 | string sql = | 136 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); |
476 | @"INSERT INTO primitems ( | 137 | conn.Open(); |
477 | itemID,primID,assetID,parentFolderID,invType,assetType,name,description,creationDate,creatorID,ownerID,lastOwnerID,groupID, | 138 | return RunCommand(cmd); |
478 | nextPermissions,currentPermissions,basePermissions,everyonePermissions,groupPermissions,flags) | ||
479 | VALUES (@itemID,@primID,@assetID,@parentFolderID,@invType,@assetType,@name,@description,@creationDate,@creatorID,@ownerID, | ||
480 | @lastOwnerID,@groupID,@nextPermissions,@currentPermissions,@basePermissions,@everyonePermissions,@groupPermissions,@flags)"; | ||
481 | |||
482 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
483 | { | ||
484 | foreach (TaskInventoryItem taskItem in items) | ||
485 | { | ||
486 | cmd.Parameters.AddRange(CreatePrimInventoryParameters(taskItem)); | ||
487 | cmd.ExecuteNonQuery(); | ||
488 | |||
489 | cmd.Parameters.Clear(); | ||
490 | } | ||
491 | } | 139 | } |
492 | } | 140 | } |
493 | 141 | ||
494 | #endregion | 142 | public List<RegionData> RunCommand(SqlCommand cmd) |
495 | |||
496 | /// <summary> | ||
497 | /// Loads the terrain map. | ||
498 | /// </summary> | ||
499 | /// <param name="regionID">regionID.</param> | ||
500 | /// <returns></returns> | ||
501 | public double[,] LoadTerrain(UUID regionID) | ||
502 | { | 143 | { |
503 | double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | 144 | List<RegionData> retList = new List<RegionData>(); |
504 | terrain.Initialize(); | ||
505 | 145 | ||
506 | string sql = "select top 1 RegionUUID, Revision, Heightfield from terrain where RegionUUID = @RegionUUID order by Revision desc"; | 146 | SqlDataReader result = cmd.ExecuteReader(); |
507 | 147 | ||
508 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | 148 | while (result.Read()) |
509 | { | 149 | { |
510 | // MySqlParameter param = new MySqlParameter(); | 150 | RegionData ret = new RegionData(); |
511 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | 151 | ret.Data = new Dictionary<string, object>(); |
512 | 152 | ||
513 | using (SqlDataReader reader = cmd.ExecuteReader()) | 153 | UUID regionID; |
154 | UUID.TryParse(result["uuid"].ToString(), out regionID); | ||
155 | ret.RegionID = regionID; | ||
156 | UUID scope; | ||
157 | UUID.TryParse(result["ScopeID"].ToString(), out scope); | ||
158 | ret.ScopeID = scope; | ||
159 | ret.RegionName = result["regionName"].ToString(); | ||
160 | ret.posX = Convert.ToInt32(result["locX"]); | ||
161 | ret.posY = Convert.ToInt32(result["locY"]); | ||
162 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | ||
163 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | ||
164 | |||
165 | if (m_ColumnNames == null) | ||
514 | { | 166 | { |
515 | int rev; | 167 | m_ColumnNames = new List<string>(); |
516 | if (reader.Read()) | ||
517 | { | ||
518 | MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]); | ||
519 | BinaryReader br = new BinaryReader(str); | ||
520 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
521 | { | ||
522 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
523 | { | ||
524 | terrain[x, y] = br.ReadDouble(); | ||
525 | } | ||
526 | } | ||
527 | rev = (int)reader["Revision"]; | ||
528 | } | ||
529 | else | ||
530 | { | ||
531 | _Log.Info("[REGION DB]: No terrain found for region"); | ||
532 | return null; | ||
533 | } | ||
534 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); | ||
535 | } | ||
536 | } | ||
537 | |||
538 | return terrain; | ||
539 | } | ||
540 | 168 | ||
541 | /// <summary> | 169 | DataTable schemaTable = result.GetSchemaTable(); |
542 | /// Stores the terrain map to DB. | 170 | foreach (DataRow row in schemaTable.Rows) |
543 | /// </summary> | 171 | m_ColumnNames.Add(row["ColumnName"].ToString()); |
544 | /// <param name="terrain">terrain map data.</param> | ||
545 | /// <param name="regionID">regionID.</param> | ||
546 | public void StoreTerrain(double[,] terrain, UUID regionID) | ||
547 | { | ||
548 | int revision = Util.UnixTimeSinceEpoch(); | ||
549 | |||
550 | //Delete old terrain map | ||
551 | string sql = "delete from terrain where RegionUUID=@RegionUUID"; | ||
552 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
553 | { | ||
554 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
555 | cmd.ExecuteNonQuery(); | ||
556 | } | ||
557 | |||
558 | sql = "insert into terrain(RegionUUID, Revision, Heightfield) values(@RegionUUID, @Revision, @Heightfield)"; | ||
559 | |||
560 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
561 | { | ||
562 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
563 | cmd.Parameters.Add(_Database.CreateParameter("@Revision", revision)); | ||
564 | cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", serializeTerrain(terrain))); | ||
565 | cmd.ExecuteNonQuery(); | ||
566 | } | ||
567 | |||
568 | _Log.Info("[REGION DB]: Stored terrain revision r " + revision); | ||
569 | } | ||
570 | |||
571 | /// <summary> | ||
572 | /// Loads all the land objects of a region. | ||
573 | /// </summary> | ||
574 | /// <param name="regionUUID">The region UUID.</param> | ||
575 | /// <returns></returns> | ||
576 | public List<LandData> LoadLandObjects(UUID regionUUID) | ||
577 | { | ||
578 | List<LandData> landDataForRegion = new List<LandData>(); | ||
579 | |||
580 | string sql = "select * from land where RegionUUID = @RegionUUID"; | ||
581 | |||
582 | //Retrieve all land data from region | ||
583 | using (AutoClosingSqlCommand cmdLandData = _Database.Query(sql)) | ||
584 | { | ||
585 | cmdLandData.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionUUID)); | ||
586 | |||
587 | using (SqlDataReader readerLandData = cmdLandData.ExecuteReader()) | ||
588 | { | ||
589 | while (readerLandData.Read()) | ||
590 | { | ||
591 | landDataForRegion.Add(BuildLandData(readerLandData)); | ||
592 | } | ||
593 | } | 172 | } |
594 | } | ||
595 | 173 | ||
596 | //Retrieve all accesslist data for all landdata | 174 | foreach (string s in m_ColumnNames) |
597 | foreach (LandData landData in landDataForRegion) | ||
598 | { | ||
599 | sql = "select * from landaccesslist where LandUUID = @LandUUID"; | ||
600 | using (AutoClosingSqlCommand cmdAccessList = _Database.Query(sql)) | ||
601 | { | 175 | { |
602 | cmdAccessList.Parameters.Add(_Database.CreateParameter("@LandUUID", landData.GlobalID)); | 176 | if (s == "uuid") |
603 | using (SqlDataReader readerAccessList = cmdAccessList.ExecuteReader()) | 177 | continue; |
604 | { | 178 | if (s == "ScopeID") |
605 | while (readerAccessList.Read()) | 179 | continue; |
606 | { | 180 | if (s == "regionName") |
607 | landData.ParcelAccessList.Add(BuildLandAccessData(readerAccessList)); | 181 | continue; |
608 | } | 182 | if (s == "locX") |
609 | } | 183 | continue; |
184 | if (s == "locY") | ||
185 | continue; | ||
186 | |||
187 | ret.Data[s] = result[s].ToString(); | ||
610 | } | 188 | } |
611 | } | ||
612 | 189 | ||
613 | //Return data | 190 | retList.Add(ret); |
614 | return landDataForRegion; | 191 | } |
192 | return retList; | ||
615 | } | 193 | } |
616 | 194 | ||
617 | /// <summary> | 195 | public bool Store(RegionData data) |
618 | /// Stores land object with landaccess list. | ||
619 | /// </summary> | ||
620 | /// <param name="parcel">parcel data.</param> | ||
621 | public void StoreLandObject(ILandObject parcel) | ||
622 | { | 196 | { |
623 | //As this is only one record in land table I just delete all and then add a new record. | 197 | if (data.Data.ContainsKey("uuid")) |
624 | //As the delete landaccess is already in the mysql code | 198 | data.Data.Remove("uuid"); |
625 | 199 | if (data.Data.ContainsKey("ScopeID")) | |
626 | //Delete old values | 200 | data.Data.Remove("ScopeID"); |
627 | RemoveLandObject(parcel.LandData.GlobalID); | 201 | if (data.Data.ContainsKey("regionName")) |
628 | 202 | data.Data.Remove("regionName"); | |
629 | //Insert new values | 203 | if (data.Data.ContainsKey("posX")) |
630 | string sql = @"INSERT INTO [land] | 204 | data.Data.Remove("posX"); |
631 | ([UUID],[RegionUUID],[LocalLandID],[Bitmap],[Name],[Description],[OwnerUUID],[IsGroupOwned],[Area],[AuctionID],[Category],[ClaimDate],[ClaimPrice],[GroupUUID],[SalePrice],[LandStatus],[LandFlags],[LandingType],[MediaAutoScale],[MediaTextureUUID],[MediaURL],[MusicURL],[PassHours],[PassPrice],[SnapshotUUID],[UserLocationX],[UserLocationY],[UserLocationZ],[UserLookAtX],[UserLookAtY],[UserLookAtZ],[AuthbuyerID],[OtherCleanTime],[Dwell]) | 205 | if (data.Data.ContainsKey("posY")) |
632 | VALUES | 206 | data.Data.Remove("posY"); |
633 | (@UUID,@RegionUUID,@LocalLandID,@Bitmap,@Name,@Description,@OwnerUUID,@IsGroupOwned,@Area,@AuctionID,@Category,@ClaimDate,@ClaimPrice,@GroupUUID,@SalePrice,@LandStatus,@LandFlags,@LandingType,@MediaAutoScale,@MediaTextureUUID,@MediaURL,@MusicURL,@PassHours,@PassPrice,@SnapshotUUID,@UserLocationX,@UserLocationY,@UserLocationZ,@UserLookAtX,@UserLookAtY,@UserLookAtZ,@AuthbuyerID,@OtherCleanTime,@Dwell)"; | 207 | if (data.Data.ContainsKey("sizeX")) |
634 | 208 | data.Data.Remove("sizeX"); | |
635 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | 209 | if (data.Data.ContainsKey("sizeY")) |
210 | data.Data.Remove("sizeY"); | ||
211 | if (data.Data.ContainsKey("locX")) | ||
212 | data.Data.Remove("locX"); | ||
213 | if (data.Data.ContainsKey("locY")) | ||
214 | data.Data.Remove("locY"); | ||
215 | |||
216 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | ||
217 | |||
218 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | ||
219 | using (SqlCommand cmd = new SqlCommand()) | ||
636 | { | 220 | { |
637 | cmd.Parameters.AddRange(CreateLandParameters(parcel.LandData, parcel.RegionUUID)); | ||
638 | |||
639 | cmd.ExecuteNonQuery(); | ||
640 | } | ||
641 | |||
642 | sql = "INSERT INTO [landaccesslist] ([LandUUID],[AccessUUID],[Flags]) VALUES (@LandUUID,@AccessUUID,@Flags)"; | ||
643 | 221 | ||
644 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | 222 | string update = "update [" + m_Realm + "] set locX=@posX, locY=@posY, sizeX=@sizeX, sizeY=@sizeY "; |
645 | { | 223 | |
646 | foreach (ParcelManager.ParcelAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) | 224 | foreach (string field in fields) |
647 | { | 225 | { |
648 | cmd.Parameters.AddRange(CreateLandAccessParameters(parcelAccessEntry, parcel.RegionUUID)); | ||
649 | |||
650 | cmd.ExecuteNonQuery(); | ||
651 | cmd.Parameters.Clear(); | ||
652 | } | ||
653 | } | ||
654 | } | ||
655 | 226 | ||
656 | /// <summary> | 227 | update += ", "; |
657 | /// Removes a land object from DB. | 228 | update += "[" + field + "] = @" + field; |
658 | /// </summary> | ||
659 | /// <param name="globalID">UUID of landobject</param> | ||
660 | public void RemoveLandObject(UUID globalID) | ||
661 | { | ||
662 | using (AutoClosingSqlCommand cmd = _Database.Query("delete from land where UUID=@UUID")) | ||
663 | { | ||
664 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | ||
665 | cmd.ExecuteNonQuery(); | ||
666 | } | ||
667 | 229 | ||
668 | using (AutoClosingSqlCommand cmd = _Database.Query("delete from landaccesslist where LandUUID=@UUID")) | 230 | cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field])); |
669 | { | 231 | } |
670 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | ||
671 | cmd.ExecuteNonQuery(); | ||
672 | } | ||
673 | } | ||
674 | 232 | ||
675 | /// <summary> | 233 | update += " where uuid = @regionID"; |
676 | /// Loads the settings of a region. | 234 | |
677 | /// </summary> | 235 | if (data.ScopeID != UUID.Zero) |
678 | /// <param name="regionUUID">The region UUID.</param> | 236 | update += " and ScopeID = @scopeID"; |
679 | /// <returns></returns> | 237 | |
680 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 238 | cmd.CommandText = update; |
681 | { | 239 | cmd.Connection = conn; |
682 | string sql = "select * from regionsettings where regionUUID = @regionUUID"; | 240 | cmd.Parameters.Add(m_database.CreateParameter("@regionID", data.RegionID)); |
683 | RegionSettings regionSettings; | 241 | cmd.Parameters.Add(m_database.CreateParameter("@regionName", data.RegionName)); |
684 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | 242 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID)); |
685 | { | 243 | cmd.Parameters.Add(m_database.CreateParameter("@posX", data.posX)); |
686 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | 244 | cmd.Parameters.Add(m_database.CreateParameter("@posY", data.posY)); |
687 | using (SqlDataReader reader = cmd.ExecuteReader()) | 245 | cmd.Parameters.Add(m_database.CreateParameter("@sizeX", data.sizeX)); |
246 | cmd.Parameters.Add(m_database.CreateParameter("@sizeY", data.sizeY)); | ||
247 | conn.Open(); | ||
248 | try | ||
688 | { | 249 | { |
689 | if (reader.Read()) | 250 | if (cmd.ExecuteNonQuery() < 1) |
690 | { | 251 | { |
691 | regionSettings = BuildRegionSettings(reader); | 252 | string insert = "insert into [" + m_Realm + "] ([uuid], [ScopeID], [locX], [locY], [sizeX], [sizeY], [regionName], [" + |
692 | regionSettings.OnSave += StoreRegionSettings; | 253 | String.Join("], [", fields) + |
254 | "]) values ( @regionID, @scopeID, @posX, @posY, @sizeX, @sizeY, @regionName, @" + String.Join(", @", fields) + ")"; | ||
255 | |||
256 | cmd.CommandText = insert; | ||
693 | 257 | ||
694 | return regionSettings; | 258 | try |
259 | { | ||
260 | if (cmd.ExecuteNonQuery() < 1) | ||
261 | { | ||
262 | return false; | ||
263 | } | ||
264 | } | ||
265 | catch (Exception ex) | ||
266 | { | ||
267 | m_log.Warn("[MSSQL Grid]: Error inserting into Regions table: " + ex.Message + ", INSERT sql: " + insert); | ||
268 | } | ||
695 | } | 269 | } |
696 | } | 270 | } |
697 | } | 271 | catch (Exception ex) |
698 | |||
699 | //If comes here then there is now region setting for that region | ||
700 | regionSettings = new RegionSettings(); | ||
701 | regionSettings.RegionUUID = regionUUID; | ||
702 | regionSettings.OnSave += StoreRegionSettings; | ||
703 | |||
704 | //Store new values | ||
705 | StoreNewRegionSettings(regionSettings); | ||
706 | |||
707 | return regionSettings; | ||
708 | } | ||
709 | |||
710 | /// <summary> | ||
711 | /// Store region settings, need to check if the check is really necesary. If we can make something for creating new region. | ||
712 | /// </summary> | ||
713 | /// <param name="regionSettings">region settings.</param> | ||
714 | public void StoreRegionSettings(RegionSettings regionSettings) | ||
715 | { | ||
716 | //Little check if regionUUID already exist in DB | ||
717 | string regionUUID; | ||
718 | using (AutoClosingSqlCommand cmd = _Database.Query("SELECT regionUUID FROM regionsettings WHERE regionUUID = @regionUUID")) | ||
719 | { | ||
720 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionSettings.RegionUUID)); | ||
721 | regionUUID = cmd.ExecuteScalar().ToString(); | ||
722 | } | ||
723 | |||
724 | if (string.IsNullOrEmpty(regionUUID)) | ||
725 | { | ||
726 | StoreNewRegionSettings(regionSettings); | ||
727 | } | ||
728 | else | ||
729 | { | ||
730 | //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB | ||
731 | string sql = | ||
732 | @"UPDATE [regionsettings] SET [block_terraform] = @block_terraform ,[block_fly] = @block_fly ,[allow_damage] = @allow_damage | ||
733 | ,[restrict_pushing] = @restrict_pushing ,[allow_land_resell] = @allow_land_resell ,[allow_land_join_divide] = @allow_land_join_divide | ||
734 | ,[block_show_in_search] = @block_show_in_search ,[agent_limit] = @agent_limit ,[object_bonus] = @object_bonus ,[maturity] = @maturity | ||
735 | ,[disable_scripts] = @disable_scripts ,[disable_collisions] = @disable_collisions ,[disable_physics] = @disable_physics | ||
736 | ,[terrain_texture_1] = @terrain_texture_1 ,[terrain_texture_2] = @terrain_texture_2 ,[terrain_texture_3] = @terrain_texture_3 | ||
737 | ,[terrain_texture_4] = @terrain_texture_4 ,[elevation_1_nw] = @elevation_1_nw ,[elevation_2_nw] = @elevation_2_nw | ||
738 | ,[elevation_1_ne] = @elevation_1_ne ,[elevation_2_ne] = @elevation_2_ne ,[elevation_1_se] = @elevation_1_se ,[elevation_2_se] = @elevation_2_se | ||
739 | ,[elevation_1_sw] = @elevation_1_sw ,[elevation_2_sw] = @elevation_2_sw ,[water_height] = @water_height ,[terrain_raise_limit] = @terrain_raise_limit | ||
740 | ,[terrain_lower_limit] = @terrain_lower_limit ,[use_estate_sun] = @use_estate_sun ,[fixed_sun] = @fixed_sun ,[sun_position] = @sun_position | ||
741 | ,[covenant] = @covenant , [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_datetime] = @loaded_creation_datetime, [loaded_creation_id] = @loaded_creation_id | ||
742 | WHERE [regionUUID] = @regionUUID"; | ||
743 | |||
744 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
745 | { | 272 | { |
746 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | 273 | m_log.Warn("[MSSQL Grid]: Error updating Regions table: " + ex.Message + ", UPDATE sql: " + update); |
747 | |||
748 | cmd.ExecuteNonQuery(); | ||
749 | } | 274 | } |
750 | } | 275 | } |
751 | } | ||
752 | |||
753 | public void Shutdown() | ||
754 | { | ||
755 | //Not used?? | ||
756 | } | ||
757 | |||
758 | #region Private Methods | ||
759 | |||
760 | /// <summary> | ||
761 | /// Serializes the terrain data for storage in DB. | ||
762 | /// </summary> | ||
763 | /// <param name="val">terrain data</param> | ||
764 | /// <returns></returns> | ||
765 | private static Array serializeTerrain(double[,] val) | ||
766 | { | ||
767 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double)); | ||
768 | BinaryWriter bw = new BinaryWriter(str); | ||
769 | |||
770 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
771 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
772 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
773 | { | ||
774 | double height = val[x, y]; | ||
775 | if (height == 0.0) | ||
776 | height = double.Epsilon; | ||
777 | 276 | ||
778 | bw.Write(height); | 277 | return true; |
779 | } | ||
780 | |||
781 | return str.ToArray(); | ||
782 | } | 278 | } |
783 | 279 | ||
784 | /// <summary> | 280 | public bool SetDataItem(UUID regionID, string item, string value) |
785 | /// Stores new regionsettings. | ||
786 | /// </summary> | ||
787 | /// <param name="regionSettings">The region settings.</param> | ||
788 | private void StoreNewRegionSettings(RegionSettings regionSettings) | ||
789 | { | 281 | { |
790 | string sql = @"INSERT INTO [regionsettings] | 282 | string sql = "update [" + m_Realm + |
791 | ([regionUUID],[block_terraform],[block_fly],[allow_damage],[restrict_pushing],[allow_land_resell],[allow_land_join_divide], | 283 | "] set [" + item + "] = @" + item + " where uuid = @UUID"; |
792 | [block_show_in_search],[agent_limit],[object_bonus],[maturity],[disable_scripts],[disable_collisions],[disable_physics], | 284 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
793 | [terrain_texture_1],[terrain_texture_2],[terrain_texture_3],[terrain_texture_4],[elevation_1_nw],[elevation_2_nw],[elevation_1_ne], | 285 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
794 | [elevation_2_ne],[elevation_1_se],[elevation_2_se],[elevation_1_sw],[elevation_2_sw],[water_height],[terrain_raise_limit], | ||
795 | [terrain_lower_limit],[use_estate_sun],[fixed_sun],[sun_position],[covenant],[sunvectorx], [sunvectory], [sunvectorz],[Sandbox], [loaded_creation_datetime], [loaded_creation_id] | ||
796 | ) | ||
797 | VALUES | ||
798 | (@regionUUID,@block_terraform,@block_fly,@allow_damage,@restrict_pushing,@allow_land_resell,@allow_land_join_divide, | ||
799 | @block_show_in_search,@agent_limit,@object_bonus,@maturity,@disable_scripts,@disable_collisions,@disable_physics, | ||
800 | @terrain_texture_1,@terrain_texture_2,@terrain_texture_3,@terrain_texture_4,@elevation_1_nw,@elevation_2_nw,@elevation_1_ne, | ||
801 | @elevation_2_ne,@elevation_1_se,@elevation_2_se,@elevation_1_sw,@elevation_2_sw,@water_height,@terrain_raise_limit, | ||
802 | @terrain_lower_limit,@use_estate_sun,@fixed_sun,@sun_position,@covenant,@sunvectorx,@sunvectory, @sunvectorz, @Sandbox, @loaded_creation_datetime, @loaded_creation_id)"; | ||
803 | |||
804 | using (AutoClosingSqlCommand cmd = _Database.Query(sql)) | ||
805 | { | 286 | { |
806 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | 287 | cmd.Parameters.Add(m_database.CreateParameter("@" + item, value)); |
807 | cmd.ExecuteNonQuery(); | 288 | cmd.Parameters.Add(m_database.CreateParameter("@UUID", regionID)); |
289 | conn.Open(); | ||
290 | if (cmd.ExecuteNonQuery() > 0) | ||
291 | return true; | ||
808 | } | 292 | } |
293 | return false; | ||
809 | } | 294 | } |
810 | 295 | ||
811 | #region Private DataRecord conversion methods | 296 | public bool Delete(UUID regionID) |
812 | |||
813 | /// <summary> | ||
814 | /// Builds the region settings from a datarecod. | ||
815 | /// </summary> | ||
816 | /// <param name="row">datarecord with regionsettings.</param> | ||
817 | /// <returns></returns> | ||
818 | private static RegionSettings BuildRegionSettings(IDataRecord row) | ||
819 | { | 297 | { |
820 | //TODO change this is some more generic code so we doesnt have to change it every time a new field is added? | 298 | string sql = "delete from [" + m_Realm + |
821 | RegionSettings newSettings = new RegionSettings(); | 299 | "] where uuid = @UUID"; |
822 | 300 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | |
823 | newSettings.RegionUUID = new UUID((Guid)row["regionUUID"]); | 301 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
824 | newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); | ||
825 | newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); | ||
826 | newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); | ||
827 | newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); | ||
828 | newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); | ||
829 | newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); | ||
830 | newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); | ||
831 | newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); | ||
832 | newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); | ||
833 | newSettings.Maturity = Convert.ToInt32(row["maturity"]); | ||
834 | newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); | ||
835 | newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); | ||
836 | newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); | ||
837 | newSettings.TerrainTexture1 = new UUID((Guid)row["terrain_texture_1"]); | ||
838 | newSettings.TerrainTexture2 = new UUID((Guid)row["terrain_texture_2"]); | ||
839 | newSettings.TerrainTexture3 = new UUID((Guid)row["terrain_texture_3"]); | ||
840 | newSettings.TerrainTexture4 = new UUID((Guid)row["terrain_texture_4"]); | ||
841 | newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); | ||
842 | newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); | ||
843 | newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); | ||
844 | newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); | ||
845 | newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); | ||
846 | newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); | ||
847 | newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); | ||
848 | newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); | ||
849 | newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); | ||
850 | newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); | ||
851 | newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); | ||
852 | newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); | ||
853 | newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); | ||
854 | newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); | ||
855 | newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); | ||
856 | newSettings.SunVector = new Vector3( | ||
857 | Convert.ToSingle(row["sunvectorx"]), | ||
858 | Convert.ToSingle(row["sunvectory"]), | ||
859 | Convert.ToSingle(row["sunvectorz"]) | ||
860 | ); | ||
861 | newSettings.Covenant = new UUID((Guid)row["covenant"]); | ||
862 | |||
863 | newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); | ||
864 | |||
865 | if (row["loaded_creation_id"] is DBNull) | ||
866 | newSettings.LoadedCreationID = ""; | ||
867 | else | ||
868 | newSettings.LoadedCreationID = (String)row["loaded_creation_id"]; | ||
869 | return newSettings; | ||
870 | } | ||
871 | |||
872 | /// <summary> | ||
873 | /// Builds the land data from a datarecord. | ||
874 | /// </summary> | ||
875 | /// <param name="row">datarecord with land data</param> | ||
876 | /// <returns></returns> | ||
877 | private static LandData BuildLandData(IDataRecord row) | ||
878 | { | ||
879 | LandData newData = new LandData(); | ||
880 | |||
881 | newData.GlobalID = new UUID((Guid)row["UUID"]); | ||
882 | newData.LocalID = Convert.ToInt32(row["LocalLandID"]); | ||
883 | |||
884 | // Bitmap is a byte[512] | ||
885 | newData.Bitmap = (Byte[])row["Bitmap"]; | ||
886 | |||
887 | newData.Name = (string)row["Name"]; | ||
888 | newData.Description = (string)row["Description"]; | ||
889 | newData.OwnerID = new UUID((Guid)row["OwnerUUID"]); | ||
890 | newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); | ||
891 | newData.Area = Convert.ToInt32(row["Area"]); | ||
892 | newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented | ||
893 | newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]); | ||
894 | //Enum libsecondlife.Parcel.ParcelCategory | ||
895 | newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); | ||
896 | newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); | ||
897 | newData.GroupID = new UUID((Guid)row["GroupUUID"]); | ||
898 | newData.SalePrice = Convert.ToInt32(row["SalePrice"]); | ||
899 | newData.Status = (ParcelStatus)Convert.ToInt32(row["LandStatus"]); | ||
900 | //Enum. libsecondlife.Parcel.ParcelStatus | ||
901 | newData.Flags = Convert.ToUInt32(row["LandFlags"]); | ||
902 | newData.LandingType = Convert.ToByte(row["LandingType"]); | ||
903 | newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); | ||
904 | newData.MediaID = new UUID((Guid)row["MediaTextureUUID"]); | ||
905 | newData.MediaURL = (string)row["MediaURL"]; | ||
906 | newData.MusicURL = (string)row["MusicURL"]; | ||
907 | newData.PassHours = Convert.ToSingle(row["PassHours"]); | ||
908 | newData.PassPrice = Convert.ToInt32(row["PassPrice"]); | ||
909 | |||
910 | // UUID authedbuyer; | ||
911 | // UUID snapshotID; | ||
912 | // | ||
913 | // if (UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer)) | ||
914 | // newData.AuthBuyerID = authedbuyer; | ||
915 | // | ||
916 | // if (UUID.TryParse((string)row["SnapshotUUID"], out snapshotID)) | ||
917 | // newData.SnapshotID = snapshotID; | ||
918 | newData.AuthBuyerID = new UUID((Guid) row["AuthBuyerID"]); | ||
919 | newData.SnapshotID = new UUID((Guid)row["SnapshotUUID"]); | ||
920 | |||
921 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); | ||
922 | newData.Dwell = Convert.ToInt32(row["Dwell"]); | ||
923 | |||
924 | try | ||
925 | { | 302 | { |
926 | newData.UserLocation = | 303 | cmd.Parameters.Add(m_database.CreateParameter("@UUID", regionID)); |
927 | new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), | 304 | conn.Open(); |
928 | Convert.ToSingle(row["UserLocationZ"])); | 305 | if (cmd.ExecuteNonQuery() > 0) |
929 | newData.UserLookAt = | 306 | return true; |
930 | new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), | ||
931 | Convert.ToSingle(row["UserLookAtZ"])); | ||
932 | } | 307 | } |
933 | catch (InvalidCastException) | 308 | return false; |
934 | { | ||
935 | newData.UserLocation = Vector3.Zero; | ||
936 | newData.UserLookAt = Vector3.Zero; | ||
937 | _Log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); | ||
938 | } | ||
939 | |||
940 | newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); | ||
941 | |||
942 | return newData; | ||
943 | } | ||
944 | |||
945 | /// <summary> | ||
946 | /// Builds the landaccess data from a data record. | ||
947 | /// </summary> | ||
948 | /// <param name="row">datarecord with landaccess data</param> | ||
949 | /// <returns></returns> | ||
950 | private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataRecord row) | ||
951 | { | ||
952 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
953 | entry.AgentID = new UUID((Guid)row["AccessUUID"]); | ||
954 | entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]); | ||
955 | entry.Time = new DateTime(); | ||
956 | return entry; | ||
957 | } | 309 | } |
958 | |||
959 | /// <summary> | ||
960 | /// Builds the prim from a datarecord. | ||
961 | /// </summary> | ||
962 | /// <param name="primRow">datarecord</param> | ||
963 | /// <returns></returns> | ||
964 | private static SceneObjectPart BuildPrim(IDataRecord primRow) | ||
965 | { | ||
966 | SceneObjectPart prim = new SceneObjectPart(); | ||
967 | |||
968 | prim.UUID = new UUID((Guid)primRow["UUID"]); | ||
969 | // explicit conversion of integers is required, which sort | ||
970 | // of sucks. No idea if there is a shortcut here or not. | ||
971 | prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]); | ||
972 | prim.Name = (string)primRow["Name"]; | ||
973 | // various text fields | ||
974 | prim.Text = (string)primRow["Text"]; | ||
975 | prim.Color = Color.FromArgb(Convert.ToInt32(primRow["ColorA"]), | ||
976 | Convert.ToInt32(primRow["ColorR"]), | ||
977 | Convert.ToInt32(primRow["ColorG"]), | ||
978 | Convert.ToInt32(primRow["ColorB"])); | ||
979 | prim.Description = (string)primRow["Description"]; | ||
980 | prim.SitName = (string)primRow["SitName"]; | ||
981 | prim.TouchName = (string)primRow["TouchName"]; | ||
982 | // permissions | ||
983 | prim.ObjectFlags = Convert.ToUInt32(primRow["ObjectFlags"]); | ||
984 | prim.CreatorID = new UUID((Guid)primRow["CreatorID"]); | ||
985 | prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); | ||
986 | prim.GroupID = new UUID((Guid)primRow["GroupID"]); | ||
987 | prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); | ||
988 | prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]); | ||
989 | prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]); | ||
990 | prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]); | ||
991 | prim.EveryoneMask = Convert.ToUInt32(primRow["EveryoneMask"]); | ||
992 | prim.BaseMask = Convert.ToUInt32(primRow["BaseMask"]); | ||
993 | // vectors | ||
994 | prim.OffsetPosition = new Vector3( | ||
995 | Convert.ToSingle(primRow["PositionX"]), | ||
996 | Convert.ToSingle(primRow["PositionY"]), | ||
997 | Convert.ToSingle(primRow["PositionZ"])); | ||
998 | |||
999 | prim.GroupPosition = new Vector3( | ||
1000 | Convert.ToSingle(primRow["GroupPositionX"]), | ||
1001 | Convert.ToSingle(primRow["GroupPositionY"]), | ||
1002 | Convert.ToSingle(primRow["GroupPositionZ"])); | ||
1003 | |||
1004 | prim.Velocity = new Vector3( | ||
1005 | Convert.ToSingle(primRow["VelocityX"]), | ||
1006 | Convert.ToSingle(primRow["VelocityY"]), | ||
1007 | Convert.ToSingle(primRow["VelocityZ"])); | ||
1008 | |||
1009 | prim.AngularVelocity = new Vector3( | ||
1010 | Convert.ToSingle(primRow["AngularVelocityX"]), | ||
1011 | Convert.ToSingle(primRow["AngularVelocityY"]), | ||
1012 | Convert.ToSingle(primRow["AngularVelocityZ"])); | ||
1013 | |||
1014 | prim.Acceleration = new Vector3( | ||
1015 | Convert.ToSingle(primRow["AccelerationX"]), | ||
1016 | Convert.ToSingle(primRow["AccelerationY"]), | ||
1017 | Convert.ToSingle(primRow["AccelerationZ"])); | ||
1018 | |||
1019 | // quaternions | ||
1020 | prim.RotationOffset = new Quaternion( | ||
1021 | Convert.ToSingle(primRow["RotationX"]), | ||
1022 | Convert.ToSingle(primRow["RotationY"]), | ||
1023 | Convert.ToSingle(primRow["RotationZ"]), | ||
1024 | Convert.ToSingle(primRow["RotationW"])); | ||
1025 | |||
1026 | prim.SitTargetPositionLL = new Vector3( | ||
1027 | Convert.ToSingle(primRow["SitTargetOffsetX"]), | ||
1028 | Convert.ToSingle(primRow["SitTargetOffsetY"]), | ||
1029 | Convert.ToSingle(primRow["SitTargetOffsetZ"])); | ||
1030 | |||
1031 | prim.SitTargetOrientationLL = new Quaternion( | ||
1032 | Convert.ToSingle(primRow["SitTargetOrientX"]), | ||
1033 | Convert.ToSingle(primRow["SitTargetOrientY"]), | ||
1034 | Convert.ToSingle(primRow["SitTargetOrientZ"]), | ||
1035 | Convert.ToSingle(primRow["SitTargetOrientW"])); | ||
1036 | |||
1037 | prim.PayPrice[0] = Convert.ToInt32(primRow["PayPrice"]); | ||
1038 | prim.PayPrice[1] = Convert.ToInt32(primRow["PayButton1"]); | ||
1039 | prim.PayPrice[2] = Convert.ToInt32(primRow["PayButton2"]); | ||
1040 | prim.PayPrice[3] = Convert.ToInt32(primRow["PayButton3"]); | ||
1041 | prim.PayPrice[4] = Convert.ToInt32(primRow["PayButton4"]); | ||
1042 | |||
1043 | prim.Sound = new UUID((Guid)primRow["LoopedSound"]); | ||
1044 | prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]); | ||
1045 | prim.SoundFlags = 1; // If it's persisted at all, it's looped | ||
1046 | |||
1047 | if (!(primRow["TextureAnimation"] is DBNull)) | ||
1048 | prim.TextureAnimation = (Byte[])primRow["TextureAnimation"]; | ||
1049 | if (!(primRow["ParticleSystem"] is DBNull)) | ||
1050 | prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; | ||
1051 | |||
1052 | prim.RotationalVelocity = new Vector3( | ||
1053 | Convert.ToSingle(primRow["OmegaX"]), | ||
1054 | Convert.ToSingle(primRow["OmegaY"]), | ||
1055 | Convert.ToSingle(primRow["OmegaZ"])); | ||
1056 | |||
1057 | prim.SetCameraEyeOffset(new Vector3( | ||
1058 | Convert.ToSingle(primRow["CameraEyeOffsetX"]), | ||
1059 | Convert.ToSingle(primRow["CameraEyeOffsetY"]), | ||
1060 | Convert.ToSingle(primRow["CameraEyeOffsetZ"]) | ||
1061 | )); | ||
1062 | |||
1063 | prim.SetCameraAtOffset(new Vector3( | ||
1064 | Convert.ToSingle(primRow["CameraAtOffsetX"]), | ||
1065 | Convert.ToSingle(primRow["CameraAtOffsetY"]), | ||
1066 | Convert.ToSingle(primRow["CameraAtOffsetZ"]) | ||
1067 | )); | ||
1068 | |||
1069 | if (Convert.ToInt16(primRow["ForceMouselook"]) != 0) | ||
1070 | prim.SetForceMouselook(true); | ||
1071 | |||
1072 | prim.ScriptAccessPin = Convert.ToInt32(primRow["ScriptAccessPin"]); | ||
1073 | |||
1074 | if (Convert.ToInt16(primRow["AllowedDrop"]) != 0) | ||
1075 | prim.AllowedDrop = true; | ||
1076 | |||
1077 | if (Convert.ToInt16(primRow["DieAtEdge"]) != 0) | ||
1078 | prim.DIE_AT_EDGE = true; | ||
1079 | |||
1080 | prim.SalePrice = Convert.ToInt32(primRow["SalePrice"]); | ||
1081 | prim.ObjectSaleType = Convert.ToByte(primRow["SaleType"]); | ||
1082 | |||
1083 | prim.Material = Convert.ToByte(primRow["Material"]); | ||
1084 | |||
1085 | if (!(primRow["ClickAction"] is DBNull)) | ||
1086 | prim.ClickAction = Convert.ToByte(primRow["ClickAction"]); | ||
1087 | |||
1088 | prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]); | ||
1089 | prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); | ||
1090 | if (Convert.ToInt16(primRow["PassTouches"]) != 0) | ||
1091 | prim.PassTouches = true; | ||
1092 | prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]); | ||
1093 | |||
1094 | return prim; | ||
1095 | } | ||
1096 | |||
1097 | /// <summary> | ||
1098 | /// Builds the prim shape from a datarecord. | ||
1099 | /// </summary> | ||
1100 | /// <param name="shapeRow">The row.</param> | ||
1101 | /// <returns></returns> | ||
1102 | private static PrimitiveBaseShape BuildShape(IDataRecord shapeRow) | ||
1103 | { | ||
1104 | PrimitiveBaseShape baseShape = new PrimitiveBaseShape(); | ||
1105 | |||
1106 | baseShape.Scale = new Vector3( | ||
1107 | Convert.ToSingle(shapeRow["ScaleX"]), | ||
1108 | Convert.ToSingle(shapeRow["ScaleY"]), | ||
1109 | Convert.ToSingle(shapeRow["ScaleZ"])); | ||
1110 | |||
1111 | // paths | ||
1112 | baseShape.PCode = Convert.ToByte(shapeRow["PCode"]); | ||
1113 | baseShape.PathBegin = Convert.ToUInt16(shapeRow["PathBegin"]); | ||
1114 | baseShape.PathEnd = Convert.ToUInt16(shapeRow["PathEnd"]); | ||
1115 | baseShape.PathScaleX = Convert.ToByte(shapeRow["PathScaleX"]); | ||
1116 | baseShape.PathScaleY = Convert.ToByte(shapeRow["PathScaleY"]); | ||
1117 | baseShape.PathShearX = Convert.ToByte(shapeRow["PathShearX"]); | ||
1118 | baseShape.PathShearY = Convert.ToByte(shapeRow["PathShearY"]); | ||
1119 | baseShape.PathSkew = Convert.ToSByte(shapeRow["PathSkew"]); | ||
1120 | baseShape.PathCurve = Convert.ToByte(shapeRow["PathCurve"]); | ||
1121 | baseShape.PathRadiusOffset = Convert.ToSByte(shapeRow["PathRadiusOffset"]); | ||
1122 | baseShape.PathRevolutions = Convert.ToByte(shapeRow["PathRevolutions"]); | ||
1123 | baseShape.PathTaperX = Convert.ToSByte(shapeRow["PathTaperX"]); | ||
1124 | baseShape.PathTaperY = Convert.ToSByte(shapeRow["PathTaperY"]); | ||
1125 | baseShape.PathTwist = Convert.ToSByte(shapeRow["PathTwist"]); | ||
1126 | baseShape.PathTwistBegin = Convert.ToSByte(shapeRow["PathTwistBegin"]); | ||
1127 | // profile | ||
1128 | baseShape.ProfileBegin = Convert.ToUInt16(shapeRow["ProfileBegin"]); | ||
1129 | baseShape.ProfileEnd = Convert.ToUInt16(shapeRow["ProfileEnd"]); | ||
1130 | baseShape.ProfileCurve = Convert.ToByte(shapeRow["ProfileCurve"]); | ||
1131 | baseShape.ProfileHollow = Convert.ToUInt16(shapeRow["ProfileHollow"]); | ||
1132 | |||
1133 | byte[] textureEntry = (byte[])shapeRow["Texture"]; | ||
1134 | baseShape.TextureEntry = textureEntry; | ||
1135 | |||
1136 | baseShape.ExtraParams = (byte[])shapeRow["ExtraParams"]; | ||
1137 | |||
1138 | try | ||
1139 | { | ||
1140 | baseShape.State = Convert.ToByte(shapeRow["State"]); | ||
1141 | } | ||
1142 | catch (InvalidCastException) | ||
1143 | { | ||
1144 | } | ||
1145 | |||
1146 | return baseShape; | ||
1147 | } | ||
1148 | |||
1149 | /// <summary> | ||
1150 | /// Build a prim inventory item from the persisted data. | ||
1151 | /// </summary> | ||
1152 | /// <param name="inventoryRow"></param> | ||
1153 | /// <returns></returns> | ||
1154 | private static TaskInventoryItem BuildItem(IDataRecord inventoryRow) | ||
1155 | { | ||
1156 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
1157 | |||
1158 | taskItem.ItemID = new UUID((Guid)inventoryRow["itemID"]); | ||
1159 | taskItem.ParentPartID = new UUID((Guid)inventoryRow["primID"]); | ||
1160 | taskItem.AssetID = new UUID((Guid)inventoryRow["assetID"]); | ||
1161 | taskItem.ParentID = new UUID((Guid)inventoryRow["parentFolderID"]); | ||
1162 | |||
1163 | taskItem.InvType = Convert.ToInt32(inventoryRow["invType"]); | ||
1164 | taskItem.Type = Convert.ToInt32(inventoryRow["assetType"]); | ||
1165 | |||
1166 | taskItem.Name = (string)inventoryRow["name"]; | ||
1167 | taskItem.Description = (string)inventoryRow["description"]; | ||
1168 | taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); | ||
1169 | taskItem.CreatorID = new UUID((Guid)inventoryRow["creatorID"]); | ||
1170 | taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]); | ||
1171 | taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]); | ||
1172 | taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]); | ||
1173 | |||
1174 | taskItem.NextPermissions = Convert.ToUInt32(inventoryRow["nextPermissions"]); | ||
1175 | taskItem.CurrentPermissions = Convert.ToUInt32(inventoryRow["currentPermissions"]); | ||
1176 | taskItem.BasePermissions = Convert.ToUInt32(inventoryRow["basePermissions"]); | ||
1177 | taskItem.EveryonePermissions = Convert.ToUInt32(inventoryRow["everyonePermissions"]); | ||
1178 | taskItem.GroupPermissions = Convert.ToUInt32(inventoryRow["groupPermissions"]); | ||
1179 | taskItem.Flags = Convert.ToUInt32(inventoryRow["flags"]); | ||
1180 | |||
1181 | return taskItem; | ||
1182 | } | ||
1183 | |||
1184 | #endregion | ||
1185 | |||
1186 | #region Create parameters methods | ||
1187 | |||
1188 | /// <summary> | ||
1189 | /// Creates the prim inventory parameters. | ||
1190 | /// </summary> | ||
1191 | /// <param name="taskItem">item in inventory.</param> | ||
1192 | /// <returns></returns> | ||
1193 | private SqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem) | ||
1194 | { | ||
1195 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1196 | |||
1197 | parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID)); | ||
1198 | parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID)); | ||
1199 | parameters.Add(_Database.CreateParameter("assetID", taskItem.AssetID)); | ||
1200 | parameters.Add(_Database.CreateParameter("parentFolderID", taskItem.ParentID)); | ||
1201 | parameters.Add(_Database.CreateParameter("invType", taskItem.InvType)); | ||
1202 | parameters.Add(_Database.CreateParameter("assetType", taskItem.Type)); | ||
1203 | |||
1204 | parameters.Add(_Database.CreateParameter("name", taskItem.Name)); | ||
1205 | parameters.Add(_Database.CreateParameter("description", taskItem.Description)); | ||
1206 | parameters.Add(_Database.CreateParameter("creationDate", taskItem.CreationDate)); | ||
1207 | parameters.Add(_Database.CreateParameter("creatorID", taskItem.CreatorID)); | ||
1208 | parameters.Add(_Database.CreateParameter("ownerID", taskItem.OwnerID)); | ||
1209 | parameters.Add(_Database.CreateParameter("lastOwnerID", taskItem.LastOwnerID)); | ||
1210 | parameters.Add(_Database.CreateParameter("groupID", taskItem.GroupID)); | ||
1211 | parameters.Add(_Database.CreateParameter("nextPermissions", taskItem.NextPermissions)); | ||
1212 | parameters.Add(_Database.CreateParameter("currentPermissions", taskItem.CurrentPermissions)); | ||
1213 | parameters.Add(_Database.CreateParameter("basePermissions", taskItem.BasePermissions)); | ||
1214 | parameters.Add(_Database.CreateParameter("everyonePermissions", taskItem.EveryonePermissions)); | ||
1215 | parameters.Add(_Database.CreateParameter("groupPermissions", taskItem.GroupPermissions)); | ||
1216 | parameters.Add(_Database.CreateParameter("flags", taskItem.Flags)); | ||
1217 | |||
1218 | return parameters.ToArray(); | ||
1219 | } | ||
1220 | |||
1221 | /// <summary> | ||
1222 | /// Creates the region setting parameters. | ||
1223 | /// </summary> | ||
1224 | /// <param name="settings">regionsettings.</param> | ||
1225 | /// <returns></returns> | ||
1226 | private SqlParameter[] CreateRegionSettingParameters(RegionSettings settings) | ||
1227 | { | ||
1228 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1229 | |||
1230 | parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID)); | ||
1231 | parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform)); | ||
1232 | parameters.Add(_Database.CreateParameter("block_fly", settings.BlockFly)); | ||
1233 | parameters.Add(_Database.CreateParameter("allow_damage", settings.AllowDamage)); | ||
1234 | parameters.Add(_Database.CreateParameter("restrict_pushing", settings.RestrictPushing)); | ||
1235 | parameters.Add(_Database.CreateParameter("allow_land_resell", settings.AllowLandResell)); | ||
1236 | parameters.Add(_Database.CreateParameter("allow_land_join_divide", settings.AllowLandJoinDivide)); | ||
1237 | parameters.Add(_Database.CreateParameter("block_show_in_search", settings.BlockShowInSearch)); | ||
1238 | parameters.Add(_Database.CreateParameter("agent_limit", settings.AgentLimit)); | ||
1239 | parameters.Add(_Database.CreateParameter("object_bonus", settings.ObjectBonus)); | ||
1240 | parameters.Add(_Database.CreateParameter("maturity", settings.Maturity)); | ||
1241 | parameters.Add(_Database.CreateParameter("disable_scripts", settings.DisableScripts)); | ||
1242 | parameters.Add(_Database.CreateParameter("disable_collisions", settings.DisableCollisions)); | ||
1243 | parameters.Add(_Database.CreateParameter("disable_physics", settings.DisablePhysics)); | ||
1244 | parameters.Add(_Database.CreateParameter("terrain_texture_1", settings.TerrainTexture1)); | ||
1245 | parameters.Add(_Database.CreateParameter("terrain_texture_2", settings.TerrainTexture2)); | ||
1246 | parameters.Add(_Database.CreateParameter("terrain_texture_3", settings.TerrainTexture3)); | ||
1247 | parameters.Add(_Database.CreateParameter("terrain_texture_4", settings.TerrainTexture4)); | ||
1248 | parameters.Add(_Database.CreateParameter("elevation_1_nw", settings.Elevation1NW)); | ||
1249 | parameters.Add(_Database.CreateParameter("elevation_2_nw", settings.Elevation2NW)); | ||
1250 | parameters.Add(_Database.CreateParameter("elevation_1_ne", settings.Elevation1NE)); | ||
1251 | parameters.Add(_Database.CreateParameter("elevation_2_ne", settings.Elevation2NE)); | ||
1252 | parameters.Add(_Database.CreateParameter("elevation_1_se", settings.Elevation1SE)); | ||
1253 | parameters.Add(_Database.CreateParameter("elevation_2_se", settings.Elevation2SE)); | ||
1254 | parameters.Add(_Database.CreateParameter("elevation_1_sw", settings.Elevation1SW)); | ||
1255 | parameters.Add(_Database.CreateParameter("elevation_2_sw", settings.Elevation2SW)); | ||
1256 | parameters.Add(_Database.CreateParameter("water_height", settings.WaterHeight)); | ||
1257 | parameters.Add(_Database.CreateParameter("terrain_raise_limit", settings.TerrainRaiseLimit)); | ||
1258 | parameters.Add(_Database.CreateParameter("terrain_lower_limit", settings.TerrainLowerLimit)); | ||
1259 | parameters.Add(_Database.CreateParameter("use_estate_sun", settings.UseEstateSun)); | ||
1260 | parameters.Add(_Database.CreateParameter("sandbox", settings.Sandbox)); | ||
1261 | parameters.Add(_Database.CreateParameter("fixed_sun", settings.FixedSun)); | ||
1262 | parameters.Add(_Database.CreateParameter("sun_position", settings.SunPosition)); | ||
1263 | parameters.Add(_Database.CreateParameter("sunvectorx", settings.SunVector.X)); | ||
1264 | parameters.Add(_Database.CreateParameter("sunvectory", settings.SunVector.Y)); | ||
1265 | parameters.Add(_Database.CreateParameter("sunvectorz", settings.SunVector.Z)); | ||
1266 | parameters.Add(_Database.CreateParameter("covenant", settings.Covenant)); | ||
1267 | parameters.Add(_Database.CreateParameter("Loaded_Creation_DateTime", settings.LoadedCreationDateTime)); | ||
1268 | parameters.Add(_Database.CreateParameter("Loaded_Creation_ID", settings.LoadedCreationID)); | ||
1269 | |||
1270 | return parameters.ToArray(); | ||
1271 | } | ||
1272 | |||
1273 | /// <summary> | ||
1274 | /// Creates the land parameters. | ||
1275 | /// </summary> | ||
1276 | /// <param name="land">land parameters.</param> | ||
1277 | /// <param name="regionUUID">region UUID.</param> | ||
1278 | /// <returns></returns> | ||
1279 | private SqlParameter[] CreateLandParameters(LandData land, UUID regionUUID) | ||
1280 | { | ||
1281 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1282 | |||
1283 | parameters.Add(_Database.CreateParameter("UUID", land.GlobalID)); | ||
1284 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | ||
1285 | parameters.Add(_Database.CreateParameter("LocalLandID", land.LocalID)); | ||
1286 | |||
1287 | // Bitmap is a byte[512] | ||
1288 | parameters.Add(_Database.CreateParameter("Bitmap", land.Bitmap)); | ||
1289 | |||
1290 | parameters.Add(_Database.CreateParameter("Name", land.Name)); | ||
1291 | parameters.Add(_Database.CreateParameter("Description", land.Description)); | ||
1292 | parameters.Add(_Database.CreateParameter("OwnerUUID", land.OwnerID)); | ||
1293 | parameters.Add(_Database.CreateParameter("IsGroupOwned", land.IsGroupOwned)); | ||
1294 | parameters.Add(_Database.CreateParameter("Area", land.Area)); | ||
1295 | parameters.Add(_Database.CreateParameter("AuctionID", land.AuctionID)); //Unemplemented | ||
1296 | parameters.Add(_Database.CreateParameter("Category", (int)land.Category)); //Enum libsecondlife.Parcel.ParcelCategory | ||
1297 | parameters.Add(_Database.CreateParameter("ClaimDate", land.ClaimDate)); | ||
1298 | parameters.Add(_Database.CreateParameter("ClaimPrice", land.ClaimPrice)); | ||
1299 | parameters.Add(_Database.CreateParameter("GroupUUID", land.GroupID)); | ||
1300 | parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice)); | ||
1301 | parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus | ||
1302 | parameters.Add(_Database.CreateParameter("LandFlags", land.Flags)); | ||
1303 | parameters.Add(_Database.CreateParameter("LandingType", land.LandingType)); | ||
1304 | parameters.Add(_Database.CreateParameter("MediaAutoScale", land.MediaAutoScale)); | ||
1305 | parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID)); | ||
1306 | parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL)); | ||
1307 | parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL)); | ||
1308 | parameters.Add(_Database.CreateParameter("PassHours", land.PassHours)); | ||
1309 | parameters.Add(_Database.CreateParameter("PassPrice", land.PassPrice)); | ||
1310 | parameters.Add(_Database.CreateParameter("SnapshotUUID", land.SnapshotID)); | ||
1311 | parameters.Add(_Database.CreateParameter("UserLocationX", land.UserLocation.X)); | ||
1312 | parameters.Add(_Database.CreateParameter("UserLocationY", land.UserLocation.Y)); | ||
1313 | parameters.Add(_Database.CreateParameter("UserLocationZ", land.UserLocation.Z)); | ||
1314 | parameters.Add(_Database.CreateParameter("UserLookAtX", land.UserLookAt.X)); | ||
1315 | parameters.Add(_Database.CreateParameter("UserLookAtY", land.UserLookAt.Y)); | ||
1316 | parameters.Add(_Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z)); | ||
1317 | parameters.Add(_Database.CreateParameter("AuthBuyerID", land.AuthBuyerID)); | ||
1318 | parameters.Add(_Database.CreateParameter("OtherCleanTime", land.OtherCleanTime)); | ||
1319 | parameters.Add(_Database.CreateParameter("Dwell", land.Dwell)); | ||
1320 | |||
1321 | return parameters.ToArray(); | ||
1322 | } | ||
1323 | |||
1324 | /// <summary> | ||
1325 | /// Creates the land access parameters. | ||
1326 | /// </summary> | ||
1327 | /// <param name="parcelAccessEntry">parcel access entry.</param> | ||
1328 | /// <param name="parcelID">parcel ID.</param> | ||
1329 | /// <returns></returns> | ||
1330 | private SqlParameter[] CreateLandAccessParameters(ParcelManager.ParcelAccessEntry parcelAccessEntry, UUID parcelID) | ||
1331 | { | ||
1332 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1333 | |||
1334 | parameters.Add(_Database.CreateParameter("LandUUID", parcelID)); | ||
1335 | parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID)); | ||
1336 | parameters.Add(_Database.CreateParameter("Flags", parcelAccessEntry.Flags)); | ||
1337 | |||
1338 | return parameters.ToArray(); | ||
1339 | } | ||
1340 | |||
1341 | /// <summary> | ||
1342 | /// Creates the prim parameters for storing in DB. | ||
1343 | /// </summary> | ||
1344 | /// <param name="prim">Basic data of SceneObjectpart prim.</param> | ||
1345 | /// <param name="sceneGroupID">The scenegroup ID.</param> | ||
1346 | /// <param name="regionUUID">The region ID.</param> | ||
1347 | /// <returns></returns> | ||
1348 | private SqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | ||
1349 | { | ||
1350 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1351 | |||
1352 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | ||
1353 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | ||
1354 | parameters.Add(_Database.CreateParameter("CreationDate", prim.CreationDate)); | ||
1355 | parameters.Add(_Database.CreateParameter("Name", prim.Name)); | ||
1356 | parameters.Add(_Database.CreateParameter("SceneGroupID", sceneGroupID)); | ||
1357 | // the UUID of the root part for this SceneObjectGroup | ||
1358 | // various text fields | ||
1359 | parameters.Add(_Database.CreateParameter("Text", prim.Text)); | ||
1360 | parameters.Add(_Database.CreateParameter("ColorR", prim.Color.R)); | ||
1361 | parameters.Add(_Database.CreateParameter("ColorG", prim.Color.G)); | ||
1362 | parameters.Add(_Database.CreateParameter("ColorB", prim.Color.B)); | ||
1363 | parameters.Add(_Database.CreateParameter("ColorA", prim.Color.A)); | ||
1364 | parameters.Add(_Database.CreateParameter("Description", prim.Description)); | ||
1365 | parameters.Add(_Database.CreateParameter("SitName", prim.SitName)); | ||
1366 | parameters.Add(_Database.CreateParameter("TouchName", prim.TouchName)); | ||
1367 | // permissions | ||
1368 | parameters.Add(_Database.CreateParameter("ObjectFlags", prim.ObjectFlags)); | ||
1369 | parameters.Add(_Database.CreateParameter("CreatorID", prim.CreatorID)); | ||
1370 | parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID)); | ||
1371 | parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID)); | ||
1372 | parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID)); | ||
1373 | parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask)); | ||
1374 | parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask)); | ||
1375 | parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask)); | ||
1376 | parameters.Add(_Database.CreateParameter("EveryoneMask", prim.EveryoneMask)); | ||
1377 | parameters.Add(_Database.CreateParameter("BaseMask", prim.BaseMask)); | ||
1378 | // vectors | ||
1379 | parameters.Add(_Database.CreateParameter("PositionX", prim.OffsetPosition.X)); | ||
1380 | parameters.Add(_Database.CreateParameter("PositionY", prim.OffsetPosition.Y)); | ||
1381 | parameters.Add(_Database.CreateParameter("PositionZ", prim.OffsetPosition.Z)); | ||
1382 | parameters.Add(_Database.CreateParameter("GroupPositionX", prim.GroupPosition.X)); | ||
1383 | parameters.Add(_Database.CreateParameter("GroupPositionY", prim.GroupPosition.Y)); | ||
1384 | parameters.Add(_Database.CreateParameter("GroupPositionZ", prim.GroupPosition.Z)); | ||
1385 | parameters.Add(_Database.CreateParameter("VelocityX", prim.Velocity.X)); | ||
1386 | parameters.Add(_Database.CreateParameter("VelocityY", prim.Velocity.Y)); | ||
1387 | parameters.Add(_Database.CreateParameter("VelocityZ", prim.Velocity.Z)); | ||
1388 | parameters.Add(_Database.CreateParameter("AngularVelocityX", prim.AngularVelocity.X)); | ||
1389 | parameters.Add(_Database.CreateParameter("AngularVelocityY", prim.AngularVelocity.Y)); | ||
1390 | parameters.Add(_Database.CreateParameter("AngularVelocityZ", prim.AngularVelocity.Z)); | ||
1391 | parameters.Add(_Database.CreateParameter("AccelerationX", prim.Acceleration.X)); | ||
1392 | parameters.Add(_Database.CreateParameter("AccelerationY", prim.Acceleration.Y)); | ||
1393 | parameters.Add(_Database.CreateParameter("AccelerationZ", prim.Acceleration.Z)); | ||
1394 | // quaternions | ||
1395 | parameters.Add(_Database.CreateParameter("RotationX", prim.RotationOffset.X)); | ||
1396 | parameters.Add(_Database.CreateParameter("RotationY", prim.RotationOffset.Y)); | ||
1397 | parameters.Add(_Database.CreateParameter("RotationZ", prim.RotationOffset.Z)); | ||
1398 | parameters.Add(_Database.CreateParameter("RotationW", prim.RotationOffset.W)); | ||
1399 | |||
1400 | // Sit target | ||
1401 | Vector3 sitTargetPos = prim.SitTargetPositionLL; | ||
1402 | parameters.Add(_Database.CreateParameter("SitTargetOffsetX", sitTargetPos.X)); | ||
1403 | parameters.Add(_Database.CreateParameter("SitTargetOffsetY", sitTargetPos.Y)); | ||
1404 | parameters.Add(_Database.CreateParameter("SitTargetOffsetZ", sitTargetPos.Z)); | ||
1405 | |||
1406 | Quaternion sitTargetOrient = prim.SitTargetOrientationLL; | ||
1407 | parameters.Add(_Database.CreateParameter("SitTargetOrientW", sitTargetOrient.W)); | ||
1408 | parameters.Add(_Database.CreateParameter("SitTargetOrientX", sitTargetOrient.X)); | ||
1409 | parameters.Add(_Database.CreateParameter("SitTargetOrientY", sitTargetOrient.Y)); | ||
1410 | parameters.Add(_Database.CreateParameter("SitTargetOrientZ", sitTargetOrient.Z)); | ||
1411 | |||
1412 | parameters.Add(_Database.CreateParameter("PayPrice", prim.PayPrice[0])); | ||
1413 | parameters.Add(_Database.CreateParameter("PayButton1", prim.PayPrice[1])); | ||
1414 | parameters.Add(_Database.CreateParameter("PayButton2", prim.PayPrice[2])); | ||
1415 | parameters.Add(_Database.CreateParameter("PayButton3", prim.PayPrice[3])); | ||
1416 | parameters.Add(_Database.CreateParameter("PayButton4", prim.PayPrice[4])); | ||
1417 | |||
1418 | if ((prim.SoundFlags & 1) != 0) // Looped | ||
1419 | { | ||
1420 | parameters.Add(_Database.CreateParameter("LoopedSound", prim.Sound)); | ||
1421 | parameters.Add(_Database.CreateParameter("LoopedSoundGain", prim.SoundGain)); | ||
1422 | } | ||
1423 | else | ||
1424 | { | ||
1425 | parameters.Add(_Database.CreateParameter("LoopedSound", UUID.Zero)); | ||
1426 | parameters.Add(_Database.CreateParameter("LoopedSoundGain", 0.0f)); | ||
1427 | } | ||
1428 | |||
1429 | parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation)); | ||
1430 | parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem)); | ||
1431 | |||
1432 | parameters.Add(_Database.CreateParameter("OmegaX", prim.RotationalVelocity.X)); | ||
1433 | parameters.Add(_Database.CreateParameter("OmegaY", prim.RotationalVelocity.Y)); | ||
1434 | parameters.Add(_Database.CreateParameter("OmegaZ", prim.RotationalVelocity.Z)); | ||
1435 | |||
1436 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X)); | ||
1437 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y)); | ||
1438 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetZ", prim.GetCameraEyeOffset().Z)); | ||
1439 | |||
1440 | parameters.Add(_Database.CreateParameter("CameraAtOffsetX", prim.GetCameraAtOffset().X)); | ||
1441 | parameters.Add(_Database.CreateParameter("CameraAtOffsetY", prim.GetCameraAtOffset().Y)); | ||
1442 | parameters.Add(_Database.CreateParameter("CameraAtOffsetZ", prim.GetCameraAtOffset().Z)); | ||
1443 | |||
1444 | if (prim.GetForceMouselook()) | ||
1445 | parameters.Add(_Database.CreateParameter("ForceMouselook", 1)); | ||
1446 | else | ||
1447 | parameters.Add(_Database.CreateParameter("ForceMouselook", 0)); | ||
1448 | |||
1449 | parameters.Add(_Database.CreateParameter("ScriptAccessPin", prim.ScriptAccessPin)); | ||
1450 | |||
1451 | if (prim.AllowedDrop) | ||
1452 | parameters.Add(_Database.CreateParameter("AllowedDrop", 1)); | ||
1453 | else | ||
1454 | parameters.Add(_Database.CreateParameter("AllowedDrop", 0)); | ||
1455 | |||
1456 | if (prim.DIE_AT_EDGE) | ||
1457 | parameters.Add(_Database.CreateParameter("DieAtEdge", 1)); | ||
1458 | else | ||
1459 | parameters.Add(_Database.CreateParameter("DieAtEdge", 0)); | ||
1460 | |||
1461 | parameters.Add(_Database.CreateParameter("SalePrice", prim.SalePrice)); | ||
1462 | parameters.Add(_Database.CreateParameter("SaleType", prim.ObjectSaleType)); | ||
1463 | |||
1464 | byte clickAction = prim.ClickAction; | ||
1465 | parameters.Add(_Database.CreateParameter("ClickAction", clickAction)); | ||
1466 | |||
1467 | parameters.Add(_Database.CreateParameter("Material", prim.Material)); | ||
1468 | |||
1469 | parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); | ||
1470 | parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); | ||
1471 | if (prim.PassTouches) | ||
1472 | parameters.Add(_Database.CreateParameter("PassTouches", 1)); | ||
1473 | else | ||
1474 | parameters.Add(_Database.CreateParameter("PassTouches", 0)); | ||
1475 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); | ||
1476 | |||
1477 | return parameters.ToArray(); | ||
1478 | } | ||
1479 | |||
1480 | /// <summary> | ||
1481 | /// Creates the primshape parameters for stroing in DB. | ||
1482 | /// </summary> | ||
1483 | /// <param name="prim">Basic data of SceneObjectpart prim.</param> | ||
1484 | /// <param name="sceneGroupID">The scene group ID.</param> | ||
1485 | /// <param name="regionUUID">The region UUID.</param> | ||
1486 | /// <returns></returns> | ||
1487 | private SqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | ||
1488 | { | ||
1489 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1490 | |||
1491 | PrimitiveBaseShape s = prim.Shape; | ||
1492 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | ||
1493 | // shape is an enum | ||
1494 | parameters.Add(_Database.CreateParameter("Shape", 0)); | ||
1495 | // vectors | ||
1496 | parameters.Add(_Database.CreateParameter("ScaleX", s.Scale.X)); | ||
1497 | parameters.Add(_Database.CreateParameter("ScaleY", s.Scale.Y)); | ||
1498 | parameters.Add(_Database.CreateParameter("ScaleZ", s.Scale.Z)); | ||
1499 | // paths | ||
1500 | parameters.Add(_Database.CreateParameter("PCode", s.PCode)); | ||
1501 | parameters.Add(_Database.CreateParameter("PathBegin", s.PathBegin)); | ||
1502 | parameters.Add(_Database.CreateParameter("PathEnd", s.PathEnd)); | ||
1503 | parameters.Add(_Database.CreateParameter("PathScaleX", s.PathScaleX)); | ||
1504 | parameters.Add(_Database.CreateParameter("PathScaleY", s.PathScaleY)); | ||
1505 | parameters.Add(_Database.CreateParameter("PathShearX", s.PathShearX)); | ||
1506 | parameters.Add(_Database.CreateParameter("PathShearY", s.PathShearY)); | ||
1507 | parameters.Add(_Database.CreateParameter("PathSkew", s.PathSkew)); | ||
1508 | parameters.Add(_Database.CreateParameter("PathCurve", s.PathCurve)); | ||
1509 | parameters.Add(_Database.CreateParameter("PathRadiusOffset", s.PathRadiusOffset)); | ||
1510 | parameters.Add(_Database.CreateParameter("PathRevolutions", s.PathRevolutions)); | ||
1511 | parameters.Add(_Database.CreateParameter("PathTaperX", s.PathTaperX)); | ||
1512 | parameters.Add(_Database.CreateParameter("PathTaperY", s.PathTaperY)); | ||
1513 | parameters.Add(_Database.CreateParameter("PathTwist", s.PathTwist)); | ||
1514 | parameters.Add(_Database.CreateParameter("PathTwistBegin", s.PathTwistBegin)); | ||
1515 | // profile | ||
1516 | parameters.Add(_Database.CreateParameter("ProfileBegin", s.ProfileBegin)); | ||
1517 | parameters.Add(_Database.CreateParameter("ProfileEnd", s.ProfileEnd)); | ||
1518 | parameters.Add(_Database.CreateParameter("ProfileCurve", s.ProfileCurve)); | ||
1519 | parameters.Add(_Database.CreateParameter("ProfileHollow", s.ProfileHollow)); | ||
1520 | parameters.Add(_Database.CreateParameter("Texture", s.TextureEntry)); | ||
1521 | parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams)); | ||
1522 | parameters.Add(_Database.CreateParameter("State", s.State)); | ||
1523 | |||
1524 | return parameters.ToArray(); | ||
1525 | } | ||
1526 | |||
1527 | #endregion | ||
1528 | |||
1529 | #endregion | ||
1530 | } | 310 | } |
1531 | } | 311 | } |
diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs index 38be9f4..7b6e7c8 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs | |||
@@ -40,19 +40,21 @@ namespace OpenSim.Data.MSSQL | |||
40 | { | 40 | { |
41 | private string m_Realm; | 41 | private string m_Realm; |
42 | private List<string> m_ColumnNames = null; | 42 | private List<string> m_ColumnNames = null; |
43 | private int m_LastExpire = 0; | ||
44 | private string m_ConnectionString; | 43 | private string m_ConnectionString; |
44 | private MSSQLManager m_database; | ||
45 | 45 | ||
46 | public MSSQLUserAccountData(string connectionString, string realm) | 46 | public MSSQLUserAccountData(string connectionString, string realm) |
47 | { | 47 | { |
48 | m_Realm = realm; | 48 | m_Realm = realm; |
49 | m_ConnectionString = connectionString; | 49 | m_ConnectionString = connectionString; |
50 | m_database = new MSSQLManager(connectionString); | ||
51 | |||
50 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 52 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
51 | { | 53 | { |
52 | conn.Open(); | 54 | conn.Open(); |
53 | Migration m = new Migration(conn, GetType().Assembly, "UserStore"); | 55 | Migration m = new Migration(conn, GetType().Assembly, "UserStore"); |
54 | m.Update(); | 56 | m.Update(); |
55 | } | 57 | } |
56 | } | 58 | } |
57 | 59 | ||
58 | public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query) | 60 | public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query) |
@@ -65,16 +67,16 @@ namespace OpenSim.Data.MSSQL | |||
65 | UserAccountData ret = new UserAccountData(); | 67 | UserAccountData ret = new UserAccountData(); |
66 | ret.Data = new Dictionary<string, object>(); | 68 | ret.Data = new Dictionary<string, object>(); |
67 | 69 | ||
68 | string sql = string.Format("select * from '{0}' where UUID = @principalID", m_Realm); | 70 | string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); |
69 | if (scopeID != UUID.Zero) | 71 | if (scopeID != UUID.Zero) |
70 | sql += " and ScopeID = @scopeID"; | 72 | sql += " and ScopeID = @scopeID"; |
71 | 73 | ||
72 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 74 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
73 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 75 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
74 | { | 76 | { |
75 | 77 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", principalID)); | |
76 | cmd.Parameters.AddWithValue("@principalID", principalID); | 78 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); |
77 | cmd.Parameters.AddWithValue("@scopeID", scopeID); | 79 | |
78 | conn.Open(); | 80 | conn.Open(); |
79 | using (SqlDataReader result = cmd.ExecuteReader()) | 81 | using (SqlDataReader result = cmd.ExecuteReader()) |
80 | { | 82 | { |
@@ -123,17 +125,16 @@ namespace OpenSim.Data.MSSQL | |||
123 | using (SqlCommand cmd = new SqlCommand()) | 125 | using (SqlCommand cmd = new SqlCommand()) |
124 | { | 126 | { |
125 | StringBuilder updateBuilder = new StringBuilder(); | 127 | StringBuilder updateBuilder = new StringBuilder(); |
126 | updateBuilder.AppendFormat("update '{0}' set ", m_Realm); | 128 | updateBuilder.AppendFormat("update {0} set ", m_Realm); |
127 | bool first = true; | 129 | bool first = true; |
128 | foreach (string field in fields) | 130 | foreach (string field in fields) |
129 | { | 131 | { |
130 | if (!first) | 132 | if (!first) |
131 | updateBuilder.Append(", "); | 133 | updateBuilder.Append(", "); |
132 | updateBuilder.AppendFormat("'{0}' = @{0}", field); | 134 | updateBuilder.AppendFormat("{0} = @{0}", field); |
133 | 135 | ||
134 | first = false; | 136 | first = false; |
135 | 137 | cmd.Parameters.Add(m_database.CreateParameter("@" + field, data.Data[field])); | |
136 | cmd.Parameters.AddWithValue("@" + field, data.Data[field]); | ||
137 | } | 138 | } |
138 | 139 | ||
139 | updateBuilder.Append(" where UUID = @principalID"); | 140 | updateBuilder.Append(" where UUID = @principalID"); |
@@ -143,16 +144,16 @@ namespace OpenSim.Data.MSSQL | |||
143 | 144 | ||
144 | cmd.CommandText = updateBuilder.ToString(); | 145 | cmd.CommandText = updateBuilder.ToString(); |
145 | cmd.Connection = conn; | 146 | cmd.Connection = conn; |
146 | cmd.Parameters.AddWithValue("@principalID", data.PrincipalID); | 147 | cmd.Parameters.Add(m_database.CreateParameter("@principalID", data.PrincipalID)); |
147 | cmd.Parameters.AddWithValue("@scopeID", data.ScopeID); | 148 | cmd.Parameters.Add(m_database.CreateParameter("@scopeID", data.ScopeID)); |
148 | conn.Open(); | 149 | conn.Open(); |
149 | 150 | ||
150 | if (cmd.ExecuteNonQuery() < 1) | 151 | if (cmd.ExecuteNonQuery() < 1) |
151 | { | 152 | { |
152 | StringBuilder insertBuilder = new StringBuilder(); | 153 | StringBuilder insertBuilder = new StringBuilder(); |
153 | insertBuilder.AppendFormat("insert into '{0}' ('UUID', 'ScopeID', '", m_Realm); | 154 | insertBuilder.AppendFormat("insert into {0} (UUID, ScopeID, ", m_Realm); |
154 | insertBuilder.Append(String.Join("', '", fields)); | 155 | insertBuilder.Append(String.Join(", ", fields)); |
155 | insertBuilder.Append("') values (@principalID, @scopeID, @"); | 156 | insertBuilder.Append(") values ( @principalID, @scopeID, @"); |
156 | insertBuilder.Append(String.Join(", @", fields)); | 157 | insertBuilder.Append(String.Join(", @", fields)); |
157 | insertBuilder.Append(")"); | 158 | insertBuilder.Append(")"); |
158 | 159 | ||
@@ -169,12 +170,13 @@ namespace OpenSim.Data.MSSQL | |||
169 | 170 | ||
170 | public bool SetDataItem(UUID principalID, string item, string value) | 171 | public bool SetDataItem(UUID principalID, string item, string value) |
171 | { | 172 | { |
172 | string sql = string.Format("update '{0}' set '{1}' = @{1} where UUID = @UUID", m_Realm, item); | 173 | string sql = string.Format("update {0} set {1} = @{1} where UUID = @UUID", m_Realm, item); |
173 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) | 174 | using (SqlConnection conn = new SqlConnection(m_ConnectionString)) |
174 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 175 | using (SqlCommand cmd = new SqlCommand(sql, conn)) |
175 | { | 176 | { |
176 | cmd.Parameters.AddWithValue("@" + item, value); | 177 | cmd.Parameters.Add(m_database.CreateParameter("@" + item, value)); |
177 | cmd.Parameters.AddWithValue("@UUID", principalID); | 178 | cmd.Parameters.Add(m_database.CreateParameter("@UUID", principalID)); |
179 | |||
178 | conn.Open(); | 180 | conn.Open(); |
179 | 181 | ||
180 | if (cmd.ExecuteNonQuery() > 0) | 182 | if (cmd.ExecuteNonQuery() > 0) |
diff --git a/OpenSim/Data/MSSQL/Resources/006_GridStore.sql b/OpenSim/Data/MSSQL/Resources/006_GridStore.sql new file mode 100644 index 0000000..42010ce --- /dev/null +++ b/OpenSim/Data/MSSQL/Resources/006_GridStore.sql | |||
@@ -0,0 +1,8 @@ | |||
1 | BEGIN TRANSACTION | ||
2 | |||
3 | ALTER TABLE regions ADD scopeid uniqueidentifier default '00000000-0000-0000-0000-000000000000'; | ||
4 | ALTER TABLE regions ADD DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [owner_uuid]; | ||
5 | ALTER TABLE regions ADD sizeX integer not null default 0; | ||
6 | ALTER TABLE regions ADD sizeY integer not null default 0; | ||
7 | |||
8 | COMMIT | ||
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index e96a123..a41f9f8 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs | |||
@@ -82,12 +82,16 @@ namespace OpenSim.Data.MySQL | |||
82 | ret.Data[s] = result[s].ToString(); | 82 | ret.Data[s] = result[s].ToString(); |
83 | } | 83 | } |
84 | 84 | ||
85 | CloseDBConnection(cmd); | ||
85 | return ret; | 86 | return ret; |
86 | } | 87 | } |
88 | else | ||
89 | { | ||
90 | CloseDBConnection(cmd); | ||
91 | return null; | ||
92 | } | ||
87 | } | 93 | } |
88 | } | 94 | } |
89 | |||
90 | return null; | ||
91 | } | 95 | } |
92 | 96 | ||
93 | public bool Store(AuthenticationData data) | 97 | public bool Store(AuthenticationData data) |
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index c756c9c..f37e9bc 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs | |||
@@ -47,7 +47,6 @@ namespace OpenSim.Data.MySQL | |||
47 | protected MySqlFramework(string connectionString) | 47 | protected MySqlFramework(string connectionString) |
48 | { | 48 | { |
49 | m_Connection = new MySqlConnection(connectionString); | 49 | m_Connection = new MySqlConnection(connectionString); |
50 | |||
51 | m_Connection.Open(); | 50 | m_Connection.Open(); |
52 | } | 51 | } |
53 | 52 | ||
@@ -82,8 +81,7 @@ namespace OpenSim.Data.MySQL | |||
82 | errorSeen = true; | 81 | errorSeen = true; |
83 | 82 | ||
84 | m_Connection.Close(); | 83 | m_Connection.Close(); |
85 | MySqlConnection newConnection = (MySqlConnection) | 84 | MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); |
86 | ((ICloneable)m_Connection).Clone(); | ||
87 | m_Connection.Dispose(); | 85 | m_Connection.Dispose(); |
88 | m_Connection = newConnection; | 86 | m_Connection = newConnection; |
89 | m_Connection.Open(); | 87 | m_Connection.Open(); |
@@ -104,14 +102,16 @@ namespace OpenSim.Data.MySQL | |||
104 | 102 | ||
105 | protected IDataReader ExecuteReader(MySqlCommand cmd) | 103 | protected IDataReader ExecuteReader(MySqlCommand cmd) |
106 | { | 104 | { |
107 | MySqlConnection newConnection = (MySqlConnection) | 105 | MySqlConnection newConnection = (MySqlConnection)((ICloneable)m_Connection).Clone(); |
108 | ((ICloneable)m_Connection).Clone(); | ||
109 | |||
110 | newConnection.Open(); | 106 | newConnection.Open(); |
111 | 107 | ||
112 | cmd.Connection = newConnection; | 108 | cmd.Connection = newConnection; |
113 | |||
114 | return cmd.ExecuteReader(); | 109 | return cmd.ExecuteReader(); |
115 | } | 110 | } |
111 | |||
112 | protected void CloseDBConnection(MySqlCommand cmd) | ||
113 | { | ||
114 | cmd.Connection.Dispose(); | ||
115 | } | ||
116 | } | 116 | } |
117 | } | 117 | } |
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index 04b24b6..3fe27d5 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs | |||
@@ -172,6 +172,8 @@ namespace OpenSim.Data.MySQL | |||
172 | 172 | ||
173 | retList.Add(ret); | 173 | retList.Add(ret); |
174 | } | 174 | } |
175 | |||
176 | CloseDBConnection(cmd); | ||
175 | } | 177 | } |
176 | 178 | ||
177 | return retList; | 179 | return retList; |
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index c713a11..38a6f55 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs | |||
@@ -97,12 +97,16 @@ namespace OpenSim.Data.MySQL | |||
97 | ret.Data[s] = result[s].ToString(); | 97 | ret.Data[s] = result[s].ToString(); |
98 | } | 98 | } |
99 | 99 | ||
100 | CloseDBConnection(cmd); | ||
100 | return ret; | 101 | return ret; |
101 | } | 102 | } |
103 | else | ||
104 | { | ||
105 | CloseDBConnection(cmd); | ||
106 | return null; | ||
107 | } | ||
102 | } | 108 | } |
103 | } | 109 | } |
104 | |||
105 | return null; | ||
106 | } | 110 | } |
107 | 111 | ||
108 | public bool Store(UserAccountData data) | 112 | public bool Store(UserAccountData data) |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 632b551..56155dd 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -238,7 +238,7 @@ namespace OpenSim.Framework.Servers | |||
238 | List<Thread> threads = ThreadTracker.GetThreads(); | 238 | List<Thread> threads = ThreadTracker.GetThreads(); |
239 | if (threads == null) | 239 | if (threads == null) |
240 | { | 240 | { |
241 | sb.Append("Thread tracking is only enabled in DEBUG mode."); | 241 | sb.Append("OpenSim thread tracking is only enabled in DEBUG mode."); |
242 | } | 242 | } |
243 | else | 243 | else |
244 | { | 244 | { |
@@ -264,6 +264,12 @@ namespace OpenSim.Framework.Servers | |||
264 | } | 264 | } |
265 | } | 265 | } |
266 | } | 266 | } |
267 | int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0; | ||
268 | ThreadPool.GetAvailableThreads(out workers, out ports); | ||
269 | ThreadPool.GetMaxThreads(out maxWorkers, out maxPorts); | ||
270 | |||
271 | sb.Append(Environment.NewLine + "*** ThreadPool threads ***" + Environment.NewLine); | ||
272 | sb.Append("workers: " + (maxWorkers - workers) + " (" + maxWorkers + "); ports: " + (maxPorts - ports) + " (" + maxPorts + ")" + Environment.NewLine); | ||
267 | 273 | ||
268 | return sb.ToString(); | 274 | return sb.ToString(); |
269 | } | 275 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs index 8a490f7..4543fd5 100644 --- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs | |||
@@ -28,14 +28,21 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Reflection; | ||
31 | using System.Text; | 32 | using System.Text; |
32 | using System.Xml; | 33 | using System.Xml; |
33 | using System.Xml.Serialization; | 34 | using System.Xml.Serialization; |
34 | 35 | ||
36 | using log4net; | ||
37 | |||
35 | namespace OpenSim.Framework.Servers.HttpServer | 38 | namespace OpenSim.Framework.Servers.HttpServer |
36 | { | 39 | { |
37 | public class SynchronousRestFormsRequester | 40 | public class SynchronousRestFormsRequester |
38 | { | 41 | { |
42 | private static readonly ILog m_log = | ||
43 | LogManager.GetLogger( | ||
44 | MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
39 | /// <summary> | 46 | /// <summary> |
40 | /// Perform a synchronous REST request. | 47 | /// Perform a synchronous REST request. |
41 | /// </summary> | 48 | /// </summary> |
@@ -72,8 +79,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
72 | requestStream = request.GetRequestStream(); | 79 | requestStream = request.GetRequestStream(); |
73 | requestStream.Write(buffer.ToArray(), 0, length); | 80 | requestStream.Write(buffer.ToArray(), 0, length); |
74 | } | 81 | } |
75 | catch | 82 | catch (Exception e) |
76 | { | 83 | { |
84 | m_log.DebugFormat("[FORMS]: exception occured on sending request {0}", e.Message); | ||
77 | } | 85 | } |
78 | finally | 86 | finally |
79 | { | 87 | { |
@@ -102,7 +110,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
102 | respstring = reader.ReadToEnd(); | 110 | respstring = reader.ReadToEnd(); |
103 | } | 111 | } |
104 | } | 112 | } |
105 | catch { } | 113 | catch (Exception e) |
114 | { | ||
115 | m_log.DebugFormat("[FORMS]: exception occured on receiving reply {0}", e.Message); | ||
116 | } | ||
106 | finally | 117 | finally |
107 | { | 118 | { |
108 | if (respStream != null) | 119 | if (respStream != null) |
@@ -114,6 +125,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
114 | catch (System.InvalidOperationException) | 125 | catch (System.InvalidOperationException) |
115 | { | 126 | { |
116 | // This is what happens when there is invalid XML | 127 | // This is what happens when there is invalid XML |
128 | m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving request"); | ||
117 | } | 129 | } |
118 | return respstring; | 130 | return respstring; |
119 | } | 131 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 5219df7..343f537 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs | |||
@@ -88,7 +88,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
88 | J2KImage imgrequest; | 88 | J2KImage imgrequest; |
89 | 89 | ||
90 | // Do a linear search for this texture download | 90 | // Do a linear search for this texture download |
91 | lock (m_priorityQueue) | 91 | lock (m_syncRoot) |
92 | m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest); | 92 | m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest); |
93 | 93 | ||
94 | if (imgrequest != null) | 94 | if (imgrequest != null) |
@@ -99,7 +99,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
99 | 99 | ||
100 | try | 100 | try |
101 | { | 101 | { |
102 | lock (m_priorityQueue) | 102 | lock (m_syncRoot) |
103 | m_priorityQueue.Delete(imgrequest.PriorityQueueHandle); | 103 | m_priorityQueue.Delete(imgrequest.PriorityQueueHandle); |
104 | } | 104 | } |
105 | catch (Exception) { } | 105 | catch (Exception) { } |
@@ -167,8 +167,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
167 | J2KImage imagereq; | 167 | J2KImage imagereq; |
168 | int numCollected = 0; | 168 | int numCollected = 0; |
169 | 169 | ||
170 | lock (m_syncRoot) | 170 | //lock (m_syncRoot) |
171 | { | 171 | //{ |
172 | m_lastloopprocessed = DateTime.Now.Ticks; | 172 | m_lastloopprocessed = DateTime.Now.Ticks; |
173 | 173 | ||
174 | // This can happen during Close() | 174 | // This can happen during Close() |
@@ -191,7 +191,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
191 | if (numCollected == count) | 191 | if (numCollected == count) |
192 | break; | 192 | break; |
193 | } | 193 | } |
194 | } | 194 | //} |
195 | 195 | ||
196 | return m_priorityQueue.Count > 0; | 196 | return m_priorityQueue.Count > 0; |
197 | } | 197 | } |
@@ -211,16 +211,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
211 | { | 211 | { |
212 | J2KImage image = null; | 212 | J2KImage image = null; |
213 | 213 | ||
214 | if (m_priorityQueue.Count > 0) | 214 | lock (m_syncRoot) |
215 | { | 215 | { |
216 | try | 216 | |
217 | if (m_priorityQueue.Count > 0) | ||
217 | { | 218 | { |
218 | lock (m_priorityQueue) | 219 | try |
220 | { | ||
219 | image = m_priorityQueue.FindMax(); | 221 | image = m_priorityQueue.FindMax(); |
222 | } | ||
223 | catch (Exception) { } | ||
220 | } | 224 | } |
221 | catch (Exception) { } | ||
222 | } | 225 | } |
223 | |||
224 | return image; | 226 | return image; |
225 | } | 227 | } |
226 | 228 | ||
@@ -228,23 +230,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
228 | { | 230 | { |
229 | image.PriorityQueueHandle = null; | 231 | image.PriorityQueueHandle = null; |
230 | 232 | ||
231 | lock (m_priorityQueue) | 233 | lock (m_syncRoot) |
232 | m_priorityQueue.Add(ref image.PriorityQueueHandle, image); | 234 | try |
235 | { | ||
236 | m_priorityQueue.Add(ref image.PriorityQueueHandle, image); | ||
237 | } | ||
238 | catch (Exception) { } | ||
233 | } | 239 | } |
234 | 240 | ||
235 | void RemoveImageFromQueue(J2KImage image) | 241 | void RemoveImageFromQueue(J2KImage image) |
236 | { | 242 | { |
237 | try | 243 | lock (m_syncRoot) |
238 | { | 244 | try |
239 | lock (m_priorityQueue) | 245 | { |
240 | m_priorityQueue.Delete(image.PriorityQueueHandle); | 246 | m_priorityQueue.Delete(image.PriorityQueueHandle); |
241 | } | 247 | } |
242 | catch (Exception) { } | 248 | catch (Exception) { } |
243 | } | 249 | } |
244 | 250 | ||
245 | void UpdateImageInQueue(J2KImage image) | 251 | void UpdateImageInQueue(J2KImage image) |
246 | { | 252 | { |
247 | lock (m_priorityQueue) | 253 | lock (m_syncRoot) |
248 | { | 254 | { |
249 | try { m_priorityQueue.Replace(image.PriorityQueueHandle, image); } | 255 | try { m_priorityQueue.Replace(image.PriorityQueueHandle, image); } |
250 | catch (Exception) | 256 | catch (Exception) |
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index 5a5ad7e..66ca7c2 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
178 | { | 178 | { |
179 | if (maximalSize <= 0 || maximalCount <= 0) | 179 | if (maximalSize <= 0 || maximalCount <= 0) |
180 | { | 180 | { |
181 | Log.Info("[ASSET CACHE]: Cenome asset cache is not enabled."); | 181 | //Log.Debug("[ASSET CACHE]: Cenome asset cache is not enabled."); |
182 | m_enabled = false; | 182 | m_enabled = false; |
183 | return; | 183 | return; |
184 | } | 184 | } |
@@ -194,7 +194,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
194 | CnmSynchronizedCache<string, AssetBase>.Synchronized(new CnmMemoryCache<string, AssetBase>( | 194 | CnmSynchronizedCache<string, AssetBase>.Synchronized(new CnmMemoryCache<string, AssetBase>( |
195 | maximalSize, maximalCount, expirationTime)); | 195 | maximalSize, maximalCount, expirationTime)); |
196 | m_enabled = true; | 196 | m_enabled = true; |
197 | Log.InfoFormat( | 197 | Log.DebugFormat( |
198 | "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})", | 198 | "[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})", |
199 | maximalSize, | 199 | maximalSize, |
200 | maximalCount, | 200 | maximalCount, |
@@ -263,7 +263,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
263 | 263 | ||
264 | if (m_getCount == m_debugEpoch) | 264 | if (m_getCount == m_debugEpoch) |
265 | { | 265 | { |
266 | Log.InfoFormat( | 266 | Log.DebugFormat( |
267 | "[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes", | 267 | "[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes", |
268 | m_cachedCount, | 268 | m_cachedCount, |
269 | m_getCount, | 269 | m_getCount, |
@@ -333,7 +333,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
333 | return; | 333 | return; |
334 | 334 | ||
335 | string name = moduleConfig.GetString("AssetCaching"); | 335 | string name = moduleConfig.GetString("AssetCaching"); |
336 | Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); | 336 | //Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); |
337 | 337 | ||
338 | if (name != Name) | 338 | if (name != Name) |
339 | return; | 339 | return; |
@@ -343,14 +343,14 @@ namespace OpenSim.Region.CoreModules.Asset | |||
343 | int maxCount = DefaultMaxCount; | 343 | int maxCount = DefaultMaxCount; |
344 | TimeSpan expirationTime = DefaultExpirationTime; | 344 | TimeSpan expirationTime = DefaultExpirationTime; |
345 | 345 | ||
346 | IConfig assetConfig = source.Configs[ "AssetCache" ]; | 346 | IConfig assetConfig = source.Configs["AssetCache"]; |
347 | if (assetConfig != null) | 347 | if (assetConfig != null) |
348 | { | 348 | { |
349 | // Get optional configurations | 349 | // Get optional configurations |
350 | maxSize = assetConfig.GetLong("MaxSize", DefaultMaxSize); | 350 | maxSize = assetConfig.GetLong("MaxSize", DefaultMaxSize); |
351 | maxCount = assetConfig.GetInt("MaxCount", DefaultMaxCount); | 351 | maxCount = assetConfig.GetInt("MaxCount", DefaultMaxCount); |
352 | expirationTime = | 352 | expirationTime = |
353 | TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int) DefaultExpirationTime.TotalMinutes)); | 353 | TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int)DefaultExpirationTime.TotalMinutes)); |
354 | 354 | ||
355 | // Debugging purposes only | 355 | // Debugging purposes only |
356 | m_debugEpoch = assetConfig.GetInt("DebugEpoch", 0); | 356 | m_debugEpoch = assetConfig.GetInt("DebugEpoch", 0); |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 2de40d2..0a7e736 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
66 | if (moduleConfig != null) | 66 | if (moduleConfig != null) |
67 | { | 67 | { |
68 | string name = moduleConfig.GetString("AssetCaching"); | 68 | string name = moduleConfig.GetString("AssetCaching"); |
69 | m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); | 69 | //m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); |
70 | 70 | ||
71 | if (name == Name) | 71 | if (name == Name) |
72 | { | 72 | { |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index c0bb70c..b81ab41 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -636,11 +636,8 @@ namespace Flotsam.RegionModules.AssetCache | |||
636 | m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearfile - Remove all assets cached on disk"); | 636 | m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearfile - Remove all assets cached on disk"); |
637 | 637 | ||
638 | } | 638 | } |
639 | |||
640 | |||
641 | } | 639 | } |
642 | 640 | ||
643 | #endregion | 641 | #endregion |
644 | |||
645 | } | 642 | } |
646 | } | 643 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 8d8e0fe..4869f5d 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
68 | if (moduleConfig != null) | 68 | if (moduleConfig != null) |
69 | { | 69 | { |
70 | string name = moduleConfig.GetString("AssetCaching"); | 70 | string name = moduleConfig.GetString("AssetCaching"); |
71 | m_log.DebugFormat("[ASSET CACHE] name = {0} (this module's name: {1}). Sync? ", name, Name, m_Cache.IsSynchronized); | 71 | //m_log.DebugFormat("[ASSET CACHE] name = {0} (this module's name: {1}). Sync? ", name, Name, m_Cache.IsSynchronized); |
72 | 72 | ||
73 | if (name == Name) | 73 | if (name == Name) |
74 | { | 74 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3ca4882..1c72488 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | |||
@@ -206,6 +206,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
206 | 206 | ||
207 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 207 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
208 | { | 208 | { |
209 | GridRegion region = null; | ||
210 | |||
211 | // First see if it's a neighbour, even if it isn't on this sim. | ||
212 | // Neighbour data is cached in memory, so this is fast | ||
213 | foreach (RegionCache rcache in m_LocalCache.Values) | ||
214 | { | ||
215 | region = rcache.GetRegionByPosition(x, y); | ||
216 | if (region != null) | ||
217 | { | ||
218 | return region; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | // Then try on this sim (may be a lookup in DB if this is using MySql). | ||
209 | return m_GridService.GetRegionByPosition(scopeID, x, y); | 223 | return m_GridService.GetRegionByPosition(scopeID, x, y); |
210 | } | 224 | } |
211 | 225 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 2b336bb..44e850b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | |||
@@ -29,10 +29,12 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | 31 | ||
32 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
34 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
35 | 36 | ||
37 | using OpenMetaverse; | ||
36 | using log4net; | 38 | using log4net; |
37 | 39 | ||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid |
@@ -75,5 +77,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
75 | { | 77 | { |
76 | return new List<GridRegion>(m_neighbours.Values); | 78 | return new List<GridRegion>(m_neighbours.Values); |
77 | } | 79 | } |
80 | |||
81 | public GridRegion GetRegionByPosition(int x, int y) | ||
82 | { | ||
83 | uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; | ||
84 | uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize; | ||
85 | ulong handle = Utils.UIntsToLong(xsnap, ysnap); | ||
86 | |||
87 | if (m_neighbours.ContainsKey(handle)) | ||
88 | return m_neighbours[handle]; | ||
89 | |||
90 | return null; | ||
91 | } | ||
78 | } | 92 | } |
79 | } | 93 | } |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 9622555..901144a 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -397,10 +397,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
397 | // with the powers requested (powers = 0 for no powers check) | 397 | // with the powers requested (powers = 0 for no powers check) |
398 | protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) | 398 | protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) |
399 | { | 399 | { |
400 | IClientAPI client = m_scene.GetScenePresence(userID).ControllingClient; | 400 | ScenePresence sp = m_scene.GetScenePresence(userID); |
401 | 401 | if (sp != null) | |
402 | return ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) && | 402 | { |
403 | ((powers == 0) || ((client.ActiveGroupPowers & powers) == powers))); | 403 | IClientAPI client = sp.ControllingClient; |
404 | |||
405 | return ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) && | ||
406 | ((powers == 0) || ((client.ActiveGroupPowers & powers) == powers))); | ||
407 | } | ||
408 | return false; | ||
404 | } | 409 | } |
405 | 410 | ||
406 | /// <summary> | 411 | /// <summary> |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 631d801..00fe5df 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -425,7 +425,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
425 | 425 | ||
426 | foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID)) | 426 | foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID)) |
427 | { | 427 | { |
428 | if (m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid)) | 428 | if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid)) |
429 | { | 429 | { |
430 | // Don't deliver messages to people who have dropped this session | 430 | // Don't deliver messages to people who have dropped this session |
431 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); | 431 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 2e89a24..b209199 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -148,9 +148,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
148 | UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count]; | 148 | UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count]; |
149 | foreach (UUID key in CurrentKeys) | 149 | foreach (UUID key in CurrentKeys) |
150 | { | 150 | { |
151 | if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout) | 151 | if (m_clientRequestIDInfo.ContainsKey(key)) |
152 | { | 152 | { |
153 | m_clientRequestIDInfo.Remove(key); | 153 | if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout) |
154 | { | ||
155 | m_clientRequestIDInfo.Remove(key); | ||
156 | } | ||
154 | } | 157 | } |
155 | } | 158 | } |
156 | } | 159 | } |
@@ -476,7 +479,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
476 | 479 | ||
477 | foreach (string key in binBucketOSD.Keys) | 480 | foreach (string key in binBucketOSD.Keys) |
478 | { | 481 | { |
479 | m_log.WarnFormat("{0}: {1}", key, binBucketOSD[key].ToString()); | 482 | if (binBucketOSD.ContainsKey(key)) |
483 | { | ||
484 | m_log.WarnFormat("{0}: {1}", key, binBucketOSD[key].ToString()); | ||
485 | } | ||
480 | } | 486 | } |
481 | } | 487 | } |
482 | 488 | ||
diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs index e26c623..ac14292 100644 --- a/OpenSim/Region/Physics/Manager/IMesher.cs +++ b/OpenSim/Region/Physics/Manager/IMesher.cs | |||
@@ -47,6 +47,8 @@ namespace OpenSim.Region.Physics.Manager | |||
47 | int[] getIndexListAsInt(); | 47 | int[] getIndexListAsInt(); |
48 | int[] getIndexListAsIntLocked(); | 48 | int[] getIndexListAsIntLocked(); |
49 | float[] getVertexListAsFloatLocked(); | 49 | float[] getVertexListAsFloatLocked(); |
50 | void getIndexListAsPtrToIntArray(out IntPtr indices, out int triStride, out int indexCount); | ||
51 | void getVertexListAsPtrToFloatArray( out IntPtr vertexList, out int vertexStride, out int vertexCount ); | ||
50 | void releaseSourceMeshData(); | 52 | void releaseSourceMeshData(); |
51 | void releasePinned(); | 53 | void releasePinned(); |
52 | void Append(IMesh newMesh); | 54 | void Append(IMesh newMesh); |
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs index aae8871..ff1f816 100644 --- a/OpenSim/Region/Physics/Meshing/Mesh.cs +++ b/OpenSim/Region/Physics/Meshing/Mesh.cs | |||
@@ -36,23 +36,27 @@ namespace OpenSim.Region.Physics.Meshing | |||
36 | { | 36 | { |
37 | public class Mesh : IMesh | 37 | public class Mesh : IMesh |
38 | { | 38 | { |
39 | private Dictionary<Vertex, int> vertices; | 39 | private Dictionary<Vertex, int> m_vertices; |
40 | private List<Triangle> triangles; | 40 | private List<Triangle> m_triangles; |
41 | GCHandle pinnedVirtexes; | 41 | GCHandle m_pinnedVertexes; |
42 | GCHandle pinnedIndex; | 42 | GCHandle m_pinnedIndex; |
43 | public float[] normals; | 43 | IntPtr m_verticesPtr = IntPtr.Zero; |
44 | int m_vertexCount = 0; | ||
45 | IntPtr m_indicesPtr = IntPtr.Zero; | ||
46 | int m_indexCount = 0; | ||
47 | public float[] m_normals; | ||
44 | 48 | ||
45 | public Mesh() | 49 | public Mesh() |
46 | { | 50 | { |
47 | vertices = new Dictionary<Vertex, int>(); | 51 | m_vertices = new Dictionary<Vertex, int>(); |
48 | triangles = new List<Triangle>(); | 52 | m_triangles = new List<Triangle>(); |
49 | } | 53 | } |
50 | 54 | ||
51 | public Mesh Clone() | 55 | public Mesh Clone() |
52 | { | 56 | { |
53 | Mesh result = new Mesh(); | 57 | Mesh result = new Mesh(); |
54 | 58 | ||
55 | foreach (Triangle t in triangles) | 59 | foreach (Triangle t in m_triangles) |
56 | { | 60 | { |
57 | result.Add(new Triangle(t.v1.Clone(), t.v2.Clone(), t.v3.Clone())); | 61 | result.Add(new Triangle(t.v1.Clone(), t.v2.Clone(), t.v3.Clone())); |
58 | } | 62 | } |
@@ -62,27 +66,27 @@ namespace OpenSim.Region.Physics.Meshing | |||
62 | 66 | ||
63 | public void Add(Triangle triangle) | 67 | public void Add(Triangle triangle) |
64 | { | 68 | { |
65 | if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated) | 69 | if (m_pinnedIndex.IsAllocated || m_pinnedVertexes.IsAllocated || m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) |
66 | throw new NotSupportedException("Attempt to Add to a pinned Mesh"); | 70 | throw new NotSupportedException("Attempt to Add to a pinned Mesh"); |
67 | // If a vertex of the triangle is not yet in the vertices list, | 71 | // If a vertex of the triangle is not yet in the vertices list, |
68 | // add it and set its index to the current index count | 72 | // add it and set its index to the current index count |
69 | if (!vertices.ContainsKey(triangle.v1)) | 73 | if( !m_vertices.ContainsKey(triangle.v1) ) |
70 | vertices[triangle.v1] = vertices.Count; | 74 | m_vertices[triangle.v1] = m_vertices.Count; |
71 | if (!vertices.ContainsKey(triangle.v2)) | 75 | if (!m_vertices.ContainsKey(triangle.v2)) |
72 | vertices[triangle.v2] = vertices.Count; | 76 | m_vertices[triangle.v2] = m_vertices.Count; |
73 | if (!vertices.ContainsKey(triangle.v3)) | 77 | if (!m_vertices.ContainsKey(triangle.v3)) |
74 | vertices[triangle.v3] = vertices.Count; | 78 | m_vertices[triangle.v3] = m_vertices.Count; |
75 | triangles.Add(triangle); | 79 | m_triangles.Add(triangle); |
76 | } | 80 | } |
77 | 81 | ||
78 | public void CalcNormals() | 82 | public void CalcNormals() |
79 | { | 83 | { |
80 | int iTriangles = triangles.Count; | 84 | int iTriangles = m_triangles.Count; |
81 | 85 | ||
82 | this.normals = new float[iTriangles * 3]; | 86 | this.m_normals = new float[iTriangles * 3]; |
83 | 87 | ||
84 | int i = 0; | 88 | int i = 0; |
85 | foreach (Triangle t in triangles) | 89 | foreach (Triangle t in m_triangles) |
86 | { | 90 | { |
87 | float ux, uy, uz; | 91 | float ux, uy, uz; |
88 | float vx, vy, vz; | 92 | float vx, vy, vz; |
@@ -129,9 +133,9 @@ namespace OpenSim.Region.Physics.Meshing | |||
129 | //ny /= l; | 133 | //ny /= l; |
130 | //nz /= l; | 134 | //nz /= l; |
131 | 135 | ||
132 | normals[i] = nx * lReciprocal; | 136 | m_normals[i] = nx * lReciprocal; |
133 | normals[i + 1] = ny * lReciprocal; | 137 | m_normals[i + 1] = ny * lReciprocal; |
134 | normals[i + 2] = nz * lReciprocal; | 138 | m_normals[i + 2] = nz * lReciprocal; |
135 | 139 | ||
136 | i += 3; | 140 | i += 3; |
137 | } | 141 | } |
@@ -140,45 +144,70 @@ namespace OpenSim.Region.Physics.Meshing | |||
140 | public List<PhysicsVector> getVertexList() | 144 | public List<PhysicsVector> getVertexList() |
141 | { | 145 | { |
142 | List<PhysicsVector> result = new List<PhysicsVector>(); | 146 | List<PhysicsVector> result = new List<PhysicsVector>(); |
143 | foreach (Vertex v in vertices.Keys) | 147 | foreach (Vertex v in m_vertices.Keys) |
144 | { | 148 | { |
145 | result.Add(v); | 149 | result.Add(v); |
146 | } | 150 | } |
147 | return result; | 151 | return result; |
148 | } | 152 | } |
149 | 153 | ||
150 | public float[] getVertexListAsFloatLocked() | 154 | private float[] getVertexListAsFloat() |
151 | { | 155 | { |
152 | if (pinnedVirtexes.IsAllocated) | 156 | if(m_vertices == null) |
153 | return (float[])(pinnedVirtexes.Target); | 157 | throw new NotSupportedException(); |
154 | float[] result; | 158 | float[] result = new float[m_vertices.Count * 3]; |
155 | 159 | foreach (KeyValuePair<Vertex, int> kvp in m_vertices) | |
156 | //m_log.WarnFormat("vertices.Count = {0}", vertices.Count); | ||
157 | result = new float[vertices.Count * 3]; | ||
158 | foreach (KeyValuePair<Vertex, int> kvp in vertices) | ||
159 | { | 160 | { |
160 | Vertex v = kvp.Key; | 161 | Vertex v = kvp.Key; |
161 | int i = kvp.Value; | 162 | int i = kvp.Value; |
162 | //m_log.WarnFormat("kvp.Value = {0}", i); | ||
163 | result[3 * i + 0] = v.X; | 163 | result[3 * i + 0] = v.X; |
164 | result[3 * i + 1] = v.Y; | 164 | result[3 * i + 1] = v.Y; |
165 | result[3 * i + 2] = v.Z; | 165 | result[3 * i + 2] = v.Z; |
166 | } | 166 | } |
167 | pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned); | ||
168 | return result; | 167 | return result; |
169 | } | 168 | } |
170 | 169 | ||
171 | public int[] getIndexListAsInt() | 170 | public float[] getVertexListAsFloatLocked() |
172 | { | 171 | { |
173 | int[] result; | 172 | if( m_pinnedVertexes.IsAllocated ) |
173 | return (float[])(m_pinnedVertexes.Target); | ||
174 | 174 | ||
175 | result = new int[triangles.Count * 3]; | 175 | float[] result = getVertexListAsFloat(); |
176 | for (int i = 0; i < triangles.Count; i++) | 176 | m_pinnedVertexes = GCHandle.Alloc(result, GCHandleType.Pinned); |
177 | |||
178 | return result; | ||
179 | } | ||
180 | |||
181 | public void getVertexListAsPtrToFloatArray(out IntPtr vertices, out int vertexStride, out int vertexCount) | ||
182 | { | ||
183 | // A vertex is 3 floats | ||
184 | vertexStride = 3 * sizeof(float); | ||
185 | |||
186 | // If there isn't an unmanaged array allocated yet, do it now | ||
187 | if (m_verticesPtr == IntPtr.Zero) | ||
177 | { | 188 | { |
178 | Triangle t = triangles[i]; | 189 | float[] vertexList = getVertexListAsFloat(); |
179 | result[3 * i + 0] = vertices[t.v1]; | 190 | // Each vertex is 3 elements (floats) |
180 | result[3 * i + 1] = vertices[t.v2]; | 191 | m_vertexCount = vertexList.Length / 3; |
181 | result[3 * i + 2] = vertices[t.v3]; | 192 | int byteCount = m_vertexCount * vertexStride; |
193 | m_verticesPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(byteCount); | ||
194 | System.Runtime.InteropServices.Marshal.Copy(vertexList, 0, m_verticesPtr, m_vertexCount * 3); | ||
195 | } | ||
196 | vertices = m_verticesPtr; | ||
197 | vertexCount = m_vertexCount; | ||
198 | } | ||
199 | |||
200 | public int[] getIndexListAsInt() | ||
201 | { | ||
202 | if (m_triangles == null) | ||
203 | throw new NotSupportedException(); | ||
204 | int[] result = new int[m_triangles.Count * 3]; | ||
205 | for (int i = 0; i < m_triangles.Count; i++) | ||
206 | { | ||
207 | Triangle t = m_triangles[i]; | ||
208 | result[3 * i + 0] = m_vertices[t.v1]; | ||
209 | result[3 * i + 1] = m_vertices[t.v2]; | ||
210 | result[3 * i + 2] = m_vertices[t.v3]; | ||
182 | } | 211 | } |
183 | return result; | 212 | return result; |
184 | } | 213 | } |
@@ -189,19 +218,48 @@ namespace OpenSim.Region.Physics.Meshing | |||
189 | /// <returns></returns> | 218 | /// <returns></returns> |
190 | public int[] getIndexListAsIntLocked() | 219 | public int[] getIndexListAsIntLocked() |
191 | { | 220 | { |
192 | if (pinnedIndex.IsAllocated) | 221 | if (m_pinnedIndex.IsAllocated) |
193 | return (int[])(pinnedIndex.Target); | 222 | return (int[])(m_pinnedIndex.Target); |
194 | 223 | ||
195 | int[] result = getIndexListAsInt(); | 224 | int[] result = getIndexListAsInt(); |
196 | pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); | 225 | m_pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); |
197 | 226 | ||
198 | return result; | 227 | return result; |
199 | } | 228 | } |
200 | 229 | ||
230 | public void getIndexListAsPtrToIntArray(out IntPtr indices, out int triStride, out int indexCount) | ||
231 | { | ||
232 | // If there isn't an unmanaged array allocated yet, do it now | ||
233 | if (m_indicesPtr == IntPtr.Zero) | ||
234 | { | ||
235 | int[] indexList = getIndexListAsInt(); | ||
236 | m_indexCount = indexList.Length; | ||
237 | int byteCount = m_indexCount * sizeof(int); | ||
238 | m_indicesPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(byteCount); | ||
239 | System.Runtime.InteropServices.Marshal.Copy(indexList, 0, m_indicesPtr, m_indexCount); | ||
240 | } | ||
241 | // A triangle is 3 ints (indices) | ||
242 | triStride = 3 * sizeof(int); | ||
243 | indices = m_indicesPtr; | ||
244 | indexCount = m_indexCount; | ||
245 | } | ||
246 | |||
201 | public void releasePinned() | 247 | public void releasePinned() |
202 | { | 248 | { |
203 | pinnedVirtexes.Free(); | 249 | if (m_pinnedVertexes.IsAllocated) |
204 | pinnedIndex.Free(); | 250 | m_pinnedVertexes.Free(); |
251 | if (m_pinnedIndex.IsAllocated) | ||
252 | m_pinnedIndex.Free(); | ||
253 | if (m_verticesPtr != IntPtr.Zero) | ||
254 | { | ||
255 | System.Runtime.InteropServices.Marshal.FreeHGlobal(m_verticesPtr); | ||
256 | m_verticesPtr = IntPtr.Zero; | ||
257 | } | ||
258 | if (m_indicesPtr != IntPtr.Zero) | ||
259 | { | ||
260 | System.Runtime.InteropServices.Marshal.FreeHGlobal(m_indicesPtr); | ||
261 | m_indicesPtr = IntPtr.Zero; | ||
262 | } | ||
205 | } | 263 | } |
206 | 264 | ||
207 | /// <summary> | 265 | /// <summary> |
@@ -209,29 +267,29 @@ namespace OpenSim.Region.Physics.Meshing | |||
209 | /// </summary> | 267 | /// </summary> |
210 | public void releaseSourceMeshData() | 268 | public void releaseSourceMeshData() |
211 | { | 269 | { |
212 | triangles = null; | 270 | m_triangles = null; |
213 | vertices = null; | 271 | m_vertices = null; |
214 | } | 272 | } |
215 | 273 | ||
216 | public void Append(IMesh newMesh) | 274 | public void Append(IMesh newMesh) |
217 | { | 275 | { |
218 | if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated) | 276 | if (m_pinnedIndex.IsAllocated || m_pinnedVertexes.IsAllocated || m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) |
219 | throw new NotSupportedException("Attempt to Append to a pinned Mesh"); | 277 | throw new NotSupportedException("Attempt to Append to a pinned Mesh"); |
220 | 278 | ||
221 | if (!(newMesh is Mesh)) | 279 | if (!(newMesh is Mesh)) |
222 | return; | 280 | return; |
223 | 281 | ||
224 | foreach (Triangle t in ((Mesh)newMesh).triangles) | 282 | foreach (Triangle t in ((Mesh)newMesh).m_triangles) |
225 | Add(t); | 283 | Add(t); |
226 | } | 284 | } |
227 | 285 | ||
228 | // Do a linear transformation of mesh. | 286 | // Do a linear transformation of mesh. |
229 | public void TransformLinear(float[,] matrix, float[] offset) | 287 | public void TransformLinear(float[,] matrix, float[] offset) |
230 | { | 288 | { |
231 | if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated) | 289 | if (m_pinnedIndex.IsAllocated || m_pinnedVertexes.IsAllocated || m_indicesPtr != IntPtr.Zero || m_verticesPtr != IntPtr.Zero) |
232 | throw new NotSupportedException("Attempt to TransformLinear a pinned Mesh"); | 290 | throw new NotSupportedException("Attempt to TransformLinear a pinned Mesh"); |
233 | 291 | ||
234 | foreach (Vertex v in vertices.Keys) | 292 | foreach (Vertex v in m_vertices.Keys) |
235 | { | 293 | { |
236 | if (v == null) | 294 | if (v == null) |
237 | continue; | 295 | continue; |
@@ -252,7 +310,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
252 | String fileName = name + "_" + title + ".raw"; | 310 | String fileName = name + "_" + title + ".raw"; |
253 | String completePath = Path.Combine(path, fileName); | 311 | String completePath = Path.Combine(path, fileName); |
254 | StreamWriter sw = new StreamWriter(completePath); | 312 | StreamWriter sw = new StreamWriter(completePath); |
255 | foreach (Triangle t in triangles) | 313 | foreach (Triangle t in m_triangles) |
256 | { | 314 | { |
257 | String s = t.ToStringRaw(); | 315 | String s = t.ToStringRaw(); |
258 | sw.WriteLine(s); | 316 | sw.WriteLine(s); |
@@ -262,7 +320,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
262 | 320 | ||
263 | public void TrimExcess() | 321 | public void TrimExcess() |
264 | { | 322 | { |
265 | triangles.TrimExcess(); | 323 | m_triangles.TrimExcess(); |
266 | } | 324 | } |
267 | } | 325 | } |
268 | } | 326 | } |
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 0e29ccc..1ea08e2 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs | |||
@@ -498,12 +498,9 @@ namespace OpenSim.Region.Physics.Meshing | |||
498 | // If this mesh has been created already, return it instead of creating another copy | 498 | // If this mesh has been created already, return it instead of creating another copy |
499 | // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory | 499 | // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory |
500 | 500 | ||
501 | if (! primShape.SculptEntry) | 501 | key = GetMeshKey(primShape, size, lod); |
502 | { | 502 | if (m_uniqueMeshes.TryGetValue(key, out mesh)) |
503 | key = GetMeshKey(primShape, size, lod); | 503 | return mesh; |
504 | if (m_uniqueMeshes.TryGetValue(key, out mesh)) | ||
505 | return mesh; | ||
506 | } | ||
507 | 504 | ||
508 | if (size.X < 0.01f) size.X = 0.01f; | 505 | if (size.X < 0.01f) size.X = 0.01f; |
509 | if (size.Y < 0.01f) size.Y = 0.01f; | 506 | if (size.Y < 0.01f) size.Y = 0.01f; |
@@ -525,10 +522,9 @@ namespace OpenSim.Region.Physics.Meshing | |||
525 | 522 | ||
526 | // trim the vertex and triangle lists to free up memory | 523 | // trim the vertex and triangle lists to free up memory |
527 | mesh.TrimExcess(); | 524 | mesh.TrimExcess(); |
528 | } | ||
529 | 525 | ||
530 | if (!primShape.SculptEntry) | ||
531 | m_uniqueMeshes.Add(key, mesh); | 526 | m_uniqueMeshes.Add(key, mesh); |
527 | } | ||
532 | 528 | ||
533 | return mesh; | 529 | return mesh; |
534 | } | 530 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 032b5df..c041243 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -813,18 +813,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
813 | } | 813 | } |
814 | } | 814 | } |
815 | 815 | ||
816 | float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory | 816 | IntPtr vertices, indices; |
817 | int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage | 817 | int vertexCount, indexCount; |
818 | int vertexStride, triStride; | ||
819 | mesh.getVertexListAsPtrToFloatArray( out vertices, out vertexStride, out vertexCount ); // Note, that vertices are fixed in unmanaged heap | ||
820 | mesh.getIndexListAsPtrToIntArray( out indices, out triStride, out indexCount ); // Also fixed, needs release after usage | ||
818 | 821 | ||
819 | mesh.releaseSourceMeshData(); // free up the original mesh data to save memory | 822 | mesh.releaseSourceMeshData(); // free up the original mesh data to save memory |
820 | 823 | ||
821 | int VertexCount = vertexList.GetLength(0)/3; | ||
822 | int IndexCount = indexList.GetLength(0); | ||
823 | |||
824 | _triMeshData = d.GeomTriMeshDataCreate(); | 824 | _triMeshData = d.GeomTriMeshDataCreate(); |
825 | 825 | ||
826 | d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3*sizeof (float), VertexCount, indexList, IndexCount, | 826 | d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); |
827 | 3*sizeof (int)); | ||
828 | d.GeomTriMeshDataPreprocess(_triMeshData); | 827 | d.GeomTriMeshDataPreprocess(_triMeshData); |
829 | 828 | ||
830 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 829 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 0769c90..f5ab1de 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -3476,7 +3476,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3476 | public override void UnCombine(PhysicsScene pScene) | 3476 | public override void UnCombine(PhysicsScene pScene) |
3477 | { | 3477 | { |
3478 | IntPtr localGround = IntPtr.Zero; | 3478 | IntPtr localGround = IntPtr.Zero; |
3479 | float[] localHeightfield; | 3479 | //float[] localHeightfield; |
3480 | bool proceed = false; | 3480 | bool proceed = false; |
3481 | List<IntPtr> geomDestroyList = new List<IntPtr>(); | 3481 | List<IntPtr> geomDestroyList = new List<IntPtr>(); |
3482 | 3482 | ||
@@ -3771,16 +3771,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3771 | sides.Z = 0.5f; | 3771 | sides.Z = 0.5f; |
3772 | 3772 | ||
3773 | ds.DrawBox(ref pos, ref R, ref sides); | 3773 | ds.DrawBox(ref pos, ref R, ref sides); |
3774 | |||
3775 | |||
3776 | } | 3774 | } |
3777 | } | 3775 | } |
3778 | } | 3776 | } |
3779 | } | 3777 | } |
3780 | 3778 | ||
3781 | public void start(int unused) | 3779 | public void start(int unused) |
3782 | { | 3780 | { |
3783 | |||
3784 | ds.SetViewpoint(ref xyz, ref hpr); | 3781 | ds.SetViewpoint(ref xyz, ref hpr); |
3785 | } | 3782 | } |
3786 | #endif | 3783 | #endif |
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 0964caa..9d9735e 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -260,7 +260,7 @@ namespace OpenSim.Server.Base | |||
260 | 260 | ||
261 | public static Dictionary<string, object> ParseXmlResponse(string data) | 261 | public static Dictionary<string, object> ParseXmlResponse(string data) |
262 | { | 262 | { |
263 | //m_log.DebugFormat("[XXX]: received xml string: {0}", data); | 263 | m_log.DebugFormat("[XXX]: received xml string: {0}", data); |
264 | 264 | ||
265 | Dictionary<string, object> ret = new Dictionary<string, object>(); | 265 | Dictionary<string, object> ret = new Dictionary<string, object>(); |
266 | 266 | ||
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index e22328d..433ed0b 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -67,43 +67,50 @@ namespace OpenSim.Server.Handlers.Grid | |||
67 | 67 | ||
68 | //m_log.DebugFormat("[XXX]: query String: {0}", body); | 68 | //m_log.DebugFormat("[XXX]: query String: {0}", body); |
69 | 69 | ||
70 | Dictionary<string, string> request = | 70 | try |
71 | ServerUtils.ParseQueryString(body); | 71 | { |
72 | Dictionary<string, string> request = | ||
73 | ServerUtils.ParseQueryString(body); | ||
72 | 74 | ||
73 | if (!request.ContainsKey("METHOD")) | 75 | if (!request.ContainsKey("METHOD")) |
74 | return FailureResult(); | 76 | return FailureResult(); |
75 | 77 | ||
76 | string method = request["METHOD"]; | 78 | string method = request["METHOD"]; |
77 | 79 | ||
78 | switch (method) | 80 | switch (method) |
79 | { | 81 | { |
80 | case "register": | 82 | case "register": |
81 | return Register(request); | 83 | return Register(request); |
82 | 84 | ||
83 | case "deregister": | 85 | case "deregister": |
84 | return Deregister(request); | 86 | return Deregister(request); |
85 | 87 | ||
86 | case "get_neighbours": | 88 | case "get_neighbours": |
87 | return GetNeighbours(request); | 89 | return GetNeighbours(request); |
88 | 90 | ||
89 | case "get_region_by_uuid": | 91 | case "get_region_by_uuid": |
90 | return GetRegionByUUID(request); | 92 | return GetRegionByUUID(request); |
91 | 93 | ||
92 | case "get_region_by_position": | 94 | case "get_region_by_position": |
93 | return GetRegionByPosition(request); | 95 | return GetRegionByPosition(request); |
94 | 96 | ||
95 | case "get_region_by_name": | 97 | case "get_region_by_name": |
96 | return GetRegionByName(request); | 98 | return GetRegionByName(request); |
97 | 99 | ||
98 | case "get_regions_by_name": | 100 | case "get_regions_by_name": |
99 | return GetRegionsByName(request); | 101 | return GetRegionsByName(request); |
100 | 102 | ||
101 | case "get_region_range": | 103 | case "get_region_range": |
102 | return GetRegionRange(request); | 104 | return GetRegionRange(request); |
103 | 105 | ||
106 | } | ||
107 | m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); | ||
108 | } | ||
109 | catch (Exception e) | ||
110 | { | ||
111 | m_log.DebugFormat("[GRID HANDLER]: Exception {0}", e); | ||
104 | } | 112 | } |
105 | 113 | ||
106 | m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); | ||
107 | return FailureResult(); | 114 | return FailureResult(); |
108 | 115 | ||
109 | } | 116 | } |
@@ -113,7 +120,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
113 | byte[] Register(Dictionary<string, string> request) | 120 | byte[] Register(Dictionary<string, string> request) |
114 | { | 121 | { |
115 | UUID scopeID = UUID.Zero; | 122 | UUID scopeID = UUID.Zero; |
116 | if (request["SCOPEID"] != null) | 123 | if (request.ContainsKey("SCOPEID")) |
117 | UUID.TryParse(request["SCOPEID"], out scopeID); | 124 | UUID.TryParse(request["SCOPEID"], out scopeID); |
118 | else | 125 | else |
119 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); | 126 | m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region"); |
@@ -137,11 +144,21 @@ namespace OpenSim.Server.Handlers.Grid | |||
137 | } | 144 | } |
138 | 145 | ||
139 | Dictionary<string, object> rinfoData = new Dictionary<string, object>(); | 146 | Dictionary<string, object> rinfoData = new Dictionary<string, object>(); |
140 | foreach (KeyValuePair<string, string> kvp in request) | 147 | GridRegion rinfo = null; |
141 | rinfoData[kvp.Key] = kvp.Value; | 148 | try |
142 | GridRegion rinfo = new GridRegion(rinfoData); | 149 | { |
150 | foreach (KeyValuePair<string, string> kvp in request) | ||
151 | rinfoData[kvp.Key] = kvp.Value; | ||
152 | rinfo = new GridRegion(rinfoData); | ||
153 | } | ||
154 | catch (Exception e) | ||
155 | { | ||
156 | m_log.DebugFormat("[GRID HANDLER]: exception unpacking region data: {0}", e); | ||
157 | } | ||
143 | 158 | ||
144 | bool result = m_GridService.RegisterRegion(scopeID, rinfo); | 159 | bool result = false; |
160 | if (rinfo != null) | ||
161 | result = m_GridService.RegisterRegion(scopeID, rinfo); | ||
145 | 162 | ||
146 | if (result) | 163 | if (result) |
147 | return SuccessResult(); | 164 | return SuccessResult(); |
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index b1d41da..6f7c90f 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -171,6 +171,8 @@ namespace OpenSim.Services.Connectors | |||
171 | 171 | ||
172 | if (asset == null) | 172 | if (asset == null) |
173 | { | 173 | { |
174 | bool result = false; | ||
175 | |||
174 | AsynchronousRestObjectRequester. | 176 | AsynchronousRestObjectRequester. |
175 | MakeRequest<int, AssetBase>("GET", uri, 0, | 177 | MakeRequest<int, AssetBase>("GET", uri, 0, |
176 | delegate(AssetBase a) | 178 | delegate(AssetBase a) |
@@ -178,8 +180,10 @@ namespace OpenSim.Services.Connectors | |||
178 | if (m_Cache != null) | 180 | if (m_Cache != null) |
179 | m_Cache.Cache(a); | 181 | m_Cache.Cache(a); |
180 | handler(id, sender, a); | 182 | handler(id, sender, a); |
183 | result = true; | ||
181 | }); | 184 | }); |
182 | 185 | ||
186 | return result; | ||
183 | } | 187 | } |
184 | else | 188 | else |
185 | { | 189 | { |
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index ba46b0d..acdf558 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -109,8 +109,13 @@ namespace OpenSim.Services.Connectors | |||
109 | { | 109 | { |
110 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | 110 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
111 | 111 | ||
112 | if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) | 112 | if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success")) |
113 | return true; | 113 | return true; |
114 | else if (!replyData.ContainsKey("Result")) | ||
115 | m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field"); | ||
116 | else | ||
117 | m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); | ||
118 | |||
114 | } | 119 | } |
115 | else | 120 | else |
116 | m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); | 121 | m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply"); |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 991acf2..a2e4771 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -69,18 +69,40 @@ namespace OpenSim.Services.GridService | |||
69 | ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) | 69 | ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) |
70 | { | 70 | { |
71 | // Region reregistering in other coordinates. Delete the old entry | 71 | // Region reregistering in other coordinates. Delete the old entry |
72 | m_Database.Delete(regionInfos.RegionID); | 72 | m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", |
73 | regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); | ||
74 | |||
75 | try | ||
76 | { | ||
77 | m_Database.Delete(regionInfos.RegionID); | ||
78 | } | ||
79 | catch (Exception e) | ||
80 | { | ||
81 | m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); | ||
82 | } | ||
73 | } | 83 | } |
74 | 84 | ||
75 | // Everything is ok, let's register | 85 | // Everything is ok, let's register |
76 | RegionData rdata = RegionInfo2RegionData(regionInfos); | 86 | RegionData rdata = RegionInfo2RegionData(regionInfos); |
77 | rdata.ScopeID = scopeID; | 87 | rdata.ScopeID = scopeID; |
78 | m_Database.Store(rdata); | 88 | try |
89 | { | ||
90 | m_Database.Store(rdata); | ||
91 | } | ||
92 | catch (Exception e) | ||
93 | { | ||
94 | m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); | ||
95 | } | ||
96 | |||
97 | m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", | ||
98 | regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); | ||
99 | |||
79 | return true; | 100 | return true; |
80 | } | 101 | } |
81 | 102 | ||
82 | public bool DeregisterRegion(UUID regionID) | 103 | public bool DeregisterRegion(UUID regionID) |
83 | { | 104 | { |
105 | m_log.DebugFormat("[GRID SERVICE]: Region {0} deregistered", regionID); | ||
84 | return m_Database.Delete(regionID); | 106 | return m_Database.Delete(regionID); |
85 | } | 107 | } |
86 | 108 | ||