1
0

MySQLRegionData.cs 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537
  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 OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Data;
  30. using System.Drawing;
  31. using System.IO;
  32. using System.Reflection;
  33. using System.Threading;
  34. using log4net;
  35. using MySql.Data.MySqlClient;
  36. using OpenMetaverse;
  37. using OpenSim.Framework;
  38. using OpenSim.Region.Framework.Interfaces;
  39. using OpenSim.Region.Framework.Scenes;
  40. namespace OpenSim.Data.MySQL
  41. {
  42. /// <summary>
  43. /// A MySQL Interface for the Region Server
  44. /// </summary>
  45. public class MySQLDataStore : IRegionDataStore
  46. {
  47. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  48. private string m_ConnectionString;
  49. private MySqlConnection m_Connection = null;
  50. public void Initialise(string connectionString)
  51. {
  52. m_ConnectionString = connectionString;
  53. m_Connection = new MySqlConnection(m_ConnectionString);
  54. m_Connection.Open();
  55. // Apply new Migrations
  56. //
  57. Assembly assem = GetType().Assembly;
  58. Migration m = new Migration(m_Connection, assem, "RegionStore");
  59. m.Update();
  60. // Clean dropped attachments
  61. //
  62. MySqlCommand cmd = m_Connection.CreateCommand();
  63. cmd.CommandText = "delete from prims, primshapes using prims " +
  64. "left join primshapes on prims.uuid = primshapes.uuid " +
  65. "where PCode = 9 and State <> 0";
  66. ExecuteNonQuery(cmd);
  67. cmd.Dispose();
  68. }
  69. private IDataReader ExecuteReader(MySqlCommand c)
  70. {
  71. IDataReader r = null;
  72. bool errorSeen = false;
  73. while (true)
  74. {
  75. try
  76. {
  77. r = c.ExecuteReader();
  78. }
  79. catch (Exception)
  80. {
  81. Thread.Sleep(500);
  82. m_Connection.Close();
  83. m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone();
  84. m_Connection.Open();
  85. c.Connection = m_Connection;
  86. if (!errorSeen)
  87. {
  88. errorSeen = true;
  89. continue;
  90. }
  91. throw;
  92. }
  93. break;
  94. }
  95. return r;
  96. }
  97. private void ExecuteNonQuery(MySqlCommand c)
  98. {
  99. bool errorSeen = false;
  100. while (true)
  101. {
  102. try
  103. {
  104. c.ExecuteNonQuery();
  105. }
  106. catch (Exception)
  107. {
  108. Thread.Sleep(500);
  109. m_Connection.Close();
  110. m_Connection = (MySqlConnection) ((ICloneable)m_Connection).Clone();
  111. m_Connection.Open();
  112. c.Connection = m_Connection;
  113. if (!errorSeen)
  114. {
  115. errorSeen = true;
  116. continue;
  117. }
  118. throw;
  119. }
  120. break;
  121. }
  122. }
  123. public void Dispose() {}
  124. public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
  125. {
  126. uint flags = obj.RootPart.GetEffectiveObjectFlags();
  127. // Eligibility check
  128. //
  129. if ((flags & (uint)PrimFlags.Temporary) != 0)
  130. return;
  131. if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
  132. return;
  133. lock (m_Connection)
  134. {
  135. MySqlCommand cmd = m_Connection.CreateCommand();
  136. foreach (SceneObjectPart prim in obj.Children.Values)
  137. {
  138. cmd.Parameters.Clear();
  139. cmd.CommandText = "replace into prims ("+
  140. "UUID, CreationDate, "+
  141. "Name, Text, Description, "+
  142. "SitName, TouchName, ObjectFlags, "+
  143. "OwnerMask, NextOwnerMask, GroupMask, "+
  144. "EveryoneMask, BaseMask, PositionX, "+
  145. "PositionY, PositionZ, GroupPositionX, "+
  146. "GroupPositionY, GroupPositionZ, VelocityX, "+
  147. "VelocityY, VelocityZ, AngularVelocityX, "+
  148. "AngularVelocityY, AngularVelocityZ, "+
  149. "AccelerationX, AccelerationY, "+
  150. "AccelerationZ, RotationX, "+
  151. "RotationY, RotationZ, "+
  152. "RotationW, SitTargetOffsetX, "+
  153. "SitTargetOffsetY, SitTargetOffsetZ, "+
  154. "SitTargetOrientW, SitTargetOrientX, "+
  155. "SitTargetOrientY, SitTargetOrientZ, "+
  156. "RegionUUID, CreatorID, "+
  157. "OwnerID, GroupID, "+
  158. "LastOwnerID, SceneGroupID, "+
  159. "PayPrice, PayButton1, "+
  160. "PayButton2, PayButton3, "+
  161. "PayButton4, LoopedSound, "+
  162. "LoopedSoundGain, TextureAnimation, "+
  163. "OmegaX, OmegaY, OmegaZ, "+
  164. "CameraEyeOffsetX, CameraEyeOffsetY, "+
  165. "CameraEyeOffsetZ, CameraAtOffsetX, "+
  166. "CameraAtOffsetY, CameraAtOffsetZ, "+
  167. "ForceMouselook, ScriptAccessPin, "+
  168. "AllowedDrop, DieAtEdge, "+
  169. "SalePrice, SaleType, "+
  170. "ColorR, ColorG, ColorB, ColorA, "+
  171. "ParticleSystem, ClickAction, Material, "+
  172. "CollisionSound, CollisionSoundVolume, "+
  173. "LinkNumber) values (" + "?UUID, "+
  174. "?CreationDate, ?Name, ?Text, "+
  175. "?Description, ?SitName, ?TouchName, "+
  176. "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, "+
  177. "?GroupMask, ?EveryoneMask, ?BaseMask, "+
  178. "?PositionX, ?PositionY, ?PositionZ, "+
  179. "?GroupPositionX, ?GroupPositionY, "+
  180. "?GroupPositionZ, ?VelocityX, "+
  181. "?VelocityY, ?VelocityZ, ?AngularVelocityX, "+
  182. "?AngularVelocityY, ?AngularVelocityZ, "+
  183. "?AccelerationX, ?AccelerationY, "+
  184. "?AccelerationZ, ?RotationX, "+
  185. "?RotationY, ?RotationZ, "+
  186. "?RotationW, ?SitTargetOffsetX, "+
  187. "?SitTargetOffsetY, ?SitTargetOffsetZ, "+
  188. "?SitTargetOrientW, ?SitTargetOrientX, "+
  189. "?SitTargetOrientY, ?SitTargetOrientZ, "+
  190. "?RegionUUID, ?CreatorID, ?OwnerID, "+
  191. "?GroupID, ?LastOwnerID, ?SceneGroupID, "+
  192. "?PayPrice, ?PayButton1, ?PayButton2, "+
  193. "?PayButton3, ?PayButton4, ?LoopedSound, "+
  194. "?LoopedSoundGain, ?TextureAnimation, "+
  195. "?OmegaX, ?OmegaY, ?OmegaZ, "+
  196. "?CameraEyeOffsetX, ?CameraEyeOffsetY, "+
  197. "?CameraEyeOffsetZ, ?CameraAtOffsetX, "+
  198. "?CameraAtOffsetY, ?CameraAtOffsetZ, "+
  199. "?ForceMouselook, ?ScriptAccessPin, "+
  200. "?AllowedDrop, ?DieAtEdge, ?SalePrice, "+
  201. "?SaleType, ?ColorR, ?ColorG, "+
  202. "?ColorB, ?ColorA, ?ParticleSystem, "+
  203. "?ClickAction, ?Material, ?CollisionSound, "+
  204. "?CollisionSoundVolume, ?LinkNumber)";
  205. FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
  206. ExecuteNonQuery(cmd);
  207. cmd.Parameters.Clear();
  208. cmd.CommandText = "replace into primshapes ("+
  209. "UUID, Shape, ScaleX, ScaleY, "+
  210. "ScaleZ, PCode, PathBegin, PathEnd, "+
  211. "PathScaleX, PathScaleY, PathShearX, "+
  212. "PathShearY, PathSkew, PathCurve, "+
  213. "PathRadiusOffset, PathRevolutions, "+
  214. "PathTaperX, PathTaperY, PathTwist, "+
  215. "PathTwistBegin, ProfileBegin, ProfileEnd, "+
  216. "ProfileCurve, ProfileHollow, Texture, "+
  217. "ExtraParams, State) values (?UUID, "+
  218. "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, "+
  219. "?PCode, ?PathBegin, ?PathEnd, "+
  220. "?PathScaleX, ?PathScaleY, "+
  221. "?PathShearX, ?PathShearY, "+
  222. "?PathSkew, ?PathCurve, ?PathRadiusOffset, "+
  223. "?PathRevolutions, ?PathTaperX, "+
  224. "?PathTaperY, ?PathTwist, "+
  225. "?PathTwistBegin, ?ProfileBegin, "+
  226. "?ProfileEnd, ?ProfileCurve, "+
  227. "?ProfileHollow, ?Texture, ?ExtraParams, "+
  228. "?State)";
  229. FillShapeCommand(cmd, prim);
  230. ExecuteNonQuery(cmd);
  231. }
  232. cmd.Dispose();
  233. }
  234. }
  235. public void RemoveObject(UUID obj, UUID regionUUID)
  236. {
  237. // Formerly, this used to check the region UUID.
  238. // That makes no sense, as we remove the contents of a prim
  239. // unconditionally, but the prim dependent on the region ID.
  240. // So, we would destroy an object and cause hard to detect
  241. // issues if we delete the contents only. Deleting it all may
  242. // cause the loss of a prim, but is cleaner.
  243. // It's also faster because it uses the primary key.
  244. //
  245. lock (m_Connection)
  246. {
  247. MySqlCommand cmd = m_Connection.CreateCommand();
  248. cmd.CommandText = "select UUID from prims where "+
  249. "SceneGroupID= ?UUID";
  250. cmd.Parameters.AddWithValue("UUID", obj.ToString());
  251. List<UUID> uuids = new List<UUID>();
  252. IDataReader reader = ExecuteReader(cmd);
  253. try
  254. {
  255. while (reader.Read())
  256. {
  257. uuids.Add(new UUID(reader["UUID"].ToString()));
  258. }
  259. }
  260. finally
  261. {
  262. reader.Close();
  263. }
  264. // delete the main prims
  265. cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
  266. ExecuteNonQuery(cmd);
  267. cmd.Dispose();
  268. // there is no way this should be < 1 unless there is
  269. // a very corrupt database, but in that case be extra
  270. // safe anyway.
  271. if (uuids.Count > 0)
  272. {
  273. RemoveShapes(uuids);
  274. RemoveItems(uuids);
  275. }
  276. }
  277. }
  278. /// <summary>
  279. /// Remove all persisted items of the given prim.
  280. /// The caller must acquire the necessrary synchronization locks
  281. /// </summary>
  282. /// <param name="uuid">the Item UUID</param>
  283. private void RemoveItems(UUID uuid)
  284. {
  285. lock (m_Connection)
  286. {
  287. MySqlCommand cmd = m_Connection.CreateCommand();
  288. cmd.CommandText = "delete from primitems where " +
  289. "PrimID = ?PrimID";
  290. cmd.Parameters.AddWithValue("PrimID", uuid.ToString());
  291. ExecuteNonQuery(cmd);
  292. cmd.Dispose();
  293. }
  294. }
  295. /// <summary>
  296. /// Remove all persisted shapes for a list of prims
  297. /// The caller must acquire the necessrary synchronization locks
  298. /// </summary>
  299. /// <param name="uuids">the list of UUIDs</param>
  300. private void RemoveShapes(List<UUID> uuids)
  301. {
  302. lock (m_Connection)
  303. {
  304. string sql = "delete from primshapes where ";
  305. MySqlCommand cmd = m_Connection.CreateCommand();
  306. for (int i = 0; i < uuids.Count; i++)
  307. {
  308. if ((i + 1) == uuids.Count)
  309. {// end of the list
  310. sql += "(UUID = ?UUID" + i + ")";
  311. }
  312. else
  313. {
  314. sql += "(UUID = ?UUID" + i + ") or ";
  315. }
  316. }
  317. cmd.CommandText = sql;
  318. for (int i = 0; i < uuids.Count; i++)
  319. {
  320. cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString());
  321. }
  322. ExecuteNonQuery(cmd);
  323. cmd.Dispose();
  324. }
  325. }
  326. /// <summary>
  327. /// Remove all persisted items for a list of prims
  328. /// The caller must acquire the necessrary synchronization locks
  329. /// </summary>
  330. /// <param name="uuids">the list of UUIDs</param>
  331. private void RemoveItems(List<UUID> uuids)
  332. {
  333. lock (m_Connection)
  334. {
  335. string sql = "delete from primitems where ";
  336. MySqlCommand cmd = m_Connection.CreateCommand();
  337. for (int i = 0; i < uuids.Count; i++)
  338. {
  339. if ((i + 1) == uuids.Count)
  340. {// end of the list
  341. sql += "(PrimID = ?PrimID" + i + ")";
  342. }
  343. else
  344. {
  345. sql += "(PrimID = ?PrimID" + i + ") or ";
  346. }
  347. }
  348. cmd.CommandText = sql;
  349. for (int i = 0; i < uuids.Count; i++)
  350. {
  351. cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString());
  352. }
  353. ExecuteNonQuery(cmd);
  354. cmd.Dispose();
  355. }
  356. }
  357. public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
  358. {
  359. UUID lastGroupID = UUID.Zero;
  360. List<SceneObjectGroup> objects = new List<SceneObjectGroup>();
  361. List<SceneObjectPart> prims = new List<SceneObjectPart>();
  362. SceneObjectGroup grp = null;
  363. lock (m_Connection)
  364. {
  365. MySqlCommand cmd = m_Connection.CreateCommand();
  366. cmd.CommandText = "select *, " +
  367. "case when prims.UUID = SceneGroupID " +
  368. "then 0 else 1 end as sort from prims " +
  369. "left join primshapes on prims.UUID = primshapes.UUID "+
  370. "where RegionUUID = ?RegionUUID " +
  371. "order by SceneGroupID asc, sort asc, LinkNumber asc";
  372. cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
  373. IDataReader reader = ExecuteReader(cmd);
  374. try
  375. {
  376. while (reader.Read())
  377. {
  378. SceneObjectPart prim = BuildPrim(reader);
  379. if (reader["Shape"] is DBNull)
  380. prim.Shape = PrimitiveBaseShape.Default;
  381. else
  382. prim.Shape = BuildShape(reader);
  383. prims.Add(prim);
  384. UUID groupID = new UUID(reader["SceneGroupID"].ToString());
  385. if (groupID != lastGroupID) // New SOG
  386. {
  387. if (grp != null)
  388. objects.Add(grp);
  389. lastGroupID = groupID;
  390. // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are
  391. // recorded as the root prim (for which the UUID must equal the persisted group UUID). In
  392. // this case, force the UUID to be the same as the group UUID so that at least these can be
  393. // deleted (we need to change the UUID so that any other prims in the linkset can also be
  394. // deleted).
  395. if (prim.UUID != groupID && groupID != UUID.Zero)
  396. {
  397. m_log.WarnFormat(
  398. "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID",
  399. prim.Name, prim.UUID, prim.GroupPosition, groupID);
  400. prim.UUID = groupID;
  401. }
  402. grp = new SceneObjectGroup(prim);
  403. }
  404. else
  405. {
  406. // Black magic to preserve link numbers
  407. //
  408. int link = prim.LinkNum;
  409. grp.AddPart(prim);
  410. if (link != 0)
  411. prim.LinkNum = link;
  412. }
  413. }
  414. }
  415. finally
  416. {
  417. reader.Close();
  418. }
  419. if (grp != null)
  420. objects.Add(grp);
  421. cmd.Dispose();
  422. }
  423. foreach (SceneObjectPart part in prims)
  424. LoadItems(part);
  425. m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count);
  426. return objects;
  427. }
  428. /// <summary>
  429. /// Load in a prim's persisted inventory.
  430. /// </summary>
  431. /// <param name="prim">The prim</param>
  432. private void LoadItems(SceneObjectPart prim)
  433. {
  434. lock (m_Connection)
  435. {
  436. MySqlCommand cmd = m_Connection.CreateCommand();
  437. cmd.CommandText = "select * from primitems where "+
  438. "PrimID = ?PrimID";
  439. cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString());
  440. IDataReader reader = ExecuteReader(cmd);
  441. List<TaskInventoryItem> inventory =
  442. new List<TaskInventoryItem>();
  443. try
  444. {
  445. while (reader.Read())
  446. {
  447. TaskInventoryItem item = BuildItem(reader);
  448. item.ParentID = prim.UUID; // Values in database are
  449. // often wrong
  450. inventory.Add(item);
  451. }
  452. }
  453. finally
  454. {
  455. reader.Close();
  456. }
  457. cmd.Dispose();
  458. prim.Inventory.RestoreInventoryItems(inventory);
  459. }
  460. }
  461. public void StoreTerrain(double[,] ter, UUID regionID)
  462. {
  463. m_log.Info("[REGION DB]: Storing terrain");
  464. lock (m_Connection)
  465. {
  466. MySqlCommand cmd = m_Connection.CreateCommand();
  467. cmd.CommandText = "delete from terrain where " +
  468. "RegionUUID = ?RegionUUID";
  469. cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
  470. ExecuteNonQuery(cmd);
  471. cmd.CommandText = "insert into terrain (RegionUUID, " +
  472. "Revision, Heightfield) values (?RegionUUID, " +
  473. "1, ?Heightfield)";
  474. cmd.Parameters.AddWithValue("Heightfield",
  475. SerializeTerrain(ter));
  476. ExecuteNonQuery(cmd);
  477. cmd.Dispose();
  478. }
  479. }
  480. public double[,] LoadTerrain(UUID regionID)
  481. {
  482. double[,] terrain = null;
  483. lock (m_Connection)
  484. {
  485. MySqlCommand cmd = m_Connection.CreateCommand();
  486. cmd.CommandText = "select RegionUUID, Revision, Heightfield " +
  487. "from terrain where RegionUUID = ?RegionUUID "+
  488. "order by Revision desc limit 1";
  489. cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
  490. IDataReader reader = ExecuteReader(cmd);
  491. try
  492. {
  493. while (reader.Read())
  494. {
  495. terrain = new double[256,256];
  496. terrain.Initialize();
  497. MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]);
  498. int rev = 0;
  499. BinaryReader br = new BinaryReader(mstr);
  500. for (int x = 0; x < 256; x++)
  501. {
  502. for (int y = 0; y < 256; y++)
  503. {
  504. terrain[x, y] = br.ReadDouble();
  505. }
  506. rev = Convert.ToInt32(reader["Revision"]);
  507. }
  508. m_log.InfoFormat("[REGION DB]: Loaded terrain " +
  509. "revision r{0}", rev);
  510. }
  511. }
  512. finally
  513. {
  514. reader.Close();
  515. }
  516. cmd.Dispose();
  517. }
  518. return terrain;
  519. }
  520. public void RemoveLandObject(UUID globalID)
  521. {
  522. lock (m_Connection)
  523. {
  524. MySqlCommand cmd = m_Connection.CreateCommand();
  525. cmd.CommandText = "delete from land where UUID = ?UUID";
  526. cmd.Parameters.AddWithValue("UUID", globalID.ToString());
  527. ExecuteNonQuery(cmd);
  528. cmd.Dispose();
  529. }
  530. }
  531. public void StoreLandObject(ILandObject parcel)
  532. {
  533. lock (m_Connection)
  534. {
  535. MySqlCommand cmd = m_Connection.CreateCommand();
  536. cmd.CommandText = "replace into land (UUID, RegionUUID, " +
  537. "LocalLandID, Bitmap, Name, Description, " +
  538. "OwnerUUID, IsGroupOwned, Area, AuctionID, " +
  539. "Category, ClaimDate, ClaimPrice, GroupUUID, " +
  540. "SalePrice, LandStatus, LandFlags, LandingType, " +
  541. "MediaAutoScale, MediaTextureUUID, MediaURL, " +
  542. "MusicURL, PassHours, PassPrice, SnapshotUUID, " +
  543. "UserLocationX, UserLocationY, UserLocationZ, " +
  544. "UserLookAtX, UserLookAtY, UserLookAtZ, " +
  545. "AuthbuyerID, OtherCleanTime, Dwell) values (" +
  546. "?UUID, ?RegionUUID, " +
  547. "?LocalLandID, ?Bitmap, ?Name, ?Description, " +
  548. "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " +
  549. "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " +
  550. "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " +
  551. "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " +
  552. "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " +
  553. "?UserLocationX, ?UserLocationY, ?UserLocationZ, " +
  554. "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " +
  555. "?AuthbuyerID, ?OtherCleanTime, ?Dwell)";
  556. FillLandCommand(cmd, parcel.landData, parcel.regionUUID);
  557. ExecuteNonQuery(cmd);
  558. cmd.CommandText = "delete from landaccesslist where " +
  559. "LandUUID = ?UUID";
  560. ExecuteNonQuery(cmd);
  561. cmd.Parameters.Clear();
  562. cmd.CommandText = "insert into landaccesslist (LandUUID, " +
  563. "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " +
  564. "?Flags)";
  565. foreach (ParcelManager.ParcelAccessEntry entry in
  566. parcel.landData.ParcelAccessList)
  567. {
  568. FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID);
  569. ExecuteNonQuery(cmd);
  570. cmd.Parameters.Clear();
  571. }
  572. cmd.Dispose();
  573. }
  574. }
  575. public RegionSettings LoadRegionSettings(UUID regionUUID)
  576. {
  577. RegionSettings rs = null;
  578. lock (m_Connection)
  579. {
  580. MySqlCommand cmd = m_Connection.CreateCommand();
  581. cmd.CommandText = "select * from regionsettings where " +
  582. "regionUUID = ?RegionUUID";
  583. cmd.Parameters.AddWithValue("regionUUID", regionUUID);
  584. IDataReader reader = ExecuteReader(cmd);
  585. try
  586. {
  587. if (reader.Read())
  588. {
  589. rs = BuildRegionSettings(reader);
  590. rs.OnSave += StoreRegionSettings;
  591. }
  592. else
  593. {
  594. rs = new RegionSettings();
  595. rs.RegionUUID = regionUUID;
  596. rs.OnSave += StoreRegionSettings;
  597. StoreRegionSettings(rs);
  598. }
  599. }
  600. finally
  601. {
  602. reader.Close();
  603. }
  604. cmd.Dispose();
  605. }
  606. return rs;
  607. }
  608. public void StoreRegionSettings(RegionSettings rs)
  609. {
  610. lock (m_Connection)
  611. {
  612. MySqlCommand cmd = m_Connection.CreateCommand();
  613. cmd.CommandText = "replace into regionsettings (regionUUID, " +
  614. "block_terraform, block_fly, allow_damage, " +
  615. "restrict_pushing, allow_land_resell, " +
  616. "allow_land_join_divide, block_show_in_search, " +
  617. "agent_limit, object_bonus, maturity, " +
  618. "disable_scripts, disable_collisions, " +
  619. "disable_physics, terrain_texture_1, " +
  620. "terrain_texture_2, terrain_texture_3, " +
  621. "terrain_texture_4, elevation_1_nw, " +
  622. "elevation_2_nw, elevation_1_ne, " +
  623. "elevation_2_ne, elevation_1_se, "+
  624. "elevation_2_se, elevation_1_sw, "+
  625. "elevation_2_sw, water_height, " +
  626. "terrain_raise_limit, terrain_lower_limit, " +
  627. "use_estate_sun, fixed_sun, sun_position, " +
  628. "covenant, Sandbox, sunvectorx, sunvectory, " +
  629. "sunvectorz) values ( ?RegionUUID, ?BlockTerraform, " +
  630. "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
  631. "?AllowLandResell, ?AllowLandJoinDivide, " +
  632. "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
  633. "?Maturity, ?DisableScripts, ?DisableCollisions, " +
  634. "?DisablePhysics, ?TerrainTexture1, " +
  635. "?TerrainTexture2, ?TerrainTexture3, " +
  636. "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " +
  637. "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " +
  638. "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " +
  639. "?WaterHeight, ?TerrainRaiseLimit, " +
  640. "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " +
  641. "?SunPosition, ?Covenant, ?Sandbox, " +
  642. "?SunVectorX, ?SunVectorY, ?SunVectorZ)";
  643. FillRegionSettingsCommand(cmd, rs);
  644. ExecuteNonQuery(cmd);
  645. cmd.Dispose();
  646. }
  647. }
  648. public List<LandData> LoadLandObjects(UUID regionUUID)
  649. {
  650. List<LandData> landData = new List<LandData>();
  651. lock (m_Connection)
  652. {
  653. MySqlCommand cmd = m_Connection.CreateCommand();
  654. cmd.CommandText = "select * from land where " +
  655. "RegionUUID = ?RegionUUID";
  656. cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
  657. IDataReader reader = ExecuteReader(cmd);
  658. try
  659. {
  660. while (reader.Read())
  661. {
  662. LandData newLand = BuildLandData(reader);
  663. landData.Add(newLand);
  664. }
  665. }
  666. finally
  667. {
  668. reader.Close();
  669. }
  670. foreach (LandData land in landData)
  671. {
  672. cmd.Parameters.Clear();
  673. cmd.CommandText = "select * from landaccesslist " +
  674. "where LandUUID = ?LandUUID";
  675. cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString());
  676. reader = ExecuteReader(cmd);
  677. try
  678. {
  679. while (reader.Read())
  680. {
  681. land.ParcelAccessList.Add(BuildLandAccessData(reader));
  682. }
  683. }
  684. finally
  685. {
  686. reader.Close();
  687. }
  688. }
  689. cmd.Dispose();
  690. }
  691. return landData;
  692. }
  693. public void Shutdown()
  694. {
  695. }
  696. private SceneObjectPart BuildPrim(IDataReader row)
  697. {
  698. SceneObjectPart prim = new SceneObjectPart();
  699. prim.UUID = new UUID((String) row["UUID"]);
  700. // explicit conversion of integers is required, which sort
  701. // of sucks. No idea if there is a shortcut here or not.
  702. prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
  703. prim.Name = (String) row["Name"];
  704. // various text fields
  705. prim.Text = (String) row["Text"];
  706. prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
  707. Convert.ToInt32(row["ColorR"]),
  708. Convert.ToInt32(row["ColorG"]),
  709. Convert.ToInt32(row["ColorB"]));
  710. prim.Description = (String) row["Description"];
  711. prim.SitName = (String) row["SitName"];
  712. prim.TouchName = (String) row["TouchName"];
  713. // permissions
  714. prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]);
  715. prim.CreatorID = new UUID((String) row["CreatorID"]);
  716. prim.OwnerID = new UUID((String) row["OwnerID"]);
  717. prim.GroupID = new UUID((String) row["GroupID"]);
  718. prim.LastOwnerID = new UUID((String) row["LastOwnerID"]);
  719. prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]);
  720. prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]);
  721. prim.GroupMask = Convert.ToUInt32(row["GroupMask"]);
  722. prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]);
  723. prim.BaseMask = Convert.ToUInt32(row["BaseMask"]);
  724. // vectors
  725. prim.OffsetPosition = new Vector3(
  726. Convert.ToSingle(row["PositionX"]),
  727. Convert.ToSingle(row["PositionY"]),
  728. Convert.ToSingle(row["PositionZ"])
  729. );
  730. prim.GroupPosition = new Vector3(
  731. Convert.ToSingle(row["GroupPositionX"]),
  732. Convert.ToSingle(row["GroupPositionY"]),
  733. Convert.ToSingle(row["GroupPositionZ"])
  734. );
  735. prim.Velocity = new Vector3(
  736. Convert.ToSingle(row["VelocityX"]),
  737. Convert.ToSingle(row["VelocityY"]),
  738. Convert.ToSingle(row["VelocityZ"])
  739. );
  740. prim.AngularVelocity = new Vector3(
  741. Convert.ToSingle(row["AngularVelocityX"]),
  742. Convert.ToSingle(row["AngularVelocityY"]),
  743. Convert.ToSingle(row["AngularVelocityZ"])
  744. );
  745. prim.Acceleration = new Vector3(
  746. Convert.ToSingle(row["AccelerationX"]),
  747. Convert.ToSingle(row["AccelerationY"]),
  748. Convert.ToSingle(row["AccelerationZ"])
  749. );
  750. // quaternions
  751. prim.RotationOffset = new Quaternion(
  752. Convert.ToSingle(row["RotationX"]),
  753. Convert.ToSingle(row["RotationY"]),
  754. Convert.ToSingle(row["RotationZ"]),
  755. Convert.ToSingle(row["RotationW"])
  756. );
  757. prim.SitTargetPositionLL = new Vector3(
  758. Convert.ToSingle(row["SitTargetOffsetX"]),
  759. Convert.ToSingle(row["SitTargetOffsetY"]),
  760. Convert.ToSingle(row["SitTargetOffsetZ"])
  761. );
  762. prim.SitTargetOrientationLL = new Quaternion(
  763. Convert.ToSingle(row["SitTargetOrientX"]),
  764. Convert.ToSingle(row["SitTargetOrientY"]),
  765. Convert.ToSingle(row["SitTargetOrientZ"]),
  766. Convert.ToSingle(row["SitTargetOrientW"])
  767. );
  768. prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]);
  769. prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]);
  770. prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]);
  771. prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]);
  772. prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]);
  773. prim.Sound = new UUID(row["LoopedSound"].ToString());
  774. prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]);
  775. prim.SoundFlags = 1; // If it's persisted at all, it's looped
  776. if (!(row["TextureAnimation"] is DBNull))
  777. prim.TextureAnimation = (Byte[])row["TextureAnimation"];
  778. if (!(row["ParticleSystem"] is DBNull))
  779. prim.ParticleSystem = (Byte[])row["ParticleSystem"];
  780. prim.RotationalVelocity = new Vector3(
  781. Convert.ToSingle(row["OmegaX"]),
  782. Convert.ToSingle(row["OmegaY"]),
  783. Convert.ToSingle(row["OmegaZ"])
  784. );
  785. prim.SetCameraEyeOffset(new Vector3(
  786. Convert.ToSingle(row["CameraEyeOffsetX"]),
  787. Convert.ToSingle(row["CameraEyeOffsetY"]),
  788. Convert.ToSingle(row["CameraEyeOffsetZ"])
  789. ));
  790. prim.SetCameraAtOffset(new Vector3(
  791. Convert.ToSingle(row["CameraAtOffsetX"]),
  792. Convert.ToSingle(row["CameraAtOffsetY"]),
  793. Convert.ToSingle(row["CameraAtOffsetZ"])
  794. ));
  795. if (Convert.ToInt16(row["ForceMouselook"]) != 0)
  796. prim.SetForceMouselook(true);
  797. prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]);
  798. if (Convert.ToInt16(row["AllowedDrop"]) != 0)
  799. prim.AllowedDrop = true;
  800. if (Convert.ToInt16(row["DieAtEdge"]) != 0)
  801. prim.DIE_AT_EDGE = true;
  802. prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
  803. prim.ObjectSaleType = Convert.ToByte(row["SaleType"]);
  804. prim.Material = Convert.ToByte(row["Material"]);
  805. if (!(row["ClickAction"] is DBNull))
  806. prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]);
  807. prim.CollisionSound = new UUID(row["CollisionSound"].ToString());
  808. prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]);
  809. prim.LinkNum = Convert.ToInt32(row["LinkNumber"]);
  810. return prim;
  811. }
  812. /// <summary>
  813. /// Build a prim inventory item from the persisted data.
  814. /// </summary>
  815. /// <param name="row"></param>
  816. /// <returns></returns>
  817. private static TaskInventoryItem BuildItem(IDataReader row)
  818. {
  819. TaskInventoryItem taskItem = new TaskInventoryItem();
  820. taskItem.ItemID = new UUID((String)row["itemID"]);
  821. taskItem.ParentPartID = new UUID((String)row["primID"]);
  822. taskItem.AssetID = new UUID((String)row["assetID"]);
  823. taskItem.ParentID = new UUID((String)row["parentFolderID"]);
  824. taskItem.InvType = Convert.ToInt32(row["invType"]);
  825. taskItem.Type = Convert.ToInt32(row["assetType"]);
  826. taskItem.Name = (String)row["name"];
  827. taskItem.Description = (String)row["description"];
  828. taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]);
  829. taskItem.CreatorID = new UUID((String)row["creatorID"]);
  830. taskItem.OwnerID = new UUID((String)row["ownerID"]);
  831. taskItem.LastOwnerID = new UUID((String)row["lastOwnerID"]);
  832. taskItem.GroupID = new UUID((String)row["groupID"]);
  833. taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]);
  834. taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]);
  835. taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]);
  836. taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]);
  837. taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]);
  838. taskItem.Flags = Convert.ToUInt32(row["flags"]);
  839. return taskItem;
  840. }
  841. private static RegionSettings BuildRegionSettings(IDataReader row)
  842. {
  843. RegionSettings newSettings = new RegionSettings();
  844. newSettings.RegionUUID = new UUID((string) row["regionUUID"]);
  845. newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]);
  846. newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]);
  847. newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]);
  848. newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]);
  849. newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]);
  850. newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]);
  851. newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]);
  852. newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]);
  853. newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]);
  854. newSettings.Maturity = Convert.ToInt32(row["maturity"]);
  855. newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]);
  856. newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]);
  857. newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]);
  858. newSettings.TerrainTexture1 = new UUID((String) row["terrain_texture_1"]);
  859. newSettings.TerrainTexture2 = new UUID((String) row["terrain_texture_2"]);
  860. newSettings.TerrainTexture3 = new UUID((String) row["terrain_texture_3"]);
  861. newSettings.TerrainTexture4 = new UUID((String) row["terrain_texture_4"]);
  862. newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]);
  863. newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]);
  864. newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]);
  865. newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]);
  866. newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]);
  867. newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]);
  868. newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]);
  869. newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]);
  870. newSettings.WaterHeight = Convert.ToDouble(row["water_height"]);
  871. newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]);
  872. newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]);
  873. newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]);
  874. newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]);
  875. newSettings.SunVector = new Vector3 (
  876. Convert.ToSingle(row["sunvectorx"]),
  877. Convert.ToSingle(row["sunvectory"]),
  878. Convert.ToSingle(row["sunvectorz"])
  879. );
  880. newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]);
  881. newSettings.SunPosition = Convert.ToDouble(row["sun_position"]);
  882. newSettings.Covenant = new UUID((String) row["covenant"]);
  883. return newSettings;
  884. }
  885. /// <summary>
  886. ///
  887. /// </summary>
  888. /// <param name="row"></param>
  889. /// <returns></returns>
  890. private static LandData BuildLandData(IDataReader row)
  891. {
  892. LandData newData = new LandData();
  893. newData.GlobalID = new UUID((String) row["UUID"]);
  894. newData.LocalID = Convert.ToInt32(row["LocalLandID"]);
  895. // Bitmap is a byte[512]
  896. newData.Bitmap = (Byte[]) row["Bitmap"];
  897. newData.Name = (String) row["Name"];
  898. newData.Description = (String) row["Description"];
  899. newData.OwnerID = new UUID((String)row["OwnerUUID"]);
  900. newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]);
  901. newData.Area = Convert.ToInt32(row["Area"]);
  902. newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented
  903. newData.Category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]);
  904. //Enum libsecondlife.Parcel.ParcelCategory
  905. newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]);
  906. newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]);
  907. newData.GroupID = new UUID((String) row["GroupUUID"]);
  908. newData.SalePrice = Convert.ToInt32(row["SalePrice"]);
  909. newData.Status = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]);
  910. //Enum. libsecondlife.Parcel.ParcelStatus
  911. newData.Flags = Convert.ToUInt32(row["LandFlags"]);
  912. newData.LandingType = Convert.ToByte(row["LandingType"]);
  913. newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]);
  914. newData.MediaID = new UUID((String) row["MediaTextureUUID"]);
  915. newData.MediaURL = (String) row["MediaURL"];
  916. newData.MusicURL = (String) row["MusicURL"];
  917. newData.PassHours = Convert.ToSingle(row["PassHours"]);
  918. newData.PassPrice = Convert.ToInt32(row["PassPrice"]);
  919. UUID authedbuyer = UUID.Zero;
  920. UUID snapshotID = UUID.Zero;
  921. UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer);
  922. UUID.TryParse((string)row["SnapshotUUID"], out snapshotID);
  923. newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]);
  924. newData.Dwell = Convert.ToInt32(row["Dwell"]);
  925. newData.AuthBuyerID = authedbuyer;
  926. newData.SnapshotID = snapshotID;
  927. try
  928. {
  929. newData.UserLocation =
  930. new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]),
  931. Convert.ToSingle(row["UserLocationZ"]));
  932. newData.UserLookAt =
  933. new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]),
  934. Convert.ToSingle(row["UserLookAtZ"]));
  935. }
  936. catch (InvalidCastException)
  937. {
  938. newData.UserLocation = Vector3.Zero;
  939. newData.UserLookAt = Vector3.Zero;
  940. m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name);
  941. }
  942. newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
  943. return newData;
  944. }
  945. /// <summary>
  946. ///
  947. /// </summary>
  948. /// <param name="row"></param>
  949. /// <returns></returns>
  950. private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row)
  951. {
  952. ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
  953. entry.AgentID = new UUID((string) row["AccessUUID"]);
  954. entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]);
  955. entry.Time = new DateTime();
  956. return entry;
  957. }
  958. /// <summary>
  959. ///
  960. /// </summary>
  961. /// <param name="val"></param>
  962. /// <returns></returns>
  963. private static Array SerializeTerrain(double[,] val)
  964. {
  965. MemoryStream str = new MemoryStream(65536*sizeof (double));
  966. BinaryWriter bw = new BinaryWriter(str);
  967. // TODO: COMPATIBILITY - Add byte-order conversions
  968. for (int x = 0; x < 256; x++)
  969. for (int y = 0; y < 256; y++)
  970. {
  971. double height = val[x, y];
  972. if (height == 0.0)
  973. height = double.Epsilon;
  974. bw.Write(height);
  975. }
  976. return str.ToArray();
  977. }
  978. /// <summary>
  979. /// Fill the prim command with prim values
  980. /// </summary>
  981. /// <param name="row"></param>
  982. /// <param name="prim"></param>
  983. /// <param name="sceneGroupID"></param>
  984. /// <param name="regionUUID"></param>
  985. private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
  986. {
  987. cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString());
  988. cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
  989. cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate);
  990. cmd.Parameters.AddWithValue("Name", prim.Name);
  991. cmd.Parameters.AddWithValue("SceneGroupID", sceneGroupID.ToString());
  992. // the UUID of the root part for this SceneObjectGroup
  993. // various text fields
  994. cmd.Parameters.AddWithValue("Text", prim.Text);
  995. cmd.Parameters.AddWithValue("ColorR", prim.Color.R);
  996. cmd.Parameters.AddWithValue("ColorG", prim.Color.G);
  997. cmd.Parameters.AddWithValue("ColorB", prim.Color.B);
  998. cmd.Parameters.AddWithValue("ColorA", prim.Color.A);
  999. cmd.Parameters.AddWithValue("Description", prim.Description);
  1000. cmd.Parameters.AddWithValue("SitName", prim.SitName);
  1001. cmd.Parameters.AddWithValue("TouchName", prim.TouchName);
  1002. // permissions
  1003. cmd.Parameters.AddWithValue("ObjectFlags", prim.ObjectFlags);
  1004. cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString());
  1005. cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString());
  1006. cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString());
  1007. cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString());
  1008. cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask);
  1009. cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask);
  1010. cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask);
  1011. cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask);
  1012. cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask);
  1013. // vectors
  1014. cmd.Parameters.AddWithValue("PositionX", (double)prim.OffsetPosition.X);
  1015. cmd.Parameters.AddWithValue("PositionY", (double)prim.OffsetPosition.Y);
  1016. cmd.Parameters.AddWithValue("PositionZ", (double)prim.OffsetPosition.Z);
  1017. cmd.Parameters.AddWithValue("GroupPositionX", (double)prim.GroupPosition.X);
  1018. cmd.Parameters.AddWithValue("GroupPositionY", (double)prim.GroupPosition.Y);
  1019. cmd.Parameters.AddWithValue("GroupPositionZ", (double)prim.GroupPosition.Z);
  1020. cmd.Parameters.AddWithValue("VelocityX", (double)prim.Velocity.X);
  1021. cmd.Parameters.AddWithValue("VelocityY", (double)prim.Velocity.Y);
  1022. cmd.Parameters.AddWithValue("VelocityZ", (double)prim.Velocity.Z);
  1023. cmd.Parameters.AddWithValue("AngularVelocityX", (double)prim.AngularVelocity.X);
  1024. cmd.Parameters.AddWithValue("AngularVelocityY", (double)prim.AngularVelocity.Y);
  1025. cmd.Parameters.AddWithValue("AngularVelocityZ", (double)prim.AngularVelocity.Z);
  1026. cmd.Parameters.AddWithValue("AccelerationX", (double)prim.Acceleration.X);
  1027. cmd.Parameters.AddWithValue("AccelerationY", (double)prim.Acceleration.Y);
  1028. cmd.Parameters.AddWithValue("AccelerationZ", (double)prim.Acceleration.Z);
  1029. // quaternions
  1030. cmd.Parameters.AddWithValue("RotationX", (double)prim.RotationOffset.X);
  1031. cmd.Parameters.AddWithValue("RotationY", (double)prim.RotationOffset.Y);
  1032. cmd.Parameters.AddWithValue("RotationZ", (double)prim.RotationOffset.Z);
  1033. cmd.Parameters.AddWithValue("RotationW", (double)prim.RotationOffset.W);
  1034. // Sit target
  1035. Vector3 sitTargetPos = prim.SitTargetPositionLL;
  1036. cmd.Parameters.AddWithValue("SitTargetOffsetX", (double)sitTargetPos.X);
  1037. cmd.Parameters.AddWithValue("SitTargetOffsetY", (double)sitTargetPos.Y);
  1038. cmd.Parameters.AddWithValue("SitTargetOffsetZ", (double)sitTargetPos.Z);
  1039. Quaternion sitTargetOrient = prim.SitTargetOrientationLL;
  1040. cmd.Parameters.AddWithValue("SitTargetOrientW", (double)sitTargetOrient.W);
  1041. cmd.Parameters.AddWithValue("SitTargetOrientX", (double)sitTargetOrient.X);
  1042. cmd.Parameters.AddWithValue("SitTargetOrientY", (double)sitTargetOrient.Y);
  1043. cmd.Parameters.AddWithValue("SitTargetOrientZ", (double)sitTargetOrient.Z);
  1044. cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]);
  1045. cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]);
  1046. cmd.Parameters.AddWithValue("PayButton2", prim.PayPrice[2]);
  1047. cmd.Parameters.AddWithValue("PayButton3", prim.PayPrice[3]);
  1048. cmd.Parameters.AddWithValue("PayButton4", prim.PayPrice[4]);
  1049. if ((prim.SoundFlags & 1) != 0) // Looped
  1050. {
  1051. cmd.Parameters.AddWithValue("LoopedSound", prim.Sound.ToString());
  1052. cmd.Parameters.AddWithValue("LoopedSoundGain", prim.SoundGain);
  1053. }
  1054. else
  1055. {
  1056. cmd.Parameters.AddWithValue("LoopedSound", UUID.Zero);
  1057. cmd.Parameters.AddWithValue("LoopedSoundGain", 0.0f);
  1058. }
  1059. cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation);
  1060. cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem);
  1061. cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X);
  1062. cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y);
  1063. cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z);
  1064. cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X);
  1065. cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y);
  1066. cmd.Parameters.AddWithValue("CameraEyeOffsetZ", (double)prim.GetCameraEyeOffset().Z);
  1067. cmd.Parameters.AddWithValue("CameraAtOffsetX", (double)prim.GetCameraAtOffset().X);
  1068. cmd.Parameters.AddWithValue("CameraAtOffsetY", (double)prim.GetCameraAtOffset().Y);
  1069. cmd.Parameters.AddWithValue("CameraAtOffsetZ", (double)prim.GetCameraAtOffset().Z);
  1070. if (prim.GetForceMouselook())
  1071. cmd.Parameters.AddWithValue("ForceMouselook", 1);
  1072. else
  1073. cmd.Parameters.AddWithValue("ForceMouselook", 0);
  1074. cmd.Parameters.AddWithValue("ScriptAccessPin", prim.ScriptAccessPin);
  1075. if (prim.AllowedDrop)
  1076. cmd.Parameters.AddWithValue("AllowedDrop", 1);
  1077. else
  1078. cmd.Parameters.AddWithValue("AllowedDrop", 0);
  1079. if (prim.DIE_AT_EDGE)
  1080. cmd.Parameters.AddWithValue("DieAtEdge", 1);
  1081. else
  1082. cmd.Parameters.AddWithValue("DieAtEdge", 0);
  1083. cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice);
  1084. cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType));
  1085. byte clickAction = prim.ClickAction;
  1086. cmd.Parameters.AddWithValue("ClickAction", clickAction);
  1087. cmd.Parameters.AddWithValue("Material", prim.Material);
  1088. cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString());
  1089. cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume);
  1090. cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
  1091. }
  1092. /// <summary>
  1093. ///
  1094. /// </summary>
  1095. /// <param name="row"></param>
  1096. /// <param name="taskItem"></param>
  1097. private static void FillItemCommand(MySqlCommand cmd, TaskInventoryItem taskItem)
  1098. {
  1099. cmd.Parameters.AddWithValue("itemID", taskItem.ItemID);
  1100. cmd.Parameters.AddWithValue("primID", taskItem.ParentPartID);
  1101. cmd.Parameters.AddWithValue("assetID", taskItem.AssetID);
  1102. cmd.Parameters.AddWithValue("parentFolderID", taskItem.ParentID);
  1103. cmd.Parameters.AddWithValue("invType", taskItem.InvType);
  1104. cmd.Parameters.AddWithValue("assetType", taskItem.Type);
  1105. cmd.Parameters.AddWithValue("name", taskItem.Name);
  1106. cmd.Parameters.AddWithValue("description", taskItem.Description);
  1107. cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate);
  1108. cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID);
  1109. cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID);
  1110. cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID);
  1111. cmd.Parameters.AddWithValue("groupID", taskItem.GroupID);
  1112. cmd.Parameters.AddWithValue("nextPermissions", taskItem.NextPermissions);
  1113. cmd.Parameters.AddWithValue("currentPermissions", taskItem.CurrentPermissions);
  1114. cmd.Parameters.AddWithValue("basePermissions", taskItem.BasePermissions);
  1115. cmd.Parameters.AddWithValue("everyonePermissions", taskItem.EveryonePermissions);
  1116. cmd.Parameters.AddWithValue("groupPermissions", taskItem.GroupPermissions);
  1117. cmd.Parameters.AddWithValue("flags", taskItem.Flags);
  1118. }
  1119. /// <summary>
  1120. ///
  1121. /// </summary>
  1122. private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings settings)
  1123. {
  1124. cmd.Parameters.AddWithValue("RegionUUID", settings.RegionUUID.ToString());
  1125. cmd.Parameters.AddWithValue("BlockTerraform", settings.BlockTerraform);
  1126. cmd.Parameters.AddWithValue("BlockFly", settings.BlockFly);
  1127. cmd.Parameters.AddWithValue("AllowDamage", settings.AllowDamage);
  1128. cmd.Parameters.AddWithValue("RestrictPushing", settings.RestrictPushing);
  1129. cmd.Parameters.AddWithValue("AllowLandResell", settings.AllowLandResell);
  1130. cmd.Parameters.AddWithValue("AllowLandJoinDivide", settings.AllowLandJoinDivide);
  1131. cmd.Parameters.AddWithValue("BlockShowInSearch", settings.BlockShowInSearch);
  1132. cmd.Parameters.AddWithValue("AgentLimit", settings.AgentLimit);
  1133. cmd.Parameters.AddWithValue("ObjectBonus", settings.ObjectBonus);
  1134. cmd.Parameters.AddWithValue("Maturity", settings.Maturity);
  1135. cmd.Parameters.AddWithValue("DisableScripts", settings.DisableScripts);
  1136. cmd.Parameters.AddWithValue("DisableCollisions", settings.DisableCollisions);
  1137. cmd.Parameters.AddWithValue("DisablePhysics", settings.DisablePhysics);
  1138. cmd.Parameters.AddWithValue("TerrainTexture1", settings.TerrainTexture1.ToString());
  1139. cmd.Parameters.AddWithValue("TerrainTexture2", settings.TerrainTexture2.ToString());
  1140. cmd.Parameters.AddWithValue("TerrainTexture3", settings.TerrainTexture3.ToString());
  1141. cmd.Parameters.AddWithValue("TerrainTexture4", settings.TerrainTexture4.ToString());
  1142. cmd.Parameters.AddWithValue("Elevation1NW", settings.Elevation1NW);
  1143. cmd.Parameters.AddWithValue("Elevation2NW", settings.Elevation2NW);
  1144. cmd.Parameters.AddWithValue("Elevation1NE", settings.Elevation1NE);
  1145. cmd.Parameters.AddWithValue("Elevation2NE", settings.Elevation2NE);
  1146. cmd.Parameters.AddWithValue("Elevation1SE", settings.Elevation1SE);
  1147. cmd.Parameters.AddWithValue("Elevation2SE", settings.Elevation2SE);
  1148. cmd.Parameters.AddWithValue("Elevation1SW", settings.Elevation1SW);
  1149. cmd.Parameters.AddWithValue("Elevation2SW", settings.Elevation2SW);
  1150. cmd.Parameters.AddWithValue("WaterHeight", settings.WaterHeight);
  1151. cmd.Parameters.AddWithValue("TerrainRaiseLimit", settings.TerrainRaiseLimit);
  1152. cmd.Parameters.AddWithValue("TerrainLowerLimit", settings.TerrainLowerLimit);
  1153. cmd.Parameters.AddWithValue("UseEstateSun", settings.UseEstateSun);
  1154. cmd.Parameters.AddWithValue("Sandbox", settings.Sandbox);
  1155. cmd.Parameters.AddWithValue("SunVectorX", settings.SunVector.X);
  1156. cmd.Parameters.AddWithValue("SunVectorY", settings.SunVector.Y);
  1157. cmd.Parameters.AddWithValue("SunVectorZ", settings.SunVector.Z);
  1158. cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun);
  1159. cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition);
  1160. cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString());
  1161. }
  1162. /// <summary>
  1163. ///
  1164. /// </summary>
  1165. /// <param name="row"></param>
  1166. /// <param name="land"></param>
  1167. /// <param name="regionUUID"></param>
  1168. private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID)
  1169. {
  1170. cmd.Parameters.AddWithValue("UUID", land.GlobalID.ToString());
  1171. cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
  1172. cmd.Parameters.AddWithValue("LocalLandID", land.LocalID);
  1173. // Bitmap is a byte[512]
  1174. cmd.Parameters.AddWithValue("Bitmap", land.Bitmap);
  1175. cmd.Parameters.AddWithValue("Name", land.Name);
  1176. cmd.Parameters.AddWithValue("Description", land.Description);
  1177. cmd.Parameters.AddWithValue("OwnerUUID", land.OwnerID.ToString());
  1178. cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned);
  1179. cmd.Parameters.AddWithValue("Area", land.Area);
  1180. cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented
  1181. cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory
  1182. cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate);
  1183. cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice);
  1184. cmd.Parameters.AddWithValue("GroupUUID", land.GroupID.ToString());
  1185. cmd.Parameters.AddWithValue("SalePrice", land.SalePrice);
  1186. cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus
  1187. cmd.Parameters.AddWithValue("LandFlags", land.Flags);
  1188. cmd.Parameters.AddWithValue("LandingType", land.LandingType);
  1189. cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale);
  1190. cmd.Parameters.AddWithValue("MediaTextureUUID", land.MediaID.ToString());
  1191. cmd.Parameters.AddWithValue("MediaURL", land.MediaURL);
  1192. cmd.Parameters.AddWithValue("MusicURL", land.MusicURL);
  1193. cmd.Parameters.AddWithValue("PassHours", land.PassHours);
  1194. cmd.Parameters.AddWithValue("PassPrice", land.PassPrice);
  1195. cmd.Parameters.AddWithValue("SnapshotUUID", land.SnapshotID.ToString());
  1196. cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X);
  1197. cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y);
  1198. cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z);
  1199. cmd.Parameters.AddWithValue("UserLookAtX", land.UserLookAt.X);
  1200. cmd.Parameters.AddWithValue("UserLookAtY", land.UserLookAt.Y);
  1201. cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z);
  1202. cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID);
  1203. cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime);
  1204. cmd.Parameters.AddWithValue("Dwell", land.Dwell);
  1205. }
  1206. /// <summary>
  1207. ///
  1208. /// </summary>
  1209. /// <param name="row"></param>
  1210. /// <param name="entry"></param>
  1211. /// <param name="parcelID"></param>
  1212. private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID)
  1213. {
  1214. cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString());
  1215. cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString());
  1216. cmd.Parameters.AddWithValue("Flags", entry.Flags);
  1217. }
  1218. /// <summary>
  1219. ///
  1220. /// </summary>
  1221. /// <param name="row"></param>
  1222. /// <returns></returns>
  1223. private PrimitiveBaseShape BuildShape(IDataReader row)
  1224. {
  1225. PrimitiveBaseShape s = new PrimitiveBaseShape();
  1226. s.Scale = new Vector3(
  1227. Convert.ToSingle(row["ScaleX"]),
  1228. Convert.ToSingle(row["ScaleY"]),
  1229. Convert.ToSingle(row["ScaleZ"])
  1230. );
  1231. // paths
  1232. s.PCode = Convert.ToByte(row["PCode"]);
  1233. s.PathBegin = Convert.ToUInt16(row["PathBegin"]);
  1234. s.PathEnd = Convert.ToUInt16(row["PathEnd"]);
  1235. s.PathScaleX = Convert.ToByte(row["PathScaleX"]);
  1236. s.PathScaleY = Convert.ToByte(row["PathScaleY"]);
  1237. s.PathShearX = Convert.ToByte(row["PathShearX"]);
  1238. s.PathShearY = Convert.ToByte(row["PathShearY"]);
  1239. s.PathSkew = Convert.ToSByte(row["PathSkew"]);
  1240. s.PathCurve = Convert.ToByte(row["PathCurve"]);
  1241. s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]);
  1242. s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]);
  1243. s.PathTaperX = Convert.ToSByte(row["PathTaperX"]);
  1244. s.PathTaperY = Convert.ToSByte(row["PathTaperY"]);
  1245. s.PathTwist = Convert.ToSByte(row["PathTwist"]);
  1246. s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]);
  1247. // profile
  1248. s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]);
  1249. s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]);
  1250. s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]);
  1251. s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]);
  1252. byte[] textureEntry = (byte[]) row["Texture"];
  1253. s.TextureEntry = textureEntry;
  1254. s.ExtraParams = (byte[]) row["ExtraParams"];
  1255. s.State = Convert.ToByte(row["State"]);
  1256. return s;
  1257. }
  1258. /// <summary>
  1259. ///
  1260. /// </summary>
  1261. /// <param name="row"></param>
  1262. /// <param name="prim"></param>
  1263. private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim)
  1264. {
  1265. PrimitiveBaseShape s = prim.Shape;
  1266. cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString());
  1267. // shape is an enum
  1268. cmd.Parameters.AddWithValue("Shape", 0);
  1269. // vectors
  1270. cmd.Parameters.AddWithValue("ScaleX", (double)s.Scale.X);
  1271. cmd.Parameters.AddWithValue("ScaleY", (double)s.Scale.Y);
  1272. cmd.Parameters.AddWithValue("ScaleZ", (double)s.Scale.Z);
  1273. // paths
  1274. cmd.Parameters.AddWithValue("PCode", s.PCode);
  1275. cmd.Parameters.AddWithValue("PathBegin", s.PathBegin);
  1276. cmd.Parameters.AddWithValue("PathEnd", s.PathEnd);
  1277. cmd.Parameters.AddWithValue("PathScaleX", s.PathScaleX);
  1278. cmd.Parameters.AddWithValue("PathScaleY", s.PathScaleY);
  1279. cmd.Parameters.AddWithValue("PathShearX", s.PathShearX);
  1280. cmd.Parameters.AddWithValue("PathShearY", s.PathShearY);
  1281. cmd.Parameters.AddWithValue("PathSkew", s.PathSkew);
  1282. cmd.Parameters.AddWithValue("PathCurve", s.PathCurve);
  1283. cmd.Parameters.AddWithValue("PathRadiusOffset", s.PathRadiusOffset);
  1284. cmd.Parameters.AddWithValue("PathRevolutions", s.PathRevolutions);
  1285. cmd.Parameters.AddWithValue("PathTaperX", s.PathTaperX);
  1286. cmd.Parameters.AddWithValue("PathTaperY", s.PathTaperY);
  1287. cmd.Parameters.AddWithValue("PathTwist", s.PathTwist);
  1288. cmd.Parameters.AddWithValue("PathTwistBegin", s.PathTwistBegin);
  1289. // profile
  1290. cmd.Parameters.AddWithValue("ProfileBegin", s.ProfileBegin);
  1291. cmd.Parameters.AddWithValue("ProfileEnd", s.ProfileEnd);
  1292. cmd.Parameters.AddWithValue("ProfileCurve", s.ProfileCurve);
  1293. cmd.Parameters.AddWithValue("ProfileHollow", s.ProfileHollow);
  1294. cmd.Parameters.AddWithValue("Texture", s.TextureEntry);
  1295. cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams);
  1296. cmd.Parameters.AddWithValue("State", s.State);
  1297. }
  1298. public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
  1299. {
  1300. lock (m_Connection)
  1301. {
  1302. RemoveItems(primID);
  1303. MySqlCommand cmd = m_Connection.CreateCommand();
  1304. if (items.Count == 0)
  1305. return;
  1306. cmd.CommandText = "insert into primitems ("+
  1307. "invType, assetType, name, "+
  1308. "description, creationDate, nextPermissions, "+
  1309. "currentPermissions, basePermissions, "+
  1310. "everyonePermissions, groupPermissions, "+
  1311. "flags, itemID, primID, assetID, "+
  1312. "parentFolderID, creatorID, ownerID, "+
  1313. "groupID, lastOwnerID) values (?invType, "+
  1314. "?assetType, ?name, ?description, "+
  1315. "?creationDate, ?nextPermissions, "+
  1316. "?currentPermissions, ?basePermissions, "+
  1317. "?everyonePermissions, ?groupPermissions, "+
  1318. "?flags, ?itemID, ?primID, ?assetID, "+
  1319. "?parentFolderID, ?creatorID, ?ownerID, "+
  1320. "?groupID, ?lastOwnerID)";
  1321. foreach (TaskInventoryItem item in items)
  1322. {
  1323. cmd.Parameters.Clear();
  1324. FillItemCommand(cmd, item);
  1325. ExecuteNonQuery(cmd);
  1326. }
  1327. cmd.Dispose();
  1328. }
  1329. }
  1330. }
  1331. }