MySQLRegionData.cs 68 KB

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