1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012 |
- /*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSim Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- using System;
- using System.Threading;
- using System.Collections.Generic;
- using System.Reflection;
- using OpenMetaverse;
- using log4net;
- using Nini.Config;
- using OpenSim.Framework;
- using OpenSim.Region.Environment.Interfaces;
- using OpenSim.Region.Environment.Scenes;
- namespace OpenSim.Region.Environment.Modules.World.Estate
- {
- public class EstateManagementModule : IEstateModule
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private delegate void LookupUUIDS(List<UUID> uuidLst);
- private Scene m_scene;
- private EstateTerrainXferHandler TerrainUploader = null;
- #region Packet Data Responders
- private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice)
- {
- uint sun = 0;
- if (!m_scene.RegionInfo.EstateSettings.UseGlobalTime)
- sun=(uint)(m_scene.RegionInfo.EstateSettings.SunPosition*1024.0) + 0x1800;
- UUID estateOwner;
- if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
- estateOwner = m_scene.RegionInfo.EstateSettings.EstateOwner;
- else
- estateOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID;
- if (m_scene.Permissions.IsGod(remote_client.AgentId))
- estateOwner = remote_client.AgentId;
- remote_client.SendDetailedEstateData(invoice,
- m_scene.RegionInfo.EstateSettings.EstateName,
- m_scene.RegionInfo.EstateSettings.EstateID,
- m_scene.RegionInfo.EstateSettings.ParentEstateID,
- GetEstateFlags(),
- sun,
- m_scene.RegionInfo.RegionSettings.Covenant,
- m_scene.RegionInfo.EstateSettings.AbuseEmail,
- estateOwner);
- remote_client.SendEstateManagersList(invoice,
- m_scene.RegionInfo.EstateSettings.EstateManagers,
- m_scene.RegionInfo.EstateSettings.EstateID);
- remote_client.SendBannedUserList(invoice,
- m_scene.RegionInfo.EstateSettings.EstateBans,
- m_scene.RegionInfo.EstateSettings.EstateID);
- }
- private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor,
- int matureLevel, bool restrictPushObject, bool allowParcelChanges)
- {
- if (blockTerraform)
- m_scene.RegionInfo.RegionSettings.BlockTerraform = true;
- else
- m_scene.RegionInfo.RegionSettings.BlockTerraform = false;
- if (noFly)
- m_scene.RegionInfo.RegionSettings.BlockFly = true;
- else
- m_scene.RegionInfo.RegionSettings.BlockFly = false;
- if (allowDamage)
- m_scene.RegionInfo.RegionSettings.AllowDamage = true;
- else
- m_scene.RegionInfo.RegionSettings.AllowDamage = false;
- if (blockLandResell)
- m_scene.RegionInfo.RegionSettings.AllowLandResell = false;
- else
- m_scene.RegionInfo.RegionSettings.AllowLandResell = true;
- m_scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents;
- m_scene.RegionInfo.RegionSettings.ObjectBonus = objectBonusFactor;
- if (matureLevel <= 13)
- m_scene.RegionInfo.RegionSettings.Maturity = 0;
- else
- m_scene.RegionInfo.RegionSettings.Maturity = 1;
- if (restrictPushObject)
- m_scene.RegionInfo.RegionSettings.RestrictPushing = true;
- else
- m_scene.RegionInfo.RegionSettings.RestrictPushing = false;
- if (allowParcelChanges)
- m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true;
- else
- m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false;
- m_scene.RegionInfo.RegionSettings.Save();
- sendRegionInfoPacketToAll();
- }
- public void setEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, UUID texture)
- {
- if (texture == UUID.Zero)
- return;
- switch (corner)
- {
- case 0:
- m_scene.RegionInfo.RegionSettings.TerrainTexture1 = texture;
- break;
- case 1:
- m_scene.RegionInfo.RegionSettings.TerrainTexture2 = texture;
- break;
- case 2:
- m_scene.RegionInfo.RegionSettings.TerrainTexture3 = texture;
- break;
- case 3:
- m_scene.RegionInfo.RegionSettings.TerrainTexture4 = texture;
- break;
- }
- m_scene.RegionInfo.RegionSettings.Save();
- }
- public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue)
- {
- switch (corner)
- {
- case 0:
- m_scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
- m_scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
- break;
- case 1:
- m_scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
- m_scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
- break;
- case 2:
- m_scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
- m_scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
- break;
- case 3:
- m_scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
- m_scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
- break;
- }
- m_scene.RegionInfo.RegionSettings.Save();
- }
- private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient)
- {
- sendRegionHandshakeToAll();
- }
- public void setRegionTerrainSettings(float WaterHeight,
- float TerrainRaiseLimit, float TerrainLowerLimit,
- bool UseEstateSun, bool UseFixedSun, float SunHour,
- bool UseGlobal, bool EstateFixedSun, float EstateSunHour)
- {
- // Water Height
- m_scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight;
- // Terraforming limits
- m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit = TerrainRaiseLimit;
- m_scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit;
- // Time of day / fixed sun
- m_scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun;
- m_scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun;
- m_scene.RegionInfo.RegionSettings.SunPosition = SunHour;
- m_scene.EventManager.TriggerEstateToolsTimeUpdate(m_scene.RegionInfo.RegionHandle, UseFixedSun, UseEstateSun, SunHour);
- //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString());
- //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString());
- sendRegionInfoPacketToAll();
- m_scene.RegionInfo.RegionSettings.Save();
- }
- private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
- {
- m_scene.Restart(timeInSeconds);
- }
- private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
- {
- m_scene.RegionInfo.RegionSettings.Covenant = estateCovenantID;
- m_scene.RegionInfo.RegionSettings.Save();
- }
- private void handleEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
- {
- // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc.
- if (user == m_scene.RegionInfo.EstateSettings.EstateOwner)
- return; // never process EO
- if (user == m_scene.RegionInfo.MasterAvatarAssignedUUID)
- return; // never process owner
- switch (estateAccessType)
- {
- case 64:
- if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
- {
- EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;
- bool alreadyInList = false;
- for (int i = 0; i < banlistcheck.Length; i++)
- {
- if (user == banlistcheck[i].bannedUUID)
- {
- alreadyInList = true;
- break;
- }
- }
- if (!alreadyInList)
- {
- EstateBan item = new EstateBan();
- item.bannedUUID = user;
- item.estateID = m_scene.RegionInfo.EstateSettings.EstateID;
- item.bannedIP = "0.0.0.0";
- item.bannedIPHostMask = "0.0.0.0";
- m_scene.RegionInfo.EstateSettings.AddBan(item);
- m_scene.RegionInfo.EstateSettings.Save();
- ScenePresence s = m_scene.GetScenePresence(user);
- if (s != null)
- {
- if (!s.IsChildAgent)
- {
- s.ControllingClient.SendTeleportLocationStart();
- m_scene.TeleportClientHome(user, s.ControllingClient);
- }
- }
- }
- else
- {
- remote_client.SendAlertMessage("User is already on the region ban list");
- }
- //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
- remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID);
- }
- else
- {
- remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
- }
- break;
- case 128:
- if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || m_scene.Permissions.BypassPermissions())
- {
- EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans;
- bool alreadyInList = false;
- EstateBan listitem = null;
- for (int i = 0; i < banlistcheck.Length; i++)
- {
- if (user == banlistcheck[i].bannedUUID)
- {
- alreadyInList = true;
- listitem = banlistcheck[i];
- break;
- }
- }
- if (alreadyInList && listitem != null)
- {
- m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.bannedUUID);
- m_scene.RegionInfo.EstateSettings.Save();
- }
- else
- {
- remote_client.SendAlertMessage("User is not on the region ban list");
- }
- //m_scene.RegionInfo.regionBanlist.Add(Manager(user);
- remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID);
- }
- else
- {
- remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
- }
- break;
- case 256:
- if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
- {
- m_scene.RegionInfo.EstateSettings.AddEstateManager(user);
- m_scene.RegionInfo.EstateSettings.Save();
- remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID);
- }
- else
- {
- remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
- }
- break;
- case 512:
- if (m_scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || m_scene.Permissions.BypassPermissions())
- {
- m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user);
- m_scene.RegionInfo.EstateSettings.Save();
- remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID);
- }
- else
- {
- remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions");
- }
- break;
- default:
- m_log.ErrorFormat("EstateOwnerMessage: Unknown EstateAccessType requested in estateAccessDelta: {0}", estateAccessType.ToString());
- break;
- }
- }
- private void SendSimulatorBlueBoxMessage(
- IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
- {
- IDialogModule dm = m_scene.RequestModuleInterface<IDialogModule>();
-
- if (dm != null)
- dm.SendNotificationToUsersInRegion(senderID, senderName, message);
- }
- private void SendEstateBlueBoxMessage(
- IClientAPI remote_client, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
- {
- IDialogModule dm = m_scene.RequestModuleInterface<IDialogModule>();
-
- if (dm != null)
- dm.SendNotificationToUsersInEstate(senderID, senderName, message);
- }
- private void handleEstateDebugRegionRequest(IClientAPI remote_client, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics)
- {
- if (physics)
- m_scene.RegionInfo.RegionSettings.DisablePhysics = true;
- else
- m_scene.RegionInfo.RegionSettings.DisablePhysics = false;
- if (scripted)
- m_scene.RegionInfo.RegionSettings.DisableScripts = true;
- else
- m_scene.RegionInfo.RegionSettings.DisableScripts = false;
- if (collisionEvents)
- m_scene.RegionInfo.RegionSettings.DisableCollisions = true;
- else
- m_scene.RegionInfo.RegionSettings.DisableCollisions = false;
- m_scene.RegionInfo.RegionSettings.Save();
- m_scene.SetSceneCoreDebug(scripted, collisionEvents, physics);
- }
- private void handleEstateTeleportOneUserHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID, UUID prey)
- {
- if (prey != UUID.Zero)
- {
- ScenePresence s = m_scene.GetScenePresence(prey);
- if (s != null)
- {
- s.ControllingClient.SendTeleportLocationStart();
- m_scene.TeleportClientHome(prey, s.ControllingClient);
- }
- }
- }
- private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
- {
- // Get a fresh list that will not change as people get teleported away
- List<ScenePresence> prescences = m_scene.GetScenePresences();
- foreach (ScenePresence p in prescences)
- {
- if (p.UUID != senderID)
- {
- // make sure they are still there, we could be working down a long list
- ScenePresence s = m_scene.GetScenePresence(p.UUID);
- if (s != null)
- {
- // Also make sure they are actually in the region
- if (!s.IsChildAgent)
- {
- s.ControllingClient.SendTeleportLocationStart();
- m_scene.TeleportClientHome(s.UUID, s.ControllingClient);
- }
- }
- }
- }
- }
- private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
- {
- if (TerrainUploader != null)
- {
- lock (TerrainUploader)
- {
- if (XferID == TerrainUploader.XferID)
- {
- remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
- remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
- TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
- TerrainUploader = null;
- remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
- }
- }
- }
- }
- private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
- {
- lock (TerrainUploader)
- {
- remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
- remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
- TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
- TerrainUploader = null;
- }
- remoteClient.SendAlertMessage("Terrain Upload Complete. Loading....");
- OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule terr = m_scene.RequestModuleInterface<OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule>();
- if (terr != null)
- {
- m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName);
- if (System.IO.File.Exists(Util.dataDir() + "/terrain.raw"))
- {
- System.IO.File.Delete(Util.dataDir() + "/terrain.raw");
- }
- try
- {
- System.IO.FileStream input = new System.IO.FileStream(Util.dataDir() + "/terrain.raw", System.IO.FileMode.CreateNew);
- input.Write(terrainData, 0, terrainData.Length);
- input.Close();
- }
- catch (System.IO.IOException e)
- {
- m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
- remoteClient.SendAlertMessage("There was an IO Exception loading your terrain. Please check free space");
- return;
- }
- catch (System.Security.SecurityException e)
- {
- m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
- remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
- return;
- }
- catch (System.UnauthorizedAccessException e)
- {
- m_log.ErrorFormat("[TERRAIN]: Error Saving a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
- remoteClient.SendAlertMessage("There was a security Exception loading your terrain. Please check the security on the simulator drive");
- return;
- }
- try
- {
- terr.LoadFromFile(Util.dataDir() + "/terrain.raw");
- remoteClient.SendAlertMessage("Your terrain was loaded. Give it a minute or two to apply");
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("[TERRAIN]: Error loading a terrain file uploaded via the estate tools. It gave us the following error: {0}", e.ToString());
- remoteClient.SendAlertMessage("There was a general error loading your terrain. Please fix the terrain file and try again");
- }
- }
- else
- {
- remoteClient.SendAlertMessage("Unable to apply terrain. Cannot get an instance of the terrain module");
- }
- }
- private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
- {
- if (TerrainUploader == null)
- {
- TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
- lock (TerrainUploader)
- {
- remote_client.OnXferReceive += TerrainUploader.XferReceive;
- remote_client.OnAbortXfer += AbortTerrainXferHandler;
- TerrainUploader.TerrainUploadDone += HandleTerrainApplication;
- }
- TerrainUploader.RequestStartXfer(remote_client);
- }
- else
- {
- remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
- }
- }
- private void handleTerrainRequest(IClientAPI remote_client, string clientFileName)
- {
- // Save terrain here
- OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule terr = m_scene.RequestModuleInterface<OpenSim.Region.Environment.Modules.World.Terrain.ITerrainModule>();
-
- if (terr != null)
- {
- m_log.Warn("[CLIENT]: Got Request to Send Terrain in region " + m_scene.RegionInfo.RegionName);
- if (System.IO.File.Exists(Util.dataDir() + "/terrain.raw"))
- {
- System.IO.File.Delete(Util.dataDir() + "/terrain.raw");
- }
- terr.SaveToFile(Util.dataDir() + "/terrain.raw");
- System.IO.FileStream input = new System.IO.FileStream(Util.dataDir() + "/terrain.raw", System.IO.FileMode.Open);
- byte[] bdata = new byte[input.Length];
- input.Read(bdata, 0, (int)input.Length);
- remote_client.SendAlertMessage("Terrain file written, starting download...");
- m_scene.XferManager.AddNewFile("terrain.raw", bdata);
- // Tell client about it
- m_log.Warn("[CLIENT]: Sending Terrain to " + remote_client.Name);
- remote_client.SendInitiateDownload("terrain.raw", clientFileName);
- }
- }
- private void HandleRegionInfoRequest(IClientAPI remote_client)
- {
- RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs();
- args.billableFactor = m_scene.RegionInfo.EstateSettings.BillableFactor;
- args.estateID = m_scene.RegionInfo.EstateSettings.EstateID;
- args.maxAgents = (byte)m_scene.RegionInfo.RegionSettings.AgentLimit;
- args.objectBonusFactor = (float)m_scene.RegionInfo.RegionSettings.ObjectBonus;
- args.parentEstateID = m_scene.RegionInfo.EstateSettings.ParentEstateID;
- args.pricePerMeter = m_scene.RegionInfo.EstateSettings.PricePerMeter;
- args.redirectGridX = m_scene.RegionInfo.EstateSettings.RedirectGridX;
- args.redirectGridY = m_scene.RegionInfo.EstateSettings.RedirectGridY;
- args.regionFlags = GetRegionFlags();
- byte mature = 13;
- if (m_scene.RegionInfo.RegionSettings.Maturity == 1)
- mature = 21;
- args.simAccess = mature;
- args.sunHour = (float)m_scene.RegionInfo.RegionSettings.SunPosition;
- args.terrainLowerLimit = (float)m_scene.RegionInfo.RegionSettings.TerrainLowerLimit;
- args.terrainRaiseLimit = (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
- args.useEstateSun = m_scene.RegionInfo.RegionSettings.UseEstateSun;
- args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;
- args.simName = m_scene.RegionInfo.RegionName;
- remote_client.SendRegionInfoToEstateMenu(args);
- }
- private void HandleEstateCovenantRequest(IClientAPI remote_client)
- {
- remote_client.SendEstateCovenantInformation(m_scene.RegionInfo.RegionSettings.Covenant);
- }
- private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient)
- {
- Dictionary<uint, float> SceneData = new Dictionary<uint,float>();
- List<UUID> uuidNameLookupList = new List<UUID>();
- if (reportType == 1)
- {
- SceneData = m_scene.PhysicsScene.GetTopColliders();
- }
- else if (reportType == 0)
- {
- SceneData = m_scene.m_sceneGraph.GetTopScripts();
- }
- List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
- lock (SceneData)
- {
- foreach (uint obj in SceneData.Keys)
- {
- SceneObjectPart prt = m_scene.GetSceneObjectPart(obj);
- if (prt != null)
- {
- if (prt.ParentGroup != null)
- {
- SceneObjectGroup sog = prt.ParentGroup;
- if (sog != null)
- {
- LandStatReportItem lsri = new LandStatReportItem();
- lsri.LocationX = sog.AbsolutePosition.X;
- lsri.LocationY = sog.AbsolutePosition.Y;
- lsri.LocationZ = sog.AbsolutePosition.Z;
- lsri.Score = SceneData[obj];
- lsri.TaskID = sog.UUID;
- lsri.TaskLocalID = sog.LocalId;
- lsri.TaskName = sog.GetPartName(obj);
- if (m_scene.CommsManager.UUIDNameCachedTest(sog.OwnerID))
- {
- lsri.OwnerName = m_scene.CommsManager.UUIDNameRequestString(sog.OwnerID);
- }
- else
- {
- lsri.OwnerName = "waiting";
- lock (uuidNameLookupList)
- uuidNameLookupList.Add(sog.OwnerID);
- }
- if (filter.Length != 0)
- {
- if ((lsri.OwnerName.Contains(filter) || lsri.TaskName.Contains(filter)))
- {
- }
- else
- {
- continue;
- }
- }
- SceneReport.Add(lsri);
- }
- }
- }
- }
- }
- remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
- if (uuidNameLookupList.Count > 0)
- LookupUUID(uuidNameLookupList);
- }
- private void LookupUUIDSCompleted(IAsyncResult iar)
- {
- LookupUUIDS icon = (LookupUUIDS)iar.AsyncState;
- icon.EndInvoke(iar);
- }
- private void LookupUUID(List<UUID> uuidLst)
- {
- LookupUUIDS d = LookupUUIDsAsync;
- d.BeginInvoke(uuidLst,
- LookupUUIDSCompleted,
- d);
- }
- private void LookupUUIDsAsync(List<UUID> uuidLst)
- {
- UUID[] uuidarr = new UUID[0];
- lock (uuidLst)
- {
- uuidarr = uuidLst.ToArray();
- }
- for (int i = 0; i < uuidarr.Length; i++)
- {
- // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
- m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
- // we drop it. It gets cached though... so we're ready for the next request.
- }
- }
- #endregion
- #region Outgoing Packets
- public void sendRegionInfoPacketToAll()
- {
- List<ScenePresence> avatars = m_scene.GetAvatars();
- for (int i = 0; i < avatars.Count; i++)
- {
- HandleRegionInfoRequest(avatars[i].ControllingClient); ;
- }
- }
- public void sendRegionHandshake(IClientAPI remoteClient)
- {
- RegionHandshakeArgs args = new RegionHandshakeArgs();
- args.isEstateManager = m_scene.RegionInfo.EstateSettings.IsEstateManager(remoteClient.AgentId);
- if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero && m_scene.RegionInfo.EstateSettings.EstateOwner == remoteClient.AgentId)
- args.isEstateManager = true;
- args.billableFactor = m_scene.RegionInfo.EstateSettings.BillableFactor;
- args.terrainStartHeight0 = (float)m_scene.RegionInfo.RegionSettings.Elevation1SW;
- args.terrainHeightRange0 = (float)m_scene.RegionInfo.RegionSettings.Elevation2SW;
- args.terrainStartHeight1 = (float)m_scene.RegionInfo.RegionSettings.Elevation1NW;
- args.terrainHeightRange1 = (float)m_scene.RegionInfo.RegionSettings.Elevation2NW;
- args.terrainStartHeight2 = (float)m_scene.RegionInfo.RegionSettings.Elevation1SE;
- args.terrainHeightRange2 = (float)m_scene.RegionInfo.RegionSettings.Elevation2SE;
- args.terrainStartHeight3 = (float)m_scene.RegionInfo.RegionSettings.Elevation1NE;
- args.terrainHeightRange3 = (float)m_scene.RegionInfo.RegionSettings.Elevation2NE;
- byte mature = 13;
- if (m_scene.RegionInfo.RegionSettings.Maturity == 1)
- mature = 21;
- args.simAccess = mature;
- args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;
- args.regionFlags = GetRegionFlags();
- args.regionName = m_scene.RegionInfo.RegionName;
- if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
- args.SimOwner = m_scene.RegionInfo.EstateSettings.EstateOwner;
- else
- args.SimOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID;
- // Fudge estate owner
- //if (m_scene.Permissions.IsGod(remoteClient.AgentId))
- // args.SimOwner = remoteClient.AgentId;
- args.terrainBase0 = UUID.Zero;
- args.terrainBase1 = UUID.Zero;
- args.terrainBase2 = UUID.Zero;
- args.terrainBase3 = UUID.Zero;
- args.terrainDetail0 = m_scene.RegionInfo.RegionSettings.TerrainTexture1;
- args.terrainDetail1 = m_scene.RegionInfo.RegionSettings.TerrainTexture2;
- args.terrainDetail2 = m_scene.RegionInfo.RegionSettings.TerrainTexture3;
- args.terrainDetail3 = m_scene.RegionInfo.RegionSettings.TerrainTexture4;
- remoteClient.SendRegionHandshake(m_scene.RegionInfo,args);
- }
- public void sendRegionHandshakeToAll()
- {
- m_scene.Broadcast(sendRegionHandshake);
- }
- public void handleEstateChangeInfo(IClientAPI remoteClient, UUID invoice, UUID senderID, UInt32 parms1, UInt32 parms2)
- {
- if (parms2 == 0)
- {
- m_scene.RegionInfo.EstateSettings.UseGlobalTime = true;
- m_scene.RegionInfo.EstateSettings.SunPosition = 0.0;
- }
- else
- {
- m_scene.RegionInfo.EstateSettings.UseGlobalTime = false;
- m_scene.RegionInfo.EstateSettings.SunPosition = (double)(parms2 - 0x1800)/1024.0;
- }
- if ((parms1 & 0x00000010) != 0)
- m_scene.RegionInfo.EstateSettings.FixedSun = true;
- else
- m_scene.RegionInfo.EstateSettings.FixedSun = false;
- if ((parms1 & 0x00008000) != 0)
- m_scene.RegionInfo.EstateSettings.PublicAccess = true;
- else
- m_scene.RegionInfo.EstateSettings.PublicAccess = false;
- if ((parms1 & 0x10000000) != 0)
- m_scene.RegionInfo.EstateSettings.AllowVoice = true;
- else
- m_scene.RegionInfo.EstateSettings.AllowVoice = false;
- if ((parms1 & 0x00100000) != 0)
- m_scene.RegionInfo.EstateSettings.AllowDirectTeleport = true;
- else
- m_scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
- if ((parms1 & 0x00800000) != 0)
- m_scene.RegionInfo.EstateSettings.DenyAnonymous = true;
- else
- m_scene.RegionInfo.EstateSettings.DenyAnonymous = false;
- if ((parms1 & 0x01000000) != 0)
- m_scene.RegionInfo.EstateSettings.DenyIdentified = true;
- else
- m_scene.RegionInfo.EstateSettings.DenyIdentified = false;
- if ((parms1 & 0x02000000) != 0)
- m_scene.RegionInfo.EstateSettings.DenyTransacted = true;
- else
- m_scene.RegionInfo.EstateSettings.DenyTransacted = false;
- if ((parms1 & 0x40000000) != 0)
- m_scene.RegionInfo.EstateSettings.DenyMinors = true;
- else
- m_scene.RegionInfo.EstateSettings.DenyMinors = false;
- m_scene.RegionInfo.EstateSettings.Save();
- float sun = (float)m_scene.RegionInfo.RegionSettings.SunPosition;
- if (m_scene.RegionInfo.RegionSettings.UseEstateSun)
- {
- sun = (float)m_scene.RegionInfo.EstateSettings.SunPosition;
- if (m_scene.RegionInfo.EstateSettings.UseGlobalTime)
- sun = m_scene.EventManager.GetSunLindenHour();
- }
- m_scene.EventManager.TriggerEstateToolsTimeUpdate(
- m_scene.RegionInfo.RegionHandle,
- m_scene.RegionInfo.EstateSettings.FixedSun ||
- m_scene.RegionInfo.RegionSettings.FixedSun,
- m_scene.RegionInfo.RegionSettings.UseEstateSun, sun);
- sendDetailedEstateData(remoteClient, invoice);
- }
- #endregion
- #region IRegionModule Members
- public void Initialise(Scene scene, IConfigSource source)
- {
- m_scene = scene;
- m_scene.RegisterModuleInterface<IEstateModule>(this);
- m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
- m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight;
- }
- public void PostInitialise()
- {
- }
- public void Close()
- {
- }
- public string Name
- {
- get { return "EstateManagementModule"; }
- }
- public bool IsSharedModule
- {
- get { return false; }
- }
- #endregion
- #region Other Functions
- public void changeWaterHeight(float height)
- {
- setRegionTerrainSettings(height,
- (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit,
- (float)m_scene.RegionInfo.RegionSettings.TerrainLowerLimit,
- m_scene.RegionInfo.RegionSettings.UseEstateSun,
- m_scene.RegionInfo.RegionSettings.FixedSun,
- (float)m_scene.RegionInfo.RegionSettings.SunPosition,
- m_scene.RegionInfo.EstateSettings.UseGlobalTime,
- m_scene.RegionInfo.EstateSettings.FixedSun,
- (float)m_scene.RegionInfo.EstateSettings.SunPosition);
- sendRegionInfoPacketToAll();
- }
- #endregion
- private void EventManager_OnNewClient(IClientAPI client)
- {
- client.OnDetailedEstateDataRequest += sendDetailedEstateData;
- client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
- // client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
- client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture;
- client.OnSetEstateTerrainTextureHeights += setEstateTerrainTextureHeights;
- client.OnCommitEstateTerrainTextureRequest += handleCommitEstateTerrainTextureRequest;
- client.OnSetRegionTerrainSettings += setRegionTerrainSettings;
- client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
- client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
- client.OnEstateChangeInfo += handleEstateChangeInfo;
- client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
- client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
- client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
- client.OnEstateDebugRegionRequest += handleEstateDebugRegionRequest;
- client.OnEstateTeleportOneUserHomeRequest += handleEstateTeleportOneUserHomeRequest;
- client.OnEstateTeleportAllUsersHomeRequest += handleEstateTeleportAllUsersHomeRequest;
- client.OnRequestTerrain += handleTerrainRequest;
- client.OnUploadTerrain += handleUploadTerrain;
- client.OnRegionInfoRequest += HandleRegionInfoRequest;
- client.OnEstateCovenantRequest += HandleEstateCovenantRequest;
- client.OnLandStatRequest += HandleLandStatRequest;
- sendRegionHandshake(client);
- }
- public uint GetRegionFlags()
- {
- RegionFlags flags = RegionFlags.None;
- // Fully implemented
- //
- if (m_scene.RegionInfo.RegionSettings.AllowDamage)
- flags |= RegionFlags.AllowDamage;
- if (m_scene.RegionInfo.RegionSettings.BlockTerraform)
- flags |= RegionFlags.BlockTerraform;
- if (!m_scene.RegionInfo.RegionSettings.AllowLandResell)
- flags |= RegionFlags.BlockLandResell;
- if (m_scene.RegionInfo.RegionSettings.DisableCollisions)
- flags |= RegionFlags.SkipCollisions;
- if (m_scene.RegionInfo.RegionSettings.DisableScripts)
- flags |= RegionFlags.SkipScripts;
- if (m_scene.RegionInfo.RegionSettings.DisablePhysics)
- flags |= RegionFlags.SkipPhysics;
- if (m_scene.RegionInfo.RegionSettings.BlockFly)
- flags |= RegionFlags.NoFly;
- if (m_scene.RegionInfo.RegionSettings.RestrictPushing)
- flags |= RegionFlags.RestrictPushObject;
- if (m_scene.RegionInfo.RegionSettings.AllowLandJoinDivide)
- flags |= RegionFlags.AllowParcelChanges;
- if (m_scene.RegionInfo.RegionSettings.BlockShowInSearch)
- flags |= (RegionFlags)(1 << 29);
- if (m_scene.RegionInfo.RegionSettings.FixedSun)
- flags |= RegionFlags.SunFixed;
- if (m_scene.RegionInfo.RegionSettings.Sandbox)
- flags |= RegionFlags.Sandbox;
- // Fudge these to always on, so the menu options activate
- //
- flags |= RegionFlags.AllowLandmark;
- flags |= RegionFlags.AllowSetHome;
- // TODO: SkipUpdateInterestList
- // Omitted
- //
- // Omitted: NullLayer (what is that?)
- // Omitted: SkipAgentAction (what does it do?)
- return (uint)flags;
- }
- public uint GetEstateFlags()
- {
- RegionFlags flags = RegionFlags.None;
- if (m_scene.RegionInfo.EstateSettings.FixedSun)
- flags |= RegionFlags.SunFixed;
- if (m_scene.RegionInfo.EstateSettings.PublicAccess)
- flags |= (RegionFlags.PublicAllowed |
- RegionFlags.ExternallyVisible);
- if (m_scene.RegionInfo.EstateSettings.AllowVoice)
- flags |= RegionFlags.AllowVoice;
- if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
- flags |= RegionFlags.AllowDirectTeleport;
- if (m_scene.RegionInfo.EstateSettings.DenyAnonymous)
- flags |= RegionFlags.DenyAnonymous;
- if (m_scene.RegionInfo.EstateSettings.DenyIdentified)
- flags |= RegionFlags.DenyIdentified;
- if (m_scene.RegionInfo.EstateSettings.DenyTransacted)
- flags |= RegionFlags.DenyTransacted;
- if (m_scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner)
- flags |= RegionFlags.AbuseEmailToEstateOwner;
- if (m_scene.RegionInfo.EstateSettings.BlockDwell)
- flags |= RegionFlags.BlockDwell;
- if (m_scene.RegionInfo.EstateSettings.EstateSkipScripts)
- flags |= RegionFlags.EstateSkipScripts;
- if (m_scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
- flags |= RegionFlags.ResetHomeOnTeleport;
- if (m_scene.RegionInfo.EstateSettings.TaxFree)
- flags |= RegionFlags.TaxFree;
- if (m_scene.RegionInfo.EstateSettings.DenyMinors)
- flags |= (RegionFlags)(1 << 30);
- return (uint)flags;
- }
- public bool IsManager(UUID avatarID)
- {
- if (avatarID == m_scene.RegionInfo.MasterAvatarAssignedUUID)
- return true;
- if (avatarID == m_scene.RegionInfo.EstateSettings.EstateOwner)
- return true;
- List<UUID> ems = new List<UUID>(m_scene.RegionInfo.EstateSettings.EstateManagers);
- if (ems.Contains(avatarID))
- return true;
- return false;
- }
- }
- }
|