GridService.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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.Net;
  30. using System.Reflection;
  31. using Nini.Config;
  32. using log4net;
  33. using OpenSim.Framework;
  34. using OpenSim.Framework.Console;
  35. using OpenSim.Data;
  36. using OpenSim.Server.Base;
  37. using OpenSim.Services.Interfaces;
  38. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  39. using OpenMetaverse;
  40. namespace OpenSim.Services.GridService
  41. {
  42. public class GridService : GridServiceBase, IGridService
  43. {
  44. private static readonly ILog m_log =
  45. LogManager.GetLogger(
  46. MethodBase.GetCurrentMethod().DeclaringType);
  47. private bool m_DeleteOnUnregister = true;
  48. private static GridService m_RootInstance = null;
  49. protected IConfigSource m_config;
  50. protected static HypergridLinker m_HypergridLinker;
  51. protected IAuthenticationService m_AuthenticationService = null;
  52. protected bool m_AllowDuplicateNames = false;
  53. protected bool m_AllowHypergridMapSearch = false;
  54. public GridService(IConfigSource config)
  55. : base(config)
  56. {
  57. m_log.DebugFormat("[GRID SERVICE]: Starting...");
  58. m_config = config;
  59. IConfig gridConfig = config.Configs["GridService"];
  60. if (gridConfig != null)
  61. {
  62. m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
  63. string authService = gridConfig.GetString("AuthenticationService", String.Empty);
  64. if (authService != String.Empty)
  65. {
  66. Object[] args = new Object[] { config };
  67. m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
  68. }
  69. m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
  70. m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch);
  71. }
  72. if (m_RootInstance == null)
  73. {
  74. m_RootInstance = this;
  75. if (MainConsole.Instance != null)
  76. {
  77. MainConsole.Instance.Commands.AddCommand("grid", true,
  78. "show region",
  79. "show region <Region name>",
  80. "Show details on a region",
  81. String.Empty,
  82. HandleShowRegion);
  83. MainConsole.Instance.Commands.AddCommand("grid", true,
  84. "set region flags",
  85. "set region flags <Region name> <flags>",
  86. "Set database flags for region",
  87. String.Empty,
  88. HandleSetFlags);
  89. }
  90. m_HypergridLinker = new HypergridLinker(m_config, this, m_Database);
  91. }
  92. }
  93. #region IGridService
  94. public string RegisterRegion(UUID scopeID, GridRegion regionInfos)
  95. {
  96. IConfig gridConfig = m_config.Configs["GridService"];
  97. if (regionInfos.RegionID == UUID.Zero)
  98. return "Invalid RegionID - cannot be zero UUID";
  99. // This needs better sanity testing. What if regionInfo is registering in
  100. // overlapping coords?
  101. RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
  102. if (region != null)
  103. {
  104. // There is a preexisting record
  105. //
  106. // Get it's flags
  107. //
  108. OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["flags"]);
  109. // Is this a reservation?
  110. //
  111. if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0)
  112. {
  113. // Regions reserved for the null key cannot be taken.
  114. if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString())
  115. return "Region location is reserved";
  116. // Treat it as an auth request
  117. //
  118. // NOTE: Fudging the flags value here, so these flags
  119. // should not be used elsewhere. Don't optimize
  120. // this with the later retrieval of the same flags!
  121. rflags |= OpenSim.Data.RegionFlags.Authenticate;
  122. }
  123. if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0)
  124. {
  125. // Can we authenticate at all?
  126. //
  127. if (m_AuthenticationService == null)
  128. return "No authentication possible";
  129. if (!m_AuthenticationService.Verify(new UUID(region.Data["PrincipalID"].ToString()), regionInfos.Token, 30))
  130. return "Bad authentication";
  131. }
  132. }
  133. if ((region != null) && (region.RegionID != regionInfos.RegionID))
  134. {
  135. m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
  136. regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
  137. return "Region overlaps another region";
  138. }
  139. if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
  140. ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
  141. {
  142. if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0)
  143. return "Can't move this region";
  144. // Region reregistering in other coordinates. Delete the old entry
  145. m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.",
  146. regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY);
  147. try
  148. {
  149. m_Database.Delete(regionInfos.RegionID);
  150. }
  151. catch (Exception e)
  152. {
  153. m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
  154. }
  155. }
  156. if (!m_AllowDuplicateNames)
  157. {
  158. List<RegionData> dupe = m_Database.Get(regionInfos.RegionName, scopeID);
  159. if (dupe != null && dupe.Count > 0)
  160. {
  161. foreach (RegionData d in dupe)
  162. {
  163. if (d.RegionID != regionInfos.RegionID)
  164. {
  165. m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.",
  166. regionInfos.RegionName, regionInfos.RegionID);
  167. return "Duplicate region name";
  168. }
  169. }
  170. }
  171. }
  172. // Everything is ok, let's register
  173. RegionData rdata = RegionInfo2RegionData(regionInfos);
  174. rdata.ScopeID = scopeID;
  175. if (region != null)
  176. {
  177. int oldFlags = Convert.ToInt32(region.Data["flags"]);
  178. if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0)
  179. return "Region locked out";
  180. oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation;
  181. rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags
  182. }
  183. else
  184. {
  185. rdata.Data["flags"] = "0";
  186. if ((gridConfig != null) && rdata.RegionName != string.Empty)
  187. {
  188. int newFlags = 0;
  189. string regionName = rdata.RegionName.Trim().Replace(' ', '_');
  190. newFlags = ParseFlags(newFlags, gridConfig.GetString("DefaultRegionFlags", String.Empty));
  191. newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty));
  192. newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty));
  193. rdata.Data["flags"] = newFlags.ToString();
  194. }
  195. }
  196. int flags = Convert.ToInt32(rdata.Data["flags"]);
  197. flags |= (int)OpenSim.Data.RegionFlags.RegionOnline;
  198. rdata.Data["flags"] = flags.ToString();
  199. try
  200. {
  201. rdata.Data["last_seen"] = Util.UnixTimeSinceEpoch();
  202. m_Database.Store(rdata);
  203. }
  204. catch (Exception e)
  205. {
  206. m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
  207. }
  208. m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}",
  209. regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY);
  210. return String.Empty;
  211. }
  212. public bool DeregisterRegion(UUID regionID)
  213. {
  214. RegionData region = m_Database.Get(regionID, UUID.Zero);
  215. if (region == null)
  216. return false;
  217. m_log.DebugFormat(
  218. "[GRID SERVICE]: Deregistering region {0} ({1}) at {2}-{3}",
  219. region.RegionName, region.RegionID, region.coordX, region.coordY);
  220. int flags = Convert.ToInt32(region.Data["flags"]);
  221. if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Data.RegionFlags.Persistent) != 0)
  222. {
  223. flags &= ~(int)OpenSim.Data.RegionFlags.RegionOnline;
  224. region.Data["flags"] = flags.ToString();
  225. region.Data["last_seen"] = Util.UnixTimeSinceEpoch();
  226. try
  227. {
  228. m_Database.Store(region);
  229. }
  230. catch (Exception e)
  231. {
  232. m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
  233. }
  234. return true;
  235. }
  236. return m_Database.Delete(regionID);
  237. }
  238. public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
  239. {
  240. List<GridRegion> rinfos = new List<GridRegion>();
  241. RegionData region = m_Database.Get(regionID, scopeID);
  242. if (region != null)
  243. {
  244. // Not really? Maybe?
  245. List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1,
  246. region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID);
  247. foreach (RegionData rdata in rdatas)
  248. {
  249. if (rdata.RegionID != regionID)
  250. {
  251. int flags = Convert.ToInt32(rdata.Data["flags"]);
  252. if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours
  253. rinfos.Add(RegionData2RegionInfo(rdata));
  254. }
  255. }
  256. // m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count);
  257. }
  258. else
  259. {
  260. m_log.WarnFormat(
  261. "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found",
  262. scopeID, regionID);
  263. }
  264. return rinfos;
  265. }
  266. public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
  267. {
  268. RegionData rdata = m_Database.Get(regionID, scopeID);
  269. if (rdata != null)
  270. return RegionData2RegionInfo(rdata);
  271. return null;
  272. }
  273. public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
  274. {
  275. int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize;
  276. int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize;
  277. RegionData rdata = m_Database.Get(snapX, snapY, scopeID);
  278. if (rdata != null)
  279. return RegionData2RegionInfo(rdata);
  280. return null;
  281. }
  282. public GridRegion GetRegionByName(UUID scopeID, string name)
  283. {
  284. List<RegionData> rdatas = m_Database.Get(name, scopeID);
  285. if ((rdatas != null) && (rdatas.Count > 0))
  286. return RegionData2RegionInfo(rdatas[0]); // get the first
  287. if (m_AllowHypergridMapSearch)
  288. {
  289. GridRegion r = GetHypergridRegionByName(scopeID, name);
  290. if (r != null)
  291. return r;
  292. }
  293. return null;
  294. }
  295. public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
  296. {
  297. // m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name);
  298. List<RegionData> rdatas = m_Database.Get(name + "%", scopeID);
  299. int count = 0;
  300. List<GridRegion> rinfos = new List<GridRegion>();
  301. if (rdatas != null)
  302. {
  303. // m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count);
  304. foreach (RegionData rdata in rdatas)
  305. {
  306. if (count++ < maxNumber)
  307. rinfos.Add(RegionData2RegionInfo(rdata));
  308. }
  309. }
  310. if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0)))
  311. {
  312. GridRegion r = GetHypergridRegionByName(scopeID, name);
  313. if (r != null)
  314. rinfos.Add(r);
  315. }
  316. return rinfos;
  317. }
  318. /// <summary>
  319. /// Get a hypergrid region.
  320. /// </summary>
  321. /// <param name="scopeID"></param>
  322. /// <param name="name"></param>
  323. /// <returns>null if no hypergrid region could be found.</returns>
  324. protected GridRegion GetHypergridRegionByName(UUID scopeID, string name)
  325. {
  326. if (name.Contains("."))
  327. return m_HypergridLinker.LinkRegion(scopeID, name);
  328. else
  329. return null;
  330. }
  331. public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
  332. {
  333. int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
  334. int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
  335. int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
  336. int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
  337. List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID);
  338. List<GridRegion> rinfos = new List<GridRegion>();
  339. foreach (RegionData rdata in rdatas)
  340. rinfos.Add(RegionData2RegionInfo(rdata));
  341. return rinfos;
  342. }
  343. #endregion
  344. #region Data structure conversions
  345. public RegionData RegionInfo2RegionData(GridRegion rinfo)
  346. {
  347. RegionData rdata = new RegionData();
  348. rdata.posX = (int)rinfo.RegionLocX;
  349. rdata.posY = (int)rinfo.RegionLocY;
  350. rdata.RegionID = rinfo.RegionID;
  351. rdata.RegionName = rinfo.RegionName;
  352. rdata.Data = rinfo.ToKeyValuePairs();
  353. rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY);
  354. rdata.Data["owner_uuid"] = rinfo.EstateOwner.ToString();
  355. return rdata;
  356. }
  357. public GridRegion RegionData2RegionInfo(RegionData rdata)
  358. {
  359. GridRegion rinfo = new GridRegion(rdata.Data);
  360. rinfo.RegionLocX = rdata.posX;
  361. rinfo.RegionLocY = rdata.posY;
  362. rinfo.RegionID = rdata.RegionID;
  363. rinfo.RegionName = rdata.RegionName;
  364. rinfo.ScopeID = rdata.ScopeID;
  365. return rinfo;
  366. }
  367. #endregion
  368. public List<GridRegion> GetDefaultRegions(UUID scopeID)
  369. {
  370. List<GridRegion> ret = new List<GridRegion>();
  371. List<RegionData> regions = m_Database.GetDefaultRegions(scopeID);
  372. foreach (RegionData r in regions)
  373. {
  374. if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0)
  375. ret.Add(RegionData2RegionInfo(r));
  376. }
  377. m_log.DebugFormat("[GRID SERVICE]: GetDefaultRegions returning {0} regions", ret.Count);
  378. return ret;
  379. }
  380. public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
  381. {
  382. List<GridRegion> ret = new List<GridRegion>();
  383. List<RegionData> regions = m_Database.GetFallbackRegions(scopeID, x, y);
  384. foreach (RegionData r in regions)
  385. {
  386. if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0)
  387. ret.Add(RegionData2RegionInfo(r));
  388. }
  389. m_log.DebugFormat("[GRID SERVICE]: Fallback returned {0} regions", ret.Count);
  390. return ret;
  391. }
  392. public List<GridRegion> GetHyperlinks(UUID scopeID)
  393. {
  394. List<GridRegion> ret = new List<GridRegion>();
  395. List<RegionData> regions = m_Database.GetHyperlinks(scopeID);
  396. foreach (RegionData r in regions)
  397. {
  398. if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0)
  399. ret.Add(RegionData2RegionInfo(r));
  400. }
  401. m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count);
  402. return ret;
  403. }
  404. public int GetRegionFlags(UUID scopeID, UUID regionID)
  405. {
  406. RegionData region = m_Database.Get(regionID, scopeID);
  407. if (region != null)
  408. {
  409. int flags = Convert.ToInt32(region.Data["flags"]);
  410. //m_log.DebugFormat("[GRID SERVICE]: Request for flags of {0}: {1}", regionID, flags);
  411. return flags;
  412. }
  413. else
  414. return -1;
  415. }
  416. private void HandleShowRegion(string module, string[] cmd)
  417. {
  418. if (cmd.Length != 3)
  419. {
  420. MainConsole.Instance.Output("Syntax: show region <region name>");
  421. return;
  422. }
  423. List<RegionData> regions = m_Database.Get(cmd[2], UUID.Zero);
  424. if (regions == null || regions.Count < 1)
  425. {
  426. MainConsole.Instance.Output("Region not found");
  427. return;
  428. }
  429. MainConsole.Instance.Output("Region Name Region UUID");
  430. MainConsole.Instance.Output("Location URI");
  431. MainConsole.Instance.Output("Owner ID Flags");
  432. MainConsole.Instance.Output("-------------------------------------------------------------------------------");
  433. foreach (RegionData r in regions)
  434. {
  435. OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]);
  436. MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n",
  437. r.RegionName, r.RegionID,
  438. String.Format("{0},{1}", r.posX / Constants.RegionSize, r.posY / Constants.RegionSize),
  439. r.Data["serverURI"],
  440. r.Data["owner_uuid"], flags));
  441. }
  442. return;
  443. }
  444. private int ParseFlags(int prev, string flags)
  445. {
  446. OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)prev;
  447. string[] parts = flags.Split(new char[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);
  448. foreach (string p in parts)
  449. {
  450. int val;
  451. try
  452. {
  453. if (p.StartsWith("+"))
  454. {
  455. val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1));
  456. f |= (OpenSim.Data.RegionFlags)val;
  457. }
  458. else if (p.StartsWith("-"))
  459. {
  460. val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1));
  461. f &= ~(OpenSim.Data.RegionFlags)val;
  462. }
  463. else
  464. {
  465. val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p);
  466. f |= (OpenSim.Data.RegionFlags)val;
  467. }
  468. }
  469. catch (Exception)
  470. {
  471. MainConsole.Instance.Output("Error in flag specification: " + p);
  472. }
  473. }
  474. return (int)f;
  475. }
  476. private void HandleSetFlags(string module, string[] cmd)
  477. {
  478. if (cmd.Length < 5)
  479. {
  480. MainConsole.Instance.Output("Syntax: set region flags <region name> <flags>");
  481. return;
  482. }
  483. List<RegionData> regions = m_Database.Get(cmd[3], UUID.Zero);
  484. if (regions == null || regions.Count < 1)
  485. {
  486. MainConsole.Instance.Output("Region not found");
  487. return;
  488. }
  489. foreach (RegionData r in regions)
  490. {
  491. int flags = Convert.ToInt32(r.Data["flags"]);
  492. flags = ParseFlags(flags, cmd[4]);
  493. r.Data["flags"] = flags.ToString();
  494. OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)flags;
  495. MainConsole.Instance.Output(String.Format("Set region {0} to {1}", r.RegionName, f));
  496. m_Database.Store(r);
  497. }
  498. }
  499. }
  500. }