PGSQLSimulationData.cs 132 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397
  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 OpenMetaverse;
  36. using OpenSim.Framework;
  37. using OpenSim.Region.Framework.Interfaces;
  38. using OpenSim.Region.Framework.Scenes;
  39. using OpenSim.Data;
  40. using Npgsql;
  41. namespace OpenSim.Data.PGSQL
  42. {
  43. /// <summary>
  44. /// A PGSQL Interface for the Region Server.
  45. /// </summary>
  46. public class PGSQLSimulationData : ISimulationDataStore
  47. {
  48. private const string _migrationStore = "RegionStore";
  49. private const string LogHeader = "[REGION DB PGSQL]";
  50. // private static FileSystemDataStore Instance = new FileSystemDataStore();
  51. private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  52. /// <summary>
  53. /// The database manager
  54. /// </summary>
  55. private PGSQLManager _Database;
  56. private string m_connectionString;
  57. protected virtual Assembly Assembly
  58. {
  59. get { return GetType().Assembly; }
  60. }
  61. public PGSQLSimulationData()
  62. {
  63. }
  64. public PGSQLSimulationData(string connectionString)
  65. {
  66. Initialise(connectionString);
  67. }
  68. /// <summary>
  69. /// Initialises the region datastore
  70. /// </summary>
  71. /// <param name="connectionString">The connection string.</param>
  72. public void Initialise(string connectionString)
  73. {
  74. m_connectionString = connectionString;
  75. _Database = new PGSQLManager(connectionString);
  76. using (NpgsqlConnection conn = new NpgsqlConnection(connectionString))
  77. {
  78. conn.Open();
  79. //New Migration settings
  80. Migration m = new Migration(conn, Assembly, "RegionStore");
  81. m.Update();
  82. }
  83. }
  84. /// <summary>
  85. /// Dispose the database
  86. /// </summary>
  87. public void Dispose() { }
  88. #region SceneObjectGroup region for loading and Store of the scene.
  89. /// <summary>
  90. /// Loads the objects present in the region.
  91. /// </summary>
  92. /// <param name="regionUUID">The region UUID.</param>
  93. /// <returns></returns>
  94. public List<SceneObjectGroup> LoadObjects(UUID regionUUID)
  95. {
  96. UUID lastGroupID = UUID.Zero;
  97. Dictionary<UUID, SceneObjectPart> prims = new Dictionary<UUID, SceneObjectPart>();
  98. Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>();
  99. SceneObjectGroup grp = null;
  100. string sql = @"SELECT *,
  101. CASE WHEN prims.""UUID"" = prims.""SceneGroupID"" THEN 0 ELSE 1 END as sort
  102. FROM prims
  103. LEFT JOIN primshapes ON prims.""UUID"" = primshapes.""UUID""
  104. WHERE ""RegionUUID"" = :RegionUUID
  105. ORDER BY ""SceneGroupID"" asc, sort asc, ""LinkNumber"" asc";
  106. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  107. using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
  108. {
  109. command.Parameters.Add(_Database.CreateParameter("regionUUID", regionUUID));
  110. conn.Open();
  111. using (NpgsqlDataReader reader = command.ExecuteReader())
  112. {
  113. while (reader.Read())
  114. {
  115. SceneObjectPart sceneObjectPart = BuildPrim(reader);
  116. if (reader["Shape"] is DBNull)
  117. sceneObjectPart.Shape = PrimitiveBaseShape.Default;
  118. else
  119. sceneObjectPart.Shape = BuildShape(reader);
  120. prims[sceneObjectPart.UUID] = sceneObjectPart;
  121. UUID groupID = new UUID((Guid)reader["SceneGroupID"]);
  122. if (groupID != lastGroupID) // New SOG
  123. {
  124. if (grp != null)
  125. objects[grp.UUID] = grp;
  126. lastGroupID = groupID;
  127. // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are
  128. // recorded as the root prim (for which the UUID must equal the persisted group UUID). In
  129. // this case, force the UUID to be the same as the group UUID so that at least these can be
  130. // deleted (we need to change the UUID so that any other prims in the linkset can also be
  131. // deleted).
  132. if (sceneObjectPart.UUID != groupID && groupID != UUID.Zero)
  133. {
  134. _Log.WarnFormat(
  135. "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID",
  136. sceneObjectPart.Name, sceneObjectPart.UUID, sceneObjectPart.GroupPosition, groupID);
  137. sceneObjectPart.UUID = groupID;
  138. }
  139. grp = new SceneObjectGroup(sceneObjectPart);
  140. }
  141. else
  142. {
  143. // Black magic to preserve link numbers
  144. // Why is this needed, fix this in AddPart method.
  145. int link = sceneObjectPart.LinkNum;
  146. grp.AddPart(sceneObjectPart);
  147. if (link != 0)
  148. sceneObjectPart.LinkNum = link;
  149. }
  150. }
  151. }
  152. }
  153. if (grp != null)
  154. objects[grp.UUID] = grp;
  155. // Instead of attempting to LoadItems on every prim,
  156. // most of which probably have no items... get a
  157. // list from DB of all prims which have items and
  158. // LoadItems only on those
  159. List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>();
  160. string qry = "select distinct \"primID\" from primitems";
  161. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  162. using (NpgsqlCommand command = new NpgsqlCommand(qry, conn))
  163. {
  164. conn.Open();
  165. using (NpgsqlDataReader itemReader = command.ExecuteReader())
  166. {
  167. while (itemReader.Read())
  168. {
  169. if (!(itemReader["primID"] is DBNull))
  170. {
  171. UUID primID = new UUID(itemReader["primID"].ToString());
  172. if (prims.ContainsKey(primID))
  173. {
  174. primsWithInventory.Add(prims[primID]);
  175. }
  176. }
  177. }
  178. }
  179. }
  180. LoadItems(primsWithInventory);
  181. _Log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count);
  182. return new List<SceneObjectGroup>(objects.Values);
  183. }
  184. /// <summary>
  185. /// Load in the prim's persisted inventory.
  186. /// </summary>
  187. /// <param name="allPrims">all prims with inventory on a region</param>
  188. private void LoadItems(List<SceneObjectPart> allPrimsWithInventory)
  189. {
  190. string sql = @"SELECT * FROM primitems WHERE ""primID"" = :PrimID";
  191. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  192. using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
  193. {
  194. conn.Open();
  195. foreach (SceneObjectPart objectPart in allPrimsWithInventory)
  196. {
  197. command.Parameters.Clear();
  198. command.Parameters.Add(_Database.CreateParameter("PrimID", objectPart.UUID));
  199. List<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
  200. using (NpgsqlDataReader reader = command.ExecuteReader())
  201. {
  202. while (reader.Read())
  203. {
  204. TaskInventoryItem item = BuildItem(reader);
  205. item.ParentID = objectPart.UUID; // Values in database are
  206. // often wrong
  207. inventory.Add(item);
  208. }
  209. }
  210. objectPart.Inventory.RestoreInventoryItems(inventory);
  211. }
  212. }
  213. }
  214. /// <summary>
  215. /// Stores all object's details apart from inventory
  216. /// </summary>
  217. /// <param name="obj"></param>
  218. /// <param name="regionUUID"></param>
  219. public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
  220. {
  221. uint flags = obj.RootPart.GetEffectiveObjectFlags();
  222. // Eligibility check
  223. //
  224. if ((flags & (uint)PrimFlags.Temporary) != 0)
  225. return;
  226. if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
  227. return;
  228. //_Log.DebugFormat("[PGSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Parts.Length);
  229. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  230. {
  231. conn.Open();
  232. NpgsqlTransaction transaction = conn.BeginTransaction();
  233. try
  234. {
  235. foreach (SceneObjectPart sceneObjectPart in obj.Parts)
  236. {
  237. //Update prim
  238. using (NpgsqlCommand sqlCommand = conn.CreateCommand())
  239. {
  240. sqlCommand.Transaction = transaction;
  241. try
  242. {
  243. StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
  244. }
  245. catch (NpgsqlException sqlEx)
  246. {
  247. _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.Line);
  248. throw;
  249. }
  250. }
  251. //Update primshapes
  252. using (NpgsqlCommand sqlCommand = conn.CreateCommand())
  253. {
  254. sqlCommand.Transaction = transaction;
  255. try
  256. {
  257. StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID);
  258. }
  259. catch (NpgsqlException sqlEx)
  260. {
  261. _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.Line);
  262. throw;
  263. }
  264. }
  265. }
  266. transaction.Commit();
  267. }
  268. catch (Exception ex)
  269. {
  270. _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message);
  271. try
  272. {
  273. transaction.Rollback();
  274. }
  275. catch (Exception ex2)
  276. {
  277. //Show error
  278. _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message);
  279. }
  280. }
  281. }
  282. }
  283. /// <summary>
  284. /// Stores the prim of the sceneobjectpart.
  285. /// </summary>
  286. /// <param name="sceneObjectPart">The sceneobjectpart or prim.</param>
  287. /// <param name="sqlCommand">The SQL command with the transaction.</param>
  288. /// <param name="sceneGroupID">The scenegroup UUID.</param>
  289. /// <param name="regionUUID">The region UUID.</param>
  290. private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID)
  291. {
  292. //Big query to update or insert a new prim.
  293. string queryPrims = @"
  294. UPDATE prims SET
  295. ""CreationDate"" = :CreationDate, ""Name"" = :Name, ""Text"" = :Text, ""Description"" = :Description, ""SitName"" = :SitName,
  296. ""TouchName"" = :TouchName, ""ObjectFlags"" = :ObjectFlags, ""OwnerMask"" = :OwnerMask, ""NextOwnerMask"" = :NextOwnerMask, ""GroupMask"" = :GroupMask,
  297. ""EveryoneMask"" = :EveryoneMask, ""BaseMask"" = :BaseMask, ""PositionX"" = :PositionX, ""PositionY"" = :PositionY, ""PositionZ"" = :PositionZ,
  298. ""GroupPositionX"" = :GroupPositionX, ""GroupPositionY"" = :GroupPositionY, ""GroupPositionZ"" = :GroupPositionZ, ""VelocityX"" = :VelocityX,
  299. ""VelocityY"" = :VelocityY, ""VelocityZ"" = :VelocityZ, ""AngularVelocityX"" = :AngularVelocityX, ""AngularVelocityY"" = :AngularVelocityY,
  300. ""AngularVelocityZ"" = :AngularVelocityZ, ""AccelerationX"" = :AccelerationX, ""AccelerationY"" = :AccelerationY,
  301. ""AccelerationZ"" = :AccelerationZ, ""RotationX"" = :RotationX, ""RotationY"" = :RotationY, ""RotationZ"" = :RotationZ, ""RotationW"" = :RotationW,
  302. ""SitTargetOffsetX"" = :SitTargetOffsetX, ""SitTargetOffsetY"" = :SitTargetOffsetY, ""SitTargetOffsetZ"" = :SitTargetOffsetZ,
  303. ""SitTargetOrientW"" = :SitTargetOrientW, ""SitTargetOrientX"" = :SitTargetOrientX, ""SitTargetOrientY"" = :SitTargetOrientY,
  304. ""SitTargetOrientZ"" = :SitTargetOrientZ, ""RegionUUID"" = :RegionUUID, ""CreatorID"" = :CreatorID, ""OwnerID"" = :OwnerID, ""GroupID"" = :GroupID,
  305. ""LastOwnerID"" = :LastOwnerID, ""SceneGroupID"" = :SceneGroupID, ""PayPrice"" = :PayPrice, ""PayButton1"" = :PayButton1, ""PayButton2"" = :PayButton2,
  306. ""PayButton3"" = :PayButton3, ""PayButton4"" = :PayButton4, ""LoopedSound"" = :LoopedSound, ""LoopedSoundGain"" = :LoopedSoundGain,
  307. ""TextureAnimation"" = :TextureAnimation, ""OmegaX"" = :OmegaX, ""OmegaY"" = :OmegaY, ""OmegaZ"" = :OmegaZ, ""CameraEyeOffsetX"" = :CameraEyeOffsetX,
  308. ""CameraEyeOffsetY"" = :CameraEyeOffsetY, ""CameraEyeOffsetZ"" = :CameraEyeOffsetZ, ""CameraAtOffsetX"" = :CameraAtOffsetX,
  309. ""CameraAtOffsetY"" = :CameraAtOffsetY, ""CameraAtOffsetZ"" = :CameraAtOffsetZ, ""ForceMouselook"" = :ForceMouselook,
  310. ""ScriptAccessPin"" = :ScriptAccessPin, ""AllowedDrop"" = :AllowedDrop, ""DieAtEdge"" = :DieAtEdge, ""SalePrice"" = :SalePrice,
  311. ""PhysicsShapeType"" = :PhysicsShapeType, ""Density"" = :Density, ""GravityModifier"" = :GravityModifier, ""Friction"" = :Friction, ""Restitution"" = :Restitution,
  312. ""PassCollisions"" = :PassCollisions, ""RotationAxisLocks"" = :RotationAxisLocks, ""RezzerID"" = :RezzerID,
  313. ""ClickAction"" = :ClickAction, ""Material"" = :Material, ""CollisionSound"" = :CollisionSound, ""CollisionSoundVolume"" = :CollisionSoundVolume, ""PassTouches"" = :PassTouches,
  314. ""LinkNumber"" = :LinkNumber, ""MediaURL"" = :MediaURL, ""DynAttrs"" = :DynAttrs, ""Vehicle"" = :Vehicle,
  315. ""PhysInertia"" = :PhysInertia
  316. WHERE ""UUID"" = :UUID ;
  317. INSERT INTO
  318. prims (
  319. ""UUID"", ""CreationDate"", ""Name"", ""Text"", ""Description"", ""SitName"", ""TouchName"", ""ObjectFlags"", ""OwnerMask"", ""NextOwnerMask"", ""GroupMask"",
  320. ""EveryoneMask"", ""BaseMask"", ""PositionX"", ""PositionY"", ""PositionZ"", ""GroupPositionX"", ""GroupPositionY"", ""GroupPositionZ"", ""VelocityX"",
  321. ""VelocityY"", ""VelocityZ"", ""AngularVelocityX"", ""AngularVelocityY"", ""AngularVelocityZ"", ""AccelerationX"", ""AccelerationY"", ""AccelerationZ"",
  322. ""RotationX"", ""RotationY"", ""RotationZ"", ""RotationW"", ""SitTargetOffsetX"", ""SitTargetOffsetY"", ""SitTargetOffsetZ"", ""SitTargetOrientW"",
  323. ""SitTargetOrientX"", ""SitTargetOrientY"", ""SitTargetOrientZ"", ""RegionUUID"", ""CreatorID"", ""OwnerID"", ""GroupID"", ""LastOwnerID"", ""SceneGroupID"",
  324. ""PayPrice"", ""PayButton1"", ""PayButton2"", ""PayButton3"", ""PayButton4"", ""LoopedSound"", ""LoopedSoundGain"", ""TextureAnimation"", ""OmegaX"",
  325. ""OmegaY"", ""OmegaZ"", ""CameraEyeOffsetX"", ""CameraEyeOffsetY"", ""CameraEyeOffsetZ"", ""CameraAtOffsetX"", ""CameraAtOffsetY"", ""CameraAtOffsetZ"",
  326. ""ForceMouselook"", ""ScriptAccessPin"", ""AllowedDrop"", ""DieAtEdge"", ""SalePrice"", ""SaleType"", ""ColorR"", ""ColorG"", ""ColorB"", ""ColorA"",
  327. ""ParticleSystem"", ""ClickAction"", ""Material"", ""CollisionSound"", ""CollisionSoundVolume"", ""PassTouches"", ""LinkNumber"", ""MediaURL"", ""DynAttrs"",
  328. ""PhysicsShapeType"", ""Density"", ""GravityModifier"", ""Friction"", ""Restitution"", ""PassCollisions"", ""RotationAxisLocks"", ""RezzerID"" , ""Vehicle"", ""PhysInertia""
  329. ) Select
  330. :UUID, :CreationDate, :Name, :Text, :Description, :SitName, :TouchName, :ObjectFlags, :OwnerMask, :NextOwnerMask, :GroupMask,
  331. :EveryoneMask, :BaseMask, :PositionX, :PositionY, :PositionZ, :GroupPositionX, :GroupPositionY, :GroupPositionZ, :VelocityX,
  332. :VelocityY, :VelocityZ, :AngularVelocityX, :AngularVelocityY, :AngularVelocityZ, :AccelerationX, :AccelerationY, :AccelerationZ,
  333. :RotationX, :RotationY, :RotationZ, :RotationW, :SitTargetOffsetX, :SitTargetOffsetY, :SitTargetOffsetZ, :SitTargetOrientW,
  334. :SitTargetOrientX, :SitTargetOrientY, :SitTargetOrientZ, :RegionUUID, :CreatorID, :OwnerID, :GroupID, :LastOwnerID, :SceneGroupID,
  335. :PayPrice, :PayButton1, :PayButton2, :PayButton3, :PayButton4, :LoopedSound, :LoopedSoundGain, :TextureAnimation, :OmegaX,
  336. :OmegaY, :OmegaZ, :CameraEyeOffsetX, :CameraEyeOffsetY, :CameraEyeOffsetZ, :CameraAtOffsetX, :CameraAtOffsetY, :CameraAtOffsetZ,
  337. :ForceMouselook, :ScriptAccessPin, :AllowedDrop, :DieAtEdge, :SalePrice, :SaleType, :ColorR, :ColorG, :ColorB, :ColorA,
  338. :ParticleSystem, :ClickAction, :Material, :CollisionSound, :CollisionSoundVolume, :PassTouches, :LinkNumber, :MediaURL, :DynAttrs,
  339. :PhysicsShapeType, :Density, :GravityModifier, :Friction, :Restitution, :PassCollisions, :RotationAxisLocks, :RezzerID, :Vehicle, :PhysInertia
  340. where not EXISTS (SELECT ""UUID"" FROM prims WHERE ""UUID"" = :UUID);
  341. ";
  342. //Set commandtext.
  343. sqlCommand.CommandText = queryPrims;
  344. //Add parameters
  345. sqlCommand.Parameters.AddRange(CreatePrimParameters(sceneObjectPart, sceneGroupID, regionUUID));
  346. //Execute the query. If it fails then error is trapped in calling function
  347. sqlCommand.ExecuteNonQuery();
  348. }
  349. /// <summary>
  350. /// Stores the scene object prim shapes.
  351. /// </summary>
  352. /// <param name="sceneObjectPart">The sceneobjectpart containing prim shape.</param>
  353. /// <param name="sqlCommand">The SQL command with the transaction.</param>
  354. /// <param name="sceneGroupID">The scenegroup UUID.</param>
  355. /// <param name="regionUUID">The region UUID.</param>
  356. private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID)
  357. {
  358. //Big query to or insert or update primshapes
  359. string queryPrimShapes = @"
  360. UPDATE primshapes SET
  361. ""Shape"" = :Shape, ""ScaleX"" = :ScaleX, ""ScaleY"" = :ScaleY, ""ScaleZ"" = :ScaleZ, ""PCode"" = :PCode, ""PathBegin"" = :PathBegin,
  362. ""PathEnd"" = :PathEnd, ""PathScaleX"" = :PathScaleX, ""PathScaleY"" = :PathScaleY, ""PathShearX"" = :PathShearX, ""PathShearY"" = :PathShearY,
  363. ""PathSkew"" = :PathSkew, ""PathCurve"" = :PathCurve, ""PathRadiusOffset"" = :PathRadiusOffset, ""PathRevolutions"" = :PathRevolutions,
  364. ""PathTaperX"" = :PathTaperX, ""PathTaperY"" = :PathTaperY, ""PathTwist"" = :PathTwist, ""PathTwistBegin"" = :PathTwistBegin,
  365. ""ProfileBegin"" = :ProfileBegin, ""ProfileEnd"" = :ProfileEnd, ""ProfileCurve"" = :ProfileCurve, ""ProfileHollow"" = :ProfileHollow,
  366. ""Texture"" = :Texture, ""ExtraParams"" = :ExtraParams, ""State"" = :State, ""Media"" = :Media
  367. WHERE ""UUID"" = :UUID ;
  368. INSERT INTO
  369. primshapes (
  370. ""UUID"", ""Shape"", ""ScaleX"", ""ScaleY"", ""ScaleZ"", ""PCode"", ""PathBegin"", ""PathEnd"", ""PathScaleX"", ""PathScaleY"", ""PathShearX"", ""PathShearY"",
  371. ""PathSkew"", ""PathCurve"", ""PathRadiusOffset"", ""PathRevolutions"", ""PathTaperX"", ""PathTaperY"", ""PathTwist"", ""PathTwistBegin"", ""ProfileBegin"",
  372. ""ProfileEnd"", ""ProfileCurve"", ""ProfileHollow"", ""Texture"", ""ExtraParams"", ""State"", ""Media""
  373. )
  374. Select
  375. :UUID, :Shape, :ScaleX, :ScaleY, :ScaleZ, :PCode, :PathBegin, :PathEnd, :PathScaleX, :PathScaleY, :PathShearX, :PathShearY,
  376. :PathSkew, :PathCurve, :PathRadiusOffset, :PathRevolutions, :PathTaperX, :PathTaperY, :PathTwist, :PathTwistBegin, :ProfileBegin,
  377. :ProfileEnd, :ProfileCurve, :ProfileHollow, :Texture, :ExtraParams, :State, :Media
  378. where not EXISTS (SELECT ""UUID"" FROM primshapes WHERE ""UUID"" = :UUID);
  379. ";
  380. //Set commandtext.
  381. sqlCommand.CommandText = queryPrimShapes;
  382. //Add parameters
  383. sqlCommand.Parameters.AddRange(CreatePrimShapeParameters(sceneObjectPart, sceneGroupID, regionUUID));
  384. //Execute the query. If it fails then error is trapped in calling function
  385. sqlCommand.ExecuteNonQuery();
  386. }
  387. /// <summary>
  388. /// Removes a object from the database.
  389. /// Meaning removing it from tables Prims, PrimShapes and PrimItems
  390. /// </summary>
  391. /// <param name="objectID">id of scenegroup</param>
  392. /// <param name="regionUUID">regionUUID (is this used anyway</param>
  393. public void RemoveObject(UUID objectID, UUID regionUUID)
  394. {
  395. //_Log.InfoFormat("[PGSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID);
  396. //Remove from prims and primsitem table
  397. string sqlPrims = @"DELETE FROM PRIMS WHERE ""SceneGroupID"" = :objectID";
  398. string sqlPrimItems = @"DELETE FROM PRIMITEMS WHERE ""primID"" in (SELECT ""UUID"" FROM PRIMS WHERE ""SceneGroupID"" = :objectID)";
  399. string sqlPrimShapes = @"DELETE FROM PRIMSHAPES WHERE ""UUID"" in (SELECT ""UUID"" FROM PRIMS WHERE ""SceneGroupID"" = :objectID)";
  400. lock (_Database)
  401. {
  402. //Using the non transaction mode.
  403. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  404. using (NpgsqlCommand cmd = new NpgsqlCommand())
  405. {
  406. cmd.Connection = conn;
  407. cmd.CommandText = sqlPrimShapes;
  408. conn.Open();
  409. cmd.Parameters.Add(_Database.CreateParameter("objectID", objectID));
  410. cmd.ExecuteNonQuery();
  411. cmd.CommandText = sqlPrimItems;
  412. cmd.ExecuteNonQuery();
  413. cmd.CommandText = sqlPrims;
  414. cmd.ExecuteNonQuery();
  415. }
  416. }
  417. }
  418. /// <summary>
  419. /// Store the inventory of a prim. Warning deletes everything first and then adds all again.
  420. /// </summary>
  421. /// <param name="primID"></param>
  422. /// <param name="items"></param>
  423. public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items)
  424. {
  425. //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID);
  426. //Statement from PGSQL section!
  427. // For now, we're just going to crudely remove all the previous inventory items
  428. // no matter whether they have changed or not, and replace them with the current set.
  429. //Delete everything from PrimID
  430. //TODO add index on PrimID in DB, if not already exist
  431. string sql = @"delete from primitems where ""primID"" = :primID";
  432. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  433. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  434. {
  435. cmd.Parameters.Add(_Database.CreateParameter("primID", primID));
  436. conn.Open();
  437. cmd.ExecuteNonQuery();
  438. }
  439. sql =
  440. @"INSERT INTO primitems (
  441. ""itemID"",""primID"",""assetID"",""parentFolderID"",""invType"",""assetType"",""name"",""description"",""creationDate"",""creatorID"",""ownerID"",""lastOwnerID"",""groupID"",
  442. ""nextPermissions"",""currentPermissions"",""basePermissions"",""everyonePermissions"",""groupPermissions"",""flags"")
  443. VALUES (:itemID,:primID,:assetID,:parentFolderID,:invType,:assetType,:name,:description,:creationDate,:creatorID,:ownerID,
  444. :lastOwnerID,:groupID,:nextPermissions,:currentPermissions,:basePermissions,:everyonePermissions,:groupPermissions,:flags)";
  445. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  446. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  447. {
  448. conn.Open();
  449. foreach (TaskInventoryItem taskItem in items)
  450. {
  451. cmd.Parameters.AddRange(CreatePrimInventoryParameters(taskItem));
  452. cmd.ExecuteNonQuery();
  453. cmd.Parameters.Clear();
  454. }
  455. }
  456. }
  457. #endregion
  458. /// <summary>
  459. /// Loads the terrain map.
  460. /// </summary>
  461. /// <param name="regionID">regionID.</param>
  462. /// <returns></returns>
  463. public double[,] LoadTerrain(UUID regionID)
  464. {
  465. double[,] ret = null;
  466. TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
  467. if (terrData != null)
  468. ret = terrData.GetDoubles();
  469. return ret;
  470. }
  471. // Returns 'null' if region not found
  472. public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
  473. {
  474. TerrainData terrData = null;
  475. string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from terrain
  476. where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; ";
  477. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  478. {
  479. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  480. {
  481. // PGSqlParameter param = new PGSqlParameter();
  482. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
  483. conn.Open();
  484. using (NpgsqlDataReader reader = cmd.ExecuteReader())
  485. {
  486. int rev;
  487. if (reader.Read())
  488. {
  489. rev = Convert.ToInt32(reader["Revision"]);
  490. if ((reader["Heightfield"] != DBNull.Value))
  491. {
  492. byte[] blob = (byte[])reader["Heightfield"];
  493. terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
  494. }
  495. }
  496. else
  497. {
  498. _Log.Info("[REGION DB]: No terrain found for region");
  499. return null;
  500. }
  501. _Log.Info("[REGION DB]: Loaded terrain revision r" + rev);
  502. }
  503. }
  504. }
  505. return terrData;
  506. }
  507. public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
  508. {
  509. TerrainData terrData = null;
  510. string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from bakedterrain
  511. where ""RegionUUID"" = :RegionUUID; ";
  512. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  513. {
  514. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  515. {
  516. // PGSqlParameter param = new PGSqlParameter();
  517. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
  518. conn.Open();
  519. using (NpgsqlDataReader reader = cmd.ExecuteReader())
  520. {
  521. int rev;
  522. if (reader.Read())
  523. {
  524. rev = Convert.ToInt32(reader["Revision"]);
  525. if ((reader["Heightfield"] != DBNull.Value))
  526. {
  527. byte[] blob = (byte[])reader["Heightfield"];
  528. terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
  529. }
  530. }
  531. }
  532. }
  533. }
  534. return terrData;
  535. }
  536. // Legacy entry point for when terrain was always a 256x256 heightmap
  537. public void StoreTerrain(double[,] terrain, UUID regionID)
  538. {
  539. StoreTerrain(new TerrainData(terrain), regionID);
  540. }
  541. /// <summary>
  542. /// Stores the terrain map to DB.
  543. /// </summary>
  544. /// <param name="terrain">terrain map data.</param>
  545. /// <param name="regionID">regionID.</param>
  546. public void StoreTerrain(TerrainData terrData, UUID regionID)
  547. {
  548. //Delete old terrain map
  549. string sql = @"delete from terrain where ""RegionUUID""=:RegionUUID";
  550. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  551. {
  552. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  553. {
  554. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
  555. conn.Open();
  556. cmd.ExecuteNonQuery();
  557. _Log.InfoFormat("{0} Deleted terrain revision id = {1}", LogHeader, regionID);
  558. }
  559. }
  560. int terrainDBRevision;
  561. Array terrainDBblob;
  562. terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
  563. sql = @"insert into terrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)";
  564. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  565. {
  566. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  567. {
  568. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
  569. cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision));
  570. cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob));
  571. conn.Open();
  572. cmd.ExecuteNonQuery();
  573. _Log.InfoFormat("{0} Stored terrain id = {1}, terrainSize = <{2},{3}>",
  574. LogHeader, regionID, terrData.SizeX, terrData.SizeY);
  575. }
  576. }
  577. }
  578. /// <summary>
  579. /// Stores the baked terrain map to DB.
  580. /// </summary>
  581. /// <param name="terrain">terrain map data.</param>
  582. /// <param name="regionID">regionID.</param>
  583. public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
  584. {
  585. //Delete old terrain map
  586. string sql = @"delete from bakedterrain where ""RegionUUID""=:RegionUUID";
  587. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  588. {
  589. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  590. {
  591. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
  592. conn.Open();
  593. cmd.ExecuteNonQuery();
  594. _Log.InfoFormat("{0} Deleted bakedterrain id = {1}", LogHeader, regionID);
  595. }
  596. }
  597. int terrainDBRevision;
  598. Array terrainDBblob;
  599. terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
  600. sql = @"insert into bakedterrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)";
  601. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  602. {
  603. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  604. {
  605. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
  606. cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision));
  607. cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob));
  608. conn.Open();
  609. cmd.ExecuteNonQuery();
  610. _Log.InfoFormat("{0} Stored bakedterrain id = {1}, terrainSize = <{2},{3}>",
  611. LogHeader, regionID, terrData.SizeX, terrData.SizeY);
  612. }
  613. }
  614. }
  615. /// <summary>
  616. /// Loads all the land objects of a region.
  617. /// </summary>
  618. /// <param name="regionUUID">The region UUID.</param>
  619. /// <returns></returns>
  620. public List<LandData> LoadLandObjects(UUID regionUUID)
  621. {
  622. List<LandData> LandDataForRegion = new List<LandData>();
  623. string sql = @"select * from land where ""RegionUUID"" = :RegionUUID";
  624. //Retrieve all land data from region
  625. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  626. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  627. {
  628. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID));
  629. conn.Open();
  630. using (NpgsqlDataReader readerLandData = cmd.ExecuteReader())
  631. {
  632. while (readerLandData.Read())
  633. {
  634. LandDataForRegion.Add(BuildLandData(readerLandData));
  635. }
  636. }
  637. }
  638. //Retrieve all accesslist data for all landdata
  639. foreach (LandData LandData in LandDataForRegion)
  640. {
  641. sql = @"select * from landaccesslist where ""LandUUID"" = :LandUUID";
  642. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  643. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  644. {
  645. cmd.Parameters.Add(_Database.CreateParameter("LandUUID", LandData.GlobalID));
  646. conn.Open();
  647. using (NpgsqlDataReader readerAccessList = cmd.ExecuteReader())
  648. {
  649. while (readerAccessList.Read())
  650. {
  651. LandData.ParcelAccessList.Add(BuildLandAccessData(readerAccessList));
  652. }
  653. }
  654. }
  655. }
  656. //Return data
  657. return LandDataForRegion;
  658. }
  659. /// <summary>
  660. /// Stores land object with landaccess list.
  661. /// </summary>
  662. /// <param name="parcel">parcel data.</param>
  663. public void StoreLandObject(ILandObject parcel)
  664. {
  665. //As this is only one record in land table I just delete all and then add a new record.
  666. //As the delete landaccess is already in the pgsql code
  667. //Delete old values
  668. RemoveLandObject(parcel.LandData.GlobalID);
  669. //Insert new values
  670. string sql = @"INSERT INTO land
  671. (""UUID"",""RegionUUID"",""LocalLandID"",""Bitmap"",""Name"",""Description"",""OwnerUUID"",""IsGroupOwned"",""Area"",""AuctionID"",""Category"",""ClaimDate"",""ClaimPrice"",
  672. ""GroupUUID"",""SalePrice"",""LandStatus"",""LandFlags"",""LandingType"",""MediaAutoScale"",""MediaTextureUUID"",""MediaURL"",""MusicURL"",""PassHours"",""PassPrice"",
  673. ""SnapshotUUID"",""UserLocationX"",""UserLocationY"",""UserLocationZ"",""UserLookAtX"",""UserLookAtY"",""UserLookAtZ"",""AuthbuyerID"",""OtherCleanTime"",""Dwell"",
  674. ""MediaType"",""MediaDescription"",""MediaSize"",""MediaLoop"",""ObscureMusic"",""ObscureMedia"",""SeeAVs"",""AnyAVSounds"",""GroupAVSounds"")
  675. VALUES
  676. (:UUID,:RegionUUID,:LocalLandID,:Bitmap,:Name,:Description,:OwnerUUID,:IsGroupOwned,:Area,:AuctionID,:Category,:ClaimDate,:ClaimPrice,
  677. :GroupUUID,:SalePrice,:LandStatus,:LandFlags,:LandingType,:MediaAutoScale,:MediaTextureUUID,:MediaURL,:MusicURL,:PassHours,:PassPrice,
  678. :SnapshotUUID,:UserLocationX,:UserLocationY,:UserLocationZ,:UserLookAtX,:UserLookAtY,:UserLookAtZ,:AuthbuyerID,:OtherCleanTime,:Dwell,
  679. :MediaType,:MediaDescription,:MediaWidth::text || ',' || :MediaHeight::text,:MediaLoop,:ObscureMusic,:ObscureMedia,:SeeAVs::int::smallint,
  680. :AnyAVSounds::int::smallint,:GroupAVSounds::int::smallint)";
  681. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  682. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  683. {
  684. cmd.Parameters.AddRange(CreateLandParameters(parcel.LandData, parcel.RegionUUID));
  685. conn.Open();
  686. cmd.ExecuteNonQuery();
  687. }
  688. sql = @"INSERT INTO landaccesslist (""LandUUID"",""AccessUUID"",""LandFlags"",""Expires"") VALUES (:LandUUID,:AccessUUID,:Flags,:Expires)";
  689. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  690. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  691. {
  692. conn.Open();
  693. foreach (LandAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList)
  694. {
  695. cmd.Parameters.AddRange(CreateLandAccessParameters(parcelAccessEntry, parcel.RegionUUID));
  696. cmd.ExecuteNonQuery();
  697. cmd.Parameters.Clear();
  698. }
  699. }
  700. }
  701. /// <summary>
  702. /// Removes a land object from DB.
  703. /// </summary>
  704. /// <param name="globalID">UUID of landobject</param>
  705. public void RemoveLandObject(UUID globalID)
  706. {
  707. string sql = @"delete from land where ""UUID""=:UUID";
  708. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  709. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  710. {
  711. cmd.Parameters.Add(_Database.CreateParameter("UUID", globalID));
  712. conn.Open();
  713. cmd.ExecuteNonQuery();
  714. }
  715. sql = @"delete from landaccesslist where ""LandUUID""=:UUID";
  716. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  717. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  718. {
  719. cmd.Parameters.Add(_Database.CreateParameter("UUID", globalID));
  720. conn.Open();
  721. cmd.ExecuteNonQuery();
  722. }
  723. }
  724. public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
  725. {
  726. RegionLightShareData nWP = new RegionLightShareData();
  727. nWP.OnSave += StoreRegionWindlightSettings;
  728. string sql = @"select * from regionwindlight where ""region_id"" = :regionID";
  729. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  730. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  731. {
  732. cmd.Parameters.Add(_Database.CreateParameter("regionID", regionUUID.ToString() ));
  733. conn.Open();
  734. using (NpgsqlDataReader result = cmd.ExecuteReader())
  735. {
  736. if (!result.Read())
  737. {
  738. //No result, so store our default windlight profile and return it
  739. nWP.regionID = regionUUID;
  740. StoreRegionWindlightSettings(nWP);
  741. return nWP;
  742. }
  743. else
  744. {
  745. nWP.regionID = DBGuid.FromDB(result["region_id"]);
  746. nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
  747. nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
  748. nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
  749. nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
  750. nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
  751. nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
  752. nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
  753. nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
  754. nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
  755. nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
  756. nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
  757. nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
  758. nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
  759. nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
  760. nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
  761. nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
  762. nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
  763. UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
  764. nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
  765. nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
  766. nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
  767. nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
  768. nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
  769. nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
  770. nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
  771. nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
  772. nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
  773. nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
  774. nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
  775. nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
  776. nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
  777. nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
  778. nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
  779. nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
  780. nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
  781. nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
  782. nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
  783. nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
  784. nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
  785. nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
  786. nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
  787. nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
  788. nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
  789. nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
  790. nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
  791. nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
  792. nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
  793. nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
  794. nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
  795. nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
  796. nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
  797. nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
  798. nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
  799. nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
  800. nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
  801. nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
  802. nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
  803. nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
  804. nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
  805. nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
  806. nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
  807. nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
  808. nWP.valid = true;
  809. }
  810. }
  811. }
  812. return nWP;
  813. }
  814. public void RemoveRegionWindlightSettings(UUID regionID)
  815. {
  816. string sql = @"delete from regionwindlight where ""region_id"" = :region_id";
  817. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  818. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  819. {
  820. conn.Open();
  821. cmd.Parameters.Add(_Database.CreateParameter("region_id", regionID.ToString()));
  822. cmd.ExecuteNonQuery();
  823. }
  824. }
  825. public void StoreRegionWindlightSettings(RegionLightShareData wl)
  826. {
  827. string sql = @"select region_id from regionwindlight where ""region_id"" = :region_id limit 1;";
  828. bool exists = false;
  829. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  830. {
  831. conn.Open();
  832. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  833. {
  834. cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID.ToString() ));
  835. NpgsqlDataReader dr = cmd.ExecuteReader();
  836. exists = dr.Read();
  837. }
  838. }
  839. if (exists)
  840. {
  841. RemoveRegionWindlightSettings(wl.regionID);
  842. }
  843. // sql insert
  844. sql = @"INSERT INTO regionwindlight
  845. (region_id
  846. ,water_color_r
  847. ,water_color_g
  848. ,water_color_b
  849. ,water_fog_density_exponent
  850. ,underwater_fog_modifier
  851. ,reflection_wavelet_scale_1
  852. ,reflection_wavelet_scale_2
  853. ,reflection_wavelet_scale_3
  854. ,fresnel_scale
  855. ,fresnel_offset
  856. ,refract_scale_above
  857. ,refract_scale_below
  858. ,blur_multiplier
  859. ,big_wave_direction_x
  860. ,big_wave_direction_y
  861. ,little_wave_direction_x
  862. ,little_wave_direction_y
  863. ,normal_map_texture
  864. ,horizon_r
  865. ,horizon_g
  866. ,horizon_b
  867. ,horizon_i
  868. ,haze_horizon
  869. ,blue_density_r
  870. ,blue_density_g
  871. ,blue_density_b
  872. ,blue_density_i
  873. ,haze_density
  874. ,density_multiplier
  875. ,distance_multiplier
  876. ,max_altitude
  877. ,sun_moon_color_r
  878. ,sun_moon_color_g
  879. ,sun_moon_color_b
  880. ,sun_moon_color_i
  881. ,sun_moon_position
  882. ,ambient_r
  883. ,ambient_g
  884. ,ambient_b
  885. ,ambient_i
  886. ,east_angle
  887. ,sun_glow_focus
  888. ,sun_glow_size
  889. ,scene_gamma
  890. ,star_brightness
  891. ,cloud_color_r
  892. ,cloud_color_g
  893. ,cloud_color_b
  894. ,cloud_color_i
  895. ,cloud_x
  896. ,cloud_y
  897. ,cloud_density
  898. ,cloud_coverage
  899. ,cloud_scale
  900. ,cloud_detail_x
  901. ,cloud_detail_y
  902. ,cloud_detail_density
  903. ,cloud_scroll_x
  904. ,cloud_scroll_x_lock
  905. ,cloud_scroll_y
  906. ,cloud_scroll_y_lock
  907. ,draw_classic_clouds)
  908. VALUES
  909. (:region_id
  910. ,:water_color_r
  911. ,:water_color_g
  912. ,:water_color_b
  913. ,:water_fog_density_exponent
  914. ,:underwater_fog_modifier
  915. ,:reflection_wavelet_scale_1
  916. ,:reflection_wavelet_scale_2
  917. ,:reflection_wavelet_scale_3
  918. ,:fresnel_scale
  919. ,:fresnel_offset
  920. ,:refract_scale_above
  921. ,:refract_scale_below
  922. ,:blur_multiplier
  923. ,:big_wave_direction_x
  924. ,:big_wave_direction_y
  925. ,:little_wave_direction_x
  926. ,:little_wave_direction_y
  927. ,:normal_map_texture
  928. ,:horizon_r
  929. ,:horizon_g
  930. ,:horizon_b
  931. ,:horizon_i
  932. ,:haze_horizon
  933. ,:blue_density_r
  934. ,:blue_density_g
  935. ,:blue_density_b
  936. ,:blue_density_i
  937. ,:haze_density
  938. ,:density_multiplier
  939. ,:distance_multiplier
  940. ,:max_altitude
  941. ,:sun_moon_color_r
  942. ,:sun_moon_color_g
  943. ,:sun_moon_color_b
  944. ,:sun_moon_color_i
  945. ,:sun_moon_position
  946. ,:ambient_r
  947. ,:ambient_g
  948. ,:ambient_b
  949. ,:ambient_i
  950. ,:east_angle
  951. ,:sun_glow_focus
  952. ,:sun_glow_size
  953. ,:scene_gamma
  954. ,:star_brightness
  955. ,:cloud_color_r
  956. ,:cloud_color_g
  957. ,:cloud_color_b
  958. ,:cloud_color_i
  959. ,:cloud_x
  960. ,:cloud_y
  961. ,:cloud_density
  962. ,:cloud_coverage
  963. ,:cloud_scale
  964. ,:cloud_detail_x
  965. ,:cloud_detail_y
  966. ,:cloud_detail_density
  967. ,:cloud_scroll_x
  968. ,:cloud_scroll_x_lock
  969. ,:cloud_scroll_y
  970. ,:cloud_scroll_y_lock
  971. ,:draw_classic_clouds);";
  972. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  973. {
  974. conn.Open();
  975. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  976. {
  977. cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID.ToString()));
  978. cmd.Parameters.Add(_Database.CreateParameter("water_color_r", wl.waterColor.X));
  979. cmd.Parameters.Add(_Database.CreateParameter("water_color_g", wl.waterColor.Y));
  980. cmd.Parameters.Add(_Database.CreateParameter("water_color_b", wl.waterColor.Z));
  981. cmd.Parameters.Add(_Database.CreateParameter("water_fog_density_exponent", wl.waterFogDensityExponent));
  982. cmd.Parameters.Add(_Database.CreateParameter("underwater_fog_modifier", wl.underwaterFogModifier));
  983. cmd.Parameters.Add(_Database.CreateParameter("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X));
  984. cmd.Parameters.Add(_Database.CreateParameter("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y));
  985. cmd.Parameters.Add(_Database.CreateParameter("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z));
  986. cmd.Parameters.Add(_Database.CreateParameter("fresnel_scale", wl.fresnelScale));
  987. cmd.Parameters.Add(_Database.CreateParameter("fresnel_offset", wl.fresnelOffset));
  988. cmd.Parameters.Add(_Database.CreateParameter("refract_scale_above", wl.refractScaleAbove));
  989. cmd.Parameters.Add(_Database.CreateParameter("refract_scale_below", wl.refractScaleBelow));
  990. cmd.Parameters.Add(_Database.CreateParameter("blur_multiplier", wl.blurMultiplier));
  991. cmd.Parameters.Add(_Database.CreateParameter("big_wave_direction_x", wl.bigWaveDirection.X));
  992. cmd.Parameters.Add(_Database.CreateParameter("big_wave_direction_y", wl.bigWaveDirection.Y));
  993. cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_x", wl.littleWaveDirection.X));
  994. cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_y", wl.littleWaveDirection.Y));
  995. cmd.Parameters.Add(_Database.CreateParameter("normal_map_texture", wl.normalMapTexture.ToString()));
  996. cmd.Parameters.Add(_Database.CreateParameter("horizon_r", wl.horizon.X));
  997. cmd.Parameters.Add(_Database.CreateParameter("horizon_g", wl.horizon.Y));
  998. cmd.Parameters.Add(_Database.CreateParameter("horizon_b", wl.horizon.Z));
  999. cmd.Parameters.Add(_Database.CreateParameter("horizon_i", wl.horizon.W));
  1000. cmd.Parameters.Add(_Database.CreateParameter("haze_horizon", wl.hazeHorizon));
  1001. cmd.Parameters.Add(_Database.CreateParameter("blue_density_r", wl.blueDensity.X));
  1002. cmd.Parameters.Add(_Database.CreateParameter("blue_density_g", wl.blueDensity.Y));
  1003. cmd.Parameters.Add(_Database.CreateParameter("blue_density_b", wl.blueDensity.Z));
  1004. cmd.Parameters.Add(_Database.CreateParameter("blue_density_i", wl.blueDensity.W));
  1005. cmd.Parameters.Add(_Database.CreateParameter("haze_density", wl.hazeDensity));
  1006. cmd.Parameters.Add(_Database.CreateParameter("density_multiplier", wl.densityMultiplier));
  1007. cmd.Parameters.Add(_Database.CreateParameter("distance_multiplier", wl.distanceMultiplier));
  1008. cmd.Parameters.Add(_Database.CreateParameter("max_altitude", wl.maxAltitude));
  1009. cmd.Parameters.Add(_Database.CreateParameter("sun_moon_color_r", wl.sunMoonColor.X));
  1010. cmd.Parameters.Add(_Database.CreateParameter("sun_moon_color_g", wl.sunMoonColor.Y));
  1011. cmd.Parameters.Add(_Database.CreateParameter("sun_moon_color_b", wl.sunMoonColor.Z));
  1012. cmd.Parameters.Add(_Database.CreateParameter("sun_moon_color_i", wl.sunMoonColor.W));
  1013. cmd.Parameters.Add(_Database.CreateParameter("sun_moon_position", wl.sunMoonPosition));
  1014. cmd.Parameters.Add(_Database.CreateParameter("ambient_r", wl.ambient.X));
  1015. cmd.Parameters.Add(_Database.CreateParameter("ambient_g", wl.ambient.Y));
  1016. cmd.Parameters.Add(_Database.CreateParameter("ambient_b", wl.ambient.Z));
  1017. cmd.Parameters.Add(_Database.CreateParameter("ambient_i", wl.ambient.W));
  1018. cmd.Parameters.Add(_Database.CreateParameter("east_angle", wl.eastAngle));
  1019. cmd.Parameters.Add(_Database.CreateParameter("sun_glow_focus", wl.sunGlowFocus));
  1020. cmd.Parameters.Add(_Database.CreateParameter("sun_glow_size", wl.sunGlowSize));
  1021. cmd.Parameters.Add(_Database.CreateParameter("scene_gamma", wl.sceneGamma));
  1022. cmd.Parameters.Add(_Database.CreateParameter("star_brightness", wl.starBrightness));
  1023. cmd.Parameters.Add(_Database.CreateParameter("cloud_color_r", wl.cloudColor.X));
  1024. cmd.Parameters.Add(_Database.CreateParameter("cloud_color_g", wl.cloudColor.Y));
  1025. cmd.Parameters.Add(_Database.CreateParameter("cloud_color_b", wl.cloudColor.Z));
  1026. cmd.Parameters.Add(_Database.CreateParameter("cloud_color_i", wl.cloudColor.W));
  1027. cmd.Parameters.Add(_Database.CreateParameter("cloud_x", wl.cloudXYDensity.X));
  1028. cmd.Parameters.Add(_Database.CreateParameter("cloud_y", wl.cloudXYDensity.Y));
  1029. cmd.Parameters.Add(_Database.CreateParameter("cloud_density", wl.cloudXYDensity.Z));
  1030. cmd.Parameters.Add(_Database.CreateParameter("cloud_coverage", wl.cloudCoverage));
  1031. cmd.Parameters.Add(_Database.CreateParameter("cloud_scale", wl.cloudScale));
  1032. cmd.Parameters.Add(_Database.CreateParameter("cloud_detail_x", wl.cloudDetailXYDensity.X));
  1033. cmd.Parameters.Add(_Database.CreateParameter("cloud_detail_y", wl.cloudDetailXYDensity.Y));
  1034. cmd.Parameters.Add(_Database.CreateParameter("cloud_detail_density", wl.cloudDetailXYDensity.Z));
  1035. cmd.Parameters.Add(_Database.CreateParameter("cloud_scroll_x", wl.cloudScrollX));
  1036. cmd.Parameters.Add(_Database.CreateParameter("cloud_scroll_x_lock", wl.cloudScrollXLock));
  1037. cmd.Parameters.Add(_Database.CreateParameter("cloud_scroll_y", wl.cloudScrollY));
  1038. cmd.Parameters.Add(_Database.CreateParameter("cloud_scroll_y_lock", wl.cloudScrollYLock));
  1039. cmd.Parameters.Add(_Database.CreateParameter("draw_classic_clouds", wl.drawClassicClouds));
  1040. cmd.ExecuteNonQuery();
  1041. }
  1042. }
  1043. #region update
  1044. // }
  1045. // else
  1046. // {
  1047. // // sql update
  1048. // sql = @"UPDATE [OpenSim].[dbo].[regionwindlight]
  1049. // SET [region_id] = @region_id
  1050. // ,[water_color_r] = @water_color_r
  1051. // ,[water_color_g] = @water_color_g
  1052. // ,[water_color_b] = @water_color_b
  1053. // ,[water_fog_density_exponent] = @water_fog_density_exponent
  1054. // ,[underwater_fog_modifier] = @underwater_fog_modifier
  1055. // ,[reflection_wavelet_scale_1] = @reflection_wavelet_scale_1
  1056. // ,[reflection_wavelet_scale_2] = @reflection_wavelet_scale_2
  1057. // ,[reflection_wavelet_scale_3] = @reflection_wavelet_scale_3
  1058. // ,[fresnel_scale] = @fresnel_scale
  1059. // ,[fresnel_offset] = @fresnel_offset
  1060. // ,[refract_scale_above] = @refract_scale_above
  1061. // ,[refract_scale_below] = @refract_scale_below
  1062. // ,[blur_multiplier] = @blur_multiplier
  1063. // ,[big_wave_direction_x] = @big_wave_direction_x
  1064. // ,[big_wave_direction_y] = @big_wave_direction_y
  1065. // ,[little_wave_direction_x] = @little_wave_direction_x
  1066. // ,[little_wave_direction_y] = @little_wave_direction_y
  1067. // ,[normal_map_texture] = @normal_map_texture
  1068. // ,[horizon_r] = @horizon_r
  1069. // ,[horizon_g] = @horizon_g
  1070. // ,[horizon_b] = @horizon_b
  1071. // ,[horizon_i] = @horizon_i
  1072. // ,[haze_horizon] = @haze_horizon
  1073. // ,[blue_density_r] = @blue_density_r
  1074. // ,[blue_density_g] = @blue_density_g
  1075. // ,[blue_density_b] = @blue_density_b
  1076. // ,[blue_density_i] = @blue_density_i
  1077. // ,[haze_density] = @haze_density
  1078. // ,[density_multiplier] = @density_multiplier
  1079. // ,[distance_multiplier] = @distance_multiplier
  1080. // ,[max_altitude] = @max_altitude
  1081. // ,[sun_moon_color_r] = @sun_moon_color_r
  1082. // ,[sun_moon_color_g] = @sun_moon_color_g
  1083. // ,[sun_moon_color_b] = @sun_moon_color_b
  1084. // ,[sun_moon_color_i] = @sun_moon_color_i
  1085. // ,[sun_moon_position] = @sun_moon_position
  1086. // ,[ambient_r] = @ambient_r
  1087. // ,[ambient_g] = @ambient_g
  1088. // ,[ambient_b] = @ambient_b
  1089. // ,[ambient_i] = @ambient_i
  1090. // ,[east_angle] = @east_angle
  1091. // ,[sun_glow_focus] = @sun_glow_focus
  1092. // ,[sun_glow_size] = @sun_glow_size
  1093. // ,[scene_gamma] = @scene_gamma
  1094. // ,[star_brightness] = @star_brightness
  1095. // ,[cloud_color_r] = @cloud_color_r
  1096. // ,[cloud_color_g] = @cloud_color_g
  1097. // ,[cloud_color_b] = @cloud_color_b
  1098. // ,[cloud_color_i] = @cloud_color_i
  1099. // ,[cloud_x] = @cloud_x
  1100. // ,[cloud_y] = @cloud_y
  1101. // ,[cloud_density] = @cloud_density
  1102. // ,[cloud_coverage] = @cloud_coverage
  1103. // ,[cloud_scale] = @cloud_scale
  1104. // ,[cloud_detail_x] = @cloud_detail_x
  1105. // ,[cloud_detail_y] = @cloud_detail_y
  1106. // ,[cloud_detail_density] = @cloud_detail_density
  1107. // ,[cloud_scroll_x] = @cloud_scroll_x
  1108. // ,[cloud_scroll_x_lock] = @cloud_scroll_x_lock
  1109. // ,[cloud_scroll_y] = @cloud_scroll_y
  1110. // ,[cloud_scroll_y_lock] = @cloud_scroll_y_lock
  1111. // ,[draw_classic_clouds] = @draw_classic_clouds
  1112. // WHERE region_id = @region_id";
  1113. // using (SqlConnection conn = new SqlConnection(m_connectionString))
  1114. // {
  1115. // conn.Open();
  1116. // using (SqlCommand cmd = new SqlCommand(sql, conn))
  1117. // {
  1118. // cmd.Parameters.AddWithValue("region_id", wl.regionID);
  1119. // cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
  1120. // cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
  1121. // cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
  1122. // cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
  1123. // cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
  1124. // cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
  1125. // cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
  1126. // cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
  1127. // cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
  1128. // cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
  1129. // cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
  1130. // cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
  1131. // cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
  1132. // cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
  1133. // cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
  1134. // cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
  1135. // cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
  1136. // cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
  1137. // cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
  1138. // cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
  1139. // cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
  1140. // cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
  1141. // cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
  1142. // cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
  1143. // cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
  1144. // cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
  1145. // cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
  1146. // cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
  1147. // cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
  1148. // cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
  1149. // cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
  1150. // cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
  1151. // cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
  1152. // cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
  1153. // cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
  1154. // cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
  1155. // cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
  1156. // cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
  1157. // cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
  1158. // cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
  1159. // cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
  1160. // cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
  1161. // cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
  1162. // cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
  1163. // cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
  1164. // cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
  1165. // cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
  1166. // cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
  1167. // cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
  1168. // cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
  1169. // cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
  1170. // cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
  1171. // cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
  1172. // cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
  1173. // cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
  1174. // cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
  1175. // cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
  1176. // cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
  1177. // cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
  1178. // cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
  1179. // cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
  1180. // cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
  1181. // cmd.ExecuteNonQuery();
  1182. // }
  1183. // }
  1184. // }
  1185. #endregion
  1186. }
  1187. #region Environment Settings
  1188. public string LoadRegionEnvironmentSettings(UUID regionUUID)
  1189. {
  1190. string sql = "select * from regionenvironment where region_id = :region_id";
  1191. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  1192. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  1193. {
  1194. cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID));
  1195. conn.Open();
  1196. using (NpgsqlDataReader result = cmd.ExecuteReader())
  1197. {
  1198. if (!result.Read())
  1199. {
  1200. return String.Empty;
  1201. }
  1202. else
  1203. {
  1204. return Convert.ToString(result["llsd_settings"]);
  1205. }
  1206. }
  1207. }
  1208. }
  1209. public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings)
  1210. {
  1211. {
  1212. string sql = "DELETE FROM regionenvironment WHERE region_id = :region_id ;";
  1213. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  1214. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  1215. {
  1216. cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID));
  1217. conn.Open();
  1218. cmd.ExecuteNonQuery();
  1219. }
  1220. sql = "INSERT INTO regionenvironment (region_id, llsd_settings) VALUES (:region_id, :llsd_settings) ;";
  1221. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  1222. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  1223. {
  1224. cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID));
  1225. cmd.Parameters.Add(_Database.CreateParameter("llsd_settings", settings));
  1226. conn.Open();
  1227. cmd.ExecuteNonQuery();
  1228. }
  1229. }
  1230. }
  1231. public void RemoveRegionEnvironmentSettings(UUID regionUUID)
  1232. {
  1233. string sql = "delete from regionenvironment where region_id = :region_id ;";
  1234. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  1235. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  1236. {
  1237. cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID));
  1238. conn.Open();
  1239. cmd.ExecuteNonQuery();
  1240. }
  1241. }
  1242. #endregion
  1243. /// <summary>
  1244. /// Loads the settings of a region.
  1245. /// </summary>
  1246. /// <param name="regionUUID">The region UUID.</param>
  1247. /// <returns></returns>
  1248. public RegionSettings LoadRegionSettings(UUID regionUUID)
  1249. {
  1250. string sql = @"select * from regionsettings where ""regionUUID"" = :regionUUID";
  1251. RegionSettings regionSettings;
  1252. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  1253. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  1254. {
  1255. cmd.Parameters.Add(_Database.CreateParameter("regionUUID", regionUUID));
  1256. conn.Open();
  1257. using (NpgsqlDataReader reader = cmd.ExecuteReader())
  1258. {
  1259. if (reader.Read())
  1260. {
  1261. regionSettings = BuildRegionSettings(reader);
  1262. regionSettings.OnSave += StoreRegionSettings;
  1263. return regionSettings;
  1264. }
  1265. }
  1266. }
  1267. //If we reach this point then there are new region settings for that region
  1268. regionSettings = new RegionSettings();
  1269. regionSettings.RegionUUID = regionUUID;
  1270. regionSettings.OnSave += StoreRegionSettings;
  1271. //Store new values
  1272. StoreNewRegionSettings(regionSettings);
  1273. LoadSpawnPoints(regionSettings);
  1274. return regionSettings;
  1275. }
  1276. /// <summary>
  1277. /// Store region settings, need to check if the check is really necesary. If we can make something for creating new region.
  1278. /// </summary>
  1279. /// <param name="regionSettings">region settings.</param>
  1280. public void StoreRegionSettings(RegionSettings regionSettings)
  1281. {
  1282. //Little check if regionUUID already exist in DB
  1283. string regionUUID;
  1284. string sql = @"SELECT ""regionUUID"" FROM regionsettings WHERE ""regionUUID"" = :regionUUID";
  1285. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  1286. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  1287. {
  1288. cmd.Parameters.Add(_Database.CreateParameter("regionUUID", regionSettings.RegionUUID));
  1289. conn.Open();
  1290. regionUUID = cmd.ExecuteScalar().ToString();
  1291. }
  1292. if (string.IsNullOrEmpty(regionUUID))
  1293. {
  1294. StoreNewRegionSettings(regionSettings);
  1295. }
  1296. else
  1297. {
  1298. //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB
  1299. sql =
  1300. @"UPDATE regionsettings SET block_terraform = :block_terraform ,block_fly = :block_fly ,allow_damage = :allow_damage
  1301. ,restrict_pushing = :restrict_pushing ,allow_land_resell = :allow_land_resell ,allow_land_join_divide = :allow_land_join_divide
  1302. ,block_show_in_search = :block_show_in_search ,agent_limit = :agent_limit ,object_bonus = :object_bonus ,maturity = :maturity
  1303. ,disable_scripts = :disable_scripts ,disable_collisions = :disable_collisions ,disable_physics = :disable_physics
  1304. ,terrain_texture_1 = :terrain_texture_1 ,terrain_texture_2 = :terrain_texture_2 ,terrain_texture_3 = :terrain_texture_3
  1305. ,terrain_texture_4 = :terrain_texture_4 ,elevation_1_nw = :elevation_1_nw ,elevation_2_nw = :elevation_2_nw
  1306. ,elevation_1_ne = :elevation_1_ne ,elevation_2_ne = :elevation_2_ne ,elevation_1_se = :elevation_1_se ,elevation_2_se = :elevation_2_se
  1307. ,elevation_1_sw = :elevation_1_sw ,elevation_2_sw = :elevation_2_sw ,water_height = :water_height ,terrain_raise_limit = :terrain_raise_limit
  1308. ,terrain_lower_limit = :terrain_lower_limit ,use_estate_sun = :use_estate_sun ,fixed_sun = :fixed_sun ,sun_position = :sun_position
  1309. ,covenant = :covenant ,covenant_datetime = :covenant_datetime, sunvectorx = :sunvectorx, sunvectory = :sunvectory, sunvectorz = :sunvectorz,
  1310. ""Sandbox"" = :Sandbox, loaded_creation_datetime = :loaded_creation_datetime, loaded_creation_id = :loaded_creation_id, ""map_tile_ID"" = :TerrainImageID,
  1311. ""TelehubObject"" = :telehubobject, ""parcel_tile_ID"" = :ParcelImageID
  1312. WHERE ""regionUUID"" = :regionUUID";
  1313. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  1314. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  1315. {
  1316. cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings));
  1317. conn.Open();
  1318. cmd.ExecuteNonQuery();
  1319. }
  1320. }
  1321. SaveSpawnPoints(regionSettings);
  1322. }
  1323. public void Shutdown()
  1324. {
  1325. //Not used??
  1326. }
  1327. #region Private Methods
  1328. /// <summary>
  1329. /// Stores new regionsettings.
  1330. /// </summary>
  1331. /// <param name="regionSettings">The region settings.</param>
  1332. private void StoreNewRegionSettings(RegionSettings regionSettings)
  1333. {
  1334. string sql = @"INSERT INTO regionsettings
  1335. (""regionUUID"",block_terraform,block_fly,allow_damage,restrict_pushing,allow_land_resell,allow_land_join_divide,
  1336. block_show_in_search,agent_limit,object_bonus,maturity,disable_scripts,disable_collisions,disable_physics,
  1337. terrain_texture_1,terrain_texture_2,terrain_texture_3,terrain_texture_4,elevation_1_nw,elevation_2_nw,elevation_1_ne,
  1338. elevation_2_ne,elevation_1_se,elevation_2_se,elevation_1_sw,elevation_2_sw,water_height,terrain_raise_limit,
  1339. terrain_lower_limit,use_estate_sun,fixed_sun,sun_position,covenant,covenant_datetime,sunvectorx, sunvectory, sunvectorz,
  1340. ""Sandbox"", loaded_creation_datetime, loaded_creation_id
  1341. )
  1342. VALUES
  1343. (:regionUUID,:block_terraform,:block_fly,:allow_damage,:restrict_pushing,:allow_land_resell,:allow_land_join_divide,
  1344. :block_show_in_search,:agent_limit,:object_bonus,:maturity,:disable_scripts,:disable_collisions,:disable_physics,
  1345. :terrain_texture_1,:terrain_texture_2,:terrain_texture_3,:terrain_texture_4,:elevation_1_nw,:elevation_2_nw,:elevation_1_ne,
  1346. :elevation_2_ne,:elevation_1_se,:elevation_2_se,:elevation_1_sw,:elevation_2_sw,:water_height,:terrain_raise_limit,
  1347. :terrain_lower_limit,:use_estate_sun,:fixed_sun,:sun_position,:covenant, :covenant_datetime, :sunvectorx,:sunvectory,
  1348. :sunvectorz, :Sandbox, :loaded_creation_datetime, :loaded_creation_id )";
  1349. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  1350. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  1351. {
  1352. cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings));
  1353. conn.Open();
  1354. cmd.ExecuteNonQuery();
  1355. }
  1356. }
  1357. #region Private DataRecord conversion methods
  1358. /// <summary>
  1359. /// Builds the region settings from a datarecod.
  1360. /// </summary>
  1361. /// <param name="row">datarecord with regionsettings.</param>
  1362. /// <returns></returns>
  1363. private static RegionSettings BuildRegionSettings(IDataRecord row)
  1364. {
  1365. //TODO change this is some more generic code so we doesnt have to change it every time a new field is added?
  1366. RegionSettings newSettings = new RegionSettings();
  1367. newSettings.RegionUUID = new UUID((Guid)row["regionUUID"]);
  1368. newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]);
  1369. newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]);
  1370. newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]);
  1371. newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]);
  1372. newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]);
  1373. newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]);
  1374. newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]);
  1375. newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]);
  1376. newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]);
  1377. newSettings.Maturity = Convert.ToInt32(row["maturity"]);
  1378. newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]);
  1379. newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]);
  1380. newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]);
  1381. newSettings.TerrainTexture1 = new UUID((Guid)row["terrain_texture_1"]);
  1382. newSettings.TerrainTexture2 = new UUID((Guid)row["terrain_texture_2"]);
  1383. newSettings.TerrainTexture3 = new UUID((Guid)row["terrain_texture_3"]);
  1384. newSettings.TerrainTexture4 = new UUID((Guid)row["terrain_texture_4"]);
  1385. newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]);
  1386. newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]);
  1387. newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]);
  1388. newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]);
  1389. newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]);
  1390. newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]);
  1391. newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]);
  1392. newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]);
  1393. newSettings.WaterHeight = Convert.ToDouble(row["water_height"]);
  1394. newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]);
  1395. newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]);
  1396. newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]);
  1397. newSettings.Sandbox = Convert.ToBoolean(row["Sandbox"]);
  1398. newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]);
  1399. newSettings.SunPosition = Convert.ToDouble(row["sun_position"]);
  1400. newSettings.SunVector = new Vector3(
  1401. Convert.ToSingle(row["sunvectorx"]),
  1402. Convert.ToSingle(row["sunvectory"]),
  1403. Convert.ToSingle(row["sunvectorz"])
  1404. );
  1405. newSettings.Covenant = new UUID((Guid)row["covenant"]);
  1406. newSettings.CovenantChangedDateTime = Convert.ToInt32(row["covenant_datetime"]);
  1407. newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]);
  1408. if (row["loaded_creation_id"] is DBNull)
  1409. newSettings.LoadedCreationID = "";
  1410. else
  1411. newSettings.LoadedCreationID = (String)row["loaded_creation_id"];
  1412. newSettings.TerrainImageID = new UUID((string)row["map_tile_ID"]);
  1413. newSettings.ParcelImageID = new UUID((Guid)row["parcel_tile_ID"]);
  1414. newSettings.TelehubObject = new UUID((Guid)row["TelehubObject"]);
  1415. return newSettings;
  1416. }
  1417. /// <summary>
  1418. /// Builds the land data from a datarecord.
  1419. /// </summary>
  1420. /// <param name="row">datarecord with land data</param>
  1421. /// <returns></returns>
  1422. private static LandData BuildLandData(IDataRecord row)
  1423. {
  1424. LandData newData = new LandData();
  1425. newData.GlobalID = new UUID((Guid)row["UUID"]);
  1426. newData.LocalID = Convert.ToInt32(row["LocalLandID"]);
  1427. // Bitmap is a byte[512]
  1428. newData.Bitmap = (Byte[])row["Bitmap"];
  1429. newData.Name = (string)row["Name"];
  1430. newData.Description = (string)row["Description"];
  1431. newData.OwnerID = new UUID((Guid)row["OwnerUUID"]);
  1432. newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]);
  1433. newData.Area = Convert.ToInt32(row["Area"]);
  1434. newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented
  1435. newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]);
  1436. //Enum libsecondlife.Parcel.ParcelCategory
  1437. newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]);
  1438. newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]);
  1439. newData.GroupID = new UUID((Guid)row["GroupUUID"]);
  1440. newData.SalePrice = Convert.ToInt32(row["SalePrice"]);
  1441. newData.Status = (ParcelStatus)Convert.ToInt32(row["LandStatus"]);
  1442. //Enum. libsecondlife.Parcel.ParcelStatus
  1443. newData.Flags = Convert.ToUInt32(row["LandFlags"]);
  1444. newData.LandingType = Convert.ToByte(row["LandingType"]);
  1445. newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]);
  1446. newData.MediaID = new UUID((Guid)row["MediaTextureUUID"]);
  1447. newData.MediaURL = (string)row["MediaURL"];
  1448. newData.MusicURL = (string)row["MusicURL"];
  1449. newData.PassHours = Convert.ToSingle(row["PassHours"]);
  1450. newData.PassPrice = Convert.ToInt32(row["PassPrice"]);
  1451. // UUID authedbuyer;
  1452. // UUID snapshotID;
  1453. //
  1454. // if (UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer))
  1455. // newData.AuthBuyerID = authedbuyer;
  1456. //
  1457. // if (UUID.TryParse((string)row["SnapshotUUID"], out snapshotID))
  1458. // newData.SnapshotID = snapshotID;
  1459. newData.AuthBuyerID = new UUID((Guid)row["AuthBuyerID"]);
  1460. newData.SnapshotID = new UUID((Guid)row["SnapshotUUID"]);
  1461. newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]);
  1462. newData.Dwell = Convert.ToSingle(row["Dwell"]);
  1463. try
  1464. {
  1465. newData.UserLocation =
  1466. new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]),
  1467. Convert.ToSingle(row["UserLocationZ"]));
  1468. newData.UserLookAt =
  1469. new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]),
  1470. Convert.ToSingle(row["UserLookAtZ"]));
  1471. }
  1472. catch (InvalidCastException)
  1473. {
  1474. newData.UserLocation = Vector3.Zero;
  1475. newData.UserLookAt = Vector3.Zero;
  1476. _Log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name);
  1477. }
  1478. newData.ParcelAccessList = new List<LandAccessEntry>();
  1479. newData.MediaDescription = (string)row["MediaDescription"];
  1480. newData.MediaType = (string)row["MediaType"];
  1481. newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]);
  1482. newData.MediaHeight = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[1]);
  1483. newData.MediaLoop = Convert.ToBoolean(row["MediaLoop"]);
  1484. newData.ObscureMusic = Convert.ToBoolean(row["ObscureMusic"]);
  1485. newData.ObscureMedia = Convert.ToBoolean(row["ObscureMedia"]);
  1486. newData.SeeAVs = Convert.ToBoolean(row["SeeAVs"]);
  1487. newData.AnyAVSounds = Convert.ToBoolean(row["AnyAVSounds"]);
  1488. newData.GroupAVSounds = Convert.ToBoolean(row["GroupAVSounds"]);
  1489. return newData;
  1490. }
  1491. /// <summary>
  1492. /// Builds the landaccess data from a data record.
  1493. /// </summary>
  1494. /// <param name="row">datarecord with landaccess data</param>
  1495. /// <returns></returns>
  1496. private static LandAccessEntry BuildLandAccessData(IDataRecord row)
  1497. {
  1498. LandAccessEntry entry = new LandAccessEntry();
  1499. entry.AgentID = new UUID((Guid)row["AccessUUID"]);
  1500. entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]);
  1501. entry.Expires = Convert.ToInt32(row["Expires"]);
  1502. return entry;
  1503. }
  1504. /// <summary>
  1505. /// Builds the prim from a datarecord.
  1506. /// </summary>
  1507. /// <param name="primRow">datarecord</param>
  1508. /// <returns></returns>
  1509. private static SceneObjectPart BuildPrim(IDataRecord primRow)
  1510. {
  1511. SceneObjectPart prim = new SceneObjectPart();
  1512. prim.UUID = new UUID((Guid)primRow["UUID"]);
  1513. // explicit conversion of integers is required, which sort
  1514. // of sucks. No idea if there is a shortcut here or not.
  1515. prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]);
  1516. prim.Name = (string)primRow["Name"];
  1517. // various text fields
  1518. prim.Text = (string)primRow["Text"];
  1519. prim.Color = Color.FromArgb(Convert.ToInt32(primRow["ColorA"]),
  1520. Convert.ToInt32(primRow["ColorR"]),
  1521. Convert.ToInt32(primRow["ColorG"]),
  1522. Convert.ToInt32(primRow["ColorB"]));
  1523. prim.Description = (string)primRow["Description"];
  1524. prim.SitName = (string)primRow["SitName"];
  1525. prim.TouchName = (string)primRow["TouchName"];
  1526. // permissions
  1527. prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]);
  1528. //prim.creatorID = new UUID((Guid)primRow["creatorID"]);
  1529. prim.CreatorIdentification = (string)primRow["CreatorID"].ToString();
  1530. prim.OwnerID = new UUID((Guid)primRow["OwnerID"]);
  1531. prim.GroupID = new UUID((Guid)primRow["GroupID"]);
  1532. prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]);
  1533. if (primRow["RezzerID"] != DBNull.Value)
  1534. prim.RezzerID = new UUID((Guid)primRow["RezzerID"]);
  1535. else
  1536. prim.RezzerID = UUID.Zero;
  1537. prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]);
  1538. prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]);
  1539. prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]);
  1540. prim.EveryoneMask = Convert.ToUInt32(primRow["EveryoneMask"]);
  1541. prim.BaseMask = Convert.ToUInt32(primRow["BaseMask"]);
  1542. // vectors
  1543. prim.OffsetPosition = new Vector3(
  1544. Convert.ToSingle(primRow["PositionX"]),
  1545. Convert.ToSingle(primRow["PositionY"]),
  1546. Convert.ToSingle(primRow["PositionZ"]));
  1547. prim.GroupPosition = new Vector3(
  1548. Convert.ToSingle(primRow["GroupPositionX"]),
  1549. Convert.ToSingle(primRow["GroupPositionY"]),
  1550. Convert.ToSingle(primRow["GroupPositionZ"]));
  1551. prim.Velocity = new Vector3(
  1552. Convert.ToSingle(primRow["VelocityX"]),
  1553. Convert.ToSingle(primRow["VelocityY"]),
  1554. Convert.ToSingle(primRow["VelocityZ"]));
  1555. prim.AngularVelocity = new Vector3(
  1556. Convert.ToSingle(primRow["AngularVelocityX"]),
  1557. Convert.ToSingle(primRow["AngularVelocityY"]),
  1558. Convert.ToSingle(primRow["AngularVelocityZ"]));
  1559. prim.Acceleration = new Vector3(
  1560. Convert.ToSingle(primRow["AccelerationX"]),
  1561. Convert.ToSingle(primRow["AccelerationY"]),
  1562. Convert.ToSingle(primRow["AccelerationZ"]));
  1563. // quaternions
  1564. prim.RotationOffset = new Quaternion(
  1565. Convert.ToSingle(primRow["RotationX"]),
  1566. Convert.ToSingle(primRow["RotationY"]),
  1567. Convert.ToSingle(primRow["RotationZ"]),
  1568. Convert.ToSingle(primRow["RotationW"]));
  1569. prim.SitTargetPositionLL = new Vector3(
  1570. Convert.ToSingle(primRow["SitTargetOffsetX"]),
  1571. Convert.ToSingle(primRow["SitTargetOffsetY"]),
  1572. Convert.ToSingle(primRow["SitTargetOffsetZ"]));
  1573. prim.SitTargetOrientationLL = new Quaternion(
  1574. Convert.ToSingle(primRow["SitTargetOrientX"]),
  1575. Convert.ToSingle(primRow["SitTargetOrientY"]),
  1576. Convert.ToSingle(primRow["SitTargetOrientZ"]),
  1577. Convert.ToSingle(primRow["SitTargetOrientW"]));
  1578. prim.PayPrice[0] = Convert.ToInt32(primRow["PayPrice"]);
  1579. prim.PayPrice[1] = Convert.ToInt32(primRow["PayButton1"]);
  1580. prim.PayPrice[2] = Convert.ToInt32(primRow["PayButton2"]);
  1581. prim.PayPrice[3] = Convert.ToInt32(primRow["PayButton3"]);
  1582. prim.PayPrice[4] = Convert.ToInt32(primRow["PayButton4"]);
  1583. prim.Sound = new UUID((Guid)primRow["LoopedSound"]);
  1584. prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]);
  1585. if (prim.Sound != UUID.Zero)
  1586. prim.SoundFlags = 1; // If it's persisted at all, it's looped
  1587. else
  1588. prim.SoundFlags = 0;
  1589. if (!(primRow["TextureAnimation"] is DBNull))
  1590. prim.TextureAnimation = (Byte[])primRow["TextureAnimation"];
  1591. if (!(primRow["ParticleSystem"] is DBNull))
  1592. prim.ParticleSystem = (Byte[])primRow["ParticleSystem"];
  1593. prim.AngularVelocity = new Vector3(
  1594. Convert.ToSingle(primRow["OmegaX"]),
  1595. Convert.ToSingle(primRow["OmegaY"]),
  1596. Convert.ToSingle(primRow["OmegaZ"]));
  1597. prim.SetCameraEyeOffset(new Vector3(
  1598. Convert.ToSingle(primRow["CameraEyeOffsetX"]),
  1599. Convert.ToSingle(primRow["CameraEyeOffsetY"]),
  1600. Convert.ToSingle(primRow["CameraEyeOffsetZ"])
  1601. ));
  1602. prim.SetCameraAtOffset(new Vector3(
  1603. Convert.ToSingle(primRow["CameraAtOffsetX"]),
  1604. Convert.ToSingle(primRow["CameraAtOffsetY"]),
  1605. Convert.ToSingle(primRow["CameraAtOffsetZ"])
  1606. ));
  1607. if (Convert.ToInt16(primRow["ForceMouselook"]) != 0)
  1608. prim.SetForceMouselook(true);
  1609. prim.ScriptAccessPin = Convert.ToInt32(primRow["ScriptAccessPin"]);
  1610. if (Convert.ToInt16(primRow["AllowedDrop"]) != 0)
  1611. prim.AllowedDrop = true;
  1612. if (Convert.ToInt16(primRow["DieAtEdge"]) != 0)
  1613. prim.DIE_AT_EDGE = true;
  1614. prim.SalePrice = Convert.ToInt32(primRow["SalePrice"]);
  1615. prim.ObjectSaleType = Convert.ToByte(primRow["SaleType"]);
  1616. prim.Material = Convert.ToByte(primRow["Material"]);
  1617. if (!(primRow["ClickAction"] is DBNull))
  1618. prim.ClickAction = Convert.ToByte(primRow["ClickAction"]);
  1619. prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]);
  1620. prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]);
  1621. prim.PassTouches = (bool)primRow["PassTouches"];
  1622. prim.PassCollisions = (bool)primRow["PassCollisions"];
  1623. if (!(primRow["MediaURL"] is System.DBNull))
  1624. prim.MediaUrl = (string)primRow["MediaURL"];
  1625. if (!(primRow["DynAttrs"] is System.DBNull) && (string)primRow["DynAttrs"] != "")
  1626. prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]);
  1627. else
  1628. prim.DynAttrs = null;
  1629. prim.PhysicsShapeType = Convert.ToByte(primRow["PhysicsShapeType"]);
  1630. prim.Density = Convert.ToSingle(primRow["Density"]);
  1631. prim.GravityModifier = Convert.ToSingle(primRow["GravityModifier"]);
  1632. prim.Friction = Convert.ToSingle(primRow["Friction"]);
  1633. prim.Restitution = Convert.ToSingle(primRow["Restitution"]);
  1634. prim.RotationAxisLocks = Convert.ToByte(primRow["RotationAxisLocks"]);
  1635. SOPVehicle vehicle = null;
  1636. if (!(primRow["Vehicle"] is System.DBNull))
  1637. {
  1638. vehicle = SOPVehicle.FromXml2(primRow["Vehicle"].ToString());
  1639. if (vehicle != null)
  1640. prim.VehicleParams = vehicle;
  1641. }
  1642. PhysicsInertiaData pdata = null;
  1643. if (!(primRow["PhysInertia"] is System.DBNull))
  1644. pdata = PhysicsInertiaData.FromXml2(primRow["PhysInertia"].ToString());
  1645. prim.PhysicsInertia = pdata;
  1646. return prim;
  1647. }
  1648. /// <summary>
  1649. /// Builds the prim shape from a datarecord.
  1650. /// </summary>
  1651. /// <param name="shapeRow">The row.</param>
  1652. /// <returns></returns>
  1653. private static PrimitiveBaseShape BuildShape(IDataRecord shapeRow)
  1654. {
  1655. PrimitiveBaseShape baseShape = new PrimitiveBaseShape();
  1656. baseShape.Scale = new Vector3(
  1657. (float)Convert.ToDouble(shapeRow["ScaleX"]),
  1658. (float)Convert.ToDouble(shapeRow["ScaleY"]),
  1659. (float)Convert.ToDouble(shapeRow["ScaleZ"]));
  1660. // paths
  1661. baseShape.PCode = Convert.ToByte(shapeRow["PCode"]);
  1662. baseShape.PathBegin = Convert.ToUInt16(shapeRow["PathBegin"]);
  1663. baseShape.PathEnd = Convert.ToUInt16(shapeRow["PathEnd"]);
  1664. baseShape.PathScaleX = Convert.ToByte(shapeRow["PathScaleX"]);
  1665. baseShape.PathScaleY = Convert.ToByte(shapeRow["PathScaleY"]);
  1666. baseShape.PathShearX = Convert.ToByte(shapeRow["PathShearX"]);
  1667. baseShape.PathShearY = Convert.ToByte(shapeRow["PathShearY"]);
  1668. baseShape.PathSkew = Convert.ToSByte(shapeRow["PathSkew"]);
  1669. baseShape.PathCurve = Convert.ToByte(shapeRow["PathCurve"]);
  1670. baseShape.PathRadiusOffset = Convert.ToSByte(shapeRow["PathRadiusOffset"]);
  1671. baseShape.PathRevolutions = Convert.ToByte(shapeRow["PathRevolutions"]);
  1672. baseShape.PathTaperX = Convert.ToSByte(shapeRow["PathTaperX"]);
  1673. baseShape.PathTaperY = Convert.ToSByte(shapeRow["PathTaperY"]);
  1674. baseShape.PathTwist = Convert.ToSByte(shapeRow["PathTwist"]);
  1675. baseShape.PathTwistBegin = Convert.ToSByte(shapeRow["PathTwistBegin"]);
  1676. // profile
  1677. baseShape.ProfileBegin = Convert.ToUInt16(shapeRow["ProfileBegin"]);
  1678. baseShape.ProfileEnd = Convert.ToUInt16(shapeRow["ProfileEnd"]);
  1679. baseShape.ProfileCurve = Convert.ToByte(shapeRow["ProfileCurve"]);
  1680. baseShape.ProfileHollow = Convert.ToUInt16(shapeRow["ProfileHollow"]);
  1681. byte[] textureEntry = (byte[])shapeRow["Texture"];
  1682. baseShape.TextureEntry = textureEntry;
  1683. baseShape.ExtraParams = (byte[])shapeRow["ExtraParams"];
  1684. try
  1685. {
  1686. baseShape.State = Convert.ToByte(shapeRow["State"]);
  1687. }
  1688. catch (InvalidCastException)
  1689. {
  1690. }
  1691. if (!(shapeRow["Media"] is System.DBNull))
  1692. {
  1693. baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]);
  1694. }
  1695. return baseShape;
  1696. }
  1697. /// <summary>
  1698. /// Build a prim inventory item from the persisted data.
  1699. /// </summary>
  1700. /// <param name="inventoryRow"></param>
  1701. /// <returns></returns>
  1702. private static TaskInventoryItem BuildItem(IDataRecord inventoryRow)
  1703. {
  1704. TaskInventoryItem taskItem = new TaskInventoryItem();
  1705. taskItem.ItemID = new UUID((Guid)inventoryRow["itemID"]);
  1706. taskItem.ParentPartID = new UUID((Guid)inventoryRow["primID"]);
  1707. taskItem.AssetID = new UUID((Guid)inventoryRow["assetID"]);
  1708. taskItem.ParentID = new UUID((Guid)inventoryRow["parentFolderID"]);
  1709. taskItem.InvType = Convert.ToInt32(inventoryRow["invType"]);
  1710. taskItem.Type = Convert.ToInt32(inventoryRow["assetType"]);
  1711. taskItem.Name = (string)inventoryRow["name"];
  1712. taskItem.Description = (string)inventoryRow["description"];
  1713. taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]);
  1714. //taskItem.creatorID = new UUID((Guid)inventoryRow["creatorID"]);
  1715. taskItem.CreatorIdentification = (string)inventoryRow["creatorID"].ToString();
  1716. taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]);
  1717. taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]);
  1718. taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]);
  1719. taskItem.NextPermissions = Convert.ToUInt32(inventoryRow["nextPermissions"]);
  1720. taskItem.CurrentPermissions = Convert.ToUInt32(inventoryRow["currentPermissions"]);
  1721. taskItem.BasePermissions = Convert.ToUInt32(inventoryRow["basePermissions"]);
  1722. taskItem.EveryonePermissions = Convert.ToUInt32(inventoryRow["everyonePermissions"]);
  1723. taskItem.GroupPermissions = Convert.ToUInt32(inventoryRow["groupPermissions"]);
  1724. taskItem.Flags = Convert.ToUInt32(inventoryRow["flags"]);
  1725. return taskItem;
  1726. }
  1727. #endregion
  1728. #region Create parameters methods
  1729. /// <summary>
  1730. /// Creates the prim inventory parameters.
  1731. /// </summary>
  1732. /// <param name="taskItem">item in inventory.</param>
  1733. /// <returns></returns>
  1734. private NpgsqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem)
  1735. {
  1736. List<NpgsqlParameter> parameters = new List<NpgsqlParameter>();
  1737. parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID));
  1738. parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID));
  1739. parameters.Add(_Database.CreateParameter("assetID", taskItem.AssetID));
  1740. parameters.Add(_Database.CreateParameter("parentFolderID", taskItem.ParentID));
  1741. parameters.Add(_Database.CreateParameter("invType", taskItem.InvType));
  1742. parameters.Add(_Database.CreateParameter("assetType", taskItem.Type));
  1743. parameters.Add(_Database.CreateParameter("name", taskItem.Name));
  1744. parameters.Add(_Database.CreateParameter("description", taskItem.Description));
  1745. parameters.Add(_Database.CreateParameter("creationDate", taskItem.CreationDate));
  1746. parameters.Add(_Database.CreateParameter("creatorID", taskItem.CreatorID));
  1747. parameters.Add(_Database.CreateParameter("ownerID", taskItem.OwnerID));
  1748. parameters.Add(_Database.CreateParameter("lastOwnerID", taskItem.LastOwnerID));
  1749. parameters.Add(_Database.CreateParameter("groupID", taskItem.GroupID));
  1750. parameters.Add(_Database.CreateParameter("nextPermissions", taskItem.NextPermissions));
  1751. parameters.Add(_Database.CreateParameter("currentPermissions", taskItem.CurrentPermissions));
  1752. parameters.Add(_Database.CreateParameter("basePermissions", taskItem.BasePermissions));
  1753. parameters.Add(_Database.CreateParameter("everyonePermissions", taskItem.EveryonePermissions));
  1754. parameters.Add(_Database.CreateParameter("groupPermissions", taskItem.GroupPermissions));
  1755. parameters.Add(_Database.CreateParameter("flags", taskItem.Flags));
  1756. return parameters.ToArray();
  1757. }
  1758. /// <summary>
  1759. /// Creates the region setting parameters.
  1760. /// </summary>
  1761. /// <param name="settings">regionsettings.</param>
  1762. /// <returns></returns>
  1763. private NpgsqlParameter[] CreateRegionSettingParameters(RegionSettings settings)
  1764. {
  1765. List<NpgsqlParameter> parameters = new List<NpgsqlParameter>();
  1766. parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID));
  1767. parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform));
  1768. parameters.Add(_Database.CreateParameter("block_fly", settings.BlockFly));
  1769. parameters.Add(_Database.CreateParameter("allow_damage", settings.AllowDamage));
  1770. parameters.Add(_Database.CreateParameter("restrict_pushing", settings.RestrictPushing));
  1771. parameters.Add(_Database.CreateParameter("allow_land_resell", settings.AllowLandResell));
  1772. parameters.Add(_Database.CreateParameter("allow_land_join_divide", settings.AllowLandJoinDivide));
  1773. parameters.Add(_Database.CreateParameter("block_show_in_search", settings.BlockShowInSearch));
  1774. parameters.Add(_Database.CreateParameter("agent_limit", settings.AgentLimit));
  1775. parameters.Add(_Database.CreateParameter("object_bonus", settings.ObjectBonus));
  1776. parameters.Add(_Database.CreateParameter("maturity", settings.Maturity));
  1777. parameters.Add(_Database.CreateParameter("disable_scripts", settings.DisableScripts));
  1778. parameters.Add(_Database.CreateParameter("disable_collisions", settings.DisableCollisions));
  1779. parameters.Add(_Database.CreateParameter("disable_physics", settings.DisablePhysics));
  1780. parameters.Add(_Database.CreateParameter("terrain_texture_1", settings.TerrainTexture1));
  1781. parameters.Add(_Database.CreateParameter("terrain_texture_2", settings.TerrainTexture2));
  1782. parameters.Add(_Database.CreateParameter("terrain_texture_3", settings.TerrainTexture3));
  1783. parameters.Add(_Database.CreateParameter("terrain_texture_4", settings.TerrainTexture4));
  1784. parameters.Add(_Database.CreateParameter("elevation_1_nw", settings.Elevation1NW));
  1785. parameters.Add(_Database.CreateParameter("elevation_2_nw", settings.Elevation2NW));
  1786. parameters.Add(_Database.CreateParameter("elevation_1_ne", settings.Elevation1NE));
  1787. parameters.Add(_Database.CreateParameter("elevation_2_ne", settings.Elevation2NE));
  1788. parameters.Add(_Database.CreateParameter("elevation_1_se", settings.Elevation1SE));
  1789. parameters.Add(_Database.CreateParameter("elevation_2_se", settings.Elevation2SE));
  1790. parameters.Add(_Database.CreateParameter("elevation_1_sw", settings.Elevation1SW));
  1791. parameters.Add(_Database.CreateParameter("elevation_2_sw", settings.Elevation2SW));
  1792. parameters.Add(_Database.CreateParameter("water_height", settings.WaterHeight));
  1793. parameters.Add(_Database.CreateParameter("terrain_raise_limit", settings.TerrainRaiseLimit));
  1794. parameters.Add(_Database.CreateParameter("terrain_lower_limit", settings.TerrainLowerLimit));
  1795. parameters.Add(_Database.CreateParameter("use_estate_sun", settings.UseEstateSun));
  1796. parameters.Add(_Database.CreateParameter("Sandbox", settings.Sandbox));
  1797. parameters.Add(_Database.CreateParameter("fixed_sun", settings.FixedSun));
  1798. parameters.Add(_Database.CreateParameter("sun_position", settings.SunPosition));
  1799. parameters.Add(_Database.CreateParameter("sunvectorx", settings.SunVector.X));
  1800. parameters.Add(_Database.CreateParameter("sunvectory", settings.SunVector.Y));
  1801. parameters.Add(_Database.CreateParameter("sunvectorz", settings.SunVector.Z));
  1802. parameters.Add(_Database.CreateParameter("covenant", settings.Covenant));
  1803. parameters.Add(_Database.CreateParameter("covenant_datetime", settings.CovenantChangedDateTime));
  1804. parameters.Add(_Database.CreateParameter("Loaded_Creation_DateTime", settings.LoadedCreationDateTime));
  1805. parameters.Add(_Database.CreateParameter("Loaded_Creation_ID", settings.LoadedCreationID));
  1806. parameters.Add(_Database.CreateParameter("TerrainImageID", settings.TerrainImageID));
  1807. parameters.Add(_Database.CreateParameter("ParcelImageID", settings.ParcelImageID));
  1808. parameters.Add(_Database.CreateParameter("TelehubObject", settings.TelehubObject));
  1809. return parameters.ToArray();
  1810. }
  1811. /// <summary>
  1812. /// Creates the land parameters.
  1813. /// </summary>
  1814. /// <param name="land">land parameters.</param>
  1815. /// <param name="regionUUID">region UUID.</param>
  1816. /// <returns></returns>
  1817. private NpgsqlParameter[] CreateLandParameters(LandData land, UUID regionUUID)
  1818. {
  1819. List<NpgsqlParameter> parameters = new List<NpgsqlParameter>();
  1820. parameters.Add(_Database.CreateParameter("UUID", land.GlobalID));
  1821. parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID));
  1822. parameters.Add(_Database.CreateParameter("LocalLandID", land.LocalID));
  1823. // Bitmap is a byte[512]
  1824. parameters.Add(_Database.CreateParameter("Bitmap", land.Bitmap));
  1825. parameters.Add(_Database.CreateParameter("Name", land.Name));
  1826. parameters.Add(_Database.CreateParameter("Description", land.Description));
  1827. parameters.Add(_Database.CreateParameter("OwnerUUID", land.OwnerID));
  1828. parameters.Add(_Database.CreateParameter("IsGroupOwned", land.IsGroupOwned));
  1829. parameters.Add(_Database.CreateParameter("Area", land.Area));
  1830. parameters.Add(_Database.CreateParameter("AuctionID", land.AuctionID)); //Unemplemented
  1831. parameters.Add(_Database.CreateParameter("Category", (int)land.Category)); //Enum libsecondlife.Parcel.ParcelCategory
  1832. parameters.Add(_Database.CreateParameter("ClaimDate", land.ClaimDate));
  1833. parameters.Add(_Database.CreateParameter("ClaimPrice", land.ClaimPrice));
  1834. parameters.Add(_Database.CreateParameter("GroupUUID", land.GroupID));
  1835. parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice));
  1836. parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus
  1837. parameters.Add(_Database.CreateParameter("LandFlags", land.Flags));
  1838. parameters.Add(_Database.CreateParameter("LandingType", Convert.ToInt32( land.LandingType) ));
  1839. parameters.Add(_Database.CreateParameter("MediaAutoScale", Convert.ToInt32( land.MediaAutoScale )));
  1840. parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID));
  1841. parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL));
  1842. parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL));
  1843. parameters.Add(_Database.CreateParameter("PassHours", land.PassHours));
  1844. parameters.Add(_Database.CreateParameter("PassPrice", land.PassPrice));
  1845. parameters.Add(_Database.CreateParameter("SnapshotUUID", land.SnapshotID));
  1846. parameters.Add(_Database.CreateParameter("UserLocationX", land.UserLocation.X));
  1847. parameters.Add(_Database.CreateParameter("UserLocationY", land.UserLocation.Y));
  1848. parameters.Add(_Database.CreateParameter("UserLocationZ", land.UserLocation.Z));
  1849. parameters.Add(_Database.CreateParameter("UserLookAtX", land.UserLookAt.X));
  1850. parameters.Add(_Database.CreateParameter("UserLookAtY", land.UserLookAt.Y));
  1851. parameters.Add(_Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z));
  1852. parameters.Add(_Database.CreateParameter("AuthBuyerID", land.AuthBuyerID));
  1853. parameters.Add(_Database.CreateParameter("OtherCleanTime", land.OtherCleanTime));
  1854. parameters.Add(_Database.CreateParameter("Dwell", land.Dwell));
  1855. parameters.Add(_Database.CreateParameter("MediaDescription", land.MediaDescription));
  1856. parameters.Add(_Database.CreateParameter("MediaType", land.MediaType));
  1857. parameters.Add(_Database.CreateParameter("MediaWidth", land.MediaWidth));
  1858. parameters.Add(_Database.CreateParameter("MediaHeight", land.MediaHeight));
  1859. parameters.Add(_Database.CreateParameter("MediaLoop", land.MediaLoop));
  1860. parameters.Add(_Database.CreateParameter("ObscureMusic", land.ObscureMusic));
  1861. parameters.Add(_Database.CreateParameter("ObscureMedia", land.ObscureMedia));
  1862. parameters.Add(_Database.CreateParameter("SeeAVs", land.SeeAVs));
  1863. parameters.Add(_Database.CreateParameter("AnyAVSounds", land.AnyAVSounds));
  1864. parameters.Add(_Database.CreateParameter("GroupAVSounds", land.GroupAVSounds));
  1865. return parameters.ToArray();
  1866. }
  1867. /// <summary>
  1868. /// Creates the land access parameters.
  1869. /// </summary>
  1870. /// <param name="parcelAccessEntry">parcel access entry.</param>
  1871. /// <param name="parcelID">parcel ID.</param>
  1872. /// <returns></returns>
  1873. private NpgsqlParameter[] CreateLandAccessParameters(LandAccessEntry parcelAccessEntry, UUID parcelID)
  1874. {
  1875. List<NpgsqlParameter> parameters = new List<NpgsqlParameter>();
  1876. parameters.Add(_Database.CreateParameter("LandUUID", parcelID));
  1877. parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID));
  1878. parameters.Add(_Database.CreateParameter("Flags", parcelAccessEntry.Flags));
  1879. parameters.Add(_Database.CreateParameter("Expires", parcelAccessEntry.Expires));
  1880. return parameters.ToArray();
  1881. }
  1882. /// <summary>
  1883. /// Creates the prim parameters for storing in DB.
  1884. /// </summary>
  1885. /// <param name="prim">Basic data of SceneObjectpart prim.</param>
  1886. /// <param name="sceneGroupID">The scenegroup ID.</param>
  1887. /// <param name="regionUUID">The region ID.</param>
  1888. /// <returns></returns>
  1889. private NpgsqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
  1890. {
  1891. List<NpgsqlParameter> parameters = new List<NpgsqlParameter>();
  1892. parameters.Add(_Database.CreateParameter("UUID", prim.UUID));
  1893. parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID));
  1894. parameters.Add(_Database.CreateParameter("CreationDate", prim.CreationDate));
  1895. parameters.Add(_Database.CreateParameter("Name", prim.Name));
  1896. parameters.Add(_Database.CreateParameter("SceneGroupID", sceneGroupID));
  1897. // the UUID of the root part for this SceneObjectGroup
  1898. // various text fields
  1899. parameters.Add(_Database.CreateParameter("Text", prim.Text));
  1900. parameters.Add(_Database.CreateParameter("ColorR", prim.Color.R));
  1901. parameters.Add(_Database.CreateParameter("ColorG", prim.Color.G));
  1902. parameters.Add(_Database.CreateParameter("ColorB", prim.Color.B));
  1903. parameters.Add(_Database.CreateParameter("ColorA", prim.Color.A));
  1904. parameters.Add(_Database.CreateParameter("Description", prim.Description));
  1905. parameters.Add(_Database.CreateParameter("SitName", prim.SitName));
  1906. parameters.Add(_Database.CreateParameter("TouchName", prim.TouchName));
  1907. // permissions
  1908. parameters.Add(_Database.CreateParameter("ObjectFlags", (uint)prim.Flags));
  1909. parameters.Add(_Database.CreateParameter("CreatorID", prim.CreatorID));
  1910. parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID));
  1911. parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID));
  1912. parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID));
  1913. parameters.Add(_Database.CreateParameter("RezzerID", prim.RezzerID));
  1914. parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask));
  1915. parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask));
  1916. parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask));
  1917. parameters.Add(_Database.CreateParameter("EveryoneMask", prim.EveryoneMask));
  1918. parameters.Add(_Database.CreateParameter("BaseMask", prim.BaseMask));
  1919. // vectors
  1920. parameters.Add(_Database.CreateParameter("PositionX", prim.OffsetPosition.X));
  1921. parameters.Add(_Database.CreateParameter("PositionY", prim.OffsetPosition.Y));
  1922. parameters.Add(_Database.CreateParameter("PositionZ", prim.OffsetPosition.Z));
  1923. parameters.Add(_Database.CreateParameter("GroupPositionX", prim.GroupPosition.X));
  1924. parameters.Add(_Database.CreateParameter("GroupPositionY", prim.GroupPosition.Y));
  1925. parameters.Add(_Database.CreateParameter("GroupPositionZ", prim.GroupPosition.Z));
  1926. parameters.Add(_Database.CreateParameter("VelocityX", prim.Velocity.X));
  1927. parameters.Add(_Database.CreateParameter("VelocityY", prim.Velocity.Y));
  1928. parameters.Add(_Database.CreateParameter("VelocityZ", prim.Velocity.Z));
  1929. parameters.Add(_Database.CreateParameter("AngularVelocityX", prim.AngularVelocity.X));
  1930. parameters.Add(_Database.CreateParameter("AngularVelocityY", prim.AngularVelocity.Y));
  1931. parameters.Add(_Database.CreateParameter("AngularVelocityZ", prim.AngularVelocity.Z));
  1932. parameters.Add(_Database.CreateParameter("AccelerationX", prim.Acceleration.X));
  1933. parameters.Add(_Database.CreateParameter("AccelerationY", prim.Acceleration.Y));
  1934. parameters.Add(_Database.CreateParameter("AccelerationZ", prim.Acceleration.Z));
  1935. // quaternions
  1936. parameters.Add(_Database.CreateParameter("RotationX", prim.RotationOffset.X));
  1937. parameters.Add(_Database.CreateParameter("RotationY", prim.RotationOffset.Y));
  1938. parameters.Add(_Database.CreateParameter("RotationZ", prim.RotationOffset.Z));
  1939. parameters.Add(_Database.CreateParameter("RotationW", prim.RotationOffset.W));
  1940. // Sit target
  1941. Vector3 sitTargetPos = prim.SitTargetPositionLL;
  1942. parameters.Add(_Database.CreateParameter("SitTargetOffsetX", sitTargetPos.X));
  1943. parameters.Add(_Database.CreateParameter("SitTargetOffsetY", sitTargetPos.Y));
  1944. parameters.Add(_Database.CreateParameter("SitTargetOffsetZ", sitTargetPos.Z));
  1945. Quaternion sitTargetOrient = prim.SitTargetOrientationLL;
  1946. parameters.Add(_Database.CreateParameter("SitTargetOrientW", sitTargetOrient.W));
  1947. parameters.Add(_Database.CreateParameter("SitTargetOrientX", sitTargetOrient.X));
  1948. parameters.Add(_Database.CreateParameter("SitTargetOrientY", sitTargetOrient.Y));
  1949. parameters.Add(_Database.CreateParameter("SitTargetOrientZ", sitTargetOrient.Z));
  1950. parameters.Add(_Database.CreateParameter("PayPrice", prim.PayPrice[0]));
  1951. parameters.Add(_Database.CreateParameter("PayButton1", prim.PayPrice[1]));
  1952. parameters.Add(_Database.CreateParameter("PayButton2", prim.PayPrice[2]));
  1953. parameters.Add(_Database.CreateParameter("PayButton3", prim.PayPrice[3]));
  1954. parameters.Add(_Database.CreateParameter("PayButton4", prim.PayPrice[4]));
  1955. if ((prim.SoundFlags & 1) != 0) // Looped
  1956. {
  1957. parameters.Add(_Database.CreateParameter("LoopedSound", prim.Sound));
  1958. parameters.Add(_Database.CreateParameter("LoopedSoundGain", prim.SoundGain));
  1959. }
  1960. else
  1961. {
  1962. parameters.Add(_Database.CreateParameter("LoopedSound", UUID.Zero));
  1963. parameters.Add(_Database.CreateParameter("LoopedSoundGain", 0.0f));
  1964. }
  1965. parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation));
  1966. parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem));
  1967. parameters.Add(_Database.CreateParameter("OmegaX", prim.AngularVelocity.X));
  1968. parameters.Add(_Database.CreateParameter("OmegaY", prim.AngularVelocity.Y));
  1969. parameters.Add(_Database.CreateParameter("OmegaZ", prim.AngularVelocity.Z));
  1970. parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X));
  1971. parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y));
  1972. parameters.Add(_Database.CreateParameter("CameraEyeOffsetZ", prim.GetCameraEyeOffset().Z));
  1973. parameters.Add(_Database.CreateParameter("CameraAtOffsetX", prim.GetCameraAtOffset().X));
  1974. parameters.Add(_Database.CreateParameter("CameraAtOffsetY", prim.GetCameraAtOffset().Y));
  1975. parameters.Add(_Database.CreateParameter("CameraAtOffsetZ", prim.GetCameraAtOffset().Z));
  1976. if (prim.GetForceMouselook())
  1977. parameters.Add(_Database.CreateParameter("ForceMouselook", 1));
  1978. else
  1979. parameters.Add(_Database.CreateParameter("ForceMouselook", 0));
  1980. parameters.Add(_Database.CreateParameter("ScriptAccessPin", prim.ScriptAccessPin));
  1981. if (prim.AllowedDrop)
  1982. parameters.Add(_Database.CreateParameter("AllowedDrop", 1));
  1983. else
  1984. parameters.Add(_Database.CreateParameter("AllowedDrop", 0));
  1985. if (prim.DIE_AT_EDGE)
  1986. parameters.Add(_Database.CreateParameter("DieAtEdge", 1));
  1987. else
  1988. parameters.Add(_Database.CreateParameter("DieAtEdge", 0));
  1989. parameters.Add(_Database.CreateParameter("SalePrice", prim.SalePrice));
  1990. parameters.Add(_Database.CreateParameter("SaleType", prim.ObjectSaleType));
  1991. byte clickAction = prim.ClickAction;
  1992. parameters.Add(_Database.CreateParameter("ClickAction", clickAction));
  1993. parameters.Add(_Database.CreateParameter("Material", prim.Material));
  1994. parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound));
  1995. parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume));
  1996. parameters.Add(_Database.CreateParameter("PassTouches", (bool)prim.PassTouches));
  1997. parameters.Add(_Database.CreateParameter("PassCollisions", (bool)prim.PassCollisions));
  1998. if (prim.PassTouches)
  1999. parameters.Add(_Database.CreateParameter("PassTouches", true));
  2000. else
  2001. parameters.Add(_Database.CreateParameter("PassTouches", false));
  2002. if (prim.PassCollisions)
  2003. parameters.Add(_Database.CreateParameter("PassCollisions", true));
  2004. else
  2005. parameters.Add(_Database.CreateParameter("PassCollisions", false));
  2006. parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum));
  2007. parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl));
  2008. if (prim.VehicleParams != null)
  2009. parameters.Add(_Database.CreateParameter("Vehicle", prim.VehicleParams.ToXml2()));
  2010. else
  2011. parameters.Add(_Database.CreateParameter("Vehicle", String.Empty));
  2012. if (prim.PhysicsInertia != null)
  2013. parameters.Add(_Database.CreateParameter("PhysInertia", prim.PhysicsInertia.ToXml2()));
  2014. else
  2015. parameters.Add(_Database.CreateParameter("PhysInertia", String.Empty));
  2016. if (prim.DynAttrs != null && prim.DynAttrs.CountNamespaces > 0)
  2017. parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml()));
  2018. else
  2019. parameters.Add(_Database.CreateParameter("DynAttrs", null));
  2020. parameters.Add(_Database.CreateParameter("PhysicsShapeType", prim.PhysicsShapeType));
  2021. parameters.Add(_Database.CreateParameter("Density", (double)prim.Density));
  2022. parameters.Add(_Database.CreateParameter("GravityModifier", (double)prim.GravityModifier));
  2023. parameters.Add(_Database.CreateParameter("Friction", (double)prim.Friction));
  2024. parameters.Add(_Database.CreateParameter("Restitution", (double)prim.Restitution));
  2025. parameters.Add(_Database.CreateParameter("RotationAxisLocks", prim.RotationAxisLocks));
  2026. return parameters.ToArray();
  2027. }
  2028. /// <summary>
  2029. /// Creates the primshape parameters for storing in DB.
  2030. /// </summary>
  2031. /// <param name="prim">Basic data of SceneObjectpart prim.</param>
  2032. /// <param name="sceneGroupID">The scene group ID.</param>
  2033. /// <param name="regionUUID">The region UUID.</param>
  2034. /// <returns></returns>
  2035. private NpgsqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID)
  2036. {
  2037. List<NpgsqlParameter> parameters = new List<NpgsqlParameter>();
  2038. PrimitiveBaseShape s = prim.Shape;
  2039. parameters.Add(_Database.CreateParameter("UUID", prim.UUID));
  2040. // shape is an enum
  2041. parameters.Add(_Database.CreateParameter("Shape", 0));
  2042. // vectors
  2043. parameters.Add(_Database.CreateParameter("ScaleX", s.Scale.X));
  2044. parameters.Add(_Database.CreateParameter("ScaleY", s.Scale.Y));
  2045. parameters.Add(_Database.CreateParameter("ScaleZ", s.Scale.Z));
  2046. // paths
  2047. parameters.Add(_Database.CreateParameter("PCode", s.PCode));
  2048. parameters.Add(_Database.CreateParameter("PathBegin", s.PathBegin));
  2049. parameters.Add(_Database.CreateParameter("PathEnd", s.PathEnd));
  2050. parameters.Add(_Database.CreateParameter("PathScaleX", s.PathScaleX));
  2051. parameters.Add(_Database.CreateParameter("PathScaleY", s.PathScaleY));
  2052. parameters.Add(_Database.CreateParameter("PathShearX", s.PathShearX));
  2053. parameters.Add(_Database.CreateParameter("PathShearY", s.PathShearY));
  2054. parameters.Add(_Database.CreateParameter("PathSkew", s.PathSkew));
  2055. parameters.Add(_Database.CreateParameter("PathCurve", s.PathCurve));
  2056. parameters.Add(_Database.CreateParameter("PathRadiusOffset", s.PathRadiusOffset));
  2057. parameters.Add(_Database.CreateParameter("PathRevolutions", s.PathRevolutions));
  2058. parameters.Add(_Database.CreateParameter("PathTaperX", s.PathTaperX));
  2059. parameters.Add(_Database.CreateParameter("PathTaperY", s.PathTaperY));
  2060. parameters.Add(_Database.CreateParameter("PathTwist", s.PathTwist));
  2061. parameters.Add(_Database.CreateParameter("PathTwistBegin", s.PathTwistBegin));
  2062. // profile
  2063. parameters.Add(_Database.CreateParameter("ProfileBegin", s.ProfileBegin));
  2064. parameters.Add(_Database.CreateParameter("ProfileEnd", s.ProfileEnd));
  2065. parameters.Add(_Database.CreateParameter("ProfileCurve", s.ProfileCurve));
  2066. parameters.Add(_Database.CreateParameter("ProfileHollow", s.ProfileHollow));
  2067. parameters.Add(_Database.CreateParameter("Texture", s.TextureEntry));
  2068. parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams));
  2069. parameters.Add(_Database.CreateParameter("State", s.State));
  2070. if (null == s.Media)
  2071. {
  2072. parameters.Add(_Database.CreateParameter("Media", DBNull.Value));
  2073. }
  2074. else
  2075. {
  2076. parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml()));
  2077. }
  2078. return parameters.ToArray();
  2079. }
  2080. #endregion
  2081. #endregion
  2082. private void LoadSpawnPoints(RegionSettings rs)
  2083. {
  2084. rs.ClearSpawnPoints();
  2085. string sql = @"SELECT ""Yaw"", ""Pitch"", ""Distance"" FROM spawn_points WHERE ""RegionUUID"" = :RegionUUID";
  2086. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  2087. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  2088. {
  2089. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID));
  2090. conn.Open();
  2091. using (NpgsqlDataReader reader = cmd.ExecuteReader())
  2092. {
  2093. if (reader.Read())
  2094. {
  2095. SpawnPoint sp = new SpawnPoint();
  2096. sp.Yaw = (float)reader["Yaw"];
  2097. sp.Pitch = (float)reader["Pitch"];
  2098. sp.Distance = (float)reader["Distance"];
  2099. rs.AddSpawnPoint(sp);
  2100. }
  2101. }
  2102. }
  2103. }
  2104. private void SaveSpawnPoints(RegionSettings rs)
  2105. {
  2106. string sql = @"DELETE FROM spawn_points WHERE ""RegionUUID"" = :RegionUUID";
  2107. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  2108. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  2109. {
  2110. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID));
  2111. conn.Open();
  2112. cmd.ExecuteNonQuery();
  2113. }
  2114. foreach (SpawnPoint p in rs.SpawnPoints())
  2115. {
  2116. sql = @"INSERT INTO spawn_points (""RegionUUID"", ""Yaw"", ""Pitch"", ""Distance"") VALUES (:RegionUUID, :Yaw, :Pitch, :Distance)";
  2117. using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
  2118. using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
  2119. {
  2120. cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID));
  2121. cmd.Parameters.Add(_Database.CreateParameter("Yaw", p.Yaw));
  2122. cmd.Parameters.Add(_Database.CreateParameter("Pitch", p.Pitch));
  2123. cmd.Parameters.Add(_Database.CreateParameter("Distance", p.Distance));
  2124. conn.Open();
  2125. cmd.ExecuteNonQuery();
  2126. }
  2127. }
  2128. }
  2129. public UUID[] GetObjectIDs(UUID regionID)
  2130. {
  2131. return new UUID[0];
  2132. }
  2133. public void SaveExtra(UUID regionID, string name, string value)
  2134. {
  2135. }
  2136. public void RemoveExtra(UUID regionID, string name)
  2137. {
  2138. }
  2139. public Dictionary<string, string> GetExtra(UUID regionID)
  2140. {
  2141. return null;
  2142. }
  2143. }
  2144. }