MySQLRegionData.cs 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540
  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", Util.ToRawUuidString(obj));
  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, Util.ToRawUuidString(uuids[i]));
  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",
  373. Util.ToRawUuidString(regionUUID));
  374. IDataReader reader = ExecuteReader(cmd);
  375. try
  376. {
  377. while (reader.Read())
  378. {
  379. SceneObjectPart prim = BuildPrim(reader);
  380. if (reader["Shape"] is DBNull)
  381. prim.Shape = PrimitiveBaseShape.Default;
  382. else
  383. prim.Shape = BuildShape(reader);
  384. prims.Add(prim);
  385. UUID groupID = new UUID(reader["SceneGroupID"].ToString());
  386. if (groupID != lastGroupID) // New SOG
  387. {
  388. if (grp != null)
  389. objects.Add(grp);
  390. lastGroupID = groupID;
  391. // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are
  392. // recorded as the root prim (for which the UUID must equal the persisted group UUID). In
  393. // this case, force the UUID to be the same as the group UUID so that at least these can be
  394. // deleted (we need to change the UUID so that any other prims in the linkset can also be
  395. // deleted).
  396. if (prim.UUID != groupID && groupID != UUID.Zero)
  397. {
  398. m_log.WarnFormat(
  399. "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID",
  400. prim.Name, prim.UUID, prim.GroupPosition, groupID);
  401. prim.UUID = groupID;
  402. }
  403. grp = new SceneObjectGroup(prim);
  404. }
  405. else
  406. {
  407. // Black magic to preserve link numbers
  408. //
  409. int link = prim.LinkNum;
  410. grp.AddPart(prim);
  411. if (link != 0)
  412. prim.LinkNum = link;
  413. }
  414. }
  415. }
  416. finally
  417. {
  418. reader.Close();
  419. }
  420. if (grp != null)
  421. objects.Add(grp);
  422. cmd.Dispose();
  423. }
  424. foreach (SceneObjectPart part in prims)
  425. LoadItems(part);
  426. m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count);
  427. return objects;
  428. }
  429. /// <summary>
  430. /// Load in a prim's persisted inventory.
  431. /// </summary>
  432. /// <param name="prim">The prim</param>
  433. private void LoadItems(SceneObjectPart prim)
  434. {
  435. lock (m_Connection)
  436. {
  437. MySqlCommand cmd = m_Connection.CreateCommand();
  438. cmd.CommandText = "select * from primitems where "+
  439. "PrimID = ?PrimID";
  440. cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString());
  441. IDataReader reader = ExecuteReader(cmd);
  442. List<TaskInventoryItem> inventory =
  443. new List<TaskInventoryItem>();
  444. try
  445. {
  446. while (reader.Read())
  447. {
  448. TaskInventoryItem item = BuildItem(reader);
  449. item.ParentID = prim.UUID; // Values in database are
  450. // often wrong
  451. inventory.Add(item);
  452. }
  453. }
  454. finally
  455. {
  456. reader.Close();
  457. }
  458. cmd.Dispose();
  459. prim.Inventory.RestoreInventoryItems(inventory);
  460. }
  461. }
  462. public void StoreTerrain(double[,] ter, UUID regionID)
  463. {
  464. m_log.Info("[REGION DB]: Storing terrain");
  465. lock (m_Connection)
  466. {
  467. MySqlCommand cmd = m_Connection.CreateCommand();
  468. cmd.CommandText = "delete from terrain where " +
  469. "RegionUUID = ?RegionUUID";
  470. cmd.Parameters.AddWithValue("RegionUUID",
  471. Util.ToRawUuidString(regionID));
  472. ExecuteNonQuery(cmd);
  473. cmd.CommandText = "insert into terrain (RegionUUID, " +
  474. "Revision, Heightfield) values (?RegionUUID, " +
  475. "1, ?Heightfield)";
  476. cmd.Parameters.AddWithValue("Heightfield",
  477. SerializeTerrain(ter));
  478. ExecuteNonQuery(cmd);
  479. cmd.Dispose();
  480. }
  481. }
  482. public double[,] LoadTerrain(UUID regionID)
  483. {
  484. double[,] terrain = null;
  485. lock (m_Connection)
  486. {
  487. MySqlCommand cmd = m_Connection.CreateCommand();
  488. cmd.CommandText = "select RegionUUID, Revision, Heightfield " +
  489. "from terrain where RegionUUID = ?RegionUUID "+
  490. "order by Revision desc limit 1";
  491. cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionID));
  492. IDataReader reader = ExecuteReader(cmd);
  493. try
  494. {
  495. while (reader.Read())
  496. {
  497. terrain = new double[256,256];
  498. terrain.Initialize();
  499. MemoryStream mstr = new MemoryStream((byte[]) reader["Heightfield"]);
  500. int rev = 0;
  501. BinaryReader br = new BinaryReader(mstr);
  502. for (int x = 0; x < 256; x++)
  503. {
  504. for (int y = 0; y < 256; y++)
  505. {
  506. terrain[x, y] = br.ReadDouble();
  507. }
  508. rev = Convert.ToInt32(reader["Revision"]);
  509. }
  510. m_log.InfoFormat("[REGION DB]: Loaded terrain " +
  511. "revision r{0}", rev);
  512. }
  513. }
  514. finally
  515. {
  516. reader.Close();
  517. }
  518. cmd.Dispose();
  519. }
  520. return terrain;
  521. }
  522. public void RemoveLandObject(UUID globalID)
  523. {
  524. lock (m_Connection)
  525. {
  526. MySqlCommand cmd = m_Connection.CreateCommand();
  527. cmd.CommandText = "delete from land where UUID = ?UUID";
  528. cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(globalID));
  529. ExecuteNonQuery(cmd);
  530. cmd.Dispose();
  531. }
  532. }
  533. public void StoreLandObject(ILandObject parcel)
  534. {
  535. lock (m_Connection)
  536. {
  537. MySqlCommand cmd = m_Connection.CreateCommand();
  538. cmd.CommandText = "replace into land (UUID, RegionUUID, " +
  539. "LocalLandID, Bitmap, Name, Description, " +
  540. "OwnerUUID, IsGroupOwned, Area, AuctionID, " +
  541. "Category, ClaimDate, ClaimPrice, GroupUUID, " +
  542. "SalePrice, LandStatus, LandFlags, LandingType, " +
  543. "MediaAutoScale, MediaTextureUUID, MediaURL, " +
  544. "MusicURL, PassHours, PassPrice, SnapshotUUID, " +
  545. "UserLocationX, UserLocationY, UserLocationZ, " +
  546. "UserLookAtX, UserLookAtY, UserLookAtZ, " +
  547. "AuthbuyerID, OtherCleanTime, Dwell) values (" +
  548. "?UUID, ?RegionUUID, " +
  549. "?LocalLandID, ?Bitmap, ?Name, ?Description, " +
  550. "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " +
  551. "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " +
  552. "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " +
  553. "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " +
  554. "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " +
  555. "?UserLocationX, ?UserLocationY, ?UserLocationZ, " +
  556. "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " +
  557. "?AuthbuyerID, ?OtherCleanTime, ?Dwell)";
  558. FillLandCommand(cmd, parcel.landData, parcel.regionUUID);
  559. ExecuteNonQuery(cmd);
  560. cmd.CommandText = "delete from landaccesslist where " +
  561. "LandUUID = ?UUID";
  562. ExecuteNonQuery(cmd);
  563. cmd.Parameters.Clear();
  564. cmd.CommandText = "insert into landaccesslist (LandUUID, " +
  565. "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " +
  566. "?Flags)";
  567. foreach (ParcelManager.ParcelAccessEntry entry in
  568. parcel.landData.ParcelAccessList)
  569. {
  570. FillLandAccessCommand(cmd, entry, parcel.landData.GlobalID);
  571. ExecuteNonQuery(cmd);
  572. cmd.Parameters.Clear();
  573. }
  574. cmd.Dispose();
  575. }
  576. }
  577. public RegionSettings LoadRegionSettings(UUID regionUUID)
  578. {
  579. RegionSettings rs = null;
  580. lock (m_Connection)
  581. {
  582. MySqlCommand cmd = m_Connection.CreateCommand();
  583. cmd.CommandText = "select * from regionsettings where " +
  584. "regionUUID = ?RegionUUID";
  585. cmd.Parameters.AddWithValue("regionUUID", regionUUID);
  586. IDataReader reader = ExecuteReader(cmd);
  587. try
  588. {
  589. if (reader.Read())
  590. {
  591. rs = BuildRegionSettings(reader);
  592. rs.OnSave += StoreRegionSettings;
  593. }
  594. else
  595. {
  596. rs = new RegionSettings();
  597. rs.RegionUUID = regionUUID;
  598. rs.OnSave += StoreRegionSettings;
  599. StoreRegionSettings(rs);
  600. }
  601. }
  602. finally
  603. {
  604. reader.Close();
  605. }
  606. cmd.Dispose();
  607. }
  608. return rs;
  609. }
  610. public void StoreRegionSettings(RegionSettings rs)
  611. {
  612. lock (m_Connection)
  613. {
  614. MySqlCommand cmd = m_Connection.CreateCommand();
  615. cmd.CommandText = "replace into regionsettings (regionUUID, " +
  616. "block_terraform, block_fly, allow_damage, " +
  617. "restrict_pushing, allow_land_resell, " +
  618. "allow_land_join_divide, block_show_in_search, " +
  619. "agent_limit, object_bonus, maturity, " +
  620. "disable_scripts, disable_collisions, " +
  621. "disable_physics, terrain_texture_1, " +
  622. "terrain_texture_2, terrain_texture_3, " +
  623. "terrain_texture_4, elevation_1_nw, " +
  624. "elevation_2_nw, elevation_1_ne, " +
  625. "elevation_2_ne, elevation_1_se, "+
  626. "elevation_2_se, elevation_1_sw, "+
  627. "elevation_2_sw, water_height, " +
  628. "terrain_raise_limit, terrain_lower_limit, " +
  629. "use_estate_sun, fixed_sun, sun_position, " +
  630. "covenant, Sandbox, sunvectorx, sunvectory, " +
  631. "sunvectorz) values ( ?RegionUUID, ?BlockTerraform, " +
  632. "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
  633. "?AllowLandResell, ?AllowLandJoinDivide, " +
  634. "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
  635. "?Maturity, ?DisableScripts, ?DisableCollisions, " +
  636. "?DisablePhysics, ?TerrainTexture1, " +
  637. "?TerrainTexture2, ?TerrainTexture3, " +
  638. "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " +
  639. "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " +
  640. "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " +
  641. "?WaterHeight, ?TerrainRaiseLimit, " +
  642. "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " +
  643. "?SunPosition, ?Covenant, ?Sandbox, " +
  644. "?SunVectorX, ?SunVectorY, ?SunVectorZ)";
  645. FillRegionSettingsCommand(cmd, rs);
  646. ExecuteNonQuery(cmd);
  647. cmd.Dispose();
  648. }
  649. }
  650. public List<LandData> LoadLandObjects(UUID regionUUID)
  651. {
  652. List<LandData> landData = new List<LandData>();
  653. lock (m_Connection)
  654. {
  655. MySqlCommand cmd = m_Connection.CreateCommand();
  656. cmd.CommandText = "select * from land where " +
  657. "RegionUUID = ?RegionUUID";
  658. cmd.Parameters.AddWithValue("RegionUUID",
  659. Util.ToRawUuidString(regionUUID));
  660. IDataReader reader = ExecuteReader(cmd);
  661. try
  662. {
  663. while (reader.Read())
  664. {
  665. LandData newLand = BuildLandData(reader);
  666. landData.Add(newLand);
  667. }
  668. }
  669. finally
  670. {
  671. reader.Close();
  672. }
  673. foreach (LandData land in landData)
  674. {
  675. cmd.Parameters.Clear();
  676. cmd.CommandText = "select * from landaccesslist " +
  677. "where LandUUID = ?LandUUID";
  678. cmd.Parameters.AddWithValue("LandUUID",
  679. Util.ToRawUuidString(land.GlobalID));
  680. reader = ExecuteReader(cmd);
  681. try
  682. {
  683. while (reader.Read())
  684. {
  685. land.ParcelAccessList.Add(BuildLandAccessData(reader));
  686. }
  687. }
  688. finally
  689. {
  690. reader.Close();
  691. }
  692. }
  693. cmd.Dispose();
  694. }
  695. return landData;
  696. }
  697. public void Shutdown()
  698. {
  699. }
  700. private SceneObjectPart BuildPrim(IDataReader row)
  701. {
  702. SceneObjectPart prim = new SceneObjectPart();
  703. prim.UUID = new UUID((String) row["UUID"]);
  704. // explicit conversion of integers is required, which sort
  705. // of sucks. No idea if there is a shortcut here or not.
  706. prim.CreationDate = Convert.ToInt32(row["CreationDate"]);
  707. prim.Name = (String) row["Name"];
  708. // various text fields
  709. prim.Text = (String) row["Text"];
  710. prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]),
  711. Convert.ToInt32(row["ColorR"]),
  712. Convert.ToInt32(row["ColorG"]),
  713. Convert.ToInt32(row["ColorB"]));
  714. prim.Description = (String) row["Description"];
  715. prim.SitName = (String) row["SitName"];
  716. prim.TouchName = (String) row["TouchName"];
  717. // permissions
  718. prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]);
  719. prim.CreatorID = new UUID((String) row["CreatorID"]);
  720. prim.OwnerID = new UUID((String) row["OwnerID"]);
  721. prim.GroupID = new UUID((String) row["GroupID"]);
  722. prim.LastOwnerID = new UUID((String) row["LastOwnerID"]);
  723. prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]);
  724. prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]);
  725. prim.GroupMask = Convert.ToUInt32(row["GroupMask"]);
  726. prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]);
  727. prim.BaseMask = Convert.ToUInt32(row["BaseMask"]);
  728. // vectors
  729. prim.OffsetPosition = new Vector3(
  730. Convert.ToSingle(row["PositionX"]),
  731. Convert.ToSingle(row["PositionY"]),
  732. Convert.ToSingle(row["PositionZ"])
  733. );
  734. prim.GroupPosition = new Vector3(
  735. Convert.ToSingle(row["GroupPositionX"]),
  736. Convert.ToSingle(row["GroupPositionY"]),
  737. Convert.ToSingle(row["GroupPositionZ"])
  738. );
  739. prim.Velocity = new Vector3(
  740. Convert.ToSingle(row["VelocityX"]),
  741. Convert.ToSingle(row["VelocityY"]),
  742. Convert.ToSingle(row["VelocityZ"])
  743. );
  744. prim.AngularVelocity = new Vector3(
  745. Convert.ToSingle(row["AngularVelocityX"]),
  746. Convert.ToSingle(row["AngularVelocityY"]),
  747. Convert.ToSingle(row["AngularVelocityZ"])
  748. );
  749. prim.Acceleration = new Vector3(
  750. Convert.ToSingle(row["AccelerationX"]),
  751. Convert.ToSingle(row["AccelerationY"]),
  752. Convert.ToSingle(row["AccelerationZ"])
  753. );
  754. // quaternions
  755. prim.RotationOffset = new Quaternion(
  756. Convert.ToSingle(row["RotationX"]),
  757. Convert.ToSingle(row["RotationY"]),
  758. Convert.ToSingle(row["RotationZ"]),
  759. Convert.ToSingle(row["RotationW"])
  760. );
  761. prim.SitTargetPositionLL = new Vector3(
  762. Convert.ToSingle(row["SitTargetOffsetX"]),
  763. Convert.ToSingle(row["SitTargetOffsetY"]),
  764. Convert.ToSingle(row["SitTargetOffsetZ"])
  765. );
  766. prim.SitTargetOrientationLL = new Quaternion(
  767. Convert.ToSingle(row["SitTargetOrientX"]),
  768. Convert.ToSingle(row["SitTargetOrientY"]),
  769. Convert.ToSingle(row["SitTargetOrientZ"]),
  770. Convert.ToSingle(row["SitTargetOrientW"])
  771. );
  772. prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]);
  773. prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]);
  774. prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]);
  775. prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]);
  776. prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]);
  777. prim.Sound = new UUID(row["LoopedSound"].ToString());
  778. prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]);
  779. prim.SoundFlags = 1; // If it's persisted at all, it's looped
  780. if (!(row["TextureAnimation"] is DBNull))
  781. prim.TextureAnimation = (Byte[])row["TextureAnimation"];
  782. if (!(row["ParticleSystem"] is DBNull))
  783. prim.ParticleSystem = (Byte[])row["ParticleSystem"];
  784. prim.RotationalVelocity = new Vector3(
  785. Convert.ToSingle(row["OmegaX"]),
  786. Convert.ToSingle(row["OmegaY"]),
  787. Convert.ToSingle(row["OmegaZ"])
  788. );
  789. prim.SetCameraEyeOffset(new Vector3(
  790. Convert.ToSingle(row["CameraEyeOffsetX"]),
  791. Convert.ToSingle(row["CameraEyeOffsetY"]),
  792. Convert.ToSingle(row["CameraEyeOffsetZ"])
  793. ));
  794. prim.SetCameraAtOffset(new Vector3(
  795. Convert.ToSingle(row["CameraAtOffsetX"]),
  796. Convert.ToSingle(row["CameraAtOffsetY"]),
  797. Convert.ToSingle(row["CameraAtOffsetZ"])
  798. ));
  799. if (Convert.ToInt16(row["ForceMouselook"]) != 0)
  800. prim.SetForceMouselook(true);
  801. prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]);
  802. if (Convert.ToInt16(row["AllowedDrop"]) != 0)
  803. prim.AllowedDrop = true;
  804. if (Convert.ToInt16(row["DieAtEdge"]) != 0)
  805. prim.DIE_AT_EDGE = true;
  806. prim.SalePrice = Convert.ToInt32(row["SalePrice"]);
  807. prim.ObjectSaleType = Convert.ToByte(row["SaleType"]);
  808. prim.Material = Convert.ToByte(row["Material"]);
  809. if (!(row["ClickAction"] is DBNull))
  810. prim.ClickAction = (byte)Convert.ToByte(row["ClickAction"]);
  811. prim.CollisionSound = new UUID(row["CollisionSound"].ToString());
  812. prim.CollisionSoundVolume = Convert.ToSingle(row["CollisionSoundVolume"]);
  813. prim.LinkNum = Convert.ToInt32(row["LinkNumber"]);
  814. return prim;
  815. }
  816. /// <summary>
  817. /// Build a prim inventory item from the persisted data.
  818. /// </summary>
  819. /// <param name="row"></param>
  820. /// <returns></returns>
  821. private static TaskInventoryItem BuildItem(IDataReader row)
  822. {
  823. TaskInventoryItem taskItem = new TaskInventoryItem();
  824. taskItem.ItemID = new UUID((String)row["itemID"]);
  825. taskItem.ParentPartID = new UUID((String)row["primID"]);
  826. taskItem.AssetID = new UUID((String)row["assetID"]);
  827. taskItem.ParentID = new UUID((String)row["parentFolderID"]);
  828. taskItem.InvType = Convert.ToInt32(row["invType"]);
  829. taskItem.Type = Convert.ToInt32(row["assetType"]);
  830. taskItem.Name = (String)row["name"];
  831. taskItem.Description = (String)row["description"];
  832. taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]);
  833. taskItem.CreatorID = new UUID((String)row["creatorID"]);
  834. taskItem.OwnerID = new UUID((String)row["ownerID"]);
  835. taskItem.LastOwnerID = new UUID((String)row["lastOwnerID"]);
  836. taskItem.GroupID = new UUID((String)row["groupID"]);
  837. taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]);
  838. taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]);
  839. taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]);
  840. taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]);
  841. taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]);
  842. taskItem.Flags = Convert.ToUInt32(row["flags"]);
  843. return taskItem;
  844. }
  845. private static RegionSettings BuildRegionSettings(IDataReader row)
  846. {
  847. RegionSettings newSettings = new RegionSettings();
  848. newSettings.RegionUUID = new UUID((string) row["regionUUID"]);
  849. newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]);
  850. newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]);
  851. newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]);
  852. newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]);
  853. newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]);
  854. newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]);
  855. newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]);
  856. newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]);
  857. newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]);
  858. newSettings.Maturity = Convert.ToInt32(row["maturity"]);
  859. newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]);
  860. newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]);
  861. newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]);
  862. newSettings.TerrainTexture1 = new UUID((String) row["terrain_texture_1"]);
  863. newSettings.TerrainTexture2 = new UUID((String) row["terrain_texture_2"]);
  864. newSettings.TerrainTexture3 = new UUID((String) row["terrain_texture_3"]);
  865. newSettings.TerrainTexture4 = new UUID((String) row["terrain_texture_4"]);
  866. newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]);
  867. newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]);
  868. newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]);
  869. newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]);
  870. newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]);
  871. newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]);
  872. newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]);
  873. newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]);
  874. newSettings.WaterHeight = Convert.ToDouble(row["water_height"]);
  875. newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]);
  876. newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]);
  877. newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]);
  878. newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]);
  879. newSettings.SunVector = new Vector3 (
  880. Convert.ToSingle(row["sunvectorx"]),
  881. Convert.ToSingle(row["sunvectory"]),
  882. Convert.ToSingle(row["sunvectorz"])
  883. );
  884. newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]);
  885. newSettings.SunPosition = Convert.ToDouble(row["sun_position"]);
  886. newSettings.Covenant = new UUID((String) row["covenant"]);
  887. return newSettings;
  888. }
  889. /// <summary>
  890. ///
  891. /// </summary>
  892. /// <param name="row"></param>
  893. /// <returns></returns>
  894. private static LandData BuildLandData(IDataReader row)
  895. {
  896. LandData newData = new LandData();
  897. newData.GlobalID = new UUID((String) row["UUID"]);
  898. newData.LocalID = Convert.ToInt32(row["LocalLandID"]);
  899. // Bitmap is a byte[512]
  900. newData.Bitmap = (Byte[]) row["Bitmap"];
  901. newData.Name = (String) row["Name"];
  902. newData.Description = (String) row["Description"];
  903. newData.OwnerID = new UUID((String)row["OwnerUUID"]);
  904. newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]);
  905. newData.Area = Convert.ToInt32(row["Area"]);
  906. newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented
  907. newData.Category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]);
  908. //Enum libsecondlife.Parcel.ParcelCategory
  909. newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]);
  910. newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]);
  911. newData.GroupID = new UUID((String) row["GroupUUID"]);
  912. newData.SalePrice = Convert.ToInt32(row["SalePrice"]);
  913. newData.Status = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]);
  914. //Enum. libsecondlife.Parcel.ParcelStatus
  915. newData.Flags = Convert.ToUInt32(row["LandFlags"]);
  916. newData.LandingType = Convert.ToByte(row["LandingType"]);
  917. newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]);
  918. newData.MediaID = new UUID((String) row["MediaTextureUUID"]);
  919. newData.MediaURL = (String) row["MediaURL"];
  920. newData.MusicURL = (String) row["MusicURL"];
  921. newData.PassHours = Convert.ToSingle(row["PassHours"]);
  922. newData.PassPrice = Convert.ToInt32(row["PassPrice"]);
  923. UUID authedbuyer = UUID.Zero;
  924. UUID snapshotID = UUID.Zero;
  925. UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer);
  926. UUID.TryParse((string)row["SnapshotUUID"], out snapshotID);
  927. newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]);
  928. newData.Dwell = Convert.ToInt32(row["Dwell"]);
  929. newData.AuthBuyerID = authedbuyer;
  930. newData.SnapshotID = snapshotID;
  931. try
  932. {
  933. newData.UserLocation =
  934. new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]),
  935. Convert.ToSingle(row["UserLocationZ"]));
  936. newData.UserLookAt =
  937. new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]),
  938. Convert.ToSingle(row["UserLookAtZ"]));
  939. }
  940. catch (InvalidCastException)
  941. {
  942. newData.UserLocation = Vector3.Zero;
  943. newData.UserLookAt = Vector3.Zero;
  944. m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name);
  945. }
  946. newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
  947. return newData;
  948. }
  949. /// <summary>
  950. ///
  951. /// </summary>
  952. /// <param name="row"></param>
  953. /// <returns></returns>
  954. private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row)
  955. {
  956. ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
  957. entry.AgentID = new UUID((string) row["AccessUUID"]);
  958. entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]);
  959. entry.Time = new DateTime();
  960. return entry;
  961. }
  962. /// <summary>
  963. ///
  964. /// </summary>
  965. /// <param name="val"></param>
  966. /// <returns></returns>
  967. private static Array SerializeTerrain(double[,] val)
  968. {
  969. MemoryStream str = new MemoryStream(65536*sizeof (double));
  970. BinaryWriter bw = new BinaryWriter(str);
  971. // TODO: COMPATIBILITY - Add byte-order conversions
  972. for (int x = 0; x < 256; x++)
  973. for (int y = 0; y < 256; y++)
  974. {
  975. double height = val[x, y];
  976. if (height == 0.0)
  977. height = double.Epsilon;
  978. bw.Write(height);
  979. }
  980. return str.ToArray();
  981. }
  982. /// <summary>
  983. /// Fill the prim command with prim values
  984. /// </summary>
  985. /// <param name="row"></param>
  986. /// <param name="prim"></param>
  987. /// <param name="sceneGroupID"></param>
  988. /// <param name="regionUUID"></param>
  989. private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
  990. {
  991. cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(prim.UUID));
  992. cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionUUID));
  993. cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate);
  994. cmd.Parameters.AddWithValue("Name", prim.Name);
  995. cmd.Parameters.AddWithValue("SceneGroupID", Util.ToRawUuidString(sceneGroupID));
  996. // the UUID of the root part for this SceneObjectGroup
  997. // various text fields
  998. cmd.Parameters.AddWithValue("Text", prim.Text);
  999. cmd.Parameters.AddWithValue("ColorR", prim.Color.R);
  1000. cmd.Parameters.AddWithValue("ColorG", prim.Color.G);
  1001. cmd.Parameters.AddWithValue("ColorB", prim.Color.B);
  1002. cmd.Parameters.AddWithValue("ColorA", prim.Color.A);
  1003. cmd.Parameters.AddWithValue("Description", prim.Description);
  1004. cmd.Parameters.AddWithValue("SitName", prim.SitName);
  1005. cmd.Parameters.AddWithValue("TouchName", prim.TouchName);
  1006. // permissions
  1007. cmd.Parameters.AddWithValue("ObjectFlags", prim.ObjectFlags);
  1008. cmd.Parameters.AddWithValue("CreatorID", Util.ToRawUuidString(prim.CreatorID));
  1009. cmd.Parameters.AddWithValue("OwnerID", Util.ToRawUuidString(prim.OwnerID));
  1010. cmd.Parameters.AddWithValue("GroupID", Util.ToRawUuidString(prim.GroupID));
  1011. cmd.Parameters.AddWithValue("LastOwnerID", Util.ToRawUuidString(prim.LastOwnerID));
  1012. cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask);
  1013. cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask);
  1014. cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask);
  1015. cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask);
  1016. cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask);
  1017. // vectors
  1018. cmd.Parameters.AddWithValue("PositionX", (double)prim.OffsetPosition.X);
  1019. cmd.Parameters.AddWithValue("PositionY", (double)prim.OffsetPosition.Y);
  1020. cmd.Parameters.AddWithValue("PositionZ", (double)prim.OffsetPosition.Z);
  1021. cmd.Parameters.AddWithValue("GroupPositionX", (double)prim.GroupPosition.X);
  1022. cmd.Parameters.AddWithValue("GroupPositionY", (double)prim.GroupPosition.Y);
  1023. cmd.Parameters.AddWithValue("GroupPositionZ", (double)prim.GroupPosition.Z);
  1024. cmd.Parameters.AddWithValue("VelocityX", (double)prim.Velocity.X);
  1025. cmd.Parameters.AddWithValue("VelocityY", (double)prim.Velocity.Y);
  1026. cmd.Parameters.AddWithValue("VelocityZ", (double)prim.Velocity.Z);
  1027. cmd.Parameters.AddWithValue("AngularVelocityX", (double)prim.AngularVelocity.X);
  1028. cmd.Parameters.AddWithValue("AngularVelocityY", (double)prim.AngularVelocity.Y);
  1029. cmd.Parameters.AddWithValue("AngularVelocityZ", (double)prim.AngularVelocity.Z);
  1030. cmd.Parameters.AddWithValue("AccelerationX", (double)prim.Acceleration.X);
  1031. cmd.Parameters.AddWithValue("AccelerationY", (double)prim.Acceleration.Y);
  1032. cmd.Parameters.AddWithValue("AccelerationZ", (double)prim.Acceleration.Z);
  1033. // quaternions
  1034. cmd.Parameters.AddWithValue("RotationX", (double)prim.RotationOffset.X);
  1035. cmd.Parameters.AddWithValue("RotationY", (double)prim.RotationOffset.Y);
  1036. cmd.Parameters.AddWithValue("RotationZ", (double)prim.RotationOffset.Z);
  1037. cmd.Parameters.AddWithValue("RotationW", (double)prim.RotationOffset.W);
  1038. // Sit target
  1039. Vector3 sitTargetPos = prim.SitTargetPositionLL;
  1040. cmd.Parameters.AddWithValue("SitTargetOffsetX", (double)sitTargetPos.X);
  1041. cmd.Parameters.AddWithValue("SitTargetOffsetY", (double)sitTargetPos.Y);
  1042. cmd.Parameters.AddWithValue("SitTargetOffsetZ", (double)sitTargetPos.Z);
  1043. Quaternion sitTargetOrient = prim.SitTargetOrientationLL;
  1044. cmd.Parameters.AddWithValue("SitTargetOrientW", (double)sitTargetOrient.W);
  1045. cmd.Parameters.AddWithValue("SitTargetOrientX", (double)sitTargetOrient.X);
  1046. cmd.Parameters.AddWithValue("SitTargetOrientY", (double)sitTargetOrient.Y);
  1047. cmd.Parameters.AddWithValue("SitTargetOrientZ", (double)sitTargetOrient.Z);
  1048. cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]);
  1049. cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]);
  1050. cmd.Parameters.AddWithValue("PayButton2", prim.PayPrice[2]);
  1051. cmd.Parameters.AddWithValue("PayButton3", prim.PayPrice[3]);
  1052. cmd.Parameters.AddWithValue("PayButton4", prim.PayPrice[4]);
  1053. if ((prim.SoundFlags & 1) != 0) // Looped
  1054. {
  1055. cmd.Parameters.AddWithValue("LoopedSound", prim.Sound.ToString());
  1056. cmd.Parameters.AddWithValue("LoopedSoundGain", prim.SoundGain);
  1057. }
  1058. else
  1059. {
  1060. cmd.Parameters.AddWithValue("LoopedSound", UUID.Zero);
  1061. cmd.Parameters.AddWithValue("LoopedSoundGain", 0.0f);
  1062. }
  1063. cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation);
  1064. cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem);
  1065. cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X);
  1066. cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y);
  1067. cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z);
  1068. cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X);
  1069. cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y);
  1070. cmd.Parameters.AddWithValue("CameraEyeOffsetZ", (double)prim.GetCameraEyeOffset().Z);
  1071. cmd.Parameters.AddWithValue("CameraAtOffsetX", (double)prim.GetCameraAtOffset().X);
  1072. cmd.Parameters.AddWithValue("CameraAtOffsetY", (double)prim.GetCameraAtOffset().Y);
  1073. cmd.Parameters.AddWithValue("CameraAtOffsetZ", (double)prim.GetCameraAtOffset().Z);
  1074. if (prim.GetForceMouselook())
  1075. cmd.Parameters.AddWithValue("ForceMouselook", 1);
  1076. else
  1077. cmd.Parameters.AddWithValue("ForceMouselook", 0);
  1078. cmd.Parameters.AddWithValue("ScriptAccessPin", prim.ScriptAccessPin);
  1079. if (prim.AllowedDrop)
  1080. cmd.Parameters.AddWithValue("AllowedDrop", 1);
  1081. else
  1082. cmd.Parameters.AddWithValue("AllowedDrop", 0);
  1083. if (prim.DIE_AT_EDGE)
  1084. cmd.Parameters.AddWithValue("DieAtEdge", 1);
  1085. else
  1086. cmd.Parameters.AddWithValue("DieAtEdge", 0);
  1087. cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice);
  1088. cmd.Parameters.AddWithValue("SaleType", Convert.ToInt16(prim.ObjectSaleType));
  1089. byte clickAction = prim.ClickAction;
  1090. cmd.Parameters.AddWithValue("ClickAction", clickAction);
  1091. cmd.Parameters.AddWithValue("Material", prim.Material);
  1092. cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString());
  1093. cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume);
  1094. cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
  1095. }
  1096. /// <summary>
  1097. ///
  1098. /// </summary>
  1099. /// <param name="row"></param>
  1100. /// <param name="taskItem"></param>
  1101. private static void FillItemCommand(MySqlCommand cmd, TaskInventoryItem taskItem)
  1102. {
  1103. cmd.Parameters.AddWithValue("itemID", taskItem.ItemID);
  1104. cmd.Parameters.AddWithValue("primID", taskItem.ParentPartID);
  1105. cmd.Parameters.AddWithValue("assetID", taskItem.AssetID);
  1106. cmd.Parameters.AddWithValue("parentFolderID", taskItem.ParentID);
  1107. cmd.Parameters.AddWithValue("invType", taskItem.InvType);
  1108. cmd.Parameters.AddWithValue("assetType", taskItem.Type);
  1109. cmd.Parameters.AddWithValue("name", taskItem.Name);
  1110. cmd.Parameters.AddWithValue("description", taskItem.Description);
  1111. cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate);
  1112. cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID);
  1113. cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID);
  1114. cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID);
  1115. cmd.Parameters.AddWithValue("groupID", taskItem.GroupID);
  1116. cmd.Parameters.AddWithValue("nextPermissions", taskItem.NextPermissions);
  1117. cmd.Parameters.AddWithValue("currentPermissions", taskItem.CurrentPermissions);
  1118. cmd.Parameters.AddWithValue("basePermissions", taskItem.BasePermissions);
  1119. cmd.Parameters.AddWithValue("everyonePermissions", taskItem.EveryonePermissions);
  1120. cmd.Parameters.AddWithValue("groupPermissions", taskItem.GroupPermissions);
  1121. cmd.Parameters.AddWithValue("flags", taskItem.Flags);
  1122. }
  1123. /// <summary>
  1124. ///
  1125. /// </summary>
  1126. private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings settings)
  1127. {
  1128. cmd.Parameters.AddWithValue("RegionUUID", settings.RegionUUID.ToString());
  1129. cmd.Parameters.AddWithValue("BlockTerraform", settings.BlockTerraform);
  1130. cmd.Parameters.AddWithValue("BlockFly", settings.BlockFly);
  1131. cmd.Parameters.AddWithValue("AllowDamage", settings.AllowDamage);
  1132. cmd.Parameters.AddWithValue("RestrictPushing", settings.RestrictPushing);
  1133. cmd.Parameters.AddWithValue("AllowLandResell", settings.AllowLandResell);
  1134. cmd.Parameters.AddWithValue("AllowLandJoinDivide", settings.AllowLandJoinDivide);
  1135. cmd.Parameters.AddWithValue("BlockShowInSearch", settings.BlockShowInSearch);
  1136. cmd.Parameters.AddWithValue("AgentLimit", settings.AgentLimit);
  1137. cmd.Parameters.AddWithValue("ObjectBonus", settings.ObjectBonus);
  1138. cmd.Parameters.AddWithValue("Maturity", settings.Maturity);
  1139. cmd.Parameters.AddWithValue("DisableScripts", settings.DisableScripts);
  1140. cmd.Parameters.AddWithValue("DisableCollisions", settings.DisableCollisions);
  1141. cmd.Parameters.AddWithValue("DisablePhysics", settings.DisablePhysics);
  1142. cmd.Parameters.AddWithValue("TerrainTexture1", settings.TerrainTexture1.ToString());
  1143. cmd.Parameters.AddWithValue("TerrainTexture2", settings.TerrainTexture2.ToString());
  1144. cmd.Parameters.AddWithValue("TerrainTexture3", settings.TerrainTexture3.ToString());
  1145. cmd.Parameters.AddWithValue("TerrainTexture4", settings.TerrainTexture4.ToString());
  1146. cmd.Parameters.AddWithValue("Elevation1NW", settings.Elevation1NW);
  1147. cmd.Parameters.AddWithValue("Elevation2NW", settings.Elevation2NW);
  1148. cmd.Parameters.AddWithValue("Elevation1NE", settings.Elevation1NE);
  1149. cmd.Parameters.AddWithValue("Elevation2NE", settings.Elevation2NE);
  1150. cmd.Parameters.AddWithValue("Elevation1SE", settings.Elevation1SE);
  1151. cmd.Parameters.AddWithValue("Elevation2SE", settings.Elevation2SE);
  1152. cmd.Parameters.AddWithValue("Elevation1SW", settings.Elevation1SW);
  1153. cmd.Parameters.AddWithValue("Elevation2SW", settings.Elevation2SW);
  1154. cmd.Parameters.AddWithValue("WaterHeight", settings.WaterHeight);
  1155. cmd.Parameters.AddWithValue("TerrainRaiseLimit", settings.TerrainRaiseLimit);
  1156. cmd.Parameters.AddWithValue("TerrainLowerLimit", settings.TerrainLowerLimit);
  1157. cmd.Parameters.AddWithValue("UseEstateSun", settings.UseEstateSun);
  1158. cmd.Parameters.AddWithValue("Sandbox", settings.Sandbox);
  1159. cmd.Parameters.AddWithValue("SunVectorX", settings.SunVector.X);
  1160. cmd.Parameters.AddWithValue("SunVectorY", settings.SunVector.Y);
  1161. cmd.Parameters.AddWithValue("SunVectorZ", settings.SunVector.Z);
  1162. cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun);
  1163. cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition);
  1164. cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString());
  1165. }
  1166. /// <summary>
  1167. ///
  1168. /// </summary>
  1169. /// <param name="row"></param>
  1170. /// <param name="land"></param>
  1171. /// <param name="regionUUID"></param>
  1172. private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID)
  1173. {
  1174. cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(land.GlobalID));
  1175. cmd.Parameters.AddWithValue("RegionUUID", Util.ToRawUuidString(regionUUID));
  1176. cmd.Parameters.AddWithValue("LocalLandID", land.LocalID);
  1177. // Bitmap is a byte[512]
  1178. cmd.Parameters.AddWithValue("Bitmap", land.Bitmap);
  1179. cmd.Parameters.AddWithValue("Name", land.Name);
  1180. cmd.Parameters.AddWithValue("Description", land.Description);
  1181. cmd.Parameters.AddWithValue("OwnerUUID", Util.ToRawUuidString(land.OwnerID));
  1182. cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned);
  1183. cmd.Parameters.AddWithValue("Area", land.Area);
  1184. cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented
  1185. cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory
  1186. cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate);
  1187. cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice);
  1188. cmd.Parameters.AddWithValue("GroupUUID", Util.ToRawUuidString(land.GroupID));
  1189. cmd.Parameters.AddWithValue("SalePrice", land.SalePrice);
  1190. cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus
  1191. cmd.Parameters.AddWithValue("LandFlags", land.Flags);
  1192. cmd.Parameters.AddWithValue("LandingType", land.LandingType);
  1193. cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale);
  1194. cmd.Parameters.AddWithValue("MediaTextureUUID", Util.ToRawUuidString(land.MediaID));
  1195. cmd.Parameters.AddWithValue("MediaURL", land.MediaURL);
  1196. cmd.Parameters.AddWithValue("MusicURL", land.MusicURL);
  1197. cmd.Parameters.AddWithValue("PassHours", land.PassHours);
  1198. cmd.Parameters.AddWithValue("PassPrice", land.PassPrice);
  1199. cmd.Parameters.AddWithValue("SnapshotUUID", Util.ToRawUuidString(land.SnapshotID));
  1200. cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X);
  1201. cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y);
  1202. cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z);
  1203. cmd.Parameters.AddWithValue("UserLookAtX", land.UserLookAt.X);
  1204. cmd.Parameters.AddWithValue("UserLookAtY", land.UserLookAt.Y);
  1205. cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z);
  1206. cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID);
  1207. cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime);
  1208. cmd.Parameters.AddWithValue("Dwell", land.Dwell);
  1209. }
  1210. /// <summary>
  1211. ///
  1212. /// </summary>
  1213. /// <param name="row"></param>
  1214. /// <param name="entry"></param>
  1215. /// <param name="parcelID"></param>
  1216. private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID)
  1217. {
  1218. cmd.Parameters.AddWithValue("LandUUID", Util.ToRawUuidString(parcelID));
  1219. cmd.Parameters.AddWithValue("AccessUUID", Util.ToRawUuidString(entry.AgentID));
  1220. cmd.Parameters.AddWithValue("Flags", entry.Flags);
  1221. }
  1222. /// <summary>
  1223. ///
  1224. /// </summary>
  1225. /// <param name="row"></param>
  1226. /// <returns></returns>
  1227. private PrimitiveBaseShape BuildShape(IDataReader row)
  1228. {
  1229. PrimitiveBaseShape s = new PrimitiveBaseShape();
  1230. s.Scale = new Vector3(
  1231. Convert.ToSingle(row["ScaleX"]),
  1232. Convert.ToSingle(row["ScaleY"]),
  1233. Convert.ToSingle(row["ScaleZ"])
  1234. );
  1235. // paths
  1236. s.PCode = Convert.ToByte(row["PCode"]);
  1237. s.PathBegin = Convert.ToUInt16(row["PathBegin"]);
  1238. s.PathEnd = Convert.ToUInt16(row["PathEnd"]);
  1239. s.PathScaleX = Convert.ToByte(row["PathScaleX"]);
  1240. s.PathScaleY = Convert.ToByte(row["PathScaleY"]);
  1241. s.PathShearX = Convert.ToByte(row["PathShearX"]);
  1242. s.PathShearY = Convert.ToByte(row["PathShearY"]);
  1243. s.PathSkew = Convert.ToSByte(row["PathSkew"]);
  1244. s.PathCurve = Convert.ToByte(row["PathCurve"]);
  1245. s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]);
  1246. s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]);
  1247. s.PathTaperX = Convert.ToSByte(row["PathTaperX"]);
  1248. s.PathTaperY = Convert.ToSByte(row["PathTaperY"]);
  1249. s.PathTwist = Convert.ToSByte(row["PathTwist"]);
  1250. s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]);
  1251. // profile
  1252. s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]);
  1253. s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]);
  1254. s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]);
  1255. s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]);
  1256. byte[] textureEntry = (byte[]) row["Texture"];
  1257. s.TextureEntry = textureEntry;
  1258. s.ExtraParams = (byte[]) row["ExtraParams"];
  1259. s.State = Convert.ToByte(row["State"]);
  1260. return s;
  1261. }
  1262. /// <summary>
  1263. ///
  1264. /// </summary>
  1265. /// <param name="row"></param>
  1266. /// <param name="prim"></param>
  1267. private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim)
  1268. {
  1269. PrimitiveBaseShape s = prim.Shape;
  1270. cmd.Parameters.AddWithValue("UUID", Util.ToRawUuidString(prim.UUID));
  1271. // shape is an enum
  1272. cmd.Parameters.AddWithValue("Shape", 0);
  1273. // vectors
  1274. cmd.Parameters.AddWithValue("ScaleX", (double)s.Scale.X);
  1275. cmd.Parameters.AddWithValue("ScaleY", (double)s.Scale.Y);
  1276. cmd.Parameters.AddWithValue("ScaleZ", (double)s.Scale.Z);
  1277. // paths
  1278. cmd.Parameters.AddWithValue("PCode", s.PCode);
  1279. cmd.Parameters.AddWithValue("PathBegin", s.PathBegin);
  1280. cmd.Parameters.AddWithValue("PathEnd", s.PathEnd);
  1281. cmd.Parameters.AddWithValue("PathScaleX", s.PathScaleX);
  1282. cmd.Parameters.AddWithValue("PathScaleY", s.PathScaleY);
  1283. cmd.Parameters.AddWithValue("PathShearX", s.PathShearX);
  1284. cmd.Parameters.AddWithValue("PathShearY", s.PathShearY);
  1285. cmd.Parameters.AddWithValue("PathSkew", s.PathSkew);
  1286. cmd.Parameters.AddWithValue("PathCurve", s.PathCurve);
  1287. cmd.Parameters.AddWithValue("PathRadiusOffset", s.PathRadiusOffset);
  1288. cmd.Parameters.AddWithValue("PathRevolutions", s.PathRevolutions);
  1289. cmd.Parameters.AddWithValue("PathTaperX", s.PathTaperX);
  1290. cmd.Parameters.AddWithValue("PathTaperY", s.PathTaperY);
  1291. cmd.Parameters.AddWithValue("PathTwist", s.PathTwist);
  1292. cmd.Parameters.AddWithValue("PathTwistBegin", s.PathTwistBegin);
  1293. // profile
  1294. cmd.Parameters.AddWithValue("ProfileBegin", s.ProfileBegin);
  1295. cmd.Parameters.AddWithValue("ProfileEnd", s.ProfileEnd);
  1296. cmd.Parameters.AddWithValue("ProfileCurve", s.ProfileCurve);
  1297. cmd.Parameters.AddWithValue("ProfileHollow", s.ProfileHollow);
  1298. cmd.Parameters.AddWithValue("Texture", s.TextureEntry);
  1299. cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams);
  1300. cmd.Parameters.AddWithValue("State", s.State);
  1301. }
  1302. public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
  1303. {
  1304. lock (m_Connection)
  1305. {
  1306. RemoveItems(primID);
  1307. MySqlCommand cmd = m_Connection.CreateCommand();
  1308. if (items.Count == 0)
  1309. return;
  1310. cmd.CommandText = "insert into primitems ("+
  1311. "invType, assetType, name, "+
  1312. "description, creationDate, nextPermissions, "+
  1313. "currentPermissions, basePermissions, "+
  1314. "everyonePermissions, groupPermissions, "+
  1315. "flags, itemID, primID, assetID, "+
  1316. "parentFolderID, creatorID, ownerID, "+
  1317. "groupID, lastOwnerID) values (?invType, "+
  1318. "?assetType, ?name, ?description, "+
  1319. "?creationDate, ?nextPermissions, "+
  1320. "?currentPermissions, ?basePermissions, "+
  1321. "?everyonePermissions, ?groupPermissions, "+
  1322. "?flags, ?itemID, ?primID, ?assetID, "+
  1323. "?parentFolderID, ?creatorID, ?ownerID, "+
  1324. "?groupID, ?lastOwnerID)";
  1325. foreach (TaskInventoryItem item in items)
  1326. {
  1327. cmd.Parameters.Clear();
  1328. FillItemCommand(cmd, item);
  1329. ExecuteNonQuery(cmd);
  1330. }
  1331. cmd.Dispose();
  1332. }
  1333. }
  1334. }
  1335. }