Merge branch 'master' of ssh://3dhosting.de/var/git/careminster

Conflicts:
	OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
This commit is contained in:
Melanie Thielker
2014-06-21 00:39:55 +02:00
663 changed files with 89998 additions and 46619 deletions

View File

@@ -464,7 +464,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// or creator data is present. Otherwise, use the estate owner instead.
foreach (SceneObjectPart part in sceneObject.Parts)
{
if (part.CreatorData == null || part.CreatorData == string.Empty)
if (string.IsNullOrEmpty(part.CreatorData))
{
if (!ResolveUserUuid(scene, part.CreatorID))
part.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;
@@ -515,7 +515,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner;
}
if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty)
if (string.IsNullOrEmpty(kvp.Value.CreatorData))
{
if (!ResolveUserUuid(scene, kvp.Value.CreatorID))
kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner;

View File

@@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// Archive the regions
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>();
scenesGroup.ForEachScene(delegate(Scene scene)
{
@@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
}
private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids)
private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, sbyte> assetUuids)
{
m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName);
@@ -276,16 +276,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
RegionSettings regionSettings = scene.RegionInfo.RegionSettings;
if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
assetUuids[regionSettings.TerrainTexture1] = (sbyte)AssetType.Texture;
if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
assetUuids[regionSettings.TerrainTexture2] = (sbyte)AssetType.Texture;
if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
assetUuids[regionSettings.TerrainTexture3] = (sbyte)AssetType.Texture;
if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture;
Save(scene, sceneObjects, regionDir);
}

View File

@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <value>
/// uuids to request
/// </value>
protected IDictionary<UUID, AssetType> m_uuids;
protected IDictionary<UUID, sbyte> m_uuids;
/// <value>
/// Callback used when all the assets requested have been received.
@@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
protected Dictionary<string, object> m_options;
protected internal AssetsRequest(
AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids,
AssetsArchiver assetsArchiver, IDictionary<UUID, sbyte> uuids,
IAssetService assetService, IUserAccountService userService,
UUID scope, Dictionary<string, object> options,
AssetsRequestCallback assetsRequestCallback)
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_requestCallbackTimer.Enabled = true;
foreach (KeyValuePair<UUID, AssetType> kvp in m_uuids)
foreach (KeyValuePair<UUID, sbyte> kvp in m_uuids)
{
// m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key);
@@ -235,9 +235,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer
if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown)
{
AssetType type = (AssetType)assetType;
m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, type);
fetchedAsset.Type = (sbyte)type;
m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, SLUtil.AssetTypeFromCode((sbyte)assetType));
fetchedAsset.Type = (sbyte)assetType;
}
AssetRequestCallback(fetchedAssetID, this, fetchedAsset);

View File

