OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
EstateManagementModule.cs
Go to the documentation of this file.
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 
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31 using System.IO;
32 using System.Linq;
33 using System.Reflection;
34 using System.Security;
35 using System.Timers;
36 using log4net;
37 using Mono.Addins;
38 using Nini.Config;
39 using OpenMetaverse;
40 using OpenSim.Framework;
41 using OpenSim.Region.Framework.Interfaces;
42 using OpenSim.Region.Framework.Scenes;
43 using OpenSim.Services.Interfaces;
45 
46 namespace OpenSim.Region.CoreModules.World.Estate
47 {
48  [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateManagementModule")]
50  {
51  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 
53  private Timer m_regionChangeTimer = new Timer();
54  public Scene Scene { get; private set; }
55  public IUserManagement UserManager { get; private set; }
56 
58 
62  public bool AllowRegionRestartFromClient { get; set; }
63 
64  private EstateTerrainXferHandler TerrainUploader;
66 
70 
71  private int m_delayCount = 0;
72 
73  #region Region Module interface
74 
75  public string Name { get { return "EstateManagementModule"; } }
76 
77  public Type ReplaceableInterface { get { return null; } }
78 
79  public void Initialise(IConfigSource source)
80  {
81  AllowRegionRestartFromClient = true;
82 
83  IConfig config = source.Configs["EstateManagement"];
84 
85  if (config != null)
86  AllowRegionRestartFromClient = config.GetBoolean("AllowRegionRestartFromClient", true);
87  }
88 
89  public void AddRegion(Scene scene)
90  {
91  Scene = scene;
92  Scene.RegisterModuleInterface<IEstateModule>(this);
93  Scene.EventManager.OnNewClient += EventManager_OnNewClient;
94  Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
95 
96  m_Telehub = new TelehubManager(scene);
97 
98  m_commands = new EstateManagementCommands(this);
99  m_commands.Initialise();
100 
101  m_regionChangeTimer.Interval = 10000;
102  m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
103  m_regionChangeTimer.AutoReset = false;
104  }
105 
106  public void RemoveRegion(Scene scene) {}
107 
108  public void RegionLoaded(Scene scene)
109  {
110  // Sets up the sun module based no the saved Estate and Region Settings
111  // DO NOT REMOVE or the sun will stop working
112  scene.TriggerEstateSunUpdate();
113 
114  UserManager = scene.RequestModuleInterface<IUserManagement>();
115  }
116 
117  public void Close()
118  {
119  m_commands.Close();
120  }
121 
122  #endregion
123 
124  #region IEstateModule Functions
125  public uint GetRegionFlags()
126  {
127  RegionFlags flags = RegionFlags.None;
128 
129  // Fully implemented
130  //
132  flags |= RegionFlags.AllowDamage;
134  flags |= RegionFlags.BlockTerraform;
136  flags |= RegionFlags.BlockLandResell;
138  flags |= RegionFlags.SkipCollisions;
140  flags |= RegionFlags.SkipScripts;
142  flags |= RegionFlags.SkipPhysics;
144  flags |= RegionFlags.NoFly;
146  flags |= RegionFlags.RestrictPushObject;
148  flags |= RegionFlags.AllowParcelChanges;
150  flags |= RegionFlags.BlockParcelSearch;
152  flags |= (RegionFlags)(1 << 11);
154  flags |= (RegionFlags)(1 << 10);
155 
157  flags |= RegionFlags.SunFixed;
159  flags |= RegionFlags.Sandbox;
161  flags |= RegionFlags.AllowVoice;
163  flags |= RegionFlags.AllowLandmark;
165  flags |= RegionFlags.AllowSetHome;
167  flags |= RegionFlags.BlockDwell;
169  flags |= RegionFlags.ResetHomeOnTeleport;
170 
171 
172  // TODO: SkipUpdateInterestList
173 
174  // Omitted
175  //
176  // Omitted: NullLayer (what is that?)
177  // Omitted: SkipAgentAction (what does it do?)
178 
179  return (uint)flags;
180  }
181 
182  public bool IsManager(UUID avatarID)
183  {
184  if (avatarID == Scene.RegionInfo.EstateSettings.EstateOwner)
185  return true;
186 
187  List<UUID> ems = new List<UUID>(Scene.RegionInfo.EstateSettings.EstateManagers);
188  if (ems.Contains(avatarID))
189  return true;
190 
191  return false;
192  }
193 
195  {
196  Scene.ForEachClient(sendRegionHandshake);
197  }
198 
200  {
201  ChangeDelegate change = OnEstateInfoChange;
202 
203  if (change != null)
204  change(Scene.RegionInfo.RegionID);
205  }
206 
207  protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e)
208  {
209  ChangeDelegate change = OnRegionInfoChange;
210 
211  if (change != null)
212  change(Scene.RegionInfo.RegionID);
213  }
214 
216  {
217  m_regionChangeTimer.Stop();
218  m_regionChangeTimer.Start();
219 
220  ChangeDelegate change = OnRegionInfoChange;
221 
222  if (change != null)
223  change(Scene.RegionInfo.RegionID);
224  }
225 
226  public void setEstateTerrainBaseTexture(int level, UUID texture)
227  {
228  setEstateTerrainBaseTexture(null, level, texture);
229  sendRegionHandshakeToAll();
230  }
231 
232  public void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue)
233  {
234  setEstateTerrainTextureHeights(null, corner, lowValue, highValue);
235  }
236 
237  public bool IsTerrainXfer(ulong xferID)
238  {
239  lock (this)
240  {
241  if (TerrainUploader == null)
242  return false;
243  else
244  return TerrainUploader.XferID == xferID;
245  }
246  }
247 
248  public string SetEstateOwner(int estateID, UserAccount account)
249  {
250  string response;
251 
252  // get the current settings from DB
253  EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
254  if (dbSettings.EstateID == 0)
255  {
256  response = String.Format("No estate found with ID {0}", estateID);
257  }
258  else if (account.PrincipalID == dbSettings.EstateOwner)
259  {
260  response = String.Format("Estate already belongs to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName);
261  }
262  else
263  {
264  dbSettings.EstateOwner = account.PrincipalID;
265  Scene.EstateDataService.StoreEstateSettings(dbSettings);
266  response = String.Empty;
267 
268  // make sure there's a log entry to document the change
269  m_log.InfoFormat("[ESTATE]: Estate Owner for {0} changed to {1} ({2} {3})", dbSettings.EstateName,
270  account.PrincipalID, account.FirstName, account.LastName);
271 
272  // propagate the change
273  List<UUID> regions = Scene.GetEstateRegions(estateID);
274  UUID regionId = (regions.Count() > 0) ? regions.ElementAt(0) : UUID.Zero;
275  if (regionId != UUID.Zero)
276  {
277  ChangeDelegate change = OnEstateInfoChange;
278 
279  if (change != null)
280  change(regionId);
281  }
282 
283  }
284  return response;
285  }
286 
287  public string SetEstateName(int estateID, string newName)
288  {
289  string response;
290 
291  // get the current settings from DB
292  EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
293 
294  if (dbSettings.EstateID == 0)
295  {
296  response = String.Format("No estate found with ID {0}", estateID);
297  }
298  else if (newName == dbSettings.EstateName)
299  {
300  response = String.Format("Estate {0} is already named \"{1}\"", estateID, newName);
301  }
302  else
303  {
304  List<int> estates = Scene.EstateDataService.GetEstates(newName);
305  if (estates.Count() > 0)
306  {
307  response = String.Format("An estate named \"{0}\" already exists.", newName);
308  }
309  else
310  {
311  string oldName = dbSettings.EstateName;
312  dbSettings.EstateName = newName;
313  Scene.EstateDataService.StoreEstateSettings(dbSettings);
314  response = String.Empty;
315 
316  // make sure there's a log entry to document the change
317  m_log.InfoFormat("[ESTATE]: Estate {0} renamed from \"{1}\" to \"{2}\"", estateID, oldName, newName);
318 
319  // propagate the change
320  List<UUID> regions = Scene.GetEstateRegions(estateID);
321  UUID regionId = (regions.Count() > 0) ? regions.ElementAt(0) : UUID.Zero;
322  if (regionId != UUID.Zero)
323  {
324  ChangeDelegate change = OnEstateInfoChange;
325 
326  if (change != null)
327  change(regionId);
328  }
329  }
330  }
331  return response;
332  }
333 
334  public string SetRegionEstate(RegionInfo regionInfo, int estateID)
335  {
336  string response;
337 
338  if (regionInfo.EstateSettings.EstateID == estateID)
339  {
340  response = String.Format("\"{0}\" is already part of estate {1}", regionInfo.RegionName, estateID);
341  }
342  else
343  {
344  // get the current settings from DB
345  EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
346  if (dbSettings.EstateID == 0)
347  {
348  response = String.Format("No estate found with ID {0}", estateID);
349  }
350  else if (Scene.EstateDataService.LinkRegion(regionInfo.RegionID, estateID))
351  {
352  // make sure there's a log entry to document the change
353  m_log.InfoFormat("[ESTATE]: Region {0} ({1}) moved to Estate {2} ({3}).", regionInfo.RegionID, regionInfo.RegionName, estateID, dbSettings.EstateName);
354 
355  // propagate the change
356  ChangeDelegate change = OnEstateInfoChange;
357 
358  if (change != null)
359  change(regionInfo.RegionID);
360 
361  response = String.Empty;
362  }
363  else
364  {
365  response = String.Format("Could not move \"{0}\" to estate {1}", regionInfo.RegionName, estateID);
366  }
367  }
368  return response;
369  }
370 
371  public string CreateEstate(string estateName, UUID ownerID)
372  {
373  string response;
374  if (string.IsNullOrEmpty(estateName))
375  {
376  response = "No estate name specified.";
377  }
378  else
379  {
380  List<int> estates = Scene.EstateDataService.GetEstates(estateName);
381  if (estates.Count() > 0)
382  {
383  response = String.Format("An estate named \"{0}\" already exists.", estateName);
384  }
385  else
386  {
387  EstateSettings settings = Scene.EstateDataService.CreateNewEstate();
388  if (settings == null)
389  response = String.Format("Unable to create estate \"{0}\" at this simulator", estateName);
390  else
391  {
392  settings.EstateOwner = ownerID;
393  settings.EstateName = estateName;
394  Scene.EstateDataService.StoreEstateSettings(settings);
395  response = String.Empty;
396  }
397  }
398  }
399  return response;
400  }
401 
402  #endregion
403 
404  #region Packet Data Responders
405 
406  private void clientSendDetailedEstateData(IClientAPI remote_client, UUID invoice)
407  {
408  sendDetailedEstateData(remote_client, invoice);
409  sendEstateLists(remote_client, invoice);
410  }
411 
412  private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice)
413  {
414  uint sun = 0;
415 
417  sun = (uint)(Scene.RegionInfo.EstateSettings.SunPosition * 1024.0) + 0x1800;
418  UUID estateOwner;
419  estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
420 
421  if (Scene.Permissions.IsGod(remote_client.AgentId))
422  estateOwner = remote_client.AgentId;
423 
424  remote_client.SendDetailedEstateData(invoice,
428  GetEstateFlags(),
429  sun,
433  estateOwner);
434  }
435 
436  private void sendEstateLists(IClientAPI remote_client, UUID invoice)
437  {
438  remote_client.SendEstateList(invoice,
439  (int)Constants.EstateAccessCodex.EstateManagers,
442 
443  remote_client.SendEstateList(invoice,
444  (int)Constants.EstateAccessCodex.AccessOptions,
447 
448  remote_client.SendEstateList(invoice,
449  (int)Constants.EstateAccessCodex.AllowedGroups,
452 
453  remote_client.SendBannedUserList(invoice,
454  Scene.RegionInfo.EstateSettings.EstateBans,
455  Scene.RegionInfo.EstateSettings.EstateID);
456  }
457 
458  private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor,
459  int matureLevel, bool restrictPushObject, bool allowParcelChanges)
460  {
461  if (blockTerraform)
462  Scene.RegionInfo.RegionSettings.BlockTerraform = true;
463  else
464  Scene.RegionInfo.RegionSettings.BlockTerraform = false;
465 
466  if (noFly)
467  Scene.RegionInfo.RegionSettings.BlockFly = true;
468  else
469  Scene.RegionInfo.RegionSettings.BlockFly = false;
470 
471  if (allowDamage)
472  Scene.RegionInfo.RegionSettings.AllowDamage = true;
473  else
474  Scene.RegionInfo.RegionSettings.AllowDamage = false;
475 
476  if (blockLandResell)
477  Scene.RegionInfo.RegionSettings.AllowLandResell = false;
478  else
479  Scene.RegionInfo.RegionSettings.AllowLandResell = true;
480 
481  if((byte)maxAgents <= Scene.RegionInfo.AgentCapacity)
482  Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents;
483  else
484  Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity;
485 
486  Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor;
487 
488  if (matureLevel <= 13)
489  Scene.RegionInfo.RegionSettings.Maturity = 0;
490  else if (matureLevel <= 21)
491  Scene.RegionInfo.RegionSettings.Maturity = 1;
492  else
493  Scene.RegionInfo.RegionSettings.Maturity = 2;
494 
495  if (restrictPushObject)
496  Scene.RegionInfo.RegionSettings.RestrictPushing = true;
497  else
498  Scene.RegionInfo.RegionSettings.RestrictPushing = false;
499 
500  if (allowParcelChanges)
501  Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true;
502  else
503  Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false;
504 
505  Scene.RegionInfo.RegionSettings.Save();
506  TriggerRegionInfoChange();
507 
508  sendRegionInfoPacketToAll();
509  }
510 
511  public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture)
512  {
513  if (texture == UUID.Zero)
514  return;
515 
516  switch (level)
517  {
518  case 0:
519  Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
520  break;
521  case 1:
522  Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
523  break;
524  case 2:
525  Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
526  break;
527  case 3:
528  Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
529  break;
530  }
531 
532  Scene.RegionInfo.RegionSettings.Save();
533  TriggerRegionInfoChange();
534  sendRegionInfoPacketToAll();
535  }
536 
537  public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
538  {
539  switch (corner)
540  {
541  case 0:
542  Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
543  Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
544  break;
545  case 1:
546  Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
547  Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
548  break;
549  case 2:
550  Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
551  Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
552  break;
553  case 3:
554  Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
555  Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
556  break;
557  }
558 
559  Scene.RegionInfo.RegionSettings.Save();
560  TriggerRegionInfoChange();
561  sendRegionHandshakeToAll();
562  sendRegionInfoPacketToAll();
563  }
564 
565  private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
566  {
567  // sendRegionHandshakeToAll();
568  }
569 
570  public void setRegionTerrainSettings(float WaterHeight,
571  float TerrainRaiseLimit, float TerrainLowerLimit,
572  bool UseEstateSun, bool UseFixedSun, float SunHour,
573  bool UseGlobal, bool EstateFixedSun, float EstateSunHour)
574  {
575  // Water Height
576  Scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight;
577 
578  // Terraforming limits
579  Scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit;
580  Scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit;
581 
582  // Time of day / fixed sun
583  Scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun;
584  Scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun;
585  Scene.RegionInfo.RegionSettings.SunPosition = SunHour;
586 
587  Scene.TriggerEstateSunUpdate();
588 
589  //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
590  //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
591 
592  sendRegionInfoPacketToAll();
593  Scene.RegionInfo.RegionSettings.Save();
594  TriggerRegionInfoChange();
595  }
596 
597  private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
598  {
599  if (!AllowRegionRestartFromClient)
600  {
601  remoteClient.SendAlertMessage("Region restart has been disabled on this simulator.");
602  return;
603  }
604 
605  IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>();
606  if (restartModule != null)
607  {
608  if (timeInSeconds == -1)
609  {
610  m_delayCount++;
611  if (m_delayCount > 3)
612  return;
613 
614  restartModule.DelayRestart(3600, "Restart delayed by region manager");
615  return;
616  }
617 
618  List<int> times = new List<int>();
619  while (timeInSeconds > 0)
620  {
621  times.Add(timeInSeconds);
622  if (timeInSeconds > 300)
623  timeInSeconds -= 120;
624  else if (timeInSeconds > 30)
625  timeInSeconds -= 30;
626  else
627  timeInSeconds -= 15;
628  }
629 
630  restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false);
631 
632  m_log.InfoFormat(
633  "User {0} requested restart of region {1} in {2} seconds",
634  remoteClient.Name, Scene.Name, times.Count != 0 ? times[0] : 0);
635  }
636  }
637 
638  private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
639  {
640 // m_log.DebugFormat(
641 // "[ESTATE MANAGEMENT MODULE]: Handling request from {0} to change estate covenant to {1}",
642 // remoteClient.Name, estateCovenantID);
643 
644  Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
645  Scene.RegionInfo.RegionSettings.CovenantChangedDateTime = Util.UnixTimeSinceEpoch();
646  Scene.RegionInfo.RegionSettings.Save();
647  TriggerRegionInfoChange();
648  }
649 
650  private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
651  {
652  // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
653 
655  return; // never process EO
656 
657  if ((estateAccessType & 4) != 0) // User add
658  {
659  if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
660  {
661  if ((estateAccessType & 1) != 0) // All estates
662  {
663  List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
664  EstateSettings estateSettings;
665 
666  foreach (int estateID in estateIDs)
667  {
668  if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
669  {
670  estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
671  estateSettings.AddEstateUser(user);
672  Scene.EstateDataService.StoreEstateSettings(estateSettings);
673  }
674  }
675  }
676 
677  Scene.RegionInfo.EstateSettings.AddEstateUser(user);
678  Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
679 
680  TriggerEstateInfoChange();
681  remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
682  }
683  else
684  {
685  remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
686  }
687 
688  }
689 
690  if ((estateAccessType & 8) != 0) // User remove
691  {
692  if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
693  {
694  if ((estateAccessType & 1) != 0) // All estates
695  {
696  List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
697  EstateSettings estateSettings;
698 
699  foreach (int estateID in estateIDs)
700  {
701  if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
702  {
703  estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
704  estateSettings.RemoveEstateUser(user);
705  Scene.EstateDataService.StoreEstateSettings(estateSettings);
706  }
707  }
708  }
709 
710  Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
711  Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
712 
713  TriggerEstateInfoChange();
714  remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AccessOptions, Scene.RegionInfo.EstateSettings.EstateAccess, Scene.RegionInfo.EstateSettings.EstateID);
715  }
716  else
717  {
718  remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
719  }
720  }
721 
722  if ((estateAccessType & 16) != 0) // Group add
723  {
724  if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
725  {
726  if ((estateAccessType & 1) != 0) // All estates
727  {
728  List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
729  EstateSettings estateSettings;
730 
731  foreach (int estateID in estateIDs)
732  {
733  if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
734  {
735  estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
736  estateSettings.AddEstateGroup(user);
737  Scene.EstateDataService.StoreEstateSettings(estateSettings);
738  }
739  }
740  }
741 
742  Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
743  Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
744 
745  TriggerEstateInfoChange();
746  remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
747  }
748  else
749  {
750  remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
751  }
752  }
753 
754  if ((estateAccessType & 32) != 0) // Group remove
755  {
756  if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
757  {
758  if ((estateAccessType & 1) != 0) // All estates
759  {
760  List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
761  EstateSettings estateSettings;
762 
763  foreach (int estateID in estateIDs)
764  {
765  if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
766  {
767  estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
768  estateSettings.RemoveEstateGroup(user);
769  Scene.EstateDataService.StoreEstateSettings(estateSettings);
770  }
771  }
772  }
773 
774  Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
775  Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
776 
777  TriggerEstateInfoChange();
778  remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.AllowedGroups, Scene.RegionInfo.EstateSettings.EstateGroups, Scene.RegionInfo.EstateSettings.EstateID);
779  }
780  else
781  {
782  remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
783  }
784  }
785 
786  if ((estateAccessType & 64) != 0) // Ban add
787  {
788  if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false))
789  {
790  EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
791 
792  bool alreadyInList = false;
793 
794  for (int i = 0; i < banlistcheck.Length; i++)
795  {
796  if (user == banlistcheck[i].BannedUserID)
797  {
798  alreadyInList = true;
799  break;
800  }
801 
802  }
803  if (!alreadyInList)
804  {
805 
806  if ((estateAccessType & 1) != 0) // All estates
807  {
808  List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
809  EstateSettings estateSettings;
810 
811  foreach (int estateID in estateIDs)
812  {
813  if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
814  {
815  EstateBan bitem = new EstateBan();
816 
817  bitem.BannedUserID = user;
818  bitem.EstateID = (uint)estateID;
819  bitem.BannedHostAddress = "0.0.0.0";
820  bitem.BannedHostIPMask = "0.0.0.0";
821 
822  estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
823  estateSettings.AddBan(bitem);
824  Scene.EstateDataService.StoreEstateSettings(estateSettings);
825  }
826  }
827  }
828 
829  EstateBan item = new EstateBan();
830 
831  item.BannedUserID = user;
832  item.EstateID = Scene.RegionInfo.EstateSettings.EstateID;
833  item.BannedHostAddress = "0.0.0.0";
834  item.BannedHostIPMask = "0.0.0.0";
835 
836  Scene.RegionInfo.EstateSettings.AddBan(item);
837  Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
838 
839  TriggerEstateInfoChange();
840 
841  ScenePresence s = Scene.GetScenePresence(user);
842  if (s != null)
843  {
844  if (!s.IsChildAgent)
845  {
847  {
848  s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
849  Scene.CloseAgent(s.UUID, false);
850  }
851  }
852  }
853 
854  }
855  else
856  {
857  remote_client.SendAlertMessage("User is already on the region ban list");
858  }
859  //Scene.RegionInfo.regionBanlist.Add(Manager(user);
860  remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
861  }
862  else
863  {
864  remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
865  }
866  }
867 
868  if ((estateAccessType & 128) != 0) // Ban remove
869  {
870  if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false))
871  {
872  EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
873 
874  bool alreadyInList = false;
875  EstateBan listitem = null;
876 
877  for (int i = 0; i < banlistcheck.Length; i++)
878  {
879  if (user == banlistcheck[i].BannedUserID)
880  {
881  alreadyInList = true;
882  listitem = banlistcheck[i];
883  break;
884  }
885  }
886 
887  if (alreadyInList && listitem != null)
888  {
889  if ((estateAccessType & 1) != 0) // All estates
890  {
891  List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
892  EstateSettings estateSettings;
893 
894  foreach (int estateID in estateIDs)
895  {
896  if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
897  {
898  estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
899  estateSettings.RemoveBan(user);
900  Scene.EstateDataService.StoreEstateSettings(estateSettings);
901  }
902  }
903  }
904 
905  Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
906  Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
907 
908  TriggerEstateInfoChange();
909  }
910  else
911  {
912  remote_client.SendAlertMessage("User is not on the region ban list");
913  }
914 
915  //Scene.RegionInfo.regionBanlist.Add(Manager(user);
916  remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
917  }
918  else
919  {
920  remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
921  }
922  }
923 
924  if ((estateAccessType & 256) != 0) // Manager add
925  {
926  if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
927  {
928  if ((estateAccessType & 1) != 0) // All estates
929  {
930  List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
931  EstateSettings estateSettings;
932 
933  foreach (int estateID in estateIDs)
934  {
935  if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
936  {
937  estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
938  estateSettings.AddEstateManager(user);
939  Scene.EstateDataService.StoreEstateSettings(estateSettings);
940  }
941  }
942  }
943 
944  Scene.RegionInfo.EstateSettings.AddEstateManager(user);
945  Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
946 
947  TriggerEstateInfoChange();
948  remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
949  }
950  else
951  {
952  remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
953  }
954  }
955 
956  if ((estateAccessType & 512) != 0) // Manager remove
957  {
958  if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true))
959  {
960  if ((estateAccessType & 1) != 0) // All estates
961  {
962  List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
963  EstateSettings estateSettings;
964 
965  foreach (int estateID in estateIDs)
966  {
967  if (estateID != Scene.RegionInfo.EstateSettings.EstateID)
968  {
969  estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
970  estateSettings.RemoveEstateManager(user);
971  Scene.EstateDataService.StoreEstateSettings(estateSettings);
972  }
973  }
974  }
975 
976  Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
977  Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
978 
979  TriggerEstateInfoChange();
980  remote_client.SendEstateList(invoice, (int)Constants.EstateAccessCodex.EstateManagers, Scene.RegionInfo.EstateSettings.EstateManagers, Scene.RegionInfo.EstateSettings.EstateID);
981  }
982  else
983  {
984  remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
985  }
986  }
987  }
988 
989  public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
990  {
991  SceneObjectPart part;
992 
993  switch (cmd)
994  {
995  case "info ui":
996  break;
997 
998  case "connect":
999  // Add the Telehub
1000  part = Scene.GetSceneObjectPart((uint)param1);
1001  if (part == null)
1002  return;
1003  SceneObjectGroup grp = part.ParentGroup;
1004 
1005  m_Telehub.Connect(grp);
1006  break;
1007 
1008  case "delete":
1009  // Disconnect Telehub
1010  m_Telehub.Disconnect();
1011  break;
1012 
1013  case "spawnpoint add":
1014  // Add SpawnPoint to the Telehub
1015  part = Scene.GetSceneObjectPart((uint)param1);
1016  if (part == null)
1017  return;
1018  m_Telehub.AddSpawnPoint(part.AbsolutePosition);
1019  break;
1020 
1021  case "spawnpoint remove":
1022  // Remove SpawnPoint from Telehub
1023  m_Telehub.RemoveSpawnPoint((int)param1);
1024  break;
1025 
1026  default:
1027  break;
1028  }
1029 
1030  if (client != null)
1031  SendTelehubInfo(client);
1032  }
1033 
1034  private void SendSimulatorBlueBoxMessage(
1035  IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
1036  {
1037  IDialogModule dm = Scene.RequestModuleInterface<IDialogModule>();
1038 
1039  if (dm != null)
1040  dm.SendNotificationToUsersInRegion(senderID, senderName, message);
1041  }
1042 
1043  private void SendEstateBlueBoxMessage(
1044  IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
1045  {
1046  TriggerEstateMessage(senderID, senderName, message);
1047  }
1048 
1049  private void handleEstateDebugRegionRequest(
1050  IClientAPI remote_client, UUID invoice, UUID senderID,
1051  bool disableScripts, bool disableCollisions, bool disablePhysics)
1052  {
1053  Scene.RegionInfo.RegionSettings.DisablePhysics = disablePhysics;
1054  Scene.RegionInfo.RegionSettings.DisableScripts = disableScripts;
1055  Scene.RegionInfo.RegionSettings.DisableCollisions = disableCollisions;
1056  Scene.RegionInfo.RegionSettings.Save();
1057  TriggerRegionInfoChange();
1058 
1059  ISceneCommandsModule scm = Scene.RequestModuleInterface<ISceneCommandsModule>();
1060 
1061  if (scm != null)
1062  {
1063  scm.SetSceneDebugOptions(
1064  new Dictionary<string, string>() {
1065  { "scripting", (!disableScripts).ToString() },
1066  { "collisions", (!disableCollisions).ToString() },
1067  { "physics", (!disablePhysics).ToString() }
1068  }
1069  );
1070  }
1071  }
1072 
1073  private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey)
1074  {
1075  if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
1076  return;
1077 
1078  if (prey != UUID.Zero)
1079  {
1080  ScenePresence s = Scene.GetScenePresence(prey);
1081  if (s != null)
1082  {
1084  {
1085  s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
1086  Scene.CloseAgent(s.UUID, false);
1087  }
1088  }
1089  }
1090  }
1091 
1092  private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
1093  {
1094  if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
1095  return;
1096 
1097  Scene.ForEachRootClient(delegate(IClientAPI client)
1098  {
1099  if (client.AgentId != senderID)
1100  {
1101  // make sure they are still there, we could be working down a long list
1102  // Also make sure they are actually in the region
1103  ScenePresence p;
1104  if(Scene.TryGetScenePresence(client.AgentId, out p))
1105  {
1106  if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
1107  {
1108  p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
1109  Scene.CloseAgent(p.UUID, false);
1110  }
1111  }
1112  }
1113  });
1114  }
1115 
1116  private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
1117  {
1118  lock (this)
1119  {
1120  if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID))
1121  {
1122  remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
1123  remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
1124  TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
1125 
1126  TerrainUploader = null;
1127  remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
1128  }
1129  }
1130  }
1131 
1132  private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
1133  {
1134  lock (this)
1135  {
1136  remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
1137  remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
1138  TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
1139 
1140  TerrainUploader = null;
1141  }
1142 
1143  m_log.DebugFormat("[CLIENT]: Terrain upload from {0} to {1} complete.", remoteClient.Name, Scene.Name);
1144  remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
1145 
1146  ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
1147 
1148  if (terr != null)
1149  {
1150  try
1151  {
1152  using (MemoryStream terrainStream = new MemoryStream(terrainData))
1153  terr.LoadFromStream(filename, terrainStream);
1154 
1155  FileInfo x = new FileInfo(filename);
1156  remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear.");
1157  }
1158  catch (IOException e)
1159  {
1160  m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
1161  remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space.");
1162 
1163  return;
1164  }
1165  catch (SecurityException e)
1166  {
1167  m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
1168  remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
1169 
1170  return;
1171  }
1172  catch (UnauthorizedAccessException e)
1173  {
1174  m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
1175  remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
1176 
1177  return;
1178  }
1179  catch (Exception e)
1180  {
1181  m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
1182  remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
1183  }
1184  }
1185  else
1186  {
1187  remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
1188  }
1189  }
1190 
1191  private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
1192  {
1193  lock (this)
1194  {
1195  if (TerrainUploader == null)
1196  {
1197  m_log.DebugFormat(
1198  "[TERRAIN]: Started receiving terrain upload for region {0} from {1}",
1199  Scene.Name, remote_client.Name);
1200 
1201  TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
1202  remote_client.OnXferReceive += TerrainUploader.XferReceive;
1203  remote_client.OnAbortXfer += AbortTerrainXferHandler;
1204  TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
1205  TerrainUploader.RequestStartXfer(remote_client);
1206  }
1207  else
1208  {
1209  remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
1210  }
1211  }
1212  }
1213 
1214  private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
1215  {
1216  // Save terrain here
1217  ITerrainModule terr = Scene.RequestModuleInterface<ITerrainModule>();
1218 
1219  if (terr != null)
1220  {
1221 // m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + Scene.RegionInfo.RegionName);
1222  if (File.Exists(Util.dataDir() + "/terrain.raw"))
1223  {
1224  File.Delete(Util.dataDir() + "/terrain.raw");
1225  }
1226  terr.SaveToFile(Util.dataDir() + "/terrain.raw");
1227 
1228  FileStream input = new FileStream(Util.dataDir() + "/terrain.raw", FileMode.Open);
1229  byte[] bdata = new byte[input.Length];
1230  input.Read(bdata, 0, (int)input.Length);
1231  remote_client.SendAlertMessage("Terrain file written, starting download...");
1232  Scene.XferManager.AddNewFile("terrain.raw", bdata);
1233 
1234  m_log.DebugFormat("[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name);
1235 
1236  remote_client.SendInitiateDownload("terrain.raw", clientFileName);
1237  }
1238  }
1239 
1240  private void HandleRegionInfoRequest(IClientAPI remote_client)
1241  {
1243  args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
1244  args.estateID = Scene.RegionInfo.EstateSettings.EstateID;
1245  args.maxAgents = (byte)Scene.RegionInfo.RegionSettings.AgentLimit;
1246  args.objectBonusFactor = (float)Scene.RegionInfo.RegionSettings.ObjectBonus;
1247  args.parentEstateID = Scene.RegionInfo.EstateSettings.ParentEstateID;
1248  args.pricePerMeter = Scene.RegionInfo.EstateSettings.PricePerMeter;
1249  args.redirectGridX = Scene.RegionInfo.EstateSettings.RedirectGridX;
1250  args.redirectGridY = Scene.RegionInfo.EstateSettings.RedirectGridY;
1251  args.regionFlags = GetRegionFlags();
1252  args.simAccess = Scene.RegionInfo.AccessLevel;
1253  args.sunHour = (float)Scene.RegionInfo.RegionSettings.SunPosition;
1254  args.terrainLowerLimit = (float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit;
1255  args.terrainRaiseLimit = (float)Scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
1257  args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
1258  args.simName = Scene.RegionInfo.RegionName;
1259  args.regionType = Scene.RegionInfo.RegionType;
1260 
1261  remote_client.SendRegionInfoToEstateMenu(args);
1262  }
1263 
1264  private void HandleEstateCovenantRequest(IClientAPI remote_client)
1265  {
1266  remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
1267  }
1268 
1269  private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
1270  {
1271  if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
1272  return;
1273 
1274  Dictionary<uint, float> sceneData = null;
1275 
1276  if (reportType == 1)
1277  {
1278  sceneData = Scene.PhysicsScene.GetTopColliders();
1279  }
1280  else if (reportType == 0)
1281  {
1282  IScriptModule scriptModule = Scene.RequestModuleInterface<IScriptModule>();
1283 
1284  if (scriptModule != null)
1285  sceneData = scriptModule.GetObjectScriptsExecutionTimes();
1286  }
1287 
1288  List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
1289  if (sceneData != null)
1290  {
1291  var sortedSceneData
1292  = sceneData.Select(
1293  item => new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) });
1294 
1295  sortedSceneData.OrderBy(item => item.Measurement);
1296 
1297  int items = 0;
1298 
1299  foreach (var entry in sortedSceneData)
1300  {
1301  // The object may have been deleted since we received the data.
1302  if (entry.Part == null)
1303  continue;
1304 
1305  // Don't show scripts that haven't executed or where execution time is below one microsecond in
1306  // order to produce a more readable report.
1307  if (entry.Measurement < 0.001)
1308  continue;
1309 
1310  items++;
1311  SceneObjectGroup so = entry.Part.ParentGroup;
1312 
1314  lsri.LocationX = so.AbsolutePosition.X;
1315  lsri.LocationY = so.AbsolutePosition.Y;
1316  lsri.LocationZ = so.AbsolutePosition.Z;
1317  lsri.Score = entry.Measurement;
1318  lsri.TaskID = so.UUID;
1319  lsri.TaskLocalID = so.LocalId;
1320  lsri.TaskName = entry.Part.Name;
1321  lsri.OwnerName = UserManager.GetUserName(so.OwnerID);
1322 
1323  if (filter.Length != 0)
1324  {
1325  if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
1326  {
1327  }
1328  else
1329  {
1330  continue;
1331  }
1332  }
1333 
1334  SceneReport.Add(lsri);
1335 
1336  if (items >= 100)
1337  break;
1338  }
1339  }
1340 
1341  remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
1342  }
1343 
1344  #endregion
1345 
1346  #region Outgoing Packets
1347 
1349  {
1350  Scene.ForEachRootClient(delegate(IClientAPI client)
1351  {
1352  HandleRegionInfoRequest(client);
1353  });
1354  }
1355 
1356  public void sendRegionHandshake(IClientAPI remoteClient)
1357  {
1359 
1360  args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(remoteClient.AgentId);
1362  args.isEstateManager = true;
1363 
1364  args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
1365  args.terrainStartHeight0 = (float)Scene.RegionInfo.RegionSettings.Elevation1SW;
1366  args.terrainHeightRange0 = (float)Scene.RegionInfo.RegionSettings.Elevation2SW;
1367  args.terrainStartHeight1 = (float)Scene.RegionInfo.RegionSettings.Elevation1NW;
1368  args.terrainHeightRange1 = (float)Scene.RegionInfo.RegionSettings.Elevation2NW;
1369  args.terrainStartHeight2 = (float)Scene.RegionInfo.RegionSettings.Elevation1SE;
1370  args.terrainHeightRange2 = (float)Scene.RegionInfo.RegionSettings.Elevation2SE;
1371  args.terrainStartHeight3 = (float)Scene.RegionInfo.RegionSettings.Elevation1NE;
1372  args.terrainHeightRange3 = (float)Scene.RegionInfo.RegionSettings.Elevation2NE;
1373  args.simAccess = Scene.RegionInfo.AccessLevel;
1374  args.waterHeight = (float)Scene.RegionInfo.RegionSettings.WaterHeight;
1375  args.regionFlags = GetRegionFlags();
1376  args.regionName = Scene.RegionInfo.RegionName;
1377  args.SimOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
1378 
1379  args.terrainBase0 = UUID.Zero;
1380  args.terrainBase1 = UUID.Zero;
1381  args.terrainBase2 = UUID.Zero;
1382  args.terrainBase3 = UUID.Zero;
1383  args.terrainDetail0 = Scene.RegionInfo.RegionSettings.TerrainTexture1;
1384  args.terrainDetail1 = Scene.RegionInfo.RegionSettings.TerrainTexture2;
1385  args.terrainDetail2 = Scene.RegionInfo.RegionSettings.TerrainTexture3;
1386  args.terrainDetail3 = Scene.RegionInfo.RegionSettings.TerrainTexture4;
1387 
1388 // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 1 {0} for region {1}", args.terrainDetail0, Scene.RegionInfo.RegionName);
1389 // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 2 {0} for region {1}", args.terrainDetail1, Scene.RegionInfo.RegionName);
1390 // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 3 {0} for region {1}", args.terrainDetail2, Scene.RegionInfo.RegionName);
1391 // m_log.DebugFormat("[ESTATE MANAGEMENT MODULE]: Sending terrain texture 4 {0} for region {1}", args.terrainDetail3, Scene.RegionInfo.RegionName);
1392 
1393  remoteClient.SendRegionHandshake(Scene.RegionInfo,args);
1394  }
1395 
1396  public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
1397  {
1398  if (parms2 == 0)
1399  {
1400  Scene.RegionInfo.EstateSettings.UseGlobalTime = true;
1401  Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
1402  }
1403  else
1404  {
1405  Scene.RegionInfo.EstateSettings.UseGlobalTime = false;
1406  Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
1407  // Warning: FixedSun should be set to True, otherwise this sun position won't be used.
1408  }
1409 
1410  if ((parms1 & 0x00000010) != 0)
1412  else
1414 
1415  if ((parms1 & 0x00008000) != 0)
1417  else
1419 
1420  if ((parms1 & 0x10000000) != 0)
1422  else
1424 
1425  if ((parms1 & 0x00100000) != 0)
1427  else
1429 
1430  if ((parms1 & 0x00800000) != 0)
1432  else
1434 
1435  if ((parms1 & 0x01000000) != 0)
1437  else
1439 
1440  if ((parms1 & 0x02000000) != 0)
1442  else
1444 
1445  if ((parms1 & 0x40000000) != 0)
1447  else
1449 
1451  TriggerEstateInfoChange();
1452 
1453  Scene.TriggerEstateSunUpdate();
1454 
1455  sendDetailedEstateData(remoteClient, invoice);
1456  }
1457 
1458  #endregion
1459 
1460  #region Other Functions
1461 
1462  public void changeWaterHeight(float height)
1463  {
1464  setRegionTerrainSettings(height,
1473 
1474  sendRegionInfoPacketToAll();
1475  }
1476 
1477 
1478  #endregion
1479 
1480  private void EventManager_OnNewClient(IClientAPI client)
1481  {
1482  client.OnDetailedEstateDataRequest += clientSendDetailedEstateData;
1483  client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
1484 // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
1485  client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture;
1486  client.OnSetEstateTerrainTextureHeights += setEstateTerrainTextureHeights;
1487  client.OnCommitEstateTerrainTextureRequest += handleCommitEstateTerrainTextureRequest;
1488  client.OnSetRegionTerrainSettings += setRegionTerrainSettings;
1489  client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
1490  client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
1491  client.OnEstateChangeInfo += handleEstateChangeInfo;
1492  client.OnEstateManageTelehub += HandleOnEstateManageTelehub;
1493  client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
1494  client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
1495  client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
1496  client.OnEstateDebugRegionRequest += handleEstateDebugRegionRequest;
1497  client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest;
1498  client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest;
1499  client.OnRequestTerrain += handleTerrainRequest;
1500  client.OnUploadTerrain += handleUploadTerrain;
1501 
1502  client.OnRegionInfoRequest += HandleRegionInfoRequest;
1503  client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
1504  client.OnLandStatRequest += HandleLandStatRequest;
1505  sendRegionHandshake(client);
1506  }
1507 
1508 
1509  public uint GetEstateFlags()
1510  {
1511  RegionFlags flags = RegionFlags.None;
1512 
1514  flags |= RegionFlags.SunFixed;
1516  flags |= (RegionFlags.PublicAllowed |
1517  RegionFlags.ExternallyVisible);
1519  flags |= RegionFlags.AllowVoice;
1521  flags |= RegionFlags.AllowDirectTeleport;
1523  flags |= RegionFlags.DenyAnonymous;
1525  flags |= RegionFlags.DenyIdentified;
1527  flags |= RegionFlags.DenyTransacted;
1529  flags |= RegionFlags.AbuseEmailToEstateOwner;
1531  flags |= RegionFlags.BlockDwell;
1533  flags |= RegionFlags.EstateSkipScripts;
1535  flags |= RegionFlags.ResetHomeOnTeleport;
1537  flags |= RegionFlags.TaxFree;
1539  flags |= RegionFlags.AllowLandmark;
1541  flags |= RegionFlags.AllowParcelChanges;
1543  flags |= RegionFlags.AllowSetHome;
1545  flags |= (RegionFlags)(1 << 30);
1546 
1547  return (uint)flags;
1548  }
1549 
1550  public void TriggerEstateMessage(UUID fromID, string fromName, string message)
1551  {
1552  MessageDelegate onmessage = OnEstateMessage;
1553 
1554  if (onmessage != null)
1555  onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
1556  }
1557 
1558 
1559  private void SendTelehubInfo(IClientAPI client)
1560  {
1561  RegionSettings settings =
1563 
1564  SceneObjectGroup telehub = null;
1565  if (settings.TelehubObject != UUID.Zero &&
1566  (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
1567  {
1568  List<Vector3> spawnPoints = new List<Vector3>();
1569 
1570  foreach (SpawnPoint sp in settings.SpawnPoints())
1571  {
1572  spawnPoints.Add(sp.GetLocation(Vector3.Zero, Quaternion.Identity));
1573  }
1574 
1575  client.SendTelehubInfo(settings.TelehubObject,
1576  telehub.Name,
1577  telehub.AbsolutePosition,
1578  telehub.GroupRotation,
1579  spawnPoints);
1580  }
1581  else
1582  {
1583  client.SendTelehubInfo(UUID.Zero,
1584  String.Empty,
1585  Vector3.Zero,
1586  Quaternion.Identity,
1587  new List<Vector3>());
1588  }
1589  }
1590  }
1591 }
1592 
void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
delegate void MessageDelegate(UUID regionID, UUID fromID, string fromName, string message)
IEstateDataService EstateDataService
Definition: Scene.cs:599
EstateSettings EstateSettings
Definition: RegionInfo.cs:275
bool LinkRegion(UUID regionID, int estateID)
Link a region to an estate.
OpenSim.Framework.RegionInfo RegionInfo
bool IsTerrainXfer(ulong xferID)
Returns whether the transfer ID is being used for a terrain transfer.
OpenSim.Framework.RegionSettings RegionSettings
void setRegionTerrainSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit, bool UseEstateSun, bool UseFixedSun, float SunHour, bool UseGlobal, bool EstateFixedSun, float EstateSunHour)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
RegionSettings RegionSettings
Definition: RegionInfo.cs:290
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void TriggerEstateMessage(UUID fromID, string fromName, string message)
System.Timers.Timer Timer
void sendRegionHandshakeToAll()
Tell all clients about the current state of the region (terrain textures, water height, etc.).
SceneObjectGroup GetSceneObjectGroup(UUID fullID)
Get a group via its UUID
Definition: Scene.cs:5299
RegionFlags
Region flags used internally by OpenSimulator to store installation specific information about region...
Definition: RegionFlags.cs:40
void LoadFromStream(string filename, Stream stream)
Load a terrain from a stream.
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
void setEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture)
void TriggerRegionInfoChange()
Fires the OnRegionInfoChange event.
override bool TryGetScenePresence(UUID agentID, out ScenePresence sp)
Try to get a scene presence from the scene
Definition: Scene.cs:5401
void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
void StoreEstateSettings(EstateSettings es)
Store estate settings.
UUID TelehubObject
Connected Telehub object
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
bool CanIssueEstateCommand(UUID user, bool ownerCommand)
delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
List< SpawnPoint > SpawnPoints()
delegate void ChangeDelegate(UUID regionID)
OpenMetaverse.RegionFlags RegionFlags
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
This maintains the relationship between a UUID and a user name.
virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
Teleport an avatar to their home region
Definition: Scene.cs:3607
void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue)