29 using System.Collections;
30 using System.Collections.Generic;
33 using System.Reflection;
34 using System.Security;
40 using OpenSim.Framework;
41 using OpenSim.Region.Framework.Interfaces;
42 using OpenSim.Region.Framework.Scenes;
43 using OpenSim.Services.Interfaces;
48 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"EstateManagementModule")]
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private Timer m_regionChangeTimer =
new Timer();
62 public bool AllowRegionRestartFromClient {
get; set; }
71 private int m_delayCount = 0;
73 #region Region Module interface
75 public string Name {
get {
return "EstateManagementModule"; } }
77 public Type ReplaceableInterface {
get {
return null; } }
81 AllowRegionRestartFromClient =
true;
83 IConfig config = source.Configs[
"EstateManagement"];
86 AllowRegionRestartFromClient = config.GetBoolean(
"AllowRegionRestartFromClient",
true);
93 Scene.EventManager.OnNewClient += EventManager_OnNewClient;
94 Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
99 m_commands.Initialise();
101 m_regionChangeTimer.Interval = 10000;
102 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
103 m_regionChangeTimer.AutoReset =
false;
112 scene.TriggerEstateSunUpdate();
124 #region IEstateModule Functions
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;
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;
187 List<UUID> ems =
new List<UUID>(Scene.RegionInfo.EstateSettings.EstateManagers);
188 if (ems.Contains(avatarID))
196 Scene.ForEachClient(sendRegionHandshake);
217 m_regionChangeTimer.Stop();
218 m_regionChangeTimer.Start();
228 setEstateTerrainBaseTexture(null, level, texture);
229 sendRegionHandshakeToAll();
234 setEstateTerrainTextureHeights(null, corner, lowValue, highValue);
241 if (TerrainUploader == null)
244 return TerrainUploader.XferID == xferID;
253 EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
256 response = String.Format(
"No estate found with ID {0}", estateID);
260 response = String.Format(
"Estate already belongs to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName);
264 dbSettings.EstateOwner = account.PrincipalID;
265 Scene.EstateDataService.StoreEstateSettings(dbSettings);
266 response = String.Empty;
269 m_log.InfoFormat(
"[ESTATE]: Estate Owner for {0} changed to {1} ({2} {3})", dbSettings.EstateName,
270 account.PrincipalID, account.FirstName, account.LastName);
273 List<UUID> regions = Scene.GetEstateRegions(estateID);
274 UUID regionId = (regions.Count() > 0) ? regions.ElementAt(0) :
UUID.Zero;
275 if (regionId !=
UUID.Zero)
292 EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
296 response = String.Format(
"No estate found with ID {0}", estateID);
300 response = String.Format(
"Estate {0} is already named \"{1}\"", estateID, newName);
304 List<int> estates = Scene.EstateDataService.GetEstates(newName);
305 if (estates.Count() > 0)
307 response = String.Format(
"An estate named \"{0}\" already exists.", newName);
311 string oldName = dbSettings.EstateName;
312 dbSettings.EstateName = newName;
313 Scene.EstateDataService.StoreEstateSettings(dbSettings);
314 response = String.Empty;
317 m_log.InfoFormat(
"[ESTATE]: Estate {0} renamed from \"{1}\" to \"{2}\"", estateID, oldName, newName);
320 List<UUID> regions = Scene.GetEstateRegions(estateID);
321 UUID regionId = (regions.Count() > 0) ? regions.ElementAt(0) :
UUID.Zero;
322 if (regionId !=
UUID.Zero)
340 response = String.Format(
"\"{0}\" is already part of estate {1}", regionInfo.RegionName, estateID);
345 EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
348 response = String.Format(
"No estate found with ID {0}", estateID);
353 m_log.InfoFormat(
"[ESTATE]: Region {0} ({1}) moved to Estate {2} ({3}).", regionInfo.RegionID, regionInfo.RegionName, estateID, dbSettings.EstateName);
361 response = String.Empty;
365 response = String.Format(
"Could not move \"{0}\" to estate {1}", regionInfo.RegionName, estateID);
374 if (
string.IsNullOrEmpty(estateName))
376 response =
"No estate name specified.";
380 List<int> estates = Scene.EstateDataService.GetEstates(estateName);
381 if (estates.Count() > 0)
383 response = String.Format(
"An estate named \"{0}\" already exists.", estateName);
387 EstateSettings settings = Scene.EstateDataService.CreateNewEstate();
388 if (settings == null)
389 response = String.Format(
"Unable to create estate \"{0}\" at this simulator", estateName);
392 settings.EstateOwner = ownerID;
393 settings.EstateName = estateName;
394 Scene.EstateDataService.StoreEstateSettings(settings);
395 response = String.Empty;
404 #region Packet Data Responders
406 private void clientSendDetailedEstateData(
IClientAPI remote_client, UUID invoice)
408 sendDetailedEstateData(remote_client, invoice);
409 sendEstateLists(remote_client, invoice);
412 private void sendDetailedEstateData(
IClientAPI remote_client, UUID invoice)
419 estateOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
422 estateOwner = remote_client.
AgentId;
436 private void sendEstateLists(
IClientAPI remote_client, UUID invoice)
438 remote_client.SendEstateList(invoice,
443 remote_client.SendEstateList(invoice,
448 remote_client.SendEstateList(invoice,
453 remote_client.SendBannedUserList(invoice,
454 Scene.RegionInfo.EstateSettings.EstateBans,
455 Scene.RegionInfo.EstateSettings.EstateID);
458 private void estateSetRegionInfoHandler(
bool blockTerraform,
bool noFly,
bool allowDamage,
bool blockLandResell,
int maxAgents,
float objectBonusFactor,
459 int matureLevel,
bool restrictPushObject,
bool allowParcelChanges)
462 Scene.RegionInfo.RegionSettings.BlockTerraform =
true;
464 Scene.RegionInfo.RegionSettings.BlockTerraform =
false;
467 Scene.RegionInfo.RegionSettings.BlockFly =
true;
469 Scene.RegionInfo.RegionSettings.BlockFly =
false;
472 Scene.RegionInfo.RegionSettings.AllowDamage =
true;
474 Scene.RegionInfo.RegionSettings.AllowDamage =
false;
477 Scene.RegionInfo.RegionSettings.AllowLandResell =
false;
479 Scene.RegionInfo.RegionSettings.AllowLandResell =
true;
482 Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents;
484 Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity;
486 Scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor;
488 if (matureLevel <= 13)
489 Scene.RegionInfo.RegionSettings.Maturity = 0;
490 else if (matureLevel <= 21)
491 Scene.RegionInfo.RegionSettings.Maturity = 1;
493 Scene.RegionInfo.RegionSettings.Maturity = 2;
495 if (restrictPushObject)
496 Scene.RegionInfo.RegionSettings.RestrictPushing =
true;
498 Scene.RegionInfo.RegionSettings.RestrictPushing =
false;
500 if (allowParcelChanges)
501 Scene.RegionInfo.RegionSettings.AllowLandJoinDivide =
true;
503 Scene.RegionInfo.RegionSettings.AllowLandJoinDivide =
false;
505 Scene.RegionInfo.RegionSettings.Save();
506 TriggerRegionInfoChange();
508 sendRegionInfoPacketToAll();
513 if (texture ==
UUID.Zero)
519 Scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
522 Scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
525 Scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
528 Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
532 Scene.RegionInfo.RegionSettings.Save();
533 TriggerRegionInfoChange();
534 sendRegionInfoPacketToAll();
542 Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
543 Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
546 Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
547 Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
550 Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
551 Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
554 Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
555 Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
559 Scene.RegionInfo.RegionSettings.Save();
560 TriggerRegionInfoChange();
561 sendRegionHandshakeToAll();
562 sendRegionInfoPacketToAll();
565 private void handleCommitEstateTerrainTextureRequest(
IClientAPI remoteClient)
571 float TerrainRaiseLimit,
float TerrainLowerLimit,
572 bool UseEstateSun,
bool UseFixedSun,
float SunHour,
573 bool UseGlobal,
bool EstateFixedSun,
float EstateSunHour)
576 Scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight;
579 Scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit;
580 Scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit;
583 Scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun;
584 Scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun;
585 Scene.RegionInfo.RegionSettings.SunPosition = SunHour;
587 Scene.TriggerEstateSunUpdate();
592 sendRegionInfoPacketToAll();
593 Scene.RegionInfo.RegionSettings.Save();
594 TriggerRegionInfoChange();
597 private void handleEstateRestartSimRequest(
IClientAPI remoteClient,
int timeInSeconds)
599 if (!AllowRegionRestartFromClient)
601 remoteClient.SendAlertMessage(
"Region restart has been disabled on this simulator.");
606 if (restartModule != null)
608 if (timeInSeconds == -1)
611 if (m_delayCount > 3)
614 restartModule.DelayRestart(3600,
"Restart delayed by region manager");
618 List<int> times =
new List<int>();
619 while (timeInSeconds > 0)
621 times.Add(timeInSeconds);
622 if (timeInSeconds > 300)
623 timeInSeconds -= 120;
624 else if (timeInSeconds > 30)
630 restartModule.ScheduleRestart(UUID.Zero,
"Region will restart in {0}", times.ToArray(),
false);
633 "User {0} requested restart of region {1} in {2} seconds",
634 remoteClient.Name, Scene.Name, times.Count != 0 ? times[0] : 0);
638 private void handleChangeEstateCovenantRequest(
IClientAPI remoteClient, UUID estateCovenantID)
644 Scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
645 Scene.RegionInfo.RegionSettings.CovenantChangedDateTime = Util.UnixTimeSinceEpoch();
646 Scene.RegionInfo.RegionSettings.Save();
647 TriggerRegionInfoChange();
650 private void handleEstateAccessDeltaRequest(
IClientAPI remote_client, UUID invoice,
int estateAccessType, UUID user)
657 if ((estateAccessType & 4) != 0)
661 if ((estateAccessType & 1) != 0)
663 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
666 foreach (
int estateID
in estateIDs)
670 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
671 estateSettings.AddEstateUser(user);
672 Scene.EstateDataService.StoreEstateSettings(estateSettings);
677 Scene.RegionInfo.EstateSettings.AddEstateUser(user);
678 Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
680 TriggerEstateInfoChange();
685 remote_client.SendAlertMessage(
"Method EstateAccessDelta Failed, you don't have permissions");
690 if ((estateAccessType & 8) != 0)
694 if ((estateAccessType & 1) != 0)
696 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
699 foreach (
int estateID
in estateIDs)
703 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
704 estateSettings.RemoveEstateUser(user);
705 Scene.EstateDataService.StoreEstateSettings(estateSettings);
710 Scene.RegionInfo.EstateSettings.RemoveEstateUser(user);
711 Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
713 TriggerEstateInfoChange();
718 remote_client.SendAlertMessage(
"Method EstateAccessDelta Failed, you don't have permissions");
722 if ((estateAccessType & 16) != 0)
726 if ((estateAccessType & 1) != 0)
728 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
731 foreach (
int estateID
in estateIDs)
735 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
736 estateSettings.AddEstateGroup(user);
737 Scene.EstateDataService.StoreEstateSettings(estateSettings);
742 Scene.RegionInfo.EstateSettings.AddEstateGroup(user);
743 Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
745 TriggerEstateInfoChange();
750 remote_client.SendAlertMessage(
"Method EstateAccessDelta Failed, you don't have permissions");
754 if ((estateAccessType & 32) != 0)
758 if ((estateAccessType & 1) != 0)
760 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
763 foreach (
int estateID
in estateIDs)
767 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
768 estateSettings.RemoveEstateGroup(user);
769 Scene.EstateDataService.StoreEstateSettings(estateSettings);
774 Scene.RegionInfo.EstateSettings.RemoveEstateGroup(user);
775 Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
777 TriggerEstateInfoChange();
782 remote_client.SendAlertMessage(
"Method EstateAccessDelta Failed, you don't have permissions");
786 if ((estateAccessType & 64) != 0)
790 EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
792 bool alreadyInList =
false;
794 for (
int i = 0; i < banlistcheck.Length; i++)
796 if (user == banlistcheck[i].BannedUserID)
798 alreadyInList =
true;
806 if ((estateAccessType & 1) != 0)
808 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
811 foreach (
int estateID
in estateIDs)
817 bitem.BannedUserID = user;
818 bitem.EstateID = (uint)estateID;
819 bitem.BannedHostAddress =
"0.0.0.0";
820 bitem.BannedHostIPMask =
"0.0.0.0";
822 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
823 estateSettings.AddBan(bitem);
824 Scene.EstateDataService.StoreEstateSettings(estateSettings);
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";
836 Scene.RegionInfo.EstateSettings.AddBan(item);
837 Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
839 TriggerEstateInfoChange();
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);
857 remote_client.SendAlertMessage(
"User is already on the region ban list");
860 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
864 remote_client.SendAlertMessage(
"Method EstateAccessDelta Failed, you don't have permissions");
868 if ((estateAccessType & 128) != 0)
872 EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans;
874 bool alreadyInList =
false;
877 for (
int i = 0; i < banlistcheck.Length; i++)
879 if (user == banlistcheck[i].BannedUserID)
881 alreadyInList =
true;
882 listitem = banlistcheck[i];
887 if (alreadyInList && listitem != null)
889 if ((estateAccessType & 1) != 0)
891 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
894 foreach (
int estateID
in estateIDs)
898 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
899 estateSettings.RemoveBan(user);
900 Scene.EstateDataService.StoreEstateSettings(estateSettings);
905 Scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
906 Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
908 TriggerEstateInfoChange();
912 remote_client.SendAlertMessage(
"User is not on the region ban list");
916 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
920 remote_client.SendAlertMessage(
"Method EstateAccessDelta Failed, you don't have permissions");
924 if ((estateAccessType & 256) != 0)
928 if ((estateAccessType & 1) != 0)
930 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
933 foreach (
int estateID
in estateIDs)
937 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
938 estateSettings.AddEstateManager(user);
939 Scene.EstateDataService.StoreEstateSettings(estateSettings);
944 Scene.RegionInfo.EstateSettings.AddEstateManager(user);
945 Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
947 TriggerEstateInfoChange();
952 remote_client.SendAlertMessage(
"Method EstateAccessDelta Failed, you don't have permissions");
956 if ((estateAccessType & 512) != 0)
960 if ((estateAccessType & 1) != 0)
962 List<int> estateIDs = Scene.EstateDataService.GetEstatesByOwner(Scene.RegionInfo.EstateSettings.EstateOwner);
965 foreach (
int estateID
in estateIDs)
969 estateSettings = Scene.EstateDataService.LoadEstateSettings(estateID);
970 estateSettings.RemoveEstateManager(user);
971 Scene.EstateDataService.StoreEstateSettings(estateSettings);
976 Scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
977 Scene.EstateDataService.StoreEstateSettings(Scene.RegionInfo.EstateSettings);
979 TriggerEstateInfoChange();
984 remote_client.SendAlertMessage(
"Method EstateAccessDelta Failed, you don't have permissions");
1000 part = Scene.GetSceneObjectPart((uint)param1);
1005 m_Telehub.Connect(grp);
1010 m_Telehub.Disconnect();
1013 case "spawnpoint add":
1015 part = Scene.GetSceneObjectPart((uint)param1);
1018 m_Telehub.AddSpawnPoint(part.AbsolutePosition);
1021 case "spawnpoint remove":
1023 m_Telehub.RemoveSpawnPoint((int)param1);
1031 SendTelehubInfo(client);
1034 private void SendSimulatorBlueBoxMessage(
1035 IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID,
string senderName,
string message)
1040 dm.SendNotificationToUsersInRegion(senderID, senderName, message);
1043 private void SendEstateBlueBoxMessage(
1044 IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID,
string senderName,
string message)
1046 TriggerEstateMessage(senderID, senderName, message);
1049 private void handleEstateDebugRegionRequest(
1050 IClientAPI remote_client, UUID invoice, UUID senderID,
1051 bool disableScripts,
bool disableCollisions,
bool disablePhysics)
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();
1063 scm.SetSceneDebugOptions(
1064 new Dictionary<string, string>() {
1065 {
"scripting", (!disableScripts).ToString() },
1066 {
"collisions", (!disableCollisions).ToString() },
1067 {
"physics", (!disablePhysics).ToString() }
1073 private void handleEstateTeleportOneUserHomeRequest(
IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey)
1078 if (prey !=
UUID.Zero)
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);
1092 private void handleEstateTeleportAllUsersHomeRequest(
IClientAPI remover_client, UUID invoice, UUID senderID)
1097 Scene.ForEachRootClient(delegate(
IClientAPI client)
1099 if (client.
AgentId != senderID)
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);
1116 private void AbortTerrainXferHandler(
IClientAPI remoteClient, ulong XferID)
1120 if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID))
1123 remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
1124 TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
1126 TerrainUploader = null;
1127 remoteClient.SendAlertMessage(
"Terrain Upload aborted by the client");
1132 private void HandleTerrainApplication(
string filename, byte[] terrainData,
IClientAPI remoteClient)
1137 remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
1138 TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
1140 TerrainUploader = null;
1143 m_log.DebugFormat(
"[CLIENT]: Terrain upload from {0} to {1} complete.", remoteClient.Name, Scene.Name);
1144 remoteClient.SendAlertMessage(
"Terrain Upload Complete. Loading....");
1152 using (MemoryStream terrainStream =
new MemoryStream(terrainData))
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.");
1158 catch (IOException e)
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.");
1165 catch (SecurityException e)
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");
1172 catch (UnauthorizedAccessException e)
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");
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");
1187 remoteClient.SendAlertMessage(
"Unable to apply terrain. Cannot get an instance of the terrain module");
1191 private void handleUploadTerrain(
IClientAPI remote_client,
string clientFileName)
1195 if (TerrainUploader == null)
1198 "[TERRAIN]: Started receiving terrain upload for region {0} from {1}",
1199 Scene.Name, remote_client.Name);
1201 TerrainUploader =
new EstateTerrainXferHandler(remote_client, clientFileName);
1203 remote_client.OnAbortXfer += AbortTerrainXferHandler;
1204 TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
1205 TerrainUploader.RequestStartXfer(remote_client);
1209 remote_client.SendAlertMessage(
"Another Terrain Upload is in progress. Please wait your turn!");
1214 private void handleTerrainRequest(
IClientAPI remote_client,
string clientFileName)
1222 if (
File.Exists(Util.dataDir() +
"/terrain.raw"))
1224 File.Delete(Util.dataDir() +
"/terrain.raw");
1226 terr.SaveToFile(Util.dataDir() +
"/terrain.raw");
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);
1234 m_log.DebugFormat(
"[CLIENT]: Sending terrain for region {0} to {1}", Scene.Name, remote_client.Name);
1236 remote_client.SendInitiateDownload(
"terrain.raw", clientFileName);
1240 private void HandleRegionInfoRequest(
IClientAPI remote_client)
1243 args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
1244 args.estateID = Scene.RegionInfo.EstateSettings.EstateID;
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;
1254 args.
terrainLowerLimit = (
float)Scene.RegionInfo.RegionSettings.TerrainLowerLimit;
1257 args.
waterHeight = (
float)Scene.RegionInfo.RegionSettings.WaterHeight;
1258 args.simName = Scene.RegionInfo.RegionName;
1259 args.regionType = Scene.RegionInfo.RegionType;
1261 remote_client.SendRegionInfoToEstateMenu(args);
1264 private void HandleEstateCovenantRequest(
IClientAPI remote_client)
1266 remote_client.SendEstateCovenantInformation(Scene.RegionInfo.RegionSettings.Covenant);
1269 private void HandleLandStatRequest(
int parcelID, uint reportType, uint requestFlags,
string filter,
IClientAPI remoteClient)
1274 Dictionary<uint, float> sceneData = null;
1276 if (reportType == 1)
1278 sceneData = Scene.PhysicsScene.GetTopColliders();
1280 else if (reportType == 0)
1284 if (scriptModule != null)
1285 sceneData = scriptModule.GetObjectScriptsExecutionTimes();
1288 List<LandStatReportItem> SceneReport =
new List<LandStatReportItem>();
1289 if (sceneData != null)
1293 item =>
new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) });
1295 sortedSceneData.OrderBy(item => item.Measurement);
1299 foreach (var entry
in sortedSceneData)
1302 if (entry.Part == null)
1307 if (entry.Measurement < 0.001)
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);
1323 if (filter.Length != 0)
1325 if ((lsri.
OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
1334 SceneReport.Add(lsri);
1341 remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
1346 #region Outgoing Packets
1350 Scene.ForEachRootClient(delegate(
IClientAPI client)
1352 HandleRegionInfoRequest(client);
1360 args.isEstateManager = Scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(remoteClient.AgentId);
1362 args.isEstateManager =
true;
1364 args.billableFactor = Scene.RegionInfo.EstateSettings.BillableFactor;
1373 args.simAccess = Scene.RegionInfo.AccessLevel;
1376 args.regionName = Scene.RegionInfo.RegionName;
1377 args.SimOwner = Scene.RegionInfo.EstateSettings.EstateOwner;
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;
1400 Scene.RegionInfo.EstateSettings.UseGlobalTime =
true;
1401 Scene.RegionInfo.EstateSettings.SunPosition = 0.0;
1405 Scene.RegionInfo.EstateSettings.UseGlobalTime =
false;
1406 Scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0;
1410 if ((parms1 & 0x00000010) != 0)
1415 if ((parms1 & 0x00008000) != 0)
1420 if ((parms1 & 0x10000000) != 0)
1425 if ((parms1 & 0x00100000) != 0)
1430 if ((parms1 & 0x00800000) != 0)
1435 if ((parms1 & 0x01000000) != 0)
1440 if ((parms1 & 0x02000000) != 0)
1445 if ((parms1 & 0x40000000) != 0)
1451 TriggerEstateInfoChange();
1453 Scene.TriggerEstateSunUpdate();
1455 sendDetailedEstateData(remoteClient, invoice);
1460 #region Other Functions
1464 setRegionTerrainSettings(height,
1474 sendRegionInfoPacketToAll();
1480 private void EventManager_OnNewClient(
IClientAPI client)
1482 client.OnDetailedEstateDataRequest += clientSendDetailedEstateData;
1483 client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
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;
1502 client.OnRegionInfoRequest += HandleRegionInfoRequest;
1503 client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
1504 client.OnLandStatRequest += HandleLandStatRequest;
1505 sendRegionHandshake(client);
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;
1554 if (onmessage != null)
1559 private void SendTelehubInfo(
IClientAPI client)
1568 List<Vector3> spawnPoints =
new List<Vector3>();
1572 spawnPoints.Add(sp.GetLocation(Vector3.Zero, Quaternion.Identity));
1575 client.SendTelehubInfo(settings.TelehubObject,
1577 telehub.AbsolutePosition,
1578 telehub.GroupRotation,
1583 client.SendTelehubInfo(UUID.Zero,
1586 Quaternion.Identity,
1587 new List<Vector3>());
float terrainHeightRange0
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...
ChangeDelegate OnRegionInfoChange
delegate void MessageDelegate(UUID regionID, UUID fromID, string fromName, string message)
string SetEstateName(int estateID, string newName)
IEstateDataService EstateDataService
EstateSettings EstateSettings
IClientAPI ControllingClient
void TriggerEstateInfoChange()
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
int CovenantChangedDateTime
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...
void setEstateTerrainBaseTexture(int level, UUID texture)
void sendRegionInfoPacketToAll()
RegionSettings RegionSettings
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
string SetEstateOwner(int estateID, UserAccount account)
void sendRegionHandshakeToAll()
Tell all clients about the current state of the region (terrain textures, water height, etc.).
float terrainHeightRange1
string CreateEstate(string estateName, UUID ownerID)
SceneObjectGroup GetSceneObjectGroup(UUID fullID)
Get a group via its UUID
RegionFlags
Region flags used internally by OpenSimulator to store installation specific information about region...
void changeWaterHeight(float height)
void sendRegionHandshake(IClientAPI remoteClient)
ChangeDelegate OnEstateInfoChange
void LoadFromStream(string filename, Stream stream)
Load a terrain from a stream.
string SetRegionEstate(RegionInfo regionInfo, int estateID)
MessageDelegate OnEstateMessage
ScenePermissions Permissions
float terrainHeightRange3
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.
void RaiseRegionInfoChange(object sender, ElapsedEventArgs e)
override bool TryGetScenePresence(UUID agentID, out ScenePresence sp)
Try to get a scene presence from the scene
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
float terrainHeightRange2
bool IsManager(UUID avatarID)
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)
bool AbuseEmailToEstateOwner
delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
List< SpawnPoint > SpawnPoints()
delegate void ChangeDelegate(UUID regionID)
OpenMetaverse.RegionFlags RegionFlags
virtual RegionInfo RegionInfo
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
EstateManagementCommands m_commands
void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
Estate management console commands.
void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue)