From 180be7de07014aa33bc6066f12a0819b731c1c9d Mon Sep 17 00:00:00 2001
From: Dr Scofield
Date: Tue, 10 Feb 2009 13:10:57 +0000
Subject: this is step 2 of 2 of the OpenSim.Region.Environment refactor.
NOTHING has been deleted or moved off to forge at this point. what has
happened is that OpenSim.Region.Environment.Modules has been split in two:
- OpenSim.Region.CoreModules: all those modules that are either
directly or indirectly referenced from other OpenSim packages, or
that provide functionality that the OpenSim developer community
considers core functionality:
CoreModules/Agent/AssetTransaction
CoreModules/Agent/Capabilities
CoreModules/Agent/TextureDownload
CoreModules/Agent/TextureSender
CoreModules/Agent/TextureSender/Tests
CoreModules/Agent/Xfer
CoreModules/Avatar/AvatarFactory
CoreModules/Avatar/Chat/ChatModule
CoreModules/Avatar/Combat
CoreModules/Avatar/Currency/SampleMoney
CoreModules/Avatar/Dialog
CoreModules/Avatar/Friends
CoreModules/Avatar/Gestures
CoreModules/Avatar/Groups
CoreModules/Avatar/InstantMessage
CoreModules/Avatar/Inventory
CoreModules/Avatar/Inventory/Archiver
CoreModules/Avatar/Inventory/Transfer
CoreModules/Avatar/Lure
CoreModules/Avatar/ObjectCaps
CoreModules/Avatar/Profiles
CoreModules/Communications/Local
CoreModules/Communications/REST
CoreModules/Framework/EventQueue
CoreModules/Framework/InterfaceCommander
CoreModules/Hypergrid
CoreModules/InterGrid
CoreModules/Scripting/DynamicTexture
CoreModules/Scripting/EMailModules
CoreModules/Scripting/HttpRequest
CoreModules/Scripting/LoadImageURL
CoreModules/Scripting/VectorRender
CoreModules/Scripting/WorldComm
CoreModules/Scripting/XMLRPC
CoreModules/World/Archiver
CoreModules/World/Archiver/Tests
CoreModules/World/Estate
CoreModules/World/Land
CoreModules/World/Permissions
CoreModules/World/Serialiser
CoreModules/World/Sound
CoreModules/World/Sun
CoreModules/World/Terrain
CoreModules/World/Terrain/DefaultEffects
CoreModules/World/Terrain/DefaultEffects/bin
CoreModules/World/Terrain/DefaultEffects/bin/Debug
CoreModules/World/Terrain/Effects
CoreModules/World/Terrain/FileLoaders
CoreModules/World/Terrain/FloodBrushes
CoreModules/World/Terrain/PaintBrushes
CoreModules/World/Terrain/Tests
CoreModules/World/Vegetation
CoreModules/World/Wind
CoreModules/World/WorldMap
- OpenSim.Region.OptionalModules: all those modules that are not core
modules:
OptionalModules/Avatar/Chat/IRC-stuff
OptionalModules/Avatar/Concierge
OptionalModules/Avatar/Voice/AsterixVoice
OptionalModules/Avatar/Voice/SIPVoice
OptionalModules/ContentManagementSystem
OptionalModules/Grid/Interregion
OptionalModules/Python
OptionalModules/SvnSerialiser
OptionalModules/World/NPC
OptionalModules/World/TreePopulator
---
.../Modules/World/Archiver/ArchiveConstants.cs | 128 --
.../Modules/World/Archiver/ArchiveReadRequest.cs | 460 ------
.../World/Archiver/ArchiveWriteRequestExecution.cs | 161 ---
.../Archiver/ArchiveWriteRequestPreparation.cs | 333 -----
.../Modules/World/Archiver/ArchiverModule.cs | 95 --
.../Modules/World/Archiver/AssetsArchiver.cs | 143 --
.../Modules/World/Archiver/AssetsDearchiver.cs | 184 ---
.../Modules/World/Archiver/AssetsRequest.cs | 138 --
.../World/Archiver/RegionSettingsSerializer.cs | 258 ----
.../Modules/World/Archiver/TarArchiveReader.cs | 195 ---
.../Modules/World/Archiver/TarArchiveWriter.cs | 202 ---
.../Modules/World/Archiver/Tests/ArchiverTests.cs | 188 ---
.../Modules/World/Estate/EstateManagementModule.cs | 1012 -------------
.../World/Estate/EstateTerrainXferHandler.cs | 127 --
.../Environment/Modules/World/Land/LandChannel.cs | 188 ---
.../Modules/World/Land/LandManagementModule.cs | 1347 ------------------
.../Environment/Modules/World/Land/LandObject.cs | 930 ------------
.../Environment/Modules/World/NPC/NPCAvatar.cs | 1060 --------------
.../Environment/Modules/World/NPC/NPCModule.cs | 68 -
.../Modules/World/Permissions/PermissionsModule.cs | 1498 --------------------
.../Modules/World/Serialiser/IFileSerialiser.cs | 36 -
.../Modules/World/Serialiser/SerialiseObjects.cs | 125 --
.../Modules/World/Serialiser/SerialiseTerrain.cs | 53 -
.../Modules/World/Serialiser/SerialiserModule.cs | 226 ---
.../Environment/Modules/World/Sound/SoundModule.cs | 97 --
.../Environment/Modules/World/Sun/SunModule.cs | 434 ------
.../Modules/World/Terrain/Effects/CookieCutter.cs | 125 --
.../Terrain/Effects/DefaultTerrainGenerator.cs | 56 -
.../Modules/World/Terrain/FileLoaders/BMP.cs | 76 -
.../Modules/World/Terrain/FileLoaders/GIF.cs | 61 -
.../Terrain/FileLoaders/GenericSystemDrawing.cs | 195 ---
.../Modules/World/Terrain/FileLoaders/JPEG.cs | 112 --
.../Modules/World/Terrain/FileLoaders/LLRAW.cs | 250 ----
.../Modules/World/Terrain/FileLoaders/PNG.cs | 61 -
.../Modules/World/Terrain/FileLoaders/RAW32.cs | 170 ---
.../Modules/World/Terrain/FileLoaders/TIFF.cs | 61 -
.../Modules/World/Terrain/FileLoaders/Terragen.cs | 142 --
.../World/Terrain/FloodBrushes/FlattenArea.cs | 70 -
.../World/Terrain/FloodBrushes/LowerArea.cs | 54 -
.../World/Terrain/FloodBrushes/NoiseArea.cs | 58 -
.../World/Terrain/FloodBrushes/RaiseArea.cs | 54 -
.../World/Terrain/FloodBrushes/RevertArea.cs | 67 -
.../World/Terrain/FloodBrushes/SmoothArea.cs | 114 --
.../Modules/World/Terrain/ITerrainEffect.cs | 36 -
.../Modules/World/Terrain/ITerrainFloodEffect.cs | 37 -
.../Modules/World/Terrain/ITerrainLoader.cs | 42 -
.../Modules/World/Terrain/ITerrainModule.cs | 61 -
.../World/Terrain/ITerrainPaintableEffect.cs | 36 -
.../World/Terrain/PaintBrushes/ErodeSphere.cs | 318 -----
.../World/Terrain/PaintBrushes/FlattenSphere.cs | 101 --
.../World/Terrain/PaintBrushes/LowerSphere.cs | 84 --
.../World/Terrain/PaintBrushes/NoiseSphere.cs | 67 -
.../World/Terrain/PaintBrushes/OlsenSphere.cs | 223 ---
.../World/Terrain/PaintBrushes/RaiseSphere.cs | 80 --
.../World/Terrain/PaintBrushes/RevertSphere.cs | 80 --
.../World/Terrain/PaintBrushes/SmoothSphere.cs | 100 --
.../World/Terrain/PaintBrushes/WeatherSphere.cs | 211 ---
.../Modules/World/Terrain/TerrainException.cs | 46 -
.../Modules/World/Terrain/TerrainModule.cs | 1001 -------------
.../Modules/World/Terrain/Tests/TerrainTest.cs | 118 --
.../World/TreePopulator/TreePopulatorModule.cs | 304 ----
.../Modules/World/Vegetation/VegetationModule.cs | 118 --
.../Environment/Modules/World/Wind/WindModule.cs | 207 ---
.../World/WorldMap/IMapTileTerrainRenderer.cs | 39 -
.../Modules/World/WorldMap/MapImageModule.cs | 586 --------
.../Modules/World/WorldMap/MapSearchModule.cs | 172 ---
.../World/WorldMap/ShadedMapTileRenderer.cs | 249 ----
.../World/WorldMap/TexturedMapTileRenderer.cs | 411 ------
.../Modules/World/WorldMap/WorldMapModule.cs | 905 ------------
69 files changed, 17044 deletions(-)
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/RegionSettingsSerializer.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Estate/EstateTerrainXferHandler.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/NPC/NPCModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Vegetation/VegetationModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/Wind/WindModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/WorldMap/IMapTileTerrainRenderer.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/WorldMap/ShadedMapTileRenderer.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
delete mode 100644 OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
(limited to 'OpenSim/Region/Environment/Modules/World')
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs
deleted file mode 100644
index 4151c88..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.Collections.Generic;
-using OpenMetaverse;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Constants for the archiving module
- ///
- public class ArchiveConstants
- {
- ///
- /// The location of the archive control file
- ///
- public static readonly string CONTROL_FILE_PATH = "archive.xml";
-
- ///
- /// Path for the assets held in an archive
- ///
- public static readonly string ASSETS_PATH = "assets/";
-
- ///
- /// Path for the assets metadata file
- ///
- //public static readonly string ASSETS_METADATA_PATH = "assets.xml";
-
- ///
- /// Path for the prims file
- ///
- public static readonly string OBJECTS_PATH = "objects/";
-
- ///
- /// Path for terrains. Technically these may be assets, but I think it's quite nice to split them out.
- ///
- public static readonly string TERRAINS_PATH = "terrains/";
-
- ///
- /// Path for region settings.
- ///
- public static readonly string SETTINGS_PATH = "settings/";
-
- ///
- /// The character the separates the uuid from extension information in an archived asset filename
- ///
- public static readonly string ASSET_EXTENSION_SEPARATOR = "_";
-
- ///
- /// Extensions used for asset types in the archive
- ///
- public static readonly IDictionary ASSET_TYPE_TO_EXTENSION = new Dictionary();
- public static readonly IDictionary EXTENSION_TO_ASSET_TYPE = new Dictionary();
-
- static ArchiveConstants()
- {
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Animation] = ASSET_EXTENSION_SEPARATOR + "animation.bvh";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Bodypart] = ASSET_EXTENSION_SEPARATOR + "bodypart.txt";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.CallingCard] = ASSET_EXTENSION_SEPARATOR + "callingcard.txt";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Clothing] = ASSET_EXTENSION_SEPARATOR + "clothing.txt";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Folder] = ASSET_EXTENSION_SEPARATOR + "folder.txt"; // Not sure if we'll ever see this
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Gesture] = ASSET_EXTENSION_SEPARATOR + "gesture.txt";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageJPEG] = ASSET_EXTENSION_SEPARATOR + "image.jpg";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageTGA] = ASSET_EXTENSION_SEPARATOR + "image.tga";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Landmark] = ASSET_EXTENSION_SEPARATOR + "landmark.txt";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = ASSET_EXTENSION_SEPARATOR + "lostandfoundfolder.txt"; // Not sure if we'll ever see this
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLBytecode] = ASSET_EXTENSION_SEPARATOR + "bytecode.lso";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLText] = ASSET_EXTENSION_SEPARATOR + "script.lsl";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = ASSET_EXTENSION_SEPARATOR + "notecard.txt";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = ASSET_EXTENSION_SEPARATOR + "object.xml";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = ASSET_EXTENSION_SEPARATOR + "rootfolder.txt"; // Not sure if we'll ever see this
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Simstate] = ASSET_EXTENSION_SEPARATOR + "simstate.bin"; // Not sure if we'll ever see this
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SnapshotFolder] = ASSET_EXTENSION_SEPARATOR + "snapshotfolder.txt"; // Not sure if we'll ever see this
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Sound] = ASSET_EXTENSION_SEPARATOR + "sound.ogg";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = ASSET_EXTENSION_SEPARATOR + "sound.wav";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga";
- ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"; // Not sure if we'll ever see this
-
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bodypart.txt"] = (sbyte)AssetType.Bodypart;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "callingcard.txt"] = (sbyte)AssetType.CallingCard;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "clothing.txt"] = (sbyte)AssetType.Clothing;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "folder.txt"] = (sbyte)AssetType.Folder;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "gesture.txt"] = (sbyte)AssetType.Gesture;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "image.jpg"] = (sbyte)AssetType.ImageJPEG;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "image.tga"] = (sbyte)AssetType.ImageTGA;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "landmark.txt"] = (sbyte)AssetType.Landmark;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "lostandfoundfolder.txt"] = (sbyte)AssetType.LostAndFoundFolder;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bytecode.lso"] = (sbyte)AssetType.LSLBytecode;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "script.lsl"] = (sbyte)AssetType.LSLText;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "notecard.txt"] = (sbyte)AssetType.Notecard;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "object.xml"] = (sbyte)AssetType.Object;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "rootfolder.txt"] = (sbyte)AssetType.RootFolder;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "simstate.bin"] = (sbyte)AssetType.Simstate;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "snapshotfolder.txt"] = (sbyte)AssetType.SnapshotFolder;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.ogg"] = (sbyte)AssetType.Sound;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.wav"] = (sbyte)AssetType.SoundWAV;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA;
- EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder;
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
deleted file mode 100644
index b507c52..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using System.IO.Compression;
-using System.Reflection;
-using System.Xml;
-using System.Net;
-using OpenMetaverse;
-using log4net;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.World.Terrain;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Handles an individual archive read request
- ///
- public class ArchiveReadRequest
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
-
- private Scene m_scene;
- private Stream m_loadStream;
- private string m_errorMessage;
-
- ///
- /// Used to cache lookups for valid uuids.
- ///
- private IDictionary m_validUserUuids = new Dictionary();
-
- public ArchiveReadRequest(Scene scene, string loadPath)
- {
- m_scene = scene;
- m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
- m_errorMessage = String.Empty;
- }
-
- public ArchiveReadRequest(Scene scene, Stream loadStream)
- {
- m_scene = scene;
- m_loadStream = loadStream;
- }
-
- ///
- /// Dearchive the region embodied in this request.
- ///
- public void DearchiveRegion()
- {
- // The same code can handle dearchiving 0.1 and 0.2 OpenSim Archive versions
- DearchiveRegion0DotStar();
- }
-
- private void DearchiveRegion0DotStar()
- {
- int successfulAssetRestores = 0;
- int failedAssetRestores = 0;
- List serialisedSceneObjects = new List();
-
- try
- {
- TarArchiveReader archive = new TarArchiveReader(m_loadStream);
-
- //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
-
- string filePath = "ERROR";
-
- byte[] data;
- TarArchiveReader.TarEntryType entryType;
-
- while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
- {
- //m_log.DebugFormat(
- // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
- if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
- {
- m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}",
- filePath);
- }
- else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
- {
- serialisedSceneObjects.Add(m_asciiEncoding.GetString(data));
- }
-// else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH))
-// {
-// string xml = m_asciiEncoding.GetString(data);
-// dearchiver.AddAssetMetadata(xml);
-// }
- else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
- {
- if (LoadAsset(filePath, data))
- successfulAssetRestores++;
- else
- failedAssetRestores++;
- }
- else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
- {
- LoadTerrain(filePath, data);
- }
- else if (filePath.StartsWith(ArchiveConstants.SETTINGS_PATH))
- {
- LoadRegionSettings(filePath, data);
- }
- }
-
- //m_log.Debug("[ARCHIVER]: Reached end of archive");
-
- archive.Close();
- }
- catch (Exception e)
- {
- m_log.ErrorFormat(
- "[ARCHIVER]: Error loading oar file. Exception was: {0}", e);
- m_errorMessage += e.ToString();
- m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
- return;
- }
-
- m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
-
- if (failedAssetRestores > 0)
- {
- m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
- m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
- }
-
- m_log.Info("[ARCHIVER]: Clearing all existing scene objects");
- m_scene.DeleteAllSceneObjects();
-
- // Reload serialized prims
- m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count);
-
- IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface();
- ICollection sceneObjects = new List();
-
- foreach (string serialisedSceneObject in serialisedSceneObjects)
- {
- SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject);
-
- // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned
- // on the same region server and multiple examples a single object archive to be imported
- // to the same scene (when this is possible).
- sceneObject.ResetIDs();
-
- // Try to retain the original creator/owner/lastowner if their uuid is present on this grid
- // otherwise, use the master avatar uuid instead
- UUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID;
-
- if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
- masterAvatarId = m_scene.RegionInfo.EstateSettings.EstateOwner;
-
- foreach (SceneObjectPart part in sceneObject.Children.Values)
- {
- if (!resolveUserUuid(part.CreatorID))
- part.CreatorID = masterAvatarId;
-
- if (!resolveUserUuid(part.OwnerID))
- part.OwnerID = masterAvatarId;
-
- if (!resolveUserUuid(part.LastOwnerID))
- part.LastOwnerID = masterAvatarId;
-
- // And zap any troublesome sit target information
- part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
- part.SitTargetPosition = new Vector3(0, 0, 0);
-
- // Fix ownership/creator of inventory items
- // Not doing so results in inventory items
- // being no copy/no mod for everyone
- TaskInventoryDictionary inv = part.TaskInventory;
- foreach (KeyValuePair kvp in inv)
- {
- if (!resolveUserUuid(kvp.Value.OwnerID))
- {
- kvp.Value.OwnerID = masterAvatarId;
- }
- if (!resolveUserUuid(kvp.Value.CreatorID))
- {
- kvp.Value.CreatorID = masterAvatarId;
- }
- }
- }
-
- if (m_scene.AddRestoredSceneObject(sceneObject, true, false))
- {
- sceneObjects.Add(sceneObject);
- }
- }
-
- m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjects.Count);
-
- int ignoredObjects = serialisedSceneObjects.Count - sceneObjects.Count;
-
- if (ignoredObjects > 0)
- m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects);
-
- m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
-
- m_log.Debug("[ARCHIVER]: Starting scripts");
-
- foreach (SceneObjectGroup sceneObject in sceneObjects)
- {
- sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0);
- }
-
- m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
- }
-
- ///
- /// Look up the given user id to check whether it's one that is valid for this grid.
- ///
- ///
- ///
- private bool resolveUserUuid(UUID uuid)
- {
- if (!m_validUserUuids.ContainsKey(uuid))
- {
- CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(uuid);
- if (profile != null && profile.UserProfile != null)
- m_validUserUuids.Add(uuid, true);
- else
- m_validUserUuids.Add(uuid, false);
- }
-
- if (m_validUserUuids[uuid])
- return true;
- else
- return false;
- }
-
- ///
- /// Load an asset
- ///
- ///
- ///
- /// true if asset was successfully loaded, false otherwise
- private bool LoadAsset(string assetPath, byte[] data)
- {
- // Right now we're nastily obtaining the UUID from the filename
- string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
- int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
-
- if (i == -1)
- {
- m_log.ErrorFormat(
- "[ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping",
- assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
-
- return false;
- }
-
- string extension = filename.Substring(i);
- string uuid = filename.Remove(filename.Length - extension.Length);
-
- if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
- {
- sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
-
- //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
-
- AssetBase asset = new AssetBase(new UUID(uuid), String.Empty);
- asset.Metadata.Type = assetType;
- asset.Data = data;
-
- m_scene.AssetCache.AddAsset(asset);
-
- /**
- * Create layers on decode for image assets. This is likely to significantly increase the time to load archives so
- * it might be best done when dearchive takes place on a separate thread
- if (asset.Type=AssetType.Texture)
- {
- IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface();
- if (cacheLayerDecode != null)
- cacheLayerDecode.syncdecode(asset.FullID, asset.Data);
- }
- */
-
- return true;
- }
- else
- {
- m_log.ErrorFormat(
- "[ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}",
- assetPath, extension);
-
- return false;
- }
- }
-
- ///
- /// Load region settings data
- ///
- ///
- ///
- ///
- /// true if settings were loaded successfully, false otherwise
- ///
- private bool LoadRegionSettings(string settingsPath, byte[] data)
- {
- RegionSettings loadedRegionSettings;
-
- try
- {
- loadedRegionSettings = RegionSettingsSerializer.Deserialize(data);
- }
- catch (Exception e)
- {
- m_log.ErrorFormat(
- "[ARCHIVER]: Could not parse region settings file {0}. Ignoring. Exception was {1}",
- settingsPath, e);
- return false;
- }
-
- RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings;
-
- currentRegionSettings.AgentLimit = loadedRegionSettings.AgentLimit;
- currentRegionSettings.AllowDamage = loadedRegionSettings.AllowDamage;
- currentRegionSettings.AllowLandJoinDivide = loadedRegionSettings.AllowLandJoinDivide;
- currentRegionSettings.AllowLandResell = loadedRegionSettings.AllowLandResell;
- currentRegionSettings.BlockFly = loadedRegionSettings.BlockFly;
- currentRegionSettings.BlockShowInSearch = loadedRegionSettings.BlockShowInSearch;
- currentRegionSettings.BlockTerraform = loadedRegionSettings.BlockTerraform;
- currentRegionSettings.DisableCollisions = loadedRegionSettings.DisableCollisions;
- currentRegionSettings.DisablePhysics = loadedRegionSettings.DisablePhysics;
- currentRegionSettings.DisableScripts = loadedRegionSettings.DisableScripts;
- currentRegionSettings.Elevation1NE = loadedRegionSettings.Elevation1NE;
- currentRegionSettings.Elevation1NW = loadedRegionSettings.Elevation1NW;
- currentRegionSettings.Elevation1SE = loadedRegionSettings.Elevation1SE;
- currentRegionSettings.Elevation1SW = loadedRegionSettings.Elevation1SW;
- currentRegionSettings.Elevation2NE = loadedRegionSettings.Elevation2NE;
- currentRegionSettings.Elevation2NW = loadedRegionSettings.Elevation2NW;
- currentRegionSettings.Elevation2SE = loadedRegionSettings.Elevation2SE;
- currentRegionSettings.Elevation2SW = loadedRegionSettings.Elevation2SW;
- currentRegionSettings.FixedSun = loadedRegionSettings.FixedSun;
- currentRegionSettings.ObjectBonus = loadedRegionSettings.ObjectBonus;
- currentRegionSettings.RestrictPushing = loadedRegionSettings.RestrictPushing;
- currentRegionSettings.TerrainLowerLimit = loadedRegionSettings.TerrainLowerLimit;
- currentRegionSettings.TerrainRaiseLimit = loadedRegionSettings.TerrainRaiseLimit;
- currentRegionSettings.TerrainTexture1 = loadedRegionSettings.TerrainTexture1;
- currentRegionSettings.TerrainTexture2 = loadedRegionSettings.TerrainTexture2;
- currentRegionSettings.TerrainTexture3 = loadedRegionSettings.TerrainTexture3;
- currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4;
- currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun;
- currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight;
-
- IEstateModule estateModule = m_scene.RequestModuleInterface();
- estateModule.sendRegionHandshakeToAll();
-
- return true;
- }
-
- ///
- /// Load terrain data
- ///
- ///
- ///
- ///
- /// true if terrain was resolved successfully, false otherwise.
- ///
- private bool LoadTerrain(string terrainPath, byte[] data)
- {
- ITerrainModule terrainModule = m_scene.RequestModuleInterface();
-
- MemoryStream ms = new MemoryStream(data);
- terrainModule.LoadFromStream(terrainPath, ms);
- ms.Close();
-
- m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath);
-
- return true;
- }
-
- ///
- /// Resolve path to a working FileStream
- ///
- private Stream GetStream(string path)
- {
- try
- {
- if (File.Exists(path))
- {
- return new FileStream(path, FileMode.Open);
- }
- else
- {
- Uri uri = new Uri(path); // throw exception if not valid URI
- if (uri.Scheme == "file")
- {
- return new FileStream(uri.AbsolutePath, FileMode.Open);
- }
- else
- {
- if (uri.Scheme != "http")
- throw new Exception(String.Format("Unsupported URI scheme ({0})", path));
-
- // OK, now we know we have an HTTP URI to work with
-
- return URIFetch(uri);
- }
- }
- }
- catch (Exception e)
- {
- throw new Exception(String.Format("Unable to create file input stream for {0}: {1}", path, e));
- }
- }
-
- private static Stream URIFetch(Uri uri)
- {
- HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
-
- // request.Credentials = credentials;
-
- request.ContentLength = 0;
-
- WebResponse response = request.GetResponse();
- Stream file = response.GetResponseStream();
-
- if (response.ContentType != "application/x-oar")
- throw new Exception(String.Format("{0} does not identify an OAR file", uri.ToString()));
-
- if (response.ContentLength == 0)
- throw new Exception(String.Format("{0} returned an empty file", uri.ToString()));
-
- // return new BufferedStream(file, (int) response.ContentLength);
- return new BufferedStream(file, 1000000);
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
deleted file mode 100644
index 9a06bf7..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using System.Xml;
-using OpenMetaverse;
-using log4net;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.World.Serialiser;
-using OpenSim.Region.Environment.Modules.World.Terrain;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Method called when all the necessary assets for an archive request have been received.
- ///
- public delegate void AssetsRequestCallback(IDictionary assetsFound, ICollection assetsNotFoundUuids);
-
- ///
- /// Execute the write of an archive once we have received all the necessary data
- ///
- public class ArchiveWriteRequestExecution
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- protected ITerrainModule m_terrainModule;
- protected IRegionSerialiserModule m_serialiser;
- protected List m_sceneObjects;
- protected Scene m_scene;
- protected Stream m_saveStream;
-
- public ArchiveWriteRequestExecution(
- List sceneObjects,
- ITerrainModule terrainModule,
- IRegionSerialiserModule serialiser,
- Scene scene,
- Stream saveStream)
- {
- m_sceneObjects = sceneObjects;
- m_terrainModule = terrainModule;
- m_serialiser = serialiser;
- m_scene = scene;
- m_saveStream = saveStream;
- }
-
- protected internal void ReceivedAllAssets(
- IDictionary assetsFound, ICollection assetsNotFoundUuids)
- {
- foreach (UUID uuid in assetsNotFoundUuids)
- {
- m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid);
- }
-
- m_log.InfoFormat(
- "[ARCHIVER]: Received {0} of {1} assets requested",
- assetsFound.Count, assetsFound.Count + assetsNotFoundUuids.Count);
-
- m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
-
- TarArchiveWriter archive = new TarArchiveWriter();
-
- // Write out control file
- archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
-
- // Write out region settings
- string settingsPath
- = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);
- archive.AddFile(settingsPath, RegionSettingsSerializer.Serialize(m_scene.RegionInfo.RegionSettings));
-
- // Write out terrain
- string terrainPath
- = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_scene.RegionInfo.RegionName);
-
- MemoryStream ms = new MemoryStream();
- m_terrainModule.SaveToStream(terrainPath, ms);
- archive.AddFile(terrainPath, ms.ToArray());
- ms.Close();
-
- // Write out scene object metadata
- foreach (SceneObjectGroup sceneObject in m_sceneObjects)
- {
- //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());
-
- Vector3 position = sceneObject.AbsolutePosition;
-
- string serializedObject = m_serialiser.SaveGroupToXml2(sceneObject);
- string filename
- = string.Format(
- "{0}{1}_{2:000}-{3:000}-{4:000}__{5}.xml",
- ArchiveConstants.OBJECTS_PATH, sceneObject.Name,
- Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z),
- sceneObject.UUID);
-
- archive.AddFile(filename, serializedObject);
- }
-
- // Write out assets
- AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
- assetsArchiver.Archive(archive);
-
- archive.WriteTar(m_saveStream);
-
- m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive for {0}", m_scene.RegionInfo.RegionName);
-
- m_scene.EventManager.TriggerOarFileSaved(String.Empty);
- }
-
- ///
- /// Create the control file for a 0.2 version archive
- ///
- ///
- public static string Create0p2ControlFile()
- {
- StringWriter sw = new StringWriter();
- XmlTextWriter xtw = new XmlTextWriter(sw);
- xtw.Formatting = Formatting.Indented;
- xtw.WriteStartDocument();
- xtw.WriteStartElement("archive");
- xtw.WriteAttributeString("major_version", "0");
- xtw.WriteAttributeString("minor_version", "2");
- xtw.WriteEndElement();
-
- xtw.Flush();
- xtw.Close();
-
- String s = sw.ToString();
- sw.Close();
-
- return s;
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
deleted file mode 100644
index 56604d6..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * 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 OpenSim.Framework;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.World.Serialiser;
-using OpenSim.Region.Environment.Modules.World.Terrain;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.IO.Compression;
-using System.Reflection;
-using System.Text.RegularExpressions;
-using System.Threading;
-using OpenMetaverse;
-using log4net;
-using Nini.Config;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Prepare to write out an archive.
- ///
- public class ArchiveWriteRequestPreparation
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- protected Scene m_scene;
- protected Stream m_saveStream;
-
- ///
- /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
- /// asset was found by the asset service.
- ///
- protected AssetBase m_requestedObjectAsset;
-
- ///
- /// Signal whether we are currently waiting for the asset service to deliver an asset.
- ///
- protected bool m_waitingForObjectAsset;
-
- ///
- /// Constructor
- ///
- public ArchiveWriteRequestPreparation(Scene scene, string savePath)
- {
- m_scene = scene;
- m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress);
- }
-
- ///
- /// Constructor.
- ///
- ///
- /// The stream to which to save data.
- public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream)
- {
- m_scene = scene;
- m_saveStream = saveStream;
- }
-
- ///
- /// The callback made when we request the asset for an object from the asset service.
- ///
- public void AssetRequestCallback(UUID assetID, AssetBase asset)
- {
- lock (this)
- {
- m_requestedObjectAsset = asset;
- m_waitingForObjectAsset = false;
- Monitor.Pulse(this);
- }
- }
-
- ///
- /// Get an asset synchronously, potentially using an asynchronous callback. If the
- /// asynchronous callback is used, we will wait for it to complete.
- ///
- ///
- ///
- protected AssetBase GetAsset(UUID uuid)
- {
- m_waitingForObjectAsset = true;
- m_scene.AssetCache.GetAsset(uuid, AssetRequestCallback, true);
-
- // The asset cache callback can either
- //
- // 1. Complete on the same thread (if the asset is already in the cache) or
- // 2. Come in via a different thread (if we need to go fetch it).
- //
- // The code below handles both these alternatives.
- lock (this)
- {
- if (m_waitingForObjectAsset)
- {
- Monitor.Wait(this);
- m_waitingForObjectAsset = false;
- }
- }
-
- return m_requestedObjectAsset;
- }
-
- ///
- /// Record the asset uuids embedded within the given script.
- ///
- ///
- /// Dictionary in which to record the references
- protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary assetUuids)
- {
- AssetBase scriptAsset = GetAsset(scriptUuid);
-
- if (null != scriptAsset)
- {
- string script = Utils.BytesToString(scriptAsset.Data);
- //m_log.DebugFormat("[ARCHIVER]: Script {0}", script);
- MatchCollection uuidMatches = Util.UUIDPattern.Matches(script);
- //m_log.DebugFormat("[ARCHIVER]: Found {0} matches in script", uuidMatches.Count);
-
- foreach (Match uuidMatch in uuidMatches)
- {
- UUID uuid = new UUID(uuidMatch.Value);
- //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid);
- assetUuids[uuid] = 1;
- }
- }
- }
-
- ///
- /// Record the uuids referenced by the given wearable asset
- ///
- ///
- /// Dictionary in which to record the references
- protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary assetUuids)
- {
- AssetBase assetBase = GetAsset(wearableAssetUuid);
- //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data));
- AssetWearable wearableAsset = new AssetBodypart(wearableAssetUuid, assetBase.Data);
- wearableAsset.Decode();
-
- //m_log.DebugFormat(
- // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count);
-
- foreach (UUID uuid in wearableAsset.Textures.Values)
- {
- //m_log.DebugFormat("[ARCHIVER]: Got bodypart uuid {0}", uuid);
- assetUuids[uuid] = 1;
- }
- }
-
- ///
- /// Get all the asset uuids associated with a given object. This includes both those directly associated with
- /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
- /// within this object).
- ///
- ///
- ///
- protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary assetUuids)
- {
- AssetBase objectAsset = GetAsset(sceneObjectUuid);
-
- if (null != objectAsset)
- {
- string xml = Utils.BytesToString(objectAsset.Data);
- SceneObjectGroup sog = new SceneObjectGroup(xml, true);
- GetSceneObjectAssetUuids(sog, assetUuids);
- }
- }
-
- ///
- /// Get all the asset uuids associated with a given object. This includes both those directly associated with
- /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
- /// within this object).
- ///
- ///
- ///
- protected void GetSceneObjectAssetUuids(SceneObjectGroup sceneObject, IDictionary assetUuids)
- {
- m_log.DebugFormat(
- "[ARCHIVER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
-
- foreach (SceneObjectPart part in sceneObject.GetParts())
- {
- //m_log.DebugFormat(
- // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);
-
- try
- {
- Primitive.TextureEntry textureEntry = part.Shape.Textures;
-
- // Get the prim's default texture. This will be used for faces which don't have their own texture
- assetUuids[textureEntry.DefaultTexture.TextureID] = 1;
-
- // XXX: Not a great way to iterate through face textures, but there's no
- // other method available to tell how many faces there actually are
- //int i = 0;
- foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
- {
- if (texture != null)
- {
- //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
- assetUuids[texture.TextureID] = 1;
- }
- }
-
- // If the prim is a sculpt then preserve this information too
- if (part.Shape.SculptTexture != UUID.Zero)
- assetUuids[part.Shape.SculptTexture] = 1;
-
- // Now analyze this prim's inventory items to preserve all the uuids that they reference
- foreach (TaskInventoryItem tii in part.TaskInventory.Values)
- {
- //m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type);
-
- if (!assetUuids.ContainsKey(tii.AssetID))
- {
- assetUuids[tii.AssetID] = 1;
-
- if ((int)AssetType.Bodypart == tii.Type || ((int)AssetType.Clothing == tii.Type))
- {
- GetWearableAssetUuids(tii.AssetID, assetUuids);
- }
- else if ((int)AssetType.LSLText == tii.Type)
- {
- GetScriptAssetUuids(tii.AssetID, assetUuids);
- }
- else if ((int)AssetType.Object == tii.Type)
- {
- GetSceneObjectAssetUuids(tii.AssetID, assetUuids);
- }
- //else
- //{
- //m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tii.AssetID, part.UUID);
- //}
- }
- }
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("[ARCHIVER]: Failed to get part - {0}", e);
- m_log.DebugFormat("[ARCHIVER]: Texture entry length for prim was {0} (min is 46)", part.Shape.TextureEntry.Length);
- }
- }
- }
-
- ///
- /// Archive the region requested.
- ///
- /// if there was an io problem with creating the file
- public void ArchiveRegion()
- {
- Dictionary assetUuids = new Dictionary();
-
- List entities = m_scene.GetEntities();
- List sceneObjects = new List();
-
- // Filter entities so that we only have scene objects.
- // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
- // end up having to do this
- foreach (EntityBase entity in entities)
- {
- if (entity is SceneObjectGroup)
- {
- SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
-
- if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
- sceneObjects.Add((SceneObjectGroup)entity);
- }
- }
-
- foreach (SceneObjectGroup sceneObject in sceneObjects)
- {
- GetSceneObjectAssetUuids(sceneObject, assetUuids);
- }
-
- m_log.DebugFormat(
- "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
- sceneObjects.Count, assetUuids.Count);
-
- // Make sure that we also request terrain texture assets
- RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;
-
- if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
- assetUuids[regionSettings.TerrainTexture1] = 1;
-
- if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
- assetUuids[regionSettings.TerrainTexture2] = 1;
-
- if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
- assetUuids[regionSettings.TerrainTexture3] = 1;
-
- if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
- assetUuids[regionSettings.TerrainTexture4] = 1;
-
- // Asynchronously request all the assets required to perform this archive operation
- ArchiveWriteRequestExecution awre
- = new ArchiveWriteRequestExecution(
- sceneObjects,
- m_scene.RequestModuleInterface(),
- m_scene.RequestModuleInterface(),
- m_scene,
- m_saveStream);
-
- new AssetsRequest(assetUuids.Keys, m_scene.AssetCache, awre.ReceivedAllAssets).Execute();
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
deleted file mode 100644
index cd81169..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiverModule.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using System.Threading;
-using OpenMetaverse;
-using log4net;
-using Nini.Config;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.World.Serialiser;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// This module loads and saves OpenSimulator archives
- ///
- public class ArchiverModule : IRegionModule, IRegionArchiverModule
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private Scene m_scene;
-
- public string Name { get { return "Archiver Module"; } }
-
- public bool IsSharedModule { get { return false; } }
-
- public void Initialise(Scene scene, IConfigSource source)
- {
- m_scene = scene;
- m_scene.RegisterModuleInterface(this);
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- }
-
- public void ArchiveRegion(string savePath)
- {
- m_log.InfoFormat(
- "[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath);
-
- new ArchiveWriteRequestPreparation(m_scene, savePath).ArchiveRegion();
- }
-
- public void ArchiveRegion(Stream saveStream)
- {
- new ArchiveWriteRequestPreparation(m_scene, saveStream).ArchiveRegion();
- }
-
- public void DearchiveRegion(string loadPath)
- {
- m_log.InfoFormat(
- "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
-
- new ArchiveReadRequest(m_scene, loadPath).DearchiveRegion();
- }
-
- public void DearchiveRegion(Stream loadStream)
- {
- new ArchiveReadRequest(m_scene, loadStream).DearchiveRegion();
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
deleted file mode 100644
index 36a60f3..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using System.Xml;
-using OpenMetaverse;
-using log4net;
-using OpenSim.Framework;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Archives assets
- ///
- public class AssetsArchiver
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- ///
- /// Archive assets
- ///
- protected IDictionary m_assets;
-
- public AssetsArchiver(IDictionary assets)
- {
- m_assets = assets;
- }
-
- ///
- /// Archive the assets given to this archiver to the given archive.
- ///
- ///
- public void Archive(TarArchiveWriter archive)
- {
- //WriteMetadata(archive);
- WriteData(archive);
- }
-
- ///
- /// Write an assets metadata file to the given archive
- ///
- ///
- protected void WriteMetadata(TarArchiveWriter archive)
- {
- StringWriter sw = new StringWriter();
- XmlTextWriter xtw = new XmlTextWriter(sw);
-
- xtw.Formatting = Formatting.Indented;
- xtw.WriteStartDocument();
-
- xtw.WriteStartElement("assets");
-
- foreach (UUID uuid in m_assets.Keys)
- {
- AssetBase asset = m_assets[uuid];
-
- if (asset != null)
- {
- xtw.WriteStartElement("asset");
-
- string extension = string.Empty;
-
- if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Metadata.Type))
- {
- extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Metadata.Type];
- }
-
- xtw.WriteElementString("filename", uuid.ToString() + extension);
-
- xtw.WriteElementString("name", asset.Metadata.Name);
- xtw.WriteElementString("description", asset.Metadata.Description);
- xtw.WriteElementString("asset-type", asset.Metadata.Type.ToString());
-
- xtw.WriteEndElement();
- }
- }
-
- xtw.WriteEndElement();
-
- xtw.WriteEndDocument();
-
- archive.AddFile("assets.xml", sw.ToString());
- }
-
- ///
- /// Write asset data files to the given archive
- ///
- ///
- protected void WriteData(TarArchiveWriter archive)
- {
- // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar
- //archive.AddDir("assets");
-
- foreach (UUID uuid in m_assets.Keys)
- {
- AssetBase asset = m_assets[uuid];
-
- string extension = string.Empty;
-
- if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Metadata.Type))
- {
- extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Metadata.Type];
- }
- else
- {
- m_log.ErrorFormat(
- "[ARCHIVER]: Unrecognized asset type {0} with uuid {1}. This asset will be saved but not reloaded",
- asset.Metadata.Type, asset.Metadata.ID);
- }
-
- archive.AddFile(
- ArchiveConstants.ASSETS_PATH + uuid.ToString() + extension,
- asset.Data);
- }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs
deleted file mode 100644
index 95ff468..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using System.Xml;
-using OpenMetaverse;
-using log4net;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications.Cache;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Dearchives assets
- ///
- public class AssetsDearchiver
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
-
- ///
- /// Store for asset data we received before we get the metadata
- ///
- protected Dictionary m_assetDataAwaitingMetadata = new Dictionary();
-
- ///
- /// Asset metadata. Is null if asset metadata isn't yet available.
- ///
- protected Dictionary m_metadata;
-
- ///
- /// Cache to which dearchived assets will be added
- ///
- protected IAssetCache m_cache;
-
- public AssetsDearchiver(IAssetCache cache)
- {
- m_cache = cache;
- }
-
- ///
- /// Add asset data to the dearchiver
- ///
- ///
- ///
- public void AddAssetData(string assetFilename, byte[] data)
- {
- if (null == m_metadata)
- {
- m_assetDataAwaitingMetadata[assetFilename] = data;
- }
- else
- {
- ResolveAssetData(assetFilename, data);
- }
- }
-
- ///
- /// Add asset metadata xml
- ///
- ///
- public void AddAssetMetadata(string xml)
- {
- m_metadata = new Dictionary();
-
- StringReader sr = new StringReader(xml);
- XmlTextReader reader = new XmlTextReader(sr);
-
- reader.ReadStartElement("assets");
- reader.Read();
-
- while (reader.Name.Equals("asset"))
- {
- reader.Read();
-
- AssetMetadata metadata = new AssetMetadata();
-
- string filename = reader.ReadElementString("filename");
- m_log.DebugFormat("[DEARCHIVER]: Reading node {0}", filename);
-
- metadata.Name = reader.ReadElementString("name");
- metadata.Description = reader.ReadElementString("description");
- metadata.AssetType = Convert.ToSByte(reader.ReadElementString("asset-type"));
-
- m_metadata[filename] = metadata;
-
- // Read asset end tag
- reader.ReadEndElement();
-
- reader.Read();
- }
-
- m_log.DebugFormat("[DEARCHIVER]: Resolved {0} items of asset metadata", m_metadata.Count);
-
- ResolvePendingAssetData();
- }
-
- ///
- /// Resolve asset data that we collected before receiving the metadata
- ///
- protected void ResolvePendingAssetData()
- {
- foreach (string filename in m_assetDataAwaitingMetadata.Keys)
- {
- ResolveAssetData(filename, m_assetDataAwaitingMetadata[filename]);
- }
- }
-
- ///
- /// Resolve a new piece of asset data against stored metadata
- ///
- ///
- ///
- protected void ResolveAssetData(string assetPath, byte[] data)
- {
- // Right now we're nastily obtaining the UUID from the filename
- string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
-
- if (m_metadata.ContainsKey(filename))
- {
- AssetMetadata metadata = m_metadata[filename];
-
- if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(metadata.AssetType))
- {
- string extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[metadata.AssetType];
- filename = filename.Remove(filename.Length - extension.Length);
- }
-
- m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename);
-
- AssetBase asset = new AssetBase(new UUID(filename), metadata.Name);
- asset.Metadata.Description = metadata.Description;
- asset.Metadata.Type = metadata.AssetType;
- asset.Data = data;
-
- m_cache.AddAsset(asset);
- }
- else
- {
- m_log.ErrorFormat(
- "[DEARCHIVER]: Tried to dearchive data with filename {0} without any corresponding metadata",
- assetPath);
- }
- }
-
- ///
- /// Metadata for an asset
- ///
- protected struct AssetMetadata
- {
- public string Name;
- public string Description;
- public sbyte AssetType;
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs
deleted file mode 100644
index b7fd170..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.Reflection;
-using System.Threading;
-using OpenMetaverse;
-using log4net;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Encapsulate the asynchronous requests for the assets required for an archive operation
- ///
- class AssetsRequest
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- ///
- /// uuids to request
- ///
- protected ICollection m_uuids;
-
- ///
- /// Callback used when all the assets requested have been received.
- ///
- protected AssetsRequestCallback m_assetsRequestCallback;
-
- ///
- /// Assets retrieved in this request
- ///
- protected Dictionary m_assets = new Dictionary();
-
- ///
- /// Maintain a list of assets that could not be found. This will be passed back to the requester.
- ///
- protected List m_notFoundAssetUuids = new List();
-
- ///
- /// Record the number of asset replies required so we know when we've finished
- ///
- private int m_repliesRequired;
-
- ///
- /// Asset cache used to request the assets
- ///
- protected IAssetCache m_assetCache;
-
- protected internal AssetsRequest(ICollection uuids, IAssetCache assetCache, AssetsRequestCallback assetsRequestCallback)
- {
- m_uuids = uuids;
- m_assetsRequestCallback = assetsRequestCallback;
- m_assetCache = assetCache;
- m_repliesRequired = uuids.Count;
- }
-
- protected internal void Execute()
- {
- // We can stop here if there are no assets to fetch
- if (m_repliesRequired == 0)
- m_assetsRequestCallback(m_assets, m_notFoundAssetUuids);
-
- foreach (UUID uuid in m_uuids)
- {
- m_assetCache.GetAsset(uuid, AssetRequestCallback, true);
- }
- }
-
- ///
- /// Called back by the asset cache when it has the asset
- ///
- ///
- ///
- public void AssetRequestCallback(UUID assetID, AssetBase asset)
- {
- if (asset != null)
- m_assets[assetID] = asset;
- else
- m_notFoundAssetUuids.Add(assetID);
-
- //m_log.DebugFormat(
- // "[ARCHIVER]: Received {0} assets and notification of {1} missing assets", m_assets.Count, m_notFoundAssetUuids.Count);
-
- if (m_assets.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
- {
- // We want to stop using the asset cache thread asap as we now need to do the actual work of producing the archive
- Thread newThread = new Thread(PerformAssetsRequestCallback);
- newThread.Name = "OpenSimulator archiving thread post assets receipt";
- newThread.Start();
- }
- }
-
- ///
- /// Perform the callback on the original requester of the assets
- ///
- protected void PerformAssetsRequestCallback()
- {
- try
- {
- m_assetsRequestCallback(m_assets, m_notFoundAssetUuids);
- }
- catch (Exception e)
- {
- m_log.ErrorFormat(
- "[ARCHIVER]: Terminating archive creation since asset requster callback failed with {0}", e);
- }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/RegionSettingsSerializer.cs b/OpenSim/Region/Environment/Modules/World/Archiver/RegionSettingsSerializer.cs
deleted file mode 100644
index e12d0ec..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/RegionSettingsSerializer.cs
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * 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.IO;
-using System.Text;
-using System.Xml;
-using OpenMetaverse;
-using OpenSim.Framework;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Serialize and deserialize region settings for an archive file format.
- ///
- /// We didn't simply use automatic .NET serializagion for OpenSim.Framework.RegionSettings since this is really
- /// a file format rather than an object serialization.
- /// TODO: However, we could still have used separate non-framework classes here to read and write the xml
- /// automatically rather than laboriously doing it by hand using XmlTextReader and Writer. Should switch to this
- /// in the future.
- public class RegionSettingsSerializer
- {
- protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
-
- ///
- /// Deserialize region settings
- ///
- ///
- ///
- ///
- public static RegionSettings Deserialize(byte[] serializedSettings)
- {
- return Deserialize(m_asciiEncoding.GetString(serializedSettings, 0, serializedSettings.Length));
- }
-
- ///
- /// Deserialize region settings
- ///
- ///
- ///
- ///
- public static RegionSettings Deserialize(string serializedSettings)
- {
- RegionSettings settings = new RegionSettings();
-
- StringReader sr = new StringReader(serializedSettings);
- XmlTextReader xtr = new XmlTextReader(sr);
-
- xtr.ReadStartElement("RegionSettings");
-
- xtr.ReadStartElement("General");
-
- while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
- {
- switch (xtr.Name)
- {
- case "AllowDamage":
- settings.AllowDamage = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "AllowLandResell":
- settings.AllowLandResell = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "AllowLandJoinDivide":
- settings.AllowLandJoinDivide = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "BlockFly":
- settings.BlockFly = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "BlockLandShowInSearch":
- settings.BlockShowInSearch = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "BlockTerraform":
- settings.BlockTerraform = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "DisableCollisions":
- settings.DisableCollisions = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "DisablePhysics":
- settings.DisablePhysics = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "DisableScripts":
- settings.DisableScripts = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "MaturityRating":
- settings.Maturity = int.Parse(xtr.ReadElementContentAsString());
- break;
- case "RestrictPushing":
- settings.RestrictPushing = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "AgentLimit":
- settings.AgentLimit = int.Parse(xtr.ReadElementContentAsString());
- break;
- case "ObjectBonus":
- settings.ObjectBonus = double.Parse(xtr.ReadElementContentAsString());
- break;
- }
- }
-
- xtr.ReadEndElement();
- xtr.ReadStartElement("GroundTextures");
-
- while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
- {
- switch (xtr.Name)
- {
- case "Texture1":
- settings.TerrainTexture1 = UUID.Parse(xtr.ReadElementContentAsString());
- break;
- case "Texture2":
- settings.TerrainTexture2 = UUID.Parse(xtr.ReadElementContentAsString());
- break;
- case "Texture3":
- settings.TerrainTexture3 = UUID.Parse(xtr.ReadElementContentAsString());
- break;
- case "Texture4":
- settings.TerrainTexture4 = UUID.Parse(xtr.ReadElementContentAsString());
- break;
- case "ElevationLowSW":
- settings.Elevation1SW = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "ElevationLowNW":
- settings.Elevation1NW = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "ElevationLowSE":
- settings.Elevation1SE = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "ElevationLowNE":
- settings.Elevation1NE = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "ElevationHighSW":
- settings.Elevation1SW = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "ElevationHighNW":
- settings.Elevation2NW = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "ElevationHighSE":
- settings.Elevation2SE = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "ElevationHighNE":
- settings.Elevation2NE = double.Parse(xtr.ReadElementContentAsString());
- break;
- }
- }
-
- xtr.ReadEndElement();
- xtr.ReadStartElement("Terrain");
-
- while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
- {
- switch (xtr.Name)
- {
- case "WaterHeight":
- settings.WaterHeight = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "TerrainRaiseLimit":
- settings.TerrainRaiseLimit = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "TerrainLowerLimit":
- settings.TerrainLowerLimit = double.Parse(xtr.ReadElementContentAsString());
- break;
- case "UseEstateSun":
- settings.UseEstateSun = bool.Parse(xtr.ReadElementContentAsString());
- break;
- case "FixedSun":
- settings.FixedSun = bool.Parse(xtr.ReadElementContentAsString());
- break;
- }
- }
-
- xtr.Close();
- sr.Close();
-
- return settings;
- }
-
- public static string Serialize(RegionSettings settings)
- {
- StringWriter sw = new StringWriter();
- XmlTextWriter xtw = new XmlTextWriter(sw);
- xtw.Formatting = Formatting.Indented;
- xtw.WriteStartDocument();
-
- xtw.WriteStartElement("RegionSettings");
-
- xtw.WriteStartElement("General");
- xtw.WriteElementString("AllowDamage", settings.AllowDamage.ToString());
- xtw.WriteElementString("AllowLandResell", settings.AllowLandResell.ToString());
- xtw.WriteElementString("AllowLandJoinDivide", settings.AllowLandJoinDivide.ToString());
- xtw.WriteElementString("BlockFly", settings.BlockFly.ToString());
- xtw.WriteElementString("BlockLandShowInSearch", settings.BlockShowInSearch.ToString());
- xtw.WriteElementString("BlockTerraform", settings.BlockTerraform.ToString());
- xtw.WriteElementString("DisableCollisions", settings.DisableCollisions.ToString());
- xtw.WriteElementString("DisablePhysics", settings.DisablePhysics.ToString());
- xtw.WriteElementString("DisableScripts", settings.DisableScripts.ToString());
- xtw.WriteElementString("MaturityRating", settings.Maturity.ToString());
- xtw.WriteElementString("RestrictPushing", settings.RestrictPushing.ToString());
- xtw.WriteElementString("AgentLimit", settings.AgentLimit.ToString());
- xtw.WriteElementString("ObjectBonus", settings.ObjectBonus.ToString());
- xtw.WriteEndElement();
-
- xtw.WriteStartElement("GroundTextures");
- xtw.WriteElementString("Texture1", settings.TerrainTexture1.ToString());
- xtw.WriteElementString("Texture2", settings.TerrainTexture2.ToString());
- xtw.WriteElementString("Texture3", settings.TerrainTexture3.ToString());
- xtw.WriteElementString("Texture4", settings.TerrainTexture4.ToString());
- xtw.WriteElementString("ElevationLowSW", settings.Elevation1SW.ToString());
- xtw.WriteElementString("ElevationLowNW", settings.Elevation1NW.ToString());
- xtw.WriteElementString("ElevationLowSE", settings.Elevation1SE.ToString());
- xtw.WriteElementString("ElevationLowNE", settings.Elevation1NE.ToString());
- xtw.WriteElementString("ElevationHighSW", settings.Elevation2SW.ToString());
- xtw.WriteElementString("ElevationHighNW", settings.Elevation2NW.ToString());
- xtw.WriteElementString("ElevationHighSE", settings.Elevation2SE.ToString());
- xtw.WriteElementString("ElevationHighNE", settings.Elevation2NE.ToString());
- xtw.WriteEndElement();
-
- xtw.WriteStartElement("Terrain");
- xtw.WriteElementString("WaterHeight", settings.WaterHeight.ToString());
- xtw.WriteElementString("TerrainRaiseLimit", settings.TerrainRaiseLimit.ToString());
- xtw.WriteElementString("TerrainLowerLimit", settings.TerrainLowerLimit.ToString());
- xtw.WriteElementString("UseEstateSun", settings.UseEstateSun.ToString());
- xtw.WriteElementString("FixedSun", settings.FixedSun.ToString());
- // XXX: Need to expose interface to get sun phase information from sun module
- // xtw.WriteStartElement("SunPhase",
- xtw.WriteEndElement();
-
- xtw.WriteEndElement();
-
- xtw.Close();
- sw.Close();
-
- return sw.ToString();
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
deleted file mode 100644
index 3862546..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * 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.IO;
-using System.Reflection;
-using System.Text;
-using log4net;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Temporary code to do the bare minimum required to read a tar archive for our purposes
- ///
- public class TarArchiveReader
- {
- //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- public enum TarEntryType
- {
- TYPE_UNKNOWN = 0,
- TYPE_NORMAL_FILE = 1,
- TYPE_HARD_LINK = 2,
- TYPE_SYMBOLIC_LINK = 3,
- TYPE_CHAR_SPECIAL = 4,
- TYPE_BLOCK_SPECIAL = 5,
- TYPE_DIRECTORY = 6,
- TYPE_FIFO = 7,
- TYPE_CONTIGUOUS_FILE = 8,
- }
-
- protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
-
- ///
- /// Binary reader for the underlying stream
- ///
- protected BinaryReader m_br;
-
- ///
- /// Used to trim off null chars
- ///
- protected char[] m_nullCharArray = new char[] { '\0' };
-
- ///
- /// Generate a tar reader which reads from the given stream.
- ///
- ///
- public TarArchiveReader(Stream s)
- {
- m_br = new BinaryReader(s);
- }
-
- ///
- /// Read the next entry in the tar file.
- ///
- ///
- /// the data for the entry. Returns null if there are no more entries
- public byte[] ReadEntry(out string filePath, out TarEntryType entryType)
- {
- filePath = String.Empty;
- entryType = TarEntryType.TYPE_UNKNOWN;
- TarHeader header = ReadHeader();
-
- if (null == header)
- return null;
-
- entryType = header.EntryType;
- filePath = header.FilePath;
- byte[] data = m_br.ReadBytes(header.FileSize);
-
- //m_log.DebugFormat("[TAR ARCHIVE READER]: filePath {0}, fileSize {1}", filePath, header.FileSize);
-
- // Read the rest of the empty padding in the 512 byte block
- if (header.FileSize % 512 != 0)
- {
- int paddingLeft = 512 - (header.FileSize % 512);
-
- //m_log.DebugFormat("[TAR ARCHIVE READER]: Reading {0} padding bytes", paddingLeft);
-
- m_br.ReadBytes(paddingLeft);
- }
-
- return data;
- }
-
- ///
- /// Read the next 512 byte chunk of data as a tar header.
- ///
- /// A tar header struct. null if we have reached the end of the archive.
- protected TarHeader ReadHeader()
- {
- byte[] header = m_br.ReadBytes(512);
-
- // If we've reached the end of the archive we'll be in null block territory, which means
- // the next byte will be 0
- if (header[0] == 0)
- return null;
-
- TarHeader tarHeader = new TarHeader();
-
- tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
- tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
- tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11);
-
- switch (header[156])
- {
- case 0:
- tarHeader.EntryType = TarEntryType.TYPE_NORMAL_FILE;
- break;
- case (byte)'0':
- tarHeader.EntryType = TarEntryType.TYPE_NORMAL_FILE;
- break;
- case (byte)'1':
- tarHeader.EntryType = TarEntryType.TYPE_HARD_LINK;
- break;
- case (byte)'2':
- tarHeader.EntryType = TarEntryType.TYPE_SYMBOLIC_LINK;
- break;
- case (byte)'3':
- tarHeader.EntryType = TarEntryType.TYPE_CHAR_SPECIAL;
- break;
- case (byte)'4':
- tarHeader.EntryType = TarEntryType.TYPE_BLOCK_SPECIAL;
- break;
- case (byte)'5':
- tarHeader.EntryType = TarEntryType.TYPE_DIRECTORY;
- break;
- case (byte)'6':
- tarHeader.EntryType = TarEntryType.TYPE_FIFO;
- break;
- case (byte)'7':
- tarHeader.EntryType = TarEntryType.TYPE_CONTIGUOUS_FILE;
- break;
- }
-
- return tarHeader;
- }
-
- public void Close()
- {
- m_br.Close();
- }
-
- ///
- /// Convert octal bytes to a decimal representation
- ///
- ///
- ///
- public static int ConvertOctalBytesToDecimal(byte[] bytes, int startIndex, int count)
- {
- string oString = m_asciiEncoding.GetString(bytes, startIndex, count);
-
- int d = 0;
-
- foreach (char c in oString)
- {
- d <<= 3;
- d |= c - '0';
- }
-
- return d;
- }
- }
-
- public class TarHeader
- {
- public string FilePath;
- public int FileSize;
- public TarArchiveReader.TarEntryType EntryType;
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
deleted file mode 100644
index 8fd247c..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using System.Text;
-using System.Reflection;
-using log4net;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver
-{
- ///
- /// Temporary code to produce a tar archive in tar v7 format
- ///
- public class TarArchiveWriter
- {
- //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- protected Dictionary m_files = new Dictionary();
-
- protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
-
- ///
- /// Add a directory to the tar archive. We can only handle one path level right now!
- ///
- ///
- public void AddDir(string dirName)
- {
- // Directories are signalled by a final /
- if (!dirName.EndsWith("/"))
- dirName += "/";
-
- AddFile(dirName, new byte[0]);
- }
-
- ///
- /// Add a file to the tar archive
- ///
- ///
- ///
- public void AddFile(string filePath, string data)
- {
- AddFile(filePath, m_asciiEncoding.GetBytes(data));
- }
-
- ///
- /// Add a file to the tar archive
- ///
- ///
- ///
- public void AddFile(string filePath, byte[] data)
- {
- m_files[filePath] = data;
- }
-
- ///
- /// Write the raw tar archive data to a stream. The stream will be closed on completion.
- ///
- /// Stream to which to write the data
- ///
- public void WriteTar(Stream s)
- {
- BinaryWriter bw = new BinaryWriter(s);
-
- foreach (string filePath in m_files.Keys)
- {
- byte[] header = new byte[512];
- byte[] data = m_files[filePath];
-
- // file path field (100)
- byte[] nameBytes = m_asciiEncoding.GetBytes(filePath);
- int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length;
- Array.Copy(nameBytes, header, nameSize);
-
- // file mode (8)
- byte[] modeBytes = m_asciiEncoding.GetBytes("0000777");
- Array.Copy(modeBytes, 0, header, 100, 7);
-
- // owner user id (8)
- byte[] ownerIdBytes = m_asciiEncoding.GetBytes("0000764");
- Array.Copy(ownerIdBytes, 0, header, 108, 7);
-
- // group user id (8)
- byte[] groupIdBytes = m_asciiEncoding.GetBytes("0000764");
- Array.Copy(groupIdBytes, 0, header, 116, 7);
-
- // file size in bytes (12)
- int fileSize = data.Length;
- //m_log.DebugFormat("[TAR ARCHIVE WRITER]: File size of {0} is {1}", filePath, fileSize);
-
- byte[] fileSizeBytes = ConvertDecimalToPaddedOctalBytes(fileSize, 11);
-
- Array.Copy(fileSizeBytes, 0, header, 124, 11);
-
- // last modification time (12)
- byte[] lastModTimeBytes = m_asciiEncoding.GetBytes("11017037332");
- Array.Copy(lastModTimeBytes, 0, header, 136, 11);
-
- // link indicator (1)
- //header[156] = m_asciiEncoding.GetBytes("0")[0];
- if (filePath.EndsWith("/"))
- {
- header[156] = m_asciiEncoding.GetBytes("5")[0];
- }
- else
- {
- header[156] = 0;
- }
-
- Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 329, 7);
- Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 337, 7);
-
- // check sum for header block (8) [calculated last]
- Array.Copy(m_asciiEncoding.GetBytes(" "), 0, header, 148, 8);
-
- int checksum = 0;
- foreach (byte b in header)
- {
- checksum += b;
- }
-
- //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Decimal header checksum is {0}", checksum);
-
- byte[] checkSumBytes = ConvertDecimalToPaddedOctalBytes(checksum, 6);
-
- Array.Copy(checkSumBytes, 0, header, 148, 6);
-
- header[154] = 0;
-
- // Write out header
- bw.Write(header);
-
- // Write out data
- bw.Write(data);
-
- if (data.Length % 512 != 0)
- {
- int paddingRequired = 512 - (data.Length % 512);
-
- //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired);
-
- byte[] padding = new byte[paddingRequired];
- bw.Write(padding);
- }
- }
-
- //m_log.Debug("[TAR ARCHIVE WRITER]: Writing final consecutive 0 blocks");
-
- // Write two consecutive 0 blocks to end the archive
- byte[] finalZeroPadding = new byte[1024];
- bw.Write(finalZeroPadding);
-
- bw.Flush();
- bw.Close();
- }
-
- public static byte[] ConvertDecimalToPaddedOctalBytes(int d, int padding)
- {
- string oString = "";
-
- while (d > 0)
- {
- oString = Convert.ToString((byte)'0' + d & 7) + oString;
- d >>= 3;
- }
-
- while (oString.Length < padding)
- {
- oString = "0" + oString;
- }
-
- byte[] oBytes = m_asciiEncoding.GetBytes(oString);
-
- return oBytes;
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
deleted file mode 100644
index e265252..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/Tests/ArchiverTests.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.IO;
-using System.Threading;
-using NUnit.Framework;
-using NUnit.Framework.SyntaxHelpers;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Environment.Modules.World.Archiver;
-using OpenSim.Region.Environment.Modules.World.Serialiser;
-using OpenSim.Region.Environment.Modules.World.Terrain;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Tests.Common.Setup;
-
-namespace OpenSim.Region.Environment.Modules.World.Archiver.Tests
-{
- [TestFixture]
- public class ArchiverTests
- {
- private EventWaitHandle m_waitHandle = new AutoResetEvent(false);
-
- private void SaveCompleted(string errorMessage)
- {
- m_waitHandle.Set();
- }
-
- ///
- /// Test saving a V0.2 OpenSim Region Archive.
- ///
- [Test]
- public void TestSaveOarV0p2()
- {
- log4net.Config.XmlConfigurator.Configure();
-
- ArchiverModule archiverModule = new ArchiverModule();
- SerialiserModule serialiserModule = new SerialiserModule();
- TerrainModule terrainModule = new TerrainModule();
-
- Scene scene = SceneSetupHelpers.SetupScene();
- SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule);
-
- SceneObjectPart part1;
-
- // Create and add prim 1
- {
- string partName = "My Little Pony";
- UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000015");
- PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
- Vector3 groupPosition = new Vector3(10, 20, 30);
- Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
- Vector3 offsetPosition = new Vector3(5, 10, 15);
-
- part1
- = new SceneObjectPart(
- ownerId, shape, groupPosition, rotationOffset, offsetPosition);
- part1.Name = partName;
-
- scene.AddNewSceneObject(new SceneObjectGroup(part1), false);
- }
-
- SceneObjectPart part2;
-
- // Create and add prim 2
- {
- string partName = "Action Man";
- UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000016");
- PrimitiveBaseShape shape = PrimitiveBaseShape.CreateCylinder();
- Vector3 groupPosition = new Vector3(90, 80, 70);
- Quaternion rotationOffset = new Quaternion(60, 70, 80, 90);
- Vector3 offsetPosition = new Vector3(20, 25, 30);
-
- part2
- = new SceneObjectPart(
- ownerId, shape, groupPosition, rotationOffset, offsetPosition);
- part2.Name = partName;
-
- scene.AddNewSceneObject(new SceneObjectGroup(part2), false);
- }
-
- MemoryStream archiveWriteStream = new MemoryStream();
-
- scene.EventManager.OnOarFileSaved += SaveCompleted;
- archiverModule.ArchiveRegion(archiveWriteStream);
- m_waitHandle.WaitOne(60000, true);
-
- byte[] archive = archiveWriteStream.ToArray();
- MemoryStream archiveReadStream = new MemoryStream(archive);
- TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
-
- bool gotControlFile = false;
- bool gotObject1File = false;
- bool gotObject2File = false;
- string expectedObject1FileName = string.Format(
- "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
- part1.Name,
- Math.Round(part1.GroupPosition.X), Math.Round(part1.GroupPosition.Y), Math.Round(part1.GroupPosition.Z),
- part1.UUID);
- string expectedObject2FileName = string.Format(
- "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
- part2.Name,
- Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z),
- part2.UUID);
-
- string filePath;
- TarArchiveReader.TarEntryType tarEntryType;
-
- while (tar.ReadEntry(out filePath, out tarEntryType) != null)
- {
- if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
- {
- gotControlFile = true;
- }
- else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
- {
- string fileName = filePath.Remove(0, ArchiveConstants.OBJECTS_PATH.Length);
-
- if (fileName.StartsWith(part1.Name))
- {
- Assert.That(fileName, Is.EqualTo(expectedObject1FileName));
- gotObject1File = true;
- }
- else if (fileName.StartsWith(part2.Name))
- {
- Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
- gotObject2File = true;
- }
- }
- }
-
- Assert.That(gotControlFile, Is.True, "No control file in archive");
- Assert.That(gotObject1File, Is.True, "No object1 file in archive");
- Assert.That(gotObject2File, Is.True, "No object2 file in archive");
-
- // TODO: Test presence of more files and contents of files.
- }
-
- ///
- /// Test loading a V0.2 OpenSim Region Archive. Does not yet do what it says on the tin.
- ///
- [Test]
- public void TestLoadOarV0p2()
- {
- MemoryStream archiveWriteStream = new MemoryStream();
- TarArchiveWriter tar = new TarArchiveWriter();
-
- tar.AddFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
- tar.WriteTar(archiveWriteStream);
-
- MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
-
- ArchiverModule archiverModule = new ArchiverModule();
-
- Scene scene = SceneSetupHelpers.SetupScene();
- SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
-
- archiverModule.DearchiveRegion(archiveReadStream);
-
- // TODO: Okay, so nothing is tested yet apart from the fact that it doesn't blow up
- }
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
deleted file mode 100644
index 6b74c83..0000000
--- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs
+++ /dev/null
@@ -1,1012 +0,0 @@
-/*
- * 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.Framework.Interfaces;
-using OpenSim.Region.Framework.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 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();
-
- 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();
-
- 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 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();
-
- 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();
-
- 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 SceneData = new Dictionary();
- List uuidNameLookupList = new List();
-
- if (reportType == 1)
- {
- SceneData = m_scene.PhysicsScene.GetTopColliders();
- }
- else if (reportType == 0)
- {
- SceneData = m_scene.m_sceneGraph.GetTopScripts();
- }
-
- List SceneReport = new List();
- 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 uuidLst)
- {
- LookupUUIDS d = LookupUUIDsAsync;
-
- d.BeginInvoke(uuidLst,
- LookupUUIDSCompleted,
- d);
- }
- private void LookupUUIDsAsync(List 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 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(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 ems = new List(m_scene.RegionInfo.EstateSettings.EstateManagers);
- if (ems.Contains(avatarID))
- return true;
-
- return false;
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateTerrainXferHandler.cs
deleted file mode 100644
index 267178e..0000000
--- a/OpenSim/Region/Environment/Modules/World/Estate/EstateTerrainXferHandler.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.IO;
-using System.Reflection;
-using log4net;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Region.Framework.Scenes;
-
-
-namespace OpenSim.Region.Environment.Modules.World.Estate
-{
-
- public class EstateTerrainXferHandler
- {
- //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private AssetBase m_asset;
-
- public delegate void TerrainUploadComplete(string name, byte[] filedata, IClientAPI remoteClient);
-
- public event TerrainUploadComplete TerrainUploadDone;
-
- //private string m_description = String.Empty;
- //private string m_name = String.Empty;
- //private UUID TransactionID = UUID.Zero;
- private sbyte type = 0;
-
- public ulong mXferID;
- private TerrainUploadComplete handlerTerrainUploadDone;
-
- public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename)
- {
-
- m_asset = new AssetBase();
- m_asset.Metadata.FullID = UUID.Zero;
- m_asset.Metadata.Type = type;
- m_asset.Data = new byte[0];
- m_asset.Metadata.Name = pClientFilename;
- m_asset.Metadata.Description = "empty";
- m_asset.Metadata.Local = true;
- m_asset.Metadata.Temporary = true;
-
- }
-
- public ulong XferID
- {
- get { return mXferID; }
- }
-
- public void RequestStartXfer(IClientAPI pRemoteClient)
- {
- mXferID = Util.GetNextXferID();
- pRemoteClient.SendXferRequest(mXferID, m_asset.Metadata.Type, m_asset.Metadata.FullID, 0, Utils.StringToBytes(m_asset.Metadata.Name));
- }
-
- ///
- /// Process transfer data received from the client.
- ///
- ///
- ///
- ///
- public void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
- {
- if (mXferID == xferID)
- {
- if (m_asset.Data.Length > 1)
- {
- byte[] destinationArray = new byte[m_asset.Data.Length + data.Length];
- Array.Copy(m_asset.Data, 0, destinationArray, 0, m_asset.Data.Length);
- Array.Copy(data, 0, destinationArray, m_asset.Data.Length, data.Length);
- m_asset.Data = destinationArray;
- }
- else
- {
- byte[] buffer2 = new byte[data.Length - 4];
- Array.Copy(data, 4, buffer2, 0, data.Length - 4);
- m_asset.Data = buffer2;
- }
-
- remoteClient.SendConfirmXfer(xferID, packetID);
-
- if ((packetID & 0x80000000) != 0)
- {
- SendCompleteMessage(remoteClient);
-
- }
- }
- }
-
- public void SendCompleteMessage(IClientAPI remoteClient)
- {
- handlerTerrainUploadDone = TerrainUploadDone;
- if (handlerTerrainUploadDone != null)
- {
- handlerTerrainUploadDone(m_asset.Metadata.Name, m_asset.Data, remoteClient);
- }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
deleted file mode 100644
index 76555d2..0000000
--- a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.Collections.Generic;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Land
-{
- public class LandChannel : ILandChannel
- {
- #region Constants
-
- //Land types set with flags in ParcelOverlay.
- //Only one of these can be used.
- public const float BAN_LINE_SAFETY_HIEGHT = 100;
- public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = 128; //Equals 10000000
- public const byte LAND_FLAG_PROPERTY_BORDER_WEST = 64; //Equals 01000000
-
- //RequestResults (I think these are right, they seem to work):
- public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
- public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
-
- //ParcelSelectObjects
- public const int LAND_SELECT_OBJECTS_GROUP = 4;
- public const int LAND_SELECT_OBJECTS_OTHER = 8;
- public const int LAND_SELECT_OBJECTS_OWNER = 2;
- public const byte LAND_TYPE_IS_BEING_AUCTIONED = 5; //Equals 00000101
- public const byte LAND_TYPE_IS_FOR_SALE = 4; //Equals 00000100
- public const byte LAND_TYPE_OWNED_BY_GROUP = 2; //Equals 00000010
- public const byte LAND_TYPE_OWNED_BY_OTHER = 1; //Equals 00000001
- public const byte LAND_TYPE_OWNED_BY_REQUESTER = 3; //Equals 00000011
- public const byte LAND_TYPE_PUBLIC = 0; //Equals 00000000
-
- //These are other constants. Yay!
- public const int START_LAND_LOCAL_ID = 1;
-
- #endregion
-
- private readonly Scene m_scene;
- private readonly LandManagementModule m_landManagementModule;
-
- public LandChannel(Scene scene, LandManagementModule landManagementMod)
- {
- m_scene = scene;
- m_landManagementModule = landManagementMod;
- }
-
- #region ILandChannel Members
-
-
- ///
- /// Get the land object at the specified point
- ///
- /// Value between 0 - 256 on the x axis of the point
- /// Value between 0 - 256 on the y axis of the point
- /// Land object at the point supplied
- public ILandObject GetLandObject(float x_float, float y_float)
- {
- if (m_landManagementModule != null)
- {
- return m_landManagementModule.GetLandObject(x_float, y_float);
- }
- ILandObject obj = new LandObject(UUID.Zero, false, m_scene);
- obj.landData.Name = "NO LAND";
- return obj;
- }
-
- public ILandObject GetLandObject(int x, int y)
- {
- if (m_landManagementModule != null)
- {
- return m_landManagementModule.GetLandObject(x, y);
- }
- ILandObject obj = new LandObject(UUID.Zero, false, m_scene);
- obj.landData.Name = "NO LAND";
- return obj;
- }
-
- public List AllParcels()
- {
- if (m_landManagementModule != null)
- {
- return m_landManagementModule.AllParcels();
- }
-
- return new List();
- }
-
- public List ParcelsNearPoint(Vector3 position)
- {
- if (m_landManagementModule != null)
- {
- return m_landManagementModule.ParcelsNearPoint(position);
- }
-
- return new List();
- }
-
- public bool IsLandPrimCountTainted()
- {
- if (m_landManagementModule != null)
- {
- return m_landManagementModule.IsLandPrimCountTainted();
- }
-
- return false;
- }
-
- public bool IsForcefulBansAllowed()
- {
- if (m_landManagementModule != null)
- {
- return m_landManagementModule.AllowedForcefulBans;
- }
-
- return false;
- }
-
- public void UpdateLandObject(int localID, LandData data)
- {
- if (m_landManagementModule != null)
- {
- m_landManagementModule.UpdateLandObject(localID, data);
- }
- }
- public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
- {
- if (m_landManagementModule != null)
- {
- m_landManagementModule.ReturnObjectsInParcel(localID, returnType, agentIDs, taskIDs, remoteClient);
- }
- }
-
- public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
- {
- if (m_landManagementModule != null)
- {
- m_landManagementModule.setParcelObjectMaxOverride(overrideDel);
- }
- }
-
- public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
- {
- if (m_landManagementModule != null)
- {
- m_landManagementModule.setSimulatorObjectMaxOverride(overrideDel);
- }
- }
-
- public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
- {
- if (m_landManagementModule != null)
- {
- m_landManagementModule.setParcelOtherCleanTime(remoteClient, localID, otherCleanTime);
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
deleted file mode 100644
index 58176e4..0000000
--- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
+++ /dev/null
@@ -1,1347 +0,0 @@
-/*
- * 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.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-using OpenMetaverse;
-using log4net;
-using Nini.Config;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Framework;
-using OpenSim.Framework.Servers;
-using OpenSim.Framework.Communications.Capabilities;
-using OpenSim.Region.Physics.Manager;
-using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
-
-namespace OpenSim.Region.Environment.Modules.World.Land
-{
- // used for caching
- internal class ExtendedLandData {
- public LandData landData;
- public ulong regionHandle;
- public uint x, y;
- }
-
- public class LandManagementModule : IRegionModule
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private static readonly string remoteParcelRequestPath = "0009/";
-
- private LandChannel landChannel;
- private Scene m_scene;
-
- private readonly int[,] m_landIDList = new int[64, 64];
- private readonly Dictionary m_landList = new Dictionary();
-
- private bool m_landPrimCountTainted;
- private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
-
- private bool m_allowedForcefulBans = true;
-
- // caches ExtendedLandData
- private Cache parcelInfoCache;
-
- #region IRegionModule Members
-
- public void Initialise(Scene scene, IConfigSource source)
- {
- m_scene = scene;
- m_landIDList.Initialize();
- landChannel = new LandChannel(scene, this);
-
- parcelInfoCache = new Cache();
- parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache
- parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0);
-
- m_scene.EventManager.OnParcelPrimCountAdd += AddPrimToLandPrimCounts;
- m_scene.EventManager.OnParcelPrimCountUpdate += UpdateLandPrimCounts;
- m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel);
- m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(handleAnyClientMovement);
- m_scene.EventManager.OnValidateLandBuy += handleLandValidationRequest;
- m_scene.EventManager.OnLandBuy += handleLandBuyRequest;
- m_scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
- m_scene.EventManager.OnSignificantClientMovement += handleSignificantClientMovement;
- m_scene.EventManager.OnObjectBeingRemovedFromScene += RemovePrimFromLandPrimCounts;
-
- m_scene.EventManager.OnNoticeNoLandDataFromStorage += this.NoLandDataFromStorage;
- m_scene.EventManager.OnIncomingLandDataFromStorage += this.IncomingLandObjectsFromStorage;
- m_scene.EventManager.OnSetAllowForcefulBan += this.SetAllowedForcefulBans;
- m_scene.EventManager.OnRequestParcelPrimCountUpdate += this.PerformParcelPrimCountUpdate;
- m_scene.EventManager.OnParcelPrimCountTainted += this.SetPrimsTainted;
- m_scene.EventManager.OnRegisterCaps += this.OnRegisterCaps;
-
- lock (m_scene)
- {
- m_scene.LandChannel = (ILandChannel) landChannel;
- }
- }
-
- void EventManager_OnNewClient(IClientAPI client)
- {
- //Register some client events
- client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(handleParcelPropertiesRequest);
- client.OnParcelDivideRequest += new ParcelDivideRequest(handleParcelDivideRequest);
- client.OnParcelJoinRequest += new ParcelJoinRequest(handleParcelJoinRequest);
- client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(handleParcelPropertiesUpdateRequest);
- client.OnParcelSelectObjects += new ParcelSelectObjects(handleParcelSelectObjectsRequest);
- client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(handleParcelObjectOwnersRequest);
- client.OnParcelAccessListRequest += new ParcelAccessListRequest(handleParcelAccessRequest);
- client.OnParcelAccessListUpdateRequest += new ParcelAccessListUpdateRequest(handleParcelAccessUpdateRequest);
- client.OnParcelAbandonRequest += new ParcelAbandonRequest(handleParcelAbandonRequest);
- client.OnParcelGodForceOwner += new ParcelGodForceOwner(handleParcelGodForceOwner);
- client.OnParcelReclaim += new ParcelReclaim(handleParcelReclaim);
- client.OnParcelInfoRequest += new ParcelInfoRequest(handleParcelInfo);
- client.OnParcelDwellRequest += new ParcelDwellRequest(handleParcelDwell);
- if (m_scene.Entities.ContainsKey(client.AgentId))
- {
- SendLandUpdate((ScenePresence)m_scene.Entities[client.AgentId], true);
- SendParcelOverlay(client);
- }
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- }
-
- public string Name
- {
- get { return "LandManagementModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return false; }
- }
-
- #endregion
-
- #region Parcel Add/Remove/Get/Create
-
- public void SetAllowedForcefulBans(bool forceful)
- {
- AllowedForcefulBans = forceful;
- }
-
- public void UpdateLandObject(int local_id, LandData data)
- {
- LandData newData = data.Copy();
- newData.LocalID = local_id;
-
- lock (m_landList)
- {
- if (m_landList.ContainsKey(local_id))
- {
- m_landList[local_id].landData = newData;
- m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]);
- }
- }
- }
-
- public bool AllowedForcefulBans
- {
- get { return m_allowedForcefulBans; }
- set { m_allowedForcefulBans = value; }
- }
-
- ///
- /// Resets the sim to the default land object (full sim piece of land owned by the default user)
- ///
- public void ResetSimLandObjects()
- {
- //Remove all the land objects in the sim and add a blank, full sim land object set to public
- lock (m_landList)
- {
- m_landList.Clear();
- m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
- m_landIDList.Initialize();
- }
-
- ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
-
- fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
- if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
- fullSimParcel.landData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
- else
- fullSimParcel.landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
- fullSimParcel.landData.ClaimDate = Util.UnixTimeSinceEpoch();
- AddLandObject(fullSimParcel);
- }
-
- public List AllParcels()
- {
- lock (m_landList)
- {
- return new List(m_landList.Values);
- }
- }
-
- public List ParcelsNearPoint(Vector3 position)
- {
- List parcelsNear = new List();
- for (int x = -4; x <= 4; x += 4)
- {
- for (int y = -4; y <= 4; y += 4)
- {
- ILandObject check = GetLandObject(position.X + x, position.Y + y);
- if (check != null)
- {
- if (!parcelsNear.Contains(check))
- {
- parcelsNear.Add(check);
- }
- }
- }
- }
-
- return parcelsNear;
- }
-
- public void SendYouAreBannedNotice(ScenePresence avatar)
- {
- if (AllowedForcefulBans)
- {
- avatar.ControllingClient.SendAlertMessage(
- "You are not allowed on this parcel because you are banned. Please go away.");
-
- avatar.PhysicsActor.Position =
- new PhysicsVector(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y,
- avatar.lastKnownAllowedPosition.Z);
- avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0);
- }
- else
- {
- avatar.ControllingClient.SendAlertMessage(
- "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim!");
- }
- }
-
- public void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, UUID regionID)
- {
- if (m_scene.RegionInfo.RegionID == regionID)
- {
- ILandObject parcelAvatarIsEntering;
- lock (m_landList)
- {
- parcelAvatarIsEntering = m_landList[localLandID];
- }
-
- if (parcelAvatarIsEntering != null)
- {
- if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
- {
- if (parcelAvatarIsEntering.isBannedFromLand(avatar.UUID))
- {
- SendYouAreBannedNotice(avatar);
- }
- else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID))
- {
- avatar.ControllingClient.SendAlertMessage(
- "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!).");
- }
- else
- {
- avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
- }
- }
- else
- {
- avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
- }
- }
- }
- }
-
- public void SendOutNearestBanLine(IClientAPI avatar)
- {
- List avatars = m_scene.GetAvatars();
- foreach (ScenePresence presence in avatars)
- {
- if (presence.UUID == avatar.AgentId)
- {
- List checkLandParcels = ParcelsNearPoint(presence.AbsolutePosition);
- foreach (ILandObject checkBan in checkLandParcels)
- {
- if (checkBan.isBannedFromLand(avatar.AgentId))
- {
- checkBan.sendLandProperties((int)ParcelStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar);
- return; //Only send one
- }
- if (checkBan.isRestrictedFromLand(avatar.AgentId))
- {
- checkBan.sendLandProperties((int)ParcelStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar);
- return; //Only send one
- }
- }
- return;
- }
- }
- }
-
- public void SendLandUpdate(ScenePresence avatar, bool force)
- {
- ILandObject over = GetLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
- (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
-
- if (over != null)
- {
- if (force)
- {
- if (!avatar.IsChildAgent)
- {
- over.sendLandUpdateToClient(avatar.ControllingClient);
- m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.LocalID,
- m_scene.RegionInfo.RegionID);
- }
- }
-
- if (avatar.currentParcelUUID != over.landData.GlobalID)
- {
- if (!avatar.IsChildAgent)
- {
- over.sendLandUpdateToClient(avatar.ControllingClient);
- avatar.currentParcelUUID = over.landData.GlobalID;
- m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.LocalID,
- m_scene.RegionInfo.RegionID);
- }
- }
- }
- }
-
- public void SendLandUpdate(ScenePresence avatar)
- {
- SendLandUpdate(avatar, false);
- }
-
- public void handleSignificantClientMovement(IClientAPI remote_client)
- {
- ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId);
-
- if (clientAvatar != null)
- {
- SendLandUpdate(clientAvatar);
- SendOutNearestBanLine(remote_client);
- ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
- if (parcel != null)
- {
- if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
- clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
- {
- handleAvatarChangingParcel(clientAvatar, parcel.landData.LocalID, m_scene.RegionInfo.RegionID);
- //They are going below the safety line!
- if (!parcel.isBannedFromLand(clientAvatar.UUID))
- {
- clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
- }
- }
- else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
- parcel.isBannedFromLand(clientAvatar.UUID))
- {
- SendYouAreBannedNotice(clientAvatar);
- }
- }
- }
- }
-
- public void handleAnyClientMovement(ScenePresence avatar)
- //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance.
- {
- ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
- if (over != null)
- {
- if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT)
- {
- avatar.lastKnownAllowedPosition =
- new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
- }
- }
- }
-
-
- public void handleParcelAccessRequest(UUID agentID, UUID sessionID, uint flags, int sequenceID,
- int landLocalID, IClientAPI remote_client)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(landLocalID, out land);
- }
-
- if (land != null)
- {
- m_landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client);
- }
- }
-
- public void handleParcelAccessUpdateRequest(UUID agentID, UUID sessionID, uint flags, int landLocalID,
- List entries,
- IClientAPI remote_client)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(landLocalID, out land);
- }
-
- if (land != null)
- {
- if (agentID == land.landData.OwnerID)
- {
- land.updateAccessList(flags, entries, remote_client);
- }
- }
- else
- {
- m_log.WarnFormat("[LAND]: Invalid local land ID {0}", landLocalID);
- }
- }
-
- ///
- /// Creates a basic Parcel object without an owner (a zeroed key)
- ///
- ///
- public ILandObject CreateBaseLand()
- {
- return new LandObject(UUID.Zero, false, m_scene);
- }
-
- ///
- /// Adds a land object to the stored list and adds them to the landIDList to what they own
- ///
- /// The land object being added
- public ILandObject AddLandObject(ILandObject land)
- {
- ILandObject new_land = land.Copy();
-
- lock (m_landList)
- {
- int newLandLocalID = ++m_lastLandLocalID;
- new_land.landData.LocalID = newLandLocalID;
-
- bool[,] landBitmap = new_land.getLandBitmap();
- for (int x = 0; x < 64; x++)
- {
- for (int y = 0; y < 64; y++)
- {
- if (landBitmap[x, y])
- {
- m_landIDList[x, y] = newLandLocalID;
- }
- }
- }
-
- m_landList.Add(newLandLocalID, new_land);
- }
-
- new_land.forceUpdateLandInfo();
- m_scene.EventManager.TriggerLandObjectAdded(new_land);
- return new_land;
- }
-
- ///
- /// Removes a land object from the list. Will not remove if local_id is still owning an area in landIDList
- ///
- /// Land.localID of the peice of land to remove.
- public void removeLandObject(int local_id)
- {
- lock (m_landList)
- {
- for (int x = 0; x < 64; x++)
- {
- for (int y = 0; y < 64; y++)
- {
- if (m_landIDList[x, y] == local_id)
- {
- m_log.WarnFormat("[LAND]: Not removing land object {0}; still being used at {1}, {2}",
- local_id, x, y);
- return;
- //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y);
- }
- }
- }
-
- m_scene.EventManager.TriggerLandObjectRemoved(m_landList[local_id].landData.GlobalID);
- m_landList.Remove(local_id);
- }
- }
-
- private void performFinalLandJoin(ILandObject master, ILandObject slave)
- {
- bool[,] landBitmapSlave = slave.getLandBitmap();
- lock (m_landList)
- {
- for (int x = 0; x < 64; x++)
- {
- for (int y = 0; y < 64; y++)
- {
- if (landBitmapSlave[x, y])
- {
- m_landIDList[x, y] = master.landData.LocalID;
- }
- }
- }
- }
-
- removeLandObject(slave.landData.LocalID);
- UpdateLandObject(master.landData.LocalID, master.landData);
- }
-
- public ILandObject GetLandObject(int parcelLocalID)
- {
- lock (m_landList)
- {
- if (m_landList.ContainsKey(parcelLocalID))
- {
- return m_landList[parcelLocalID];
- }
- }
- return null;
- }
-
- ///
- /// Get the land object at the specified point
- ///
- /// Value between 0 - 256 on the x axis of the point
- /// Value between 0 - 256 on the y axis of the point
- /// Land object at the point supplied
- public ILandObject GetLandObject(float x_float, float y_float)
- {
- int x;
- int y;
-
- try
- {
- x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0));
- y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / 4.0));
- }
- catch (OverflowException)
- {
- return null;
- }
-
- if (x >= 64 || y >= 64 || x < 0 || y < 0)
- {
- return null;
- }
- lock (m_landList)
- {
- // Corner case. If an autoreturn happens during sim startup
- // we will come here with the list uninitialized
- //
- if (m_landList.ContainsKey(m_landIDList[x, y]))
- return m_landList[m_landIDList[x, y]];
- return null;
- }
- }
-
- public ILandObject GetLandObject(int x, int y)
- {
- if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
- {
- // These exceptions here will cause a lot of complaints from the users specifically because
- // they happen every time at border crossings
- throw new Exception("Error: Parcel not found at point " + x + ", " + y);
- }
- lock (m_landIDList)
- {
- return m_landList[m_landIDList[x / 4, y / 4]];
- }
- }
-
- #endregion
-
- #region Parcel Modification
-
- public void ResetAllLandPrimCounts()
- {
- lock (m_landList)
- {
- foreach (LandObject p in m_landList.Values)
- {
- p.resetLandPrimCounts();
- }
- }
- }
-
- public void SetPrimsTainted()
- {
- m_landPrimCountTainted = true;
- }
-
- public bool IsLandPrimCountTainted()
- {
- return m_landPrimCountTainted;
- }
-
- public void AddPrimToLandPrimCounts(SceneObjectGroup obj)
- {
- Vector3 position = obj.AbsolutePosition;
- ILandObject landUnderPrim = GetLandObject(position.X, position.Y);
- if (landUnderPrim != null)
- {
- landUnderPrim.addPrimToCount(obj);
- }
- }
-
- public void RemovePrimFromLandPrimCounts(SceneObjectGroup obj)
- {
-
- lock (m_landList)
- {
- foreach (LandObject p in m_landList.Values)
- {
- p.removePrimFromCount(obj);
- }
- }
- }
-
- public void FinalizeLandPrimCountUpdate()
- {
- //Get Simwide prim count for owner
- Dictionary> landOwnersAndParcels = new Dictionary>();
- lock (m_landList)
- {
- foreach (LandObject p in m_landList.Values)
- {
- if (!landOwnersAndParcels.ContainsKey(p.landData.OwnerID))
- {
- List tempList = new List();
- tempList.Add(p);
- landOwnersAndParcels.Add(p.landData.OwnerID, tempList);
- }
- else
- {
- landOwnersAndParcels[p.landData.OwnerID].Add(p);
- }
- }
- }
-
- foreach (UUID owner in landOwnersAndParcels.Keys)
- {
- int simArea = 0;
- int simPrims = 0;
- foreach (LandObject p in landOwnersAndParcels[owner])
- {
- simArea += p.landData.Area;
- simPrims += p.landData.OwnerPrims + p.landData.OtherPrims + p.landData.GroupPrims +
- p.landData.SelectedPrims;
- }
-
- foreach (LandObject p in landOwnersAndParcels[owner])
- {
- p.landData.SimwideArea = simArea;
- p.landData.SimwidePrims = simPrims;
- }
- }
- }
-
- public void UpdateLandPrimCounts()
- {
- ResetAllLandPrimCounts();
- foreach (EntityBase obj in m_scene.Entities)
- {
- if (obj != null)
- {
- if ((obj is SceneObjectGroup) && !obj.IsDeleted && !((SceneObjectGroup) obj).IsAttachment)
- {
- m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj);
- }
- }
- }
- FinalizeLandPrimCountUpdate();
- m_landPrimCountTainted = false;
- }
-
- public void PerformParcelPrimCountUpdate()
- {
- ResetAllLandPrimCounts();
- m_scene.EventManager.TriggerParcelPrimCountUpdate();
- FinalizeLandPrimCountUpdate();
- m_landPrimCountTainted = false;
- }
-
- ///
- /// Subdivides a piece of land
- ///
- /// West Point
- /// South Point
- /// East Point
- /// North Point
- /// UUID of user who is trying to subdivide
- /// Returns true if successful
- private void subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
- {
- //First, lets loop through the points and make sure they are all in the same peice of land
- //Get the land object at start
-
- ILandObject startLandObject = GetLandObject(start_x, start_y);
-
- if (startLandObject == null) return;
-
- //Loop through the points
- try
- {
- int totalX = end_x - start_x;
- int totalY = end_y - start_y;
- for (int y = 0; y < totalY; y++)
- {
- for (int x = 0; x < totalX; x++)
- {
- ILandObject tempLandObject = GetLandObject(start_x + x, start_y + y);
- if (tempLandObject == null) return;
- if (tempLandObject != startLandObject) return;
- }
- }
- }
- catch (Exception)
- {
- return;
- }
-
- //If we are still here, then they are subdividing within one piece of land
- //Check owner
- if (!m_scene.Permissions.CanEditParcel(attempting_user_id, startLandObject))
- {
- return;
- }
-
- //Lets create a new land object with bitmap activated at that point (keeping the old land objects info)
- ILandObject newLand = startLandObject.Copy();
- newLand.landData.Name = "Subdivision of " + newLand.landData.Name;
- newLand.landData.GlobalID = UUID.Random();
-
- newLand.setLandBitmap(newLand.getSquareLandBitmap(start_x, start_y, end_x, end_y));
-
- //Now, lets set the subdivision area of the original to false
- int startLandObjectIndex = startLandObject.landData.LocalID;
- lock (m_landList)
- {
- m_landList[startLandObjectIndex].setLandBitmap(
- newLand.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false));
- m_landList[startLandObjectIndex].forceUpdateLandInfo();
- }
-
- SetPrimsTainted();
-
- //Now add the new land object
- ILandObject result = AddLandObject(newLand);
- UpdateLandObject(startLandObject.landData.LocalID, startLandObject.landData);
- result.sendLandUpdateToAvatarsOverMe();
- }
-
- ///
- /// Join 2 land objects together
- ///
- /// x value in first piece of land
- /// y value in first piece of land
- /// x value in second peice of land
- /// y value in second peice of land
- /// UUID of the avatar trying to join the land objects
- /// Returns true if successful
- private void join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
- {
- end_x -= 4;
- end_y -= 4;
-
- List selectedLandObjects = new List();
- int stepYSelected;
- for (stepYSelected = start_y; stepYSelected <= end_y; stepYSelected += 4)
- {
- int stepXSelected;
- for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4)
- {
- ILandObject p = GetLandObject(stepXSelected, stepYSelected);
-
- if (p != null)
- {
- if (!selectedLandObjects.Contains(p))
- {
- selectedLandObjects.Add(p);
- }
- }
- }
- }
- ILandObject masterLandObject = selectedLandObjects[0];
- selectedLandObjects.RemoveAt(0);
-
- if (selectedLandObjects.Count < 1)
- {
- return;
- }
- if (!m_scene.Permissions.CanEditParcel(attempting_user_id, masterLandObject))
- {
- return;
- }
- foreach (ILandObject p in selectedLandObjects)
- {
- if (p.landData.OwnerID != masterLandObject.landData.OwnerID)
- {
- return;
- }
- }
-
- lock (m_landList)
- {
- foreach (ILandObject slaveLandObject in selectedLandObjects)
- {
- m_landList[masterLandObject.landData.LocalID].setLandBitmap(
- slaveLandObject.mergeLandBitmaps(masterLandObject.getLandBitmap(), slaveLandObject.getLandBitmap()));
- performFinalLandJoin(masterLandObject, slaveLandObject);
- }
- }
- SetPrimsTainted();
-
- masterLandObject.sendLandUpdateToAvatarsOverMe();
- }
-
- #endregion
-
- #region Parcel Updating
-
- ///
- /// Where we send the ParcelOverlay packet to the client
- ///
- /// The object representing the client
- public void SendParcelOverlay(IClientAPI remote_client)
- {
- const int LAND_BLOCKS_PER_PACKET = 1024;
-
- byte[] byteArray = new byte[LAND_BLOCKS_PER_PACKET];
- int byteArrayCount = 0;
- int sequenceID = 0;
-
- for (int y = 0; y < 64; y++)
- {
- for (int x = 0; x < 64; x++)
- {
- byte tempByte = 0; //This represents the byte for the current 4x4
-
- ILandObject currentParcelBlock = GetLandObject(x * 4, y * 4);
-
- if (currentParcelBlock != null)
- {
- if (currentParcelBlock.landData.OwnerID == remote_client.AgentId)
- {
- //Owner Flag
- tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
- }
- else if (currentParcelBlock.landData.SalePrice > 0 &&
- (currentParcelBlock.landData.AuthBuyerID == UUID.Zero ||
- currentParcelBlock.landData.AuthBuyerID == remote_client.AgentId))
- {
- //Sale Flag
- tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_IS_FOR_SALE);
- }
- else if (currentParcelBlock.landData.OwnerID == UUID.Zero)
- {
- //Public Flag
- tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_PUBLIC);
- }
- else
- {
- //Other Flag
- tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_OTHER);
- }
-
- //Now for border control
-
- ILandObject westParcel = null;
- ILandObject southParcel = null;
- if (x > 0)
- {
- westParcel = GetLandObject((x - 1) * 4, y * 4);
- }
- if (y > 0)
- {
- southParcel = GetLandObject(x * 4, (y - 1) * 4);
- }
-
- if (x == 0)
- {
- tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_WEST);
- }
- else if (westParcel != null && westParcel != currentParcelBlock)
- {
- tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_WEST);
- }
-
- if (y == 0)
- {
- tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH);
- }
- else if (southParcel != null && southParcel != currentParcelBlock)
- {
- tempByte = Convert.ToByte(tempByte | LandChannel.LAND_FLAG_PROPERTY_BORDER_SOUTH);
- }
-
- byteArray[byteArrayCount] = tempByte;
- byteArrayCount++;
- if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
- {
- remote_client.SendLandParcelOverlay(byteArray, sequenceID);
- byteArrayCount = 0;
- sequenceID++;
- byteArray = new byte[LAND_BLOCKS_PER_PACKET];
- }
- }
- }
- }
- }
-
- public void handleParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id,
- bool snap_selection, IClientAPI remote_client)
- {
- //Get the land objects within the bounds
- List temp = new List();
- int inc_x = end_x - start_x;
- int inc_y = end_y - start_y;
- for (int x = 0; x < inc_x; x++)
- {
- for (int y = 0; y < inc_y; y++)
- {
- ILandObject currentParcel = GetLandObject(start_x + x, start_y + y);
-
- if (currentParcel != null)
- {
- if (!temp.Contains(currentParcel))
- {
- currentParcel.forceUpdateLandInfo();
- temp.Add(currentParcel);
- }
- }
- }
- }
-
- int requestResult = LandChannel.LAND_RESULT_SINGLE;
- if (temp.Count > 1)
- {
- requestResult = LandChannel.LAND_RESULT_MULTIPLE;
- }
-
- for (int i = 0; i < temp.Count; i++)
- {
- temp[i].sendLandProperties(sequence_id, snap_selection, requestResult, remote_client);
- }
-
- SendParcelOverlay(remote_client);
- }
-
- public void handleParcelPropertiesUpdateRequest(LandUpdateArgs args, int localID, IClientAPI remote_client)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(localID, out land);
- }
-
- if (land != null) land.updateLandProperties(args, remote_client);
- }
-
- public void handleParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
- {
- subdivide(west, south, east, north, remote_client.AgentId);
- }
-
- public void handleParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client)
- {
- join(west, south, east, north, remote_client.AgentId);
- }
-
- public void handleParcelSelectObjectsRequest(int local_id, int request_type, List returnIDs, IClientAPI remote_client)
- {
- m_landList[local_id].sendForceObjectSelect(local_id, request_type, returnIDs, remote_client);
- }
-
- public void handleParcelObjectOwnersRequest(int local_id, IClientAPI remote_client)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(local_id, out land);
- }
-
- if (land != null)
- {
- m_landList[local_id].sendLandObjectOwners(remote_client);
- }
- else
- {
- m_log.WarnFormat("[PARCEL]: Invalid land object {0} passed for parcel object owner request", local_id);
- }
- }
-
- public void handleParcelGodForceOwner(int local_id, UUID ownerID, IClientAPI remote_client)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(local_id, out land);
- }
-
- if (land != null)
- {
- if (m_scene.Permissions.IsGod(remote_client.AgentId))
- {
- land.landData.OwnerID = ownerID;
-
- m_scene.Broadcast(SendParcelOverlay);
- land.sendLandUpdateToClient(remote_client);
- }
- }
- }
-
- public void handleParcelAbandonRequest(int local_id, IClientAPI remote_client)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(local_id, out land);
- }
-
- if (land != null)
- {
- if (m_scene.Permissions.CanAbandonParcel(remote_client.AgentId, land))
- {
- if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
- land.landData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
- else
- land.landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
- m_scene.Broadcast(SendParcelOverlay);
- land.sendLandUpdateToClient(remote_client);
- }
- }
- }
-
- public void handleParcelReclaim(int local_id, IClientAPI remote_client)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(local_id, out land);
- }
-
- if (land != null)
- {
- if (m_scene.Permissions.CanReclaimParcel(remote_client.AgentId, land))
- {
- if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
- land.landData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
- else
- land.landData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
- land.landData.ClaimDate = Util.UnixTimeSinceEpoch();
- m_scene.Broadcast(SendParcelOverlay);
- land.sendLandUpdateToClient(remote_client);
- }
- }
- }
- #endregion
-
- // If the economy has been validated by the economy module,
- // and land has been validated as well, this method transfers
- // the land ownership
-
- public void handleLandBuyRequest(Object o, EventManager.LandBuyArgs e)
- {
- if (e.economyValidated && e.landValidated)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(e.parcelLocalID, out land);
- }
-
- if (land != null)
- {
- land.updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea);
- }
- }
- }
-
- // After receiving a land buy packet, first the data needs to
- // be validated. This method validates the right to buy the
- // parcel
-
- public void handleLandValidationRequest(Object o, EventManager.LandBuyArgs e)
- {
- if (e.landValidated == false)
- {
- ILandObject lob = null;
- lock (m_landList)
- {
- m_landList.TryGetValue(e.parcelLocalID, out lob);
- }
-
- if (lob != null)
- {
- UUID AuthorizedID = lob.landData.AuthBuyerID;
- int saleprice = lob.landData.SalePrice;
- UUID pOwnerID = lob.landData.OwnerID;
-
- bool landforsale = ((lob.landData.Flags &
- (uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0);
- if ((AuthorizedID == UUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale)
- {
- // TODO I don't think we have to lock it here, no?
- //lock (e)
- //{
- e.parcelOwnerID = pOwnerID;
- e.landValidated = true;
- //}
- }
- }
- }
- }
-
- #region Land Object From Storage Functions
-
- public void IncomingLandObjectsFromStorage(List data)
- {
- for (int i = 0; i < data.Count; i++)
- {
- IncomingLandObjectFromStorage(data[i]);
- }
- }
-
- public void IncomingLandObjectFromStorage(LandData data)
- {
- ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
- new_land.landData = data.Copy();
- new_land.setLandBitmapFromByteArray();
- AddLandObject(new_land);
- }
-
- public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
- {
- ILandObject selectedParcel = null;
- lock (m_landList)
- {
- m_landList.TryGetValue(localID, out selectedParcel);
- }
-
- if (selectedParcel == null) return;
-
- selectedParcel.returnLandObjects(returnType, agentIDs, taskIDs, remoteClient);
- }
-
- public void NoLandDataFromStorage()
- {
- ResetSimLandObjects();
- }
-
- #endregion
-
- public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
- {
- lock (m_landList)
- {
- foreach (LandObject obj in m_landList.Values)
- {
- obj.setParcelObjectMaxOverride(overrideDel);
- }
- }
- }
-
- public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
- {
- }
-
- #region CAPS handler
-
- private void OnRegisterCaps(UUID agentID, Caps caps)
- {
- string capsBase = "/CAPS/" + caps.CapsObjectPath;
- caps.RegisterHandler("RemoteParcelRequest",
- new RestStreamHandler("POST", capsBase + remoteParcelRequestPath,
- delegate(string request, string path, string param,
- OSHttpRequest httpRequest, OSHttpResponse httpResponse)
- {
- return RemoteParcelRequest(request, path, param, agentID, caps);
- }));
- }
-
- // we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the
- // "real" parcelID, because we wouldn't be able to map that to the region the parcel belongs to.
- // So, we create a "fake" parcelID by using the regionHandle (64 bit), and the local (integer) x
- // and y coordinate (each 8 bit), encoded in a UUID (128 bit).
- //
- // Request format:
- //
- //
- //
- private string RemoteParcelRequest(string request, string path, string param, UUID agentID, Caps caps)
- {
- UUID parcelID = UUID.Zero;
- try
- {
- Hashtable hash = new Hashtable();
- hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
- if (hash.ContainsKey("region_id") && hash.ContainsKey("location"))
- {
- UUID regionID = (UUID)hash["region_id"];
- ArrayList list = (ArrayList)hash["location"];
- uint x = (uint)(double)list[0];
- uint y = (uint)(double)list[1];
- if (hash.ContainsKey("region_handle"))
- {
- // if you do a "About Landmark" on a landmark a second time, the viewer sends the
- // region_handle it got earlier via RegionHandleRequest
- ulong regionHandle = Util.BytesToUInt64Big((byte[])hash["region_handle"]);
- parcelID = Util.BuildFakeParcelID(regionHandle, x, y);
- }
- else if (regionID == m_scene.RegionInfo.RegionID)
- {
- // a parcel request for a local parcel => no need to query the grid
- parcelID = Util.BuildFakeParcelID(m_scene.RegionInfo.RegionHandle, x, y);
- }
- else
- {
- // a parcel request for a parcel in another region. Ask the grid about the region
- RegionInfo info = m_scene.CommsManager.GridService.RequestNeighbourInfo(regionID);
- if (info != null)
- parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y);
- }
- }
- }
- catch (LLSD.LLSDParseException e)
- {
- m_log.ErrorFormat("[LAND] Fetch error: {0}", e.Message);
- m_log.ErrorFormat("[LAND] ... in request {0}", request);
- }
- catch(InvalidCastException)
- {
- m_log.ErrorFormat("[LAND] Wrong type in request {0}", request);
- }
-
- LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse();
- response.parcel_id = parcelID;
- m_log.DebugFormat("[LAND] got parcelID {0}", parcelID);
-
- return LLSDHelpers.SerialiseLLSDReply(response);
- }
-
- #endregion
-
- private void handleParcelDwell(int localID, IClientAPI remoteClient)
- {
- ILandObject selectedParcel = null;
- lock (m_landList)
- {
- if (!m_landList.TryGetValue(localID, out selectedParcel))
- return;
- }
-
- remoteClient.SendParcelDwellReply(localID, selectedParcel.landData.GlobalID, selectedParcel.landData.Dwell);
- }
-
- private void handleParcelInfo(IClientAPI remoteClient, UUID parcelID)
- {
- if (parcelID == UUID.Zero)
- return;
-
- ExtendedLandData data = (ExtendedLandData)parcelInfoCache.Get(parcelID, delegate(UUID parcel) {
- // assume we've got the parcelID we just computed in RemoteParcelRequest
- ExtendedLandData extLandData = new ExtendedLandData();
- Util.ParseFakeParcelID(parcel, out extLandData.regionHandle, out extLandData.x, out extLandData.y);
- m_log.DebugFormat("[LAND] got parcelinfo request for regionHandle {0}, x/y {1}/{2}",
- extLandData.regionHandle, extLandData.x, extLandData.y);
-
- // for this region or for somewhere else?
- if (extLandData.regionHandle == m_scene.RegionInfo.RegionHandle)
- {
- extLandData.landData = this.GetLandObject(extLandData.x, extLandData.y).landData;
- }
- else
- {
- extLandData.landData = m_scene.CommsManager.GridService.RequestLandData(extLandData.regionHandle,
- extLandData.x,
- extLandData.y);
- if (extLandData.landData == null)
- {
- // we didn't find the region/land => don't cache
- return null;
- }
- }
- return extLandData;
- });
-
- if (data != null) // if we found some data, send it
- {
- RegionInfo info;
- if (data.regionHandle == m_scene.RegionInfo.RegionHandle)
- {
- info = m_scene.RegionInfo;
- }
- else
- {
- // most likely still cached from building the extLandData entry
- info = m_scene.CommsManager.GridService.RequestNeighbourInfo(data.regionHandle);
- }
- // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
- m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...",
- data.landData.Name, data.regionHandle);
- remoteClient.SendParcelInfo(info, data.landData, parcelID, data.x, data.y);
- }
- else
- m_log.Debug("[LAND] got no parcelinfo; not sending");
- }
-
- public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
- {
- ILandObject land;
- lock (m_landList)
- {
- m_landList.TryGetValue(localID, out land);
- }
-
- if (land == null) return;
-
- if (!m_scene.Permissions.CanEditParcel(remoteClient.AgentId, land))
- return;
-
- land.landData.OtherCleanTime = otherCleanTime;
-
- UpdateLandObject(localID, land.landData);
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
deleted file mode 100644
index b5f7225..0000000
--- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
+++ /dev/null
@@ -1,930 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.Reflection;
-using OpenMetaverse;
-using log4net;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Land
-{
- ///
- /// Keeps track of a specific piece of land's information
- ///
- public class LandObject : ILandObject
- {
- #region Member Variables
-
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private bool[,] m_landBitmap = new bool[64,64];
-
- protected LandData m_landData = new LandData();
- protected Scene m_scene;
- protected List primsOverMe = new List();
-
- public bool[,] landBitmap
- {
- get { return m_landBitmap; }
- set { m_landBitmap = value; }
- }
-
- #endregion
-
- #region ILandObject Members
-
- public LandData landData
- {
- get { return m_landData; }
-
- set { m_landData = value; }
- }
-
- public UUID regionUUID
- {
- get { return m_scene.RegionInfo.RegionID; }
- }
-
- #region Constructors
-
- public LandObject(UUID owner_id, bool is_group_owned, Scene scene)
- {
- m_scene = scene;
- landData.OwnerID = owner_id;
- landData.IsGroupOwned = is_group_owned;
- }
-
- #endregion
-
- #region Member Functions
-
- #region General Functions
-
- ///
- /// Checks to see if this land object contains a point
- ///
- ///
- ///
- /// Returns true if the piece of land contains the specified point
- public bool containsPoint(int x, int y)
- {
- if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
- {
- return (landBitmap[x / 4, y / 4] == true);
- }
- else
- {
- return false;
- }
- }
-
- public ILandObject Copy()
- {
- ILandObject newLand = new LandObject(landData.OwnerID, landData.IsGroupOwned, m_scene);
-
- //Place all new variables here!
- newLand.landBitmap = (bool[,]) (landBitmap.Clone());
- newLand.landData = landData.Copy();
-
- return newLand;
- }
-
-
- static overrideParcelMaxPrimCountDelegate overrideParcelMaxPrimCount;
- static overrideSimulatorMaxPrimCountDelegate overrideSimulatorMaxPrimCount;
-
- public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
- {
- overrideParcelMaxPrimCount = overrideDel;
- }
- public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
- {
- overrideSimulatorMaxPrimCount = overrideDel;
- }
-
- public int getParcelMaxPrimCount(ILandObject thisObject)
- {
- if (overrideParcelMaxPrimCount != null)
- {
- return overrideParcelMaxPrimCount(thisObject);
- }
- else
- {
- //Normal Calculations
- return Convert.ToInt32(
- Math.Round((Convert.ToDecimal(landData.Area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity *
- Convert.ToDecimal(m_scene.RegionInfo.RegionSettings.ObjectBonus))); ;
- }
- }
- public int getSimulatorMaxPrimCount(ILandObject thisObject)
- {
- if (overrideSimulatorMaxPrimCount != null)
- {
- return overrideSimulatorMaxPrimCount(thisObject);
- }
- else
- {
- //Normal Calculations
- return m_scene.objectCapacity;
- }
- }
- #endregion
-
- #region Packet Request Handling
-
- public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client)
- {
- IEstateModule estateModule = m_scene.RequestModuleInterface();
- uint regionFlags = 336723974 & ~((uint)(RegionFlags.AllowLandmark | RegionFlags.AllowSetHome));
- if (estateModule != null)
- regionFlags = estateModule.GetRegionFlags();
-
- // In a perfect world, this would have worked.
- //
-// if ((landData.Flags & (uint)Parcel.ParcelFlags.AllowLandmark) != 0)
-// regionFlags |= (uint)RegionFlags.AllowLandmark;
-// if (landData.OwnerID == remote_client.AgentId)
-// regionFlags |= (uint)RegionFlags.AllowSetHome;
- remote_client.SendLandProperties(sequence_id,
- snap_selection, request_result, landData,
- (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
- getParcelMaxPrimCount(this),
- getSimulatorMaxPrimCount(this), regionFlags);
- }
-
- public void updateLandProperties(LandUpdateArgs args, IClientAPI remote_client)
- {
- if (m_scene.Permissions.CanEditParcel(remote_client.AgentId,this))
- {
- //Needs later group support
- LandData newData = landData.Copy();
-
- if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice)
- {
- if (m_scene.Permissions.CanSellParcel(remote_client.AgentId, this))
- {
- newData.AuthBuyerID = args.AuthBuyerID;
- newData.SalePrice = args.SalePrice;
- }
- }
- newData.Category = args.Category;
- newData.Description = args.Desc;
- newData.GroupID = args.GroupID;
- newData.LandingType = args.LandingType;
- newData.MediaAutoScale = args.MediaAutoScale;
- newData.MediaID = args.MediaID;
- newData.MediaURL = args.MediaURL;
- newData.MusicURL = args.MusicURL;
- newData.Name = args.Name;
- newData.Flags = args.ParcelFlags;
- newData.PassHours = args.PassHours;
- newData.PassPrice = args.PassPrice;
- newData.SnapshotID = args.SnapshotID;
- newData.UserLocation = args.UserLocation;
- newData.UserLookAt = args.UserLookAt;
-
- m_scene.LandChannel.UpdateLandObject(landData.LocalID, newData);
-
- sendLandUpdateToAvatarsOverMe();
- }
- }
-
- public void updateLandSold(UUID avatarID, UUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
- {
- LandData newData = landData.Copy();
- newData.OwnerID = avatarID;
- newData.GroupID = groupID;
- newData.IsGroupOwned = groupOwned;
- //newData.auctionID = AuctionID;
- newData.ClaimDate = Util.UnixTimeSinceEpoch();
- newData.ClaimPrice = claimprice;
- newData.SalePrice = 0;
- newData.AuthBuyerID = UUID.Zero;
- newData.Flags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
- m_scene.LandChannel.UpdateLandObject(landData.LocalID, newData);
-
- sendLandUpdateToAvatarsOverMe();
- }
-
- public bool isEitherBannedOrRestricted(UUID avatar)
- {
- if (isBannedFromLand(avatar))
- {
- return true;
- }
- else if (isRestrictedFromLand(avatar))
- {
- return true;
- }
- return false;
- }
-
- public bool isBannedFromLand(UUID avatar)
- {
- if ((landData.Flags & (uint) Parcel.ParcelFlags.UseBanList) > 0)
- {
- ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
- entry.AgentID = avatar;
- entry.Flags = AccessList.Ban;
- entry.Time = new DateTime();
- if (landData.ParcelAccessList.Contains(entry))
- {
- //They are banned, so lets send them a notice about this parcel
- return true;
- }
- }
- return false;
- }
-
- public bool isRestrictedFromLand(UUID avatar)
- {
- if ((landData.Flags & (uint) Parcel.ParcelFlags.UseAccessList) > 0)
- {
- ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
- entry.AgentID = avatar;
- entry.Flags = AccessList.Access;
- entry.Time = new DateTime();
- if (!landData.ParcelAccessList.Contains(entry))
- {
- //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
- return true;
- }
- }
- return false;
- }
-
- public void sendLandUpdateToClient(IClientAPI remote_client)
- {
- sendLandProperties(0, false, 0, remote_client);
- }
-
- public void sendLandUpdateToAvatarsOverMe()
- {
- List avatars = m_scene.GetAvatars();
- ILandObject over = null;
- for (int i = 0; i < avatars.Count; i++)
- {
- try
- {
- over =
- m_scene.LandChannel.GetLandObject(Util.Clamp((int)Math.Round(avatars[i].AbsolutePosition.X), 0, 255),
- Util.Clamp((int)Math.Round(avatars[i].AbsolutePosition.Y), 0, 255));
- }
- catch (Exception)
- {
- m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " +
- Math.Round(avatars[i].AbsolutePosition.Y));
- }
-
- if (over != null)
- {
- if (over.landData.LocalID == landData.LocalID)
- {
- if (((over.landData.Flags & (uint)Parcel.ParcelFlags.AllowDamage) != 0) && m_scene.RegionInfo.RegionSettings.AllowDamage)
- avatars[i].Invulnerable = false;
- else
- avatars[i].Invulnerable = true;
-
- sendLandUpdateToClient(avatars[i].ControllingClient);
- }
- }
- }
- }
-
- #endregion
-
- #region AccessList Functions
-
- public List createAccessListArrayByFlag(AccessList flag)
- {
- List list = new List();
- foreach (ParcelManager.ParcelAccessEntry entry in landData.ParcelAccessList)
- {
- if (entry.Flags == flag)
- {
- list.Add(entry.AgentID);
- }
- }
- if (list.Count == 0)
- {
- list.Add(UUID.Zero);
- }
-
- return list;
- }
-
- public void sendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID,
- IClientAPI remote_client)
- {
-
- if (flags == (uint) AccessList.Access || flags == (uint) AccessList.Both)
- {
- List avatars = createAccessListArrayByFlag(AccessList.Access);
- remote_client.SendLandAccessListData(avatars,(uint) AccessList.Access,landData.LocalID);
- }
-
- if (flags == (uint) AccessList.Ban || flags == (uint) AccessList.Both)
- {
- List avatars = createAccessListArrayByFlag(AccessList.Ban);
- remote_client.SendLandAccessListData(avatars, (uint)AccessList.Ban, landData.LocalID);
- }
- }
-
- public void updateAccessList(uint flags, List entries, IClientAPI remote_client)
- {
- LandData newData = landData.Copy();
-
- if (entries.Count == 1 && entries[0].AgentID == UUID.Zero)
- {
- entries.Clear();
- }
-
- List toRemove = new List();
- foreach (ParcelManager.ParcelAccessEntry entry in newData.ParcelAccessList)
- {
- if (entry.Flags == (AccessList)flags)
- {
- toRemove.Add(entry);
- }
- }
-
- foreach (ParcelManager.ParcelAccessEntry entry in toRemove)
- {
- newData.ParcelAccessList.Remove(entry);
- }
- foreach (ParcelManager.ParcelAccessEntry entry in entries)
- {
- ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry();
- temp.AgentID = entry.AgentID;
- temp.Time = new DateTime(); //Pointless? Yes.
- temp.Flags = (AccessList)flags;
-
- if (!newData.ParcelAccessList.Contains(temp))
- {
- newData.ParcelAccessList.Add(temp);
- }
- }
-
- m_scene.LandChannel.UpdateLandObject(landData.LocalID, newData);
- }
-
- #endregion
-
- #region Update Functions
-
- public void updateLandBitmapByteArray()
- {
- landData.Bitmap = convertLandBitmapToBytes();
- }
-
- ///
- /// Update all settings in land such as area, bitmap byte array, etc
- ///
- public void forceUpdateLandInfo()
- {
- updateAABBAndAreaValues();
- updateLandBitmapByteArray();
- }
-
- public void setLandBitmapFromByteArray()
- {
- landBitmap = convertBytesToLandBitmap();
- }
-
- ///
- /// Updates the AABBMin and AABBMax values after area/shape modification of the land object
- ///
- private void updateAABBAndAreaValues()
- {
- int min_x = 64;
- int min_y = 64;
- int max_x = 0;
- int max_y = 0;
- int tempArea = 0;
- int x, y;
- for (x = 0; x < 64; x++)
- {
- for (y = 0; y < 64; y++)
- {
- if (landBitmap[x, y] == true)
- {
- if (min_x > x) min_x = x;
- if (min_y > y) min_y = y;
- if (max_x < x) max_x = x;
- if (max_y < y) max_y = y;
- tempArea += 16; //16sqm peice of land
- }
- }
- }
- int tx = min_x * 4;
- if (tx > 255)
- tx = 255;
- int ty = min_y * 4;
- if (ty > 255)
- ty = 255;
- landData.AABBMin =
- new Vector3((float) (min_x * 4), (float) (min_y * 4),
- (float) m_scene.Heightmap[tx, ty]);
-
- tx = max_x * 4;
- if (tx > 255)
- tx = 255;
- ty = max_y * 4;
- if (ty > 255)
- ty = 255;
- landData.AABBMax =
- new Vector3((float) (max_x * 4), (float) (max_y * 4),
- (float) m_scene.Heightmap[tx, ty]);
- landData.Area = tempArea;
- }
-
- #endregion
-
- #region Land Bitmap Functions
-
- ///
- /// Sets the land's bitmap manually
- ///
- /// 64x64 block representing where this land is on a map
- public void setLandBitmap(bool[,] bitmap)
- {
- if (bitmap.GetLength(0) != 64 || bitmap.GetLength(1) != 64 || bitmap.Rank != 2)
- {
- //Throw an exception - The bitmap is not 64x64
- //throw new Exception("Error: Invalid Parcel Bitmap");
- }
- else
- {
- //Valid: Lets set it
- landBitmap = bitmap;
- forceUpdateLandInfo();
- }
- }
-
- ///
- /// Gets the land's bitmap manually
- ///
- ///
- public bool[,] getLandBitmap()
- {
- return landBitmap;
- }
-
- ///
- /// Full sim land object creation
- ///
- ///
- public bool[,] basicFullRegionLandBitmap()
- {
- return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize);
- }
-
- ///
- /// Used to modify the bitmap between the x and y points. Points use 64 scale
- ///
- ///
- ///
- ///
- ///
- ///
- public bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y)
- {
- bool[,] tempBitmap = new bool[64,64];
- tempBitmap.Initialize();
-
- tempBitmap = modifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true);
- return tempBitmap;
- }
-
- ///
- /// Change a land bitmap at within a square and set those points to a specific value
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y,
- bool set_value)
- {
- if (land_bitmap.GetLength(0) != 64 || land_bitmap.GetLength(1) != 64 || land_bitmap.Rank != 2)
- {
- //Throw an exception - The bitmap is not 64x64
- //throw new Exception("Error: Invalid Parcel Bitmap in modifyLandBitmapSquare()");
- }
-
- int x, y;
- for (y = 0; y < 64; y++)
- {
- for (x = 0; x < 64; x++)
- {
- if (x >= start_x / 4 && x < end_x / 4
- && y >= start_y / 4 && y < end_y / 4)
- {
- land_bitmap[x, y] = set_value;
- }
- }
- }
- return land_bitmap;
- }
-
- ///
- /// Join the true values of 2 bitmaps together
- ///
- ///
- ///
- ///
- public bool[,] mergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add)
- {
- if (bitmap_base.GetLength(0) != 64 || bitmap_base.GetLength(1) != 64 || bitmap_base.Rank != 2)
- {
- //Throw an exception - The bitmap is not 64x64
- throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_base in mergeLandBitmaps");
- }
- if (bitmap_add.GetLength(0) != 64 || bitmap_add.GetLength(1) != 64 || bitmap_add.Rank != 2)
- {
- //Throw an exception - The bitmap is not 64x64
- throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps");
- }
-
- int x, y;
- for (y = 0; y < 64; y++)
- {
- for (x = 0; x < 64; x++)
- {
- if (bitmap_add[x, y])
- {
- bitmap_base[x, y] = true;
- }
- }
- }
- return bitmap_base;
- }
-
- ///
- /// Converts the land bitmap to a packet friendly byte array
- ///
- ///
- private byte[] convertLandBitmapToBytes()
- {
- byte[] tempConvertArr = new byte[512];
- byte tempByte = 0;
- int x, y, i, byteNum = 0;
- i = 0;
- for (y = 0; y < 64; y++)
- {
- for (x = 0; x < 64; x++)
- {
- tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8));
- if (i % 8 == 0)
- {
- tempConvertArr[byteNum] = tempByte;
- tempByte = (byte) 0;
- i = 0;
- byteNum++;
- }
- }
- }
- return tempConvertArr;
- }
-
- private bool[,] convertBytesToLandBitmap()
- {
- bool[,] tempConvertMap = new bool[64,64];
- tempConvertMap.Initialize();
- byte tempByte = 0;
- int x = 0, y = 0, i = 0, bitNum = 0;
- for (i = 0; i < 512; i++)
- {
- tempByte = landData.Bitmap[i];
- for (bitNum = 0; bitNum < 8; bitNum++)
- {
- bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
- tempConvertMap[x, y] = bit;
- x++;
- if (x > 63)
- {
- x = 0;
- y++;
- }
- }
- }
- return tempConvertMap;
- }
-
- #endregion
-
- #region Object Select and Object Owner Listing
-
- public void sendForceObjectSelect(int local_id, int request_type, List returnIDs, IClientAPI remote_client)
- {
- if (m_scene.Permissions.CanEditParcel(remote_client.AgentId, this))
- {
- List resultLocalIDs = new List();
- try
- {
- lock (primsOverMe)
- {
- foreach (SceneObjectGroup obj in primsOverMe)
- {
- if (obj.LocalId > 0)
- {
- if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == landData.OwnerID)
- {
- resultLocalIDs.Add(obj.LocalId);
- }
- else if (request_type == LandChannel.LAND_SELECT_OBJECTS_GROUP && obj.GroupID == landData.GroupID && landData.GroupID != UUID.Zero)
- {
- resultLocalIDs.Add(obj.LocalId);
- }
- else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER &&
- obj.OwnerID != remote_client.AgentId)
- {
- resultLocalIDs.Add(obj.LocalId);
- }
- else if (request_type == (int)ObjectReturnType.List && returnIDs.Contains(obj.OwnerID))
- {
- resultLocalIDs.Add(obj.LocalId);
- }
- }
- }
- }
- } catch (InvalidOperationException)
- {
- m_log.Error("[LAND]: Unable to force select the parcel objects. Arr.");
- }
-
- remote_client.SendForceClientSelectObjects(resultLocalIDs);
- }
- }
-
- ///
- /// Notify the parcel owner each avatar that owns prims situated on their land. This notification includes
- /// aggreagete details such as the number of prims.
- ///
- ///
- ///
- /// A
- ///
- public void sendLandObjectOwners(IClientAPI remote_client)
- {
- if (m_scene.Permissions.CanEditParcel(remote_client.AgentId, this))
- {
- Dictionary primCount = new Dictionary();
-
- lock (primsOverMe)
- {
- try
- {
-
- foreach (SceneObjectGroup obj in primsOverMe)
- {
- try
- {
- if (!primCount.ContainsKey(obj.OwnerID))
- {
- primCount.Add(obj.OwnerID, 0);
- }
- }
- catch (NullReferenceException)
- {
- m_log.Info("[LAND]: " + "Got Null Reference when searching land owners from the parcel panel");
- }
- try
- {
- primCount[obj.OwnerID] += obj.PrimCount;
- }
- catch (KeyNotFoundException)
- {
- m_log.Error("[LAND]: Unable to match a prim with it's owner.");
- }
- }
- }
- catch (InvalidOperationException)
- {
- m_log.Error("[LAND]: Unable to Enumerate Land object arr.");
- }
- }
-
- remote_client.SendLandObjectOwners(primCount);
- }
- }
-
- public Dictionary getLandObjectOwners()
- {
- Dictionary ownersAndCount = new Dictionary();
- lock (primsOverMe)
- {
- try
- {
-
- foreach (SceneObjectGroup obj in primsOverMe)
- {
- if (!ownersAndCount.ContainsKey(obj.OwnerID))
- {
- ownersAndCount.Add(obj.OwnerID, 0);
- }
- ownersAndCount[obj.OwnerID] += obj.PrimCount;
- }
- }
- catch (InvalidOperationException)
- {
- m_log.Error("[LAND]: Unable to enumerate land owners. arr.");
- }
-
- }
- return ownersAndCount;
- }
-
- #endregion
-
- #region Object Returning
-
- public void returnObject(SceneObjectGroup obj)
- {
- SceneObjectGroup[] objs = new SceneObjectGroup[1];
- objs[0] = obj;
- m_scene.returnObjects(objs, obj.OwnerID);
- }
-
- public void returnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client)
- {
- Dictionary> returns =
- new Dictionary>();
-
- lock (primsOverMe)
- {
- if (type == (uint)ObjectReturnType.Owner)
- {
- foreach (SceneObjectGroup obj in primsOverMe)
- {
- if (obj.OwnerID == m_landData.OwnerID)
- {
- if (!returns.ContainsKey(obj.OwnerID))
- returns[obj.OwnerID] =
- new List();
- returns[obj.OwnerID].Add(obj);
- }
- }
- }
- else if (type == (uint)ObjectReturnType.Group && m_landData.GroupID != UUID.Zero)
- {
- foreach (SceneObjectGroup obj in primsOverMe)
- {
- if (obj.GroupID == m_landData.GroupID)
- {
- if (!returns.ContainsKey(obj.OwnerID))
- returns[obj.OwnerID] =
- new List();
- returns[obj.OwnerID].Add(obj);
- }
- }
- }
- else if (type == (uint)ObjectReturnType.Other)
- {
- foreach (SceneObjectGroup obj in primsOverMe)
- {
- if (obj.OwnerID != m_landData.OwnerID &&
- (obj.GroupID != m_landData.GroupID ||
- m_landData.GroupID == UUID.Zero))
- {
- if (!returns.ContainsKey(obj.OwnerID))
- returns[obj.OwnerID] =
- new List();
- returns[obj.OwnerID].Add(obj);
- }
- }
- }
- else if (type == (uint)ObjectReturnType.List)
- {
- List ownerlist = new List(owners);
-
- foreach (SceneObjectGroup obj in primsOverMe)
- {
- if (ownerlist.Contains(obj.OwnerID))
- {
- if (!returns.ContainsKey(obj.OwnerID))
- returns[obj.OwnerID] =
- new List();
- returns[obj.OwnerID].Add(obj);
- }
- }
- }
- }
-
- foreach (List ol in returns.Values)
- m_scene.returnObjects(ol.ToArray(), remote_client.AgentId);
- }
-
- #endregion
-
- #region Object Adding/Removing from Parcel
-
- public void resetLandPrimCounts()
- {
- landData.GroupPrims = 0;
- landData.OwnerPrims = 0;
- landData.OtherPrims = 0;
- landData.SelectedPrims = 0;
-
-
- lock (primsOverMe)
- primsOverMe.Clear();
- }
-
- public void addPrimToCount(SceneObjectGroup obj)
- {
-
- UUID prim_owner = obj.OwnerID;
- int prim_count = obj.PrimCount;
-
- if (obj.IsSelected)
- {
- landData.SelectedPrims += prim_count;
- }
- else
- {
- if (prim_owner == landData.OwnerID)
- {
- landData.OwnerPrims += prim_count;
- }
- else if ((obj.GroupID == landData.GroupID ||
- prim_owner == landData.GroupID) &&
- landData.GroupID != UUID.Zero)
- {
- landData.GroupPrims += prim_count;
- }
- else
- {
- landData.OtherPrims += prim_count;
- }
- }
-
- lock (primsOverMe)
- primsOverMe.Add(obj);
- }
-
- public void removePrimFromCount(SceneObjectGroup obj)
- {
- lock (primsOverMe)
- {
- if (primsOverMe.Contains(obj))
- {
- UUID prim_owner = obj.OwnerID;
- int prim_count = obj.PrimCount;
-
- if (prim_owner == landData.OwnerID)
- {
- landData.OwnerPrims -= prim_count;
- }
- else if (obj.GroupID == landData.GroupID ||
- prim_owner == landData.GroupID)
- {
- landData.GroupPrims -= prim_count;
- }
- else
- {
- landData.OtherPrims -= prim_count;
- }
-
- primsOverMe.Remove(obj);
- }
- }
- }
-
- #endregion
-
- #endregion
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
deleted file mode 100644
index 9165554..0000000
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
+++ /dev/null
@@ -1,1060 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.Net;
-using OpenMetaverse;
-using OpenMetaverse.Packets;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.NPC
-{
- public class NPCAvatar : IClientAPI
- {
- private readonly string m_firstname;
- private readonly string m_lastname;
- private readonly Vector3 m_startPos;
- private readonly UUID m_uuid = UUID.Random();
- private readonly Scene m_scene;
-
-
- public NPCAvatar(string firstname, string lastname, Vector3 position, Scene scene)
- {
- m_firstname = firstname;
- m_lastname = lastname;
- m_startPos = position;
- m_scene = scene;
- }
-
- public IScene Scene
- {
- get { return m_scene; }
- }
-
- public void Say(string message)
- {
- SendOnChatFromClient(message, ChatTypeEnum.Say);
- }
-
- public void Shout(string message)
- {
- SendOnChatFromClient(message, ChatTypeEnum.Shout);
- }
-
- public void Whisper(string message)
- {
- SendOnChatFromClient(message, ChatTypeEnum.Whisper);
- }
-
- public void Broadcast(string message)
- {
- SendOnChatFromClient(message, ChatTypeEnum.Broadcast);
- }
-
- public void GiveMoney(UUID target, int amount)
- {
- OnMoneyTransferRequest(m_uuid, target, amount, 1, "Payment");
- }
-
- public void InstantMessage(UUID target, string message)
- {
- OnInstantMessage(this, new GridInstantMessage(m_scene,
- m_uuid, m_firstname + " " + m_lastname,
- target, 0, false, message,
- UUID.Zero, false, Position, new byte[0]));
- }
-
- public void SendAgentOffline(UUID[] agentIDs)
- {
-
- }
-
- public void SendAgentOnline(UUID[] agentIDs)
- {
-
- }
- public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
- Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
- {
-
- }
-
- public void SendAdminResponse(UUID Token, uint AdminLevel)
- {
-
- }
-
- public void SendGroupMembership(GroupMembershipData[] GroupMembership)
- {
-
- }
-
- public UUID GetDefaultAnimation(string name)
- {
- return UUID.Zero;
- }
-
- public Vector3 Position
- {
- get { return m_scene.Entities[m_uuid].AbsolutePosition; }
- set { m_scene.Entities[m_uuid].AbsolutePosition = value; }
- }
-
- public bool SendLogoutPacketWhenClosing
- {
- set { }
- }
-
- #region Internal Functions
-
- private void SendOnChatFromClient(string message, ChatTypeEnum chatType)
- {
- OSChatMessage chatFromClient = new OSChatMessage();
- chatFromClient.Channel = 0;
- chatFromClient.From = Name;
- chatFromClient.Message = message;
- chatFromClient.Position = StartPos;
- chatFromClient.Scene = m_scene;
- chatFromClient.Sender = this;
- chatFromClient.SenderUUID = AgentId;
- chatFromClient.Type = chatType;
-
- OnChatFromClient(this, chatFromClient);
- }
-
- #endregion
-
- #region Event Definitions IGNORE
-
-// disable warning: public events constituting public API
-#pragma warning disable 67
- public event Action OnLogout;
- public event ObjectPermissions OnObjectPermissions;
-
- public event MoneyTransferRequest OnMoneyTransferRequest;
- public event ParcelBuy OnParcelBuy;
- public event Action OnConnectionClosed;
- public event GenericMessage OnGenericMessage;
- public event ImprovedInstantMessage OnInstantMessage;
- public event ChatMessage OnChatFromClient;
- public event TextureRequest OnRequestTexture;
- public event RezObject OnRezObject;
- public event ModifyTerrain OnModifyTerrain;
- public event SetAppearance OnSetAppearance;
- public event AvatarNowWearing OnAvatarNowWearing;
- public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
- public event UUIDNameRequest OnDetachAttachmentIntoInv;
- public event ObjectAttach OnObjectAttach;
- public event ObjectDeselect OnObjectDetach;
- public event ObjectDrop OnObjectDrop;
- public event StartAnim OnStartAnim;
- public event StopAnim OnStopAnim;
- public event LinkObjects OnLinkObjects;
- public event DelinkObjects OnDelinkObjects;
- public event RequestMapBlocks OnRequestMapBlocks;
- public event RequestMapName OnMapNameRequest;
- public event TeleportLocationRequest OnTeleportLocationRequest;
- public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
- public event DisconnectUser OnDisconnectUser;
- public event RequestAvatarProperties OnRequestAvatarProperties;
- public event SetAlwaysRun OnSetAlwaysRun;
-
- public event DeRezObject OnDeRezObject;
- public event Action OnRegionHandShakeReply;
- public event GenericCall2 OnRequestWearables;
- public event GenericCall2 OnCompleteMovementToRegion;
- public event UpdateAgent OnAgentUpdate;
- public event AgentRequestSit OnAgentRequestSit;
- public event AgentSit OnAgentSit;
- public event AvatarPickerRequest OnAvatarPickerRequest;
- public event Action OnRequestAvatarsData;
- public event AddNewPrim OnAddPrim;
- public event RequestGodlikePowers OnRequestGodlikePowers;
- public event GodKickUser OnGodKickUser;
- public event ObjectDuplicate OnObjectDuplicate;
- public event GrabObject OnGrabObject;
- public event ObjectSelect OnDeGrabObject;
- public event MoveObject OnGrabUpdate;
- public event ViewerEffectEventHandler OnViewerEffect;
-
- public event FetchInventory OnAgentDataUpdateRequest;
- public event TeleportLocationRequest OnSetStartLocationRequest;
-
- public event UpdateShape OnUpdatePrimShape;
- public event ObjectExtraParams OnUpdateExtraParams;
- public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
- public event ObjectSelect OnObjectSelect;
- public event GenericCall7 OnObjectDescription;
- public event GenericCall7 OnObjectName;
- public event GenericCall7 OnObjectClickAction;
- public event GenericCall7 OnObjectMaterial;
- public event UpdatePrimFlags OnUpdatePrimFlags;
- public event UpdatePrimTexture OnUpdatePrimTexture;
- public event UpdateVector OnUpdatePrimGroupPosition;
- public event UpdateVector OnUpdatePrimSinglePosition;
- public event UpdatePrimRotation OnUpdatePrimGroupRotation;
- public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
- public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
- public event UpdateVector OnUpdatePrimScale;
- public event UpdateVector OnUpdatePrimGroupScale;
- public event StatusChange OnChildAgentStatus;
- public event GenericCall2 OnStopMovement;
- public event Action OnRemoveAvatar;
-
- public event CreateNewInventoryItem OnCreateNewInventoryItem;
- public event CreateInventoryFolder OnCreateNewInventoryFolder;
- public event UpdateInventoryFolder OnUpdateInventoryFolder;
- public event MoveInventoryFolder OnMoveInventoryFolder;
- public event RemoveInventoryFolder OnRemoveInventoryFolder;
- public event RemoveInventoryItem OnRemoveInventoryItem;
- public event FetchInventoryDescendents OnFetchInventoryDescendents;
- public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
- public event FetchInventory OnFetchInventory;
- public event RequestTaskInventory OnRequestTaskInventory;
- public event UpdateInventoryItem OnUpdateInventoryItem;
- public event CopyInventoryItem OnCopyInventoryItem;
- public event MoveInventoryItem OnMoveInventoryItem;
- public event UDPAssetUploadRequest OnAssetUploadRequest;
- public event XferReceive OnXferReceive;
- public event RequestXfer OnRequestXfer;
- public event AbortXfer OnAbortXfer;
- public event ConfirmXfer OnConfirmXfer;
- public event RezScript OnRezScript;
- public event UpdateTaskInventory OnUpdateTaskInventory;
- public event MoveTaskInventory OnMoveTaskItem;
- public event RemoveTaskInventory OnRemoveTaskItem;
- public event RequestAsset OnRequestAsset;
-
- public event UUIDNameRequest OnNameFromUUIDRequest;
- public event UUIDNameRequest OnUUIDGroupNameRequest;
-
- public event ParcelPropertiesRequest OnParcelPropertiesRequest;
- public event ParcelDivideRequest OnParcelDivideRequest;
- public event ParcelJoinRequest OnParcelJoinRequest;
- public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
- public event ParcelAbandonRequest OnParcelAbandonRequest;
- public event ParcelGodForceOwner OnParcelGodForceOwner;
- public event ParcelReclaim OnParcelReclaim;
- public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
- public event ParcelAccessListRequest OnParcelAccessListRequest;
- public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
- public event ParcelSelectObjects OnParcelSelectObjects;
- public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
- public event ObjectDeselect OnObjectDeselect;
- public event RegionInfoRequest OnRegionInfoRequest;
- public event EstateCovenantRequest OnEstateCovenantRequest;
- public event RequestTerrain OnRequestTerrain;
- public event RequestTerrain OnUploadTerrain;
- public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
-
- public event FriendActionDelegate OnApproveFriendRequest;
- public event FriendActionDelegate OnDenyFriendRequest;
- public event FriendshipTermination OnTerminateFriendship;
-
- public event EconomyDataRequest OnEconomyDataRequest;
- public event MoneyBalanceRequest OnMoneyBalanceRequest;
- public event UpdateAvatarProperties OnUpdateAvatarProperties;
-
- public event ObjectIncludeInSearch OnObjectIncludeInSearch;
- public event UUIDNameRequest OnTeleportHomeRequest;
-
- public event ScriptAnswer OnScriptAnswer;
- public event RequestPayPrice OnRequestPayPrice;
- public event ObjectSaleInfo OnObjectSaleInfo;
- public event ObjectBuy OnObjectBuy;
- public event BuyObjectInventory OnBuyObjectInventory;
- public event AgentSit OnUndo;
-
- public event ForceReleaseControls OnForceReleaseControls;
- public event GodLandStatRequest OnLandStatRequest;
- public event RequestObjectPropertiesFamily OnObjectGroupRequest;
-
- public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
- public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
- public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
- public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
- public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
- public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
- public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
- public event BakeTerrain OnBakeTerrain;
- public event EstateRestartSimRequest OnEstateRestartSimRequest;
- public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
- public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
- public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
- public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
- public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
- public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
- public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
- public event EstateChangeInfo OnEstateChangeInfo;
- public event ScriptReset OnScriptReset;
- public event GetScriptRunning OnGetScriptRunning;
- public event SetScriptRunning OnSetScriptRunning;
- public event UpdateVector OnAutoPilotGo;
-
- public event TerrainUnacked OnUnackedTerrain;
-
- public event RegionHandleRequest OnRegionHandleRequest;
- public event ParcelInfoRequest OnParcelInfoRequest;
-
- public event ActivateGesture OnActivateGesture;
- public event DeactivateGesture OnDeactivateGesture;
- public event ObjectOwner OnObjectOwner;
-
- public event DirPlacesQuery OnDirPlacesQuery;
- public event DirFindQuery OnDirFindQuery;
- public event DirLandQuery OnDirLandQuery;
- public event DirPopularQuery OnDirPopularQuery;
- public event DirClassifiedQuery OnDirClassifiedQuery;
- public event EventInfoRequest OnEventInfoRequest;
- public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
-
- public event MapItemRequest OnMapItemRequest;
-
- public event OfferCallingCard OnOfferCallingCard;
- public event AcceptCallingCard OnAcceptCallingCard;
- public event DeclineCallingCard OnDeclineCallingCard;
- public event SoundTrigger OnSoundTrigger;
-
- public event StartLure OnStartLure;
- public event TeleportLureRequest OnTeleportLureRequest;
- public event NetworkStats OnNetworkStatsUpdate;
-
- public event ClassifiedInfoRequest OnClassifiedInfoRequest;
- public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
- public event ClassifiedDelete OnClassifiedDelete;
- public event ClassifiedDelete OnClassifiedGodDelete;
-
- public event EventNotificationAddRequest OnEventNotificationAddRequest;
- public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
- public event EventGodDelete OnEventGodDelete;
-
- public event ParcelDwellRequest OnParcelDwellRequest;
-
- public event UserInfoRequest OnUserInfoRequest;
- public event UpdateUserInfo OnUpdateUserInfo;
-
-#pragma warning restore 67
-
- #endregion
-
- public void ActivateGesture(UUID assetId, UUID gestureId)
- {
- }
- public void DeactivateGesture(UUID assetId, UUID gestureId)
- {
- }
-
- #region Overrriden Methods IGNORE
-
- public virtual Vector3 StartPos
- {
- get { return m_startPos; }
- set { }
- }
-
- public virtual UUID AgentId
- {
- get { return m_uuid; }
- }
-
- public UUID SessionId
- {
- get { return UUID.Zero; }
- }
-
- public UUID SecureSessionId
- {
- get { return UUID.Zero; }
- }
-
- public virtual string FirstName
- {
- get { return m_firstname; }
- }
-
- public virtual string LastName
- {
- get { return m_lastname; }
- }
-
- public virtual String Name
- {
- get { return FirstName + " " + LastName; }
- }
-
- public bool IsActive
- {
- get { return true; }
- set { }
- }
-
- public UUID ActiveGroupId
- {
- get { return UUID.Zero; }
- }
-
- public string ActiveGroupName
- {
- get { return String.Empty; }
- }
-
- public ulong ActiveGroupPowers
- {
- get { return 0; }
- }
-
- public bool IsGroupMember(UUID groupID)
- {
- return false;
- }
-
- public ulong GetGroupPowers(UUID groupID)
- {
- return 0;
- }
-
- public virtual int NextAnimationSequenceNumber
- {
- get { return 1; }
- }
-
- public virtual void SendWearables(AvatarWearable[] wearables, int serial)
- {
- }
-
- public virtual void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
- {
- }
-
- public virtual void Kick(string message)
- {
- }
-
- public virtual void SendStartPingCheck(byte seq)
- {
- }
-
- public virtual void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data)
- {
- }
-
- public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
- {
-
- }
-
- public virtual void SendKillObject(ulong regionHandle, uint localID)
- {
- }
-
- public virtual void SetChildAgentThrottle(byte[] throttle)
- {
- }
- public byte[] GetThrottlesPacked(float multiplier)
- {
- return new byte[0];
- }
-
-
- public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId)
- {
- }
-
- public virtual void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
- UUID fromAgentID, byte source, byte audible)
- {
- }
-
- public virtual void SendChatMessage(byte[] message, byte type, Vector3 fromPos, string fromName,
- UUID fromAgentID, byte source, byte audible)
- {
- }
-
- public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp)
- {
-
- }
-
- public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp, UUID transationID, bool fromGroup, byte[] binaryBucket)
- {
-
- }
-
- public void SendGenericMessage(string method, List message)
- {
-
- }
-
- public virtual void SendLayerData(float[] map)
- {
- }
-
- public virtual void SendLayerData(int px, int py, float[] map)
- {
- }
- public virtual void SendLayerData(int px, int py, float[] map, bool track)
- {
- }
-
- public virtual void SendWindData(Vector2[] windSpeeds) { }
-
- public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
- {
- }
-
- public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
- {
- }
-
- public virtual AgentCircuitData RequestClientInfo()
- {
- return new AgentCircuitData();
- }
-
- public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt,
- IPEndPoint newRegionExternalEndPoint, string capsURL)
- {
- }
-
- public virtual void SendMapBlock(List mapBlocks, uint flag)
- {
- }
-
- public virtual void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
- {
- }
-
- public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint,
- uint locationID, uint flags, string capsURL)
- {
- }
-
- public virtual void SendTeleportFailed(string reason)
- {
- }
-
- public virtual void SendTeleportLocationStart()
- {
- }
-
- public virtual void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance)
- {
- }
-
- public virtual void SendPayPrice(UUID objectID, int[] payPrice)
- {
- }
-
- public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, string grouptitle, UUID avatarID,
- uint avatarLocalID, Vector3 Pos, byte[] textureEntry, uint parentID, Quaternion rotation)
- {
- }
-
- public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID,
- Vector3 position, Vector3 velocity, Quaternion rotation)
- {
- }
-
- public virtual void SendCoarseLocationUpdate(List CoarseLocations)
- {
- }
-
- public virtual void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID)
- {
- }
-
- public virtual void SendDialog(string objectname, UUID objectID, UUID ownerID, string msg, UUID textureID, int ch, string[] buttonlabels)
- {
- }
-
- public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID,
- PrimitiveBaseShape primShape, Vector3 pos, Vector3 vel,
- Vector3 acc, Quaternion rotation, Vector3 rvel, uint flags,
- UUID objectID, UUID ownerID, string text, byte[] color,
- uint parentID,
- byte[] particleSystem, byte clickAction, byte material)
- {
- }
- public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID,
- PrimitiveBaseShape primShape, Vector3 pos, Vector3 vel,
- Vector3 acc, Quaternion rotation, Vector3 rvel, uint flags,
- UUID objectID, UUID ownerID, string text, byte[] color,
- uint parentID,
- byte[] particleSystem, byte clickAction, byte material, byte[] textureanimation,
- bool attachment, uint AttachmentPoint, UUID AssetId, UUID SoundId, double SoundVolume, byte SoundFlags, double SoundRadius)
- {
- }
- public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID,
- Vector3 position, Quaternion rotation, Vector3 velocity,
- Vector3 rotationalvelocity, byte state, UUID AssetId, UUID ownerID, int attachPoint)
- {
- }
-
- public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID,
- List items,
- List folders,
- bool fetchFolders,
- bool fetchItems)
- {
- }
-
- public virtual void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
- {
- }
-
- public virtual void SendInventoryItemCreateUpdate(InventoryItemBase Item)
- {
- }
-
- public virtual void SendRemoveInventoryItem(UUID itemID)
- {
- }
-
- /// IClientAPI.SendBulkUpdateInventory(InventoryItemBase)
- public virtual void SendBulkUpdateInventory(InventoryItemBase item)
- {
- }
-
- public virtual void SendBulkUpdateInventory(InventoryFolderBase folderBase)
- {}
-
- public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
- {
- }
-
- public virtual void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
- {
- }
-
- public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data)
- {
- }
-
- public virtual void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
- int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
- int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
- int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
- {
-
- }
- public virtual void SendNameReply(UUID profileId, string firstname, string lastname)
- {
- }
-
- public virtual void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
- {
- }
-
- public virtual void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain,
- byte flags)
- {
- }
-
- public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
- {
- }
-
- public void SendAttachedSoundGainChange(UUID objectID, float gain)
- {
-
- }
-
- public void SendAlertMessage(string message)
- {
- }
-
- public void SendAgentAlertMessage(string message, bool modal)
- {
- }
-
- public void SendSystemAlertMessage(string message)
- {
- }
-
- public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
- string url)
- {
- }
-
- public virtual void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
- {
- if (OnRegionHandShakeReply != null)
- {
- OnRegionHandShakeReply(this);
- }
-
- if (OnCompleteMovementToRegion != null)
- {
- OnCompleteMovementToRegion();
- }
- }
- public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
- {
- }
-
- public void SendConfirmXfer(ulong xferID, uint PacketID)
- {
- }
-
- public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
- {
- }
-
- public void SendInitiateDownload(string simFileName, string clientFileName)
- {
- }
-
- public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
- {
- }
-
- public void SendImageNotFound(UUID imageid)
- {
- }
-
- public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
- {
- }
-
- public void SendShutdownConnectionNotice()
- {
- }
-
- public void SendSimStats(SimStats stats)
- {
- }
-
- public void SendObjectPropertiesFamilyData(uint RequestFlags, UUID ObjectUUID, UUID OwnerID, UUID GroupID,
- uint BaseMask, uint OwnerMask, uint GroupMask, uint EveryoneMask,
- uint NextOwnerMask, int OwnershipCost, byte SaleType, int SalePrice, uint Category,
- UUID LastOwnerID, string ObjectName, string Description)
- {
- }
-
- public void SendObjectPropertiesReply(UUID ItemID, ulong CreationDate, UUID CreatorUUID, UUID FolderUUID, UUID FromTaskUUID,
- UUID GroupUUID, short InventorySerial, UUID LastOwnerUUID, UUID ObjectUUID,
- UUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName,
- string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask,
- uint BaseMask, byte saleType, int salePrice)
- {
- }
-
- public bool AddMoney(int debit)
- {
- return false;
- }
-
- public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
- {
- }
-
- public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
- {
- }
-
- public void SendViewerTime(int phase)
- {
- }
-
- public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
- string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
- UUID partnerID)
- {
- }
-
- public void SendAsset(AssetRequestToClient req)
- {
- }
-
- public void SendTexture(AssetBase TextureAsset)
- {
- }
-
- public void SetDebugPacketLevel(int newDebug)
- {
- }
-
- public void InPacket(object NewPack)
- {
- }
-
- public void ProcessInPacket(Packet NewPack)
- {
- }
-
- public void Close(bool ShutdownCircuit)
- {
- }
-
- public void Start()
- {
- }
-
- public void Stop()
- {
- }
-
- private uint m_circuitCode;
-
- public uint CircuitCode
- {
- get { return m_circuitCode; }
- set { m_circuitCode = value; }
- }
-
- public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
- {
-
- }
- public void SendLogoutPacket()
- {
- }
-
- public void Terminate()
- {
- }
-
- public ClientInfo GetClientInfo()
- {
- return null;
- }
-
- public void SetClientInfo(ClientInfo info)
- {
- }
-
- public void SendScriptQuestion(UUID objectID, string taskName, string ownerName, UUID itemID, int question)
- {
- }
- public void SendHealth(float health)
- {
- }
-
- public void SendEstateManagersList(UUID invoice, UUID[] EstateManagers, uint estateID)
- {
- }
-
- public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID)
- {
- }
-
- public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
- {
- }
- public void SendEstateCovenantInformation(UUID covenant)
- {
- }
- public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner)
- {
- }
-
- public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor,int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
- {
- }
- public void SendLandAccessListData(List avatars, uint accessFlag, int localLandID)
- {
- }
- public void SendForceClientSelectObjects(List objectIDs)
- {
- }
- public void SendLandObjectOwners(Dictionary ownersAndCount)
- {
- }
- public void SendLandParcelOverlay(byte[] data, int sequence_id)
- {
- }
-
- public void SendGroupNameReply(UUID groupLLUID, string GroupName)
- {
- }
-
- public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
- {
- }
-
- public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
- {
- }
- #endregion
-
-
- public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
- {
- }
-
- public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
- byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
- byte mediaLoop)
- {
- }
-
- public void SendSetFollowCamProperties (UUID objectID, SortedDictionary parameters)
- {
- }
-
- public void SendClearFollowCamProperties (UUID objectID)
- {
- }
-
- public void SendRegionHandle (UUID regoinID, ulong handle)
- {
- }
-
- public void SendParcelInfo (RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
- {
- }
-
- public void SetClientOption(string option, string value)
- {
- }
-
- public string GetClientOption(string option)
- {
- return string.Empty;
- }
-
- public void SendScriptTeleportRequest (string objName, string simName, Vector3 pos, Vector3 lookAt)
- {
- }
-
- public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
- {
- }
-
- public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
- {
- }
-
- public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
- {
- }
-
- public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
- {
- }
-
- public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
- {
- }
-
- public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
- {
- }
-
- public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
- {
- }
-
- public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
- {
- }
-
- public void KillEndDone()
- {
- }
-
- public void SendEventInfoReply (EventData info)
- {
- }
-
- public void SendOfferCallingCard (UUID destID, UUID transactionID)
- {
- }
-
- public void SendAcceptCallingCard (UUID transactionID)
- {
- }
-
- public void SendDeclineCallingCard (UUID transactionID)
- {
- }
-
- public void SendJoinGroupReply(UUID groupID, bool success)
- {
- }
-
- public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
- {
- }
-
- public void SendLeaveGroupReply(UUID groupID, bool success)
- {
- }
-
- public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
- {
- }
-
- public void SendTerminateFriend(UUID exFriendID)
- {
- }
-
- #region IClientAPI Members
-
-
- public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
- {
- throw new NotImplementedException();
- }
-
- public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
- {
- }
-
- public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price)
- {
- }
-
- public void SendAgentDropGroup(UUID groupID)
- {
- }
-
- public void SendAvatarNotesReply(UUID targetID, string text)
- {
- }
-
- public void SendAvatarPicksReply(UUID targetID, Dictionary picks)
- {
- }
-
- public void SendAvatarClassifiedReply(UUID targetID, Dictionary classifieds)
- {
- }
-
- public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
- {
- }
-
- public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
- {
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCModule.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCModule.cs
deleted file mode 100644
index 2e7b16c..0000000
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCModule.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 OpenMetaverse;
-using Nini.Config;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.NPC
-{
- public class NPCModule : IRegionModule
- {
- // private const bool m_enabled = false;
-
- public void Initialise(Scene scene, IConfigSource source)
- {
- // if (m_enabled)
- // {
- // NPCAvatar testAvatar = new NPCAvatar("Jack", "NPC", new Vector3(128, 128, 40), scene);
- // NPCAvatar testAvatar2 = new NPCAvatar("Jill", "NPC", new Vector3(136, 128, 40), scene);
- // scene.AddNewClient(testAvatar, false);
- // scene.AddNewClient(testAvatar2, false);
- // }
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- }
-
- public string Name
- {
- get { return "NPCModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return true; }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
deleted file mode 100644
index 8838e39..0000000
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ /dev/null
@@ -1,1498 +0,0 @@
-/*
- * 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 OpenMetaverse;
-using Nini.Config;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-using log4net;
-using OpenSim;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.Framework;
-using OpenSim.Framework.Communications.Cache;
-
-namespace OpenSim.Region.Environment.Modules.World.Permissions
-{
- public class PermissionsModule : IRegionModule
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- protected Scene m_scene;
-
- #region Constants
- // These are here for testing. They will be taken out
-
- //private uint PERM_ALL = (uint)2147483647;
- private uint PERM_COPY = (uint)32768;
- //private uint PERM_MODIFY = (uint)16384;
- private uint PERM_MOVE = (uint)524288;
- //private uint PERM_TRANS = (uint)8192;
- private uint PERM_LOCKED = (uint)540672;
-
- ///
- /// Different user set names that come in from the configuration file.
- ///
- enum UserSet
- {
- All,
- Administrators
- };
-
- #endregion
-
- #region Bypass Permissions / Debug Permissions Stuff
-
- // Bypasses the permissions engine
- private bool m_bypassPermissions = true;
- private bool m_bypassPermissionsValue = true;
- private bool m_propagatePermissions = false;
- private bool m_debugPermissions = false;
- private bool m_allowGridGods = false;
- private bool m_RegionOwnerIsGod = false;
- private bool m_ParcelOwnerIsGod = false;
-
- ///
- /// The set of users that are allowed to create scripts. This is only active if permissions are not being
- /// bypassed. This overrides normal permissions.
- ///
- private UserSet m_allowedScriptCreators = UserSet.All;
-
- ///
- /// The set of users that are allowed to edit (save) scripts. This is only active if
- /// permissions are not being bypassed. This overrides normal permissions.-
- ///
- private UserSet m_allowedScriptEditors = UserSet.All;
-
- #endregion
-
- #region IRegionModule Members
-
- public void Initialise(Scene scene, IConfigSource config)
- {
- m_scene = scene;
-
- IConfig myConfig = config.Configs["Startup"];
-
- string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule");
-
- List modules=new List(permissionModules.Split(','));
-
- if (!modules.Contains("DefaultPermissionsModule"))
- return;
-
- m_allowGridGods = myConfig.GetBoolean("allow_grid_gods", false);
- m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", true);
- m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true);
- m_RegionOwnerIsGod = myConfig.GetBoolean("region_owner_is_god", true);
- m_ParcelOwnerIsGod = myConfig.GetBoolean("parcel_owner_is_god", true);
-
- m_allowedScriptCreators
- = ParseUserSetConfigSetting(myConfig, "allowed_script_creators", m_allowedScriptCreators);
- m_allowedScriptEditors
- = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors);
-
- if (m_bypassPermissions)
- m_log.Info("[PERMISSIONS]: serviceside_object_permissions = false in ini file so disabling all region service permission checks");
- else
- m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks");
-
- //Register functions with Scene External Checks!
- m_scene.Permissions.AddBypassPermissionsHandler(BypassPermissions); //FULLY IMPLEMENTED
- m_scene.Permissions.AddSetBypassPermissionsHandler(SetBypassPermissions); //FULLY IMPLEMENTED
- m_scene.Permissions.AddPropagatePermissionsHandler(PropagatePermissions); //FULLY IMPLEMENTED
- m_scene.Permissions.AddGenerateClientFlagsHandler(GenerateClientFlags); //NOT YET FULLY IMPLEMENTED
- m_scene.Permissions.AddAbandonParcelHandler(CanAbandonParcel); //FULLY IMPLEMENTED
- m_scene.Permissions.AddReclaimParcelHandler(CanReclaimParcel); //FULLY IMPLEMENTED
- m_scene.Permissions.AddIsGodHandler(IsGod); //FULLY IMPLEMENTED
- m_scene.Permissions.AddDuplicateObjectHandler(CanDuplicateObject); //FULLY IMPLEMENTED
- m_scene.Permissions.AddDeleteObjectHandler(CanDeleteObject); //MAYBE FULLY IMPLEMENTED
- m_scene.Permissions.AddEditObjectHandler(CanEditObject);//MAYBE FULLY IMPLEMENTED
- m_scene.Permissions.AddEditParcelHandler(CanEditParcel); //FULLY IMPLEMENTED
- m_scene.Permissions.AddInstantMessageHandler(CanInstantMessage); //FULLY IMPLEMENTED
- m_scene.Permissions.AddInventoryTransferHandler(CanInventoryTransfer); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddIssueEstateCommandHandler(CanIssueEstateCommand); //FULLY IMPLEMENTED
- m_scene.Permissions.AddMoveObjectHandler(CanMoveObject); //HOPEFULLY FULLY IMPLEMENTED
- m_scene.Permissions.AddObjectEntryHandler(CanObjectEntry); //FULLY IMPLEMENTED
- m_scene.Permissions.AddReturnObjectHandler(CanReturnObject); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddRezObjectHandler(CanRezObject); //HOPEFULLY FULLY IMPLEMENTED
- m_scene.Permissions.AddRunConsoleCommandHandler(CanRunConsoleCommand); //FULLY IMPLEMENTED
- m_scene.Permissions.AddRunScriptHandler(CanRunScript); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddSellParcelHandler(CanSellParcel); //FULLY IMPLEMENTED
- m_scene.Permissions.AddTakeObjectHandler(CanTakeObject); //FULLY IMPLEMENTED
- m_scene.Permissions.AddTakeCopyObjectHandler(CanTakeCopyObject); //FULLY IMPLEMENTED
- m_scene.Permissions.AddTerraformLandHandler(CanTerraformLand); //FULL IMPLEMENTED (POINT ONLY!!! NOT AREA!!!)
- m_scene.Permissions.AddCanLinkObjectHandler(CanLinkObject); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddCanDelinkObjectHandler(CanDelinkObject); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddCanBuyLandHandler(CanBuyLand); //NOT YET IMPLEMENTED
-
- m_scene.Permissions.AddViewNotecardHandler(CanViewNotecard); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddViewScriptHandler(CanViewScript); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddEditNotecardHandler(CanEditNotecard); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddEditScriptHandler(CanEditScript); //NOT YET IMPLEMENTED
-
- m_scene.Permissions.AddCanCreateObjectInventoryHandler(CanCreateObjectInventory); //NOT IMPLEMENTED HERE
- m_scene.Permissions.AddEditObjectInventoryHandler(CanEditObjectInventory);//MAYBE FULLY IMPLEMENTED
- m_scene.Permissions.AddCanCopyObjectInventoryHandler(CanCopyObjectInventory); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddCanDeleteObjectInventoryHandler(CanDeleteObjectInventory); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddResetScriptHandler(CanResetScript);
-
- m_scene.Permissions.AddCanCreateUserInventoryHandler(CanCreateUserInventory); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddCanCopyUserInventoryHandler(CanCopyUserInventory); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddCanEditUserInventoryHandler(CanEditUserInventory); //NOT YET IMPLEMENTED
- m_scene.Permissions.AddCanDeleteUserInventoryHandler(CanDeleteUserInventory); //NOT YET IMPLEMENTED
-
- m_scene.Permissions.AddCanTeleportHandler(CanTeleport); //NOT YET IMPLEMENTED
-
- m_scene.AddCommand("permissions", "bypass permissions",
- "bypass permissions ",
- "Bypass permission checks",
- HandleBypassPermissions);
-
- m_scene.AddCommand("permissions", "force permissions",
- "force permissions ",
- "Force permissions on or off",
- HandleForcePermissions);
-
- m_scene.AddCommand("permissions", "debug permissions",
- "debug permissions ",
- "Enable permissions debugging",
- HandleDebugPermissions);
- }
-
- public void HandleBypassPermissions(string module, string[] args)
- {
- if (m_scene.ConsoleScene() != null &&
- m_scene.ConsoleScene() != m_scene)
- {
- return;
- }
-
- if (args.Length > 2)
- {
- bool val;
-
- if (!bool.TryParse(args[2], out val))
- return;
-
- m_bypassPermissions = val;
-
- m_log.InfoFormat(
- "[PERMISSIONS]: Set permissions bypass to {0} for {1}",
- m_bypassPermissions, m_scene.RegionInfo.RegionName);
- }
- }
-
- public void HandleForcePermissions(string module, string[] args)
- {
- if (m_scene.ConsoleScene() != null &&
- m_scene.ConsoleScene() != m_scene)
- {
- return;
- }
-
- if (!m_bypassPermissions)
- {
- m_log.Error("[PERMISSIONS] Permissions can't be forced unless they are bypassed first");
- return;
- }
-
- if (args.Length > 2)
- {
- bool val;
-
- if (!bool.TryParse(args[2], out val))
- return;
-
- m_bypassPermissionsValue = val;
-
- m_log.InfoFormat("[PERMISSIONS] Forced permissions to {0} in {1}", m_bypassPermissionsValue, m_scene.RegionInfo.RegionName);
- }
- }
-
- public void HandleDebugPermissions(string module, string[] args)
- {
- if (m_scene.ConsoleScene() != null &&
- m_scene.ConsoleScene() != m_scene)
- {
- return;
- }
-
- if (args.Length > 2)
- {
- bool val;
-
- if (!bool.TryParse(args[2], out val))
- return;
-
- m_debugPermissions = val;
-
- m_log.InfoFormat("[PERMISSIONS] Set permissions debugging to {0} in {1}", m_debugPermissions, m_scene.RegionInfo.RegionName);
- }
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- }
-
- public string Name
- {
- get { return "PermissionsModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return false; }
- }
-
- #endregion
-
- #region Helper Functions
- protected void SendPermissionError(UUID user, string reason)
- {
- m_scene.EventManager.TriggerPermissionError(user, reason);
- }
-
- protected void DebugPermissionInformation(string permissionCalled)
- {
- if (m_debugPermissions)
- m_log.Debug("[PERMISSIONS]: " + permissionCalled + " was called from " + m_scene.RegionInfo.RegionName);
- }
-
- ///
- /// Parse a user set configuration setting
- ///
- ///
- ///
- /// The default value for this attribute
- /// The parsed value
- private static UserSet ParseUserSetConfigSetting(IConfig config, string settingName, UserSet defaultValue)
- {
- UserSet userSet = defaultValue;
-
- string rawSetting = config.GetString(settingName, defaultValue.ToString());
-
- // Temporary measure to allow 'gods' to be specified in config for consistency's sake. In the long term
- // this should disappear.
- if ("gods" == rawSetting.ToLower())
- rawSetting = UserSet.Administrators.ToString();
-
- // Doing it this was so that we can do a case insensitive conversion
- try
- {
- userSet = (UserSet)Enum.Parse(typeof(UserSet), rawSetting, true);
- }
- catch
- {
- m_log.ErrorFormat(
- "[PERMISSIONS]: {0} is not a valid {1} value, setting to {2}",
- rawSetting, settingName, userSet);
- }
-
- m_log.DebugFormat("[PERMISSIONS]: {0} {1}", settingName, userSet);
-
- return userSet;
- }
-
- ///
- /// Is the given user an administrator (in other words, a god)?
- ///
- ///
- ///
- protected bool IsAdministrator(UUID user)
- {
- if (m_scene.RegionInfo.MasterAvatarAssignedUUID != UUID.Zero)
- {
- if (m_RegionOwnerIsGod && (m_scene.RegionInfo.MasterAvatarAssignedUUID == user))
- return true;
- }
-
- if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero)
- {
- if (m_scene.RegionInfo.EstateSettings.EstateOwner == user)
- return true;
- }
-
- if (m_allowGridGods)
- {
- CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(user);
- if (profile != null && profile.UserProfile != null)
- {
- if (profile.UserProfile.GodLevel >= 200)
- return true;
- }
- else
- {
- m_log.ErrorFormat("[PERMISSIONS]: Could not find user {0} for administrator check", user);
- }
- }
-
- return false;
- }
-
- protected bool IsEstateManager(UUID user)
- {
- return m_scene.RegionInfo.EstateSettings.IsEstateManager(user);
- }
-#endregion
-
- public bool PropagatePermissions()
- {
- if (m_bypassPermissions)
- return false;
-
- return m_propagatePermissions;
- }
-
- public bool BypassPermissions()
- {
- return m_bypassPermissions;
- }
-
- public void SetBypassPermissions(bool value)
- {
- m_bypassPermissions=value;
- }
-
- #region Object Permissions
-
- public uint GenerateClientFlags(UUID user, UUID objID)
- {
- // Here's the way this works,
- // ObjectFlags and Permission flags are two different enumerations
- // ObjectFlags, however, tells the client to change what it will allow the user to do.
- // So, that means that all of the permissions type ObjectFlags are /temporary/ and only
- // supposed to be set when customizing the objectflags for the client.
-
- // These temporary objectflags get computed and added in this function based on the
- // Permission mask that's appropriate!
- // Outside of this method, they should never be added to objectflags!
- // -teravus
-
- SceneObjectPart task = m_scene.GetSceneObjectPart(objID);
-
- // this shouldn't ever happen.. return no permissions/objectflags.
- if (task == null)
- return (uint)0;
-
- uint objflags = task.GetEffectiveObjectFlags();
- UUID objectOwner = task.OwnerID;
-
-
- // Remove any of the objectFlags that are temporary. These will get added back if appropriate
- // in the next bit of code
-
- // libomv will moan about PrimFlags.ObjectYouOfficer being
- // deprecated
- #pragma warning disable 0612
- objflags &= (uint)
- ~(PrimFlags.ObjectCopy | // Tells client you can copy the object
- PrimFlags.ObjectModify | // tells client you can modify the object
- PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
- PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
- PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
- PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
- PrimFlags.ObjectOwnerModify | // Tells client that you're the owner of the object
- PrimFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
- );
- #pragma warning restore 0612
-
- // Creating the three ObjectFlags options for this method to choose from.
- // Customize the OwnerMask
- uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
- objectOwnerMask |= (uint)PrimFlags.ObjectYouOwner | (uint)PrimFlags.ObjectAnyOwner | (uint)PrimFlags.ObjectOwnerModify;
-
- // Customize the GroupMask
- // uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
-
- // Customize the EveryoneMask
- uint objectEveryoneMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags);
-
-
- // Hack to allow collaboration until Groups and Group Permissions are implemented
- if ((objectEveryoneMask & (uint)PrimFlags.ObjectMove) != 0)
- objectEveryoneMask |= (uint)PrimFlags.ObjectModify;
-
- if (m_bypassPermissions)
- return objectOwnerMask;
-
- // Object owners should be able to edit their own content
- if (user == objectOwner)
- {
- return objectOwnerMask;
- }
-
- // Users should be able to edit what is over their land.
- ILandObject parcel = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y);
- if (parcel != null && parcel.landData.OwnerID == user && m_ParcelOwnerIsGod)
- return objectOwnerMask;
-
- // Admin objects should not be editable by the above
- if (IsAdministrator(objectOwner))
- return objectEveryoneMask;
-
- // Estate users should be able to edit anything in the sim
- if (IsEstateManager(user) && m_RegionOwnerIsGod)
- return objectOwnerMask;
-
- // Admin should be able to edit anything in the sim (including admin objects)
- if (IsAdministrator(user))
- return objectOwnerMask;
-
-
- return objectEveryoneMask;
- }
-
- private uint ApplyObjectModifyMasks(uint setPermissionMask, uint objectFlagsMask)
- {
- // We are adding the temporary objectflags to the object's objectflags based on the
- // permission flag given. These change the F flags on the client.
-
- if ((setPermissionMask & (uint)PermissionMask.Copy) != 0)
- {
- objectFlagsMask |= (uint)PrimFlags.ObjectCopy;
- }
-
- if ((setPermissionMask & (uint)PermissionMask.Move) != 0)
- {
- objectFlagsMask |= (uint)PrimFlags.ObjectMove;
- }
-
- if ((setPermissionMask & (uint)PermissionMask.Modify) != 0)
- {
- objectFlagsMask |= (uint)PrimFlags.ObjectModify;
- }
-
- if ((setPermissionMask & (uint)PermissionMask.Transfer) != 0)
- {
- objectFlagsMask |= (uint)PrimFlags.ObjectTransfer;
- }
-
- return objectFlagsMask;
- }
-
- ///
- /// General permissions checks for any operation involving an object. These supplement more specific checks
- /// implemented by callers.
- ///
- ///
- ///
- ///
- ///
- protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
- {
- // Default: deny
- bool permission = false;
- bool locked = false;
-
- if (!m_scene.Entities.ContainsKey(objId))
- {
- return false;
- }
-
- // If it's not an object, we cant edit it.
- if ((!(m_scene.Entities[objId] is SceneObjectGroup)))
- {
- return false;
- }
-
- SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objId];
-
- UUID objectOwner = group.OwnerID;
- locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
-
- // People shouldn't be able to do anything with locked objects, except the Administrator
- // The 'set permissions' runs through a different permission check, so when an object owner
- // sets an object locked, the only thing that they can do is unlock it.
- //
- // Nobody but the object owner can set permissions on an object
- //
-
- if (locked && (!IsAdministrator(currentUser)) && denyOnLocked)
- {
- return false;
- }
-
- // Object owners should be able to edit their own content
- if (currentUser == objectOwner)
- {
- permission = true;
- }
- else if (group.IsAttachment)
- {
- permission = false;
- }
-
- // Users should be able to edit what is over their land.
- ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y);
- if ((parcel != null) && (parcel.landData.OwnerID == currentUser))
- {
- permission = true;
- }
-
- // Estate users should be able to edit anything in the sim
- if (IsEstateManager(currentUser))
- {
- permission = true;
- }
-
- // Admin objects should not be editable by the above
- if (IsAdministrator(objectOwner))
- {
- permission = false;
- }
-
- // Admin should be able to edit anything in the sim (including admin objects)
- if (IsAdministrator(currentUser))
- {
- permission = true;
- }
-
- return permission;
- }
-
- #endregion
-
- #region Generic Permissions
- protected bool GenericCommunicationPermission(UUID user, UUID target)
- {
- // Setting this to true so that cool stuff can happen until we define what determines Generic Communication Permission
- bool permission = true;
- string reason = "Only registered users may communicate with another account.";
-
- // Uhh, we need to finish this before we enable it.. because it's blocking all sorts of goodies and features
- if (IsAdministrator(user))
- permission = true;
-
- if (IsEstateManager(user))
- permission = true;
-
- if (!permission)
- SendPermissionError(user, reason);
-
- return permission;
- }
-
- public bool GenericEstatePermission(UUID user)
- {
- // Default: deny
- bool permission = false;
-
- // Estate admins should be able to use estate tools
- if (IsEstateManager(user))
- permission = true;
-
- // Administrators always have permission
- if (IsAdministrator(user))
- permission = true;
-
- return permission;
- }
-
- protected bool GenericParcelPermission(UUID user, ILandObject parcel)
- {
- bool permission = false;
-
- if (parcel.landData.OwnerID == user)
- {
- permission = true;
- }
-
- if (parcel.landData.IsGroupOwned)
- {
- // TODO: Need to do some extra checks here. Requires group code.
- }
-
- if (IsEstateManager(user))
- {
- permission = true;
- }
-
- if (IsAdministrator(user))
- {
- permission = true;
- }
-
- return permission;
- }
-
- protected bool GenericParcelPermission(UUID user, Vector3 pos)
- {
- ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
- if (parcel == null) return false;
- return GenericParcelPermission(user, parcel);
- }
-#endregion
-
- #region Permission Checks
- private bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return GenericParcelPermission(user, parcel);
- }
-
- private bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return GenericParcelPermission(user, parcel);
- }
-
- private bool IsGod(UUID user, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return IsAdministrator(user);
- }
-
- private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if (!GenericObjectPermission(owner, objectID, true))
- {
- //They can't even edit the object
- return false;
- }
-
- SceneObjectPart part = scene.GetSceneObjectPart(objectID);
- if (part == null)
- return false;
-
- if ((part.OwnerMask & PERM_COPY) == 0)
- return false;
-
- if ((part.ParentGroup.GetEffectivePermissions() & PERM_COPY) == 0)
- return false;
-
- //If they can rez, they can duplicate
- return CanRezObject(objectCount, owner, objectPosition, scene);
- }
-
- private bool CanDeleteObject(UUID objectID, UUID deleter, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return GenericObjectPermission(deleter, objectID, false);
- }
-
- private bool CanEditObject(UUID objectID, UUID editorID, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
-
- return GenericObjectPermission(editorID, objectID, false);
- }
-
- private bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
-
- // If we selected a sub-prim to edit, the objectID won't represent the object, but only a part.
- // We have to check the permissions of the group, though.
- if (part.ParentID != 0)
- {
- objectID = part.ParentUUID;
- part = m_scene.GetSceneObjectPart(objectID);
- }
-
- // TODO: add group support!
- //
- if (part.OwnerID != editorID)
- return false;
-
- return GenericObjectPermission(editorID, objectID, false);
- }
-
- private bool CanEditParcel(UUID user, ILandObject parcel, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return GenericParcelPermission(user, parcel);
- }
-
- ///
- /// Check whether the specified user can edit the given script
- ///
- ///
- ///
- ///
- ///
- ///
- private bool CanEditScript(UUID script, UUID objectID, UUID user, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(user))
- return false;
-
- // Ordinarily, if you can view it, you can edit it
- // There is no viewing a no mod script
- //
- return CanViewScript(script, objectID, user, scene);
- }
-
- ///
- /// Check whether the specified user can edit the given notecard
- ///
- ///
- ///
- ///
- ///
- ///
- private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if (objectID == UUID.Zero) // User inventory
- {
- CachedUserInfo userInfo =
- scene.CommsManager.UserProfileCacheService.GetUserDetails(user);
-
- if (userInfo == null)
- {
- m_log.ErrorFormat("[PERMISSIONS]: Could not find user {0} for edit notecard check", user);
- return false;
- }
-
- if (userInfo.RootFolder == null)
- return false;
-
- InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(notecard);
- if (assetRequestItem == null) // Library item
- {
- assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard);
-
- if (assetRequestItem != null) // Implicitly readable
- return true;
- }
-
- // Notecards must be both mod and copy to be saveable
- // This is because of they're not copy, you can't read
- // them, and if they're not mod, well, then they're
- // not mod. Duh.
- //
- if ((assetRequestItem.CurrentPermissions &
- ((uint)PermissionMask.Modify |
- (uint)PermissionMask.Copy)) !=
- ((uint)PermissionMask.Modify |
- (uint)PermissionMask.Copy))
- return false;
- }
- else // Prim inventory
- {
- SceneObjectPart part = scene.GetSceneObjectPart(objectID);
-
- if (part == null)
- return false;
-
- if (part.OwnerID != user)
- return false;
-
- if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
- return false;
-
- TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
-
- if (ti == null)
- return false;
-
- if (ti.OwnerID != user)
- return false;
-
- // Require full perms
- if ((ti.CurrentPermissions &
- ((uint)PermissionMask.Modify |
- (uint)PermissionMask.Copy)) !=
- ((uint)PermissionMask.Modify |
- (uint)PermissionMask.Copy))
- return false;
- }
-
- return true;
- }
-
- private bool CanInstantMessage(UUID user, UUID target, Scene startScene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- // If the sender is an object, check owner instead
- //
- SceneObjectPart part = startScene.GetSceneObjectPart(user);
- if (part != null)
- user = part.OwnerID;
-
- return GenericCommunicationPermission(user, target);
- }
-
- private bool CanInventoryTransfer(UUID user, UUID target, Scene startScene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return GenericCommunicationPermission(user, target);
- }
-
- private bool CanIssueEstateCommand(UUID user, Scene requestFromScene, bool ownerCommand)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if (IsAdministrator(user))
- return true;
-
- if (m_scene.RegionInfo.EstateSettings.IsEstateOwner(user))
- return true;
-
- if (ownerCommand)
- return false;
-
- return GenericEstatePermission(user);
- }
-
- private bool CanMoveObject(UUID objectID, UUID moverID, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions)
- {
- SceneObjectPart part = scene.GetSceneObjectPart(objectID);
- if (part.OwnerID != moverID)
- {
- if (part.ParentGroup != null && !part.ParentGroup.IsDeleted)
- {
- if (part.ParentGroup.IsAttachment)
- return false;
- }
- }
- return m_bypassPermissionsValue;
- }
-
- bool permission = GenericObjectPermission(moverID, objectID, true);
- if (!permission)
- {
- if (!m_scene.Entities.ContainsKey(objectID))
- {
- return false;
- }
-
- // The client
- // may request to edit linked parts, and therefore, it needs
- // to also check for SceneObjectPart
-
- // If it's not an object, we cant edit it.
- if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
- {
- return false;
- }
-
-
- SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
-
-
- // UUID taskOwner = null;
- // Added this because at this point in time it wouldn't be wise for
- // the administrator object permissions to take effect.
- // UUID objectOwner = task.OwnerID;
-
- // Anyone can move
- if ((task.RootPart.EveryoneMask & PERM_MOVE) != 0)
- permission = true;
-
- // Locked
- if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0)
- permission = false;
- }
- else
- {
- bool locked = false;
- if (!m_scene.Entities.ContainsKey(objectID))
- {
- return false;
- }
-
- // If it's not an object, we cant edit it.
- if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
- {
- return false;
- }
-
- SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objectID];
-
- UUID objectOwner = group.OwnerID;
- locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
-
- // This is an exception to the generic object permission.
- // Administrators who lock their objects should not be able to move them,
- // however generic object permission should return true.
- // This keeps locked objects from being affected by random click + drag actions by accident
- // and allows the administrator to grab or delete a locked object.
-
- // Administrators and estate managers are still able to click+grab locked objects not
- // owned by them in the scene
- // This is by design.
-
- if (locked && (moverID == objectOwner))
- return false;
- }
- return permission;
- }
-
- private bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if ((newPoint.X > 257f || newPoint.X < -1f || newPoint.Y > 257f || newPoint.Y < -1f))
- {
- return true;
- }
-
- SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
-
- ILandObject land = m_scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
-
- if (!enteringRegion)
- {
- ILandObject fromland = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y);
-
- if (fromland == land) // Not entering
- return true;
- }
-
- if (land == null)
- {
- return false;
- }
-
- if ((land.landData.Flags & ((int)Parcel.ParcelFlags.AllowAPrimitiveEntry)) != 0)
- {
- return true;
- }
-
- //TODO: check for group rights
-
- if (!m_scene.Entities.ContainsKey(objectID))
- {
- return false;
- }
-
- // If it's not an object, we cant edit it.
- if (!(m_scene.Entities[objectID] is SceneObjectGroup))
- {
- return false;
- }
-
-
- if (GenericParcelPermission(task.OwnerID, newPoint))
- {
- return true;
- }
-
- //Otherwise, false!
- return false;
- }
-
- private bool CanReturnObject(UUID objectID, UUID returnerID, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return GenericObjectPermission(returnerID, objectID, false);
- }
-
- private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- bool permission = false;
-
- ILandObject land = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
- if (land == null) return false;
-
- if ((land.landData.Flags & ((int)Parcel.ParcelFlags.CreateObjects)) ==
- (int)Parcel.ParcelFlags.CreateObjects)
- permission = true;
-
- //TODO: check for group rights
-
- if (IsAdministrator(owner))
- {
- permission = true;
- }
-
- if (GenericParcelPermission(owner, objectPosition))
- {
- permission = true;
- }
-
- return permission;
- }
-
- private bool CanRunConsoleCommand(UUID user, Scene requestFromScene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
-
- return IsAdministrator(user);
- }
-
- private bool CanRunScript(UUID script, UUID objectID, UUID user, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- private bool CanSellParcel(UUID user, ILandObject parcel, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return GenericParcelPermission(user, parcel);
- }
-
- private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return GenericObjectPermission(stealer,objectID, false);
- }
-
- private bool CanTakeCopyObject(UUID objectID, UUID userID, Scene inScene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- bool permission = GenericObjectPermission(userID, objectID,false);
- if (!permission)
- {
- if (!m_scene.Entities.ContainsKey(objectID))
- {
- return false;
- }
-
- // If it's not an object, we cant edit it.
- if (!(m_scene.Entities[objectID] is SceneObjectGroup))
- {
- return false;
- }
-
- SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
- // UUID taskOwner = null;
- // Added this because at this point in time it wouldn't be wise for
- // the administrator object permissions to take effect.
- // UUID objectOwner = task.OwnerID;
-
- if ((task.RootPart.EveryoneMask & PERM_COPY) != 0)
- permission = true;
-
- if ((task.GetEffectivePermissions() & PERM_COPY) == 0)
- permission = false;
- }
- else
- {
- SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
-
- if ((task.GetEffectivePermissions() & PERM_COPY) == 0)
- permission = false;
- }
-
- return permission;
- }
-
- private bool CanTerraformLand(UUID user, Vector3 position, Scene requestFromScene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- // Estate override
- if (GenericEstatePermission(user))
- return true;
-
- float X = position.X;
- float Y = position.Y;
-
- if (X > 255)
- X = 255;
- if (Y > 255)
- Y = 255;
- if (X < 0)
- X = 0;
- if (Y < 0)
- Y = 0;
-
- ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y);
- if (parcel == null)
- return false;
-
- // Others allowed to terraform?
- if ((parcel.landData.Flags & ((int)Parcel.ParcelFlags.AllowTerraform)) != 0)
- return true;
-
- // Land owner can terraform too
- if (parcel != null && GenericParcelPermission(user, parcel))
- return true;
-
- return false;
- }
-
- ///
- /// Check whether the specified user can view the given script
- ///
- ///
- ///
- ///
- ///
- ///
- private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if (objectID == UUID.Zero) // User inventory
- {
- CachedUserInfo userInfo =
- scene.CommsManager.UserProfileCacheService.GetUserDetails(user);
-
- if (userInfo == null)
- {
- m_log.ErrorFormat("[PERMISSIONS]: Could not find user {0} for administrator check", user);
- return false;
- }
-
- if (userInfo.RootFolder == null)
- return false;
-
- InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(script);
- if (assetRequestItem == null) // Library item
- {
- assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script);
-
- if (assetRequestItem != null) // Implicitly readable
- return true;
- }
-
- // SL is rather harebrained here. In SL, a script you
- // have mod/copy no trans is readable. This subverts
- // permissions, but is used in some products, most
- // notably Hippo door plugin and HippoRent 5 networked
- // prim counter.
- // To enable this broken SL-ism, remove Transfer from
- // the below expressions.
- // Trying to improve on SL perms by making a script
- // readable only if it's really full perms
- //
- if ((assetRequestItem.CurrentPermissions &
- ((uint)PermissionMask.Modify |
- (uint)PermissionMask.Copy |
- (uint)PermissionMask.Transfer)) !=
- ((uint)PermissionMask.Modify |
- (uint)PermissionMask.Copy |
- (uint)PermissionMask.Transfer))
- return false;
- }
- else // Prim inventory
- {
- SceneObjectPart part = scene.GetSceneObjectPart(objectID);
-
- if (part == null)
- return false;
-
- if (part.OwnerID != user)
- return false;
-
- if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
- return false;
-
- TaskInventoryItem ti = part.Inventory.GetInventoryItem(script);
-
- if (ti == null)
- return false;
-
- if (ti.OwnerID != user)
- return false;
-
- // Require full perms
- if ((ti.CurrentPermissions &
- ((uint)PermissionMask.Modify |
- (uint)PermissionMask.Copy |
- (uint)PermissionMask.Transfer)) !=
- ((uint)PermissionMask.Modify |
- (uint)PermissionMask.Copy |
- (uint)PermissionMask.Transfer))
- return false;
- }
-
- return true;
- }
-
- ///
- /// Check whether the specified user can view the given notecard
- ///
- ///
- ///
- ///
- ///
- ///
- private bool CanViewNotecard(UUID notecard, UUID objectID, UUID user, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if (objectID == UUID.Zero) // User inventory
- {
- CachedUserInfo userInfo =
- scene.CommsManager.UserProfileCacheService.GetUserDetails(user);
-
- if (userInfo == null)
- {
- m_log.ErrorFormat("[PERMISSIONS]: Could not find user {0} for view notecard check", user);
- return false;
- }
-
- if (userInfo.RootFolder == null)
- return false;
-
- InventoryItemBase assetRequestItem = userInfo.RootFolder.FindItem(notecard);
- if (assetRequestItem == null) // Library item
- {
- assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard);
-
- if (assetRequestItem != null) // Implicitly readable
- return true;
- }
-
- // Notecards are always readable unless no copy
- //
- if ((assetRequestItem.CurrentPermissions &
- (uint)PermissionMask.Copy) !=
- (uint)PermissionMask.Copy)
- return false;
- }
- else // Prim inventory
- {
- SceneObjectPart part = scene.GetSceneObjectPart(objectID);
-
- if (part == null)
- return false;
-
- if (part.OwnerID != user)
- return false;
-
- if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
- return false;
-
- TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
-
- if (ti == null)
- return false;
-
- if (ti.OwnerID != user)
- return false;
-
- // Notecards are always readable unless no copy
- //
- if ((ti.CurrentPermissions &
- (uint)PermissionMask.Copy) !=
- (uint)PermissionMask.Copy)
- return false;
- }
-
- return true;
- }
-
- #endregion
-
- private bool CanLinkObject(UUID userID, UUID objectID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- private bool CanDelinkObject(UUID userID, UUID objectID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- private bool CanBuyLand(UUID userID, ILandObject parcel, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- private bool CanCopyObjectInventory(UUID itemID, UUID objectID, UUID userID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- private bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- ///
- /// Check whether the specified user is allowed to directly create the given inventory type in a prim's
- /// inventory (e.g. the New Script button in the 1.21 Linden Lab client).
- ///
- ///
- ///
- ///
- ///
- private bool CanCreateObjectInventory(int invType, UUID objectID, UUID userID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if ((int)InventoryType.LSL == invType)
- if (m_allowedScriptCreators == UserSet.Administrators && !IsAdministrator(userID))
- return false;
-
- return true;
- }
-
- ///
- /// Check whether the specified user is allowed to create the given inventory type in their inventory.
- ///
- ///
- ///
- ///
- private bool CanCreateUserInventory(int invType, UUID userID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- if ((int)InventoryType.LSL == invType)
- if (m_allowedScriptCreators == UserSet.Administrators && !IsAdministrator(userID))
- return false;
-
- return true;
- }
-
- ///
- /// Check whether the specified user is allowed to copy the given inventory type in their inventory.
- ///
- ///
- ///
- ///
- private bool CanCopyUserInventory(UUID itemID, UUID userID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- ///
- /// Check whether the specified user is allowed to edit the given inventory item within their own inventory.
- ///
- ///
- ///
- ///
- private bool CanEditUserInventory(UUID itemID, UUID userID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- ///
- /// Check whether the specified user is allowed to delete the given inventory item from their own inventory.
- ///
- ///
- ///
- ///
- private bool CanDeleteUserInventory(UUID itemID, UUID userID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- private bool CanTeleport(UUID userID)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- return true;
- }
-
- private bool CanResetScript(UUID prim, UUID script, UUID agentID, Scene scene)
- {
- DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
- if (m_bypassPermissions) return m_bypassPermissionsValue;
-
- SceneObjectPart part = m_scene.GetSceneObjectPart(prim);
-
- // If we selected a sub-prim to reset, prim won't represent the object, but only a part.
- // We have to check the permissions of the object, though.
- if (part.ParentID != 0) prim = part.ParentUUID;
-
- // You can reset the scripts in any object you can edit
- return GenericObjectPermission(agentID, prim, false);
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs
deleted file mode 100644
index afad3cf..0000000
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/IFileSerialiser.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Serialiser
-{
- internal interface IFileSerialiser
- {
- string WriteToFile(Scene scene, string dir);
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
deleted file mode 100644
index 8b3f2ce..0000000
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using System.IO.Compression;
-using System.Text;
-using System.Xml;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Serialiser
-{
- internal class SerialiseObjects : IFileSerialiser
- {
- #region IFileSerialiser Members
-
- public string WriteToFile(Scene scene, string dir)
- {
- string targetFileName = dir + "objects.xml";
-
- SaveSerialisedToFile(targetFileName, scene);
-
- return "objects.xml";
- }
-
- #endregion
-
- public void SaveSerialisedToFile(string fileName, Scene scene)
- {
- string xmlstream = GetObjectXml(scene);
-
- MemoryStream stream = ReformatXmlString(xmlstream);
-
- stream.Seek(0, SeekOrigin.Begin);
- CreateXmlFile(stream, fileName);
-
- stream.Seek(0, SeekOrigin.Begin);
- CreateCompressedXmlFile(stream, fileName);
- }
-
- private static MemoryStream ReformatXmlString(string xmlstream)
- {
- MemoryStream stream = new MemoryStream();
- XmlTextWriter formatter = new XmlTextWriter(stream, Encoding.UTF8);
- XmlDocument doc = new XmlDocument();
-
- doc.LoadXml(xmlstream);
- formatter.Formatting = Formatting.Indented;
- doc.WriteContentTo(formatter);
- formatter.Flush();
- return stream;
- }
-
- private static string GetObjectXml(Scene scene)
- {
- string xmlstream = "";
-
- List EntityList = scene.GetEntities();
- List EntityXml = new List();
-
- foreach (EntityBase ent in EntityList)
- {
- if (ent is SceneObjectGroup)
- {
- EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2());
- }
- }
- EntityXml.Sort();
-
- foreach (string xml in EntityXml)
- xmlstream += xml;
-
- xmlstream += "";
- return xmlstream;
- }
-
- private static void CreateXmlFile(MemoryStream xmlStream, string fileName)
- {
- FileStream objectsFile = new FileStream(fileName, FileMode.Create);
-
- xmlStream.WriteTo(objectsFile);
- objectsFile.Flush();
- objectsFile.Close();
- }
-
- private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName)
- {
- #region GZip Compressed Version
-
- FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
- MemoryStream gzipMSStream = new MemoryStream();
- GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
- xmlStream.WriteTo(gzipStream);
- gzipMSStream.WriteTo(objectsFileCompressed);
- objectsFileCompressed.Flush();
- objectsFileCompressed.Close();
-
- #endregion
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs
deleted file mode 100644
index d0ce3d8..0000000
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseTerrain.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 OpenSim.Region.Environment.Modules.World.Terrain;
-using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Serialiser
-{
- internal class SerialiseTerrain : IFileSerialiser
- {
- #region IFileSerialiser Members
-
- public string WriteToFile(Scene scene, string dir)
- {
- ITerrainLoader fileSystemExporter = new RAW32();
- string targetFileName = dir + "heightmap.r32";
-
- lock (scene.Heightmap)
- {
- fileSystemExporter.SaveFile(targetFileName, scene.Heightmap);
- }
-
- return "heightmap.r32";
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
deleted file mode 100644
index 0e7873c..0000000
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using OpenMetaverse;
-using Nini.Config;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander;
-
-namespace OpenSim.Region.Environment.Modules.World.Serialiser
-{
- public class SerialiserModule : IRegionModule, IRegionSerialiserModule
- {
- private Commander m_commander = new Commander("export");
- private List m_regions = new List();
- private string m_savedir = "exports" + "/";
- private List m_serialisers = new List();
-
- #region IRegionModule Members
-
- public void Initialise(Scene scene, IConfigSource source)
- {
- scene.RegisterModuleCommander(m_commander);
- scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
- scene.RegisterModuleInterface(this);
-
- lock (m_regions)
- {
- m_regions.Add(scene);
- }
- }
-
- public void PostInitialise()
- {
- lock (m_serialisers)
- {
- m_serialisers.Add(new SerialiseTerrain());
- m_serialisers.Add(new SerialiseObjects());
- }
-
- LoadCommanderCommands();
- }
-
- public void Close()
- {
- m_regions.Clear();
- }
-
- public string Name
- {
- get { return "ExportSerialisationModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return true; }
- }
-
- #endregion
-
- #region IRegionSerialiser Members
-
- public void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, Vector3 loadOffset)
- {
- SceneXmlLoader.LoadPrimsFromXml(scene, fileName, newIDS, loadOffset);
- }
-
- public void SavePrimsToXml(Scene scene, string fileName)
- {
- SceneXmlLoader.SavePrimsToXml(scene, fileName);
- }
-
- public void LoadPrimsFromXml2(Scene scene, string fileName)
- {
- SceneXmlLoader.LoadPrimsFromXml2(scene, fileName);
- }
-
- public void LoadPrimsFromXml2(Scene scene, TextReader reader, bool startScripts)
- {
- SceneXmlLoader.LoadPrimsFromXml2(scene, reader, startScripts);
- }
-
- public void SavePrimsToXml2(Scene scene, string fileName)
- {
- SceneXmlLoader.SavePrimsToXml2(scene, fileName);
- }
-
- public void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
- {
- SceneXmlLoader.SavePrimsToXml2(scene, stream, min, max);
- }
-
- public void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
- {
- SceneXmlLoader.SaveNamedPrimsToXml2(scene, primName, fileName);
- }
-
- public SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
- {
- return SceneXmlLoader.DeserializeGroupFromXml2(xmlString);
- }
-
- public string SaveGroupToXml2(SceneObjectGroup grp)
- {
- return SceneXmlLoader.SaveGroupToXml2(grp);
- }
-
- public void SavePrimListToXml2(List entityList, string fileName)
- {
- SceneXmlLoader.SavePrimListToXml2(entityList, fileName);
- }
-
- public void SavePrimListToXml2(List entityList, TextWriter stream, Vector3 min, Vector3 max)
- {
- SceneXmlLoader.SavePrimListToXml2(entityList, stream, min, max);
- }
-
- public List SerialiseRegion(Scene scene, string saveDir)
- {
- List results = new List();
-
- if (!Directory.Exists(saveDir))
- {
- Directory.CreateDirectory(saveDir);
- }
-
- lock (m_serialisers)
- {
- foreach (IFileSerialiser serialiser in m_serialisers)
- {
- results.Add(serialiser.WriteToFile(scene, saveDir));
- }
- }
-
- TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT");
- regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName);
- regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString());
- regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString());
- regionInfoWriter.WriteLine("Serialise Version: 0.1");
- regionInfoWriter.Close();
-
- TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest");
- foreach (string line in results)
- {
- manifestWriter.WriteLine(line);
- }
- manifestWriter.Close();
-
- return results;
- }
-
- #endregion
-
- private void EventManager_OnPluginConsole(string[] args)
- {
- if (args[0] == "export")
- {
- string[] tmpArgs = new string[args.Length - 2];
- int i = 0;
- for (i = 2; i < args.Length; i++)
- tmpArgs[i - 2] = args[i];
-
- m_commander.ProcessConsoleCommand(args[1], tmpArgs);
- }
- }
-
- private void InterfaceSaveRegion(Object[] args)
- {
- foreach (Scene region in m_regions)
- {
- if (region.RegionInfo.RegionName == (string) args[0])
- {
- // List results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
- SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
- }
- }
- }
-
- private void InterfaceSaveAllRegions(Object[] args)
- {
- foreach (Scene region in m_regions)
- {
- // List results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
- SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
- }
- }
-
- private void LoadCommanderCommands()
- {
- Command serialiseSceneCommand = new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveRegion, "Saves the named region into the exports directory.");
- serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String");
-
- Command serialiseAllScenesCommand = new Command("save-all",CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveAllRegions, "Saves all regions into the exports directory.");
-
- m_commander.RegisterCommand("save", serialiseSceneCommand);
- m_commander.RegisterCommand("save-all", serialiseAllScenesCommand);
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs b/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs
deleted file mode 100644
index 1713797..0000000
--- a/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.Reflection;
-using Nini.Config;
-using log4net;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.World.Sound
-{
- public class SoundModule : IRegionModule, ISoundModule
- {
- //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- protected Scene m_scene;
-
- public void Initialise(Scene scene, IConfigSource source)
- {
- m_scene = scene;
-
- m_scene.EventManager.OnNewClient += OnNewClient;
-
- m_scene.RegisterModuleInterface(this);
- }
-
- public void PostInitialise() {}
- public void Close() {}
- public string Name { get { return "Sound Module"; } }
- public bool IsSharedModule { get { return false; } }
-
- private void OnNewClient(IClientAPI client)
- {
- client.OnSoundTrigger += TriggerSound;
- }
-
- public virtual void PlayAttachedSound(
- UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags)
- {
- foreach (ScenePresence p in m_scene.GetAvatars())
- {
- double dis = Util.GetDistanceTo(p.AbsolutePosition, position);
- if (dis > 100.0) // Max audio distance
- continue;
-
- // Scale by distance
- gain = (float)((double)gain*((100.0 - dis) / 100.0));
-
- p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags);
- }
- }
-
- public virtual void TriggerSound(
- UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle)
- {
- foreach (ScenePresence p in m_scene.GetAvatars())
- {
- double dis = Util.GetDistanceTo(p.AbsolutePosition, position);
- if (dis > 100.0) // Max audio distance
- continue;
-
- // Scale by distance
- gain = (float)((double)gain*((100.0 - dis) / 100.0));
-
- p.ControllingClient.SendTriggeredSound(
- soundId, ownerID, objectID, parentID, handle, position, (float)gain);
- }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
deleted file mode 100644
index ee96d58..0000000
--- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * 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.Collections.Generic;
-using OpenMetaverse;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules
-{
- public class SunModule : IRegionModule
- {
-
- private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
-
- private const double SeasonalTilt = 0.03 * Math.PI; // A daily shift of approximately 1.7188 degrees
- private const double AverageTilt = -0.25 * Math.PI; // A 45 degree tilt
- private const double SunCycle = 2.0D * Math.PI; // A perfect circle measured in radians
- private const double SeasonalCycle = 2.0D * Math.PI; // Ditto
-
- //
- // Per Region Values
- //
-
- private bool ready = false;
-
- // Configurable values
- private string m_mode = "SL";
- private int m_frame_mod = 0;
- private double m_day_length = 0;
- private int m_year_length = 0;
- private double m_day_night = 0;
- // private double m_longitude = 0;
- // private double m_latitude = 0;
- // Configurable defaults Defaults close to SL
- private string d_mode = "SL";
- private int d_frame_mod = 100; // Every 10 seconds (actually less)
- private double d_day_length = 4; // A VW day is 4 RW hours long
- private int d_year_length = 60; // There are 60 VW days in a VW year
- private double d_day_night = 0.45; // axis offset: ratio of light-to-dark, approx 1:3
- // private double d_longitude = -73.53;
- // private double d_latitude = 41.29;
-
- // Frame counter
- private uint m_frame = 0;
-
- // Cached Scene reference
- private Scene m_scene = null;
-
- // Calculated Once in the lifetime of a region
- private long TicksToEpoch; // Elapsed time for 1/1/1970
- private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds
- private uint SecondsPerYear; // Length of a virtual year in RW seconds
- private double SunSpeed; // Rate of passage in radians/second
- private double SeasonSpeed; // Rate of change for seasonal effects
- // private double HoursToRadians; // Rate of change for seasonal effects
- private long TicksOffset = 0; // seconds offset from UTC
- // Calculated every update
- private float OrbitalPosition; // Orbital placement at a point in time
- private double HorizonShift; // Axis offset to skew day and night
- private double TotalDistanceTravelled; // Distance since beginning of time (in radians)
- private double SeasonalOffset; // Seaonal variation of tilt
- private float Magnitude; // Normal tilt
- // private double VWTimeRatio; // VW time as a ratio of real time
-
- // Working values
- private Vector3 Position = Vector3.Zero;
- private Vector3 Velocity = Vector3.Zero;
- private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f);
-
- private long LindenHourOffset = 0;
- private bool sunFixed = false;
-
- private Dictionary m_rootAgents = new Dictionary();
-
- // Current time in elapsed seconds since Jan 1st 1970
- private ulong CurrentTime
- {
- get {
- return (ulong)(((System.DateTime.Now.Ticks) - TicksToEpoch + TicksOffset + LindenHourOffset)/10000000);
- }
- }
-
- private float GetLindenEstateHourFromCurrentTime()
- {
- float ticksleftover = ((float)CurrentTime) % ((float)SecondsPerSunCycle);
-
- float hour = (24 * (ticksleftover / SecondsPerSunCycle)) + 6;
-
- return hour;
- }
-
- private void SetTimeByLindenHour(float LindenHour)
- {
- // Linden hour is 24 hours with a 6 hour offset. 6-30
-
- if (LindenHour - 6 == 0)
- {
- LindenHourOffset = 0;
- return;
- }
-
- // Remove LindenHourOffset to calculate it from LocalTime
- float ticksleftover = ((float)(((long)(CurrentTime * 10000000) - (long)LindenHourOffset)/ 10000000) % ((float)SecondsPerSunCycle));
- float hour = (24 * (ticksleftover / SecondsPerSunCycle));
-
- float offsethours = 0;
-
- if (LindenHour - 6 > hour)
- {
- offsethours = hour + ((LindenHour-6) - hour);
- }
- else
- {
- offsethours = hour - (hour - (LindenHour - 6));
- }
- //m_log.Debug("[OFFSET]: " + hour + " - " + LindenHour + " - " + offsethours.ToString());
-
- LindenHourOffset = (long)((float)offsethours * (36000000000/m_day_length));
- m_log.Debug("[SUN]: Directive from the Estate Tools to set the sun phase to LindenHour " + GetLindenEstateHourFromCurrentTime().ToString());
- }
-
- // Called immediately after the module is loaded for a given region
- // i.e. Immediately after instance creation.
- public void Initialise(Scene scene, IConfigSource config)
- {
- m_scene = scene;
-
- m_frame = 0;
-
- TimeZone local = TimeZone.CurrentTimeZone;
- TicksOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
- m_log.Debug("[SUN]: localtime offset is " + TicksOffset);
-
- // Align ticks with Second Life
-
- TicksToEpoch = new System.DateTime(1970,1,1).Ticks;
-
- // Just in case they don't have the stanzas
- try
- {
- // Mode: determines how the sun is handled
- m_mode = config.Configs["Sun"].GetString("mode", d_mode);
- // Mode: determines how the sun is handled
- // m_latitude = config.Configs["Sun"].GetDouble("latitude", d_latitude);
- // Mode: determines how the sun is handled
- // m_longitude = config.Configs["Sun"].GetDouble("longitude", d_longitude);
- // Year length in days
- m_year_length = config.Configs["Sun"].GetInt("year_length", d_year_length);
- // Day length in decimal hours
- m_day_length = config.Configs["Sun"].GetDouble("day_length", d_day_length);
- // Day to Night Ratio
- m_day_night = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night);
- // Update frequency in frames
- m_frame_mod = config.Configs["Sun"].GetInt("update_interval", d_frame_mod);
- }
- catch (Exception e)
- {
- m_log.Debug("[SUN]: Configuration access failed, using defaults. Reason: "+e.Message);
- m_mode = d_mode;
- m_year_length = d_year_length;
- m_day_length = d_day_length;
- m_day_night = d_day_night;
- m_frame_mod = d_frame_mod;
- // m_latitude = d_latitude;
- // m_longitude = d_longitude;
- }
-
- switch (m_mode)
- {
- case "T1":
- default:
- case "SL":
- // Time taken to complete a cycle (day and season)
-
- SecondsPerSunCycle = (uint) (m_day_length * 60 * 60);
- SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length);
-
- // Ration of real-to-virtual time
-
- // VWTimeRatio = 24/m_day_length;
-
- // Speed of rotation needed to complete a cycle in the
- // designated period (day and season)
-
- SunSpeed = SunCycle/SecondsPerSunCycle;
- SeasonSpeed = SeasonalCycle/SecondsPerYear;
-
- // Horizon translation
-
- HorizonShift = m_day_night; // Z axis translation
- // HoursToRadians = (SunCycle/24)*VWTimeRatio;
-
- // Insert our event handling hooks
-
- scene.EventManager.OnFrame += SunUpdate;
- scene.EventManager.OnMakeChildAgent += MakeChildAgent;
- scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
- scene.EventManager.OnClientClosed += ClientLoggedOut;
- scene.EventManager.OnEstateToolsTimeUpdate += EstateToolsTimeUpdate;
- scene.EventManager.OnGetSunLindenHour += GetLindenEstateHourFromCurrentTime;
-
- ready = true;
-
- m_log.Debug("[SUN]: Mode is "+m_mode);
- m_log.Debug("[SUN]: Initialization completed. Day is "+SecondsPerSunCycle+" seconds, and year is "+m_year_length+" days");
- m_log.Debug("[SUN]: Axis offset is "+m_day_night);
- m_log.Debug("[SUN]: Positional data updated every "+m_frame_mod+" frames");
-
- break;
- }
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- ready = false;
-
- // Remove our hooks
- m_scene.EventManager.OnFrame -= SunUpdate;
- m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
- m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
- m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
- m_scene.EventManager.OnEstateToolsTimeUpdate -= EstateToolsTimeUpdate;
- m_scene.EventManager.OnGetSunLindenHour -= GetLindenEstateHourFromCurrentTime;
- }
-
- public string Name
- {
- get { return "SunModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return false; }
- }
-
- public void SunToClient(IClientAPI client)
- {
- if (m_mode != "T1")
- {
- if (ready)
- {
- if (!sunFixed)
- GenSunPos(); // Generate shared values once
- client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition);
- }
- }
- }
-
- public void SunUpdate()
- {
- if (((m_frame++%m_frame_mod) != 0) || !ready || sunFixed)
- {
- return;
- }
-
- GenSunPos(); // Generate shared values once
-
- List avatars = m_scene.GetAvatars();
- foreach (ScenePresence avatar in avatars)
- {
- if (!avatar.IsChildAgent)
- avatar.ControllingClient.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition);
- }
-
- // set estate settings for region access to sun position
- m_scene.RegionInfo.RegionSettings.SunVector = Position;
- //m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime();
- }
-
- public void ForceSunUpdateToAllClients()
- {
- GenSunPos(); // Generate shared values once
-
- List avatars = m_scene.GetAvatars();
- foreach (ScenePresence avatar in avatars)
- {
- if (!avatar.IsChildAgent)
- avatar.ControllingClient.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition);
- }
-
- // set estate settings for region access to sun position
- m_scene.RegionInfo.RegionSettings.SunVector = Position;
- m_scene.RegionInfo.RegionSettings.SunPosition = GetLindenEstateHourFromCurrentTime();
- }
-
- ///
- /// Calculate the sun's orbital position and its velocity.
- ///
- private void GenSunPos()
- {
- TotalDistanceTravelled = SunSpeed * CurrentTime; // distance measured in radians
- OrbitalPosition = (float) (TotalDistanceTravelled%SunCycle); // position measured in radians
-
- // TotalDistanceTravelled += HoursToRadians-(0.25*Math.PI)*Math.Cos(HoursToRadians)-OrbitalPosition;
- // OrbitalPosition = (float) (TotalDistanceTravelled%SunCycle);
-
- SeasonalOffset = SeasonSpeed * CurrentTime; // Present season determined as total radians travelled around season cycle
-
- Tilt.W = (float) (AverageTilt + (SeasonalTilt*Math.Sin(SeasonalOffset))); // Calculate seasonal orbital N/S tilt
-
- // m_log.Debug("[SUN] Total distance travelled = "+TotalDistanceTravelled+", present position = "+OrbitalPosition+".");
- // m_log.Debug("[SUN] Total seasonal progress = "+SeasonalOffset+", present tilt = "+Tilt.W+".");
-
- // The sun rotates about the Z axis
-
- Position.X = (float) Math.Cos(-TotalDistanceTravelled);
- Position.Y = (float) Math.Sin(-TotalDistanceTravelled);
- Position.Z = 0;
-
- // For interest we rotate it slightly about the X access.
- // Celestial tilt is a value that ranges .025
-
- Position *= Tilt;
-
- // Finally we shift the axis so that more of the
- // circle is above the horizon than below. This
- // makes the nights shorter than the days.
-
- Position.Z = Position.Z + (float) HorizonShift;
- Position = Vector3.Normalize(Position);
-
- // m_log.Debug("[SUN] Position("+Position.X+","+Position.Y+","+Position.Z+")");
-
- Velocity.X = 0;
- Velocity.Y = 0;
- Velocity.Z = (float) SunSpeed;
-
- // Correct angular velocity to reflect the seasonal rotation
-
- Magnitude = Position.Length();
- if (sunFixed)
- {
- Velocity.X = 0;
- Velocity.Y = 0;
- Velocity.Z = 0;
- return;
- }
-
- Velocity = (Velocity * Tilt) * (1.0f / Magnitude);
-
- // m_log.Debug("[SUN] Velocity("+Velocity.X+","+Velocity.Y+","+Velocity.Z+")");
- }
-
- private void ClientLoggedOut(UUID AgentId)
- {
- lock (m_rootAgents)
- {
- if (m_rootAgents.ContainsKey(AgentId))
- {
- m_rootAgents.Remove(AgentId);
- }
- }
- }
-
- private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
- {
- lock (m_rootAgents)
- {
- if (m_rootAgents.ContainsKey(avatar.UUID))
- {
- m_rootAgents[avatar.UUID] = avatar.RegionHandle;
- }
- else
- {
- m_rootAgents.Add(avatar.UUID, avatar.RegionHandle);
- SunToClient(avatar.ControllingClient);
- }
- }
- //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
- }
-
- private void MakeChildAgent(ScenePresence avatar)
- {
- lock (m_rootAgents)
- {
- if (m_rootAgents.ContainsKey(avatar.UUID))
- {
- if (m_rootAgents[avatar.UUID] == avatar.RegionHandle)
- {
- m_rootAgents.Remove(avatar.UUID);
- }
- }
- }
- }
-
- public void EstateToolsTimeUpdate(ulong regionHandle, bool FixedTime, bool useEstateTime, float LindenHour)
- {
- if (m_scene.RegionInfo.RegionHandle == regionHandle)
- {
- SetTimeByLindenHour(LindenHour);
-
- //if (useEstateTime)
- //LindenHourOffset = 0;
-
- ForceSunUpdateToAllClients();
- sunFixed = FixedTime;
- if (sunFixed)
- GenSunPos();
- }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
deleted file mode 100644
index 83246fb..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/CookieCutter.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects
-{
- internal class CookieCutter : ITerrainEffect
- {
- #region ITerrainEffect Members
-
- public void RunEffect(ITerrainChannel map)
- {
- ITerrainPaintableEffect eroder = new WeatherSphere();
-
- bool[,] cliffMask = new bool[map.Width,map.Height];
- bool[,] channelMask = new bool[map.Width,map.Height];
- bool[,] smoothMask = new bool[map.Width,map.Height];
- bool[,] allowMask = new bool[map.Width,map.Height];
-
- Console.WriteLine("S1");
-
- // Step one, generate rough mask
- int x, y;
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- Console.Write(".");
- smoothMask[x, y] = true;
- allowMask[x,y] = true;
-
- // Start underwater
- map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 5;
- // Add a little height. (terrain should now be above water, mostly.)
- map[x, y] += 20;
-
- const int channelsX = 4;
- int channelWidth = (map.Width / channelsX / 4);
- const int channelsY = 4;
- int channelHeight = (map.Height / channelsY / 4);
-
- SetLowerChannel(map, cliffMask, channelMask, x, y, channelsX, channelWidth, map.Width, x);
- SetLowerChannel(map, cliffMask, channelMask, x, y, channelsY, channelHeight, map.Height, y);
- }
- }
-
- Console.WriteLine("S2");
- //smooth.FloodEffect(map, smoothMask, 4.0);
-
- Console.WriteLine("S3");
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- if (cliffMask[x, y])
- eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1);
- }
- }
-
- for (x = 0; x < map.Width; x += 2)
- {
- for (y = 0; y < map.Height; y += 2)
- {
- if (map[x, y] < 0.1)
- map[x, y] = 0.1;
- if (map[x, y] > 256)
- map[x, y] = 256;
- }
- }
- //smooth.FloodEffect(map, smoothMask, 4.0);
- }
-
- #endregion
-
- private static void SetLowerChannel(ITerrainChannel map, bool[,] cliffMask, bool[,] channelMask, int x, int y, int numChannels, int channelWidth,
- int mapSize, int rp)
- {
- for (int i = 0; i < numChannels; i++)
- {
- double distanceToLine = Math.Abs(rp - ((mapSize / numChannels) * i));
-
- if (distanceToLine < channelWidth)
- {
- if (channelMask[x, y])
- return;
-
- // Remove channels
- map[x, y] -= 10;
- channelMask[x, y] = true;
- }
- if (distanceToLine < 1)
- {
- cliffMask[x, y] = true;
- }
- }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs
deleted file mode 100644
index 2082137..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/Effects/DefaultTerrainGenerator.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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 OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects
-{
- internal class DefaultTerrainGenerator : ITerrainEffect
- {
- #region ITerrainEffect Members
-
- public void RunEffect(ITerrainChannel map)
- {
- int x, y;
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10;
- double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01;
- if (map[x, y] < spherFac)
- {
- map[x, y] = spherFac;
- }
- }
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs
deleted file mode 100644
index a8e79d0..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/BMP.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- ///
- /// A generic windows bitmap loader.
- /// Should be capable of handling 24-bit RGB images.
- ///
- /// Uses the System.Drawing filesystem loader.
- ///
- internal class BMP : GenericSystemDrawing
- {
- ///
- /// Exports a file to a image on the disk using a System.Drawing exporter.
- ///
- /// The target filename
- /// The terrain channel being saved
- public override void SaveFile(string filename, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(filename, ImageFormat.Bmp);
- }
-
- ///
- /// Exports a stream using a System.Drawing exporter.
- ///
- /// The target stream
- /// The terrain channel being saved
- public override void SaveStream(Stream stream, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(stream, ImageFormat.Png);
- }
-
- ///
- /// The human readable version of the file format(s) this loader handles
- ///
- ///
- public override string ToString()
- {
- return "BMP";
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
deleted file mode 100644
index b76fe05..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- internal class GIF : GenericSystemDrawing
- {
- public override void SaveFile(string filename, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(filename, ImageFormat.Gif);
- }
-
- ///
- /// Exports a stream using a System.Drawing exporter.
- ///
- /// The target stream
- /// The terrain channel being saved
- public override void SaveStream(Stream stream, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(stream, ImageFormat.Gif);
- }
-
- public override string ToString()
- {
- return "GIF";
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
deleted file mode 100644
index 80873d9..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GenericSystemDrawing.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * 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.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- ///
- /// A virtual class designed to have methods overloaded,
- /// this class provides an interface for a generic image
- /// saving and loading mechanism, but does not specify the
- /// format. It should not be insubstantiated directly.
- ///
- public class GenericSystemDrawing : ITerrainLoader
- {
- #region ITerrainLoader Members
-
- public string FileExtension
- {
- get { return ".gsd"; }
- }
-
- ///
- /// Loads a file from a specified filename on the disk,
- /// parses the image using the System.Drawing parsers
- /// then returns a terrain channel. Values are
- /// returned based on HSL brightness between 0m and 128m
- ///
- /// The target image to load
- /// A terrain channel generated from the image.
- public virtual ITerrainChannel LoadFile(string filename)
- {
- return LoadBitmap(new Bitmap(filename));
- }
-
- public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
- {
- throw new NotImplementedException();
- }
-
- public virtual ITerrainChannel LoadStream(Stream stream)
- {
- return LoadBitmap(new Bitmap(stream));
- }
-
- protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap)
- {
- ITerrainChannel retval = new TerrainChannel(bitmap.Width, bitmap.Height);
-
- int x;
- for (x = 0; x < bitmap.Width; x++)
- {
- int y;
- for (y = 0; y < bitmap.Height; y++)
- {
- retval[x, y] = bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness() * 128;
- }
- }
-
- return retval;
- }
-
- ///
- /// Exports a file to a image on the disk using a System.Drawing exporter.
- ///
- /// The target filename
- /// The terrain channel being saved
- public virtual void SaveFile(string filename, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(filename, ImageFormat.Png);
- }
-
- ///
- /// Exports a stream using a System.Drawing exporter.
- ///
- /// The target stream
- /// The terrain channel being saved
- public virtual void SaveStream(Stream stream, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(stream, ImageFormat.Png);
- }
-
- #endregion
-
- public override string ToString()
- {
- return "SYS.DRAWING";
- }
-
- ///
- /// Protected method, generates a grayscale bitmap
- /// image from a specified terrain channel.
- ///
- /// The terrain channel to export to bitmap
- /// A System.Drawing.Bitmap containing a grayscale image
- protected static Bitmap CreateGrayscaleBitmapFromMap(ITerrainChannel map)
- {
- Bitmap bmp = new Bitmap(map.Width, map.Height);
-
- const int pallete = 256;
-
- Color[] grays = new Color[pallete];
- for (int i = 0; i < grays.Length; i++)
- {
- grays[i] = Color.FromArgb(i, i, i);
- }
-
- for (int y = 0; y < map.Height; y++)
- {
- for (int x = 0; x < map.Width; x++)
- {
- // 512 is the largest possible height before colours clamp
- int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 128.0), 0.0) * (pallete - 1));
-
- // Handle error conditions
- if (colorindex > pallete - 1 || colorindex < 0)
- bmp.SetPixel(x, map.Height - y - 1, Color.Red);
- else
- bmp.SetPixel(x, map.Height - y - 1, grays[colorindex]);
- }
- }
- return bmp;
- }
-
- ///
- /// Protected method, generates a coloured bitmap
- /// image from a specified terrain channel.
- ///
- /// The terrain channel to export to bitmap
- /// A System.Drawing.Bitmap containing a coloured image
- protected static Bitmap CreateBitmapFromMap(ITerrainChannel map)
- {
- Bitmap gradientmapLd = new Bitmap("defaultstripe.png");
-
- int pallete = gradientmapLd.Height;
-
- Bitmap bmp = new Bitmap(map.Width, map.Height);
- Color[] colours = new Color[pallete];
-
- for (int i = 0; i < pallete; i++)
- {
- colours[i] = gradientmapLd.GetPixel(0, i);
- }
-
- for (int y = 0; y < map.Height; y++)
- {
- for (int x = 0; x < map.Width; x++)
- {
- // 512 is the largest possible height before colours clamp
- int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1));
-
- // Handle error conditions
- if (colorindex > pallete - 1 || colorindex < 0)
- bmp.SetPixel(x, map.Height - y - 1, Color.Red);
- else
- bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]);
- }
- }
- return bmp;
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs
deleted file mode 100644
index bea504d..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/JPEG.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- public class JPEG : ITerrainLoader
- {
- #region ITerrainLoader Members
-
- public string FileExtension
- {
- get { return ".jpg"; }
- }
-
- public ITerrainChannel LoadFile(string filename)
- {
- throw new NotImplementedException();
- }
-
- public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
- {
- throw new NotImplementedException();
- }
-
- public ITerrainChannel LoadStream(Stream stream)
- {
- throw new NotImplementedException();
- }
-
- public void SaveFile(string filename, ITerrainChannel map)
- {
- Bitmap colours = CreateBitmapFromMap(map);
-
- colours.Save(filename, ImageFormat.Jpeg);
- }
-
- ///
- /// Exports a stream using a System.Drawing exporter.
- ///
- /// The target stream
- /// The terrain channel being saved
- public void SaveStream(Stream stream, ITerrainChannel map)
- {
- Bitmap colours = CreateBitmapFromMap(map);
-
- colours.Save(stream, ImageFormat.Jpeg);
- }
-
- #endregion
-
- public override string ToString()
- {
- return "JPEG";
- }
-
- private static Bitmap CreateBitmapFromMap(ITerrainChannel map)
- {
- Bitmap gradientmapLd = new Bitmap("defaultstripe.png");
-
- int pallete = gradientmapLd.Height;
-
- Bitmap bmp = new Bitmap(map.Width, map.Height);
- Color[] colours = new Color[pallete];
-
- for (int i = 0; i < pallete; i++)
- {
- colours[i] = gradientmapLd.GetPixel(0, i);
- }
-
- for (int y = 0; y < map.Height; y++)
- {
- for (int x = 0; x < map.Width; x++)
- {
- // 512 is the largest possible height before colours clamp
- int colorindex = (int) (Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1));
- bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]);
- }
- }
- return bmp;
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
deleted file mode 100644
index e323e28..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/LLRAW.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * 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.IO;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- public class LLRAW : ITerrainLoader
- {
- public struct HeightmapLookupValue : IComparable
- {
- public int Index;
- public double Value;
-
- public HeightmapLookupValue(int index, double value)
- {
- Index = index;
- Value = value;
- }
-
- public int CompareTo(HeightmapLookupValue val)
- {
- return Value.CompareTo(val.Value);
- }
- }
-
- /// Lookup table to speed up terrain exports
- HeightmapLookupValue[] LookupHeightTable;
-
- public LLRAW()
- {
- LookupHeightTable = new HeightmapLookupValue[256 * 256];
-
- for (int i = 0; i < 256; i++)
- {
- for (int j = 0; j < 256; j++)
- {
- LookupHeightTable[i + (j * 256)] = new HeightmapLookupValue(i + (j * 256), ((double)i * ((double)j / 128.0d)));
- }
- }
- Array.Sort(LookupHeightTable);
- }
-
- #region ITerrainLoader Members
-
- public ITerrainChannel LoadFile(string filename)
- {
- FileInfo file = new FileInfo(filename);
- FileStream s = file.Open(FileMode.Open, FileAccess.Read);
- ITerrainChannel retval = LoadStream(s);
-
- s.Close();
-
- return retval;
- }
-
- public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight)
- {
- TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight);
-
- FileInfo file = new FileInfo(filename);
- FileStream s = file.Open(FileMode.Open, FileAccess.Read);
- BinaryReader bs = new BinaryReader(s);
-
- int currFileYOffset = fileHeight - 1;
-
- // if our region isn't on the first Y section of the areas to be landscaped, then
- // advance to our section of the file
- while (currFileYOffset > offsetY)
- {
- // read a whole strip of regions
- int heightsToRead = sectionHeight * (fileWidth * sectionWidth);
- bs.ReadBytes(heightsToRead * 13); // because there are 13 fun channels
- currFileYOffset--;
- }
-
- // got to the Y start offset within the file of our region
- // so read the file bits associated with our region
- int y;
- // for each Y within our Y offset
- for (y = sectionHeight - 1; y >= 0; y--)
- {
- int currFileXOffset = 0;
-
- // if our region isn't the first X section of the areas to be landscaped, then
- // advance the stream to the X start pos of our section in the file
- // i.e. eat X upto where we start
- while (currFileXOffset < offsetX)
- {
- bs.ReadBytes(sectionWidth * 13);
- currFileXOffset++;
- }
-
- // got to our X offset, so write our regions X line
- int x;
- for (x = 0; x < sectionWidth; x++)
- {
- // Read a strip and continue
- retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 128.0);
- bs.ReadBytes(11);
- }
- // record that we wrote it
- currFileXOffset++;
-
- // if our region isn't the last X section of the areas to be landscaped, then
- // advance the stream to the end of this Y column
- while (currFileXOffset < fileWidth)
- {
- // eat the next regions x line
- bs.ReadBytes(sectionWidth * 13); //The 13 channels again
- currFileXOffset++;
- }
- }
-
- bs.Close();
- s.Close();
-
- return retval;
- }
-
- public ITerrainChannel LoadStream(Stream s)
- {
- TerrainChannel retval = new TerrainChannel();
-
- BinaryReader bs = new BinaryReader(s);
- int y;
- for (y = 0; y < retval.Height; y++)
- {
- int x;
- for (x = 0; x < retval.Width; x++)
- {
- retval[x, (retval.Height - 1) - y] = bs.ReadByte() * (bs.ReadByte() / 128.0);
- bs.ReadBytes(11); // Advance the stream to next bytes.
- }
- }
-
- bs.Close();
-
- return retval;
- }
-
- public void SaveFile(string filename, ITerrainChannel map)
- {
- FileInfo file = new FileInfo(filename);
- FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
- SaveStream(s, map);
-
- s.Close();
- }
-
- public void SaveStream(Stream s, ITerrainChannel map)
- {
- BinaryWriter binStream = new BinaryWriter(s);
-
- // Output the calculated raw
- for (int y = 0; y < map.Height; y++)
- {
- for (int x = 0; x < map.Width; x++)
- {
- double t = map[x, (map.Height - 1) - y];
- //if height is less than 0, set it to 0 as
- //can't save -ve values in a LLRAW file
- if (t < 0d)
- {
- t = 0d;
- }
-
- int index = 0;
-
- // The lookup table is pre-sorted, so we either find an exact match or
- // the next closest (smaller) match with a binary search
- index = Array.BinarySearch(LookupHeightTable, new HeightmapLookupValue(0, t));
- if (index < 0)
- index = ~index - 1;
-
- index = LookupHeightTable[index].Index;
-
- byte red = (byte) (index & 0xFF);
- byte green = (byte) ((index >> 8) & 0xFF);
- const byte blue = 20;
- const byte alpha1 = 0;
- const byte alpha2 = 0;
- const byte alpha3 = 0;
- const byte alpha4 = 0;
- const byte alpha5 = 255;
- const byte alpha6 = 255;
- const byte alpha7 = 255;
- const byte alpha8 = 255;
- byte alpha9 = red;
- byte alpha10 = green;
-
- binStream.Write(red);
- binStream.Write(green);
- binStream.Write(blue);
- binStream.Write(alpha1);
- binStream.Write(alpha2);
- binStream.Write(alpha3);
- binStream.Write(alpha4);
- binStream.Write(alpha5);
- binStream.Write(alpha6);
- binStream.Write(alpha7);
- binStream.Write(alpha8);
- binStream.Write(alpha9);
- binStream.Write(alpha10);
- }
- }
-
- binStream.Close();
- }
-
- public string FileExtension
- {
- get { return ".raw"; }
- }
-
- #endregion
-
- public override string ToString()
- {
- return "LL/SL RAW";
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
deleted file mode 100644
index 25967f3..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- internal class PNG : GenericSystemDrawing
- {
- public override void SaveFile(string filename, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(filename, ImageFormat.Png);
- }
-
- ///
- /// Exports a stream using a System.Drawing exporter.
- ///
- /// The target stream
- /// The terrain channel being saved
- public override void SaveStream(Stream stream, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(stream, ImageFormat.Png);
- }
-
- public override string ToString()
- {
- return "PNG";
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs
deleted file mode 100644
index 7aff56a..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/RAW32.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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.IO;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- public class RAW32 : ITerrainLoader
- {
- #region ITerrainLoader Members
-
- public string FileExtension
- {
- get { return ".r32"; }
- }
-
- public ITerrainChannel LoadFile(string filename)
- {
- FileInfo file = new FileInfo(filename);
- FileStream s = file.Open(FileMode.Open, FileAccess.Read);
- ITerrainChannel retval = LoadStream(s);
-
- s.Close();
-
- return retval;
- }
-
- public ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight)
- {
- TerrainChannel retval = new TerrainChannel(sectionWidth, sectionHeight);
-
- FileInfo file = new FileInfo(filename);
- FileStream s = file.Open(FileMode.Open, FileAccess.Read);
- BinaryReader bs = new BinaryReader(s);
-
- int currFileYOffset = 0;
-
- // if our region isn't on the first Y section of the areas to be landscaped, then
- // advance to our section of the file
- while (currFileYOffset < offsetY)
- {
- // read a whole strip of regions
- int heightsToRead = sectionHeight * (fileWidth * sectionWidth);
- bs.ReadBytes(heightsToRead * 4); // because the floats are 4 bytes in the file
- currFileYOffset++;
- }
-
- // got to the Y start offset within the file of our region
- // so read the file bits associated with our region
- int y;
- // for each Y within our Y offset
- for (y = 0; y < sectionHeight; y++)
- {
- int currFileXOffset = 0;
-
- // if our region isn't the first X section of the areas to be landscaped, then
- // advance the stream to the X start pos of our section in the file
- // i.e. eat X upto where we start
- while (currFileXOffset < offsetX)
- {
- bs.ReadBytes(sectionWidth * 4); // 4 bytes = single
- currFileXOffset++;
- }
-
- // got to our X offset, so write our regions X line
- int x;
- for (x = 0; x < sectionWidth; x++)
- {
- // Read a strip and continue
- retval[x, y] = bs.ReadSingle();
- }
- // record that we wrote it
- currFileXOffset++;
-
- // if our region isn't the last X section of the areas to be landscaped, then
- // advance the stream to the end of this Y column
- while (currFileXOffset < fileWidth)
- {
- // eat the next regions x line
- bs.ReadBytes(sectionWidth * 4); // 4 bytes = single
- currFileXOffset++;
- }
- }
-
- bs.Close();
- s.Close();
-
- return retval;
- }
-
- public ITerrainChannel LoadStream(Stream s)
- {
- TerrainChannel retval = new TerrainChannel();
-
- BinaryReader bs = new BinaryReader(s);
- int y;
- for (y = 0; y < retval.Height; y++)
- {
- int x;
- for (x = 0; x < retval.Width; x++)
- {
- retval[x, y] = bs.ReadSingle();
- }
- }
-
- bs.Close();
-
- return retval;
- }
-
- public void SaveFile(string filename, ITerrainChannel map)
- {
- FileInfo file = new FileInfo(filename);
- FileStream s = file.Open(FileMode.Create, FileAccess.Write);
- SaveStream(s, map);
-
- s.Close();
- }
-
- public void SaveStream(Stream s, ITerrainChannel map)
- {
- BinaryWriter bs = new BinaryWriter(s);
-
- int y;
- for (y = 0; y < map.Height; y++)
- {
- int x;
- for (x = 0; x < map.Width; x++)
- {
- bs.Write((float) map[x, y]);
- }
- }
-
- bs.Close();
- }
-
- #endregion
-
- public override string ToString()
- {
- return "RAW32";
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
deleted file mode 100644
index 0503487..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- internal class TIFF : GenericSystemDrawing
- {
- public override void SaveFile(string filename, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(filename, ImageFormat.Tiff);
- }
-
- ///
- /// Exports a stream using a System.Drawing exporter.
- ///
- /// The target stream
- /// The terrain channel being saved
- public override void SaveStream(Stream stream, ITerrainChannel map)
- {
- Bitmap colours = CreateGrayscaleBitmapFromMap(map);
-
- colours.Save(stream, ImageFormat.Tiff);
- }
-
- public override string ToString()
- {
- return "TIFF";
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
deleted file mode 100644
index 44d03e3..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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.IO;
-using System.Text;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
-{
- ///
- /// Terragen File Format Loader
- /// Built from specification at
- /// http://www.planetside.co.uk/terragen/dev/tgterrain.html
- ///
- internal class Terragen : ITerrainLoader
- {
- #region ITerrainLoader Members
-
- public ITerrainChannel LoadFile(string filename)
- {
- FileInfo file = new FileInfo(filename);
- FileStream s = file.Open(FileMode.Open, FileAccess.Read);
- ITerrainChannel retval = LoadStream(s);
-
- s.Close();
-
- return retval;
- }
-
- public ITerrainChannel LoadStream(Stream s)
- {
- TerrainChannel retval = new TerrainChannel();
-
- BinaryReader bs = new BinaryReader(s);
-
- bool eof = false;
- if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ")
- {
- int w = 256;
- int h = 256;
-
- // Terragen file
- while (eof == false)
- {
- string tmp = Encoding.ASCII.GetString(bs.ReadBytes(4));
- switch (tmp)
- {
- case "SIZE":
- int sztmp = bs.ReadInt16() + 1;
- w = sztmp;
- h = sztmp;
- bs.ReadInt16();
- break;
- case "XPTS":
- w = bs.ReadInt16();
- bs.ReadInt16();
- break;
- case "YPTS":
- h = bs.ReadInt16();
- bs.ReadInt16();
- break;
- case "ALTW":
- eof = true;
- Int16 heightScale = bs.ReadInt16();
- Int16 baseHeight = bs.ReadInt16();
- retval = new TerrainChannel(w, h);
- int x;
- for (x = 0; x < w; x++)
- {
- int y;
- for (y = 0; y < h; y++)
- {
- retval[x, y] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0;
- }
- }
- break;
- default:
- bs.ReadInt32();
- break;
- }
- }
- }
-
- bs.Close();
-
- return retval;
- }
-
- public void SaveFile(string filename, ITerrainChannel map)
- {
- throw new NotImplementedException();
- }
-
- public void SaveStream(Stream stream, ITerrainChannel map)
- {
- throw new NotImplementedException();
- }
-
- public string FileExtension
- {
- get { return ".ter"; }
- }
-
- public ITerrainChannel LoadFile(string filename, int x, int y, int fileWidth, int fileHeight, int w, int h)
- {
- throw new NotImplementedException();
- }
-
- #endregion
-
- public override string ToString()
- {
- return "Terragen";
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs
deleted file mode 100644
index 4d49a70..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/FlattenArea.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes
-{
- public class FlattenArea : ITerrainFloodEffect
- {
- #region ITerrainFloodEffect Members
-
- public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
- {
- double sum = 0.0;
- double steps = 0.0;
-
- int x, y;
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- if (fillArea[x, y])
- {
- sum += map[x, y];
- steps += 1.0;
- }
- }
- }
-
- double avg = sum / steps;
-
- double str = 0.1 * strength; // == 0.2 in the default client
-
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- if (fillArea[x, y])
- map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str);
- }
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs
deleted file mode 100644
index 64f9014..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/LowerArea.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes
-{
- public class LowerArea : ITerrainFloodEffect
- {
- #region ITerrainFloodEffect Members
-
- public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
- {
- int x;
- for (x = 0; x < map.Width; x++)
- {
- int y;
- for (y = 0; y < map.Height; y++)
- {
- if (fillArea[x, y])
- {
- map[x, y] -= strength;
- }
- }
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs
deleted file mode 100644
index 2d44a3a..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/NoiseArea.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes
-{
- public class NoiseArea : ITerrainFloodEffect
- {
- #region ITerrainFloodEffect Members
-
- public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
- {
- int x;
- for (x = 0; x < map.Width; x++)
- {
- int y;
- for (y = 0; y < map.Height; y++)
- {
- if (fillArea[x, y])
- {
- double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0);
-
- map[x, y] += noise * strength;
- }
- }
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs
deleted file mode 100644
index 0c7d016..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RaiseArea.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes
-{
- public class RaiseArea : ITerrainFloodEffect
- {
- #region ITerrainFloodEffect Members
-
- public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
- {
- int x;
- for (x = 0; x < map.Width; x++)
- {
- int y;
- for (y = 0; y < map.Height; y++)
- {
- if (fillArea[x, y])
- {
- map[x, y] += strength;
- }
- }
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs
deleted file mode 100644
index 3f06d82..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/RevertArea.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes
-{
- public class RevertArea : ITerrainFloodEffect
- {
- private readonly ITerrainChannel m_revertmap;
-
- public RevertArea(ITerrainChannel revertmap)
- {
- m_revertmap = revertmap;
- }
-
- #region ITerrainFloodEffect Members
-
- ///
- /// reverts an area of the map to the heightfield stored in the revertmap
- ///
- /// the current heightmap
- /// array indicating which sections of the map are to be reverted
- /// unused
- public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
- {
- int x;
- for (x = 0; x < map.Width; x++)
- {
- int y;
- for (y = 0; y < map.Height; y++)
- {
- if (fillArea[x, y])
- {
- map[x, y] = m_revertmap[x, y];
- }
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs
deleted file mode 100644
index 3881264..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FloodBrushes/SmoothArea.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes
-{
- public class SmoothArea : ITerrainFloodEffect
- {
- #region ITerrainFloodEffect Members
-
- public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
- {
- double area = strength;
- double step = strength / 4.0;
-
- double[,] manipulate = new double[map.Width,map.Height];
- int x, y;
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- if (!fillArea[x, y])
- continue;
-
- double average = 0.0;
- int avgsteps = 0;
-
- double n;
- for (n = 0.0 - area; n < area; n += step)
- {
- double l;
- for (l = 0.0 - area; l < area; l += step)
- {
- avgsteps++;
- average += GetBilinearInterpolate(x + n, y + l, map);
- }
- }
-
- manipulate[x, y] = average / avgsteps;
- }
- }
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- if (!fillArea[x, y])
- continue;
-
- map[x, y] = manipulate[x, y];
- }
- }
- }
-
- #endregion
-
- private static double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
- {
- int w = map.Width;
- int h = map.Height;
-
- if (x > w - 2.0)
- x = w - 2.0;
- if (y > h - 2.0)
- y = h - 2.0;
- if (x < 0.0)
- x = 0.0;
- if (y < 0.0)
- y = 0.0;
-
- const int stepSize = 1;
- double h00 = map[(int) x, (int) y];
- double h10 = map[(int) x + stepSize, (int) y];
- double h01 = map[(int) x, (int) y + stepSize];
- double h11 = map[(int) x + stepSize, (int) y + stepSize];
- double h1 = h00;
- double h2 = h10;
- double h3 = h01;
- double h4 = h11;
- double a00 = h1;
- double a10 = h2 - h1;
- double a01 = h3 - h1;
- double a11 = h1 - h2 - h3 + h4;
- double partialx = x - (int) x;
- double partialz = y - (int) y;
- double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
- return hi;
- }
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs
deleted file mode 100644
index 4533e9e..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainEffect.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain
-{
- public interface ITerrainEffect
- {
- void RunEffect(ITerrainChannel map);
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs
deleted file mode 100644
index 5bae84b..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainFloodEffect.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain
-{
- public interface ITerrainFloodEffect
- {
- void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength);
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs
deleted file mode 100644
index 21bda58..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainLoader.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.IO;
-using OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain
-{
- public interface ITerrainLoader
- {
- string FileExtension { get; }
- ITerrainChannel LoadFile(string filename);
- ITerrainChannel LoadFile(string filename, int fileStartX, int fileStartY, int fileWidth, int fileHeight, int sectionWidth, int sectionHeight);
- ITerrainChannel LoadStream(Stream stream);
- void SaveFile(string filename, ITerrainChannel map);
- void SaveStream(Stream stream, ITerrainChannel map);
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
deleted file mode 100644
index 91bc31f..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainModule.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.IO;
-using OpenMetaverse;
-using OpenSim.Framework;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain
-{
- public interface ITerrainModule
- {
- void LoadFromFile(string filename);
- void SaveToFile(string filename);
- void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId);
-
- ///
- /// Load a terrain from a stream.
- ///
- ///
- /// Only required here to identify the image type. Not otherwise used in the loading itself.
- ///
- ///
- void LoadFromStream(string filename, Stream stream);
-
- ///
- /// Save a terrain to a stream.
- ///
- ///
- /// Only required here to identify the image type. Not otherwise used in the saving itself.
- ///
- ///
- void SaveToStream(string filename, Stream stream);
-
- void InstallPlugin(string name, ITerrainEffect plug);
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs b/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs
deleted file mode 100644
index 7461560..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/ITerrainPaintableEffect.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain
-{
- public interface ITerrainPaintableEffect
- {
- void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z, double strength, double duration);
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
deleted file mode 100644
index 4d694cc..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- ///
- /// Hydraulic Erosion Brush
- ///
- public class ErodeSphere : ITerrainPaintableEffect
- {
- private const double rainHeight = 0.2;
- private const int rounds = 10;
- private const NeighbourSystem type = NeighbourSystem.Moore;
- private const double waterSaturation = 0.30;
-
- #region Supporting Functions
-
- private static int[] Neighbours(NeighbourSystem neighbourType, int index)
- {
- int[] coord = new int[2];
-
- index++;
-
- switch (neighbourType)
- {
- case NeighbourSystem.Moore:
- switch (index)
- {
- case 1:
- coord[0] = -1;
- coord[1] = -1;
- break;
-
- case 2:
- coord[0] = -0;
- coord[1] = -1;
- break;
-
- case 3:
- coord[0] = +1;
- coord[1] = -1;
- break;
-
- case 4:
- coord[0] = -1;
- coord[1] = -0;
- break;
-
- case 5:
- coord[0] = -0;
- coord[1] = -0;
- break;
-
- case 6:
- coord[0] = +1;
- coord[1] = -0;
- break;
-
- case 7:
- coord[0] = -1;
- coord[1] = +1;
- break;
-
- case 8:
- coord[0] = -0;
- coord[1] = +1;
- break;
-
- case 9:
- coord[0] = +1;
- coord[1] = +1;
- break;
-
- default:
- break;
- }
- break;
-
- case NeighbourSystem.VonNeumann:
- switch (index)
- {
- case 1:
- coord[0] = 0;
- coord[1] = -1;
- break;
-
- case 2:
- coord[0] = -1;
- coord[1] = 0;
- break;
-
- case 3:
- coord[0] = +1;
- coord[1] = 0;
- break;
-
- case 4:
- coord[0] = 0;
- coord[1] = +1;
- break;
-
- case 5:
- coord[0] = -0;
- coord[1] = -0;
- break;
-
- default:
- break;
- }
- break;
- }
-
- return coord;
- }
-
- private enum NeighbourSystem
- {
- Moore,
- VonNeumann
- } ;
-
- #endregion
-
- #region ITerrainPaintableEffect Members
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- strength = TerrainUtil.MetersToSphericalStrength(strength);
-
- int x, y;
- // Using one 'rain' round for this, so skipping a useless loop
- // Will need to adapt back in for the Flood brush
-
- ITerrainChannel water = new TerrainChannel(map.Width, map.Height);
- ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height);
-
- // Fill with rain
- for (x = 0; x < water.Width; x++)
- for (y = 0; y < water.Height; y++)
- water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration);
-
- for (int i = 0; i < rounds; i++)
- {
- // Erode underlying terrain
- for (x = 0; x < water.Width; x++)
- {
- for (y = 0; y < water.Height; y++)
- {
- if (mask[x,y])
- {
- const double solConst = (1.0 / rounds);
- double sedDelta = water[x, y] * solConst;
- map[x, y] -= sedDelta;
- sediment[x, y] += sedDelta;
- }
- }
- }
-
- // Move water
- for (x = 0; x < water.Width; x++)
- {
- for (y = 0; y < water.Height; y++)
- {
- if (water[x, y] <= 0)
- continue;
-
- // Step 1. Calculate average of neighbours
-
- int neighbours = 0;
- double altitudeTotal = 0.0;
- double altitudeMe = map[x, y] + water[x, y];
-
- const int NEIGHBOUR_ME = 4;
- const int NEIGHBOUR_MAX = 9;
-
- for (int j = 0; j < NEIGHBOUR_MAX; j++)
- {
- if (j != NEIGHBOUR_ME)
- {
- int[] coords = Neighbours(type, j);
-
- coords[0] += x;
- coords[1] += y;
-
- if (coords[0] > map.Width - 1)
- continue;
- if (coords[1] > map.Height - 1)
- continue;
- if (coords[0] < 0)
- continue;
- if (coords[1] < 0)
- continue;
-
- // Calculate total height of this neighbour
- double altitudeNeighbour = water[coords[0], coords[1]] + map[coords[0], coords[1]];
-
- // If it's greater than me...
- if (altitudeNeighbour - altitudeMe < 0)
- {
- // Add it to our calculations
- neighbours++;
- altitudeTotal += altitudeNeighbour;
- }
- }
- }
-
- if (neighbours == 0)
- continue;
-
- double altitudeAvg = altitudeTotal / neighbours;
-
- // Step 2. Allocate water to neighbours.
- for (int j = 0; j < NEIGHBOUR_MAX; j++)
- {
- if (j != NEIGHBOUR_ME)
- {
- int[] coords = Neighbours(type, j);
-
- coords[0] += x;
- coords[1] += y;
-
- if (coords[0] > map.Width - 1)
- continue;
- if (coords[1] > map.Height - 1)
- continue;
- if (coords[0] < 0)
- continue;
- if (coords[1] < 0)
- continue;
-
- // Skip if we dont have water to begin with.
- if (water[x, y] < 0)
- continue;
-
- // Calculate our delta average
- double altitudeDelta = altitudeMe - altitudeAvg;
-
- if (altitudeDelta < 0)
- continue;
-
- // Calculate how much water we can move
- double waterMin = Math.Min(water[x, y], altitudeDelta);
- double waterDelta = waterMin * ((water[coords[0], coords[1]] + map[coords[0], coords[1]])
- / altitudeTotal);
-
- double sedimentDelta = sediment[x, y] * (waterDelta / water[x, y]);
-
- if (sedimentDelta > 0)
- {
- sediment[x, y] -= sedimentDelta;
- sediment[coords[0], coords[1]] += sedimentDelta;
- }
- }
- }
- }
- }
-
- // Evaporate
-
- for (x = 0; x < water.Width; x++)
- {
- for (y = 0; y < water.Height; y++)
- {
- water[x, y] *= 1.0 - (rainHeight / rounds);
-
- double waterCapacity = waterSaturation * water[x, y];
-
- double sedimentDeposit = sediment[x, y] - waterCapacity;
- if (sedimentDeposit > 0)
- {
- if (mask[x,y])
- {
- sediment[x, y] -= sedimentDeposit;
- map[x, y] += sedimentDeposit;
- }
- }
- }
- }
- }
-
- // Deposit any remainder (should be minimal)
- for (x = 0; x < water.Width; x++)
- for (y = 0; y < water.Height; y++)
- if (mask[x,y] && sediment[x, y] > 0)
- map[x, y] += sediment[x, y];
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
deleted file mode 100644
index 91c030d..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- public class FlattenSphere : ITerrainPaintableEffect
- {
- #region ITerrainPaintableEffect Members
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- strength = TerrainUtil.MetersToSphericalStrength(strength);
-
- int x, y;
-
- if (rz < 0) {
- double sum = 0.0;
- double step2 = 0.0;
- duration = 0.009; //MCP Should be read from ini file
-
-
- // compute delta map
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
-
- if (z > 0) // add in non-zero amount
- {
- sum += map[x, y] * z;
- step2 += z;
- }
- }
- }
- rz = sum / step2;
- }
-
-
- // blend in map
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- if (!mask[x,y])
- continue;
-
- double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration;
-
- if (z > 0) // add in non-zero amount
- {
- if (z > 1.0)
- z = 1.0;
-
- map[x, y] = (map[x, y] * (1.0 - z)) + (rz * z);
- }
-
- double delta = rz - map[x, y];
- if (Math.Abs(delta) > 0.1)
- delta *= 0.25;
-
- if (delta != 0) // add in non-zero amount
- {
- map[x, y] += delta;
- }
-
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
deleted file mode 100644
index d391e94..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- public class LowerSphere : ITerrainPaintableEffect
- {
- #region ITerrainPaintableEffect Members
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- int s = (int) (Math.Pow(2, strength) + 0.5);
-
- int x;
- int xFrom = (int)(rx-s+0.5);
- int xTo = (int)(rx+s+0.5) + 1;
- int yFrom = (int)(ry-s+0.5);
- int yTo = (int)(ry+s+0.5) + 1;
-
- if (xFrom < 0)
- xFrom = 0;
-
- if (yFrom < 0)
- yFrom = 0;
-
- if (xTo > map.Width)
- xTo = map.Width;
-
- if (yTo > map.Width)
- yTo = map.Width;
-
- for (x = xFrom; x < xTo; x++)
- {
- int y;
- for (y = yFrom; y < yTo; y++)
- {
- if (!mask[x,y])
- continue;
-
- // Calculate a cos-sphere and add it to the heighmap
- double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry)));
- double z = Math.Cos(r * Math.PI / (s * 2));
- if (z > 0.0)
- {
- double newz = map[x, y] - z * duration;
- if (newz < 0.0)
- map[x, y] = 0.0;
- else
- map[x, y] = newz;
- }
- }
- }
-
- }
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
deleted file mode 100644
index 32a6869..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- public class NoiseSphere : ITerrainPaintableEffect
- {
- #region ITerrainPaintableEffect Members
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- strength = TerrainUtil.MetersToSphericalStrength(strength);
-
- int x;
- for (x = 0; x < map.Width; x++)
- {
- int y;
- for (y = 0; y < map.Height; y++)
- {
- if (!mask[x,y])
- continue;
-
- // Calculate a sphere and add it to the heighmap
- double z = strength;
- z *= z;
- z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
-
- double noise = TerrainUtil.PerlinNoise2D(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0);
-
- if (z > 0.0)
- map[x, y] += noise * z * duration;
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
deleted file mode 100644
index 86d01d3..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- ///
- /// Speed-Optimised Hybrid Erosion Brush
- ///
- /// As per Jacob Olsen's Paper
- /// http://www.oddlabs.com/download/terrain_generation.pdf
- ///
- public class OlsenSphere : ITerrainPaintableEffect
- {
- private const double nConst = 1024.0;
- private const NeighbourSystem type = NeighbourSystem.Moore;
-
- #region Supporting Functions
-
- private static int[] Neighbours(NeighbourSystem neighbourType, int index)
- {
- int[] coord = new int[2];
-
- index++;
-
- switch (neighbourType)
- {
- case NeighbourSystem.Moore:
- switch (index)
- {
- case 1:
- coord[0] = -1;
- coord[1] = -1;
- break;
-
- case 2:
- coord[0] = -0;
- coord[1] = -1;
- break;
-
- case 3:
- coord[0] = +1;
- coord[1] = -1;
- break;
-
- case 4:
- coord[0] = -1;
- coord[1] = -0;
- break;
-
- case 5:
- coord[0] = -0;
- coord[1] = -0;
- break;
-
- case 6:
- coord[0] = +1;
- coord[1] = -0;
- break;
-
- case 7:
- coord[0] = -1;
- coord[1] = +1;
- break;
-
- case 8:
- coord[0] = -0;
- coord[1] = +1;
- break;
-
- case 9:
- coord[0] = +1;
- coord[1] = +1;
- break;
-
- default:
- break;
- }
- break;
-
- case NeighbourSystem.VonNeumann:
- switch (index)
- {
- case 1:
- coord[0] = 0;
- coord[1] = -1;
- break;
-
- case 2:
- coord[0] = -1;
- coord[1] = 0;
- break;
-
- case 3:
- coord[0] = +1;
- coord[1] = 0;
- break;
-
- case 4:
- coord[0] = 0;
- coord[1] = +1;
- break;
-
- case 5:
- coord[0] = -0;
- coord[1] = -0;
- break;
-
- default:
- break;
- }
- break;
- }
-
- return coord;
- }
-
- private enum NeighbourSystem
- {
- Moore,
- VonNeumann
- } ;
-
- #endregion
-
- #region ITerrainPaintableEffect Members
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- strength = TerrainUtil.MetersToSphericalStrength(strength);
-
- int x;
-
- for (x = 0; x < map.Width; x++)
- {
- int y;
- for (y = 0; y < map.Height; y++)
- {
- if (!mask[x,y])
- continue;
-
- double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
-
- if (z > 0) // add in non-zero amount
- {
- const int NEIGHBOUR_ME = 4;
- const int NEIGHBOUR_MAX = 9;
-
- double max = Double.MinValue;
- int loc = 0;
-
-
- for (int j = 0; j < NEIGHBOUR_MAX; j++)
- {
- if (j != NEIGHBOUR_ME)
- {
- int[] coords = Neighbours(type, j);
-
- coords[0] += x;
- coords[1] += y;
-
- if (coords[0] > map.Width - 1)
- continue;
- if (coords[1] > map.Height - 1)
- continue;
- if (coords[0] < 0)
- continue;
- if (coords[1] < 0)
- continue;
-
- double cellmax = map[x, y] - map[coords[0], coords[1]];
- if (cellmax > max)
- {
- max = cellmax;
- loc = j;
- }
- }
- }
-
- double T = nConst / ((map.Width + map.Height) / 2.0);
- // Apply results
- if (0 < max && max <= T)
- {
- int[] maxCoords = Neighbours(type, loc);
- double heightDelta = 0.5 * max * z * duration;
- map[x, y] -= heightDelta;
- map[x + maxCoords[0], y + maxCoords[1]] += heightDelta;
- }
- }
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
deleted file mode 100644
index a0ff262..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- public class RaiseSphere : ITerrainPaintableEffect
- {
- #region ITerrainPaintableEffect Members
-
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- int s = (int) (Math.Pow(2, strength) + 0.5);
-
- int x;
- int xFrom = (int)(rx-s+0.5);
- int xTo = (int)(rx+s+0.5) + 1;
- int yFrom = (int)(ry-s+0.5);
- int yTo = (int)(ry+s+0.5) + 1;
-
- if (xFrom < 0)
- xFrom = 0;
-
- if (yFrom < 0)
- yFrom = 0;
-
- if (xTo > map.Width)
- xTo = map.Width;
-
- if (yTo > map.Width)
- yTo = map.Width;
-
- for (x = xFrom; x < xTo; x++)
- {
- int y;
- for (y = yFrom; y < yTo; y++)
- {
- if (!mask[x,y])
- continue;
-
- // Calculate a cos-sphere and add it to the heighmap
- double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry)));
- double z = Math.Cos(r * Math.PI / (s * 2));
- if (z > 0.0)
- map[x, y] += z * duration;
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
deleted file mode 100644
index af6d94d..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- public class RevertSphere : ITerrainPaintableEffect
- {
- private readonly ITerrainChannel m_revertmap;
-
- public RevertSphere(ITerrainChannel revertmap)
- {
- m_revertmap = revertmap;
- }
-
- #region ITerrainPaintableEffect Members
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- strength = TerrainUtil.MetersToSphericalStrength(strength);
- duration = 0.03; //MCP Should be read from ini file
-
- if (duration > 1.0)
- duration = 1.0;
- if (duration < 0)
- return;
-
- int x;
- for (x = 0; x < map.Width; x++)
- {
- int y;
- for (y = 0; y < map.Height; y++)
- {
- if (!mask[x,y])
- continue;
-
- // Calculate a sphere and add it to the heighmap
- double z = strength;
- z *= z;
- z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
-
- if (z > 0.0)
- {
- z *= duration;
- map[x, y] = (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z);
- }
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
deleted file mode 100644
index fe270f7..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- public class SmoothSphere : ITerrainPaintableEffect
- {
- #region ITerrainPaintableEffect Members
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- strength = TerrainUtil.MetersToSphericalStrength(strength);
-
- int x, y;
- double[,] tweak = new double[map.Width,map.Height];
-
- double area = strength;
- double step = strength / 4.0;
- duration = 0.03; //MCP Should be read from ini file
-
-
- // compute delta map
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
-
- if (z > 0) // add in non-zero amount
- {
- double average = 0.0;
- int avgsteps = 0;
-
- double n;
- for (n = 0.0 - area; n < area; n += step)
- {
- double l;
- for (l = 0.0 - area; l < area; l += step)
- {
- avgsteps++;
- average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map);
- }
- }
- tweak[x, y] = average / avgsteps;
- }
- }
- }
- // blend in map
- for (x = 0; x < map.Width; x++)
- {
- for (y = 0; y < map.Height; y++)
- {
- if (!mask[x,y])
- continue;
-
- double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
-
- if (z > 0) // add in non-zero amount
- {
- double da = z;
- double a = (map[x, y] - tweak[x, y]) * da;
- double newz = map[x, y] - (a * duration);
-
- if (newz > 0.0)
- map[x, y] = newz;
- }
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
deleted file mode 100644
index faba119..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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 OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
-{
- ///
- /// Thermal Weathering Paint Brush
- ///
- public class WeatherSphere : ITerrainPaintableEffect
- {
- private const double talus = 0.2;
- private const NeighbourSystem type = NeighbourSystem.Moore;
-
- #region Supporting Functions
-
- private static int[] Neighbours(NeighbourSystem neighbourType, int index)
- {
- int[] coord = new int[2];
-
- index++;
-
- switch (neighbourType)
- {
- case NeighbourSystem.Moore:
- switch (index)
- {
- case 1:
- coord[0] = -1;
- coord[1] = -1;
- break;
-
- case 2:
- coord[0] = -0;
- coord[1] = -1;
- break;
-
- case 3:
- coord[0] = +1;
- coord[1] = -1;
- break;
-
- case 4:
- coord[0] = -1;
- coord[1] = -0;
- break;
-
- case 5:
- coord[0] = -0;
- coord[1] = -0;
- break;
-
- case 6:
- coord[0] = +1;
- coord[1] = -0;
- break;
-
- case 7:
- coord[0] = -1;
- coord[1] = +1;
- break;
-
- case 8:
- coord[0] = -0;
- coord[1] = +1;
- break;
-
- case 9:
- coord[0] = +1;
- coord[1] = +1;
- break;
-
- default:
- break;
- }
- break;
-
- case NeighbourSystem.VonNeumann:
- switch (index)
- {
- case 1:
- coord[0] = 0;
- coord[1] = -1;
- break;
-
- case 2:
- coord[0] = -1;
- coord[1] = 0;
- break;
-
- case 3:
- coord[0] = +1;
- coord[1] = 0;
- break;
-
- case 4:
- coord[0] = 0;
- coord[1] = +1;
- break;
-
- case 5:
- coord[0] = -0;
- coord[1] = -0;
- break;
-
- default:
- break;
- }
- break;
- }
-
- return coord;
- }
-
- private enum NeighbourSystem
- {
- Moore,
- VonNeumann
- } ;
-
- #endregion
-
- #region ITerrainPaintableEffect Members
-
- public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
- {
- strength = TerrainUtil.MetersToSphericalStrength(strength);
-
- int x;
-
- for (x = 0; x < map.Width; x++)
- {
- int y;
- for (y = 0; y < map.Height; y++)
- {
- if (!mask[x,y])
- continue;
-
- double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
-
- if (z > 0) // add in non-zero amount
- {
- const int NEIGHBOUR_ME = 4;
- const int NEIGHBOUR_MAX = 9;
-
- for (int j = 0; j < NEIGHBOUR_MAX; j++)
- {
- if (j != NEIGHBOUR_ME)
- {
- int[] coords = Neighbours(type, j);
-
- coords[0] += x;
- coords[1] += y;
-
- if (coords[0] > map.Width - 1)
- continue;
- if (coords[1] > map.Height - 1)
- continue;
- if (coords[0] < 0)
- continue;
- if (coords[1] < 0)
- continue;
-
- double heightF = map[x, y];
- double target = map[coords[0], coords[1]];
-
- if (target > heightF + talus)
- {
- double calc = duration * ((target - heightF) - talus) * z;
- heightF += calc;
- target -= calc;
- }
-
- map[x, y] = heightF;
- map[coords[0], coords[1]] = target;
- }
- }
- }
- }
- }
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs
deleted file mode 100644
index 2411de0..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainException.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain
-{
- public class TerrainException : Exception
- {
- public TerrainException()
- {
- }
-
- public TerrainException(string msg) : base(msg)
- {
- }
-
- public TerrainException(string msg, Exception e) : base(msg, e)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
deleted file mode 100644
index bc601dc..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ /dev/null
@@ -1,1001 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using OpenMetaverse;
-using log4net;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander;
-using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
-using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes;
-using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain
-{
- public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule
- {
- #region StandardTerrainEffects enum
-
- ///
- /// A standard set of terrain brushes and effects recognised by viewers
- ///
- public enum StandardTerrainEffects : byte
- {
- Flatten = 0,
- Raise = 1,
- Lower = 2,
- Smooth = 3,
- Noise = 4,
- Revert = 5,
-
- // Extended brushes
- Erode = 255,
- Weather = 254,
- Olsen = 253
- }
-
- #endregion
-
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private readonly Commander m_commander = new Commander("terrain");
-
- private readonly Dictionary m_floodeffects =
- new Dictionary();
-
- private readonly Dictionary m_loaders = new Dictionary();
-
- private readonly Dictionary m_painteffects =
- new Dictionary();
-
- private ITerrainChannel m_channel;
- private Dictionary m_plugineffects;
- private ITerrainChannel m_revert;
- private Scene m_scene;
- private bool m_tainted;
-
- #region ICommandableModule Members
-
- public ICommander CommandInterface
- {
- get { return m_commander; }
- }
-
- #endregion
-
- #region IRegionModule Members
-
- ///
- /// Creates and initialises a terrain module for a region
- ///
- /// Region initialising
- /// Config for the region
- public void Initialise(Scene scene, IConfigSource config)
- {
- m_scene = scene;
-
- // Install terrain module in the simulator
- if (m_scene.Heightmap == null)
- {
- lock (m_scene)
- {
- m_channel = new TerrainChannel();
- m_scene.Heightmap = m_channel;
- m_revert = new TerrainChannel();
- UpdateRevertMap();
- }
- }
- else
- {
- m_channel = m_scene.Heightmap;
- m_revert = new TerrainChannel();
- UpdateRevertMap();
- }
-
- m_scene.RegisterModuleInterface(this);
- m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
- m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
- m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
- }
-
- ///
- /// Enables terrain module when called
- ///
- public void PostInitialise()
- {
- InstallDefaultEffects();
- InstallInterfaces();
- LoadPlugins();
- }
-
- public void Close()
- {
- }
-
- public string Name
- {
- get { return "TerrainModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return false; }
- }
-
- #endregion
-
- #region ITerrainModule Members
-
- ///
- /// Loads a terrain file from disk and installs it in the scene.
- ///
- /// Filename to terrain file. Type is determined by extension.
- public void LoadFromFile(string filename)
- {
- foreach (KeyValuePair loader in m_loaders)
- {
- if (filename.EndsWith(loader.Key))
- {
- lock (m_scene)
- {
- try
- {
- ITerrainChannel channel = loader.Value.LoadFile(filename);
- if (channel.Width != Constants.RegionSize || channel.Height != Constants.RegionSize)
- {
- // TerrainChannel expects a RegionSize x RegionSize map, currently
- throw new ArgumentException(String.Format("wrong size, use a file with size {0} x {1}",
- Constants.RegionSize, Constants.RegionSize));
- }
- m_log.DebugFormat("[TERRAIN]: Loaded terrain, wd/ht: {0}/{1}", channel.Width, channel.Height);
- m_scene.Heightmap = channel;
- m_channel = channel;
- UpdateRevertMap();
- }
- catch (NotImplementedException)
- {
- m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value +
- " parser does not support file loading. (May be save only)");
- throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value));
- }
- catch (FileNotFoundException)
- {
- m_log.Error(
- "[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)");
- throw new TerrainException(
- String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", filename));
- }
- catch (ArgumentException e)
- {
- m_log.ErrorFormat("[TERRAIN]: Unable to load heightmap: {0}", e.Message);
- throw new TerrainException(
- String.Format("Unable to load heightmap: {0}", e.Message));
- }
- }
- CheckForTerrainUpdates();
- m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
- return;
- }
- }
-
- m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader available for that format.");
- throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
- }
-
- ///
- /// Saves the current heightmap to a specified file.
- ///
- /// The destination filename
- public void SaveToFile(string filename)
- {
- try
- {
- foreach (KeyValuePair loader in m_loaders)
- {
- if (filename.EndsWith(loader.Key))
- {
- loader.Value.SaveFile(filename, m_channel);
- return;
- }
- }
- }
- catch (NotImplementedException)
- {
- m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented.");
- throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented"));
- }
- }
-
- ///
- /// Loads a terrain file from a stream and installs it in the scene.
- ///
- /// Filename to terrain file. Type is determined by extension.
- ///
- public void LoadFromStream(string filename, Stream stream)
- {
- foreach (KeyValuePair loader in m_loaders)
- {
- if (@filename.EndsWith(loader.Key))
- {
- lock (m_scene)
- {
- try
- {
- ITerrainChannel channel = loader.Value.LoadStream(stream);
- m_scene.Heightmap = channel;
- m_channel = channel;
- UpdateRevertMap();
- }
- catch (NotImplementedException)
- {
- m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value +
- " parser does not support file loading. (May be save only)");
- throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value));
- }
- }
-
- CheckForTerrainUpdates();
- m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
- return;
- }
- }
- m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader available for that format.");
- throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
- }
-
- ///
- /// Modify Land
- ///
- /// Land-position (X,Y,0)
- /// The size of the brush (0=small, 1=medium, 2=large)
- /// 0=LAND_LEVEL, 1=LAND_RAISE, 2=LAND_LOWER, 3=LAND_SMOOTH, 4=LAND_NOISE, 5=LAND_REVERT
- /// UUID of script-owner
- public void ModifyTerrain(UUID user, Vector3 pos, byte size, byte action, UUID agentId)
- {
- client_OnModifyTerrain(user, (float)pos.Z, (float)0.25, size, action, pos.Y, pos.X, pos.Y, pos.X, agentId);
- }
-
- ///
- /// Saves the current heightmap to a specified stream.
- ///
- /// The destination filename. Used here only to identify the image type
- ///
- public void SaveToStream(string filename, Stream stream)
- {
- try
- {
- foreach (KeyValuePair loader in m_loaders)
- {
- if (filename.EndsWith(loader.Key))
- {
- loader.Value.SaveStream(stream, m_channel);
- return;
- }
- }
- }
- catch (NotImplementedException)
- {
- m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented.");
- throw new TerrainException(String.Format("Unable to save heightmap: saving of this file format not implemented"));
- }
- }
-
- #region Plugin Loading Methods
-
- private void LoadPlugins()
- {
- m_plugineffects = new Dictionary();
- // Load the files in the Terrain/ dir
- string[] files = Directory.GetFiles("Terrain");
- foreach (string file in files)
- {
- m_log.Info("Loading effects in " + file);
- try
- {
- Assembly library = Assembly.LoadFrom(file);
- foreach (Type pluginType in library.GetTypes())
- {
- try
- {
- if (pluginType.IsAbstract || pluginType.IsNotPublic)
- continue;
-
- string typeName = pluginType.Name;
-
- if (pluginType.GetInterface("ITerrainEffect", false) != null)
- {
- ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString()));
-
- InstallPlugin(typeName, terEffect);
- }
- else if (pluginType.GetInterface("ITerrainLoader", false) != null)
- {
- ITerrainLoader terLoader = (ITerrainLoader) Activator.CreateInstance(library.GetType(pluginType.ToString()));
- m_loaders[terLoader.FileExtension] = terLoader;
- m_log.Info("L ... " + typeName);
- }
- }
- catch (AmbiguousMatchException)
- {
- }
- }
- }
- catch (BadImageFormatException)
- {
- }
- }
- }
-
- public void InstallPlugin(string pluginName, ITerrainEffect effect)
- {
- lock (m_plugineffects)
- {
- if (!m_plugineffects.ContainsKey(pluginName))
- {
- m_plugineffects.Add(pluginName, effect);
- m_log.Info("E ... " + pluginName);
- }
- else
- {
- m_plugineffects[pluginName] = effect;
- m_log.Warn("E ... " + pluginName + " (Replaced)");
- }
- }
- }
-
- #endregion
-
- #endregion
-
- ///
- /// Installs into terrain module the standard suite of brushes
- ///
- private void InstallDefaultEffects()
- {
- // Draggable Paint Brush Effects
- m_painteffects[StandardTerrainEffects.Raise] = new RaiseSphere();
- m_painteffects[StandardTerrainEffects.Lower] = new LowerSphere();
- m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere();
- m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere();
- m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere();
- m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_revert);
- m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere();
- m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere();
- m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere();
-
- // Area of effect selection effects
- m_floodeffects[StandardTerrainEffects.Raise] = new RaiseArea();
- m_floodeffects[StandardTerrainEffects.Lower] = new LowerArea();
- m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea();
- m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea();
- m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea();
- m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_revert);
-
- // Filesystem load/save loaders
- m_loaders[".r32"] = new RAW32();
- m_loaders[".f32"] = m_loaders[".r32"];
- m_loaders[".ter"] = new Terragen();
- m_loaders[".raw"] = new LLRAW();
- m_loaders[".jpg"] = new JPEG();
- m_loaders[".jpeg"] = m_loaders[".jpg"];
- m_loaders[".bmp"] = new BMP();
- m_loaders[".png"] = new PNG();
- m_loaders[".gif"] = new GIF();
- m_loaders[".tif"] = new TIFF();
- m_loaders[".tiff"] = m_loaders[".tif"];
- }
-
- ///
- /// Saves the current state of the region into the revert map buffer.
- ///
- public void UpdateRevertMap()
- {
- int x;
- for (x = 0; x < m_channel.Width; x++)
- {
- int y;
- for (y = 0; y < m_channel.Height; y++)
- {
- m_revert[x, y] = m_channel[x, y];
- }
- }
- }
-
- ///
- /// Loads a tile from a larger terrain file and installs it into the region.
- ///
- /// The terrain file to load
- /// The width of the file in units
- /// The height of the file in units
- /// Where to begin our slice
- /// Where to begin our slice
- public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY)
- {
- int offsetX = (int) m_scene.RegionInfo.RegionLocX - fileStartX;
- int offsetY = (int) m_scene.RegionInfo.RegionLocY - fileStartY;
-
- if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight)
- {
- // this region is included in the tile request
- foreach (KeyValuePair loader in m_loaders)
- {
- if (filename.EndsWith(loader.Key))
- {
- lock (m_scene)
- {
- ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY,
- fileWidth, fileHeight,
- (int) Constants.RegionSize,
- (int) Constants.RegionSize);
- m_scene.Heightmap = channel;
- m_channel = channel;
- UpdateRevertMap();
- }
- return;
- }
- }
- }
- }
-
- ///
- /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections
- ///
- private void EventManager_OnTerrainTick()
- {
- if (m_tainted)
- {
- m_tainted = false;
- m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised());
- m_scene.SaveTerrain();
-
- // Clients who look at the map will never see changes after they looked at the map, so i've commented this out.
- //m_scene.CreateTerrainTexture(true);
- }
- }
-
- ///
- /// Processes commandline input. Do not call directly.
- ///
- /// Commandline arguments
- private void EventManager_OnPluginConsole(string[] args)
- {
- if (args[0] == "terrain")
- {
- 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);
- }
- }
-
- ///
- /// Installs terrain brush hook to IClientAPI
- ///
- ///
- private void EventManager_OnNewClient(IClientAPI client)
- {
- client.OnModifyTerrain += client_OnModifyTerrain;
- client.OnBakeTerrain += client_OnBakeTerrain;
- }
-
- ///
- /// Checks to see if the terrain has been modified since last check
- /// but won't attempt to limit those changes to the limits specified in the estate settings
- /// currently invoked by the command line operations in the region server only
- ///
- private void CheckForTerrainUpdates()
- {
- CheckForTerrainUpdates(false);
- }
-
- ///
- /// Checks to see if the terrain has been modified since last check.
- /// If it has been modified, every all the terrain patches are sent to the client.
- /// If the call is asked to respect the estate settings for terrain_raise_limit and
- /// terrain_lower_limit, it will clamp terrain updates between these values
- /// currently invoked by client_OnModifyTerrain only and not the Commander interfaces
- /// should height map deltas be limited to the estate settings limits
- ///
- private void CheckForTerrainUpdates(bool respectEstateSettings)
- {
- bool shouldTaint = false;
- float[] serialised = m_channel.GetFloatsSerialised();
- int x;
- for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize)
- {
- int y;
- for (y = 0; y < m_channel.Height; y += Constants.TerrainPatchSize)
- {
- if (m_channel.Tainted(x, y))
- {
- // if we should respect the estate settings then
- // fixup and height deltas that don't respect them
- if (respectEstateSettings && LimitChannelChanges(x, y))
- {
- // this has been vetoed, so update
- // what we are going to send to the client
- serialised = m_channel.GetFloatsSerialised();
- }
-
- SendToClients(serialised, x, y);
- shouldTaint = true;
- }
- }
- }
- if (shouldTaint)
- {
- m_tainted = true;
- }
- }
-
- ///
- /// Checks to see height deltas in the tainted terrain patch at xStart ,yStart
- /// are all within the current estate limits
- /// true if changes were limited, false otherwise
- ///
- private bool LimitChannelChanges(int xStart, int yStart)
- {
- bool changesLimited = false;
- double minDelta = m_scene.RegionInfo.RegionSettings.TerrainLowerLimit;
- double maxDelta = m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
-
- // loop through the height map for this patch and compare it against
- // the revert map
- for (int x = xStart; x < xStart + Constants.TerrainPatchSize; x++)
- {
- for (int y = yStart; y < yStart + Constants.TerrainPatchSize; y++)
- {
-
- double requestedHeight = m_channel[x, y];
- double bakedHeight = m_revert[x, y];
- double requestedDelta = requestedHeight - bakedHeight;
-
- if (requestedDelta > maxDelta)
- {
- m_channel[x, y] = bakedHeight + maxDelta;
- changesLimited = true;
- }
- else if (requestedDelta < minDelta)
- {
- m_channel[x, y] = bakedHeight + minDelta; //as lower is a -ve delta
- changesLimited = true;
- }
- }
- }
-
- return changesLimited;
- }
-
- ///
- /// Sends a copy of the current terrain to the scenes clients
- ///
- /// A copy of the terrain as a 1D float array of size w*h
- /// The patch corner to send
- /// The patch corner to send
- private void SendToClients(float[] serialised, int x, int y)
- {
- m_scene.ForEachClient(
- delegate(IClientAPI controller)
- { controller.SendLayerData(
- x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised);
- }
- );
- }
-
- private void client_OnModifyTerrain(UUID user, float height, float seconds, byte size, byte action,
- float north, float west, float south, float east, UUID agentId)
- {
- bool god = m_scene.Permissions.IsGod(user);
- bool allowed = false;
- if (north == south && east == west)
- {
- if (m_painteffects.ContainsKey((StandardTerrainEffects) action))
- {
- bool[,] allowMask = new bool[m_channel.Width,m_channel.Height];
- allowMask.Initialize();
- int n = size + 1;
- if (n > 2)
- n = 4;
-
- int zx = (int) (west + 0.5);
- int zy = (int) (north + 0.5);
-
- int dx;
- for (dx=-n; dx<=n; dx++)
- {
- int dy;
- for (dy=-n; dy<=n; dy++)
- {
- int x = zx + dx;
- int y = zy + dy;
- if (x>=0 && y>=0 && x west)
- {
- if (y < north && y > south)
- {
- if (m_scene.Permissions.CanTerraformLand(agentId, new Vector3(x,y,0)))
- {
- fillArea[x, y] = true;
- allowed = true;
- }
- }
- }
- }
- }
-
- if (allowed)
- {
- m_floodeffects[(StandardTerrainEffects) action].FloodEffect(
- m_channel, fillArea, size);
-
- CheckForTerrainUpdates(!god); //revert changes outside estate limits
- }
- }
- else
- {
- m_log.Debug("Unknown terrain flood type " + action);
- }
- }
- }
-
- private void client_OnBakeTerrain(IClientAPI remoteClient)
- {
- // Not a good permissions check (see client_OnModifyTerrain above), need to check the entire area.
- // for now check a point in the centre of the region
-
- if (m_scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, true))
- {
- InterfaceBakeTerrain(null); //bake terrain does not use the passed in parameter
- }
- }
-
- #region Console Commands
-
- private void InterfaceLoadFile(Object[] args)
- {
- LoadFromFile((string) args[0]);
- CheckForTerrainUpdates();
- }
-
- private void InterfaceLoadTileFile(Object[] args)
- {
- LoadFromFile((string) args[0],
- (int) args[1],
- (int) args[2],
- (int) args[3],
- (int) args[4]);
- CheckForTerrainUpdates();
- }
-
- private void InterfaceSaveFile(Object[] args)
- {
- SaveToFile((string) args[0]);
- }
-
- private void InterfaceBakeTerrain(Object[] args)
- {
- UpdateRevertMap();
- }
-
- private void InterfaceRevertTerrain(Object[] args)
- {
- int x, y;
- for (x = 0; x < m_channel.Width; x++)
- for (y = 0; y < m_channel.Height; y++)
- m_channel[x, y] = m_revert[x, y];
-
- CheckForTerrainUpdates();
- }
-
- private void InterfaceFlipTerrain(Object[] args)
- {
- String direction = (String)args[0];
-
- if (direction.ToLower().StartsWith("y"))
- {
- for (int x = 0; x < Constants.RegionSize; x++)
- {
- for (int y = 0; y < Constants.RegionSize / 2; y++)
- {
- double height = m_channel[x, y];
- double flippedHeight = m_channel[x, (int)Constants.RegionSize - 1 - y];
- m_channel[x, y] = flippedHeight;
- m_channel[x, (int)Constants.RegionSize - 1 - y] = height;
-
- }
- }
- }
- else if (direction.ToLower().StartsWith("x"))
- {
- for (int y = 0; y < Constants.RegionSize; y++)
- {
- for (int x = 0; x < Constants.RegionSize / 2; x++)
- {
- double height = m_channel[x, y];
- double flippedHeight = m_channel[(int)Constants.RegionSize - 1 - x, y];
- m_channel[x, y] = flippedHeight;
- m_channel[(int)Constants.RegionSize - 1 - x, y] = height;
-
- }
- }
- }
- else
- {
- m_log.Error("Unrecognised direction - need x or y");
- }
-
-
- CheckForTerrainUpdates();
- }
-
- private void InterfaceElevateTerrain(Object[] args)
- {
- int x, y;
- for (x = 0; x < m_channel.Width; x++)
- for (y = 0; y < m_channel.Height; y++)
- m_channel[x, y] += (double) args[0];
- CheckForTerrainUpdates();
- }
-
- private void InterfaceMultiplyTerrain(Object[] args)
- {
- int x, y;
- for (x = 0; x < m_channel.Width; x++)
- for (y = 0; y < m_channel.Height; y++)
- m_channel[x, y] *= (double) args[0];
- CheckForTerrainUpdates();
- }
-
- private void InterfaceLowerTerrain(Object[] args)
- {
- int x, y;
- for (x = 0; x < m_channel.Width; x++)
- for (y = 0; y < m_channel.Height; y++)
- m_channel[x, y] -= (double) args[0];
- CheckForTerrainUpdates();
- }
-
- private void InterfaceFillTerrain(Object[] args)
- {
- int x, y;
-
- for (x = 0; x < m_channel.Width; x++)
- for (y = 0; y < m_channel.Height; y++)
- m_channel[x, y] = (double) args[0];
- CheckForTerrainUpdates();
- }
-
- private void InterfaceShowDebugStats(Object[] args)
- {
- double max = Double.MinValue;
- double min = double.MaxValue;
- double sum = 0;
-
- int x;
- for (x = 0; x < m_channel.Width; x++)
- {
- int y;
- for (y = 0; y < m_channel.Height; y++)
- {
- sum += m_channel[x, y];
- if (max < m_channel[x, y])
- max = m_channel[x, y];
- if (min > m_channel[x, y])
- min = m_channel[x, y];
- }
- }
-
- double avg = sum / (m_channel.Height * m_channel.Width);
-
- m_log.Info("Channel " + m_channel.Width + "x" + m_channel.Height);
- m_log.Info("max/min/avg/sum: " + max + "/" + min + "/" + avg + "/" + sum);
- }
-
- private void InterfaceEnableExperimentalBrushes(Object[] args)
- {
- if ((bool) args[0])
- {
- m_painteffects[StandardTerrainEffects.Revert] = new WeatherSphere();
- m_painteffects[StandardTerrainEffects.Flatten] = new OlsenSphere();
- m_painteffects[StandardTerrainEffects.Smooth] = new ErodeSphere();
- }
- else
- {
- InstallDefaultEffects();
- }
- }
-
- private void InterfaceRunPluginEffect(Object[] args)
- {
- if ((string) args[0] == "list")
- {
- m_log.Info("List of loaded plugins");
- foreach (KeyValuePair kvp in m_plugineffects)
- {
- m_log.Info(kvp.Key);
- }
- return;
- }
- if ((string) args[0] == "reload")
- {
- LoadPlugins();
- return;
- }
- if (m_plugineffects.ContainsKey((string) args[0]))
- {
- m_plugineffects[(string) args[0]].RunEffect(m_channel);
- CheckForTerrainUpdates();
- }
- else
- {
- m_log.Warn("No such plugin effect loaded.");
- }
- }
-
- private void InstallInterfaces()
- {
- // Load / Save
- string supportedFileExtensions = "";
- foreach (KeyValuePair loader in m_loaders)
- supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")";
-
- Command loadFromFileCommand =
- new Command("load", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadFile, "Loads a terrain from a specified file.");
- loadFromFileCommand.AddArgument("filename",
- "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
- supportedFileExtensions, "String");
-
- Command saveToFileCommand =
- new Command("save", CommandIntentions.COMMAND_NON_HAZARDOUS, InterfaceSaveFile, "Saves the current heightmap to a specified file.");
- saveToFileCommand.AddArgument("filename",
- "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " +
- supportedFileExtensions, "String");
-
- Command loadFromTileCommand =
- new Command("load-tile", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLoadTileFile, "Loads a terrain from a section of a larger file.");
- loadFromTileCommand.AddArgument("filename",
- "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
- supportedFileExtensions, "String");
- loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
- loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
- loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",
- "Integer");
- loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
- "Integer");
-
- // Terrain adjustments
- Command fillRegionCommand =
- new Command("fill", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
- fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.",
- "Double");
-
- Command elevateCommand =
- new Command("elevate", CommandIntentions.COMMAND_HAZARDOUS, InterfaceElevateTerrain, "Raises the current heightmap by the specified amount.");
- elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double");
-
- Command lowerCommand =
- new Command("lower", CommandIntentions.COMMAND_HAZARDOUS, InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount.");
- lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double");
-
- Command multiplyCommand =
- new Command("multiply", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified.");
- multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double");
-
- Command bakeRegionCommand =
- new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions revert map.");
- Command revertRegionCommand =
- new Command("revert", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap.");
-
- Command flipCommand =
- new Command("flip", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFlipTerrain, "Flips the current terrain about the X or Y axis");
- flipCommand.AddArgument("direction", "[x|y] the direction to flip the terrain in", "String");
-
- // Debug
- Command showDebugStatsCommand =
- new Command("stats", CommandIntentions.COMMAND_STATISTICAL, InterfaceShowDebugStats,
- "Shows some information about the regions heightmap for debugging purposes.");
-
- Command experimentalBrushesCommand =
- new Command("newbrushes", CommandIntentions.COMMAND_HAZARDOUS, InterfaceEnableExperimentalBrushes,
- "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time.");
- experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean");
-
- //Plugins
- Command pluginRunCommand =
- new Command("effect", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRunPluginEffect, "Runs a specified plugin effect");
- pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String");
-
- m_commander.RegisterCommand("load", loadFromFileCommand);
- m_commander.RegisterCommand("load-tile", loadFromTileCommand);
- m_commander.RegisterCommand("save", saveToFileCommand);
- m_commander.RegisterCommand("fill", fillRegionCommand);
- m_commander.RegisterCommand("elevate", elevateCommand);
- m_commander.RegisterCommand("lower", lowerCommand);
- m_commander.RegisterCommand("multiply", multiplyCommand);
- m_commander.RegisterCommand("bake", bakeRegionCommand);
- m_commander.RegisterCommand("revert", revertRegionCommand);
- m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand);
- m_commander.RegisterCommand("stats", showDebugStatsCommand);
- m_commander.RegisterCommand("effect", pluginRunCommand);
- m_commander.RegisterCommand("flip", flipCommand);
-
- // Add this to our scene so scripts can call these functions
- m_scene.RegisterModuleCommander(m_commander);
- }
-
- #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
deleted file mode 100644
index 2acd5bc..0000000
--- a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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 NUnit.Framework;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
-
-namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests
-{
- [TestFixture]
- public class TerrainTest
- {
- [Test]
- public void BrushTest()
- {
- bool[,] allowMask = new bool[256, 256];
- int x;
- int y;
- for (x=0; x<128; x++)
- {
- for (y=0; y<256; y++)
- {
- allowMask[x,y] = true;
- }
- }
-
- //
- // Test RaiseSphere
- //
- TerrainChannel map = new TerrainChannel(256, 256);
- ITerrainPaintableEffect effect = new RaiseSphere();
-
- effect.PaintEffect(map, allowMask, 128.0, 128.0, -1.0, 2, 0.1);
- Assert.That(map[127, 128] > 0.0, "Raise brush should raising value at this point (127,128).");
- Assert.That(map[124, 128] > 0.0, "Raise brush should raising value at this point (124,128).");
- Assert.That(map[123, 128] == 0.0, "Raise brush should not change value at this point (123,128).");
- Assert.That(map[128, 128] == 0.0, "Raise brush should not change value at this point (128,128).");
- Assert.That(map[0, 128] == 0.0, "Raise brush should not change value at this point (0,128).");
-
- //
- // Test LowerSphere
- //
- map = new TerrainChannel(256, 256);
- for (x=0; x= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
- Assert.That(map[127, 128] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
- Assert.That(map[124, 128] < 1.0, "Lower brush should lowering value at this point (124,128).");
- Assert.That(map[123, 128] == 1.0, "Lower brush should not change value at this point (123,128).");
- Assert.That(map[128, 128] == 1.0, "Lower brush should not change value at this point (128,128).");
- Assert.That(map[0, 128] == 1.0, "Lower brush should not change value at this point (0,128).");
- }
-
- [Test]
- public void TerrainChannelTest()
- {
- TerrainChannel x = new TerrainChannel(256, 256);
- Assert.That(x[0, 0] == 0.0, "Terrain not initialising correctly.");
-
- x[0, 0] = 1.0;
- Assert.That(x[0, 0] == 1.0, "Terrain not setting values correctly.");
-
- x[0, 0] = 0;
- x[0, 0] += 5.0;
- x[0, 0] -= 1.0;
- Assert.That(x[0, 0] == 4.0, "Terrain addition/subtraction error.");
-
- x[0, 0] = Math.PI;
- double[,] doublesExport = x.GetDoubles();
- Assert.That(doublesExport[0, 0] == Math.PI, "Export to double[,] array not working correctly.");
-
- x[0, 0] = 1.0;
- float[] floatsExport = x.GetFloatsSerialised();
- Assert.That(floatsExport[0] == 1.0f, "Export to float[] not working correctly.");
-
- x[0, 0] = 1.0;
- Assert.That(x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
- Assert.That(!x.Tainted(0, 0), "Terrain channel tainting not working correctly.");
-
- TerrainChannel y = x.Copy();
- Assert.That(!ReferenceEquals(x, y), "Terrain copy not duplicating correctly.");
- Assert.That(!ReferenceEquals(x.GetDoubles(), y.GetDoubles()), "Terrain array not duplicating correctly.");
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
deleted file mode 100644
index 8a49540..0000000
--- a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * 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.Collections.Generic;
-using System.Reflection;
-using System.Timers;
-using OpenMetaverse;
-using log4net;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.TreePopulator
-{
- ///
- /// Version 2.0 - Very hacky compared to the original. Will fix original and release as 0.3 later.
- ///
- public class TreePopulatorModule : IRegionModule
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private Scene m_scene;
-
- public double m_tree_density = 50.0; // Aim for this many per region
- public double m_tree_updates = 1000.0; // MS between updates
- private bool m_active_trees = false;
- private List m_trees;
- Timer CalculateTrees;
-
- #region IRegionModule Members
-
- public void Initialise(Scene scene, IConfigSource config)
- {
- try
- {
- m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density);
- m_active_trees = config.Configs["Trees"].GetBoolean("active_trees", m_active_trees);
- }
- catch (Exception)
- {
- }
-
- m_trees = new List();
- m_scene = scene;
-
- m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
-
- if (m_active_trees)
- activeizeTreeze(true);
-
- m_log.Debug("[TREES]: Initialised tree module");
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- }
-
- public string Name
- {
- get { return "TreePopulatorModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return false; }
- }
-
- #endregion
-
- private void EventManager_OnPluginConsole(string[] args)
- {
- if (args.Length == 1)
- {
- if (args[0] == "tree")
- {
- UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
- if (uuid == UUID.Zero)
- uuid = m_scene.RegionInfo.MasterAvatarAssignedUUID;
- m_log.Debug("[TREES]: New tree planting");
- CreateTree(uuid, new Vector3(128.0f, 128.0f, 0.0f));
-
- }
- }
-
- if (args.Length == 2 || args.Length == 3)
- {
- if (args[1] == "active")
- {
- if (args.Length >= 3)
- {
- if (args[2] == "true" && !m_active_trees)
- {
- m_active_trees = true;
- activeizeTreeze(m_active_trees);
- m_log.Info("[TREES]: Activizing Trees");
- }
- if (args[2] == "false" && m_active_trees)
- {
- m_active_trees = false;
- activeizeTreeze(m_active_trees);
- m_log.Info("[TREES]: Trees no longer Active, for now...");
- }
- }
- else
- {
- m_log.Info("[TREES]: When setting the tree module active via the console, you must specify true or false");
- }
- }
- }
-
- }
-
- private void activeizeTreeze(bool activeYN)
- {
- if (activeYN)
- {
- CalculateTrees = new Timer(m_tree_updates);
- CalculateTrees.Elapsed += CalculateTrees_Elapsed;
- CalculateTrees.Start();
- }
- else
- {
- CalculateTrees.Stop();
- }
- }
-
- private void growTrees()
- {
- foreach (UUID tree in m_trees)
- {
- if (m_scene.Entities.ContainsKey(tree))
- {
- SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
-
- // 100 seconds to grow 1m
- s_tree.Scale += new Vector3(0.1f, 0.1f, 0.1f);
- s_tree.SendFullUpdateToAllClients();
- //s_tree.ScheduleTerseUpdate();
- }
- else
- {
- m_trees.Remove(tree);
- }
- }
- }
-
- private void seedTrees()
- {
- foreach (UUID tree in m_trees)
- {
- if (m_scene.Entities.ContainsKey(tree))
- {
- SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
-
- if (s_tree.Scale.X > 0.5)
- {
- if (Util.RandomClass.NextDouble() > 0.75)
- {
- SpawnChild(s_tree);
- }
- }
- }
- else
- {
- m_trees.Remove(tree);
- }
- }
- }
-
- private void killTrees()
- {
- foreach (UUID tree in m_trees)
- {
- double killLikelyhood = 0.0;
-
- if (m_scene.Entities.ContainsKey(tree))
- {
- SceneObjectPart selectedTree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
- double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) +
- Math.Pow(selectedTree.Scale.Y, 2) +
- Math.Pow(selectedTree.Scale.Z, 2));
-
- foreach (UUID picktree in m_trees)
- {
- if (picktree != tree)
- {
- SceneObjectPart pickedTree = ((SceneObjectGroup) m_scene.Entities[picktree]).RootPart;
-
- double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) +
- Math.Pow(pickedTree.Scale.Y, 2) +
- Math.Pow(pickedTree.Scale.Z, 2));
-
- double pickedTreeDistance = Math.Sqrt(Math.Pow(Math.Abs(pickedTree.AbsolutePosition.X - selectedTree.AbsolutePosition.X), 2) +
- Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Y - selectedTree.AbsolutePosition.Y), 2) +
- Math.Pow(Math.Abs(pickedTree.AbsolutePosition.Z - selectedTree.AbsolutePosition.Z), 2));
-
- killLikelyhood += (selectedTreeScale / (pickedTreeScale * pickedTreeDistance)) * 0.1;
- }
- }
-
- if (Util.RandomClass.NextDouble() < killLikelyhood)
- {
- m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
- m_trees.Remove(selectedTree.ParentGroup.UUID);
-
- m_scene.ForEachClient(delegate(IClientAPI controller)
- {
- controller.SendKillObject(m_scene.RegionInfo.RegionHandle,
- selectedTree.LocalId);
- });
-
- break;
- }
- selectedTree.SetText(killLikelyhood.ToString(), new Vector3(1.0f, 1.0f, 1.0f), 1.0);
- }
- else
- {
- m_trees.Remove(tree);
- }
- }
- }
-
- private void SpawnChild(SceneObjectPart s_tree)
- {
- Vector3 position = new Vector3();
-
- position.X = s_tree.AbsolutePosition.X + (1 * (-1 * Util.RandomClass.Next(1)));
- if (position.X > 255)
- position.X = 255;
- if (position.X < 0)
- position.X = 0;
- position.Y = s_tree.AbsolutePosition.Y + (1 * (-1 * Util.RandomClass.Next(1)));
- if (position.Y > 255)
- position.Y = 255;
- if (position.Y < 0)
- position.Y = 0;
-
- double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
- double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
-
- position.X += (float) randX;
- position.Y += (float) randY;
-
- UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
- if (uuid == UUID.Zero)
- uuid = m_scene.RegionInfo.MasterAvatarAssignedUUID;
-
- CreateTree(uuid, position);
- }
-
- private void CreateTree(UUID uuid, Vector3 position)
- {
- position.Z = (float) m_scene.Heightmap[(int) position.X, (int) position.Y];
-
- IVegetationModule module = m_scene.RequestModuleInterface();
-
- if (null == module)
- return;
-
- SceneObjectGroup tree
- = module.AddTree(
- uuid, UUID.Zero, new Vector3(0.1f, 0.1f, 0.1f), Quaternion.Identity, position, Tree.Cypress1, false);
-
- m_trees.Add(tree.UUID);
- tree.SendGroupFullUpdate();
- }
-
- private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e)
- {
- growTrees();
- seedTrees();
- killTrees();
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/Environment/Modules/World/Vegetation/VegetationModule.cs
deleted file mode 100644
index 4c4ca0d..0000000
--- a/OpenSim/Region/Environment/Modules/World/Vegetation/VegetationModule.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.Reflection;
-using log4net;
-using Nini.Config;
-using OpenMetaverse;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.Avatar.Vegetation
-{
- public class VegetationModule : IRegionModule, IVegetationModule
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- protected Scene m_scene;
-
- protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.Grass, PCode.NewTree, PCode.Tree };
- public PCode[] CreationCapabilities { get { return creationCapabilities; } }
-
- public void Initialise(Scene scene, IConfigSource source)
- {
- m_scene = scene;
- m_scene.RegisterModuleInterface(this);
- }
-
- public void PostInitialise() {}
- public void Close() {}
- public string Name { get { return "Vegetation Module"; } }
- public bool IsSharedModule { get { return false; } }
-
- public SceneObjectGroup AddTree(
- UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree)
- {
- PrimitiveBaseShape treeShape = new PrimitiveBaseShape();
- treeShape.PathCurve = 16;
- treeShape.PathEnd = 49900;
- treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree;
- treeShape.Scale = scale;
- treeShape.State = (byte)treeType;
-
- return m_scene.AddNewPrim(uuid, groupID, position, rotation, treeShape);
- }
-
- public SceneObjectGroup CreateEntity(
- UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
- {
- if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0)
- {
- m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name);
- return null;
- }
-
- SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
- SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID);
-
- // if grass or tree, make phantom
- //rootPart.TrimPermissions();
- rootPart.AddFlag(PrimFlags.Phantom);
- if (rootPart.Shape.PCode != (byte)PCode.Grass)
- AdaptTree(ref shape);
-
- m_scene.AddNewSceneObject(sceneObject, true);
- sceneObject.SetGroup(groupID, null);
-
- return sceneObject;
- }
-
- protected void AdaptTree(ref PrimitiveBaseShape tree)
- {
- // Tree size has to be adapted depending on its type
- switch ((Tree)tree.State)
- {
- case Tree.Cypress1:
- case Tree.Cypress2:
- tree.Scale = new Vector3(4, 4, 10);
- break;
-
- // case... other tree types
- // tree.Scale = new Vector3(?, ?, ?);
- // break;
-
- default:
- tree.Scale = new Vector3(4, 4, 4);
- break;
- }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/Wind/WindModule.cs b/OpenSim/Region/Environment/Modules/World/Wind/WindModule.cs
deleted file mode 100644
index 8e54fd9..0000000
--- a/OpenSim/Region/Environment/Modules/World/Wind/WindModule.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.Collections.Generic;
-using OpenMetaverse;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules
-{
- public class WindModule : IWindModule
- {
-// private static readonly log4net.ILog m_log
-// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
-
- private int m_frame = 0;
- private int m_frame_mod = 150;
- private Random rndnums = new Random(System.Environment.TickCount);
- private Scene m_scene = null;
- private bool ready = false;
- private Vector2[] windSpeeds = new Vector2[16 * 16];
- private Dictionary m_rootAgents = new Dictionary();
-
- public void Initialise(Scene scene, IConfigSource config)
- {
- m_scene = scene;
- m_frame = 0;
-
- scene.EventManager.OnFrame += WindUpdate;
- scene.EventManager.OnMakeChildAgent += MakeChildAgent;
- scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
- scene.EventManager.OnClientClosed += ClientLoggedOut;
- scene.RegisterModuleInterface(this);
-
- GenWindPos();
-
- ready = true;
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- ready = false;
- // Remove our hooks
- m_scene.EventManager.OnFrame -= WindUpdate;
- // m_scene.EventManager.OnNewClient -= SunToClient;
- m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
- m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
- m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
- }
-
- public string Name
- {
- get { return "WindModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return false; }
- }
-
- public Vector2[] WindSpeeds
- {
- get { return windSpeeds; }
- }
-
- public void WindToClient(IClientAPI client)
- {
- if (ready)
- {
- //if (!sunFixed)
- //GenWindPos(); // Generate shared values once
- client.SendWindData(windSpeeds);
- }
- }
-
- public void WindUpdate()
- {
- if (((m_frame++ % m_frame_mod) != 0) || !ready)
- {
- return;
- }
- //m_log.Debug("[WIND]:Regenerating...");
- GenWindPos(); // Generate shared values once
-
- //int spotxp = 0;
- //int spotyp = 0;
- //int spotxm = 0;
- //int spotym = 0;
- List avatars = m_scene.GetAvatars();
- foreach (ScenePresence avatar in avatars)
- {
- if (!avatar.IsChildAgent)
- {
- avatar.ControllingClient.SendWindData(windSpeeds);
- }
- }
-
- // set estate settings for region access to sun position
- //m_scene.RegionInfo.RegionSettings.SunVector = Position;
- //m_scene.RegionInfo.EstateSettings.sunHour = GetLindenEstateHourFromCurrentTime();
- }
-
- public void ForceWindUpdateToAllClients()
- {
- GenWindPos(); // Generate shared values once
-
- List avatars = m_scene.GetAvatars();
- foreach (ScenePresence avatar in avatars)
- {
- if (!avatar.IsChildAgent)
- avatar.ControllingClient.SendWindData(windSpeeds);
- }
-
- // set estate settings for region access to sun position
- //m_scene.RegionInfo.RegionSettings.SunVector = Position;
- //m_scene.RegionInfo.RegionSettings.SunPosition = GetLindenEstateHourFromCurrentTime();
- }
- ///
- /// Calculate the sun's orbital position and its velocity.
- ///
-
- private void GenWindPos()
- {
- for (int y = 0; y < 16; y++)
- {
- for (int x = 0; x < 16; x++)
- {
- windSpeeds[y * 16 + x].X = (float)(rndnums.NextDouble() * 2d - 1d);
- windSpeeds[y * 16 + x].Y = (float)(rndnums.NextDouble() * 2d - 1d);
- }
- }
- }
-
- private void ClientLoggedOut(UUID AgentId)
- {
- lock (m_rootAgents)
- {
- if (m_rootAgents.ContainsKey(AgentId))
- {
- m_rootAgents.Remove(AgentId);
- }
- }
- }
-
- private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
- {
- lock (m_rootAgents)
- {
- if (m_rootAgents.ContainsKey(avatar.UUID))
- {
- m_rootAgents[avatar.UUID] = avatar.RegionHandle;
- }
- else
- {
- m_rootAgents.Add(avatar.UUID, avatar.RegionHandle);
- WindToClient(avatar.ControllingClient);
- }
- }
- //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
- }
-
- private void MakeChildAgent(ScenePresence avatar)
- {
- lock (m_rootAgents)
- {
- if (m_rootAgents.ContainsKey(avatar.UUID))
- {
- if (m_rootAgents[avatar.UUID] == avatar.RegionHandle)
- {
- m_rootAgents.Remove(avatar.UUID);
- }
- }
- }
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/IMapTileTerrainRenderer.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/IMapTileTerrainRenderer.cs
deleted file mode 100644
index cb0ac8c..0000000
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/IMapTileTerrainRenderer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.Drawing;
-using OpenSim.Region.Framework.Scenes;
-using Nini.Config;
-
-namespace OpenSim.Region.Environment
-{
- public interface IMapTileTerrainRenderer
- {
- void Initialise(Scene scene, IConfigSource config);
- void TerrainToBitmap(Bitmap mapbmp);
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs
deleted file mode 100644
index a806c7d..0000000
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * 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.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Reflection;
-using Nini.Config;
-using OpenMetaverse.Imaging;
-using log4net;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenMetaverse;
-
-namespace OpenSim.Region.Environment.Modules.World.WorldMap
-{
- public enum DrawRoutine
- {
- Rectangle,
- Polygon,
- Ellipse
- }
-
- public struct face
- {
- public Point[] pts;
- }
-
- public struct DrawStruct
- {
- public DrawRoutine dr;
- public Rectangle rect;
- public SolidBrush brush;
- public face[] trns;
- }
-
- public class MapImageModule : IMapImageGenerator, IRegionModule
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private Scene m_scene;
- private IConfigSource m_config;
- private IMapTileTerrainRenderer terrainRenderer;
-
- #region IMapImageGenerator Members
-
- public byte[] WriteJpeg2000Image(string gradientmap)
- {
- byte[] imageData = null;
-
- bool drawPrimVolume = true;
- bool textureTerrain = true;
-
- try
- {
- IConfig startupConfig = m_config.Configs["Startup"];
- drawPrimVolume = startupConfig.GetBoolean("DrawPrimOnMapTile", drawPrimVolume);
- textureTerrain = startupConfig.GetBoolean("TextureOnMapTile", textureTerrain);
- }
- catch
- {
- m_log.Warn("[MAPTILE]: Failed to load StartupConfig");
- }
-
- if (textureTerrain)
- {
- terrainRenderer = new TexturedMapTileRenderer();
- }
- else
- {
- terrainRenderer = new ShadedMapTileRenderer();
- }
- terrainRenderer.Initialise(m_scene, m_config);
-
- Bitmap mapbmp = new Bitmap(256, 256);
- //long t = System.Environment.TickCount;
- //for (int i = 0; i < 10; ++i) {
- terrainRenderer.TerrainToBitmap(mapbmp);
- //}
- //t = System.Environment.TickCount - t;
- //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
-
-
- if (drawPrimVolume)
- {
- DrawObjectVolume(m_scene, mapbmp);
- }
-
- try
- {
- imageData = OpenJPEG.EncodeFromImage(mapbmp, true);
- }
- catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
- {
- Console.WriteLine("Failed generating terrain map: " + e);
- }
-
- return imageData;
- }
-
- #endregion
-
- #region IRegionModule Members
-
- public void Initialise(Scene scene, IConfigSource source)
- {
- m_scene = scene;
- m_config = source;
-
- IConfig startupConfig = m_config.Configs["Startup"];
- if (startupConfig.GetString("MapImageModule", "MapImageModule") !=
- "MapImageModule")
- return;
-
- m_scene.RegisterModuleInterface(this);
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- }
-
- public string Name
- {
- get { return "MapImageModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return false; }
- }
-
- #endregion
-
-// TODO: unused:
-// private void ShadeBuildings(Bitmap map)
-// {
-// lock (map)
-// {
-// lock (m_scene.Entities)
-// {
-// foreach (EntityBase entity in m_scene.Entities.Values)
-// {
-// if (entity is SceneObjectGroup)
-// {
-// SceneObjectGroup sog = (SceneObjectGroup) entity;
-//
-// foreach (SceneObjectPart primitive in sog.Children.Values)
-// {
-// int x = (int) (primitive.AbsolutePosition.X - (primitive.Scale.X / 2));
-// int y = (int) (primitive.AbsolutePosition.Y - (primitive.Scale.Y / 2));
-// int w = (int) primitive.Scale.X;
-// int h = (int) primitive.Scale.Y;
-//
-// int dx;
-// for (dx = x; dx < x + w; dx++)
-// {
-// int dy;
-// for (dy = y; dy < y + h; dy++)
-// {
-// if (x < 0 || y < 0)
-// continue;
-// if (x >= map.Width || y >= map.Height)
-// continue;
-//
-// map.SetPixel(dx, dy, Color.DarkGray);
-// }
-// }
-// }
-// }
-// }
-// }
-// }
-// }
-
- private Bitmap DrawObjectVolume(Scene whichScene, Bitmap mapbmp)
- {
- int tc = 0;
- double[,] hm = whichScene.Heightmap.GetDoubles();
- tc = System.Environment.TickCount;
- m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
- List objs = whichScene.GetEntities();
- Dictionary z_sort = new Dictionary();
- //SortedList z_sort = new SortedList();
- List z_sortheights = new List();
- List z_localIDs = new List();
-
- lock (objs)
- {
- foreach (EntityBase obj in objs)
- {
- // Only draw the contents of SceneObjectGroup
- if (obj is SceneObjectGroup)
- {
- 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.Children.Values)
- {
- 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)
- {
- // 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;
-
- if (part.Shape.Textures == null)
- continue;
-
- if (part.Shape.Textures.DefaultTexture == null)
- continue;
-
- Color4 texcolor = part.Shape.Textures.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)
- 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 > 255 || mapdrawendX < 0 || mapdrawendX > 255
- || mapdrawstartY < 0 || mapdrawstartY > 255 || mapdrawendY < 0
- || mapdrawendY > 255)
- 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++)
- //{
- //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
- //{
- //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
-
- float[] sortedZHeights = z_sortheights.ToArray();
- uint[] sortedlocalIds = z_localIDs.ToArray();
-
- // 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]))
- {
- 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.Dispose();
- } // lock entities objs
-
- m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (System.Environment.TickCount - tc) + " ms");
- return mapbmp;
- }
-
- private Point project(Vector3 point3d, Vector3 originpos)
- {
- Point returnpt = new Point();
- //originpos = point3d;
- //int d = (int)(256f / 1.5f);
-
- //Vector3 topos = new Vector3(0, 0, 0);
- // float z = -point3d.z - topos.z;
-
- returnpt.X = (int)point3d.X;//(int)((topos.x - point3d.x) / z * d);
- returnpt.Y = (int)(255 - point3d.Y);//(int)(255 - (((topos.y - point3d.y) / z * d)));
-
- return returnpt;
- }
-
-// TODO: unused:
-// #region Deprecated Maptile Generation. Adam may update this
-// private Bitmap TerrainToBitmap(string gradientmap)
-// {
-// Bitmap gradientmapLd = new Bitmap(gradientmap);
-//
-// int pallete = gradientmapLd.Height;
-//
-// Bitmap bmp = new Bitmap(m_scene.Heightmap.Width, m_scene.Heightmap.Height);
-// Color[] colours = new Color[pallete];
-//
-// for (int i = 0; i < pallete; i++)
-// {
-// colours[i] = gradientmapLd.GetPixel(0, i);
-// }
-//
-// lock (m_scene.Heightmap)
-// {
-// ITerrainChannel copy = m_scene.Heightmap;
-// for (int y = 0; y < copy.Height; y++)
-// {
-// for (int x = 0; x < copy.Width; x++)
-// {
-// // 512 is the largest possible height before colours clamp
-// int colorindex = (int) (Math.Max(Math.Min(1.0, copy[x, y] / 512.0), 0.0) * (pallete - 1));
-//
-// // Handle error conditions
-// if (colorindex > pallete - 1 || colorindex < 0)
-// bmp.SetPixel(x, copy.Height - y - 1, Color.Red);
-// else
-// bmp.SetPixel(x, copy.Height - y - 1, colours[colorindex]);
-// }
-// }
-// ShadeBuildings(bmp);
-// return bmp;
-// }
-// }
-// #endregion
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs
deleted file mode 100644
index 43ed1e4..0000000
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/MapSearchModule.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * 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.Reflection;
-using System.Collections.Generic;
-using System.Net;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Framework.Scenes.Hypergrid;
-using OpenMetaverse;
-using log4net;
-using Nini.Config;
-
-namespace OpenSim.Region.Environment.Modules.World.WorldMap
-{
- public class MapSearchModule : IRegionModule
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- Scene m_scene = null; // only need one for communication with GridService
- List m_scenes = new List();
-
- #region IRegionModule Members
- public void Initialise(Scene scene, IConfigSource source)
- {
- if (m_scene == null)
- {
- m_scene = scene;
- }
-
- m_scenes.Add(scene);
- scene.EventManager.OnNewClient += OnNewClient;
- }
-
- public void PostInitialise()
- {
- }
-
- public void Close()
- {
- m_scene = null;
- m_scenes.Clear();
- }
-
- public string Name
- {
- get { return "MapSearchModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return true; }
- }
-
- #endregion
-
- private void OnNewClient(IClientAPI client)
- {
- client.OnMapNameRequest += OnMapNameRequest;
- }
-
- private void OnMapNameRequest(IClientAPI remoteClient, string mapName)
- {
- if (mapName.Length < 3)
- {
- remoteClient.SendAlertMessage("Use a search string with at least 3 characters");
- return;
- }
-
- // try to fetch from GridServer
- List regionInfos = m_scene.SceneGridService.RequestNamedRegions(mapName, 20);
- if (regionInfos == null)
- {
- m_log.Warn("[MAPSEARCHMODULE]: RequestNamedRegions returned null. Old gridserver?");
- // service wasn't available; maybe still an old GridServer. Try the old API, though it will return only one region
- regionInfos = new List();
- RegionInfo info = m_scene.SceneGridService.RequestClosestRegion(mapName);
- if (info != null) regionInfos.Add(info);
- }
-
- if ((regionInfos.Count == 0) && IsHypergridOn())
- {
- // OK, we tried but there are no regions matching that name.
- // Let's check quickly if this is a domain name, and if so link to it
- if (mapName.Contains(".") && mapName.Contains(":"))
- {
- // It probably is a domain name. Try to link to it.
- RegionInfo regInfo;
- Scene cScene = GetClientScene(remoteClient);
- regInfo = HGHyperlink.TryLinkRegion(cScene, remoteClient, mapName);
- if (regInfo != null)
- regionInfos.Add(regInfo);
- }
- }
-
- List blocks = new List();
-
- MapBlockData data;
- if (regionInfos.Count > 0)
- {
- foreach (RegionInfo info in regionInfos)
- {
- data = new MapBlockData();
- data.Agents = 0;
- data.Access = 21; // TODO what's this?
- data.MapImageId = info.RegionSettings.TerrainImageID;
- data.Name = info.RegionName;
- data.RegionFlags = 0; // TODO not used?
- data.WaterHeight = 0; // not used
- data.X = (ushort)info.RegionLocX;
- data.Y = (ushort)info.RegionLocY;
- blocks.Add(data);
- }
- }
-
- // final block, closing the search result
- data = new MapBlockData();
- data.Agents = 0;
- data.Access = 255;
- data.MapImageId = UUID.Zero;
- data.Name = mapName;
- data.RegionFlags = 0;
- data.WaterHeight = 0; // not used
- data.X = 0;
- data.Y = 0;
- blocks.Add(data);
-
- remoteClient.SendMapBlock(blocks, 0);
- }
-
- private bool IsHypergridOn()
- {
- return (m_scene.SceneGridService is HGSceneCommunicationService);
- }
-
- private Scene GetClientScene(IClientAPI client)
- {
- foreach (Scene s in m_scenes)
- {
- if (client.Scene.RegionInfo.RegionHandle == s.RegionInfo.RegionHandle)
- return s;
- }
- return m_scene;
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/ShadedMapTileRenderer.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/ShadedMapTileRenderer.cs
deleted file mode 100644
index 7fe538e..0000000
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/ShadedMapTileRenderer.cs
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * 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.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Reflection;
-using OpenMetaverse;
-using OpenMetaverse.Imaging;
-using Nini.Config;
-using log4net;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-
-namespace OpenSim.Region.Environment.Modules.World.WorldMap
-{
- public class ShadedMapTileRenderer : IMapTileTerrainRenderer
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private Scene m_scene;
- //private IConfigSource m_config; // not used currently
-
- public void Initialise(Scene scene, IConfigSource config)
- {
- m_scene = scene;
- // m_config = config; // not used currently
- }
-
- public void TerrainToBitmap(Bitmap mapbmp)
- {
- int tc = System.Environment.TickCount;
- m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain");
-
- double[,] hm = m_scene.Heightmap.GetDoubles();
- bool ShadowDebugContinue = true;
-
- bool terraincorruptedwarningsaid = false;
-
- float low = 255;
- float high = 0;
- for (int x = 0; x < 256; x++)
- {
- for (int y = 0; y < 256; y++)
- {
- float hmval = (float)hm[x, y];
- if (hmval < low)
- low = hmval;
- if (hmval > high)
- high = hmval;
- }
- }
-
- float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;
-
- for (int x = 0; x < 256; x++)
- {
- for (int y = 0; y < 256; y++)
- {
- // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left
- int yr = 255 - y;
-
- float heightvalue = (float)hm[x, y];
-
- if (heightvalue > waterHeight)
- {
- // scale height value
- // No, that doesn't scale it:
- // heightvalue = low + mid * (heightvalue - low) / mid; => low + (heightvalue - low) * mid / mid = low + (heightvalue - low) * 1 = low + heightvalue - low = heightvalue
-
- if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue))
- heightvalue = 0;
- else if (heightvalue > 255f)
- heightvalue = 255f;
- else if (heightvalue < 0f)
- heightvalue = 0f;
-
- Color color = Color.FromArgb((int)heightvalue, 100, (int)heightvalue);
-
- mapbmp.SetPixel(x, yr, color);
-
- try
- {
- //X
- // .
- //
- // Shade the terrain for shadows
- if (x < 255 && yr < 255)
- {
- float hfvalue = (float)hm[x, y];
- float hfvaluecompare = 0f;
-
- if ((x + 1 < 256) && (y + 1 < 256))
- {
- hfvaluecompare = (float)hm[x + 1, y + 1]; // light from north-east => look at land height there
- }
- if (Single.IsInfinity(hfvalue) || Single.IsNaN(hfvalue))
- hfvalue = 0f;
-
- if (Single.IsInfinity(hfvaluecompare) || Single.IsNaN(hfvaluecompare))
- hfvaluecompare = 0f;
-
- float hfdiff = hfvalue - hfvaluecompare; // => positive if NE is lower, negative if here is lower
-
- int hfdiffi = 0;
- int hfdiffihighlight = 0;
- float highlightfactor = 0.18f;
-
- try
- {
- // hfdiffi = Math.Abs((int)((hfdiff * 4) + (hfdiff * 0.5))) + 1;
- hfdiffi = Math.Abs((int)(hfdiff * 4.5f)) + 1;
- if (hfdiff % 1f != 0)
- {
- // hfdiffi = hfdiffi + Math.Abs((int)(((hfdiff % 1) * 0.5f) * 10f) - 1);
- hfdiffi = hfdiffi + Math.Abs((int)((hfdiff % 1f) * 5f) - 1);
- }
-
- hfdiffihighlight = Math.Abs((int)((hfdiff * highlightfactor) * 4.5f)) + 1;
- if (hfdiff % 1f != 0)
- {
- // hfdiffi = hfdiffi + Math.Abs((int)(((hfdiff % 1) * 0.5f) * 10f) - 1);
- hfdiffihighlight = hfdiffihighlight + Math.Abs((int)(((hfdiff * highlightfactor) % 1f) * 5f) - 1);
- }
- }
- catch (System.OverflowException)
- {
- m_log.Debug("[MAPTILE]: Shadow failed at value: " + hfdiff.ToString());
- ShadowDebugContinue = false;
- }
-
- if (hfdiff > 0.3f)
- {
- // NE is lower than here
- // We have to desaturate and lighten the land at the same time
- // we use floats, colors use bytes, so shrink are space down to
- // 0-255
-
- if (ShadowDebugContinue)
- {
- int r = color.R;
- int g = color.G;
- int b = color.B;
- color = Color.FromArgb((r + hfdiffihighlight < 255) ? r + hfdiffihighlight : 255,
- (g + hfdiffihighlight < 255) ? g + hfdiffihighlight : 255,
- (b + hfdiffihighlight < 255) ? b + hfdiffihighlight : 255);
- }
- }
- else if (hfdiff < -0.3f)
- {
- // here is lower than NE:
- // We have to desaturate and blacken the land at the same time
- // we use floats, colors use bytes, so shrink are space down to
- // 0-255
-
- if (ShadowDebugContinue)
- {
- if ((x - 1 > 0) && (yr + 1 < 256))
- {
- color = mapbmp.GetPixel(x - 1, yr + 1);
- int r = color.R;
- int g = color.G;
- int b = color.B;
- color = Color.FromArgb((r - hfdiffi > 0) ? r - hfdiffi : 0,
- (g - hfdiffi > 0) ? g - hfdiffi : 0,
- (b - hfdiffi > 0) ? b - hfdiffi : 0);
-
- mapbmp.SetPixel(x-1, yr+1, color);
- }
- }
- }
- }
- }
- catch (System.ArgumentException)
- {
- 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);
- terraincorruptedwarningsaid = true;
- }
- color = Color.Black;
- mapbmp.SetPixel(x, yr, color);
- }
- }
- else
- {
- // We're under the water level with the terrain, so paint water instead of land
-
- // Y flip the cordinates
- heightvalue = waterHeight - heightvalue;
- if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue))
- heightvalue = 0f;
- else if (heightvalue > 19f)
- heightvalue = 19f;
- else if (heightvalue < 0f)
- heightvalue = 0f;
-
- heightvalue = 100f - (heightvalue * 100f) / 19f;
-
- try
- {
- Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255);
- mapbmp.SetPixel(x, yr, water);
- }
- catch (System.ArgumentException)
- {
- 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);
- terraincorruptedwarningsaid = true;
- }
- Color black = Color.Black;
- mapbmp.SetPixel(x, (256 - y) - 1, black);
- }
- }
- }
- }
- m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (System.Environment.TickCount - tc) + " ms");
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
deleted file mode 100644
index d23c352..0000000
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/TexturedMapTileRenderer.cs
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * 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.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Reflection;
-using OpenMetaverse;
-using Nini.Config;
-using log4net;
-using OpenMetaverse.Imaging;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Environment.Modules.World.Terrain;
-
-namespace OpenSim.Region.Environment.Modules.World.WorldMap
-{
- // Hue, Saturation, Value; used for color-interpolation
- struct HSV {
- public float h;
- public float s;
- public float v;
-
- public HSV(float h, float s, float v)
- {
- this.h = h;
- this.s = s;
- this.v = v;
- }
-
- // (for info about algorithm, see http://en.wikipedia.org/wiki/HSL_and_HSV)
- public HSV(Color c)
- {
- float r = c.R / 255f;
- float g = c.G / 255f;
- float b = c.B / 255f;
- float max = Math.Max(Math.Max(r, g), b);
- float min = Math.Min(Math.Min(r, g), b);
- float diff = max - min;
-
- if (max == min) h = 0f;
- else if (max == r) h = (g - b) / diff * 60f;
- else if (max == g) h = (b - r) / diff * 60f + 120f;
- else h = (r - g) / diff * 60f + 240f;
- if (h < 0f) h += 360f;
-
- if (max == 0f) s = 0f;
- else s = diff / max;
-
- v = max;
- }
-
- // (for info about algorithm, see http://en.wikipedia.org/wiki/HSL_and_HSV)
- public Color toColor()
- {
- if (s < 0f) Console.WriteLine("S < 0: " + s);
- else if (s > 1f) Console.WriteLine("S > 1: " + s);
- if (v < 0f) Console.WriteLine("V < 0: " + v);
- else if (v > 1f) Console.WriteLine("V > 1: " + v);
-
- float f = h / 60f;
- int sector = (int)f % 6;
- f = f - (int)f;
- int pi = (int)(v * (1f - s) * 255f);
- int qi = (int)(v * (1f - s * f) * 255f);
- int ti = (int)(v * (1f - (1f - f) * s) * 255f);
- int vi = (int)(v * 255f);
-
- switch (sector)
- {
- case 0:
- return Color.FromArgb(vi, ti, pi);
- case 1:
- return Color.FromArgb(qi, vi, pi);
- case 2:
- return Color.FromArgb(pi, vi, ti);
- case 3:
- return Color.FromArgb(pi, qi, vi);
- case 4:
- return Color.FromArgb(ti, pi, vi);
- default:
- return Color.FromArgb(vi, pi, qi);
- }
- }
- }
-
- public class TexturedMapTileRenderer : IMapTileTerrainRenderer
- {
- #region Constants
-
- private static readonly ILog m_log =
- LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- // some hardcoded terrain UUIDs that work with SL 1.20 (the four default textures and "Blank").
- // The color-values were choosen because they "look right" (at least to me) ;-)
- private static readonly UUID defaultTerrainTexture1 = new UUID("0bc58228-74a0-7e83-89bc-5c23464bcec5");
- private static readonly Color defaultColor1 = Color.FromArgb(165, 137, 118);
- private static readonly UUID defaultTerrainTexture2 = new UUID("63338ede-0037-c4fd-855b-015d77112fc8");
- private static readonly Color defaultColor2 = Color.FromArgb(69, 89, 49);
- private static readonly UUID defaultTerrainTexture3 = new UUID("303cd381-8560-7579-23f1-f0a880799740");
- private static readonly Color defaultColor3 = Color.FromArgb(162, 154, 141);
- private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c");
- private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200);
-
- #endregion
-
-
- private Scene m_scene;
- // private IConfigSource m_config; // not used currently
-
- // mapping from texture UUIDs to averaged color. This will contain 5-9 values, in general; new values are only
- // added when the terrain textures are changed in the estate dialog and a new map is generated (and will stay in
- // that map until the region-server restarts. This could be considered a memory-leak, but it's a *very* small one.
- // TODO does it make sense to use a "real" cache and regenerate missing entries on fetch?
- private Dictionary m_mapping;
-
-
- public void Initialise(Scene scene, IConfigSource source)
- {
- m_scene = scene;
- // m_config = source; // not used currently
- m_mapping = new Dictionary();
- m_mapping.Add(defaultTerrainTexture1, defaultColor1);
- m_mapping.Add(defaultTerrainTexture2, defaultColor2);
- m_mapping.Add(defaultTerrainTexture3, defaultColor3);
- m_mapping.Add(defaultTerrainTexture4, defaultColor4);
- m_mapping.Add(Util.BLANK_TEXTURE_UUID, Color.White);
- }
-
- #region Helpers
- // This fetches the texture from the asset server synchroneously. That should be ok, as we
- // call map-creation only in those places:
- // - on start: We can wait here until the asset server returns the texture
- // TODO (- on "map" command: We are in the command-line thread, we will wait for completion anyway)
- // TODO (- on "automatic" update after some change: We are called from the mapUpdateTimer here and
- // will wait anyway)
- private Bitmap fetchTexture(UUID id)
- {
- AssetBase asset = m_scene.AssetCache.GetAsset(id, true);
- m_log.DebugFormat("Fetched texture {0}, found: {1}", id, asset != null);
- if (asset == null) return null;
-
- ManagedImage managedImage;
- Image image;
-
- try
- {
- if (OpenJPEG.DecodeToImage(asset.Data, out managedImage, out image))
- return new Bitmap(image);
- else
- return null;
- }
- catch (DllNotFoundException)
- {
- m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", id);
-
- }
- catch (IndexOutOfRangeException)
- {
- m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id);
-
- }
- catch (Exception)
- {
- m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id);
-
- }
- return null;
-
- }
-
- // Compute the average color of a texture.
- private Color computeAverageColor(Bitmap bmp)
- {
- // we have 256 x 256 pixel, each with 256 possible color-values per
- // color-channel, so 2^24 is the maximum value we can get, adding everything.
- // int is be big enough for that.
- int r = 0, g = 0, b = 0;
- for (int y = 0; y < bmp.Height; ++y)
- {
- for (int x = 0; x < bmp.Width; ++x)
- {
- Color c = bmp.GetPixel(x, y);
- r += (int)c.R & 0xff;
- g += (int)c.G & 0xff;
- b += (int)c.B & 0xff;
- }
- }
-
- int pixels = bmp.Width * bmp.Height;
- return Color.FromArgb(r / pixels, g / pixels, b / pixels);
- }
-
- // return either the average color of the texture, or the defaultColor if the texturID is invalid
- // or the texture couldn't be found
- private Color computeAverageColor(UUID textureID, Color defaultColor) {
- 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;
-
- return color;
- }
-
- // S-curve: f(x) = 3x² - 2x³:
- // f(0) = 0, f(0.5) = 0.5, f(1) = 1,
- // f'(x) = 0 at x = 0 and x = 1; f'(0.5) = 1.5,
- // f''(0.5) = 0, f''(x) != 0 for x != 0.5
- private float S(float v) {
- return (v * v * (3f - 2f * v));
- }
-
- // interpolate two colors in HSV space and return the resulting color
- private HSV interpolateHSV(ref HSV c1, ref HSV c2, float ratio) {
- if (ratio <= 0f) return c1;
- if (ratio >= 1f) return c2;
-
- // make sure we are on the same side on the hue-circle for interpolation
- // We change the hue of the parameters here, but we don't change the color
- // represented by that value
- if (c1.h - c2.h > 180f) c1.h -= 360f;
- else if (c2.h - c1.h > 180f) c1.h += 360f;
-
- return new HSV(c1.h * (1f - ratio) + c2.h * ratio,
- c1.s * (1f - ratio) + c2.s * ratio,
- c1.v * (1f - ratio) + c2.v * ratio);
- }
-
- // the heigthfield might have some jumps in values. Rendered land is smooth, though,
- // as a slope is rendered at that place. So average 4 neighbour values to emulate that.
- private float getHeight(double[,] hm, int x, int y) {
- if (x < 255 && y < 255)
- return (float)(hm[x, y] * .444 + (hm[x + 1, y] + hm[x, y + 1]) * .222 + hm[x + 1, y +1] * .112);
- else
- return (float)hm[x, y];
- }
- #endregion
-
- public void TerrainToBitmap(Bitmap mapbmp)
- {
- int tc = System.Environment.TickCount;
- m_log.Info("[MAPTILE]: 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),
- // and on change of the estate settings (textures and terrain values), when the map should
- // be recreated.
- RegionSettings settings = m_scene.RegionInfo.RegionSettings;
-
- // the four terrain colors as HSVs for interpolation
- HSV hsv1 = new HSV(computeAverageColor(settings.TerrainTexture1, defaultColor1));
- HSV hsv2 = new HSV(computeAverageColor(settings.TerrainTexture2, defaultColor2));
- HSV hsv3 = new HSV(computeAverageColor(settings.TerrainTexture3, defaultColor3));
- HSV hsv4 = new HSV(computeAverageColor(settings.TerrainTexture4, defaultColor4));
-
- float levelNElow = (float)settings.Elevation1NE;
- float levelNEhigh = (float)settings.Elevation2NE;
-
- float levelNWlow = (float)settings.Elevation1NW;
- float levelNWhigh = (float)settings.Elevation2NW;
-
- float levelSElow = (float)settings.Elevation1SE;
- float levelSEhigh = (float)settings.Elevation2SE;
-
- float levelSWlow = (float)settings.Elevation1SW;
- float levelSWhigh = (float)settings.Elevation2SW;
-
- float waterHeight = (float)settings.WaterHeight;
-
- double[,] hm = m_scene.Heightmap.GetDoubles();
-
- for (int x = 0; x < 256; x++)
- {
- float columnRatio = x / 255f; // 0 - 1, for interpolation
- for (int y = 0; y < 256; y++)
- {
- float rowRatio = y / 255f; // 0 - 1, for interpolation
-
- // Y flip the cordinates for the bitmap: hf origin is lower left, bm origin is upper left
- int yr = 255 - y;
-
- float heightvalue = getHeight(hm, x, y);
- if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue))
- heightvalue = 0;
-
- if (heightvalue > waterHeight)
- {
- // add a bit noise for breaking up those flat colors:
- // - a large-scale noise, for the "patches" (using an doubled s-curve for sharper contrast)
- // - a small-scale noise, for bringing in some small scale variation
- //float bigNoise = (float)TerrainUtil.InterpolatedNoise(x / 8.0, y / 8.0) * .5f + .5f; // map to 0.0 - 1.0
- //float smallNoise = (float)TerrainUtil.InterpolatedNoise(x + 33, y + 43) * .5f + .5f;
- //float hmod = heightvalue + smallNoise * 3f + S(S(bigNoise)) * 10f;
- float hmod =
- heightvalue +
- (float)TerrainUtil.InterpolatedNoise(x + 33, y + 43) * 1.5f + 1.5f + // 0 - 3
- S(S((float)TerrainUtil.InterpolatedNoise(x / 8.0, y / 8.0) * .5f + .5f)) * 10f; // 0 - 10
-
- // find the low/high values for this point (interpolated bilinearily)
- // (and remember, x=0,y=0 is SW)
- float low = levelSWlow * (1f - rowRatio) * (1f - columnRatio) +
- levelSElow * (1f - rowRatio) * columnRatio +
- levelNWlow * rowRatio * (1f - columnRatio) +
- levelNElow * rowRatio * columnRatio;
- float high = levelSWhigh * (1f - rowRatio) * (1f - columnRatio) +
- levelSEhigh * (1f - rowRatio) * columnRatio +
- levelNWhigh * rowRatio * (1f - columnRatio) +
- levelNEhigh * rowRatio * columnRatio;
- if (high < low)
- {
- // someone tried to fool us. High value should be higher than low every time
- float tmp = high;
- high = low;
- low = tmp;
- }
-
- HSV hsv;
- if (hmod <= low) hsv = hsv1; // too low
- else if (hmod >= high) hsv = hsv4; // too high
- else
- {
- // HSV-interpolate along the colors
- // first, rescale h to 0.0 - 1.0
- hmod = (hmod - low) / (high - low);
- // now we have to split: 0.00 => color1, 0.33 => color2, 0.67 => color3, 1.00 => color4
- if (hmod < 1f/3f) hsv = interpolateHSV(ref hsv1, ref hsv2, hmod * 3f);
- else if (hmod < 2f/3f) hsv = interpolateHSV(ref hsv2, ref hsv3, (hmod * 3f) - 1f);
- else hsv = interpolateHSV(ref hsv3, ref hsv4, (hmod * 3f) - 2f);
- }
-
- // Shade the terrain for shadows
- if (x < 255 && y < 255)
- {
- float hfvaluecompare = getHeight(hm, x + 1, y + 1); // light from north-east => look at land height there
- if (Single.IsInfinity(hfvaluecompare) || Single.IsNaN(hfvaluecompare))
- hfvaluecompare = 0f;
-
- float hfdiff = heightvalue - hfvaluecompare; // => positive if NE is lower, negative if here is lower
- hfdiff *= 0.06f; // some random factor so "it looks good"
- if (hfdiff > 0.02f)
- {
- float highlightfactor = 0.18f;
- // NE is lower than here
- // We have to desaturate and lighten the land at the same time
- hsv.s = (hsv.s - (hfdiff * highlightfactor) > 0f) ? hsv.s - (hfdiff * highlightfactor) : 0f;
- hsv.v = (hsv.v + (hfdiff * highlightfactor) < 1f) ? hsv.v + (hfdiff * highlightfactor) : 1f;
- }
- else if (hfdiff < -0.02f)
- {
- // here is lower than NE:
- // We have to desaturate and blacken the land at the same time
- hsv.s = (hsv.s + hfdiff > 0f) ? hsv.s + hfdiff : 0f;
- hsv.v = (hsv.v + hfdiff > 0f) ? hsv.v + hfdiff : 0f;
- }
- }
- mapbmp.SetPixel(x, yr, hsv.toColor());
- }
- else
- {
- // We're under the water level with the terrain, so paint water instead of land
-
- heightvalue = waterHeight - heightvalue;
- if (Single.IsInfinity(heightvalue) || Single.IsNaN(heightvalue))
- heightvalue = 0f;
- else if (heightvalue > 19f)
- heightvalue = 19f;
- else if (heightvalue < 0f)
- heightvalue = 0f;
-
- heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0
-
- Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255);
- mapbmp.SetPixel(x, yr, water);
- }
- }
- }
- m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (System.Environment.TickCount - tc) + " ms");
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
deleted file mode 100644
index 37b4547..0000000
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
+++ /dev/null
@@ -1,905 +0,0 @@
-/*
- * 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.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Net;
-using System.Reflection;
-using System.Threading;
-using OpenMetaverse;
-using OpenMetaverse.Imaging;
-using OpenMetaverse.StructuredData;
-using log4net;
-using Nini.Config;
-using OpenSim.Framework;
-using OpenSim.Framework.Communications.Cache;
-using OpenSim.Framework.Communications.Capabilities;
-using OpenSim.Framework.Servers;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using OpenSim.Region.Framework.Scenes.Types;
-using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
-
-using OSD = OpenMetaverse.StructuredData.OSD;
-using OSDMap = OpenMetaverse.StructuredData.OSDMap;
-using OSDArray = OpenMetaverse.StructuredData.OSDArray;
-
-namespace OpenSim.Region.Environment.Modules.World.WorldMap
-{
- public class WorldMapModule : IRegionModule
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private static readonly string m_mapLayerPath = "0001/";
-
- private OpenSim.Framework.BlockingQueue requests = new OpenSim.Framework.BlockingQueue();
-
- //private IConfig m_config;
- protected Scene m_scene;
- private List cachedMapBlocks = new List();
- private int cachedTime = 0;
- private byte[] myMapImageJPEG;
- protected bool m_Enabled = false;
- private Dictionary m_openRequests = new Dictionary();
- private Dictionary m_blacklistedurls = new Dictionary();
- private Dictionary m_blacklistedregions = new Dictionary();
- private Dictionary m_cachedRegionMapItemsAddress = new Dictionary();
- private List m_rootAgents = new List();
- private Thread mapItemReqThread;
- private volatile bool threadrunning = false;
-
- //private int CacheRegionsDistance = 256;
-
- #region IRegionModule Members
-
- public virtual void Initialise(Scene scene, IConfigSource config)
- {
- IConfig startupConfig = config.Configs["Startup"];
- if (startupConfig.GetString("WorldMapModule", "WorldMap") ==
- "WorldMap")
- m_Enabled = true;
-
- if (!m_Enabled)
- return;
-
- m_scene = scene;
- }
-
- public virtual void PostInitialise()
- {
- if (m_Enabled)
- AddHandlers();
- }
-
- public virtual void Close()
- {
- }
-
- public virtual string Name
- {
- get { return "WorldMapModule"; }
- }
-
- public bool IsSharedModule
- {
- get { return false; }
- }
-
- #endregion
-
- protected virtual void AddHandlers()
- {
- myMapImageJPEG = new byte[0];
-
- string regionimage = "regionImage" + m_scene.RegionInfo.RegionID.ToString();
- regionimage = regionimage.Replace("-", "");
- m_log.Info("[WORLD MAP]: JPEG Map location: http://" + m_scene.RegionInfo.ExternalEndPoint.Address.ToString() + ":" + m_scene.RegionInfo.HttpPort.ToString() + "/index.php?method=" + regionimage);
-
- m_scene.CommsManager.HttpServer.AddHTTPHandler(regionimage, OnHTTPGetMapImage);
- m_scene.CommsManager.HttpServer.AddLLSDHandler(
- "/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest);
-
- m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
- m_scene.EventManager.OnNewClient += OnNewClient;
- m_scene.EventManager.OnClientClosed += ClientLoggedOut;
- m_scene.EventManager.OnMakeChildAgent += MakeChildAgent;
- m_scene.EventManager.OnMakeRootAgent += MakeRootAgent;
- }
-
- public void OnRegisterCaps(UUID agentID, Caps caps)
- {
- //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
- string capsBase = "/CAPS/" + caps.CapsObjectPath;
- caps.RegisterHandler("MapLayer",
- new RestStreamHandler("POST", capsBase + m_mapLayerPath,
- delegate(string request, string path, string param,
- OSHttpRequest httpRequest, OSHttpResponse httpResponse)
- {
- return MapLayerRequest(request, path, param,
- agentID, caps);
- }));
- }
-
- ///
- /// Callback for a map layer request
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public string MapLayerRequest(string request, string path, string param,
- UUID agentID, Caps caps)
- {
- //try
- //{
- //m_log.DebugFormat("[MAPLAYER]: request: {0}, path: {1}, param: {2}, agent:{3}",
- //request, path, param,agentID.ToString());
-
- // this is here because CAPS map requests work even beyond the 10,000 limit.
- ScenePresence avatarPresence = null;
-
- m_scene.TryGetAvatar(agentID, out avatarPresence);
-
- if (avatarPresence != null)
- {
- bool lookup = false;
-
- lock (cachedMapBlocks)
- {
- if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch()))
- {
- List mapBlocks;
-
- mapBlocks = cachedMapBlocks;
- avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
- }
- else
- {
- lookup = true;
- }
- }
- if (lookup)
- {
- List mapBlocks;
-
- mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks((int)m_scene.RegionInfo.RegionLocX - 8, (int)m_scene.RegionInfo.RegionLocY - 8, (int)m_scene.RegionInfo.RegionLocX + 8, (int)m_scene.RegionInfo.RegionLocY + 8);
- avatarPresence.ControllingClient.SendMapBlock(mapBlocks,0);
-
- lock (cachedMapBlocks)
- cachedMapBlocks = mapBlocks;
-
- cachedTime = Util.UnixTimeSinceEpoch();
- }
- }
- LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
- mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
- return mapResponse.ToString();
- }
-
- ///
- ///
- ///
- ///
- ///
- public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq)
- {
- m_log.Debug("[WORLD MAP]: MapLayer Request in region: " + m_scene.RegionInfo.RegionName);
- LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
- mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
- return mapResponse;
- }
-
- ///
- ///
- ///
- ///
- protected static OSDMapLayer GetOSDMapLayerResponse()
- {
- OSDMapLayer mapLayer = new OSDMapLayer();
- mapLayer.Right = 5000;
- mapLayer.Top = 5000;
- mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006");
-
- return mapLayer;
- }
- #region EventHandlers
-
- ///
- /// Registered for event
- ///
- ///
- private void OnNewClient(IClientAPI client)
- {
- client.OnRequestMapBlocks += RequestMapBlocks;
- client.OnMapItemRequest += HandleMapItemRequest;
- }
-
- ///
- /// Client logged out, check to see if there are any more root agents in the simulator
- /// If not, stop the mapItemRequest Thread
- /// Event handler
- ///
- /// AgentID that logged out
- private void ClientLoggedOut(UUID AgentId)
- {
- List presences = m_scene.GetAvatars();
- int rootcount = 0;
- for (int i=0;i
- /// Starts the MapItemRequest Thread
- /// Note that this only gets started when there are actually agents in the region
- /// Additionally, it gets stopped when there are none.
- ///
- ///
- private void StartThread(object o)
- {
- if (threadrunning) return;
- threadrunning = true;
- m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread");
- mapItemReqThread = new Thread(new ThreadStart(process));
- mapItemReqThread.IsBackground = true;
- mapItemReqThread.Name = "MapItemRequestThread";
- mapItemReqThread.Priority = ThreadPriority.BelowNormal;
- mapItemReqThread.SetApartmentState(ApartmentState.MTA);
- mapItemReqThread.Start();
- ThreadTracker.Add(mapItemReqThread);
- }
-
- ///
- /// Enqueues a 'stop thread' MapRequestState. Causes the MapItemRequest thread to end
- ///
- private void StopThread()
- {
- MapRequestState st = new MapRequestState();
- st.agentID=UUID.Zero;
- st.EstateID=0;
- st.flags=0;
- st.godlike=false;
- st.itemtype=0;
- st.regionhandle=0;
-
- requests.Enqueue(st);
- }
-
- public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
- uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
- {
- lock (m_rootAgents)
- {
- if (!m_rootAgents.Contains(remoteClient.AgentId))
- return;
- }
- uint xstart = 0;
- uint ystart = 0;
- Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out xstart, out ystart);
- if (itemtype == 6) // we only sevice 6 right now (avatar green dots)
- {
- if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
- {
- // Local Map Item Request
- List avatars = m_scene.GetAvatars();
- int tc = System.Environment.TickCount;
- List mapitems = new List();
- mapItemReply mapitem = new mapItemReply();
- if (avatars.Count == 0 || avatars.Count == 1)
- {
- mapitem = new mapItemReply();
- mapitem.x = (uint)(xstart + 1);
- mapitem.y = (uint)(ystart + 1);
- mapitem.id = UUID.Zero;
- mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString());
- mapitem.Extra = 0;
- mapitem.Extra2 = 0;
- mapitems.Add(mapitem);
- }
- else
- {
- foreach (ScenePresence av in avatars)
- {
- // Don't send a green dot for yourself
- if (av.UUID != remoteClient.AgentId)
- {
- mapitem = new mapItemReply();
- mapitem.x = (uint)(xstart + av.AbsolutePosition.X);
- mapitem.y = (uint)(ystart + av.AbsolutePosition.Y);
- mapitem.id = UUID.Zero;
- mapitem.name = Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString());
- mapitem.Extra = 1;
- mapitem.Extra2 = 0;
- mapitems.Add(mapitem);
- }
- }
- }
- remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
- }
- else
- {
- // Remote Map Item Request
-
- // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
- // Note that we only start up a remote mapItem Request thread if there's users who could
- // be making requests
- if (!threadrunning)
- {
- m_log.Warn("[WORLD MAP]: Starting new remote request thread manually. This means that AvatarEnteringParcel never fired! This needs to be fixed! Don't Mantis this, as the developers can see it in this message");
- StartThread(new object());
- }
-
- RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
- }
- }
- }
-
- ///
- /// Processing thread main() loop for doing remote mapitem requests
- ///
- public void process()
- {
- try
- {
- while (true)
- {
- MapRequestState st = requests.Dequeue();
-
- // end gracefully
- if (st.agentID == UUID.Zero)
- {
- ThreadTracker.Remove(mapItemReqThread);
- break;
- }
-
- bool dorequest = true;
- lock (m_rootAgents)
- {
- if (!m_rootAgents.Contains(st.agentID))
- dorequest = false;
- }
-
- if (dorequest)
- {
- OSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle);
- RequestMapItemsCompleted(response);
- }
- }
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("[WORLD MAP]: Map item request thread terminated abnormally with exception {0}", e);
- }
-
- threadrunning = false;
- }
-
- ///
- /// Enqueues the map item request into the processing thread
- ///
- ///
- public void EnqueueMapItemRequest(MapRequestState state)
- {
- requests.Enqueue(state);
- }
-
- ///
- /// Sends the mapitem response to the IClientAPI
- ///
- /// The OSDMap Response for the mapitem
- private void RequestMapItemsCompleted(OSDMap response)
- {
- UUID requestID = response["requestID"].AsUUID();
-
- if (requestID != UUID.Zero)
- {
- MapRequestState mrs = new MapRequestState();
- mrs.agentID = UUID.Zero;
- lock (m_openRequests)
- {
- if (m_openRequests.ContainsKey(requestID))
- {
- mrs = m_openRequests[requestID];
- m_openRequests.Remove(requestID);
- }
- }
-
- if (mrs.agentID != UUID.Zero)
- {
- ScenePresence av = null;
- m_scene.TryGetAvatar(mrs.agentID, out av);
- if (av != null)
- {
- if (response.ContainsKey(mrs.itemtype.ToString()))
- {
- List returnitems = new List();
- OSDArray itemarray = (OSDArray)response[mrs.itemtype.ToString()];
- for (int i = 0; i < itemarray.Count; i++)
- {
- OSDMap mapitem = (OSDMap)itemarray[i];
- mapItemReply mi = new mapItemReply();
- mi.x = (uint)mapitem["X"].AsInteger();
- mi.y = (uint)mapitem["Y"].AsInteger();
- mi.id = mapitem["ID"].AsUUID();
- mi.Extra = mapitem["Extra"].AsInteger();
- mi.Extra2 = mapitem["Extra2"].AsInteger();
- mi.name = mapitem["Name"].AsString();
- returnitems.Add(mi);
- }
- av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags);
- }
- }
- }
- }
- }
-
- ///
- /// Enqueue the MapItem request for remote processing
- ///
- /// blank string, we discover this in the process
- /// Agent ID that we are making this request on behalf
- /// passed in from packet
- /// passed in from packet
- /// passed in from packet
- /// passed in from packet
- /// Region we're looking up
- public void RequestMapItems(string httpserver, UUID id, uint flags,
- uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
- {
- MapRequestState st = new MapRequestState();
- st.agentID = id;
- st.flags = flags;
- st.EstateID = EstateID;
- st.godlike = godlike;
- st.itemtype = itemtype;
- st.regionhandle = regionhandle;
- EnqueueMapItemRequest(st);
- }
-
- ///
- /// Does the actual remote mapitem request
- /// This should be called from an asynchronous thread
- /// Request failures get blacklisted until region restart so we don't
- /// continue to spend resources trying to contact regions that are down.
- ///
- /// blank string, we discover this in the process
- /// Agent ID that we are making this request on behalf
- /// passed in from packet
- /// passed in from packet
- /// passed in from packet
- /// passed in from packet
- /// Region we're looking up
- ///
- private OSDMap RequestMapItemsAsync(string httpserver, UUID id, uint flags,
- uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
- {
- bool blacklisted = false;
- lock (m_blacklistedregions)
- {
- if (m_blacklistedregions.ContainsKey(regionhandle))
- blacklisted = true;
- }
-
- if (blacklisted)
- return new OSDMap();
-
- UUID requestID = UUID.Random();
- lock (m_cachedRegionMapItemsAddress)
- {
- if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle))
- httpserver = m_cachedRegionMapItemsAddress[regionhandle];
- }
- if (httpserver.Length == 0)
- {
- RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle);
-
- if (mreg != null)
- {
- httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString();
- lock (m_cachedRegionMapItemsAddress)
- {
- if (!m_cachedRegionMapItemsAddress.ContainsKey(regionhandle))
- m_cachedRegionMapItemsAddress.Add(regionhandle, httpserver);
- }
- }
- else
- {
- lock (m_blacklistedregions)
- {
- if (!m_blacklistedregions.ContainsKey(regionhandle))
- m_blacklistedregions.Add(regionhandle, System.Environment.TickCount);
- }
- m_log.InfoFormat("[WORLD MAP]: Blacklisted region {0}", regionhandle.ToString());
- }
- }
-
- blacklisted = false;
- lock (m_blacklistedurls)
- {
- if (m_blacklistedurls.ContainsKey(httpserver))
- blacklisted = true;
- }
-
- // Can't find the http server
- if (httpserver.Length == 0 || blacklisted)
- return new OSDMap();
-
- MapRequestState mrs = new MapRequestState();
- mrs.agentID = id;
- mrs.EstateID = EstateID;
- mrs.flags = flags;
- mrs.godlike = godlike;
- mrs.itemtype=itemtype;
- mrs.regionhandle = regionhandle;
-
- lock (m_openRequests)
- m_openRequests.Add(requestID, mrs);
-
- WebRequest mapitemsrequest = WebRequest.Create(httpserver);
- mapitemsrequest.Method = "POST";
- mapitemsrequest.ContentType = "application/xml+llsd";
- OSDMap RAMap = new OSDMap();
-
- // string RAMapString = RAMap.ToString();
- OSD LLSDofRAMap = RAMap; // RENAME if this works
-
- byte[] buffer = OSDParser.SerializeLLSDXmlBytes(LLSDofRAMap);
- OSDMap responseMap = new OSDMap();
- responseMap["requestID"] = OSD.FromUUID(requestID);
-
- Stream os = null;
- try
- { // send the Post
- mapitemsrequest.ContentLength = buffer.Length; //Count bytes to send
- os = mapitemsrequest.GetRequestStream();
- os.Write(buffer, 0, buffer.Length); //Send it
- os.Close();
- //m_log.DebugFormat("[WORLD MAP]: Getting MapItems from Sim {0}", httpserver);
- }
- catch (WebException ex)
- {
- m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message);
- responseMap["connect"] = OSD.FromBoolean(false);
- lock (m_blacklistedurls)
- {
- if (!m_blacklistedurls.ContainsKey(httpserver))
- m_blacklistedurls.Add(httpserver, System.Environment.TickCount);
- }
-
- m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver);
-
- return responseMap;
- }
-
- string response_mapItems_reply = null;
- { // get the response
- try
- {
- WebResponse webResponse = mapitemsrequest.GetResponse();
- if (webResponse != null)
- {
- StreamReader sr = new StreamReader(webResponse.GetResponseStream());
- response_mapItems_reply = sr.ReadToEnd().Trim();
- }
- else
- {
- return new OSDMap();
- }
- }
- catch (WebException)
- {
- responseMap["connect"] = OSD.FromBoolean(false);
- lock (m_blacklistedurls)
- {
- if (!m_blacklistedurls.ContainsKey(httpserver))
- m_blacklistedurls.Add(httpserver, System.Environment.TickCount);
- }
-
- m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver);
-
- return responseMap;
- }
- OSD rezResponse = null;
- try
- {
- rezResponse = OSDParser.DeserializeLLSDXml(response_mapItems_reply);
-
- responseMap = (OSDMap)rezResponse;
- responseMap["requestID"] = OSD.FromUUID(requestID);
- }
- catch (Exception)
- {
- //m_log.InfoFormat("[OGP]: exception on parse of rez reply {0}", ex.Message);
- responseMap["connect"] = OSD.FromBoolean(false);
-
- return responseMap;
- }
- }
- return responseMap;
- }
-
- ///
- /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
- ///
- ///
- ///
- ///
- ///
- public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
- {
- List mapBlocks;
- if ((flag & 0x10000) != 0) // user clicked on the map a tile that isn't visible
- {
- List response = new List();
-
- // this should return one mapblock at most. But make sure: Look whether the one we requested is in there
- mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
- if (mapBlocks != null)
- {
- foreach (MapBlockData block in mapBlocks)
- {
- if (block.X == minX && block.Y == minY)
- {
- // found it => add it to response
- response.Add(block);
- break;
- }
- }
- }
-
- if (response.Count == 0)
- {
- // response still empty => couldn't find the map-tile the user clicked on => tell the client
- MapBlockData block = new MapBlockData();
- block.X = (ushort)minX;
- block.Y = (ushort)minY;
- block.Access = 254; // == not there
- response.Add(block);
- }
- remoteClient.SendMapBlock(response, 0);
- }
- else
- {
- // normal mapblock request. Use the provided values
- mapBlocks = m_scene.SceneGridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, maxX + 4, maxY + 4);
- remoteClient.SendMapBlock(mapBlocks, flag);
- }
- }
-
- public Hashtable OnHTTPGetMapImage(Hashtable keysvals)
- {
- m_log.Debug("[WORLD MAP]: Sending map image jpeg");
- Hashtable reply = new Hashtable();
- int statuscode = 200;
- byte[] jpeg = new byte[0];
-
- if (myMapImageJPEG.Length == 0)
- {
- MemoryStream imgstream = new MemoryStream();
- Bitmap mapTexture = new Bitmap(1,1);
- ManagedImage managedImage;
- Image image = (Image)mapTexture;
-
- try
- {
- // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular jpeg data
-
- imgstream = new MemoryStream();
-
- // non-async because we know we have the asset immediately.
- AssetBase mapasset = m_scene.AssetCache.GetAsset(m_scene.RegionInfo.lastMapUUID, true);
-
- // Decode image to System.Drawing.Image
- if (OpenJPEG.DecodeToImage(mapasset.Data, out managedImage, out image))
- {
- // Save to bitmap
- mapTexture = new Bitmap(image);
-
- EncoderParameters myEncoderParameters = new EncoderParameters();
- myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L);
-
- // Save bitmap to stream
- mapTexture.Save(imgstream, GetEncoderInfo("image/jpeg"), myEncoderParameters);
-
- // Write the stream to a byte array for output
- jpeg = imgstream.ToArray();
- myMapImageJPEG = jpeg;
- }
- }
- catch (Exception)
- {
- // Dummy!
- m_log.Warn("[WORLD MAP]: Unable to generate Map image");
- }
- finally
- {
- // Reclaim memory, these are unmanaged resources
- mapTexture.Dispose();
- image.Dispose();
- imgstream.Close();
- imgstream.Dispose();
- }
- }
- else
- {
- // Use cached version so we don't have to loose our mind
- jpeg = myMapImageJPEG;
- }
-
- reply["str_response_string"] = Convert.ToBase64String(jpeg);
- reply["int_response_code"] = statuscode;
- reply["content_type"] = "image/jpeg";
-
- return reply;
- }
-
- // From msdn
- private static ImageCodecInfo GetEncoderInfo(String mimeType)
- {
- ImageCodecInfo[] encoders;
- encoders = ImageCodecInfo.GetImageEncoders();
- for (int j = 0; j < encoders.Length; ++j)
- {
- if (encoders[j].MimeType == mimeType)
- return encoders[j];
- }
- return null;
- }
-
- public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
- {
- uint xstart = 0;
- uint ystart = 0;
-
- Utils.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);
-
- OSDMap responsemap = new OSDMap();
- List avatars = m_scene.GetAvatars();
- OSDArray responsearr = new OSDArray(avatars.Count);
- OSDMap responsemapdata = new OSDMap();
- int tc = System.Environment.TickCount;
- /*
- foreach (ScenePresence av in avatars)
- {
- responsemapdata = new OSDMap();
- responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
- responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
- responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
- responsemapdata["Name"] = OSD.FromString("TH");
- responsemapdata["Extra"] = OSD.FromInteger(0);
- responsemapdata["Extra2"] = OSD.FromInteger(0);
- responsearr.Add(responsemapdata);
- }
- responsemap["1"] = responsearr;
- */
- if (avatars.Count == 0)
- {
- responsemapdata = new OSDMap();
- responsemapdata["X"] = OSD.FromInteger((int)(xstart + 1));
- responsemapdata["Y"] = OSD.FromInteger((int)(ystart + 1));
- responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
- responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
- responsemapdata["Extra"] = OSD.FromInteger(0);
- responsemapdata["Extra2"] = OSD.FromInteger(0);
- responsearr.Add(responsemapdata);
-
- responsemap["6"] = responsearr;
- }
- else
- {
- responsearr = new OSDArray(avatars.Count);
- foreach (ScenePresence av in avatars)
- {
- responsemapdata = new OSDMap();
- responsemapdata["X"] = OSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
- responsemapdata["Y"] = OSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
- responsemapdata["ID"] = OSD.FromUUID(UUID.Zero);
- responsemapdata["Name"] = OSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
- responsemapdata["Extra"] = OSD.FromInteger(1);
- responsemapdata["Extra2"] = OSD.FromInteger(0);
- responsearr.Add(responsemapdata);
- }
- responsemap["6"] = responsearr;
- }
- return responsemap;
- }
-
- private void MakeRootAgent(ScenePresence avatar)
- {
- // You may ask, why this is in a threadpool to start with..
- // The reason is so we don't cause the thread to freeze waiting
- // for the 1 second it costs to start a thread manually.
- if (!threadrunning)
- ThreadPool.QueueUserWorkItem(new WaitCallback(this.StartThread));
-
- lock (m_rootAgents)
- {
- if (!m_rootAgents.Contains(avatar.UUID))
- {
- m_rootAgents.Add(avatar.UUID);
- }
- }
- }
-
- private void MakeChildAgent(ScenePresence avatar)
- {
- List presences = m_scene.GetAvatars();
- int rootcount = 0;
- for (int i = 0; i < presences.Count; i++)
- {
- if (presences[i] != null)
- {
- if (!presences[i].IsChildAgent)
- rootcount++;
- }
- }
- if (rootcount <= 1)
- StopThread();
-
- lock (m_rootAgents)
- {
- if (m_rootAgents.Contains(avatar.UUID))
- {
- m_rootAgents.Remove(avatar.UUID);
- }
- }
- }
- }
-
- public struct MapRequestState
- {
- public UUID agentID;
- public uint flags;
- public uint EstateID;
- public bool godlike;
- public uint itemtype;
- public ulong regionhandle;
- }
-}
--
cgit v1.1