@@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
public void Initialise()
{
m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName);
// m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName);
m_module.Scene.AddCommand("Regions", m_module, "set terrain texture",
"set terrain texture <number> <uuid> [<x>] [<y>]",
@@ -76,6 +76,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
" that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3, all corners = -1.",
consoleSetTerrainHeights);
m_module.Scene.AddCommand("Regions", m_module, "set water height",
"set water height <height> [<x>] [<y>]",
"Sets the water height in meters. If <x> and <y> are specified, it will only set it on regions with a matching coordinate. " +
"Specify -1 in <x> or <y> to wildcard that coordinate.",
consoleSetWaterHeight);
m_module.Scene.AddCommand(
"Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand);
}
@@ -121,7 +128,29 @@ namespace OpenSim.Region.CoreModules.World.Estate
}
}
}
protected void consoleSetWaterHeight(string module, string[] args)
{
string heightstring = args[3];
int x = (args.Length > 4 ? int.Parse(args[4]) : -1);
int y = (args.Length > 5 ? int.Parse(args[5]) : -1);
if (x == -1 || m_module.Scene.RegionInfo.RegionLocX == x)
{
if (y == -1 || m_module.Scene.RegionInfo.RegionLocY == y)
{
double selectedheight = double.Parse(heightstring);
m_log.Debug("[ESTATEMODULE]: Setting water height in " + m_module.Scene.RegionInfo.RegionName + " to " +
string.Format(" {0}", selectedheight));
m_module.Scene.RegionInfo.RegionSettings.WaterHeight = selectedheight;
m_module.Scene.RegionInfo.RegionSettings.Save();
m_module.TriggerRegionInfoChange();
m_module.sendRegionHandshakeToAll();
}
}
}
protected void consoleSetTerrainHeights(string module, string[] args)
{
string num = args[3];

View File

@@ -576,7 +576,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (!Scene.TeleportClientHome(user, s.ControllingClient))
{
s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
s.ControllingClient.Close();
Scene.CloseAgent(s.UUID, false);
}
}
}
@@ -716,7 +716,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
}
}
public void handleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
{
SceneObjectPart part;
@@ -756,7 +756,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
default:
break;
}
SendTelehubInfo(client);
if (client != null)
SendTelehubInfo(client);
}
private void SendSimulatorBlueBoxMessage(
@@ -811,7 +813,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (!Scene.TeleportClientHome(prey, s.ControllingClient))
{
s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
s.ControllingClient.Close();
Scene.CloseAgent(s.UUID, false);
}
}
}
@@ -834,7 +836,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
{
p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
p.ControllingClient.Close();
Scene.CloseAgent(p.UUID, false);
}
}
}
@@ -843,26 +845,23 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void AbortTerrainXferHandler(IClientAPI remoteClient, ulong XferID)
{
if (TerrainUploader != null)
lock (this)
{
lock (TerrainUploader)
if ((TerrainUploader != null) && (XferID == TerrainUploader.XferID))
{
if (XferID == TerrainUploader.XferID)
{
remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
TerrainUploader.TerrainUploadDone -= HandleTerrainApplication;
TerrainUploader = null;
remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
}
TerrainUploader = null;
remoteClient.SendAlertMessage("Terrain Upload aborted by the client");
}
}
}
private void HandleTerrainApplication(string filename, byte[] terrainData, IClientAPI remoteClient)
{
lock (TerrainUploader)
lock (this)
{
remoteClient.OnXferReceive -= TerrainUploader.XferReceive;
remoteClient.OnAbortXfer -= AbortTerrainXferHandler;
@@ -921,22 +920,32 @@ namespace OpenSim.Region.CoreModules.World.Estate
private void handleUploadTerrain(IClientAPI remote_client, string clientFileName)
{
if (TerrainUploader == null)
lock (this)
{
TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
lock (TerrainUploader)
if (TerrainUploader == null)
{
m_log.DebugFormat("Starting to receive uploaded terrain");
TerrainUploader = new EstateTerrainXferHandler(remote_client, clientFileName);
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!");
}
TerrainUploader.RequestStartXfer(remote_client);
}
else
}
public bool IsTerrainXfer(ulong xferID)
{
lock (this)
{
remote_client.SendAlertMessage("Another Terrain Upload is in progress. Please wait your turn!");
if (TerrainUploader == null)
return false;
else
return TerrainUploader.XferID == xferID;
}
}
@@ -1221,7 +1230,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
client.OnEstateChangeInfo += handleEstateChangeInfo;
client.OnEstateManageTelehub += handleOnEstateManageTelehub;
client.OnEstateManageTelehub += HandleOnEstateManageTelehub;
client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;

View File

@@ -78,7 +78,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
/// <param name="data"></param>
public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
{
if (mXferID == xferID)
if (mXferID != xferID)
return;
lock (this)
{
if (m_asset.Data.Length > 1)
{
@@ -99,7 +102,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
if ((packetID & 0x80000000) != 0)
{
SendCompleteMessage(remoteClient);
}
}
}

View File

@@ -0,0 +1,218 @@
/*
* 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 OpenSimulator 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.Collections.Generic;
using System.Reflection;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenMetaverse;
using log4net;
namespace OpenSim.Region.CoreModules.World.Estate
{
public class EstateConnector
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected XEstateModule m_EstateModule;
public EstateConnector(XEstateModule module)
{
m_EstateModule = module;
}
public void SendTeleportHomeOneUser(uint EstateID, UUID PreyID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "teleport_home_one_user";
sendData["EstateID"] = EstateID.ToString();
sendData["PreyID"] = PreyID.ToString();
SendToEstate(EstateID, sendData);
}
public void SendTeleportHomeAllUsers(uint EstateID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "teleport_home_all_users";
sendData["EstateID"] = EstateID.ToString();
SendToEstate(EstateID, sendData);
}
public bool SendUpdateCovenant(uint EstateID, UUID CovenantID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "update_covenant";
sendData["CovenantID"] = CovenantID.ToString();
sendData["EstateID"] = EstateID.ToString();
// Handle local regions locally
//
foreach (Scene s in m_EstateModule.Scenes)
{
if (s.RegionInfo.EstateSettings.EstateID == EstateID)
s.RegionInfo.RegionSettings.Covenant = CovenantID;
// s.ReloadEstateData();
}
SendToEstate(EstateID, sendData);
return true;
}
public bool SendUpdateEstate(uint EstateID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "update_estate";
sendData["EstateID"] = EstateID.ToString();
// Handle local regions locally
//
foreach (Scene s in m_EstateModule.Scenes)
{
if (s.RegionInfo.EstateSettings.EstateID == EstateID)
s.ReloadEstateData();
}
SendToEstate(EstateID, sendData);
return true;
}
public void SendEstateMessage(uint EstateID, UUID FromID, string FromName, string Message)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["METHOD"] = "estate_message";
sendData["EstateID"] = EstateID.ToString();
sendData["FromID"] = FromID.ToString();
sendData["FromName"] = FromName;
sendData["Message"] = Message;
SendToEstate(EstateID, sendData);
}
private void SendToEstate(uint EstateID, Dictionary<string, object> sendData)
{
List<UUID> regions = m_EstateModule.Scenes[0].GetEstateRegions((int)EstateID);
UUID ScopeID = UUID.Zero;
// Handle local regions locally
//
lock (m_EstateModule.Scenes)
{
foreach (Scene s in m_EstateModule.Scenes)
{
if (regions.Contains(s.RegionInfo.RegionID))
{
// All regions in one estate are in the same scope.
// Use that scope.
//
ScopeID = s.RegionInfo.ScopeID;
regions.Remove(s.RegionInfo.RegionID);
}
}
}
// Our own region should always be in the above list.
// In a standalone this would not be true. But then,
// Scope ID is not relevat there. Use first scope.
//
if (ScopeID == UUID.Zero)
ScopeID = m_EstateModule.Scenes[0].RegionInfo.ScopeID;
// Don't send to the same instance twice
//
List<string> done = new List<string>();
// Send to remote regions
//
foreach (UUID regionID in regions)
{
GridRegion region = m_EstateModule.Scenes[0].GridService.GetRegionByUUID(ScopeID, regionID);
if (region != null)
{
string url = "http://" + region.ExternalHostName + ":" + region.HttpPort;
if (done.Contains(url))
continue;
Call(region, sendData);
done.Add(url);
}
}
}
private bool Call(GridRegion region, Dictionary<string, object> sendData)
{
string reqString = ServerUtils.BuildQueryString(sendData);
// m_log.DebugFormat("[XESTATE CONNECTOR]: queryString = {0}", reqString);
try
{
string url = "http://" + region.ExternalHostName + ":" + region.HttpPort;
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
url + "/estate",
reqString);
if (reply != string.Empty)
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData.ContainsKey("RESULT"))
{
if (replyData["RESULT"].ToString().ToLower() == "true")
return true;
else
return false;
}
else
m_log.DebugFormat("[XESTATE CONNECTOR]: reply data does not contain result field");
}
else
m_log.DebugFormat("[XESTATE CONNECTOR]: received empty reply");
}
catch (Exception e)
{
m_log.DebugFormat("[XESTATE CONNECTOR]: Exception when contacting remote sim: {0}", e.Message);
}
return false;
}
}
}

View File

@@ -0,0 +1,256 @@
/*
* 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 OpenSimulator 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.Collections;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using Nini.Config;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using Mono.Addins;
namespace OpenSim.Region.CoreModules.World.Estate
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XEstate")]
public class XEstateModule : ISharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected List<Scene> m_Scenes = new List<Scene>();
protected bool m_InInfoUpdate = false;
public bool InInfoUpdate
{
get { return m_InInfoUpdate; }
set { m_InInfoUpdate = value; }
}
public List<Scene> Scenes
{
get { return m_Scenes; }
}
protected EstateConnector m_EstateConnector;
public void Initialise(IConfigSource config)
{
int port = 0;
IConfig estateConfig = config.Configs["Estate"];
if (estateConfig != null)
{
port = estateConfig.GetInt("Port", 0);
}
m_EstateConnector = new EstateConnector(this);
// Instantiate the request handler
IHttpServer server = MainServer.GetHttpServer((uint)port);
server.AddStreamHandler(new EstateRequestHandler(this));
}
public void PostInitialise()
{
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
lock (m_Scenes)
m_Scenes.Add(scene);
scene.EventManager.OnNewClient += OnNewClient;
}
public void RegionLoaded(Scene scene)
{
IEstateModule em = scene.RequestModuleInterface<IEstateModule>();
em.OnRegionInfoChange += OnRegionInfoChange;
em.OnEstateInfoChange += OnEstateInfoChange;
em.OnEstateMessage += OnEstateMessage;
}
public void RemoveRegion(Scene scene)
{
scene.EventManager.OnNewClient -= OnNewClient;
lock (m_Scenes)
m_Scenes.Remove(scene);
}
public string Name
{
get { return "EstateModule"; }
}
public Type ReplaceableInterface
{
get { return null; }
}
private Scene FindScene(UUID RegionID)
{
foreach (Scene s in Scenes)
{
if (s.RegionInfo.RegionID == RegionID)
return s;
}
return null;
}
private void OnRegionInfoChange(UUID RegionID)
{
Scene s = FindScene(RegionID);
if (s == null)
return;
if (!m_InInfoUpdate)
m_EstateConnector.SendUpdateCovenant(s.RegionInfo.EstateSettings.EstateID, s.RegionInfo.RegionSettings.Covenant);
}
private void OnEstateInfoChange(UUID RegionID)
{
Scene s = FindScene(RegionID);
if (s == null)
return;
if (!m_InInfoUpdate)
m_EstateConnector.SendUpdateEstate(s.RegionInfo.EstateSettings.EstateID);
}
private void OnEstateMessage(UUID RegionID, UUID FromID, string FromName, string Message)
{
Scene senderScenes = FindScene(RegionID);
if (senderScenes == null)
return;
uint estateID = senderScenes.RegionInfo.EstateSettings.EstateID;
foreach (Scene s in Scenes)
{
if (s.RegionInfo.EstateSettings.EstateID == estateID)
{
IDialogModule dm = s.RequestModuleInterface<IDialogModule>();
if (dm != null)
{
dm.SendNotificationToUsersInRegion(FromID, FromName,
Message);
}
}
}
if (!m_InInfoUpdate)
m_EstateConnector.SendEstateMessage(estateID, FromID, FromName, Message);
}
private void OnNewClient(IClientAPI client)
{
client.OnEstateTeleportOneUserHomeRequest += OnEstateTeleportOneUserHomeRequest;
client.OnEstateTeleportAllUsersHomeRequest += OnEstateTeleportAllUsersHomeRequest;
}
private void OnEstateTeleportOneUserHomeRequest(IClientAPI client, UUID invoice, UUID senderID, UUID prey)
{
if (prey == UUID.Zero)
return;
if (!(client.Scene is Scene))
return;
Scene scene = (Scene)client.Scene;
uint estateID = scene.RegionInfo.EstateSettings.EstateID;
if (!scene.Permissions.CanIssueEstateCommand(client.AgentId, false))
return;
foreach (Scene s in Scenes)
{
if (s == scene)
continue; // Already handles by estate module
if (s.RegionInfo.EstateSettings.EstateID != estateID)
continue;
ScenePresence p = scene.GetScenePresence(prey);
if (p != null && !p.IsChildAgent)
{
p.ControllingClient.SendTeleportStart(16);
scene.TeleportClientHome(prey, p.ControllingClient);
}
}
m_EstateConnector.SendTeleportHomeOneUser(estateID, prey);
}
private void OnEstateTeleportAllUsersHomeRequest(IClientAPI client, UUID invoice, UUID senderID)
{
if (!(client.Scene is Scene))
return;
Scene scene = (Scene)client.Scene;
uint estateID = scene.RegionInfo.EstateSettings.EstateID;
if (!scene.Permissions.CanIssueEstateCommand(client.AgentId, false))
return;
foreach (Scene s in Scenes)
{
if (s == scene)
continue; // Already handles by estate module
if (s.RegionInfo.EstateSettings.EstateID != estateID)
continue;
scene.ForEachScenePresence(delegate(ScenePresence p) {
if (p != null && !p.IsChildAgent)
{
p.ControllingClient.SendTeleportStart(16);
scene.TeleportClientHome(p.ControllingClient.AgentId, p.ControllingClient);
}
});
}
m_EstateConnector.SendTeleportHomeAllUsers(estateID);
}
}
}

View File

@@ -0,0 +1,298 @@
/*
* 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 OpenSimulator 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.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml;
using OpenSim.Framework;
using OpenSim.Server.Base;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenMetaverse;
using log4net;
namespace OpenSim.Region.CoreModules.World.Estate
{
public class EstateRequestHandler : BaseStreamHandler
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected XEstateModule m_EstateModule;
protected Object m_RequestLock = new Object();
public EstateRequestHandler(XEstateModule fmodule)
: base("POST", "/estate")
{
m_EstateModule = fmodule;
}
protected override byte[] ProcessRequest(string path, Stream requestData,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
StreamReader sr = new StreamReader(requestData);
string body = sr.ReadToEnd();
sr.Close();
body = body.Trim();
m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body);
try
{
lock (m_RequestLock)
{
Dictionary<string, object> request =
ServerUtils.ParseQueryString(body);
if (!request.ContainsKey("METHOD"))
return FailureResult();
string method = request["METHOD"].ToString();
request.Remove("METHOD");
try
{
m_EstateModule.InInfoUpdate = false;
switch (method)
{
case "update_covenant":
return UpdateCovenant(request);
case "update_estate":
return UpdateEstate(request);
case "estate_message":
return EstateMessage(request);
case "teleport_home_one_user":
return TeleportHomeOneUser(request);
case "teleport_home_all_users":
return TeleportHomeAllUsers(request);
}
}
finally
{
m_EstateModule.InInfoUpdate = false;
}
}
}
catch (Exception e)
{
m_log.Debug("[XESTATE]: Exception {0}" + e.ToString());
}
return FailureResult();
}
byte[] TeleportHomeAllUsers(Dictionary<string, object> request)
{
UUID PreyID = UUID.Zero;
int EstateID = 0;
if (!request.ContainsKey("EstateID"))
return FailureResult();
if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID))
return FailureResult();
foreach (Scene s in m_EstateModule.Scenes)
{
if (s.RegionInfo.EstateSettings.EstateID == EstateID)
{
s.ForEachScenePresence(delegate(ScenePresence p) {
if (p != null && !p.IsChildAgent)
{
p.ControllingClient.SendTeleportStart(16);
s.TeleportClientHome(p.ControllingClient.AgentId, p.ControllingClient);
}
});
}
}
return SuccessResult();
}
byte[] TeleportHomeOneUser(Dictionary<string, object> request)
{
UUID PreyID = UUID.Zero;
int EstateID = 0;
if (!request.ContainsKey("PreyID") ||
!request.ContainsKey("EstateID"))
{
return FailureResult();
}
if (!UUID.TryParse(request["PreyID"].ToString(), out PreyID))
return FailureResult();
if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID))
return FailureResult();
foreach (Scene s in m_EstateModule.Scenes)
{
if (s.RegionInfo.EstateSettings.EstateID == EstateID)
{
ScenePresence p = s.GetScenePresence(PreyID);
if (p != null && !p.IsChildAgent)
{
p.ControllingClient.SendTeleportStart(16);
s.TeleportClientHome(PreyID, p.ControllingClient);
}
}
}
return SuccessResult();
}
byte[] EstateMessage(Dictionary<string, object> request)
{
UUID FromID = UUID.Zero;
string FromName = String.Empty;
string Message = String.Empty;
int EstateID = 0;
if (!request.ContainsKey("FromID") ||
!request.ContainsKey("FromName") ||
!request.ContainsKey("Message") ||
!request.ContainsKey("EstateID"))
{
return FailureResult();
}
if (!UUID.TryParse(request["FromID"].ToString(), out FromID))
return FailureResult();
if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID))
return FailureResult();
FromName = request["FromName"].ToString();
Message = request["Message"].ToString();
foreach (Scene s in m_EstateModule.Scenes)
{
if (s.RegionInfo.EstateSettings.EstateID == EstateID)
{
IDialogModule dm = s.RequestModuleInterface<IDialogModule>();
if (dm != null)
{
dm.SendNotificationToUsersInRegion(FromID, FromName,
Message);
}
}
}
return SuccessResult();
}
byte[] UpdateCovenant(Dictionary<string, object> request)
{
UUID CovenantID = UUID.Zero;
int EstateID = 0;
if (!request.ContainsKey("CovenantID") || !request.ContainsKey("EstateID"))
return FailureResult();
if (!UUID.TryParse(request["CovenantID"].ToString(), out CovenantID))
return FailureResult();
if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID))
return FailureResult();
foreach (Scene s in m_EstateModule.Scenes)
{
if (s.RegionInfo.EstateSettings.EstateID == (uint)EstateID)
s.RegionInfo.RegionSettings.Covenant = CovenantID;
}
return SuccessResult();
}
byte[] UpdateEstate(Dictionary<string, object> request)
{
int EstateID = 0;
if (!request.ContainsKey("EstateID"))
return FailureResult();
if (!Int32.TryParse(request["EstateID"].ToString(), out EstateID))
return FailureResult();
foreach (Scene s in m_EstateModule.Scenes)
{
if (s.RegionInfo.EstateSettings.EstateID == (uint)EstateID)
s.ReloadEstateData();
}
return SuccessResult();
}
private byte[] FailureResult()
{
return BoolResult(false);
}
private byte[] SuccessResult()
{
return BoolResult(true);
}
private byte[] BoolResult(bool value)
{
XmlDocument doc = new XmlDocument();
XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
"", "");
doc.AppendChild(xmlnode);
XmlElement rootElement = doc.CreateElement("", "ServerResponse",
"");
doc.AppendChild(rootElement);
XmlElement result = doc.CreateElement("", "RESULT", "");
result.AppendChild(doc.CreateTextNode(value.ToString()));
rootElement.AppendChild(result);
return DocToBytes(doc);
}
private byte[] DocToBytes(XmlDocument doc)
{
MemoryStream ms = new MemoryStream();
XmlTextWriter xw = new XmlTextWriter(ms, null);
xw.Formatting = Formatting.Indented;
doc.WriteTo(xw);
xw.Flush();
return ms.ToArray();
}
}
}

View File

@@ -42,7 +42,6 @@ using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Physics.Manager;
@@ -70,10 +69,10 @@ namespace OpenSim.Region.CoreModules.World.Land
private LandChannel landChannel;
private Scene m_scene;
protected Commander m_commander = new Commander("land");
protected IUserManagement m_userManager;
protected IPrimCountModule m_primCountModule;
protected IDialogModule m_Dialog;
// Minimum for parcels to work is 64m even if we don't actually use them.
#pragma warning disable 0429
@@ -147,52 +146,33 @@ namespace OpenSim.Region.CoreModules.World.Land
m_scene.EventManager.OnIncomingLandDataFromStorage += EventManagerOnIncomingLandDataFromStorage;
m_scene.EventManager.OnSetAllowForcefulBan += EventManagerOnSetAllowedForcefulBan;
m_scene.EventManager.OnRegisterCaps += EventManagerOnRegisterCaps;
m_scene.EventManager.OnPluginConsole += EventManagerOnPluginConsole;
lock (m_scene)
{
m_scene.LandChannel = (ILandChannel)landChannel;
}
InstallInterfaces();
RegisterCommands();
}
public void RegionLoaded(Scene scene)
{
m_userManager = m_scene.RequestModuleInterface<IUserManagement>();
m_primCountModule = m_scene.RequestModuleInterface<IPrimCountModule>();
m_Dialog = m_scene.RequestModuleInterface<IDialogModule>();
}
public void RemoveRegion(Scene scene)
{
// TODO: Also release other event manager listeners here
m_scene.EventManager.OnPluginConsole -= EventManagerOnPluginConsole;
m_scene.UnregisterModuleCommander(m_commander.Name);
// TODO: Release event manager listeners here
}
/// <summary>
/// Processes commandline input. Do not call directly.
/// </summary>
/// <param name="args">Commandline arguments</param>
protected void EventManagerOnPluginConsole(string[] args)
{
if (args[0] == "land")
{
if (args.Length == 1)
{
m_commander.ProcessConsoleCommand("help", new string[0]);
return;
}
string[] tmpArgs = new string[args.Length - 2];
int i;
for (i = 2; i < args.Length; i++)
tmpArgs[i - 2] = args[i];
m_commander.ProcessConsoleCommand(args[1], tmpArgs);
}
}
// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
// {
// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
// reason = "You are not allowed to enter this sim.";
// return nearestParcel != null;
// }
void EventManagerOnNewClient(IClientAPI client)
{
@@ -213,6 +193,7 @@ namespace OpenSim.Region.CoreModules.World.Land
client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
client.OnParcelEjectUser += ClientOnParcelEjectUser;
client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
client.OnSetStartLocationRequest += ClientOnSetHome;
EntityBase presenceEntity;
if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
@@ -1896,44 +1877,131 @@ namespace OpenSim.Region.CoreModules.World.Land
land.LandData.ParcelAccessList.Add(entry);
}
}
protected void InstallInterfaces()
/// <summary>
/// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="regionHandle"></param>
/// <param name="position"></param>
/// <param name="lookAt"></param>
/// <param name="flags"></param>
public virtual void ClientOnSetHome(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
{
Command clearCommand
= new Command("clear", CommandIntentions.COMMAND_HAZARDOUS, ClearCommand, "Clears all the parcels from the region.");
Command showCommand
= new Command("show", CommandIntentions.COMMAND_STATISTICAL, ShowParcelsCommand, "Shows all parcels on the region.");
// Let's find the parcel in question
ILandObject land = landChannel.GetLandObject(position);
if (land == null || m_scene.GridUserService == null)
{
m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed.");
return;
}
m_commander.RegisterCommand("clear", clearCommand);
m_commander.RegisterCommand("show", showCommand);
// Gather some data
ulong gpowers = remoteClient.GetGroupPowers(land.LandData.GroupID);
SceneObjectGroup telehub = null;
if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero)
// Does the telehub exist in the scene?
telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject);
// Add this to our scene so scripts can call these functions
m_scene.RegisterModuleCommander(m_commander);
// Can the user set home here?
if (// (a) gods and land managers can set home
m_scene.Permissions.IsAdministrator(remoteClient.AgentId) ||
m_scene.Permissions.IsGod(remoteClient.AgentId) ||
// (b) land owners can set home
remoteClient.AgentId == land.LandData.OwnerID ||
// (c) members of the land-associated group in roles that can set home
((gpowers & (ulong)GroupPowers.AllowSetHome) == (ulong)GroupPowers.AllowSetHome) ||
// (d) parcels with telehubs can be the home of anyone
(telehub != null && land.ContainsPoint((int)telehub.AbsolutePosition.X, (int)telehub.AbsolutePosition.Y)))
{
if (m_scene.GridUserService.SetHome(remoteClient.AgentId.ToString(), land.RegionUUID, position, lookAt))
// FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
m_Dialog.SendAlertToUser(remoteClient, "Home position set.");
else
m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed.");
}
else
m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel.");
}
protected void RegisterCommands()
{
ICommands commands = MainConsole.Instance.Commands;
commands.AddCommand(
"Land", false, "land clear",
"land clear",
"Clear all the parcels from the region.",
"Command will ask for confirmation before proceeding.",
HandleClearCommand);
commands.AddCommand(
"Land", false, "land show",
"land show [<local-land-id>]",
"Show information about the parcels on the region.",
"If no local land ID is given, then summary information about all the parcels is shown.\n"
+ "If a local land ID is given then full information about that parcel is shown.",
HandleShowCommand);
}
protected void ClearCommand(Object[] args)
protected void HandleClearCommand(string module, string[] args)
{
if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
return;
string response = MainConsole.Instance.CmdPrompt(
string.Format(
"Are you sure that you want to clear all land parcels from {0} (y or n)",
m_scene.RegionInfo.RegionName),
"Are you sure that you want to clear all land parcels from {0} (y or n)", m_scene.Name),
"n");
if (response.ToLower() == "y")
{
Clear(true);
MainConsole.Instance.OutputFormat("Cleared all parcels from {0}", m_scene.RegionInfo.RegionName);
MainConsole.Instance.OutputFormat("Cleared all parcels from {0}", m_scene.Name);
}
else
{
MainConsole.Instance.OutputFormat("Aborting clear of all parcels from {0}", m_scene.RegionInfo.RegionName);
MainConsole.Instance.OutputFormat("Aborting clear of all parcels from {0}", m_scene.Name);
}
}
protected void ShowParcelsCommand(Object[] args)
protected void HandleShowCommand(string module, string[] args)
{
StringBuilder report = new StringBuilder();
if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
return;
StringBuilder report = new StringBuilder();
if (args.Length <= 2)
{
AppendParcelsSummaryReport(report);
}
else
{
int landLocalId;
if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[2], out landLocalId))
return;
ILandObject lo;
lock (m_landList)
{
if (!m_landList.TryGetValue(landLocalId, out lo))
{
MainConsole.Instance.OutputFormat("No parcel found with local ID {0}", landLocalId);
return;
}
}
AppendParcelReport(report, lo);
}
MainConsole.Instance.Output(report.ToString());
}
private void AppendParcelsSummaryReport(StringBuilder report)
{
report.AppendFormat("Land information for {0}\n", m_scene.RegionInfo.RegionName);
report.AppendFormat(
"{0,-20} {1,-10} {2,-9} {3,-18} {4,-18} {5,-20}\n",
@@ -1979,6 +2047,69 @@ namespace OpenSim.Region.CoreModules.World.Land
ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
}
}
}
private void AppendParcelReport(StringBuilder report, ILandObject lo)
{
LandData ld = lo.LandData;
ConsoleDisplayList cdl = new ConsoleDisplayList();
cdl.AddRow("Parcel name", ld.Name);
cdl.AddRow("Local ID", ld.LocalID);
cdl.AddRow("Description", ld.Description);
cdl.AddRow("Snapshot ID", ld.SnapshotID);
cdl.AddRow("Area", ld.Area);
cdl.AddRow("Starts", lo.StartPoint);
cdl.AddRow("Ends", lo.EndPoint);
cdl.AddRow("AABB Min", ld.AABBMin);
cdl.AddRow("AABB Max", ld.AABBMax);
cdl.AddRow("Owner", m_userManager.GetUserName(ld.OwnerID));
cdl.AddRow("Is group owned?", ld.IsGroupOwned);
cdl.AddRow("GroupID", ld.GroupID);
cdl.AddRow("Status", ld.Status);
cdl.AddRow("Flags", (ParcelFlags)ld.Flags);
cdl.AddRow("Landing Type", (LandingType)ld.LandingType);
cdl.AddRow("User Location", ld.UserLocation);
cdl.AddRow("User look at", ld.UserLookAt);
cdl.AddRow("Other clean time", ld.OtherCleanTime);
cdl.AddRow("Max Prims", lo.GetParcelMaxPrimCount());
IPrimCounts pc = lo.PrimCounts;
cdl.AddRow("Owner Prims", pc.Owner);
cdl.AddRow("Group Prims", pc.Group);
cdl.AddRow("Other Prims", pc.Others);
cdl.AddRow("Selected Prims", pc.Selected);
cdl.AddRow("Total Prims", pc.Total);
cdl.AddRow("Music URL", ld.MusicURL);
cdl.AddRow("Obscure Music", ld.ObscureMusic);
cdl.AddRow("Media ID", ld.MediaID);
cdl.AddRow("Media Autoscale", Convert.ToBoolean(ld.MediaAutoScale));
cdl.AddRow("Media URL", ld.MediaURL);
cdl.AddRow("Media Type", ld.MediaType);
cdl.AddRow("Media Description", ld.MediaDescription);
cdl.AddRow("Media Width", ld.MediaWidth);
cdl.AddRow("Media Height", ld.MediaHeight);
cdl.AddRow("Media Loop", ld.MediaLoop);
cdl.AddRow("Obscure Media", ld.ObscureMedia);
cdl.AddRow("Parcel Category", ld.Category);
cdl.AddRow("Claim Date", ld.ClaimDate);
cdl.AddRow("Claim Price", ld.ClaimPrice);
cdl.AddRow("Pass Hours", ld.PassHours);
cdl.AddRow("Pass Price", ld.PassPrice);
cdl.AddRow("Auction ID", ld.AuctionID);
cdl.AddRow("Authorized Buyer ID", ld.AuthBuyerID);
cdl.AddRow("Sale Price", ld.SalePrice);
cdl.AddToStringBuilder(report);
}
}
}

View File

@@ -82,14 +82,14 @@ namespace OpenSim.Region.CoreModules.World.Land
set { m_landData = value; }
}
public IPrimCounts PrimCounts { get; set; }
public UUID RegionUUID
{
get { return m_scene.RegionInfo.RegionID; }
}
public Vector3 StartPoint
{
get
@@ -102,11 +102,11 @@ namespace OpenSim.Region.CoreModules.World.Land
return new Vector3(x * 4, y * 4, 0);
}
}
return new Vector3(-1, -1, -1);
}
}
}
public Vector3 EndPoint
{
get
@@ -117,15 +117,15 @@ namespace OpenSim.Region.CoreModules.World.Land
{
if (LandBitmap[x, y])
{
return new Vector3(x * 4, y * 4, 0);
}
return new Vector3(x * 4 + 4, y * 4 + 4, 0);
}
}
}
}
return new Vector3(-1, -1, -1);
}
}
#region Constructors
public LandObject(UUID owner_id, bool is_group_owned, Scene scene)
@@ -249,13 +249,6 @@ namespace OpenSim.Region.CoreModules.World.Land
if (estateModule != null)
regionFlags = estateModule.GetRegionFlags();
// In a perfect world, this would have worked.
//
// if ((landData.Flags & (uint)ParcelFlags.AllowLandmark) != 0)
// regionFlags |= (uint)RegionFlags.AllowLandmark;
// if (landData.OwnerID == remote_client.AgentId)
// regionFlags |= (uint)RegionFlags.AllowSetHome;
int seq_id;
if (snap_selection && (sequence_id == 0))
{

View File

@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
public struct DrawStruct
{
public DrawRoutine dr;
public Rectangle rect;
// public Rectangle rect;
public SolidBrush brush;
public face[] trns;
}
@@ -119,6 +119,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
{
mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID);
}
return mapbmp;
}
@@ -127,7 +128,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
try
{
using (Bitmap mapbmp = CreateMapTile())
return OpenJPEG.EncodeFromImage(mapbmp, true);
{
if (mapbmp != null)
return OpenJPEG.EncodeFromImage(mapbmp, true);
}
}
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
{
@@ -277,321 +281,331 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
tc = Environment.TickCount;
m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
EntityBase[] objs = whichScene.GetEntities();
Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
//SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
List<float> z_sortheights = new List<float>();
List<uint> z_localIDs = new List<uint>();
Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
lock (objs)
try
{
foreach (EntityBase obj in objs)
//SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
lock (objs)
{
// Only draw the contents of SceneObjectGroup
if (obj is SceneObjectGroup)
foreach (EntityBase obj in objs)
{
SceneObjectGroup mapdot = (SceneObjectGroup)obj;
Color mapdotspot = Color.Gray; // Default color when prim color is white
// Loop over prim in group
foreach (SceneObjectPart part in mapdot.Parts)
// Only draw the contents of SceneObjectGroup
if (obj is SceneObjectGroup)
{
if (part == null)
continue;
// Draw if the object is at least 1 meter wide in any direction
if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
SceneObjectGroup mapdot = (SceneObjectGroup)obj;
Color mapdotspot = Color.Gray; // Default color when prim color is white
// Loop over prim in group
foreach (SceneObjectPart part in mapdot.Parts)
{
// Try to get the RGBA of the default texture entry..
//
try
{
// get the null checks out of the way
// skip the ones that break
if (part == null)
continue;
if (part.Shape == null)
continue;
if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass)
continue; // eliminates trees from this since we don't really have a good tree representation
// if you want tree blocks on the map comment the above line and uncomment the below line
//mapdotspot = Color.PaleGreen;
Primitive.TextureEntry textureEntry = part.Shape.Textures;
if (textureEntry == null || textureEntry.DefaultTexture == null)
continue;
Color4 texcolor = textureEntry.DefaultTexture.RGBA;
// Not sure why some of these are null, oh well.
int colorr = 255 - (int)(texcolor.R * 255f);
int colorg = 255 - (int)(texcolor.G * 255f);
int colorb = 255 - (int)(texcolor.B * 255f);
if (!(colorr == 255 && colorg == 255 && colorb == 255))
{
//Try to set the map spot color
try
{
// If the color gets goofy somehow, skip it *shakes fist at Color4
mapdotspot = Color.FromArgb(colorr, colorg, colorb);
}
catch (ArgumentException)
{
}
}
}
catch (IndexOutOfRangeException)
{
// Windows Array
}
catch (ArgumentOutOfRangeException)
{
// Mono Array
}
Vector3 pos = part.GetWorldPosition();
// skip prim outside of retion
if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
if (part == null)
continue;
// skip prim in non-finite position
if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
continue;
// Figure out if object is under 256m above the height of the terrain
bool isBelow256AboveTerrain = false;
try
// Draw if the object is at least 1 meter wide in any direction
if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
{
isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
}
catch (Exception)
{
}
if (isBelow256AboveTerrain)
{
// Translate scale by rotation so scale is represented properly when object is rotated
Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
Vector3 scale = new Vector3();
Vector3 tScale = new Vector3();
Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
Quaternion llrot = part.GetWorldRotation();
Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
scale = lscale * rot;
// negative scales don't work in this situation
scale.X = Math.Abs(scale.X);
scale.Y = Math.Abs(scale.Y);
scale.Z = Math.Abs(scale.Z);
// This scaling isn't very accurate and doesn't take into account the face rotation :P
int mapdrawstartX = (int)(pos.X - scale.X);
int mapdrawstartY = (int)(pos.Y - scale.Y);
int mapdrawendX = (int)(pos.X + scale.X);
int mapdrawendY = (int)(pos.Y + scale.Y);
// If object is beyond the edge of the map, don't draw it to avoid errors
if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
|| mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
|| mapdrawendY > ((int)Constants.RegionSize - 1))
continue;
#region obb face reconstruction part duex
Vector3[] vertexes = new Vector3[8];
// float[] distance = new float[6];
Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[0].x = pos.X + vertexes[0].x;
//vertexes[0].y = pos.Y + vertexes[0].y;
//vertexes[0].z = pos.Z + vertexes[0].z;
FaceA[0] = vertexes[0];
FaceB[3] = vertexes[0];
FaceA[4] = vertexes[0];
tScale = lscale;
scale = ((tScale * rot));
vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[1].x = pos.X + vertexes[1].x;
// vertexes[1].y = pos.Y + vertexes[1].y;
//vertexes[1].z = pos.Z + vertexes[1].z;
FaceB[0] = vertexes[1];
FaceA[1] = vertexes[1];
FaceC[4] = vertexes[1];
tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[2].x = pos.X + vertexes[2].x;
//vertexes[2].y = pos.Y + vertexes[2].y;
//vertexes[2].z = pos.Z + vertexes[2].z;
FaceC[0] = vertexes[2];
FaceD[3] = vertexes[2];
FaceC[5] = vertexes[2];
tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[3].x = pos.X + vertexes[3].x;
// vertexes[3].y = pos.Y + vertexes[3].y;
// vertexes[3].z = pos.Z + vertexes[3].z;
FaceD[0] = vertexes[3];
FaceC[1] = vertexes[3];
FaceA[5] = vertexes[3];
tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[4].x = pos.X + vertexes[4].x;
// vertexes[4].y = pos.Y + vertexes[4].y;
// vertexes[4].z = pos.Z + vertexes[4].z;
FaceB[1] = vertexes[4];
FaceA[2] = vertexes[4];
FaceD[4] = vertexes[4];
tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[5].x = pos.X + vertexes[5].x;
// vertexes[5].y = pos.Y + vertexes[5].y;
// vertexes[5].z = pos.Z + vertexes[5].z;
FaceD[1] = vertexes[5];
FaceC[2] = vertexes[5];
FaceB[5] = vertexes[5];
tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[6].x = pos.X + vertexes[6].x;
// vertexes[6].y = pos.Y + vertexes[6].y;
// vertexes[6].z = pos.Z + vertexes[6].z;
FaceB[2] = vertexes[6];
FaceA[3] = vertexes[6];
FaceB[4] = vertexes[6];
tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[7].x = pos.X + vertexes[7].x;
// vertexes[7].y = pos.Y + vertexes[7].y;
// vertexes[7].z = pos.Z + vertexes[7].z;
FaceD[2] = vertexes[7];
FaceC[3] = vertexes[7];
FaceD[5] = vertexes[7];
#endregion
//int wy = 0;
//bool breakYN = false; // If we run into an error drawing, break out of the
// loop so we don't lag to death on error handling
DrawStruct ds = new DrawStruct();
ds.brush = new SolidBrush(mapdotspot);
//ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
ds.trns = new face[FaceA.Length];
for (int i = 0; i < FaceA.Length; i++)
// Try to get the RGBA of the default texture entry..
//
try
{
Point[] working = new Point[5];
working[0] = project(FaceA[i], axPos);
working[1] = project(FaceB[i], axPos);
working[2] = project(FaceD[i], axPos);
working[3] = project(FaceC[i], axPos);
working[4] = project(FaceA[i], axPos);
// get the null checks out of the way
// skip the ones that break
if (part == null)
continue;
face workingface = new face();
workingface.pts = working;
if (part.Shape == null)
continue;
ds.trns[i] = workingface;
if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass)
continue; // eliminates trees from this since we don't really have a good tree representation
// if you want tree blocks on the map comment the above line and uncomment the below line
//mapdotspot = Color.PaleGreen;
Primitive.TextureEntry textureEntry = part.Shape.Textures;
if (textureEntry == null || textureEntry.DefaultTexture == null)
continue;
Color4 texcolor = textureEntry.DefaultTexture.RGBA;
// Not sure why some of these are null, oh well.
int colorr = 255 - (int)(texcolor.R * 255f);
int colorg = 255 - (int)(texcolor.G * 255f);
int colorb = 255 - (int)(texcolor.B * 255f);
if (!(colorr == 255 && colorg == 255 && colorb == 255))
{
//Try to set the map spot color
try
{
// If the color gets goofy somehow, skip it *shakes fist at Color4
mapdotspot = Color.FromArgb(colorr, colorg, colorb);
}
catch (ArgumentException)
{
}
}
}
catch (IndexOutOfRangeException)
{
// Windows Array
}
catch (ArgumentOutOfRangeException)
{
// Mono Array
}
z_sort.Add(part.LocalId, ds);
z_localIDs.Add(part.LocalId);
z_sortheights.Add(pos.Z);
Vector3 pos = part.GetWorldPosition();
//for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
//{
//for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
// skip prim outside of retion
if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
continue;
// skip prim in non-finite position
if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
continue;
// Figure out if object is under 256m above the height of the terrain
bool isBelow256AboveTerrain = false;
try
{
isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
}
catch (Exception)
{
}
if (isBelow256AboveTerrain)
{
// Translate scale by rotation so scale is represented properly when object is rotated
Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
Vector3 scale = new Vector3();
Vector3 tScale = new Vector3();
Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
Quaternion llrot = part.GetWorldRotation();
Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
scale = lscale * rot;
// negative scales don't work in this situation
scale.X = Math.Abs(scale.X);
scale.Y = Math.Abs(scale.Y);
scale.Z = Math.Abs(scale.Z);
// This scaling isn't very accurate and doesn't take into account the face rotation :P
int mapdrawstartX = (int)(pos.X - scale.X);
int mapdrawstartY = (int)(pos.Y - scale.Y);
int mapdrawendX = (int)(pos.X + scale.X);
int mapdrawendY = (int)(pos.Y + scale.Y);
// If object is beyond the edge of the map, don't draw it to avoid errors
if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
|| mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
|| mapdrawendY > ((int)Constants.RegionSize - 1))
continue;
#region obb face reconstruction part duex
Vector3[] vertexes = new Vector3[8];
// float[] distance = new float[6];
Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[0].x = pos.X + vertexes[0].x;
//vertexes[0].y = pos.Y + vertexes[0].y;
//vertexes[0].z = pos.Z + vertexes[0].z;
FaceA[0] = vertexes[0];
FaceB[3] = vertexes[0];
FaceA[4] = vertexes[0];
tScale = lscale;
scale = ((tScale * rot));
vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[1].x = pos.X + vertexes[1].x;
// vertexes[1].y = pos.Y + vertexes[1].y;
//vertexes[1].z = pos.Z + vertexes[1].z;
FaceB[0] = vertexes[1];
FaceA[1] = vertexes[1];
FaceC[4] = vertexes[1];
tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[2].x = pos.X + vertexes[2].x;
//vertexes[2].y = pos.Y + vertexes[2].y;
//vertexes[2].z = pos.Z + vertexes[2].z;
FaceC[0] = vertexes[2];
FaceD[3] = vertexes[2];
FaceC[5] = vertexes[2];
tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
//vertexes[3].x = pos.X + vertexes[3].x;
// vertexes[3].y = pos.Y + vertexes[3].y;
// vertexes[3].z = pos.Z + vertexes[3].z;
FaceD[0] = vertexes[3];
FaceC[1] = vertexes[3];
FaceA[5] = vertexes[3];
tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[4].x = pos.X + vertexes[4].x;
// vertexes[4].y = pos.Y + vertexes[4].y;
// vertexes[4].z = pos.Z + vertexes[4].z;
FaceB[1] = vertexes[4];
FaceA[2] = vertexes[4];
FaceD[4] = vertexes[4];
tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[5].x = pos.X + vertexes[5].x;
// vertexes[5].y = pos.Y + vertexes[5].y;
// vertexes[5].z = pos.Z + vertexes[5].z;
FaceD[1] = vertexes[5];
FaceC[2] = vertexes[5];
FaceB[5] = vertexes[5];
tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
scale = ((tScale * rot));
vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[6].x = pos.X + vertexes[6].x;
// vertexes[6].y = pos.Y + vertexes[6].y;
// vertexes[6].z = pos.Z + vertexes[6].z;
FaceB[2] = vertexes[6];
FaceA[3] = vertexes[6];
FaceB[4] = vertexes[6];
tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
scale = ((tScale * rot));
vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
// vertexes[7].x = pos.X + vertexes[7].x;
// vertexes[7].y = pos.Y + vertexes[7].y;
// vertexes[7].z = pos.Z + vertexes[7].z;
FaceD[2] = vertexes[7];
FaceC[3] = vertexes[7];
FaceD[5] = vertexes[7];
#endregion
//int wy = 0;
//bool breakYN = false; // If we run into an error drawing, break out of the
// loop so we don't lag to death on error handling
DrawStruct ds = new DrawStruct();
ds.brush = new SolidBrush(mapdotspot);
//ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
ds.trns = new face[FaceA.Length];
for (int i = 0; i < FaceA.Length; i++)
{
Point[] working = new Point[5];
working[0] = project(FaceA[i], axPos);
working[1] = project(FaceB[i], axPos);
working[2] = project(FaceD[i], axPos);
working[3] = project(FaceC[i], axPos);
working[4] = project(FaceA[i], axPos);
face workingface = new face();
workingface.pts = working;
ds.trns[i] = workingface;
}
z_sort.Add(part.LocalId, ds);
z_localIDs.Add(part.LocalId);
z_sortheights.Add(pos.Z);
//for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
//{
//m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
//try
//for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
//{
// Remember, flip the y!
// mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
//}
//catch (ArgumentException)
//{
// breakYN = true;
//m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
//try
//{
// Remember, flip the y!
// mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
//}
//catch (ArgumentException)
//{
// breakYN = true;
//}
//if (breakYN)
// break;
//}
//if (breakYN)
// break;
//}
} // Object is within 256m Z of terrain
} // object is at least a meter wide
} // loop over group children
} // entitybase is sceneobject group
} // foreach loop over entities
//if (breakYN)
// break;
//}
} // Object is within 256m Z of terrain
} // object is at least a meter wide
} // loop over group children
} // entitybase is sceneobject group
} // foreach loop over entities
float[] sortedZHeights = z_sortheights.ToArray();
uint[] sortedlocalIds = z_localIDs.ToArray();
float[] sortedZHeights = z_sortheights.ToArray();
uint[] sortedlocalIds = z_localIDs.ToArray();
// Sort prim by Z position
Array.Sort(sortedZHeights, sortedlocalIds);
// Sort prim by Z position
Array.Sort(sortedZHeights, sortedlocalIds);
Graphics g = Graphics.FromImage(mapbmp);
for (int s = 0; s < sortedZHeights.Length; s++)
{
if (z_sort.ContainsKey(sortedlocalIds[s]))
using (Graphics g = Graphics.FromImage(mapbmp))
{
DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
for (int r = 0; r < rectDrawStruct.trns.Length; r++)
for (int s = 0; s < sortedZHeights.Length; s++)
{
g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts);
if (z_sort.ContainsKey(sortedlocalIds[s]))
{
DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
for (int r = 0; r < rectDrawStruct.trns.Length; r++)
{
g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts);
}
//g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
}
}
//g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
}
}
} // lock entities objs
g.Dispose();
} // lock entities objs
}
finally
{
foreach (DrawStruct ds in z_sort.Values)
ds.brush.Dispose();
}
m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms");
return mapbmp;
}

View File

@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
public void TerrainToBitmap(Bitmap mapbmp)
{
int tc = Environment.TickCount;
m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain");
m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain");
double[,] hm = m_scene.Heightmap.GetDoubles();
bool ShadowDebugContinue = true;
@@ -199,7 +199,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
{
if (!terraincorruptedwarningsaid)
{
m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName);
m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName);
terraincorruptedwarningsaid = true;
}
color = Color.Black;
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
{
if (!terraincorruptedwarningsaid)
{
m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName);
m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName);
terraincorruptedwarningsaid = true;
}
Color black = Color.Black;
@@ -238,7 +238,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
}
}
}
m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
}
}
}
}

View File

@@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
private Bitmap fetchTexture(UUID id)
{
AssetBase asset = m_scene.AssetService.Get(id.ToString());
m_log.DebugFormat("[TexturedMapTileRenderer]: Fetched texture {0}, found: {1}", id, asset != null);
m_log.DebugFormat("[TEXTURED MAP TILE RENDERER]: Fetched texture {0}, found: {1}", id, asset != null);
if (asset == null) return null;
ManagedImage managedImage;
@@ -188,17 +188,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
}
catch (DllNotFoundException)
{
m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id);
m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id);
}
catch (IndexOutOfRangeException)
{
m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
}
catch (Exception)
{
m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
}
return null;
@@ -233,10 +233,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
if (textureID == UUID.Zero) return defaultColor; // not set
if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures
Bitmap bmp = fetchTexture(textureID);
Color color = bmp == null ? defaultColor : computeAverageColor(bmp);
// store it for future reference
m_mapping[textureID] = color;
Color color;
using (Bitmap bmp = fetchTexture(textureID))
{
color = bmp == null ? defaultColor : computeAverageColor(bmp);
// store it for future reference
m_mapping[textureID] = color;
}
return color;
}
@@ -278,7 +282,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
public void TerrainToBitmap(Bitmap mapbmp)
{
int tc = Environment.TickCount;
m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain");
m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain");
// These textures should be in the AssetCache anyway, as every client conneting to this
// region needs them. Except on start, when the map is recreated (before anyone connected),
@@ -412,7 +416,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
}
}
}
m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
}
}
}
}

View File

@@ -205,13 +205,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
item.InvType = (int)InventoryType.Object;
item.Folder = categoryID;
uint nextPerms=(perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
if ((nextPerms & (uint)PermissionMask.Modify) == 0)
perms &= ~(uint)PermissionMask.Modify;
PermissionsUtil.ApplyFoldedPermissions(perms, ref perms);
item.BasePermissions = perms & part.NextOwnerMask;
item.CurrentPermissions = perms & part.NextOwnerMask;

View File

@@ -546,7 +546,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
{
ConsoleDisplayList cdl = new ConsoleDisplayList();
cdl.AddRow("Name", so.Name);
cdl.AddRow("Descrition", so.Description);
cdl.AddRow("Description", so.Description);
cdl.AddRow("Local ID", so.LocalId);
cdl.AddRow("UUID", so.UUID);
cdl.AddRow("Location", string.Format("{0} @ {1}", so.AbsolutePosition, so.Scene.Name));
@@ -631,7 +631,22 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
cdl.AddRow("SculptType", s.SculptType);
cdl.AddRow("State", s.State);
// TODO, unpack and display texture entries
// TODO, need to display more information about textures but in a compact format
// to stop output becoming huge.
for (int i = 0; i < sop.GetNumberOfSides(); i++)
{
Primitive.TextureEntryFace teFace = s.Textures.FaceTextures[i];
UUID textureID;
if (teFace != null)
textureID = teFace.TextureID;
else
textureID = s.Textures.DefaultTexture.TextureID;
cdl.AddRow(string.Format("Face {0} texture ID", i), textureID);
}
//cdl.AddRow("Textures", string.Format("{0} entries", s.Textures.
}

View File

@@ -1453,6 +1453,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
bool permission = false;
// m_log.DebugFormat("[PERMISSIONS MODULE]: Checking rez object at {0} in {1}", objectPosition, m_scene.Name);
ILandObject land = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
if (land == null) return false;

View File

@@ -48,8 +48,8 @@ namespace OpenSim.Region.CoreModules.World.Region
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")]
public class RestartModule : INonSharedRegionModule, IRestartModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_Scene;
protected Timer m_CountdownTimer = null;
@@ -223,11 +223,25 @@ namespace OpenSim.Region.CoreModules.World.Region
public void SetTimer(int intervalSeconds)
{
m_CountdownTimer = new Timer();
m_CountdownTimer.AutoReset = false;
m_CountdownTimer.Interval = intervalSeconds * 1000;
m_CountdownTimer.Elapsed += OnTimer;
m_CountdownTimer.Start();
if (intervalSeconds > 0)
{
m_CountdownTimer = new Timer();
m_CountdownTimer.AutoReset = false;
m_CountdownTimer.Interval = intervalSeconds * 1000;
m_CountdownTimer.Elapsed += OnTimer;
m_CountdownTimer.Start();
}
else if (m_CountdownTimer != null)
{
m_CountdownTimer.Stop();
m_CountdownTimer = null;
}
else
{
m_log.WarnFormat(
"[RESTART MODULE]: Tried to set restart timer to {0} in {1}, which is not a valid interval",
intervalSeconds, m_Scene.Name);
}
}
private void OnTimer(object source, ElapsedEventArgs e)
@@ -332,4 +346,4 @@ namespace OpenSim.Region.CoreModules.World.Region
}
}
}
}
}

View File

@@ -144,7 +144,20 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
<Flags>None</Flags>
<CollisionSound><Guid>00000000-0000-0000-0000-000000000000</Guid></CollisionSound>
<CollisionSoundVolume>0</CollisionSoundVolume>
<DynAttrs><llsd><map><key>MyStore</key><map><key>the answer</key><integer>42</integer></map></map></llsd></DynAttrs>
<DynAttrs>
<llsd>
<map>
<key>MyNamespace</key>
<map>
<key>MyStore</key>
<map>
<key>the answer</key>
<integer>42</integer>
</map>
</map>
</map>
</llsd>
</DynAttrs>
</SceneObjectPart>
</RootPart>
<OtherParts />
@@ -333,7 +346,20 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
<EveryoneMask>0</EveryoneMask>
<NextOwnerMask>2147483647</NextOwnerMask>
<Flags>None</Flags>
<DynAttrs><llsd><map><key>MyStore</key><map><key>last words</key><string>Rosebud</string></map></map></llsd></DynAttrs>
<DynAttrs>
<llsd>
<map>
<key>MyNamespace</key>
<map>
<key>MyStore</key>
<map>
<key>last words</key>
<string>Rosebud</string>
</map>
</map>
</map>
</llsd>
</DynAttrs>
<SitTargetAvatar><UUID>00000000-0000-0000-0000-000000000000</UUID></SitTargetAvatar>
</SceneObjectPart>
<OtherParts />
@@ -362,7 +388,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
Assert.That(rootPart.UUID, Is.EqualTo(new UUID("e6a5a05e-e8cc-4816-8701-04165e335790")));
Assert.That(rootPart.CreatorID, Is.EqualTo(new UUID("a6dacf01-4636-4bb9-8a97-30609438af9d")));
Assert.That(rootPart.Name, Is.EqualTo("PrimMyRide"));
OSDMap store = rootPart.DynAttrs["MyStore"];
OSDMap store = rootPart.DynAttrs.GetStore("MyNamespace", "MyStore");
Assert.AreEqual(42, store["the answer"].AsInteger());
// TODO: Check other properties
@@ -414,13 +440,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
rp.CreatorID = rpCreatorId;
rp.Shape = shape;
string daNamespace = "MyNamespace";
string daStoreName = "MyStore";
string daKey = "foo";
string daValue = "bar";
OSDMap myStore = new OSDMap();
myStore.Add(daKey, daValue);
rp.DynAttrs = new DAMap();
rp.DynAttrs[daStoreName] = myStore;
rp.DynAttrs.SetStore(daNamespace, daStoreName, myStore);
SceneObjectGroup so = new SceneObjectGroup(rp);
@@ -481,7 +508,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
Assert.That(name, Is.EqualTo(rpName));
Assert.That(creatorId, Is.EqualTo(rpCreatorId));
Assert.NotNull(daMap);
Assert.AreEqual(daValue, daMap[daStoreName][daKey].AsString());
Assert.AreEqual(daValue, daMap.GetStore(daNamespace, daStoreName)[daKey].AsString());
}
[Test]
@@ -496,7 +523,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
Assert.That(rootPart.UUID, Is.EqualTo(new UUID("9be68fdd-f740-4a0f-9675-dfbbb536b946")));
Assert.That(rootPart.CreatorID, Is.EqualTo(new UUID("b46ef588-411e-4a8b-a284-d7dcfe8e74ef")));
Assert.That(rootPart.Name, Is.EqualTo("PrimFun"));
OSDMap store = rootPart.DynAttrs["MyStore"];
OSDMap store = rootPart.DynAttrs.GetStore("MyNamespace", "MyStore");
Assert.AreEqual("Rosebud", store["last words"].AsString());
// TODO: Check other properties
@@ -522,13 +549,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
rp.CreatorID = rpCreatorId;
rp.Shape = shape;
string daNamespace = "MyNamespace";
string daStoreName = "MyStore";
string daKey = "foo";
string daValue = "bar";
OSDMap myStore = new OSDMap();
myStore.Add(daKey, daValue);
rp.DynAttrs = new DAMap();
rp.DynAttrs[daStoreName] = myStore;
rp.DynAttrs.SetStore(daNamespace, daStoreName, myStore);
SceneObjectGroup so = new SceneObjectGroup(rp);
@@ -585,7 +613,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
Assert.That(name, Is.EqualTo(rpName));
Assert.That(creatorId, Is.EqualTo(rpCreatorId));
Assert.NotNull(daMap);
Assert.AreEqual(daValue, daMap[daStoreName][daKey].AsString());
Assert.AreEqual(daValue, daMap.GetStore(daNamespace, daStoreName)[daKey].AsString());
}
}
}

View File

@@ -369,6 +369,15 @@ namespace OpenSim.Region.CoreModules.World.Sound
});
}
public void SetSoundQueueing(UUID objectID, bool shouldQueue)
{
SceneObjectPart part;
if (!m_scene.TryGetSceneObjectPart(objectID, out part))
return;
part.SoundQueueing = shouldQueue;
}
#endregion
}
}

View File

@@ -216,13 +216,13 @@ namespace OpenSim.Region.CoreModules
// FIXME: If console region is root then this will be printed by every module. Currently, there is no
// way to prevent this, short of making the entire module shared (which is complete overkill).
// One possibility is to return a bool to signal whether the module has completely handled the command
m_log.InfoFormat("[WIND]: Please change to a specific region in order to set Sun parameters.");
MainConsole.Instance.Output("Please change to a specific region in order to set Sun parameters.");
return;
}
if (m_scene.ConsoleScene() != m_scene)
{
m_log.InfoFormat("[WIND]: Console Scene is not my scene.");
MainConsole.Instance.Output("Console Scene is not my scene.");
return;
}
}
@@ -233,7 +233,9 @@ namespace OpenSim.Region.CoreModules
private void HandleConsoleCommand(string module, string[] cmdparams)
{
ValidateConsole();
m_log.Info("[WIND] The wind command can be used to change the currently active wind model plugin and update the parameters for wind plugins.");
MainConsole.Instance.Output(
"The wind command can be used to change the currently active wind model plugin and update the parameters for wind plugins.");
}
/// <summary>
@@ -246,7 +248,9 @@ namespace OpenSim.Region.CoreModules
if ((cmdparams.Length != 4)
|| !cmdparams[1].Equals("base"))
{
m_log.Info("[WIND] Invalid parameters to change parameters for Wind module base, usage: wind base <parameter> <value>");
MainConsole.Instance.Output(
"Invalid parameters to change parameters for Wind module base, usage: wind base <parameter> <value>");
return;
}
@@ -261,7 +265,9 @@ namespace OpenSim.Region.CoreModules
}
else
{
m_log.InfoFormat("[WIND] Invalid value {0} specified for {1}", cmdparams[3], cmdparams[2]);
MainConsole.Instance.OutputFormat(
"Invalid value {0} specified for {1}", cmdparams[3], cmdparams[2]);
return;
}
@@ -271,22 +277,23 @@ namespace OpenSim.Region.CoreModules
if (desiredPlugin.Equals(m_activeWindPlugin.Name))
{
m_log.InfoFormat("[WIND] Wind model plugin {0} is already active", cmdparams[3]);
MainConsole.Instance.OutputFormat("Wind model plugin {0} is already active", cmdparams[3]);
return;
}
if (m_availableWindPlugins.ContainsKey(desiredPlugin))
{
m_activeWindPlugin = m_availableWindPlugins[cmdparams[3]];
m_log.InfoFormat("[WIND] {0} wind model plugin now active", m_activeWindPlugin.Name);
MainConsole.Instance.OutputFormat("{0} wind model plugin now active", m_activeWindPlugin.Name);
}
else
{
m_log.InfoFormat("[WIND] Could not find wind model plugin {0}", desiredPlugin);
MainConsole.Instance.OutputFormat("Could not find wind model plugin {0}", desiredPlugin);
}
break;
}
}
/// <summary>
@@ -300,7 +307,7 @@ namespace OpenSim.Region.CoreModules
if ((cmdparams.Length != 4)
&& (cmdparams.Length != 3))
{
m_log.Info("[WIND] Usage: wind <plugin> <param> [value]");
MainConsole.Instance.Output("Usage: wind <plugin> <param> [value]");
return;
}
@@ -311,16 +318,17 @@ namespace OpenSim.Region.CoreModules
{
if (!float.TryParse(cmdparams[3], out value))
{
m_log.InfoFormat("[WIND] Invalid value {0}", cmdparams[3]);
MainConsole.Instance.OutputFormat("Invalid value {0}", cmdparams[3]);
}
try
{
WindParamSet(plugin, param, value);
MainConsole.Instance.OutputFormat("{0} set to {1}", param, value);
}
catch (Exception e)
{
m_log.InfoFormat("[WIND] {0}", e.Message);
MainConsole.Instance.OutputFormat("{0}", e.Message);
}
}
else
@@ -328,11 +336,11 @@ namespace OpenSim.Region.CoreModules
try
{
value = WindParamGet(plugin, param);
m_log.InfoFormat("[WIND] {0} : {1}", param, value);
MainConsole.Instance.OutputFormat("{0} : {1}", param, value);
}
catch (Exception e)
{
m_log.InfoFormat("[WIND] {0}", e.Message);
MainConsole.Instance.OutputFormat("{0}", e.Message);
}
}
@@ -366,13 +374,11 @@ namespace OpenSim.Region.CoreModules
{
IWindModelPlugin windPlugin = m_availableWindPlugins[plugin];
windPlugin.WindParamSet(param, value);
m_log.InfoFormat("[WIND] {0} set to {1}", param, value);
}
else
{
throw new Exception(String.Format("Could not find plugin {0}", plugin));
}
}
public float WindParamGet(string plugin, string param)

View File

@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
"export-map [<path>]",
"Save an image of the world map", HandleExportWorldMapConsoleCommand);
m_scene.AddCommand(
"Regions", this, "generate map",
"generate map",
"Generates and stores a new maptile.", HandleGenerateMapConsoleCommand);
AddHandlers();
}
}
@@ -162,7 +167,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
regionimage = regionimage.Replace("-", "");
m_log.Info("[WORLD MAP]: JPEG Map location: " + m_scene.RegionInfo.ServerURI + "index.php?method=" + regionimage);
MainServer.Instance.AddHTTPHandler(regionimage, OnHTTPGetMapImage);
MainServer.Instance.AddHTTPHandler(regionimage,
new GenericHTTPDOSProtector(OnHTTPGetMapImage, OnHTTPThrottled, new BasicDosProtectorOptions()
{
AllowXForwardedFor = false,
ForgetTimeSpan = TimeSpan.FromMinutes(2),
MaxRequestsInTimeframe = 4,
ReportingName = "MAPDOSPROTECTOR",
RequestTimeSpan = TimeSpan.FromSeconds(10),
ThrottledAction = BasicDOSProtector.ThrottleAction.DoThrottledMethod
}).Process);
MainServer.Instance.AddLLSDHandler(
"/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest);
@@ -1131,6 +1145,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
block.Y = (ushort)(r.RegionLocY / Constants.RegionSize);
}
public Hashtable OnHTTPThrottled(Hashtable keysvals)
{
Hashtable reply = new Hashtable();
int statuscode = 500;
reply["str_response_string"] = "";
reply["int_response_code"] = statuscode;
reply["content_type"] = "text/plain";
return reply;
}
public Hashtable OnHTTPGetMapImage(Hashtable keysvals)
{
m_log.Debug("[WORLD MAP]: Sending map image jpeg");
@@ -1305,6 +1329,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_scene.RegionInfo.RegionName, exportPath);
}
public void HandleGenerateMapConsoleCommand(string module, string[] cmdparams)
{
Scene consoleScene = m_scene.ConsoleScene();
if (consoleScene != null && consoleScene != m_scene)
return;
GenerateMaptile();
}
public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
{
uint xstart = 0;
@@ -1542,88 +1576,69 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private Byte[] GenerateOverlay()
{
Bitmap overlay = new Bitmap(256, 256);
bool[,] saleBitmap = new bool[64, 64];
for (int x = 0 ; x < 64 ; x++)
using (Bitmap overlay = new Bitmap(256, 256))
{
for (int y = 0 ; y < 64 ; y++)
saleBitmap[x, y] = false;
}
bool landForSale = false;
List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
Color background = Color.FromArgb(0, 0, 0, 0);
SolidBrush transparent = new SolidBrush(background);
Graphics g = Graphics.FromImage(overlay);
g.FillRectangle(transparent, 0, 0, 255, 255);
SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9));
Pen grey = new Pen(Color.FromArgb(255, 92, 92, 92));
foreach (ILandObject land in parcels)
{
// m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
bool[,] saleBitmap = new bool[64, 64];
for (int x = 0 ; x < 64 ; x++)
{
landForSale = true;
bool[,] landBitmap = land.GetLandBitmap();
for (int y = 0 ; y < 64 ; y++)
saleBitmap[x, y] = false;
}
for (int x = 0 ; x < 64 ; x++)
bool landForSale = false;
List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
Color background = Color.FromArgb(0, 0, 0, 0);
using (Graphics g = Graphics.FromImage(overlay))
{
using (SolidBrush transparent = new SolidBrush(background))
g.FillRectangle(transparent, 0, 0, 256, 256);
foreach (ILandObject land in parcels)
{
for (int y = 0 ; y < 64 ; y++)
// m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
{
if (landBitmap[x, y])
{
g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
landForSale = true;
if (x > 0)
{
if ((saleBitmap[x - 1, y] || landBitmap[x - 1, y]) == false)
g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4, 255 - (y * 4));
}
if (y > 0)
{
if ((saleBitmap[x, y-1] || landBitmap[x, y-1]) == false)
g.DrawLine(grey, x * 4, 255 - (y * 4), x * 4 + 3, 255 - (y * 4));
}
if (x < 63)
{
if ((saleBitmap[x + 1, y] || landBitmap[x + 1, y]) == false)
g.DrawLine(grey, x * 4 + 3, 252 - (y * 4), x * 4 + 3, 255 - (y * 4));
}
if (y < 63)
{
if ((saleBitmap[x, y + 1] || landBitmap[x, y + 1]) == false)
g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4 + 3, 252 - (y * 4));
}
}
saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
}
}
saleBitmap = land.MergeLandBitmaps(saleBitmap, landBitmap);
if (!landForSale)
{
m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
return null;
}
m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
{
for (int x = 0 ; x < 64 ; x++)
{
for (int y = 0 ; y < 64 ; y++)
{
if (saleBitmap[x, y])
g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
}
}
}
}
try
{
return OpenJPEG.EncodeFromImage(overlay, true);
}
catch (Exception e)
{
m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
}
}
if (!landForSale)
{
m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
return null;
}
m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
try
{
return OpenJPEG.EncodeFromImage(overlay, true);
}
catch (Exception e)
{
m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
}
return null;
}
}