MySQLLegacyRegionData.cs 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. 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. using OpenSim.Data;
  41. namespace OpenSim.Data.MySQL
  42. {
  43. /// <summary>
  44. /// A MySQL Interface for the Region Server
  45. /// </summary>
  46. public class MySQLDataStore : IRegionDataStore
  47. {
  48. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  49. private string m_connectionString;
  50. private object m_dbLock = new object();
  51. public void Initialise(string connectionString)
  52. {
  53. m_connectionString = connectionString;
  54. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  55. {
  56. dbcon.Open();
  57. // Apply new Migrations
  58. //
  59. Assembly assem = GetType().Assembly;
  60. Migration m = new Migration(dbcon, assem, "RegionStore");
  61. m.Update();
  62. // Clean dropped attachments
  63. //
  64. try
  65. {
  66. using (MySqlCommand cmd = dbcon.CreateCommand())
  67. {
  68. cmd.CommandText = "delete from prims, primshapes using prims " +
  69. "left join primshapes on prims.uuid = primshapes.uuid " +
  70. "where PCode = 9 and State <> 0";
  71. ExecuteNonQuery(cmd);
  72. }
  73. }
  74. catch (MySqlException ex)
  75. {
  76. m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message);
  77. }
  78. }
  79. }
  80. private IDataReader ExecuteReader(MySqlCommand c)
  81. {
  82. IDataReader r = null;
  83. try
  84. {
  85. r = c.ExecuteReader();
  86. }
  87. catch (Exception e)
  88. {
  89. m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message);
  90. throw;
  91. }
  92. return r;
  93. }
  94. private void ExecuteNonQuery(MySqlCommand c)
  95. {
  96. try
  97. {
  98. c.ExecuteNonQuery();
  99. }
  100. catch (Exception e)
  101. {
  102. m_log.Error("[REGION DB]: MySQL error in ExecuteNonQuery: " + e.Message);
  103. throw;
  104. }
  105. }
  106. public void Dispose() {}
  107. public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
  108. {
  109. uint flags = obj.RootPart.GetEffectiveObjectFlags();
  110. // Eligibility check
  111. //
  112. if ((flags & (uint)PrimFlags.Temporary) != 0)
  113. return;
  114. if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
  115. return;
  116. lock (m_dbLock)
  117. {
  118. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  119. {
  120. dbcon.Open();
  121. MySqlCommand cmd = dbcon.CreateCommand();
  122. foreach (SceneObjectPart prim in obj.Children.Values)
  123. {
  124. cmd.Parameters.Clear();
  125. cmd.CommandText = "replace into prims (" +
  126. "UUID, CreationDate, " +
  127. "Name, Text, Description, " +
  128. "SitName, TouchName, ObjectFlags, " +
  129. "OwnerMask, NextOwnerMask, GroupMask, " +
  130. "EveryoneMask, BaseMask, PositionX, " +
  131. "PositionY, PositionZ, GroupPositionX, " +
  132. "GroupPositionY, GroupPositionZ, VelocityX, " +
  133. "VelocityY, VelocityZ, AngularVelocityX, " +
  134. "AngularVelocityY, AngularVelocityZ, " +
  135. "AccelerationX, AccelerationY, " +
  136. "AccelerationZ, RotationX, " +
  137. "RotationY, RotationZ, " +
  138. "RotationW, SitTargetOffsetX, " +
  139. "SitTargetOffsetY, SitTargetOffsetZ, " +
  140. "SitTargetOrientW, SitTargetOrientX, " +
  141. "SitTargetOrientY, SitTargetOrientZ, " +
  142. "RegionUUID, CreatorID, " +
  143. "OwnerID, GroupID, " +
  144. "LastOwnerID, SceneGroupID, " +
  145. "PayPrice, PayButton1, " +
  146. "PayButton2, PayButton3, " +
  147. "PayButton4, LoopedSound, " +
  148. "LoopedSoundGain, TextureAnimation, " +
  149. "OmegaX, OmegaY, OmegaZ, " +
  150. "CameraEyeOffsetX, CameraEyeOffsetY, " +
  151. "CameraEyeOffsetZ, CameraAtOffsetX, " +
  152. "CameraAtOffsetY, CameraAtOffsetZ, " +
  153. "ForceMouselook, ScriptAccessPin, " +
  154. "AllowedDrop, DieAtEdge, " +
  155. "SalePrice, SaleType, " +
  156. "ColorR, ColorG, ColorB, ColorA, " +
  157. "ParticleSystem, ClickAction, Material, " +
  158. "CollisionSound, CollisionSoundVolume, " +
  159. "PassTouches, " +
  160. "LinkNumber) values (" + "?UUID, " +
  161. "?CreationDate, ?Name, ?Text, " +
  162. "?Description, ?SitName, ?TouchName, " +
  163. "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " +
  164. "?GroupMask, ?EveryoneMask, ?BaseMask, " +
  165. "?PositionX, ?PositionY, ?PositionZ, " +
  166. "?GroupPositionX, ?GroupPositionY, " +
  167. "?GroupPositionZ, ?VelocityX, " +
  168. "?VelocityY, ?VelocityZ, ?AngularVelocityX, " +
  169. "?AngularVelocityY, ?AngularVelocityZ, " +
  170. "?AccelerationX, ?AccelerationY, " +
  171. "?AccelerationZ, ?RotationX, " +
  172. "?RotationY, ?RotationZ, " +
  173. "?RotationW, ?SitTargetOffsetX, " +
  174. "?SitTargetOffsetY, ?SitTargetOffsetZ, " +
  175. "?SitTargetOrientW, ?SitTargetOrientX, " +
  176. "?SitTargetOrientY, ?SitTargetOrientZ, " +
  177. "?RegionUUID, ?CreatorID, ?OwnerID, " +
  178. "?GroupID, ?LastOwnerID, ?SceneGroupID, " +
  179. "?PayPrice, ?PayButton1, ?PayButton2, " +
  180. "?PayButton3, ?PayButton4, ?LoopedSound, " +
  181. "?LoopedSoundGain, ?TextureAnimation, " +
  182. "?OmegaX, ?OmegaY, ?OmegaZ, " +
  183. "?CameraEyeOffsetX, ?CameraEyeOffsetY, " +
  184. "?CameraEyeOffsetZ, ?CameraAtOffsetX, " +
  185. "?CameraAtOffsetY, ?CameraAtOffsetZ, " +
  186. "?ForceMouselook, ?ScriptAccessPin, " +
  187. "?AllowedDrop, ?DieAtEdge, ?SalePrice, " +
  188. "?SaleType, ?ColorR, ?ColorG, " +
  189. "?ColorB, ?ColorA, ?ParticleSystem, " +
  190. "?ClickAction, ?Material, ?CollisionSound, " +
  191. "?CollisionSoundVolume, ?PassTouches, ?LinkNumber)";
  192. FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
  193. ExecuteNonQuery(cmd);
  194. cmd.Parameters.Clear();
  195. cmd.CommandText = "replace into primshapes (" +
  196. "UUID, Shape, ScaleX, ScaleY, " +
  197. "ScaleZ, PCode, PathBegin, PathEnd, " +
  198. "PathScaleX, PathScaleY, PathShearX, " +
  199. "PathShearY, PathSkew, PathCurve, " +
  200. "PathRadiusOffset, PathRevolutions, " +
  201. "PathTaperX, PathTaperY, PathTwist, " +
  202. "PathTwistBegin, ProfileBegin, ProfileEnd, " +
  203. "ProfileCurve, ProfileHollow, Texture, " +
  204. "ExtraParams, State) values (?UUID, " +
  205. "?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " +
  206. "?PCode, ?PathBegin, ?PathEnd, " +
  207. "?PathScaleX, ?PathScaleY, " +
  208. "?PathShearX, ?PathShearY, " +
  209. "?PathSkew, ?PathCurve, ?PathRadiusOffset, " +
  210. "?PathRevolutions, ?PathTaperX, " +
  211. "?PathTaperY, ?PathTwist, " +
  212. "?PathTwistBegin, ?ProfileBegin, " +
  213. "?ProfileEnd, ?ProfileCurve, " +
  214. "?ProfileHollow, ?Texture, ?ExtraParams, " +
  215. "?State)";
  216. FillShapeCommand(cmd, prim);
  217. ExecuteNonQuery(cmd);
  218. }
  219. cmd.Dispose();
  220. }
  221. }
  222. }
  223. public void RemoveObject(UUID obj, UUID regionUUID)
  224. {
  225. List<UUID> uuids = new List<UUID>();
  226. // Formerly, this used to check the region UUID.
  227. // That makes no sense, as we remove the contents of a prim
  228. // unconditionally, but the prim dependent on the region ID.
  229. // So, we would destroy an object and cause hard to detect
  230. // issues if we delete the contents only. Deleting it all may
  231. // cause the loss of a prim, but is cleaner.
  232. // It's also faster because it uses the primary key.
  233. //
  234. lock (m_dbLock)
  235. {
  236. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  237. {
  238. dbcon.Open();
  239. using (MySqlCommand cmd = dbcon.CreateCommand())
  240. {
  241. cmd.CommandText = "select UUID from prims where SceneGroupID= ?UUID";
  242. cmd.Parameters.AddWithValue("UUID", obj.ToString());
  243. using (IDataReader reader = ExecuteReader(cmd))
  244. {
  245. while (reader.Read())
  246. uuids.Add(DBGuid.FromDB(reader["UUID"].ToString()));
  247. }
  248. // delete the main prims
  249. cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
  250. ExecuteNonQuery(cmd);
  251. }
  252. }
  253. }
  254. // there is no way this should be < 1 unless there is
  255. // a very corrupt database, but in that case be extra
  256. // safe anyway.
  257. if (uuids.Count > 0)
  258. {
  259. RemoveShapes(uuids);
  260. RemoveItems(uuids);
  261. }
  262. }
  263. /// <summary>
  264. /// Remove all persisted items of the given prim.
  265. /// The caller must acquire the necessrary synchronization locks
  266. /// </summary>
  267. /// <param name="uuid">the Item UUID</param>
  268. private void RemoveItems(UUID uuid)
  269. {
  270. lock (m_dbLock)
  271. {
  272. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  273. {
  274. dbcon.Open();
  275. using (MySqlCommand cmd = dbcon.CreateCommand())
  276. {
  277. cmd.CommandText = "delete from primitems where PrimID = ?PrimID";
  278. cmd.Parameters.AddWithValue("PrimID", uuid.ToString());
  279. ExecuteNonQuery(cmd);
  280. }
  281. }
  282. }
  283. }
  284. /// <summary>
  285. /// Remove all persisted shapes for a list of prims
  286. /// The caller must acquire the necessrary synchronization locks
  287. /// </summary>
  288. /// <param name="uuids">the list of UUIDs</param>
  289. private void RemoveShapes(List<UUID> uuids)
  290. {
  291. lock (m_dbLock)
  292. {
  293. string sql = "delete from primshapes where ";
  294. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  295. {
  296. dbcon.Open();
  297. using (MySqlCommand cmd = dbcon.CreateCommand())
  298. {
  299. for (int i = 0; i < uuids.Count; i++)
  300. {
  301. if ((i + 1) == uuids.Count)
  302. {// end of the list
  303. sql += "(UUID = ?UUID" + i + ")";
  304. }
  305. else
  306. {
  307. sql += "(UUID = ?UUID" + i + ") or ";
  308. }
  309. }
  310. cmd.CommandText = sql;
  311. for (int i = 0; i < uuids.Count; i++)
  312. cmd.Parameters.AddWithValue("UUID" + i, uuids[i].ToString());
  313. ExecuteNonQuery(cmd);
  314. }
  315. }
  316. }
  317. }
  318. /// <summary>
  319. /// Remove all persisted items for a list of prims
  320. /// The caller must acquire the necessrary synchronization locks
  321. /// </summary>
  322. /// <param name="uuids">the list of UUIDs</param>
  323. private void RemoveItems(List<UUID> uuids)
  324. {
  325. lock (m_dbLock)
  326. {
  327. string sql = "delete from primitems where ";
  328. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  329. {
  330. dbcon.Open();
  331. using (MySqlCommand cmd = dbcon.CreateCommand())
  332. {
  333. for (int i = 0; i < uuids.Count; i++)
  334. {
  335. if ((i + 1) == uuids.Count)
  336. {
  337. // end of the list
  338. sql += "(PrimID = ?PrimID" + i + ")";
  339. }
  340. else
  341. {
  342. sql += "(PrimID = ?PrimID" + i + ") or ";
  343. }
  344. }
  345. cmd.CommandText = sql;
  346. for (int i = 0; i < uuids.Count; i++)
  347. cmd.Parameters.AddWithValue("PrimID" + i, uuids[i].ToString());
  348. ExecuteNonQuery(cmd);
  349. }
  350. }
  351. }
  352. }
  353. public List<SceneObjectGroup> LoadObjects(UUID regionID)
  354. {
  355. const int ROWS_PER_QUERY = 5000;
  356. Dictionary<UUID, SceneObjectPart> prims = new Dictionary<UUID, SceneObjectPart>(ROWS_PER_QUERY);
  357. Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>();
  358. int count = 0;
  359. #region Prim Loading
  360. lock (m_dbLock)
  361. {
  362. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  363. {
  364. dbcon.Open();
  365. using (MySqlCommand cmd = dbcon.CreateCommand())
  366. {
  367. cmd.CommandText =
  368. "SELECT * FROM prims LEFT JOIN primshapes ON prims.UUID = primshapes.UUID WHERE RegionUUID = ?RegionUUID";
  369. cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
  370. using (IDataReader reader = ExecuteReader(cmd))
  371. {
  372. while (reader.Read())
  373. {
  374. SceneObjectPart prim = BuildPrim(reader);
  375. if (reader["Shape"] is DBNull)
  376. prim.Shape = PrimitiveBaseShape.Default;
  377. else
  378. prim.Shape = BuildShape(reader);
  379. UUID parentID = DBGuid.FromDB(reader["SceneGroupID"].ToString());
  380. if (parentID != prim.UUID)
  381. prim.ParentUUID = parentID;
  382. prims[prim.UUID] = prim;
  383. ++count;
  384. if (count % ROWS_PER_QUERY == 0)
  385. m_log.Debug("[REGION DB]: Loaded " + count + " prims...");
  386. }
  387. }
  388. }
  389. }
  390. }
  391. #endregion Prim Loading
  392. #region SceneObjectGroup Creation
  393. // Create all of the SOGs from the root prims first
  394. foreach (SceneObjectPart prim in prims.Values)
  395. {
  396. if (prim.ParentUUID == UUID.Zero)
  397. objects[prim.UUID] = new SceneObjectGroup(prim);
  398. }
  399. // Add all of the children objects to the SOGs
  400. foreach (SceneObjectPart prim in prims.Values)
  401. {
  402. SceneObjectGroup sog;
  403. if (prim.UUID != prim.ParentUUID)
  404. {
  405. if (objects.TryGetValue(prim.ParentUUID, out sog))
  406. {
  407. int originalLinkNum = prim.LinkNum;
  408. sog.AddPart(prim);
  409. // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum.
  410. // We override that here
  411. if (originalLinkNum != 0)
  412. prim.LinkNum = originalLinkNum;
  413. }
  414. else
  415. {
  416. m_log.WarnFormat(
  417. "[REGION DB]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.",
  418. prim.Name, prim.UUID, regionID, prim.ParentUUID);
  419. }
  420. }
  421. }
  422. #endregion SceneObjectGroup Creation
  423. m_log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count);
  424. #region Prim Inventory Loading
  425. // Instead of attempting to LoadItems on every prim,
  426. // most of which probably have no items... get a
  427. // list from DB of all prims which have items and
  428. // LoadItems only on those
  429. List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>();
  430. lock (m_dbLock)
  431. {
  432. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  433. {
  434. dbcon.Open();
  435. using (MySqlCommand itemCmd = dbcon.CreateCommand())
  436. {
  437. itemCmd.CommandText = "SELECT DISTINCT primID FROM primitems";
  438. using (IDataReader itemReader = ExecuteReader(itemCmd))
  439. {
  440. while (itemReader.Read())
  441. {
  442. if (!(itemReader["primID"] is DBNull))
  443. {
  444. UUID primID = DBGuid.FromDB(itemReader["primID"].ToString());
  445. if (prims.ContainsKey(primID))
  446. primsWithInventory.Add(prims[primID]);
  447. }
  448. }
  449. }
  450. }
  451. }
  452. }
  453. foreach (SceneObjectPart prim in primsWithInventory)
  454. {
  455. LoadItems(prim);
  456. }
  457. #endregion Prim Inventory Loading
  458. m_log.DebugFormat("[REGION DB]: Loaded inventory from {0} objects", primsWithInventory.Count);
  459. return new List<SceneObjectGroup>(objects.Values);
  460. }
  461. /// <summary>
  462. /// Load in a prim's persisted inventory.
  463. /// </summary>
  464. /// <param name="prim">The prim</param>
  465. private void LoadItems(SceneObjectPart prim)
  466. {
  467. lock (m_dbLock)
  468. {
  469. List<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
  470. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  471. {
  472. dbcon.Open();
  473. using (MySqlCommand cmd = dbcon.CreateCommand())
  474. {
  475. cmd.CommandText = "select * from primitems where PrimID = ?PrimID";
  476. cmd.Parameters.AddWithValue("PrimID", prim.UUID.ToString());
  477. using (IDataReader reader = ExecuteReader(cmd))
  478. {
  479. while (reader.Read())
  480. {
  481. TaskInventoryItem item = BuildItem(reader);
  482. item.ParentID = prim.UUID; // Values in database are often wrong
  483. inventory.Add(item);
  484. }
  485. }
  486. }
  487. }
  488. prim.Inventory.RestoreInventoryItems(inventory);
  489. }
  490. }
  491. public void StoreTerrain(double[,] ter, UUID regionID)
  492. {
  493. m_log.Info("[REGION DB]: Storing terrain");
  494. lock (m_dbLock)
  495. {
  496. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  497. {
  498. dbcon.Open();
  499. using (MySqlCommand cmd = dbcon.CreateCommand())
  500. {
  501. cmd.CommandText = "delete from terrain where RegionUUID = ?RegionUUID";
  502. cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
  503. ExecuteNonQuery(cmd);
  504. cmd.CommandText = "insert into terrain (RegionUUID, " +
  505. "Revision, Heightfield) values (?RegionUUID, " +
  506. "1, ?Heightfield)";
  507. cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
  508. ExecuteNonQuery(cmd);
  509. }
  510. }
  511. }
  512. }
  513. public double[,] LoadTerrain(UUID regionID)
  514. {
  515. double[,] terrain = null;
  516. lock (m_dbLock)
  517. {
  518. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  519. {
  520. dbcon.Open();
  521. using (MySqlCommand cmd = dbcon.CreateCommand())
  522. {
  523. cmd.CommandText = "select RegionUUID, Revision, Heightfield " +
  524. "from terrain where RegionUUID = ?RegionUUID " +
  525. "order by Revision desc limit 1";
  526. cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
  527. using (IDataReader reader = ExecuteReader(cmd))
  528. {
  529. while (reader.Read())
  530. {
  531. int rev = Convert.ToInt32(reader["Revision"]);
  532. terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize];
  533. terrain.Initialize();
  534. using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"]))
  535. {
  536. using (BinaryReader br = new BinaryReader(mstr))
  537. {
  538. for (int x = 0; x < (int)Constants.RegionSize; x++)
  539. {
  540. for (int y = 0; y < (int)Constants.RegionSize; y++)
  541. {
  542. terrain[x, y] = br.ReadDouble();
  543. }
  544. }
  545. }
  546. m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev);
  547. }
  548. }
  549. }
  550. }
  551. }
  552. }
  553. return terrain;
  554. }
  555. public void RemoveLandObject(UUID globalID)
  556. {
  557. lock (m_dbLock)
  558. {
  559. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  560. {
  561. dbcon.Open();
  562. using (MySqlCommand cmd = dbcon.CreateCommand())
  563. {
  564. cmd.CommandText = "delete from land where UUID = ?UUID";
  565. cmd.Parameters.AddWithValue("UUID", globalID.ToString());
  566. ExecuteNonQuery(cmd);
  567. }
  568. }
  569. }
  570. }
  571. public void StoreLandObject(ILandObject parcel)
  572. {
  573. lock (m_dbLock)
  574. {
  575. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  576. {
  577. dbcon.Open();
  578. using (MySqlCommand cmd = dbcon.CreateCommand())
  579. {
  580. cmd.CommandText = "replace into land (UUID, RegionUUID, " +
  581. "LocalLandID, Bitmap, Name, Description, " +
  582. "OwnerUUID, IsGroupOwned, Area, AuctionID, " +
  583. "Category, ClaimDate, ClaimPrice, GroupUUID, " +
  584. "SalePrice, LandStatus, LandFlags, LandingType, " +
  585. "MediaAutoScale, MediaTextureUUID, MediaURL, " +
  586. "MusicURL, PassHours, PassPrice, SnapshotUUID, " +
  587. "UserLocationX, UserLocationY, UserLocationZ, " +
  588. "UserLookAtX, UserLookAtY, UserLookAtZ, " +
  589. "AuthbuyerID, OtherCleanTime, Dwell) values (" +
  590. "?UUID, ?RegionUUID, " +
  591. "?LocalLandID, ?Bitmap, ?Name, ?Description, " +
  592. "?OwnerUUID, ?IsGroupOwned, ?Area, ?AuctionID, " +
  593. "?Category, ?ClaimDate, ?ClaimPrice, ?GroupUUID, " +
  594. "?SalePrice, ?LandStatus, ?LandFlags, ?LandingType, " +
  595. "?MediaAutoScale, ?MediaTextureUUID, ?MediaURL, " +
  596. "?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " +
  597. "?UserLocationX, ?UserLocationY, ?UserLocationZ, " +
  598. "?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " +
  599. "?AuthbuyerID, ?OtherCleanTime, ?Dwell)";
  600. FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID);
  601. ExecuteNonQuery(cmd);
  602. cmd.CommandText = "delete from landaccesslist where LandUUID = ?UUID";
  603. ExecuteNonQuery(cmd);
  604. cmd.Parameters.Clear();
  605. cmd.CommandText = "insert into landaccesslist (LandUUID, " +
  606. "AccessUUID, Flags) values (?LandUUID, ?AccessUUID, " +
  607. "?Flags)";
  608. foreach (ParcelManager.ParcelAccessEntry entry in parcel.LandData.ParcelAccessList)
  609. {
  610. FillLandAccessCommand(cmd, entry, parcel.LandData.GlobalID);
  611. ExecuteNonQuery(cmd);
  612. cmd.Parameters.Clear();
  613. }
  614. }
  615. }
  616. }
  617. }
  618. public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
  619. {
  620. RegionLightShareData nWP = new RegionLightShareData();
  621. nWP.OnSave += StoreRegionWindlightSettings;
  622. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  623. {
  624. dbcon.Open();
  625. string command = "select * from `regionwindlight` where region_id = ?regionID";
  626. using(MySqlCommand cmd = new MySqlCommand(command))
  627. {
  628. cmd.Connection = dbcon;
  629. cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
  630. IDataReader result = ExecuteReader(cmd);
  631. if (!result.Read())
  632. {
  633. //No result, so store our default windlight profile and return it
  634. nWP.regionID = regionUUID;
  635. StoreRegionWindlightSettings(nWP);
  636. return nWP;
  637. }
  638. else
  639. {
  640. nWP.regionID = DBGuid.FromDB(result["region_id"]);
  641. nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
  642. nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
  643. nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
  644. nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
  645. nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
  646. nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
  647. nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
  648. nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
  649. nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
  650. nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
  651. nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
  652. nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
  653. nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
  654. nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
  655. nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
  656. nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
  657. nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
  658. UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
  659. nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
  660. nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
  661. nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
  662. nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
  663. nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
  664. nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
  665. nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
  666. nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
  667. nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
  668. nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
  669. nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
  670. nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
  671. nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
  672. nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
  673. nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
  674. nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
  675. nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
  676. nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
  677. nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
  678. nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
  679. nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
  680. nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
  681. nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
  682. nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
  683. nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
  684. nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
  685. nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
  686. nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
  687. nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
  688. nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
  689. nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
  690. nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
  691. nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
  692. nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
  693. nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
  694. nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
  695. nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
  696. nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
  697. nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
  698. nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
  699. nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
  700. nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
  701. nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
  702. nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
  703. }
  704. }
  705. }
  706. return nWP;
  707. }
  708. public RegionSettings LoadRegionSettings(UUID regionUUID)
  709. {
  710. RegionSettings rs = null;
  711. lock (m_dbLock)
  712. {
  713. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  714. {
  715. dbcon.Open();
  716. using (MySqlCommand cmd = dbcon.CreateCommand())
  717. {
  718. cmd.CommandText = "select * from regionsettings where regionUUID = ?RegionUUID";
  719. cmd.Parameters.AddWithValue("regionUUID", regionUUID);
  720. using (IDataReader reader = ExecuteReader(cmd))
  721. {
  722. if (reader.Read())
  723. {
  724. rs = BuildRegionSettings(reader);
  725. rs.OnSave += StoreRegionSettings;
  726. }
  727. else
  728. {
  729. rs = new RegionSettings();
  730. rs.RegionUUID = regionUUID;
  731. rs.OnSave += StoreRegionSettings;
  732. StoreRegionSettings(rs);
  733. }
  734. }
  735. }
  736. }
  737. }
  738. return rs;
  739. }
  740. public void StoreRegionWindlightSettings(RegionLightShareData wl)
  741. {
  742. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  743. {
  744. dbcon.Open();
  745. using (MySqlCommand cmd = dbcon.CreateCommand())
  746. {
  747. cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, ";
  748. cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, ";
  749. cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, ";
  750. cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, ";
  751. cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, ";
  752. cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, ";
  753. cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, ";
  754. cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, ";
  755. cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, ";
  756. cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, ";
  757. cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, ";
  758. cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, ";
  759. cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, ";
  760. cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, ";
  761. cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, ";
  762. cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, ";
  763. cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, ";
  764. cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, ";
  765. cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, ";
  766. cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, ";
  767. cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, ";
  768. cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, ";
  769. cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, ";
  770. cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, ";
  771. cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)";
  772. cmd.Parameters.AddWithValue("region_id", wl.regionID);
  773. cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
  774. cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
  775. cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
  776. cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
  777. cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
  778. cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
  779. cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
  780. cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
  781. cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
  782. cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
  783. cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
  784. cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
  785. cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
  786. cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
  787. cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
  788. cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
  789. cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
  790. cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
  791. cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
  792. cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
  793. cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
  794. cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
  795. cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
  796. cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
  797. cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
  798. cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
  799. cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
  800. cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
  801. cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
  802. cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
  803. cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
  804. cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
  805. cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
  806. cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
  807. cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
  808. cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
  809. cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
  810. cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
  811. cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
  812. cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
  813. cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
  814. cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
  815. cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
  816. cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
  817. cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
  818. cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
  819. cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
  820. cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
  821. cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
  822. cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
  823. cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
  824. cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
  825. cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
  826. cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
  827. cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
  828. cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
  829. cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
  830. cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
  831. cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
  832. cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
  833. cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
  834. cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
  835. ExecuteNonQuery(cmd);
  836. }
  837. }
  838. }
  839. public void StoreRegionSettings(RegionSettings rs)
  840. {
  841. lock (m_dbLock)
  842. {
  843. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  844. {
  845. dbcon.Open();
  846. using (MySqlCommand cmd = dbcon.CreateCommand())
  847. {
  848. cmd.CommandText = "replace into regionsettings (regionUUID, " +
  849. "block_terraform, block_fly, allow_damage, " +
  850. "restrict_pushing, allow_land_resell, " +
  851. "allow_land_join_divide, block_show_in_search, " +
  852. "agent_limit, object_bonus, maturity, " +
  853. "disable_scripts, disable_collisions, " +
  854. "disable_physics, terrain_texture_1, " +
  855. "terrain_texture_2, terrain_texture_3, " +
  856. "terrain_texture_4, elevation_1_nw, " +
  857. "elevation_2_nw, elevation_1_ne, " +
  858. "elevation_2_ne, elevation_1_se, " +
  859. "elevation_2_se, elevation_1_sw, " +
  860. "elevation_2_sw, water_height, " +
  861. "terrain_raise_limit, terrain_lower_limit, " +
  862. "use_estate_sun, fixed_sun, sun_position, " +
  863. "covenant, Sandbox, sunvectorx, sunvectory, " +
  864. "sunvectorz, loaded_creation_datetime, " +
  865. "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " +
  866. "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
  867. "?AllowLandResell, ?AllowLandJoinDivide, " +
  868. "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " +
  869. "?Maturity, ?DisableScripts, ?DisableCollisions, " +
  870. "?DisablePhysics, ?TerrainTexture1, " +
  871. "?TerrainTexture2, ?TerrainTexture3, " +
  872. "?TerrainTexture4, ?Elevation1NW, ?Elevation2NW, " +
  873. "?Elevation1NE, ?Elevation2NE, ?Elevation1SE, " +
  874. "?Elevation2SE, ?Elevation1SW, ?Elevation2SW, " +
  875. "?WaterHeight, ?TerrainRaiseLimit, " +
  876. "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " +
  877. "?SunPosition, ?Covenant, ?Sandbox, " +
  878. "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
  879. "?LoadedCreationDateTime, ?LoadedCreationID, " +
  880. "?TerrainImageID)";
  881. FillRegionSettingsCommand(cmd, rs);
  882. ExecuteNonQuery(cmd);
  883. }
  884. }
  885. }
  886. }
  887. public List<LandData> LoadLandObjects(UUID regionUUID)
  888. {
  889. List<LandData> landData = new List<LandData>();
  890. lock (m_dbLock)
  891. {
  892. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  893. {
  894. dbcon.Open();
  895. using (MySqlCommand cmd = dbcon.CreateCommand())
  896. {
  897. cmd.CommandText = "select * from land where RegionUUID = ?RegionUUID";
  898. cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
  899. using (IDataReader reader = ExecuteReader(cmd))
  900. {
  901. while (reader.Read())
  902. {
  903. LandData newLand = BuildLandData(reader);
  904. landData.Add(newLand);
  905. }
  906. }
  907. }
  908. using (MySqlCommand cmd = dbcon.CreateCommand())
  909. {
  910. foreach (LandData land in landData)
  911. {
  912. cmd.Parameters.Clear();
  913. cmd.CommandText = "select * from landaccesslist where LandUUID = ?LandUUID";
  914. cmd.Parameters.AddWithValue("LandUUID", land.GlobalID.ToString());
  915. using (IDataReader reader = ExecuteReader(cmd))
  916. {
  917. while (reader.Read())
  918. {
  919. land.ParcelAccessList.Add(BuildLandAccessData(reader));
  920. }
  921. }
  922. }
  923. }
  924. }
  925. }
  926. return landData;
  927. }
  928. public void Shutdown()
  929. {
  930. }
  931. private SceneObjectPart BuildPrim(IDataReader row)
  932. {
  933. SceneObjectPart prim = new SceneObjectPart();
  934. // depending on the MySQL connector version, CHAR(36) may be already converted to Guid!
  935. prim.UUID = DBGuid.FromDB(row["UUID"]);
  936. prim.CreatorID = DBGuid.FromDB(row["CreatorID"]);
  937. prim.OwnerID = DBGuid.FromDB(row["OwnerID"]);
  938. prim.GroupID = DBGuid.FromDB(row["GroupID"]);
  939. prim.LastOwnerID = DBGuid.FromDB(row["LastOwnerID"]);
  940. // explicit conversion of integers is required, which sort
  941. // of sucks. No idea if there is a shortcut here or not.
  942. prim.CreationDate = (int)row["CreationDate"];
  943. if (row["Name"] != DBNull.Value)
  944. prim.Name = (string)row["Name"];
  945. else
  946. prim.Name = String.Empty;
  947. // Various text fields
  948. prim.Text = (string)row["Text"];
  949. prim.Color = Color.FromArgb((int)row["ColorA"],
  950. (int)row["ColorR"],
  951. (int)row["ColorG"],
  952. (int)row["ColorB"]);
  953. prim.Description = (string)row["Description"];
  954. prim.SitName = (string)row["SitName"];
  955. prim.TouchName = (string)row["TouchName"];
  956. // Permissions
  957. prim.ObjectFlags = (uint)(int)row["ObjectFlags"];
  958. prim.OwnerMask = (uint)(int)row["OwnerMask"];
  959. prim.NextOwnerMask = (uint)(int)row["NextOwnerMask"];
  960. prim.GroupMask = (uint)(int)row["GroupMask"];
  961. prim.EveryoneMask = (uint)(int)row["EveryoneMask"];
  962. prim.BaseMask = (uint)(int)row["BaseMask"];
  963. // Vectors
  964. prim.OffsetPosition = new Vector3(
  965. (float)(double)row["PositionX"],
  966. (float)(double)row["PositionY"],
  967. (float)(double)row["PositionZ"]
  968. );
  969. prim.GroupPosition = new Vector3(
  970. (float)(double)row["GroupPositionX"],
  971. (float)(double)row["GroupPositionY"],
  972. (float)(double)row["GroupPositionZ"]
  973. );
  974. prim.Velocity = new Vector3(
  975. (float)(double)row["VelocityX"],
  976. (float)(double)row["VelocityY"],
  977. (float)(double)row["VelocityZ"]
  978. );
  979. prim.AngularVelocity = new Vector3(
  980. (float)(double)row["AngularVelocityX"],
  981. (float)(double)row["AngularVelocityY"],
  982. (float)(double)row["AngularVelocityZ"]
  983. );
  984. prim.Acceleration = new Vector3(
  985. (float)(double)row["AccelerationX"],
  986. (float)(double)row["AccelerationY"],
  987. (float)(double)row["AccelerationZ"]
  988. );
  989. // quaternions
  990. prim.RotationOffset = new Quaternion(
  991. (float)(double)row["RotationX"],
  992. (float)(double)row["RotationY"],
  993. (float)(double)row["RotationZ"],
  994. (float)(double)row["RotationW"]
  995. );
  996. prim.SitTargetPositionLL = new Vector3(
  997. (float)(double)row["SitTargetOffsetX"],
  998. (float)(double)row["SitTargetOffsetY"],
  999. (float)(double)row["SitTargetOffsetZ"]
  1000. );
  1001. prim.SitTargetOrientationLL = new Quaternion(
  1002. (float)(double)row["SitTargetOrientX"],
  1003. (float)(double)row["SitTargetOrientY"],
  1004. (float)(double)row["SitTargetOrientZ"],
  1005. (float)(double)row["SitTargetOrientW"]
  1006. );
  1007. prim.PayPrice[0] = (int)row["PayPrice"];
  1008. prim.PayPrice[1] = (int)row["PayButton1"];
  1009. prim.PayPrice[2] = (int)row["PayButton2"];
  1010. prim.PayPrice[3] = (int)row["PayButton3"];
  1011. prim.PayPrice[4] = (int)row["PayButton4"];
  1012. prim.Sound = DBGuid.FromDB(row["LoopedSound"].ToString());
  1013. prim.SoundGain = (float)(double)row["LoopedSoundGain"];
  1014. prim.SoundFlags = 1; // If it's persisted at all, it's looped
  1015. if (!(row["TextureAnimation"] is DBNull))
  1016. prim.TextureAnimation = (byte[])row["TextureAnimation"];
  1017. if (!(row["ParticleSystem"] is DBNull))
  1018. prim.ParticleSystem = (byte[])row["ParticleSystem"];
  1019. prim.AngularVelocity = new Vector3(
  1020. (float)(double)row["OmegaX"],
  1021. (float)(double)row["OmegaY"],
  1022. (float)(double)row["OmegaZ"]
  1023. );
  1024. prim.SetCameraEyeOffset(new Vector3(
  1025. (float)(double)row["CameraEyeOffsetX"],
  1026. (float)(double)row["CameraEyeOffsetY"],
  1027. (float)(double)row["CameraEyeOffsetZ"]
  1028. ));
  1029. prim.SetCameraAtOffset(new Vector3(
  1030. (float)(double)row["CameraAtOffsetX"],
  1031. (float)(double)row["CameraAtOffsetY"],
  1032. (float)(double)row["CameraAtOffsetZ"]
  1033. ));
  1034. prim.SetForceMouselook((sbyte)row["ForceMouselook"] != 0);
  1035. prim.ScriptAccessPin = (int)row["ScriptAccessPin"];
  1036. prim.AllowedDrop = ((sbyte)row["AllowedDrop"] != 0);
  1037. prim.DIE_AT_EDGE = ((sbyte)row["DieAtEdge"] != 0);
  1038. prim.SalePrice = (int)row["SalePrice"];
  1039. prim.ObjectSaleType = unchecked((byte)(sbyte)row["SaleType"]);
  1040. prim.Material = unchecked((byte)(sbyte)row["Material"]);
  1041. if (!(row["ClickAction"] is DBNull))
  1042. prim.ClickAction = unchecked((byte)(sbyte)row["ClickAction"]);
  1043. prim.CollisionSound = DBGuid.FromDB(row["CollisionSound"]);
  1044. prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"];
  1045. prim.PassTouches = ((sbyte)row["PassTouches"] != 0);
  1046. prim.LinkNum = (int)row["LinkNumber"];
  1047. return prim;
  1048. }
  1049. /// <summary>
  1050. /// Build a prim inventory item from the persisted data.
  1051. /// </summary>
  1052. /// <param name="row"></param>
  1053. /// <returns></returns>
  1054. private static TaskInventoryItem BuildItem(IDataReader row)
  1055. {
  1056. TaskInventoryItem taskItem = new TaskInventoryItem();
  1057. taskItem.ItemID = DBGuid.FromDB(row["itemID"]);
  1058. taskItem.ParentPartID = DBGuid.FromDB(row["primID"]);
  1059. taskItem.AssetID = DBGuid.FromDB(row["assetID"]);
  1060. taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]);
  1061. taskItem.InvType = Convert.ToInt32(row["invType"]);
  1062. taskItem.Type = Convert.ToInt32(row["assetType"]);
  1063. taskItem.Name = (String)row["name"];
  1064. taskItem.Description = (String)row["description"];
  1065. taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]);
  1066. taskItem.CreatorID = DBGuid.FromDB(row["creatorID"]);
  1067. taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]);
  1068. taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]);
  1069. taskItem.GroupID = DBGuid.FromDB(row["groupID"]);
  1070. taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]);
  1071. taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]);
  1072. taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]);
  1073. taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]);
  1074. taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]);
  1075. taskItem.Flags = Convert.ToUInt32(row["flags"]);
  1076. return taskItem;
  1077. }
  1078. private static RegionSettings BuildRegionSettings(IDataReader row)
  1079. {
  1080. RegionSettings newSettings = new RegionSettings();
  1081. newSettings.RegionUUID = DBGuid.FromDB(row["regionUUID"]);
  1082. newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]);
  1083. newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]);
  1084. newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]);
  1085. newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]);
  1086. newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]);
  1087. newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]);
  1088. newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]);
  1089. newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]);
  1090. newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]);
  1091. newSettings.Maturity = Convert.ToInt32(row["maturity"]);
  1092. newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]);
  1093. newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]);
  1094. newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]);
  1095. newSettings.TerrainTexture1 = DBGuid.FromDB(row["terrain_texture_1"]);
  1096. newSettings.TerrainTexture2 = DBGuid.FromDB(row["terrain_texture_2"]);
  1097. newSettings.TerrainTexture3 = DBGuid.FromDB(row["terrain_texture_3"]);
  1098. newSettings.TerrainTexture4 = DBGuid.FromDB(row["terrain_texture_4"]);
  1099. newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]);
  1100. newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]);
  1101. newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]);
  1102. newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]);
  1103. newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]);
  1104. newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]);
  1105. newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]);
  1106. newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]);
  1107. newSettings.WaterHeight = Convert.ToDouble(row["water_height"]);
  1108. newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]);
  1109. newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]);
  1110. newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]);
  1111. newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]);
  1112. newSettings.SunVector = new Vector3 (
  1113. Convert.ToSingle(row["sunvectorx"]),
  1114. Convert.ToSingle(row["sunvectory"]),
  1115. Convert.ToSingle(row["sunvectorz"])
  1116. );
  1117. newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]);
  1118. newSettings.SunPosition = Convert.ToDouble(row["sun_position"]);
  1119. newSettings.Covenant = DBGuid.FromDB(row["covenant"]);
  1120. newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]);
  1121. if (row["loaded_creation_id"] is DBNull)
  1122. newSettings.LoadedCreationID = "";
  1123. else
  1124. newSettings.LoadedCreationID = (String) row["loaded_creation_id"];
  1125. newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]);
  1126. return newSettings;
  1127. }
  1128. /// <summary>
  1129. ///
  1130. /// </summary>
  1131. /// <param name="row"></param>
  1132. /// <returns></returns>
  1133. private static LandData BuildLandData(IDataReader row)
  1134. {
  1135. LandData newData = new LandData();
  1136. newData.GlobalID = DBGuid.FromDB(row["UUID"]);
  1137. newData.LocalID = Convert.ToInt32(row["LocalLandID"]);
  1138. // Bitmap is a byte[512]
  1139. newData.Bitmap = (Byte[]) row["Bitmap"];
  1140. newData.Name = (String) row["Name"];
  1141. newData.Description = (String) row["Description"];
  1142. newData.OwnerID = DBGuid.FromDB(row["OwnerUUID"]);
  1143. newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]);
  1144. newData.Area = Convert.ToInt32(row["Area"]);
  1145. newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unimplemented
  1146. newData.Category = (ParcelCategory) Convert.ToInt32(row["Category"]);
  1147. //Enum libsecondlife.Parcel.ParcelCategory
  1148. newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]);
  1149. newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]);
  1150. newData.GroupID = DBGuid.FromDB(row["GroupUUID"]);
  1151. newData.SalePrice = Convert.ToInt32(row["SalePrice"]);
  1152. newData.Status = (ParcelStatus) Convert.ToInt32(row["LandStatus"]);
  1153. //Enum. libsecondlife.Parcel.ParcelStatus
  1154. newData.Flags = Convert.ToUInt32(row["LandFlags"]);
  1155. newData.LandingType = Convert.ToByte(row["LandingType"]);
  1156. newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]);
  1157. newData.MediaID = DBGuid.FromDB(row["MediaTextureUUID"]);
  1158. newData.MediaURL = (String) row["MediaURL"];
  1159. newData.MusicURL = (String) row["MusicURL"];
  1160. newData.PassHours = Convert.ToSingle(row["PassHours"]);
  1161. newData.PassPrice = Convert.ToInt32(row["PassPrice"]);
  1162. UUID authedbuyer = UUID.Zero;
  1163. UUID snapshotID = UUID.Zero;
  1164. UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer);
  1165. UUID.TryParse((string)row["SnapshotUUID"], out snapshotID);
  1166. newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]);
  1167. newData.Dwell = Convert.ToInt32(row["Dwell"]);
  1168. newData.AuthBuyerID = authedbuyer;
  1169. newData.SnapshotID = snapshotID;
  1170. try
  1171. {
  1172. newData.UserLocation =
  1173. new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]),
  1174. Convert.ToSingle(row["UserLocationZ"]));
  1175. newData.UserLookAt =
  1176. new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]),
  1177. Convert.ToSingle(row["UserLookAtZ"]));
  1178. }
  1179. catch (InvalidCastException)
  1180. {
  1181. newData.UserLocation = Vector3.Zero;
  1182. newData.UserLookAt = Vector3.Zero;
  1183. m_log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name);
  1184. }
  1185. newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>();
  1186. return newData;
  1187. }
  1188. /// <summary>
  1189. ///
  1190. /// </summary>
  1191. /// <param name="row"></param>
  1192. /// <returns></returns>
  1193. private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataReader row)
  1194. {
  1195. ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
  1196. entry.AgentID = DBGuid.FromDB(row["AccessUUID"]);
  1197. entry.Flags = (AccessList) Convert.ToInt32(row["Flags"]);
  1198. entry.Time = new DateTime();
  1199. return entry;
  1200. }
  1201. /// <summary>
  1202. ///
  1203. /// </summary>
  1204. /// <param name="val"></param>
  1205. /// <returns></returns>
  1206. private static Array SerializeTerrain(double[,] val)
  1207. {
  1208. MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
  1209. BinaryWriter bw = new BinaryWriter(str);
  1210. // TODO: COMPATIBILITY - Add byte-order conversions
  1211. for (int x = 0; x < (int)Constants.RegionSize; x++)
  1212. for (int y = 0; y < (int)Constants.RegionSize; y++)
  1213. {
  1214. double height = val[x, y];
  1215. if (height == 0.0)
  1216. height = double.Epsilon;
  1217. bw.Write(height);
  1218. }
  1219. return str.ToArray();
  1220. }
  1221. /// <summary>
  1222. /// Fill the prim command with prim values
  1223. /// </summary>
  1224. /// <param name="row"></param>
  1225. /// <param name="prim"></param>
  1226. /// <param name="sceneGroupID"></param>
  1227. /// <param name="regionUUID"></param>
  1228. private void FillPrimCommand(MySqlCommand cmd, SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
  1229. {
  1230. cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString());
  1231. cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
  1232. cmd.Parameters.AddWithValue("CreationDate", prim.CreationDate);
  1233. cmd.Parameters.AddWithValue("Name", prim.Name);
  1234. cmd.Parameters.AddWithValue("SceneGroupID", sceneGroupID.ToString());
  1235. // the UUID of the root part for this SceneObjectGroup
  1236. // various text fields
  1237. cmd.Parameters.AddWithValue("Text", prim.Text);
  1238. cmd.Parameters.AddWithValue("ColorR", prim.Color.R);
  1239. cmd.Parameters.AddWithValue("ColorG", prim.Color.G);
  1240. cmd.Parameters.AddWithValue("ColorB", prim.Color.B);
  1241. cmd.Parameters.AddWithValue("ColorA", prim.Color.A);
  1242. cmd.Parameters.AddWithValue("Description", prim.Description);
  1243. cmd.Parameters.AddWithValue("SitName", prim.SitName);
  1244. cmd.Parameters.AddWithValue("TouchName", prim.TouchName);
  1245. // permissions
  1246. cmd.Parameters.AddWithValue("ObjectFlags", prim.ObjectFlags);
  1247. cmd.Parameters.AddWithValue("CreatorID", prim.CreatorID.ToString());
  1248. cmd.Parameters.AddWithValue("OwnerID", prim.OwnerID.ToString());
  1249. cmd.Parameters.AddWithValue("GroupID", prim.GroupID.ToString());
  1250. cmd.Parameters.AddWithValue("LastOwnerID", prim.LastOwnerID.ToString());
  1251. cmd.Parameters.AddWithValue("OwnerMask", prim.OwnerMask);
  1252. cmd.Parameters.AddWithValue("NextOwnerMask", prim.NextOwnerMask);
  1253. cmd.Parameters.AddWithValue("GroupMask", prim.GroupMask);
  1254. cmd.Parameters.AddWithValue("EveryoneMask", prim.EveryoneMask);
  1255. cmd.Parameters.AddWithValue("BaseMask", prim.BaseMask);
  1256. // vectors
  1257. cmd.Parameters.AddWithValue("PositionX", (double)prim.OffsetPosition.X);
  1258. cmd.Parameters.AddWithValue("PositionY", (double)prim.OffsetPosition.Y);
  1259. cmd.Parameters.AddWithValue("PositionZ", (double)prim.OffsetPosition.Z);
  1260. cmd.Parameters.AddWithValue("GroupPositionX", (double)prim.GroupPosition.X);
  1261. cmd.Parameters.AddWithValue("GroupPositionY", (double)prim.GroupPosition.Y);
  1262. cmd.Parameters.AddWithValue("GroupPositionZ", (double)prim.GroupPosition.Z);
  1263. cmd.Parameters.AddWithValue("VelocityX", (double)prim.Velocity.X);
  1264. cmd.Parameters.AddWithValue("VelocityY", (double)prim.Velocity.Y);
  1265. cmd.Parameters.AddWithValue("VelocityZ", (double)prim.Velocity.Z);
  1266. cmd.Parameters.AddWithValue("AngularVelocityX", (double)prim.AngularVelocity.X);
  1267. cmd.Parameters.AddWithValue("AngularVelocityY", (double)prim.AngularVelocity.Y);
  1268. cmd.Parameters.AddWithValue("AngularVelocityZ", (double)prim.AngularVelocity.Z);
  1269. cmd.Parameters.AddWithValue("AccelerationX", (double)prim.Acceleration.X);
  1270. cmd.Parameters.AddWithValue("AccelerationY", (double)prim.Acceleration.Y);
  1271. cmd.Parameters.AddWithValue("AccelerationZ", (double)prim.Acceleration.Z);
  1272. // quaternions
  1273. cmd.Parameters.AddWithValue("RotationX", (double)prim.RotationOffset.X);
  1274. cmd.Parameters.AddWithValue("RotationY", (double)prim.RotationOffset.Y);
  1275. cmd.Parameters.AddWithValue("RotationZ", (double)prim.RotationOffset.Z);
  1276. cmd.Parameters.AddWithValue("RotationW", (double)prim.RotationOffset.W);
  1277. // Sit target
  1278. Vector3 sitTargetPos = prim.SitTargetPositionLL;
  1279. cmd.Parameters.AddWithValue("SitTargetOffsetX", (double)sitTargetPos.X);
  1280. cmd.Parameters.AddWithValue("SitTargetOffsetY", (double)sitTargetPos.Y);
  1281. cmd.Parameters.AddWithValue("SitTargetOffsetZ", (double)sitTargetPos.Z);
  1282. Quaternion sitTargetOrient = prim.SitTargetOrientationLL;
  1283. cmd.Parameters.AddWithValue("SitTargetOrientW", (double)sitTargetOrient.W);
  1284. cmd.Parameters.AddWithValue("SitTargetOrientX", (double)sitTargetOrient.X);
  1285. cmd.Parameters.AddWithValue("SitTargetOrientY", (double)sitTargetOrient.Y);
  1286. cmd.Parameters.AddWithValue("SitTargetOrientZ", (double)sitTargetOrient.Z);
  1287. cmd.Parameters.AddWithValue("PayPrice", prim.PayPrice[0]);
  1288. cmd.Parameters.AddWithValue("PayButton1", prim.PayPrice[1]);
  1289. cmd.Parameters.AddWithValue("PayButton2", prim.PayPrice[2]);
  1290. cmd.Parameters.AddWithValue("PayButton3", prim.PayPrice[3]);
  1291. cmd.Parameters.AddWithValue("PayButton4", prim.PayPrice[4]);
  1292. if ((prim.SoundFlags & 1) != 0) // Looped
  1293. {
  1294. cmd.Parameters.AddWithValue("LoopedSound", prim.Sound.ToString());
  1295. cmd.Parameters.AddWithValue("LoopedSoundGain", prim.SoundGain);
  1296. }
  1297. else
  1298. {
  1299. cmd.Parameters.AddWithValue("LoopedSound", UUID.Zero);
  1300. cmd.Parameters.AddWithValue("LoopedSoundGain", 0.0f);
  1301. }
  1302. cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation);
  1303. cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem);
  1304. cmd.Parameters.AddWithValue("OmegaX", (double)prim.AngularVelocity.X);
  1305. cmd.Parameters.AddWithValue("OmegaY", (double)prim.AngularVelocity.Y);
  1306. cmd.Parameters.AddWithValue("OmegaZ", (double)prim.AngularVelocity.Z);
  1307. cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X);
  1308. cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y);
  1309. cmd.Parameters.AddWithValue("CameraEyeOffsetZ", (double)prim.GetCameraEyeOffset().Z);
  1310. cmd.Parameters.AddWithValue("CameraAtOffsetX", (double)prim.GetCameraAtOffset().X);
  1311. cmd.Parameters.AddWithValue("CameraAtOffsetY", (double)prim.GetCameraAtOffset().Y);
  1312. cmd.Parameters.AddWithValue("CameraAtOffsetZ", (double)prim.GetCameraAtOffset().Z);
  1313. if (prim.GetForceMouselook())
  1314. cmd.Parameters.AddWithValue("ForceMouselook", 1);
  1315. else
  1316. cmd.Parameters.AddWithValue("ForceMouselook", 0);
  1317. cmd.Parameters.AddWithValue("ScriptAccessPin", prim.ScriptAccessPin);
  1318. if (prim.AllowedDrop)
  1319. cmd.Parameters.AddWithValue("AllowedDrop", 1);
  1320. else
  1321. cmd.Parameters.AddWithValue("AllowedDrop", 0);
  1322. if (prim.DIE_AT_EDGE)
  1323. cmd.Parameters.AddWithValue("DieAtEdge", 1);
  1324. else
  1325. cmd.Parameters.AddWithValue("DieAtEdge", 0);
  1326. cmd.Parameters.AddWithValue("SalePrice", prim.SalePrice);
  1327. cmd.Parameters.AddWithValue("SaleType", unchecked((sbyte)(prim.ObjectSaleType)));
  1328. byte clickAction = prim.ClickAction;
  1329. cmd.Parameters.AddWithValue("ClickAction", unchecked((sbyte)(clickAction)));
  1330. cmd.Parameters.AddWithValue("Material", unchecked((sbyte)(prim.Material)));
  1331. cmd.Parameters.AddWithValue("CollisionSound", prim.CollisionSound.ToString());
  1332. cmd.Parameters.AddWithValue("CollisionSoundVolume", prim.CollisionSoundVolume);
  1333. if (prim.PassTouches)
  1334. cmd.Parameters.AddWithValue("PassTouches", 1);
  1335. else
  1336. cmd.Parameters.AddWithValue("PassTouches", 0);
  1337. cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
  1338. }
  1339. /// <summary>
  1340. ///
  1341. /// </summary>
  1342. /// <param name="row"></param>
  1343. /// <param name="taskItem"></param>
  1344. private static void FillItemCommand(MySqlCommand cmd, TaskInventoryItem taskItem)
  1345. {
  1346. cmd.Parameters.AddWithValue("itemID", taskItem.ItemID);
  1347. cmd.Parameters.AddWithValue("primID", taskItem.ParentPartID);
  1348. cmd.Parameters.AddWithValue("assetID", taskItem.AssetID);
  1349. cmd.Parameters.AddWithValue("parentFolderID", taskItem.ParentID);
  1350. cmd.Parameters.AddWithValue("invType", taskItem.InvType);
  1351. cmd.Parameters.AddWithValue("assetType", taskItem.Type);
  1352. cmd.Parameters.AddWithValue("name", taskItem.Name);
  1353. cmd.Parameters.AddWithValue("description", taskItem.Description);
  1354. cmd.Parameters.AddWithValue("creationDate", taskItem.CreationDate);
  1355. cmd.Parameters.AddWithValue("creatorID", taskItem.CreatorID);
  1356. cmd.Parameters.AddWithValue("ownerID", taskItem.OwnerID);
  1357. cmd.Parameters.AddWithValue("lastOwnerID", taskItem.LastOwnerID);
  1358. cmd.Parameters.AddWithValue("groupID", taskItem.GroupID);
  1359. cmd.Parameters.AddWithValue("nextPermissions", taskItem.NextPermissions);
  1360. cmd.Parameters.AddWithValue("currentPermissions", taskItem.CurrentPermissions);
  1361. cmd.Parameters.AddWithValue("basePermissions", taskItem.BasePermissions);
  1362. cmd.Parameters.AddWithValue("everyonePermissions", taskItem.EveryonePermissions);
  1363. cmd.Parameters.AddWithValue("groupPermissions", taskItem.GroupPermissions);
  1364. cmd.Parameters.AddWithValue("flags", taskItem.Flags);
  1365. }
  1366. /// <summary>
  1367. ///
  1368. /// </summary>
  1369. private static void FillRegionSettingsCommand(MySqlCommand cmd, RegionSettings settings)
  1370. {
  1371. cmd.Parameters.AddWithValue("RegionUUID", settings.RegionUUID.ToString());
  1372. cmd.Parameters.AddWithValue("BlockTerraform", settings.BlockTerraform);
  1373. cmd.Parameters.AddWithValue("BlockFly", settings.BlockFly);
  1374. cmd.Parameters.AddWithValue("AllowDamage", settings.AllowDamage);
  1375. cmd.Parameters.AddWithValue("RestrictPushing", settings.RestrictPushing);
  1376. cmd.Parameters.AddWithValue("AllowLandResell", settings.AllowLandResell);
  1377. cmd.Parameters.AddWithValue("AllowLandJoinDivide", settings.AllowLandJoinDivide);
  1378. cmd.Parameters.AddWithValue("BlockShowInSearch", settings.BlockShowInSearch);
  1379. cmd.Parameters.AddWithValue("AgentLimit", settings.AgentLimit);
  1380. cmd.Parameters.AddWithValue("ObjectBonus", settings.ObjectBonus);
  1381. cmd.Parameters.AddWithValue("Maturity", settings.Maturity);
  1382. cmd.Parameters.AddWithValue("DisableScripts", settings.DisableScripts);
  1383. cmd.Parameters.AddWithValue("DisableCollisions", settings.DisableCollisions);
  1384. cmd.Parameters.AddWithValue("DisablePhysics", settings.DisablePhysics);
  1385. cmd.Parameters.AddWithValue("TerrainTexture1", settings.TerrainTexture1.ToString());
  1386. cmd.Parameters.AddWithValue("TerrainTexture2", settings.TerrainTexture2.ToString());
  1387. cmd.Parameters.AddWithValue("TerrainTexture3", settings.TerrainTexture3.ToString());
  1388. cmd.Parameters.AddWithValue("TerrainTexture4", settings.TerrainTexture4.ToString());
  1389. cmd.Parameters.AddWithValue("Elevation1NW", settings.Elevation1NW);
  1390. cmd.Parameters.AddWithValue("Elevation2NW", settings.Elevation2NW);
  1391. cmd.Parameters.AddWithValue("Elevation1NE", settings.Elevation1NE);
  1392. cmd.Parameters.AddWithValue("Elevation2NE", settings.Elevation2NE);
  1393. cmd.Parameters.AddWithValue("Elevation1SE", settings.Elevation1SE);
  1394. cmd.Parameters.AddWithValue("Elevation2SE", settings.Elevation2SE);
  1395. cmd.Parameters.AddWithValue("Elevation1SW", settings.Elevation1SW);
  1396. cmd.Parameters.AddWithValue("Elevation2SW", settings.Elevation2SW);
  1397. cmd.Parameters.AddWithValue("WaterHeight", settings.WaterHeight);
  1398. cmd.Parameters.AddWithValue("TerrainRaiseLimit", settings.TerrainRaiseLimit);
  1399. cmd.Parameters.AddWithValue("TerrainLowerLimit", settings.TerrainLowerLimit);
  1400. cmd.Parameters.AddWithValue("UseEstateSun", settings.UseEstateSun);
  1401. cmd.Parameters.AddWithValue("Sandbox", settings.Sandbox);
  1402. cmd.Parameters.AddWithValue("SunVectorX", settings.SunVector.X);
  1403. cmd.Parameters.AddWithValue("SunVectorY", settings.SunVector.Y);
  1404. cmd.Parameters.AddWithValue("SunVectorZ", settings.SunVector.Z);
  1405. cmd.Parameters.AddWithValue("FixedSun", settings.FixedSun);
  1406. cmd.Parameters.AddWithValue("SunPosition", settings.SunPosition);
  1407. cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString());
  1408. cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
  1409. cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
  1410. cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
  1411. }
  1412. /// <summary>
  1413. ///
  1414. /// </summary>
  1415. /// <param name="row"></param>
  1416. /// <param name="land"></param>
  1417. /// <param name="regionUUID"></param>
  1418. private static void FillLandCommand(MySqlCommand cmd, LandData land, UUID regionUUID)
  1419. {
  1420. cmd.Parameters.AddWithValue("UUID", land.GlobalID.ToString());
  1421. cmd.Parameters.AddWithValue("RegionUUID", regionUUID.ToString());
  1422. cmd.Parameters.AddWithValue("LocalLandID", land.LocalID);
  1423. // Bitmap is a byte[512]
  1424. cmd.Parameters.AddWithValue("Bitmap", land.Bitmap);
  1425. cmd.Parameters.AddWithValue("Name", land.Name);
  1426. cmd.Parameters.AddWithValue("Description", land.Description);
  1427. cmd.Parameters.AddWithValue("OwnerUUID", land.OwnerID.ToString());
  1428. cmd.Parameters.AddWithValue("IsGroupOwned", land.IsGroupOwned);
  1429. cmd.Parameters.AddWithValue("Area", land.Area);
  1430. cmd.Parameters.AddWithValue("AuctionID", land.AuctionID); //Unemplemented
  1431. cmd.Parameters.AddWithValue("Category", land.Category); //Enum libsecondlife.Parcel.ParcelCategory
  1432. cmd.Parameters.AddWithValue("ClaimDate", land.ClaimDate);
  1433. cmd.Parameters.AddWithValue("ClaimPrice", land.ClaimPrice);
  1434. cmd.Parameters.AddWithValue("GroupUUID", land.GroupID.ToString());
  1435. cmd.Parameters.AddWithValue("SalePrice", land.SalePrice);
  1436. cmd.Parameters.AddWithValue("LandStatus", land.Status); //Enum. libsecondlife.Parcel.ParcelStatus
  1437. cmd.Parameters.AddWithValue("LandFlags", land.Flags);
  1438. cmd.Parameters.AddWithValue("LandingType", land.LandingType);
  1439. cmd.Parameters.AddWithValue("MediaAutoScale", land.MediaAutoScale);
  1440. cmd.Parameters.AddWithValue("MediaTextureUUID", land.MediaID.ToString());
  1441. cmd.Parameters.AddWithValue("MediaURL", land.MediaURL);
  1442. cmd.Parameters.AddWithValue("MusicURL", land.MusicURL);
  1443. cmd.Parameters.AddWithValue("PassHours", land.PassHours);
  1444. cmd.Parameters.AddWithValue("PassPrice", land.PassPrice);
  1445. cmd.Parameters.AddWithValue("SnapshotUUID", land.SnapshotID.ToString());
  1446. cmd.Parameters.AddWithValue("UserLocationX", land.UserLocation.X);
  1447. cmd.Parameters.AddWithValue("UserLocationY", land.UserLocation.Y);
  1448. cmd.Parameters.AddWithValue("UserLocationZ", land.UserLocation.Z);
  1449. cmd.Parameters.AddWithValue("UserLookAtX", land.UserLookAt.X);
  1450. cmd.Parameters.AddWithValue("UserLookAtY", land.UserLookAt.Y);
  1451. cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z);
  1452. cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID);
  1453. cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime);
  1454. cmd.Parameters.AddWithValue("Dwell", land.Dwell);
  1455. }
  1456. /// <summary>
  1457. ///
  1458. /// </summary>
  1459. /// <param name="row"></param>
  1460. /// <param name="entry"></param>
  1461. /// <param name="parcelID"></param>
  1462. private static void FillLandAccessCommand(MySqlCommand cmd, ParcelManager.ParcelAccessEntry entry, UUID parcelID)
  1463. {
  1464. cmd.Parameters.AddWithValue("LandUUID", parcelID.ToString());
  1465. cmd.Parameters.AddWithValue("AccessUUID", entry.AgentID.ToString());
  1466. cmd.Parameters.AddWithValue("Flags", entry.Flags);
  1467. }
  1468. /// <summary>
  1469. ///
  1470. /// </summary>
  1471. /// <param name="row"></param>
  1472. /// <returns></returns>
  1473. private PrimitiveBaseShape BuildShape(IDataReader row)
  1474. {
  1475. PrimitiveBaseShape s = new PrimitiveBaseShape();
  1476. s.Scale = new Vector3(
  1477. (float)(double)row["ScaleX"],
  1478. (float)(double)row["ScaleY"],
  1479. (float)(double)row["ScaleZ"]
  1480. );
  1481. // paths
  1482. s.PCode = (byte)(int)row["PCode"];
  1483. s.PathBegin = (ushort)(int)row["PathBegin"];
  1484. s.PathEnd = (ushort)(int)row["PathEnd"];
  1485. s.PathScaleX = (byte)(int)row["PathScaleX"];
  1486. s.PathScaleY = (byte)(int)row["PathScaleY"];
  1487. s.PathShearX = (byte)(int)row["PathShearX"];
  1488. s.PathShearY = (byte)(int)row["PathShearY"];
  1489. s.PathSkew = (sbyte)(int)row["PathSkew"];
  1490. s.PathCurve = (byte)(int)row["PathCurve"];
  1491. s.PathRadiusOffset = (sbyte)(int)row["PathRadiusOffset"];
  1492. s.PathRevolutions = (byte)(int)row["PathRevolutions"];
  1493. s.PathTaperX = (sbyte)(int)row["PathTaperX"];
  1494. s.PathTaperY = (sbyte)(int)row["PathTaperY"];
  1495. s.PathTwist = (sbyte)(int)row["PathTwist"];
  1496. s.PathTwistBegin = (sbyte)(int)row["PathTwistBegin"];
  1497. // profile
  1498. s.ProfileBegin = (ushort)(int)row["ProfileBegin"];
  1499. s.ProfileEnd = (ushort)(int)row["ProfileEnd"];
  1500. s.ProfileCurve = (byte)(int)row["ProfileCurve"];
  1501. s.ProfileHollow = (ushort)(int)row["ProfileHollow"];
  1502. s.TextureEntry = (byte[])row["Texture"];
  1503. s.ExtraParams = (byte[])row["ExtraParams"];
  1504. s.State = (byte)(int)row["State"];
  1505. return s;
  1506. }
  1507. /// <summary>
  1508. ///
  1509. /// </summary>
  1510. /// <param name="row"></param>
  1511. /// <param name="prim"></param>
  1512. private void FillShapeCommand(MySqlCommand cmd, SceneObjectPart prim)
  1513. {
  1514. PrimitiveBaseShape s = prim.Shape;
  1515. cmd.Parameters.AddWithValue("UUID", prim.UUID.ToString());
  1516. // shape is an enum
  1517. cmd.Parameters.AddWithValue("Shape", 0);
  1518. // vectors
  1519. cmd.Parameters.AddWithValue("ScaleX", (double)s.Scale.X);
  1520. cmd.Parameters.AddWithValue("ScaleY", (double)s.Scale.Y);
  1521. cmd.Parameters.AddWithValue("ScaleZ", (double)s.Scale.Z);
  1522. // paths
  1523. cmd.Parameters.AddWithValue("PCode", s.PCode);
  1524. cmd.Parameters.AddWithValue("PathBegin", s.PathBegin);
  1525. cmd.Parameters.AddWithValue("PathEnd", s.PathEnd);
  1526. cmd.Parameters.AddWithValue("PathScaleX", s.PathScaleX);
  1527. cmd.Parameters.AddWithValue("PathScaleY", s.PathScaleY);
  1528. cmd.Parameters.AddWithValue("PathShearX", s.PathShearX);
  1529. cmd.Parameters.AddWithValue("PathShearY", s.PathShearY);
  1530. cmd.Parameters.AddWithValue("PathSkew", s.PathSkew);
  1531. cmd.Parameters.AddWithValue("PathCurve", s.PathCurve);
  1532. cmd.Parameters.AddWithValue("PathRadiusOffset", s.PathRadiusOffset);
  1533. cmd.Parameters.AddWithValue("PathRevolutions", s.PathRevolutions);
  1534. cmd.Parameters.AddWithValue("PathTaperX", s.PathTaperX);
  1535. cmd.Parameters.AddWithValue("PathTaperY", s.PathTaperY);
  1536. cmd.Parameters.AddWithValue("PathTwist", s.PathTwist);
  1537. cmd.Parameters.AddWithValue("PathTwistBegin", s.PathTwistBegin);
  1538. // profile
  1539. cmd.Parameters.AddWithValue("ProfileBegin", s.ProfileBegin);
  1540. cmd.Parameters.AddWithValue("ProfileEnd", s.ProfileEnd);
  1541. cmd.Parameters.AddWithValue("ProfileCurve", s.ProfileCurve);
  1542. cmd.Parameters.AddWithValue("ProfileHollow", s.ProfileHollow);
  1543. cmd.Parameters.AddWithValue("Texture", s.TextureEntry);
  1544. cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams);
  1545. cmd.Parameters.AddWithValue("State", s.State);
  1546. }
  1547. public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
  1548. {
  1549. lock (m_dbLock)
  1550. {
  1551. RemoveItems(primID);
  1552. using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
  1553. {
  1554. dbcon.Open();
  1555. MySqlCommand cmd = dbcon.CreateCommand();
  1556. if (items.Count == 0)
  1557. return;
  1558. cmd.CommandText = "insert into primitems (" +
  1559. "invType, assetType, name, " +
  1560. "description, creationDate, nextPermissions, " +
  1561. "currentPermissions, basePermissions, " +
  1562. "everyonePermissions, groupPermissions, " +
  1563. "flags, itemID, primID, assetID, " +
  1564. "parentFolderID, creatorID, ownerID, " +
  1565. "groupID, lastOwnerID) values (?invType, " +
  1566. "?assetType, ?name, ?description, " +
  1567. "?creationDate, ?nextPermissions, " +
  1568. "?currentPermissions, ?basePermissions, " +
  1569. "?everyonePermissions, ?groupPermissions, " +
  1570. "?flags, ?itemID, ?primID, ?assetID, " +
  1571. "?parentFolderID, ?creatorID, ?ownerID, " +
  1572. "?groupID, ?lastOwnerID)";
  1573. foreach (TaskInventoryItem item in items)
  1574. {
  1575. cmd.Parameters.Clear();
  1576. FillItemCommand(cmd, item);
  1577. ExecuteNonQuery(cmd);
  1578. }
  1579. cmd.Dispose();
  1580. }
  1581. }
  1582. }
  1583. }
  1584. }