From 8f0b03597b0bc8ea6873af9a55495407fae1ec56 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 19 Sep 2007 00:30:55 +0000 Subject: * Modernized ScriptManager to new interface-based module calls. * 'remove redundant this qualifier' ftw --- OpenSim/Region/Environment/EstateManager.cs | 81 +++-- .../Interfaces/IDynamicTextureManager.cs | 21 +- .../Region/Environment/Interfaces/IHttpRequests.cs | 9 +- .../Environment/Interfaces/IRegionDataStore.cs | 9 +- .../Region/Environment/Interfaces/IRegionModule.cs | 10 +- OpenSim/Region/Environment/Interfaces/ISimChat.cs | 9 +- OpenSim/Region/Environment/Interfaces/ITerrain.cs | 16 +- OpenSim/Region/Environment/Interfaces/IXfer.cs | 6 +- OpenSim/Region/Environment/LandManagement/Land.cs | 149 ++++---- .../Environment/LandManagement/LandManager.cs | 122 ++++--- OpenSim/Region/Environment/ModuleLoader.cs | 66 ++-- .../Environment/Modules/AssetDownloadModule.cs | 21 +- .../Environment/Modules/AvatarProfilesModule.cs | 32 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 50 ++- .../Environment/Modules/DynamicTextureModule.cs | 56 ++- OpenSim/Region/Environment/Modules/EmailModule.cs | 8 +- .../Region/Environment/Modules/FriendsModule.cs | 17 +- OpenSim/Region/Environment/Modules/GroupsModule.cs | 17 +- .../Environment/Modules/InstantMessageModule.cs | 19 +- .../Region/Environment/Modules/InventoryModule.cs | 19 +- .../Environment/Modules/ScriptsHttpRequests.cs | 8 +- .../Region/Environment/Modules/TeleportModule.cs | 8 +- .../Environment/Modules/TextureDownloadModule.cs | 26 +- OpenSim/Region/Environment/Modules/XferModule.cs | 41 +-- OpenSim/Region/Environment/PermissionManager.cs | 38 +- OpenSim/Region/Environment/RegionManager.cs | 33 +- OpenSim/Region/Environment/Scenes/EntityBase.cs | 21 +- .../Environment/Scenes/IScenePresenceBody.cs | 2 +- .../Region/Environment/Scenes/Scene.Inventory.cs | 134 +++---- .../Environment/Scenes/Scene.PacketHandlers.cs | 115 +++--- OpenSim/Region/Environment/Scenes/Scene.cs | 284 +++++++-------- OpenSim/Region/Environment/Scenes/SceneBase.cs | 16 +- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 21 +- OpenSim/Region/Environment/Scenes/SceneManager.cs | 54 +-- .../Region/Environment/Scenes/SceneObjectGroup.cs | 402 ++++++++++++--------- .../Region/Environment/Scenes/SceneObjectPart.cs | 345 ++++++++++-------- .../Environment/Scenes/ScenePresence.Animations.cs | 5 +- .../Environment/Scenes/ScenePresence.Body.cs | 5 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 393 ++++++++++---------- .../Environment/Scenes/Scripting/IScriptHost.cs | 20 +- .../Environment/Scenes/Scripting/NullScriptHost.cs | 28 +- .../Scenes/Scripting/ScriptEngineInterface.cs | 14 +- .../Scenes/Scripting/ScriptEngineLoader.cs | 38 +- OpenSim/Region/Environment/StorageManager.cs | 26 +- .../Region/Environment/Types/BasicQuadTreeNode.cs | 45 ++- OpenSim/Region/Environment/Types/UpdateQueue.cs | 15 +- .../Region/ExtensionsScriptModule/ScriptManager.cs | 43 ++- 47 files changed, 1456 insertions(+), 1461 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index 92e1956..30d206f 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs @@ -39,7 +39,6 @@ using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence; namespace OpenSim.Region.Environment { - /// /// Processes requests regarding estates. Refer to EstateSettings.cs in OpenSim.Framework. Types for all of the core settings /// @@ -48,9 +47,9 @@ namespace OpenSim.Region.Environment private Scene m_scene; private RegionInfo m_regInfo; - public EstateManager(Scene scene,RegionInfo reginfo) + public EstateManager(Scene scene, RegionInfo reginfo) { - m_scene = scene; + m_scene = scene; m_regInfo = reginfo; } @@ -125,7 +124,8 @@ namespace OpenSim.Region.Environment /// Minimum amount terrain can be lowered from previous baking /// Use a fixed time of day on the sun? /// The offset hour of the day - public void setRegionSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit, bool UseFixedSun, float SunHour) + public void setRegionSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit, + bool UseFixedSun, float SunHour) { // Water Height m_regInfo.estateSettings.waterHeight = WaterHeight; @@ -144,13 +144,12 @@ namespace OpenSim.Region.Environment #region Packet Handlers - public void handleEstateOwnerMessage(EstateOwnerMessagePacket packet, IClientAPI remote_client) { switch (Helpers.FieldToUTF8String(packet.MethodData.Method)) { case "getinfo": - this.sendRegionInfoPacketToAll(); + sendRegionInfoPacketToAll(); break; case "setregioninfo": if (m_scene.PermissionsMngr.CanEditEstateTerrain(remote_client.AgentId)) @@ -193,47 +192,54 @@ namespace OpenSim.Region.Environment if (convertParamStringToBool(packet.ParamList[0].Parameter)) { - m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockTerraform; + m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | + Simulator.RegionFlags.BlockTerraform; } if (convertParamStringToBool(packet.ParamList[1].Parameter)) { - m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.NoFly; + m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | + Simulator.RegionFlags.NoFly; } if (convertParamStringToBool(packet.ParamList[2].Parameter)) { - m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowDamage; + m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | + Simulator.RegionFlags.AllowDamage; } if (convertParamStringToBool(packet.ParamList[3].Parameter) == false) { - m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.BlockLandResell; + m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | + Simulator.RegionFlags.BlockLandResell; } - int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter))); - m_regInfo.estateSettings.maxAgents = (byte)tempMaxAgents; + int tempMaxAgents = + Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter))); + m_regInfo.estateSettings.maxAgents = (byte) tempMaxAgents; - float tempObjectBonusFactor = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); + float tempObjectBonusFactor = + (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); m_regInfo.estateSettings.objectBonusFactor = tempObjectBonusFactor; int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter)); - m_regInfo.estateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel; + m_regInfo.estateSettings.simAccess = (Simulator.SimAccess) tempMatureLevel; if (convertParamStringToBool(packet.ParamList[7].Parameter)) { - m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.RestrictPushObject; + m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | + Simulator.RegionFlags.RestrictPushObject; } if (convertParamStringToBool(packet.ParamList[8].Parameter)) { - m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | Simulator.RegionFlags.AllowParcelChanges; + m_regInfo.estateSettings.regionFlags = m_regInfo.estateSettings.regionFlags | + Simulator.RegionFlags.AllowParcelChanges; } sendRegionInfoPacketToAll(); - } } @@ -245,11 +251,13 @@ namespace OpenSim.Region.Environment } else { - float WaterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); - float TerrainRaiseLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); - float TerrainLowerLimit = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); - bool UseFixedSun = this.convertParamStringToBool(packet.ParamList[4].Parameter); - float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); + float WaterHeight = (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); + float TerrainRaiseLimit = + (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); + float TerrainLowerLimit = + (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); + bool UseFixedSun = convertParamStringToBool(packet.ParamList[4].Parameter); + float SunHour = (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour); @@ -265,10 +273,9 @@ namespace OpenSim.Region.Environment string[] splitField = s.Split(' '); if (splitField.Length == 3) { - Int16 corner = Convert.ToInt16(splitField[0]); - float lowValue = (float)Convert.ToDecimal(splitField[1]); - float highValue = (float)Convert.ToDecimal(splitField[2]); + float lowValue = (float) Convert.ToDecimal(splitField[1]); + float highValue = (float) Convert.ToDecimal(splitField[2]); setEstateTextureRange(corner, lowValue, highValue); } @@ -279,7 +286,6 @@ namespace OpenSim.Region.Environment { foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) { - string s = Helpers.FieldToUTF8String(block.Parameter); string[] splitField = s.Split(' '); if (splitField.Length == 2) @@ -326,12 +332,12 @@ namespace OpenSim.Region.Environment public void sendRegionInfoPacketToAll() { - List avatars = m_scene.RequestAvatarList(); + List avatars = m_scene.RequestAvatarList(); - for (int i = 0; i < avatars.Count; i++) - { - this.sendRegionInfoPacket(avatars[i].ControllingClient); - } + for (int i = 0; i < avatars.Count; i++) + { + sendRegionInfoPacket(avatars[i].ControllingClient); + } } public void sendRegionHandshakeToAll() @@ -340,8 +346,8 @@ namespace OpenSim.Region.Environment for (int i = 0; i < avatars.Count; i++) { - this.sendRegionHandshake(avatars[i].ControllingClient); - } + sendRegionHandshake(avatars[i].ControllingClient); + } } public void sendRegionInfoPacket(IClientAPI remote_client) @@ -361,9 +367,9 @@ namespace OpenSim.Region.Environment regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.estateSettings.pricePerMeter; regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.estateSettings.redirectGridX; regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.estateSettings.redirectGridY; - regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.estateSettings.regionFlags; - regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.estateSettings.simAccess; - regionInfoPacket.RegionInfo.SimName = _enc.GetBytes( m_regInfo.RegionName); + regionInfoPacket.RegionInfo.RegionFlags = (uint) m_regInfo.estateSettings.regionFlags; + regionInfoPacket.RegionInfo.SimAccess = (byte) m_regInfo.estateSettings.simAccess; + regionInfoPacket.RegionInfo.SimName = _enc.GetBytes(m_regInfo.RegionName); regionInfoPacket.RegionInfo.SunHour = m_regInfo.estateSettings.sunHour; regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.estateSettings.terrainLowerLimit; regionInfoPacket.RegionInfo.TerrainRaiseLimit = m_regInfo.estateSettings.terrainRaiseLimit; @@ -379,6 +385,5 @@ namespace OpenSim.Region.Environment } #endregion - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs index 727b386..05cecf8 100644 --- a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs @@ -1,17 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using libsecondlife; - +using System.IO; +using libsecondlife; + namespace OpenSim.Region.Environment.Interfaces { public interface IDynamicTextureManager { void RegisterRender(string handleType, IDynamicTextureRender render); - void ReturnData(LLUUID id, byte[] data); - LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer); - LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer); + void ReturnData(LLUUID id, byte[] data); + + LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, + int updateTimer); + + LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, + int updateTimer); } public interface IDynamicTextureRender @@ -24,4 +25,4 @@ namespace OpenSim.Region.Environment.Interfaces bool AsyncConvertUrl(LLUUID id, string url, string extraParams); bool AsyncConvertData(LLUUID id, string bodyData, string extraParams); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs index e974e25..cb00b48 100644 --- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - +using libsecondlife; + namespace OpenSim.Region.Environment.Interfaces { public interface IHttpRequests { LLUUID MakeHttpRequest(string url, string type, string body); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index 89a0e8c..1a00f2c 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs @@ -26,15 +26,10 @@ * */ +using System.Collections.Generic; using libsecondlife; - -using OpenSim.Framework.Types; -using OpenSim.Region; -using OpenSim.Region.Environment; -using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.LandManagement; - -using System.Collections.Generic; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Interfaces { diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs index 47f3d92..981b73f 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs @@ -1,15 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; - +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Interfaces { public interface IRegionModule { - void Initialise(Scenes.Scene scene); + void Initialise(Scene scene); void PostInitialise(); void CloseDown(); string GetName(); bool IsSharedModule(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/ISimChat.cs b/OpenSim/Region/Environment/Interfaces/ISimChat.cs index f0adabc..5aa78ab 100644 --- a/OpenSim/Region/Environment/Interfaces/ISimChat.cs +++ b/OpenSim/Region/Environment/Interfaces/ISimChat.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - +using libsecondlife; + namespace OpenSim.Region.Environment.Interfaces { public interface ISimChat { void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/ITerrain.cs b/OpenSim/Region/Environment/Interfaces/ITerrain.cs index 576c5b4..f9ff71a 100644 --- a/OpenSim/Region/Environment/Interfaces/ITerrain.cs +++ b/OpenSim/Region/Environment/Interfaces/ITerrain.cs @@ -1,16 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Interfaces; - +using OpenSim.Framework.Interfaces; + namespace OpenSim.Region.Environment.Interfaces { public interface ITerrain { bool Tainted(); bool Tainted(int x, int y); - void ResetTaint(); - void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser); + void ResetTaint(); + + void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, + IClientAPI remoteUser); + void CheckHeightValues(); float[] GetHeights1D(); float[,] GetHeights2D(); @@ -43,4 +43,4 @@ namespace OpenSim.Region.Environment.Interfaces void ExportImage(string filename, string gradientmap); byte[] ExportJpegImage(string gradientmap); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IXfer.cs b/OpenSim/Region/Environment/Interfaces/IXfer.cs index 7482ec0..6fd4d6f 100644 --- a/OpenSim/Region/Environment/Interfaces/IXfer.cs +++ b/OpenSim/Region/Environment/Interfaces/IXfer.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.Environment.Interfaces { public interface IXfer { bool AddNewFile(string fileName, byte[] data); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index a1d8885..4d36650 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -8,37 +8,40 @@ using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.LandManagement { + #region Parcel Class + /// /// Keeps track of a specific piece of land's information /// public class Land { #region Member Variables + public LandData landData = new LandData(); public List primsOverMe = new List(); public Scene m_scene; - private bool[,] landBitmap = new bool[64, 64]; + private bool[,] landBitmap = new bool[64,64]; #endregion - #region Constructors + public Land(LLUUID owner_id, bool is_group_owned, Scene scene) { m_scene = scene; landData.ownerID = owner_id; landData.isGroupOwned = is_group_owned; - } - #endregion + #endregion #region Member Functions #region General Functions + /// /// Checks to see if this land object contains a point /// @@ -49,7 +52,7 @@ namespace OpenSim.Region.Environment.LandManagement { if (x >= 0 && y >= 0 && x <= 256 && x <= 256) { - return (landBitmap[x / 4, y / 4] == true); + return (landBitmap[x/4, y/4] == true); } else { @@ -59,10 +62,10 @@ namespace OpenSim.Region.Environment.LandManagement public Land Copy() { - Land newLand = new Land(this.landData.ownerID, this.landData.isGroupOwned, m_scene); + Land newLand = new Land(landData.ownerID, landData.isGroupOwned, m_scene); //Place all new variables here! - newLand.landBitmap = (bool[,])(this.landBitmap.Clone()); + newLand.landBitmap = (bool[,]) (landBitmap.Clone()); newLand.landData = landData.Copy(); return newLand; @@ -70,17 +73,17 @@ namespace OpenSim.Region.Environment.LandManagement #endregion - #region Packet Request Handling + /// /// Sends land properties as requested /// /// ID sent by client for them to keep track of /// Bool sent by client for them to use /// Object representing the client - public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) + public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, + IClientAPI remote_client) { - ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket(); updatePacket.ParcelData.AABBMax = landData.AABBMax; updatePacket.ParcelData.AABBMin = landData.AABBMin; @@ -91,17 +94,20 @@ namespace OpenSim.Region.Environment.LandManagement updatePacket.ParcelData.Bitmap = landData.landBitmapByteArray; updatePacket.ParcelData.Desc = Helpers.StringToField(landData.landDesc); - updatePacket.ParcelData.Category = (byte)landData.category; + updatePacket.ParcelData.Category = (byte) landData.category; updatePacket.ParcelData.ClaimDate = landData.claimDate; updatePacket.ParcelData.ClaimPrice = landData.claimPrice; updatePacket.ParcelData.GroupID = landData.groupID; updatePacket.ParcelData.GroupPrims = landData.groupPrims; updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned; - updatePacket.ParcelData.LandingType = (byte)landData.landingType; + updatePacket.ParcelData.LandingType = (byte) landData.landingType; updatePacket.ParcelData.LocalID = landData.localID; if (landData.area > 0) { - updatePacket.ParcelData.MaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_scene.RegionInfo.estateSettings.objectBonusFactor))); + updatePacket.ParcelData.MaxPrims = + Convert.ToInt32( + Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*15000* + Convert.ToDecimal(m_scene.RegionInfo.estateSettings.objectBonusFactor))); } else { @@ -122,22 +128,29 @@ namespace OpenSim.Region.Environment.LandManagement updatePacket.ParcelData.PassHours = landData.passHours; updatePacket.ParcelData.PassPrice = landData.passPrice; updatePacket.ParcelData.PublicCount = 0; //unemplemented - - uint regionFlags = (uint)m_scene.RegionInfo.estateSettings.regionFlags; - updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint)Simulator.RegionFlags.DenyAnonymous) > 0); - updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint)Simulator.RegionFlags.DenyIdentified) > 0); - updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint)Simulator.RegionFlags.DenyTransacted) > 0); - updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0); - + + uint regionFlags = (uint) m_scene.RegionInfo.estateSettings.regionFlags; + updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > + 0); + updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint) Simulator.RegionFlags.DenyIdentified) > + 0); + updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint) Simulator.RegionFlags.DenyTransacted) > + 0); + updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint) Simulator.RegionFlags.RestrictPushObject) > + 0); + updatePacket.ParcelData.RentPrice = 0; updatePacket.ParcelData.RequestResult = request_result; updatePacket.ParcelData.SalePrice = landData.salePrice; updatePacket.ParcelData.SelectedPrims = landData.selectedPrims; - updatePacket.ParcelData.SelfCount = 0;//unemplemented + updatePacket.ParcelData.SelfCount = 0; //unemplemented updatePacket.ParcelData.SequenceID = sequence_id; if (landData.simwideArea > 0) { - updatePacket.ParcelData.SimWideMaxPrims = Convert.ToInt32(Math.Round((Convert.ToDecimal(landData.simwideArea) / Convert.ToDecimal(65536)) * 15000 * Convert.ToDecimal(m_scene.RegionInfo.estateSettings.objectBonusFactor))); + updatePacket.ParcelData.SimWideMaxPrims = + Convert.ToInt32( + Math.Round((Convert.ToDecimal(landData.simwideArea)/Convert.ToDecimal(65536))*15000* + Convert.ToDecimal(m_scene.RegionInfo.estateSettings.objectBonusFactor))); } else { @@ -146,11 +159,12 @@ namespace OpenSim.Region.Environment.LandManagement updatePacket.ParcelData.SimWideTotalPrims = landData.simwidePrims; updatePacket.ParcelData.SnapSelection = snap_selection; updatePacket.ParcelData.SnapshotID = landData.snapshotID; - updatePacket.ParcelData.Status = (byte)landData.landStatus; - updatePacket.ParcelData.TotalPrims = landData.ownerPrims + landData.groupPrims + landData.otherPrims + landData.selectedPrims; + updatePacket.ParcelData.Status = (byte) landData.landStatus; + updatePacket.ParcelData.TotalPrims = landData.ownerPrims + landData.groupPrims + landData.otherPrims + + landData.selectedPrims; updatePacket.ParcelData.UserLocation = landData.userLocation; updatePacket.ParcelData.UserLookAt = landData.userLookAt; - remote_client.OutPacket((Packet)updatePacket); + remote_client.OutPacket((Packet) updatePacket); } public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client) @@ -159,7 +173,7 @@ namespace OpenSim.Region.Environment.LandManagement { //Needs later group support landData.authBuyerID = packet.ParcelData.AuthBuyerID; - landData.category = (libsecondlife.Parcel.ParcelCategory)packet.ParcelData.Category; + landData.category = (Parcel.ParcelCategory) packet.ParcelData.Category; landData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); landData.groupID = packet.ParcelData.GroupID; landData.landingType = packet.ParcelData.LandingType; @@ -176,8 +190,6 @@ namespace OpenSim.Region.Environment.LandManagement landData.userLocation = packet.ParcelData.UserLocation; landData.userLookAt = packet.ParcelData.UserLookAt; sendLandUpdateToAvatarsOverMe(); - - } } @@ -186,17 +198,20 @@ namespace OpenSim.Region.Environment.LandManagement List avatars = m_scene.RequestAvatarList(); for (int i = 0; i < avatars.Count; i++) { - Land over = m_scene.LandManager.getLandObject((int)Math.Round(avatars[i].AbsolutePosition.X), (int)Math.Round(avatars[i].AbsolutePosition.Y)); - if (over.landData.localID == this.landData.localID) + Land over = + m_scene.LandManager.getLandObject((int) Math.Round(avatars[i].AbsolutePosition.X), + (int) Math.Round(avatars[i].AbsolutePosition.Y)); + if (over.landData.localID == landData.localID) { sendLandProperties(0, false, 0, avatars[i].ControllingClient); } } } - #endregion + #endregion #region Update Functions + /// /// Updates the AABBMin and AABBMax values after area/shape modification of the land object /// @@ -222,8 +237,12 @@ namespace OpenSim.Region.Environment.LandManagement } } } - landData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_scene.Terrain.GetHeight((min_x * 4), (min_y * 4))); - landData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_scene.Terrain.GetHeight((max_x * 4), (max_y * 4))); + landData.AABBMin = + new LLVector3((float) (min_x*4), (float) (min_y*4), + (float) m_scene.Terrain.GetHeight((min_x*4), (min_y*4))); + landData.AABBMax = + new LLVector3((float) (max_x*4), (float) (max_y*4), + (float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4))); landData.area = tempArea; } @@ -237,18 +256,19 @@ namespace OpenSim.Region.Environment.LandManagement /// public void forceUpdateLandInfo() { - this.updateAABBAndAreaValues(); - this.updateLandBitmapByteArray(); + updateAABBAndAreaValues(); + updateLandBitmapByteArray(); } public void setLandBitmapFromByteArray() { landBitmap = convertBytesToLandBitmap(); } - #endregion + #endregion #region Land Bitmap Functions + /// /// Sets the land's bitmap manually /// @@ -265,9 +285,9 @@ namespace OpenSim.Region.Environment.LandManagement //Valid: Lets set it landBitmap = bitmap; forceUpdateLandInfo(); - } } + /// /// Gets the land's bitmap manually /// @@ -276,6 +296,7 @@ namespace OpenSim.Region.Environment.LandManagement { return landBitmap; } + /// /// Converts the land bitmap to a packet friendly byte array /// @@ -290,11 +311,11 @@ namespace OpenSim.Region.Environment.LandManagement { for (x = 0; x < 64; x++) { - tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8)); - if (i % 8 == 0) + tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8)); + if (i%8 == 0) { tempConvertArr[byteNum] = tempByte; - tempByte = (byte)0; + tempByte = (byte) 0; i = 0; byteNum++; } @@ -305,7 +326,7 @@ namespace OpenSim.Region.Environment.LandManagement private bool[,] convertBytesToLandBitmap() { - bool[,] tempConvertMap = new bool[64, 64]; + bool[,] tempConvertMap = new bool[64,64]; tempConvertMap.Initialize(); byte tempByte = 0; int x = 0, y = 0, i = 0, bitNum = 0; @@ -314,7 +335,7 @@ namespace OpenSim.Region.Environment.LandManagement tempByte = landData.landBitmapByteArray[i]; for (bitNum = 0; bitNum < 8; bitNum++) { - bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte)1); + bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1); tempConvertMap[x, y] = bit; x++; if (x > 63) @@ -322,12 +343,11 @@ namespace OpenSim.Region.Environment.LandManagement x = 0; y++; } - } - } return tempConvertMap; } + /// /// Full sim land object creation /// @@ -347,8 +367,7 @@ namespace OpenSim.Region.Environment.LandManagement /// public static bool[,] getSquareLandBitmap(int start_x, int start_y, int end_x, int end_y) { - - bool[,] tempBitmap = new bool[64, 64]; + bool[,] tempBitmap = new bool[64,64]; tempBitmap.Initialize(); tempBitmap = modifyLandBitmapSquare(tempBitmap, start_x, start_y, end_x, end_y, true); @@ -365,7 +384,8 @@ namespace OpenSim.Region.Environment.LandManagement /// /// /// - public static bool[,] modifyLandBitmapSquare(bool[,] land_bitmap, int start_x, int start_y, int end_x, int end_y, bool set_value) + public static 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) { @@ -378,8 +398,8 @@ namespace OpenSim.Region.Environment.LandManagement { for (x = 0; x < 64; x++) { - if (x >= start_x / 4 && x < end_x / 4 - && y >= start_y / 4 && y < end_y / 4) + if (x >= start_x/4 && x < end_x/4 + && y >= start_y/4 && y < end_y/4) { land_bitmap[x, y] = set_value; } @@ -387,6 +407,7 @@ namespace OpenSim.Region.Environment.LandManagement } return land_bitmap; } + /// /// Join the true values of 2 bitmaps together /// @@ -404,7 +425,6 @@ namespace OpenSim.Region.Environment.LandManagement { //Throw an exception - The bitmap is not 64x64 throw new Exception("Error: Invalid Parcel Bitmap - Bitmap_add in mergeLandBitmaps"); - } int x, y; @@ -420,9 +440,11 @@ namespace OpenSim.Region.Environment.LandManagement } return bitmap_base; } + #endregion #region Object Select and Object Owner Listing + public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) { List resultLocalIDs = new List(); @@ -430,15 +452,16 @@ namespace OpenSim.Region.Environment.LandManagement { if (obj.LocalId > 0) { - if (request_type == LandManager.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == this.landData.ownerID) + if (request_type == LandManager.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == landData.ownerID) { resultLocalIDs.Add(obj.LocalId); } - else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && false) //TODO: change false to group support! + else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && false) + //TODO: change false to group support! { - } - else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && obj.OwnerID != remote_client.AgentId) + else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && + obj.OwnerID != remote_client.AgentId) { resultLocalIDs.Add(obj.LocalId); } @@ -479,10 +502,10 @@ namespace OpenSim.Region.Environment.LandManagement resultLocalIDs.RemoveAt(0); } pack.Data = data; - remote_client.OutPacket((Packet)pack); + remote_client.OutPacket((Packet) pack); } - } + public void sendLandObjectOwners(IClientAPI remote_client) { Dictionary ownersAndCount = new Dictionary(); @@ -496,7 +519,6 @@ namespace OpenSim.Region.Environment.LandManagement } if (ownersAndCount.Count > 0) { - ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock = new ParcelObjectOwnersReplyPacket.DataBlock[32]; if (ownersAndCount.Count < 32) @@ -522,19 +544,23 @@ namespace OpenSim.Region.Environment.LandManagement remote_client.OutPacket(pack); } } + #endregion #region Object Returning + public void returnObject(SceneObjectGroup obj) { } + public void returnLandObjects(int type, LLUUID owner) { - } + #endregion #region Object Adding/Removing from Parcel + public void resetLandPrimCounts() { landData.groupPrims = 0; @@ -566,7 +592,6 @@ namespace OpenSim.Region.Environment.LandManagement } primsOverMe.Add(obj); - } public void removePrimFromCount(SceneObjectGroup obj) @@ -592,11 +617,11 @@ namespace OpenSim.Region.Environment.LandManagement primsOverMe.Remove(obj); } } - #endregion #endregion - + #endregion } + #endregion -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index 8e49811..843c0f5 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -36,34 +36,34 @@ using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.LandManagement { - #region LandManager Class + /// /// Handles Land objects and operations requiring information from other Land objects (divide, join, etc) /// public class LandManager { - #region Constants + //Land types set with flags in ParcelOverlay. //Only one of these can be used. - public const byte LAND_TYPE_PUBLIC = (byte)0; //Equals 00000000 - public const byte LAND_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 - public const byte LAND_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010 - public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011 - public const byte LAND_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100 - public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101 + public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000 + public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001 + public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010 + public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011 + public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100 + public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101 //Flags that when set, a border on the given side will be placed //NOTE: North and East is assumable by the west and south sides (if land to east has a west border, then I have an east border; etc) //This took forever to figure out -- jeesh. /blame LL for even having to send these - public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000 - public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000 + public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000 + public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000 //RequestResults (I think these are right, they seem to work): - public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land - 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 + public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land //ParcelSelectObjects public const int LAND_SELECT_OBJECTS_OWNER = 2; @@ -73,12 +73,14 @@ namespace OpenSim.Region.Environment.LandManagement //These are other constants. Yay! public const int START_LAND_LOCAL_ID = 1; + #endregion #region Member Variables + public Dictionary landList = new Dictionary(); private int lastLandLocalID = START_LAND_LOCAL_ID - 1; - private int[,] landIDList = new int[64, 64]; + private int[,] landIDList = new int[64,64]; /// /// Set to true when a prim is moved, created, added. Performs a prim count update @@ -91,35 +93,37 @@ namespace OpenSim.Region.Environment.LandManagement #endregion #region Constructors + public LandManager(Scene scene, RegionInfo reginfo) { - m_scene = scene; m_regInfo = reginfo; landIDList.Initialize(); - } + #endregion #region Member Functions #region Parcel From Storage Functions + public void LandFromStorage(LandData data) { Land new_land = new Land(data.ownerID, data.isGroupOwned, m_scene); new_land.landData = data.Copy(); new_land.setLandBitmapFromByteArray(); addLandObject(new_land); - } public void NoLandDataFromStorage() { resetSimLandObjects(); } + #endregion #region Parcel Add/Remove/Get/Create + /// /// Creates a basic Parcel object without an owner (a zeroed key) /// @@ -155,8 +159,8 @@ namespace OpenSim.Region.Environment.LandManagement landList[lastLandLocalID].forceUpdateLandInfo(); return new_land; - } + /// /// Removes a land object from the list. Will not remove if local_id is still owning an area in landIDList /// @@ -194,6 +198,7 @@ namespace OpenSim.Region.Environment.LandManagement } removeLandObject(slave.landData.localID); } + /// /// Get the land object at the specified point /// @@ -202,16 +207,16 @@ namespace OpenSim.Region.Environment.LandManagement /// Land object at the point supplied public Land getLandObject(float x_float, float y_float) { - int x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); - int y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); - + int x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float)/Convert.ToDouble(4.0))); + int y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float)/Convert.ToDouble(4.0))); + if (x > 63 || y > 63 || x < 0 || y < 0) { throw new Exception("Error: Parcel not found at point " + x + ", " + y); } else { - // Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")"); + // Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")"); return landList[landIDList[x, y]]; } } @@ -224,12 +229,14 @@ namespace OpenSim.Region.Environment.LandManagement } else { - return landList[landIDList[x / 4, y / 4]]; + return landList[landIDList[x/4, y/4]]; } } + #endregion #region Parcel Modification + /// /// Subdivides a piece of land /// @@ -241,7 +248,6 @@ namespace OpenSim.Region.Environment.LandManagement /// Returns true if successful private bool subdivide(int start_x, int start_y, int end_x, int end_y, LLUUID 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 Land startLandObject = getLandObject(start_x, start_y); @@ -284,21 +290,21 @@ namespace OpenSim.Region.Environment.LandManagement //Now, lets set the subdivision area of the original to false int startLandObjectIndex = startLandObject.landData.localID; - landList[startLandObjectIndex].setLandBitmap(Land.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false)); + landList[startLandObjectIndex].setLandBitmap( + Land.modifyLandBitmapSquare(startLandObject.getLandBitmap(), start_x, start_y, end_x, end_y, false)); landList[startLandObjectIndex].forceUpdateLandInfo(); - this.setPrimsTainted(); + setPrimsTainted(); //Now add the new land object Land result = addLandObject(newLand); result.sendLandUpdateToAvatarsOverMe(); - - return true; } + /// /// Join 2 land objects together /// @@ -320,7 +326,7 @@ namespace OpenSim.Region.Environment.LandManagement { for (stepXSelected = start_x; stepXSelected <= end_x; stepXSelected += 4) { - Land p = getLandObject(stepXSelected,stepYSelected); + Land p = getLandObject(stepXSelected, stepYSelected); if (!selectedLandObjects.Contains(p)) { selectedLandObjects.Add(p); @@ -330,7 +336,7 @@ namespace OpenSim.Region.Environment.LandManagement Land masterLandObject = selectedLandObjects[0]; selectedLandObjects.RemoveAt(0); - + if (selectedLandObjects.Count < 1) { return false; //Only one piece of land selected @@ -348,23 +354,23 @@ namespace OpenSim.Region.Environment.LandManagement } foreach (Land slaveLandObject in selectedLandObjects) { - landList[masterLandObject.landData.localID].setLandBitmap(Land.mergeLandBitmaps(masterLandObject.getLandBitmap(), slaveLandObject.getLandBitmap())); + landList[masterLandObject.landData.localID].setLandBitmap( + Land.mergeLandBitmaps(masterLandObject.getLandBitmap(), slaveLandObject.getLandBitmap())); performFinalLandJoin(masterLandObject, slaveLandObject); } - this.setPrimsTainted(); + setPrimsTainted(); masterLandObject.sendLandUpdateToAvatarsOverMe(); return true; - - - } + #endregion #region Parcel Updating + /// /// Where we send the ParcelOverlay packet to the client /// @@ -382,15 +388,17 @@ namespace OpenSim.Region.Environment.LandManagement { for (x = 0; x < 64; x++) { - byte tempByte = (byte)0; //This represents the byte for the current 4x4 - Land currentParcelBlock = getLandObject(x * 4, y * 4); + byte tempByte = (byte) 0; //This represents the byte for the current 4x4 + Land currentParcelBlock = getLandObject(x*4, y*4); if (currentParcelBlock.landData.ownerID == remote_client.AgentId) { //Owner Flag tempByte = Convert.ToByte(tempByte | LAND_TYPE_OWNED_BY_REQUESTER); } - else if (currentParcelBlock.landData.salePrice > 0 && (currentParcelBlock.landData.authBuyerID == LLUUID.Zero || currentParcelBlock.landData.authBuyerID == remote_client.AgentId)) + else if (currentParcelBlock.landData.salePrice > 0 && + (currentParcelBlock.landData.authBuyerID == LLUUID.Zero || + currentParcelBlock.landData.authBuyerID == remote_client.AgentId)) { //Sale Flag tempByte = Convert.ToByte(tempByte | LAND_TYPE_IS_FOR_SALE); @@ -412,7 +420,7 @@ namespace OpenSim.Region.Environment.LandManagement { tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); } - else if (getLandObject((x - 1) * 4, y * 4) != currentParcelBlock) + else if (getLandObject((x - 1)*4, y*4) != currentParcelBlock) { tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_WEST); } @@ -421,7 +429,7 @@ namespace OpenSim.Region.Environment.LandManagement { tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); } - else if (getLandObject(x * 4, (y - 1) * 4) != currentParcelBlock) + else if (getLandObject(x*4, (y - 1)*4) != currentParcelBlock) { tempByte = Convert.ToByte(tempByte | LAND_FLAG_PROPERTY_BORDER_SOUTH); } @@ -434,17 +442,16 @@ namespace OpenSim.Region.Environment.LandManagement packet = new ParcelOverlayPacket(); packet.ParcelData.Data = byteArray; packet.ParcelData.SequenceID = sequenceID; - remote_client.OutPacket((Packet)packet); + remote_client.OutPacket((Packet) packet); 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) + 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(); @@ -486,14 +493,15 @@ namespace OpenSim.Region.Environment.LandManagement landList[packet.ParcelData.LocalID].updateLandProperties(packet, 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, IClientAPI remote_client) @@ -505,6 +513,7 @@ namespace OpenSim.Region.Environment.LandManagement { landList[local_id].sendLandObjectOwners(remote_client); } + #endregion /// @@ -523,7 +532,6 @@ namespace OpenSim.Region.Environment.LandManagement fullSimParcel.landData.ownerID = m_regInfo.MasterAvatarAssignedUUID; addLandObject(fullSimParcel); - } @@ -532,7 +540,7 @@ namespace OpenSim.Region.Environment.LandManagement ScenePresence clientAvatar = m_scene.RequestAvatar(remote_client.AgentId); if (clientAvatar != null) { - Land over = getLandObject(clientAvatar.AbsolutePosition.X,clientAvatar.AbsolutePosition.Y); + Land over = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); if (over != null) { over.sendLandProperties(0, false, 0, remote_client); @@ -547,9 +555,10 @@ namespace OpenSim.Region.Environment.LandManagement p.resetLandPrimCounts(); } } + public void setPrimsTainted() { - this.landPrimCountTainted = true; + landPrimCountTainted = true; } public void addPrimToLandPrimCounts(SceneObjectGroup obj) @@ -573,14 +582,14 @@ namespace OpenSim.Region.Environment.LandManagement public void finalizeLandPrimCountUpdate() { //Get Simwide prim count for owner - Dictionary> landOwnersAndParcels = new Dictionary>(); + Dictionary> landOwnersAndParcels = new Dictionary>(); foreach (Land p in landList.Values) { - if(!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) + if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID)) { List tempList = new List(); tempList.Add(p); - landOwnersAndParcels.Add(p.landData.ownerID,tempList); + landOwnersAndParcels.Add(p.landData.ownerID, tempList); } else { @@ -595,7 +604,8 @@ namespace OpenSim.Region.Environment.LandManagement foreach (Land p in landOwnersAndParcels[owner]) { simArea += p.landData.area; - simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + p.landData.selectedPrims; + simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims + + p.landData.selectedPrims; } foreach (Land p in landOwnersAndParcels[owner]) @@ -604,14 +614,10 @@ namespace OpenSim.Region.Environment.LandManagement p.landData.simwidePrims = simPrims; } } - } + #endregion } - #endregion - - - - -} + #endregion +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 5e27f50..34cc383 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -1,25 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules; - +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment { public class ModuleLoader - { - + { public Dictionary LoadedAssemblys = new Dictionary(); public List LoadedModules = new List(); public Dictionary LoadedSharedModules = new Dictionary(); - - public ModuleLoader() - { + public ModuleLoader() + { } /// @@ -28,32 +25,31 @@ namespace OpenSim.Region.Environment /// public void CreateDefaultModules(Scene scene, string exceptModules) { - IRegionModule module = new XferModule(); + IRegionModule module = new XferModule(); InitialiseModule(module, scene); module = new ChatModule(); InitialiseModule(module, scene); - + module = new AvatarProfilesModule(); InitialiseModule(module, scene); - this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); - - string lslPath = System.IO.Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); - this.LoadRegionModule(lslPath, "LSLScriptingModule", scene); + LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); + string lslPath = Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); + LoadRegionModule(lslPath, "LSLScriptingModule", scene); } public void LoadDefaultSharedModules(string exceptModules) { DynamicTextureModule dynamicModule = new DynamicTextureModule(); - this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); + LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); } public void InitialiseSharedModules(Scene scene) { - foreach (IRegionModule module in this.LoadedSharedModules.Values) + foreach (IRegionModule module in LoadedSharedModules.Values) { module.Initialise(scene); scene.AddModule(module.GetName(), module); //should be doing this? @@ -75,19 +71,19 @@ namespace OpenSim.Region.Environment /// public void LoadSharedModule(string dllName, string moduleName) { - IRegionModule module = this.LoadModule(dllName, moduleName); + IRegionModule module = LoadModule(dllName, moduleName); if (module != null) { - this.LoadedSharedModules.Add(module.GetName(), module); + LoadedSharedModules.Add(module.GetName(), module); } } public void LoadRegionModule(string dllName, string moduleName, Scene scene) { - IRegionModule module = this.LoadModule(dllName, moduleName); + IRegionModule module = LoadModule(dllName, moduleName); if (module != null) { - this.InitialiseModule(module, scene); + InitialiseModule(module, scene); } } @@ -107,7 +103,7 @@ namespace OpenSim.Region.Environment else { pluginAssembly = Assembly.LoadFrom(dllName); - this.LoadedAssemblys.Add(dllName, pluginAssembly); + LoadedAssemblys.Add(dllName, pluginAssembly); } IRegionModule module = null; @@ -121,7 +117,8 @@ namespace OpenSim.Region.Environment if (typeInterface != null) { - module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + module = + (IRegionModule) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); break; } typeInterface = null; @@ -130,23 +127,22 @@ namespace OpenSim.Region.Environment } pluginAssembly = null; - if ((module != null ) || (module.GetName() == moduleName)) + if ((module != null) || (module.GetName() == moduleName)) { return module; } - return null; - + return null; } public void PostInitialise() { - foreach (IRegionModule module in this.LoadedSharedModules.Values) + foreach (IRegionModule module in LoadedSharedModules.Values) { module.PostInitialise(); } - foreach (IRegionModule module in this.LoadedModules) + foreach (IRegionModule module in LoadedModules) { module.PostInitialise(); } @@ -154,7 +150,7 @@ namespace OpenSim.Region.Environment public void ClearCache() { - this.LoadedAssemblys.Clear(); + LoadedAssemblys.Clear(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs index 7a53f6f..511b5f6 100644 --- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { public class AssetDownloadModule : IRegionModule @@ -14,8 +9,7 @@ namespace OpenSim.Region.Environment.Modules private Scene m_scene; public AssetDownloadModule() - { - + { } public void Initialise(Scene scene) @@ -25,8 +19,7 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() @@ -47,4 +40,4 @@ namespace OpenSim.Region.Environment.Modules { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs index c349888..ea5f787 100644 --- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs @@ -1,21 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { - public class AvatarProfilesModule :IRegionModule - { - + public class AvatarProfilesModule : IRegionModule + { private Scene m_scene; public AvatarProfilesModule() - { - + { } public void Initialise(Scene scene) @@ -25,13 +20,11 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() - { - + { } public string GetName() @@ -65,7 +58,8 @@ namespace OpenSim.Region.Environment.Modules string bornOn = "Before now"; string flAbout = "First life? What is one of those? OpenSim is my life!"; LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner); + remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", + partner); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 8d3a553..468a5b7 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -1,17 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.IO; -using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Console; - +using System; +using System.IO; +using System.Net.Sockets; +using System.Threading; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { public class ChatModule : IRegionModule, ISimChat @@ -20,18 +16,18 @@ namespace OpenSim.Region.Environment.Modules private string m_server = "irc2.choopa.net"; - // private int m_port = 6668; + // private int m_port = 6668; //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; private string m_nick = "OSimBot"; private string m_channel = "#opensim"; - // private NetworkStream m_stream; - private TcpClient m_irc; + // private NetworkStream m_stream; + private TcpClient m_irc; private StreamWriter m_ircWriter; - private StreamReader m_ircReader; + private StreamReader m_ircReader; - // private Thread pingSender; - // private Thread listener; + // private Thread pingSender; + // private Thread listener; private bool connected = false; @@ -127,16 +123,18 @@ namespace OpenSim.Region.Environment.Modules { string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - presence.ControllingClient.SendChatMessage(Helpers.StringToField(mess), 255, pos, "IRC:", - LLUUID.Zero); - }); + { + presence.ControllingClient.SendChatMessage( + Helpers.StringToField(mess), 255, pos, "IRC:", + LLUUID.Zero); + }); } } } } - public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID) + public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, + LLUUID fromAgentID) { ScenePresence avatar = null; avatar = m_scene.RequestAvatar(fromAgentID); @@ -213,4 +211,4 @@ namespace OpenSim.Region.Environment.Modules } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs index bbd9810..3f737e1 100644 --- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs @@ -1,23 +1,20 @@ -using System.Text; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.IO; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Console; -using OpenSim.Framework.Types; - +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { - public class DynamicTextureModule :IRegionModule, IDynamicTextureManager + public class DynamicTextureModule : IRegionModule, IDynamicTextureManager { - private Dictionary RegisteredScenes = new Dictionary(); - private Dictionary RenderPlugins= new Dictionary(); + private Dictionary RegisteredScenes = new Dictionary(); + + private Dictionary RenderPlugins = + new Dictionary(); + private Dictionary Updaters = new Dictionary(); public void Initialise(Scene scene) @@ -30,8 +27,7 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() @@ -69,10 +65,11 @@ namespace OpenSim.Region.Environment.Modules } } - public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer) + public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, + string extraParams, int updateTimer) { - System.Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); - if (this.RenderPlugins.ContainsKey(contentType)) + Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); + if (RenderPlugins.ContainsKey(contentType)) { DynamicTextureUpdater updater = new DynamicTextureUpdater(); updater.SimUUID = simID; @@ -83,7 +80,7 @@ namespace OpenSim.Region.Environment.Modules updater.UpdaterID = LLUUID.Random(); updater.Params = extraParams; - if (!this.Updaters.ContainsKey(updater.UpdaterID)) + if (!Updaters.ContainsKey(updater.UpdaterID)) { Updaters.Add(updater.UpdaterID, updater); } @@ -94,9 +91,10 @@ namespace OpenSim.Region.Environment.Modules return LLUUID.Zero; } - public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer) + public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, + string extraParams, int updateTimer) { - if (this.RenderPlugins.ContainsKey(contentType)) + if (RenderPlugins.ContainsKey(contentType)) { DynamicTextureUpdater updater = new DynamicTextureUpdater(); updater.SimUUID = simID; @@ -107,7 +105,7 @@ namespace OpenSim.Region.Environment.Modules updater.UpdaterID = LLUUID.Random(); updater.Params = extraParams; - if (!this.Updaters.ContainsKey(updater.UpdaterID)) + if (!Updaters.ContainsKey(updater.UpdaterID)) { Updaters.Add(updater.UpdaterID, updater); } @@ -140,7 +138,7 @@ namespace OpenSim.Region.Environment.Modules public void DataReceived(byte[] data, Scene scene) { //TODO delete the last asset(data), if it was a dynamic texture - + AssetBase asset = new AssetBase(); asset.FullID = LLUUID.Random(); asset.Data = data; @@ -148,7 +146,7 @@ namespace OpenSim.Region.Environment.Modules asset.Type = 0; scene.commsManager.AssetCache.AddAsset(asset); - this.LastAssetID = asset.FullID; + LastAssetID = asset.FullID; SceneObjectPart part = scene.GetSceneObjectPart(PrimID); part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); @@ -156,4 +154,4 @@ namespace OpenSim.Region.Environment.Modules } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/EmailModule.cs b/OpenSim/Region/Environment/Modules/EmailModule.cs index fff9539..7a61373 100644 --- a/OpenSim/Region/Environment/Modules/EmailModule.cs +++ b/OpenSim/Region/Environment/Modules/EmailModule.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.Environment.Modules { - class EmailModule + internal class EmailModule { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs index 411b838..c2a7291 100644 --- a/OpenSim/Region/Environment/Modules/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { public class FriendsModule : IRegionModule @@ -19,8 +13,7 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() @@ -37,4 +30,4 @@ namespace OpenSim.Region.Environment.Modules return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs index 9ed0e96..dcef2c5 100644 --- a/OpenSim/Region/Environment/Modules/GroupsModule.cs +++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { public class GroupsModule : IRegionModule @@ -18,8 +13,7 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() @@ -36,5 +30,4 @@ namespace OpenSim.Region.Environment.Modules return false; } } -} - +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs index 25c118a..14f2b65 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs @@ -1,15 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { - public class InstantMessageModule :IRegionModule + public class InstantMessageModule : IRegionModule { private Scene m_scene; @@ -19,8 +13,7 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() @@ -37,4 +30,4 @@ namespace OpenSim.Region.Environment.Modules return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/InventoryModule.cs b/OpenSim/Region/Environment/Modules/InventoryModule.cs index bfcb7d7..40bd37e 100644 --- a/OpenSim/Region/Environment/Modules/InventoryModule.cs +++ b/OpenSim/Region/Environment/Modules/InventoryModule.cs @@ -1,15 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { - public class InventoryModule :IRegionModule + public class InventoryModule : IRegionModule { private Scene m_scene; @@ -19,8 +13,7 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() @@ -37,4 +30,4 @@ namespace OpenSim.Region.Environment.Modules return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs index e47cc9e..1e84a59 100644 --- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.Environment.Modules { - class ScriptsHttpRequests + internal class ScriptsHttpRequests { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/TeleportModule.cs b/OpenSim/Region/Environment/Modules/TeleportModule.cs index 1c01b27..f331a9c 100644 --- a/OpenSim/Region/Environment/Modules/TeleportModule.cs +++ b/OpenSim/Region/Environment/Modules/TeleportModule.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.Environment.Modules { - class TeleportModule + internal class TeleportModule { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 59c0839..f107d77 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -1,20 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { - public class TextureDownloadModule :IRegionModule + public class TextureDownloadModule : IRegionModule { private Scene m_scene; public TextureDownloadModule() - { - + { } public void Initialise(Scene scene) @@ -24,8 +20,7 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() @@ -47,8 +42,7 @@ namespace OpenSim.Region.Environment.Modules } public void TextureAssetCallback(LLUUID texture, byte[] data) - { - + { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/XferModule.cs b/OpenSim/Region/Environment/Modules/XferModule.cs index 216d10a..7f8c5c1 100644 --- a/OpenSim/Region/Environment/Modules/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/XferModule.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - +using System; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Modules { public class XferModule : IRegionModule, IXfer @@ -18,8 +15,7 @@ namespace OpenSim.Region.Environment.Modules private Scene m_scene; public XferModule() - { - + { } public void Initialise(Scene scene) @@ -31,13 +27,11 @@ namespace OpenSim.Region.Environment.Modules } public void PostInitialise() - { - + { } public void CloseDown() - { - + { } public string GetName() @@ -67,7 +61,7 @@ namespace OpenSim.Region.Environment.Modules lock (NewFiles) { if (NewFiles.ContainsKey(fileName)) - { + { if (!Transfers.ContainsKey(xferID)) { byte[] fileData = NewFiles[fileName]; @@ -82,7 +76,7 @@ namespace OpenSim.Region.Environment.Modules public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) { - if (this.Transfers.ContainsKey(xferID)) + if (Transfers.ContainsKey(xferID)) { Transfers[xferID].AckPacket(packet); } @@ -125,8 +119,7 @@ namespace OpenSim.Region.Environment.Modules } public XferDownLoad() - { - + { } public void StartSend() @@ -142,10 +135,10 @@ namespace OpenSim.Region.Environment.Modules } else { - byte[] transferData = new byte[1000 +4]; + byte[] transferData = new byte[1000 + 4]; Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); Array.Copy(Data, 0, transferData, 4, 1000); - Client.SendXferPacket(XferID, 0 , transferData); + Client.SendXferPacket(XferID, 0, transferData); Packet++; DataPointer = 1000; } @@ -167,7 +160,7 @@ namespace OpenSim.Region.Environment.Modules { byte[] transferData = new byte[Data.Length - DataPointer]; Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); - uint endPacket = Packet |= (uint)0x80000000; + uint endPacket = Packet |= (uint) 0x80000000; Client.SendXferPacket(XferID, endPacket, transferData); Packet++; DataPointer += (Data.Length - DataPointer); @@ -177,4 +170,4 @@ namespace OpenSim.Region.Environment.Modules } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index cb455f4..0a33380 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -1,14 +1,7 @@ -using System.Collections.Generic; -using OpenSim.Framework; -using OpenSim.Framework.Types; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.LandManagement; - -using libsecondlife; - +using libsecondlife; +using OpenSim.Region.Environment.LandManagement; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment { public class PermissionManager @@ -19,7 +12,8 @@ namespace OpenSim.Region.Environment // disable in any production environment // TODO: Change this to false when permissions are a desired default // TODO: Move to configuration option. - private bool m_bypassPermissions = true; + private bool m_bypassPermissions = true; + public bool BypassPermissions { get { return m_bypassPermissions; } @@ -104,26 +98,27 @@ namespace OpenSim.Region.Environment // Default: deny bool permission = false; - if( !m_scene.Entities.ContainsKey( objId )) + 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 task = (SceneObjectGroup)m_scene.Entities[objId]; - LLUUID taskOwner = null; + + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[objId]; + LLUUID taskOwner = null; // Object owners should be able to edit their own content if (user == taskOwner) permission = true; // Users should be able to edit what is over their land. - if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == user) + if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == + user) permission = true; // Estate users should be able to edit anything in the sim @@ -270,7 +265,7 @@ namespace OpenSim.Region.Environment // TODO: Need to do some extra checks here. Requires group code. } - if(IsEstateManager(user)) + if (IsEstateManager(user)) permission = true; if (IsAdministrator(user)) @@ -299,7 +294,6 @@ namespace OpenSim.Region.Environment return GenericParcelPermission(user, parcel); } - #endregion - + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs index 86a3626..dfae0fd 100644 --- a/OpenSim/Region/Environment/RegionManager.cs +++ b/OpenSim/Region/Environment/RegionManager.cs @@ -1,34 +1,3 @@ -using System.Collections.Generic; -using OpenSim.Framework; -using OpenSim.Framework.Types; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.LandManagement; - namespace OpenSim.Region.Environment { - public delegate TResult ModuleAPIMethod1(TParam0 param0); - public delegate TResult ModuleAPIMethod2(TParam0 param0, TParam1 param1); - - public class RegionManager - { - protected AgentCircuitManager authenticateHandler; - protected RegionCommsListener regionCommsHost; - protected CommunicationsManager commsManager; - protected List capsHandlers = new List(); - protected BaseHttpServer httpListener; - - protected Scene m_Scene; - - public LandManager LandManager; - public EstateManager estateManager; - - public RegionManager() - { - - } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index 2caab9e..bc27ec8 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -1,30 +1,25 @@ using System.Collections.Generic; using Axiom.Math; using libsecondlife; -using OpenSim.Region.Environment.Scenes.Scripting; namespace OpenSim.Region.Environment.Scenes { - public abstract class EntityBase + public abstract class EntityBase { protected List m_children; protected Scene m_scene; public LLUUID m_uuid; + public virtual LLUUID UUID { - get - { - return m_uuid; - } - set - { - m_uuid = value; - } + get { return m_uuid; } + set { m_uuid = value; } } protected string m_name; + /// /// /// @@ -35,6 +30,7 @@ namespace OpenSim.Region.Environment.Scenes } protected LLVector3 m_pos; + /// /// /// @@ -45,6 +41,7 @@ namespace OpenSim.Region.Environment.Scenes } public LLVector3 m_velocity; + /// /// /// @@ -55,6 +52,7 @@ namespace OpenSim.Region.Environment.Scenes } protected Quaternion m_rotation = new Quaternion(0, 0, 1, 0); + public virtual Quaternion Rotation { get { return m_rotation; } @@ -62,6 +60,7 @@ namespace OpenSim.Region.Environment.Scenes } protected uint m_localId; + public virtual uint LocalId { get { return m_localId; } @@ -125,5 +124,5 @@ namespace OpenSim.Region.Environment.Scenes } public abstract void SetText(string text, Vector3 color, double alpha); - } + } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs index 8551b70..851ad4e 100644 --- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs +++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs @@ -11,4 +11,4 @@ namespace OpenSim.Region.Environment.Scenes void SendOurAppearance(IClientAPI OurClient); void SendAppearanceToOtherAgent(ScenePresence avatarInfo); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index a259dd0..048d2b4 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1,15 +1,13 @@ -using System; -using System.IO; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Communications.Caches; -using OpenSim.Framework.Data; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Physics.Manager; - +using Axiom.Math; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Data; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Physics.Manager; + namespace OpenSim.Region.Environment.Scenes { public partial class Scene @@ -19,9 +17,9 @@ namespace OpenSim.Region.Environment.Scenes public void AddInventoryItem(LLUUID userID, InventoryItemBase item) { - if (this.Avatars.ContainsKey(userID)) + if (Avatars.ContainsKey(userID)) { - this.AddInventoryItem(this.Avatars[userID].ControllingClient, item); + AddInventoryItem(Avatars[userID].ControllingClient, item); } } @@ -37,9 +35,9 @@ namespace OpenSim.Region.Environment.Scenes public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data) { - if (this.Avatars.ContainsKey(userID)) + if (Avatars.ContainsKey(userID)) { - return this.CapsUpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data); + return CapsUpdateInventoryItemAsset(Avatars[userID].ControllingClient, itemID, data); } return LLUUID.Zero; } @@ -57,8 +55,8 @@ namespace OpenSim.Region.Environment.Scenes AssetBase asset; asset = new AssetBase(); asset.FullID = LLUUID.Random(); - asset.Type = (sbyte)item.assetType; - asset.InvType = (sbyte)item.invType; + asset.Type = (sbyte) item.assetType; + asset.InvType = (sbyte) item.invType; asset.Name = item.inventoryName; asset.Data = data; commsManager.AssetCache.AddAsset(asset); @@ -83,7 +81,8 @@ namespace OpenSim.Region.Environment.Scenes return LLUUID.Zero; } - public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID) + public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, + LLUUID itemID) { CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); if (userInfo != null) @@ -93,7 +92,8 @@ namespace OpenSim.Region.Environment.Scenes InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); if (item != null) { - AgentAssetTransactions transactions = commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); + AgentAssetTransactions transactions = + commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); if (transactions != null) { AssetBase asset = null; @@ -112,8 +112,8 @@ namespace OpenSim.Region.Environment.Scenes { asset.Name = item.inventoryName; asset.Description = item.inventoryDescription; - asset.InvType = (sbyte)item.invType; - asset.Type = (sbyte)item.assetType; + asset.InvType = (sbyte) item.invType; + asset.Type = (sbyte) item.assetType; item.assetID = asset.FullID; if (addToCache) @@ -143,7 +143,9 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, sbyte type, + byte wearableType, uint nextOwnerMask) { if (transActionID == LLUUID.Zero) { @@ -157,7 +159,7 @@ namespace OpenSim.Region.Environment.Scenes asset.Type = type; asset.FullID = LLUUID.Random(); asset.Data = new byte[1]; - this.commsManager.AssetCache.AddAsset(asset); + commsManager.AssetCache.AddAsset(asset); InventoryItemBase item = new InventoryItemBase(); item.avatarID = remoteClient.AgentId; @@ -178,7 +180,9 @@ namespace OpenSim.Region.Environment.Scenes } else { - commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, + callbackID, description, name, invType, + type, wearableType, nextOwnerMask); //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); } } @@ -195,15 +199,15 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); if (hasPrim != false) { - bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); + bool fileChange = ((SceneObjectGroup) ent).GetPartInventoryFileName(remoteClient, primLocalID); if (fileChange) { - if (this.XferManager != null) + if (XferManager != null) { - ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, XferManager); + ((SceneObjectGroup) ent).RequestInventoryFile(primLocalID, XferManager); } } break; @@ -219,14 +223,14 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - int type = ((SceneObjectGroup)ent).RemoveInventoryItem(remoteClient, localID, itemID); - ((SceneObjectGroup)ent).GetProperites(remoteClient); + int type = ((SceneObjectGroup) ent).RemoveInventoryItem(remoteClient, localID, itemID); + ((SceneObjectGroup) ent).GetProperites(remoteClient); if (type == 10) { - this.EventManager.TriggerRemoveScript(localID, itemID); + EventManager.TriggerRemoveScript(localID, itemID); } } } @@ -255,7 +259,7 @@ namespace OpenSim.Region.Environment.Scenes { string script = Util.FieldToString(rezAsset.Data); //Console.WriteLine("rez script "+script); - this.EventManager.TriggerRezScript(localID, copyID, script); + EventManager.TriggerRezScript(localID, copyID, script); rezzed = true; } else @@ -266,7 +270,7 @@ namespace OpenSim.Region.Environment.Scenes { string script = Util.FieldToString(rezAsset.Data); // Console.WriteLine("rez script " + script); - this.EventManager.TriggerRezScript(localID, copyID, script); + EventManager.TriggerRezScript(localID, copyID, script); rezzed = true; } } @@ -278,12 +282,13 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) - { - - bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item, copyID); - ((SceneObjectGroup)ent).GetProperites(remoteClient); + { + bool added = + ((SceneObjectGroup) ent).AddInventoryItem(remoteClient, localID, item, + copyID); + ((SceneObjectGroup) ent).GetProperites(remoteClient); } } } @@ -300,7 +305,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void DeRezObject(Packet packet, IClientAPI remoteClient) { - DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; + DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet; if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) { @@ -312,7 +317,7 @@ namespace OpenSim.Region.Environment.Scenes { EntityBase selectedEnt = null; //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); - foreach (EntityBase ent in this.Entities.Values) + foreach (EntityBase ent in Entities.Values) { if (ent.LocalId == Data.ObjectLocalID) { @@ -322,15 +327,16 @@ namespace OpenSim.Region.Environment.Scenes } if (selectedEnt != null) { - if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup)selectedEnt).UUID)) + if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) { - string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString(); + string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { AssetBase asset = new AssetBase(); - asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId); - asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId); + asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId); + asset.Description = + ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId); asset.InvType = 6; asset.Type = 6; asset.FullID = LLUUID.Random(); @@ -355,21 +361,23 @@ namespace OpenSim.Region.Environment.Scenes remoteClient.SendInventoryItemUpdate(item); } - SceneObjectPart rootPart = ((SceneObjectGroup)selectedEnt).GetChildPart(((SceneObjectGroup)selectedEnt).UUID); + SceneObjectPart rootPart = + ((SceneObjectGroup) selectedEnt).GetChildPart(((SceneObjectGroup) selectedEnt).UUID); if (rootPart.PhysActor != null) { - this.phyScene.RemovePrim(rootPart.PhysActor); + phyScene.RemovePrim(rootPart.PhysActor); rootPart.PhysActor = null; } - storageManager.DataStore.RemoveObject(((SceneObjectGroup)selectedEnt).UUID, m_regInfo.SimUUID); - ((SceneObjectGroup)selectedEnt).DeleteGroup(); + storageManager.DataStore.RemoveObject(((SceneObjectGroup) selectedEnt).UUID, + m_regInfo.SimUUID); + ((SceneObjectGroup) selectedEnt).DeleteGroup(); lock (Entities) { - Entities.Remove(((SceneObjectGroup)selectedEnt).UUID); + Entities.Remove(((SceneObjectGroup) selectedEnt).UUID); } - ((SceneObjectGroup)selectedEnt).DeleteParts(); + ((SceneObjectGroup) selectedEnt).DeleteParts(); } } } @@ -389,7 +397,7 @@ namespace OpenSim.Region.Environment.Scenes AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); if (rezAsset != null) { - this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); + AddRezObject(Util.FieldToString(rezAsset.Data), pos); userInfo.DeleteItem(remoteClient.AgentId, item); remoteClient.SendRemoveInventoryItem(itemID); } @@ -399,7 +407,7 @@ namespace OpenSim.Region.Environment.Scenes rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); if (rezAsset != null) { - this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); + AddRezObject(Util.FieldToString(rezAsset.Data), pos); userInfo.DeleteItem(remoteClient.AgentId, item); remoteClient.SendRemoveInventoryItem(itemID); } @@ -411,17 +419,17 @@ namespace OpenSim.Region.Environment.Scenes private void AddRezObject(string xmlData, LLVector3 pos) { - SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData); - this.AddEntity(group); + SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); + AddEntity(group); group.AbsolutePosition = pos; SceneObjectPart rootPart = group.GetChildPart(group.UUID); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrim( - new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), + new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, + rootPart.AbsolutePosition.Z), new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); + new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, + rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); } - } - -} + } +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 881b4a1..5a7dda5 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -25,17 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.IO; using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; +using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Communications.Caches; -using OpenSim.Framework.Data; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.Scenes { @@ -50,7 +44,8 @@ namespace OpenSim.Region.Environment.Scenes /// The action to be performed /// Distance from the north border where the cursor is located /// Distance from the west border where the cursor is located - public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser) + public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, + IClientAPI remoteUser) { // Do a permissions check before allowing terraforming. // random users are now no longer allowed to terraform @@ -71,17 +66,19 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void InstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog) + public void InstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, + uint timestamp, string fromAgentName, string message, byte dialog) { - if (this.Avatars.ContainsKey(toAgentID)) + if (Avatars.ContainsKey(toAgentID)) { - if (this.Avatars.ContainsKey(fromAgentID)) + if (Avatars.ContainsKey(fromAgentID)) { // Local sim message - ScenePresence fromAvatar = this.Avatars[fromAgentID]; - ScenePresence toAvatar = this.Avatars[toAgentID]; + ScenePresence fromAvatar = Avatars[fromAgentID]; + ScenePresence toAvatar = Avatars[toAgentID]; string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname; - toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromName, dialog, timestamp); + toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID, + imSessionID, fromName, dialog, timestamp); } else { @@ -102,7 +99,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID) + public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, + LLUUID fromAgentID) { if (m_simChatModule != null) { @@ -123,9 +121,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == originalPrim) + if (((SceneObjectGroup) ent).LocalId == originalPrim) { - originPrim = (SceneObjectGroup)ent; + originPrim = (SceneObjectGroup) ent; break; } } @@ -135,7 +133,7 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectGroup copy = originPrim.Copy(); copy.AbsolutePosition = copy.AbsolutePosition + offset; - this.Entities.Add(copy.UUID, copy); + Entities.Add(copy.UUID, copy); copy.ScheduleGroupForFullUpdate(); /* List avatars = this.RequestAvatarList(); @@ -143,13 +141,11 @@ namespace OpenSim.Region.Environment.Scenes { // copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); }*/ - } else { - OpenSim.Framework.Console.MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); + MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); } - } /// @@ -164,9 +160,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == parentPrim) + if (((SceneObjectGroup) ent).LocalId == parentPrim) { - parenPrim = (SceneObjectGroup)ent; + parenPrim = (SceneObjectGroup) ent; break; } } @@ -181,9 +177,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == childPrims[i]) + if (((SceneObjectGroup) ent).LocalId == childPrims[i]) { - children.Add((SceneObjectGroup)ent); + children.Add((SceneObjectGroup) ent); } } } @@ -208,10 +204,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); if (hasPrim != false) { - ((SceneObjectGroup)ent).UpdateShape(shapeBlock, primLocalID); + ((SceneObjectGroup) ent).UpdateShape(shapeBlock, primLocalID); break; } } @@ -225,10 +221,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); if (hasPrim != false) { - ((SceneObjectGroup)ent).UpdateExtraParam(primLocalID, type, inUse, data); + ((SceneObjectGroup) ent).UpdateExtraParam(primLocalID, type, inUse, data); break; } } @@ -246,11 +242,11 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == primLocalID) + if (((SceneObjectGroup) ent).LocalId == primLocalID) { - ((SceneObjectGroup)ent).GetProperites(remoteClient); - ((SceneObjectGroup)ent).IsSelected = true; - this.LandManager.setPrimsTainted(); + ((SceneObjectGroup) ent).GetProperites(remoteClient); + ((SceneObjectGroup) ent).IsSelected = true; + LandManager.setPrimsTainted(); break; } } @@ -268,10 +264,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == primLocalID) + if (((SceneObjectGroup) ent).LocalId == primLocalID) { - ((SceneObjectGroup)ent).IsSelected = false; - this.LandManager.setPrimsTainted(); + ((SceneObjectGroup) ent).IsSelected = false; + LandManager.setPrimsTainted(); break; } } @@ -290,10 +286,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); if (hasPrim != false) { - ((SceneObjectGroup)ent).SetPartDescription(description, primLocalID); + ((SceneObjectGroup) ent).SetPartDescription(description, primLocalID); break; } } @@ -312,10 +308,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); if (hasPrim != false) { - ((SceneObjectGroup)ent).SetPartName(name, primLocalID); + ((SceneObjectGroup) ent).SetPartName(name, primLocalID); break; } } @@ -331,10 +327,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(objectID); if (hasPrim != false) { - ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient); + ((SceneObjectGroup) ent).GrabMovement(offset, pos, remoteClient); break; } } @@ -350,7 +346,6 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) { - } /// @@ -366,10 +361,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - ((SceneObjectGroup)ent).UpdateTextureEntry(localID, texture); + ((SceneObjectGroup) ent).UpdateTextureEntry(localID, texture); break; } } @@ -389,10 +384,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - ((SceneObjectGroup)ent).UpdateGroupPosition(pos); + ((SceneObjectGroup) ent).UpdateGroupPosition(pos); break; } } @@ -406,10 +401,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - ((SceneObjectGroup)ent).UpdateSinglePosition(pos, localID); + ((SceneObjectGroup) ent).UpdateSinglePosition(pos, localID); break; } } @@ -430,10 +425,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot); + ((SceneObjectGroup) ent).UpdateGroupRotation(pos, rot); break; } } @@ -453,10 +448,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - ((SceneObjectGroup)ent).UpdateGroupRotation(rot); + ((SceneObjectGroup) ent).UpdateGroupRotation(rot); break; } } @@ -476,10 +471,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - ((SceneObjectGroup)ent).UpdateSingleRotation(rot, localID); + ((SceneObjectGroup) ent).UpdateSingleRotation(rot, localID); break; } } @@ -499,10 +494,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - ((SceneObjectGroup)ent).Resize(scale, localID); + ((SceneObjectGroup) ent).Resize(scale, localID); break; } } @@ -511,7 +506,7 @@ namespace OpenSim.Region.Environment.Scenes public void StartAnimation(IClientAPI client, LLUUID animID, int seq) { - List avatars = this.RequestAvatarList(); + List avatars = RequestAvatarList(); for (int i = 0; i < avatars.Count; i++) { avatars[i].ControllingClient.SendAnimation(animID, seq, client.AgentId); @@ -520,7 +515,7 @@ namespace OpenSim.Region.Environment.Scenes public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) { - this.EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient); + EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d763fe3..df125aa 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -27,28 +27,28 @@ */ using System; using System.Collections.Generic; +using System.IO; using System.Threading; using System.Timers; -using System.IO; using System.Xml; +using Axiom.Math; using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Caches; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; -using OpenSim.Region.Physics.Manager; -using OpenSim.Framework.Communications.Caches; -using OpenSim.Region.Environment.LandManagement; -using OpenSim.Region.Environment; +using OpenSim.Region.Capabilities; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.LandManagement; +using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Types; +using OpenSim.Region.Physics.Manager; using OpenSim.Region.Terrain; -using OpenSim.Framework.Data; -using Caps = OpenSim.Region.Capabilities.Caps; -using Timer = System.Timers.Timer; +using Timer=System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { @@ -61,8 +61,11 @@ namespace OpenSim.Region.Environment.Scenes protected Timer m_heartbeatTimer = new Timer(); protected Dictionary Avatars; protected Dictionary Prims; - public PhysicsScene phyScene; /// publicized so it can be accessed from SceneObjectGroup. + public PhysicsScene phyScene; + + /// publicized so it can be accessed from SceneObjectGroup. protected float timeStep = 0.1f; + private Random Rand = new Random(); private uint _primCount = 702000; private Mutex _primAllocateMutex = new Mutex(false); @@ -102,8 +105,9 @@ namespace OpenSim.Region.Environment.Scenes public AgentCircuitManager AuthenticateHandler { - get { return this.authenticateHandler; } + get { return authenticateHandler; } } + /// /// /// @@ -141,7 +145,7 @@ namespace OpenSim.Region.Environment.Scenes public int TimePhase { - get { return this.m_timePhase; } + get { return m_timePhase; } } #endregion @@ -155,7 +159,8 @@ namespace OpenSim.Region.Environment.Scenes /// Region Handle for this region /// Region Name for this region public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, - AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader) + AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, + ModuleLoader moduleLoader) { updateLock = new Mutex(false); @@ -190,22 +195,21 @@ namespace OpenSim.Region.Environment.Scenes Prims = new Dictionary(); MainLog.Instance.Verbose("Creating LandMap"); - Terrain = new TerrainEngine((int)this.RegionInfo.RegionLocX, (int)this.RegionInfo.RegionLocY); + Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); ScenePresence.LoadAnims(); httpListener = httpServer; - } #endregion public void SetModuleInterfaces() { - m_simChatModule = this.RequestModuleInterface(); - m_httpRequestModule = this.RequestModuleInterface(); + m_simChatModule = RequestModuleInterface(); + m_httpRequestModule = RequestModuleInterface(); - XferManager = this.RequestModuleInterface(); + XferManager = RequestModuleInterface(); } #region Script Handling Methods @@ -249,7 +253,8 @@ namespace OpenSim.Region.Environment.Scenes { if (phyScene.IsThreaded) { - phyScene.GetResults(); /// no engines implement this, and what does it have to do with threading? possible DEAD CODE + phyScene.GetResults(); + /// no engines implement this, and what does it have to do with threading? possible DEAD CODE } List moveEntities = new List(Entities.Values); @@ -308,9 +313,10 @@ namespace OpenSim.Region.Environment.Scenes { for (int y = 0; y < 16; y++) { - if (Terrain.Tainted(x * 16, y * 16)) + if (Terrain.Tainted(x*16, y*16)) { - SendLayerData(x, y, presence.ControllingClient, terData); + SendLayerData(x, y, presence.ControllingClient, + terData); } } } @@ -340,7 +346,7 @@ namespace OpenSim.Region.Environment.Scenes m_timeUpdateCount++; if (m_timeUpdateCount > 600) { - List Avatars = this.RequestAvatarList(); + List Avatars = RequestAvatarList(); foreach (ScenePresence avatar in Avatars) { if (!avatar.childAgent) @@ -398,10 +404,7 @@ namespace OpenSim.Region.Environment.Scenes storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); - ForEachScenePresence(delegate(ScenePresence presence) - { - SendLayerData(presence.ControllingClient); - }); + ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence.ControllingClient); }); foreach (LLUUID UUID in Entities.Keys) { @@ -429,10 +432,7 @@ namespace OpenSim.Region.Environment.Scenes } storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); - ForEachScenePresence(delegate(ScenePresence presence) - { - SendLayerData(presence.ControllingClient); - }); + ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence.ControllingClient); }); foreach (LLUUID UUID in Entities.Keys) { @@ -521,23 +521,23 @@ namespace OpenSim.Region.Environment.Scenes public void LoadPrimsFromStorage() { MainLog.Instance.Verbose("Loading objects from datastore"); - List PrimsFromDB = storageManager.DataStore.LoadObjects(this.m_regInfo.SimUUID); + List PrimsFromDB = storageManager.DataStore.LoadObjects(m_regInfo.SimUUID); foreach (SceneObjectGroup prim in PrimsFromDB) { AddEntityFromStorage(prim); SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrim( - new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), + new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, + rootPart.AbsolutePosition.Z), new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); + new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, + rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); } MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); } - /// /// Returns a new unallocated primitive ID /// @@ -561,20 +561,23 @@ namespace OpenSim.Region.Environment.Scenes /// public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape) { - if (this.PermissionsMngr.CanRezObject(ownerID, pos)) + if (PermissionsMngr.CanRezObject(ownerID, pos)) { - SceneObjectGroup sceneOb = new SceneObjectGroup(this, this.m_regionHandle, ownerID, PrimIDAllocate(), pos, shape); + SceneObjectGroup sceneOb = + new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, shape); AddEntity(sceneOb); SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); // if grass or tree, make phantom - if ((rootPart.Shape.PCode==95) || (rootPart.Shape.PCode==255)) + if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255)) { - rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; + rootPart.ObjectFlags += (uint) LLObject.ObjectFlags.Phantom; } // if not phantom, add to physics - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) - rootPart.PhysActor = phyScene.AddPrim(new PhysicsVector(pos.X, pos.Y, pos.Z), new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), - new Axiom.Math.Quaternion()); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) + rootPart.PhysActor = + phyScene.AddPrim(new PhysicsVector(pos.X, pos.Y, pos.Z), + new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), + new Quaternion()); } } @@ -584,9 +587,9 @@ namespace OpenSim.Region.Environment.Scenes { if (obj is SceneObjectGroup) { - if (((SceneObjectGroup)obj).LocalId == localID) + if (((SceneObjectGroup) obj).LocalId == localID) { - RemoveEntity((SceneObjectGroup)obj); + RemoveEntity((SceneObjectGroup) obj); return; } } @@ -595,21 +598,21 @@ namespace OpenSim.Region.Environment.Scenes public void AddEntityFromStorage(SceneObjectGroup sceneObject) { - sceneObject.RegionHandle = this.m_regionHandle; + sceneObject.RegionHandle = m_regionHandle; sceneObject.SetScene(this); foreach (SceneObjectPart part in sceneObject.Children.Values) { - part.LocalID = this.PrimIDAllocate(); + part.LocalID = PrimIDAllocate(); } sceneObject.UpdateParentIDs(); - this.AddEntity(sceneObject); + AddEntity(sceneObject); } public void AddEntity(SceneObjectGroup sceneObject) { if (!Entities.ContainsKey(sceneObject.UUID)) { - // QuadTree.AddObject(sceneObject); + // QuadTree.AddObject(sceneObject); Entities.Add(sceneObject.UUID, sceneObject); } } @@ -648,18 +651,19 @@ namespace OpenSim.Region.Environment.Scenes foreach (XmlNode aPrimNode in rootNode.ChildNodes) { SceneObjectGroup obj = new SceneObjectGroup(this, - this.m_regionHandle, aPrimNode.OuterXml); + m_regionHandle, aPrimNode.OuterXml); //if we want this to be a import method then we need new uuids for the object to avoid any clashes //obj.RegenerateFullIDs(); AddEntity(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrim( - new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), - new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); + new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, + rootPart.AbsolutePosition.Z), + new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), + new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, + rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); primCount++; } } @@ -679,7 +683,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); primCount++; } } @@ -688,7 +692,6 @@ namespace OpenSim.Region.Environment.Scenes file.Close(); } - #endregion #region Add/Remove Avatar Methods @@ -703,7 +706,7 @@ namespace OpenSim.Region.Environment.Scenes { SubscribeToClientEvents(client); m_estateManager.sendRegionHandshake(client); - CreateAndAddScenePresence(client, child ); + CreateAndAddScenePresence(client, child); m_LandManager.sendParcelOverlay(client); commsManager.UserProfiles.AddNewUser(client.AgentId); commsManager.TransactionsManager.AddUser(client.AgentId); @@ -744,9 +747,11 @@ namespace OpenSim.Region.Environment.Scenes client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest); client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest); client.OnParcelJoinRequest += new ParcelJoinRequest(m_LandManager.handleParcelJoinRequest); - client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_LandManager.handleParcelPropertiesUpdateRequest); + client.OnParcelPropertiesUpdateRequest += + new ParcelPropertiesUpdateRequest(m_LandManager.handleParcelPropertiesUpdateRequest); client.OnParcelSelectObjects += new ParcelSelectObjects(m_LandManager.handleParcelSelectObjectsRequest); - client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); + client.OnParcelObjectOwnerRequest += + new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); @@ -768,7 +773,7 @@ namespace OpenSim.Region.Environment.Scenes EventManager.TriggerOnNewClient(client); } - protected ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child ) + protected ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child) { ScenePresence newAvatar = null; @@ -777,16 +782,18 @@ namespace OpenSim.Region.Environment.Scenes if (child) { - MainLog.Instance.Verbose(this.RegionInfo.RegionName + ": Creating new child agent."); + MainLog.Instance.Verbose(RegionInfo.RegionName + ": Creating new child agent."); } else { newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement; - MainLog.Instance.Verbose(this.RegionInfo.RegionName + ": Creating new root agent."); - MainLog.Instance.Verbose(this.RegionInfo.RegionName + ": Adding Physical agent."); + MainLog.Instance.Verbose(RegionInfo.RegionName + ": Creating new root agent."); + MainLog.Instance.Verbose(RegionInfo.RegionName + ": Adding Physical agent."); - PhysicsVector pVec = new PhysicsVector(newAvatar.AbsolutePosition.X, newAvatar.AbsolutePosition.Y, newAvatar.AbsolutePosition.Z); + PhysicsVector pVec = + new PhysicsVector(newAvatar.AbsolutePosition.X, newAvatar.AbsolutePosition.Y, + newAvatar.AbsolutePosition.Z); lock (m_syncRoot) { newAvatar.PhysActor = phyScene.AddAvatar(pVec); @@ -832,14 +839,14 @@ namespace OpenSim.Region.Environment.Scenes ForEachScenePresence( delegate(ScenePresence presence) - { - presence.CoarseLocationChange(avatar); - presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); - if (presence.PhysActor != null) { - phyScene.RemoveAvatar(presence.PhysActor); - } - }); + presence.CoarseLocationChange(avatar); + presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); + if (presence.PhysActor != null) + { + phyScene.RemoveAvatar(presence.PhysActor); + } + }); lock (Avatars) { @@ -943,7 +950,7 @@ namespace OpenSim.Region.Environment.Scenes if (Entities.ContainsKey(entID)) { Entities.Remove(entID); - storageManager.DataStore.RemoveObject(entID, this.m_regInfo.SimUUID); + storageManager.DataStore.RemoveObject(entID, m_regInfo.SimUUID); return true; } return false; @@ -951,10 +958,10 @@ namespace OpenSim.Region.Environment.Scenes public void SendKillObject(uint localID) { - List avatars = this.RequestAvatarList(); + List avatars = RequestAvatarList(); for (int i = 0; i < avatars.Count; i++) { - avatars[i].ControllingClient.SendKillObject(this.m_regionHandle, localID); + avatars[i].ControllingClient.SendKillObject(m_regionHandle, localID); } } @@ -964,8 +971,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - // ((SceneObjectGroup)ent).SendFullUpdateToClient(client); - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + // ((SceneObjectGroup)ent).SendFullUpdateToClient(client); + ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); } } } @@ -999,15 +1006,19 @@ namespace OpenSim.Region.Environment.Scenes if (agent.CapsPath != "") { //Console.WriteLine("new user, so creating caps handler for it"); - Caps cap = new Caps(commsManager.AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, agent.CapsPath, agent.AgentID); - Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + "/CAPS/" + agent.CapsPath + "0000/"); + Caps cap = + new Caps(commsManager.AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, + agent.CapsPath, agent.AgentID); + Util.SetCapsURL(agent.AgentID, + "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + + "/CAPS/" + agent.CapsPath + "0000/"); cap.RegisterHandlers(); - cap.AddNewInventoryItem = this.AddInventoryItem; - cap.ItemUpdatedCall = this.CapsUpdateInventoryItemAsset; + cap.AddNewInventoryItem = AddInventoryItem; + cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; if (capsHandlers.ContainsKey(agent.AgentID)) { MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + - agent.AgentID.ToStringHyphenated()); + agent.AgentID.ToStringHyphenated()); capsHandlers[agent.AgentID] = cap; } else @@ -1142,43 +1153,25 @@ namespace OpenSim.Region.Environment.Scenes public void AddModule(string name, IRegionModule module) { - if (!this.Modules.ContainsKey(name)) + if (!Modules.ContainsKey(name)) { Modules.Add(name, module); } } - //following delegate methods will be removed, so use the interface methods (below these) - public void RegisterAPIMethod(string name, object method) - { - if (!this.ModuleAPIMethods.ContainsKey(name)) - { - this.ModuleAPIMethods.Add(name, method); - } - } - - public object RequestAPIMethod(string name) - { - if (this.ModuleAPIMethods.ContainsKey(name)) - { - return ModuleAPIMethods[name]; - } - return false; - } - public void RegisterModuleInterface(M mod) { - if (!this.ModuleInterfaces.ContainsKey(typeof(M))) + if (!ModuleInterfaces.ContainsKey(typeof (M))) { - ModuleInterfaces.Add(typeof(M), mod); + ModuleInterfaces.Add(typeof (M), mod); } } public T RequestModuleInterface() { - if (ModuleInterfaces.ContainsKey(typeof(T))) + if (ModuleInterfaces.ContainsKey(typeof (T))) { - return (T)ModuleInterfaces[typeof(T)]; + return (T) ModuleInterfaces[typeof (T)]; } else { @@ -1191,7 +1184,8 @@ namespace OpenSim.Region.Environment.Scenes m_timePhase = phase; } - public void SendUrlToUser(LLUUID avatarID, string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) + public void SendUrlToUser(LLUUID avatarID, string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, + string message, string url) { if (Avatars.ContainsKey(avatarID)) { @@ -1201,7 +1195,7 @@ namespace OpenSim.Region.Environment.Scenes #region Alert Methods - void SendPermissionAlert(LLUUID user, string reason) + private void SendPermissionAlert(LLUUID user, string reason) { SendAlertToUser(user, reason, false); } @@ -1209,7 +1203,7 @@ namespace OpenSim.Region.Environment.Scenes public void SendGeneralAlert(string message) { - foreach (ScenePresence presence in this.Avatars.Values) + foreach (ScenePresence presence in Avatars.Values) { presence.ControllingClient.SendAlertMessage(message); } @@ -1217,15 +1211,15 @@ namespace OpenSim.Region.Environment.Scenes public void SendAlertToUser(LLUUID agentID, string message, bool modal) { - if (this.Avatars.ContainsKey(agentID)) + if (Avatars.ContainsKey(agentID)) { - this.Avatars[agentID].ControllingClient.SendAgentAlertMessage(message, modal); + Avatars[agentID].ControllingClient.SendAgentAlertMessage(message, modal); } } public void SendAlertToUser(string firstName, string lastName, string message, bool modal) { - foreach (ScenePresence presence in this.Avatars.Values) + foreach (ScenePresence presence in Avatars.Values) { if ((presence.Firstname == firstName) && (presence.Lastname == lastName)) { @@ -1239,13 +1233,13 @@ namespace OpenSim.Region.Environment.Scenes { if (commandParams[0] == "general") { - string message = this.CombineParams(commandParams, 1); - this.SendGeneralAlert(message); + string message = CombineParams(commandParams, 1); + SendGeneralAlert(message); } else { - string message = this.CombineParams(commandParams, 2); - this.SendAlertToUser(commandParams[0], commandParams[1], message, false); + string message = CombineParams(commandParams, 2); + SendAlertToUser(commandParams[0], commandParams[1], message, false); } } @@ -1258,36 +1252,39 @@ namespace OpenSim.Region.Environment.Scenes } return result; } + #endregion public void ForceClientUpdate() { - foreach (EntityBase ent in this.Entities.Values) + foreach (EntityBase ent in Entities.Values) { if (ent is SceneObjectGroup) { - ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); + ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); } } } - + public void HandleEditCommand(string[] cmmdparams) { Console.WriteLine("Searching for Primitive: '" + cmmdparams[0] + "'"); - foreach (EntityBase ent in this.Entities.Values) + foreach (EntityBase ent in Entities.Values) { if (ent is SceneObjectGroup) { - SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); - if (part != null) - { - if (part.Name == cmmdparams[0]) - { - part.Resize( new LLVector3(Convert.ToSingle(cmmdparams[1]), Convert.ToSingle(cmmdparams[2]), Convert.ToSingle(cmmdparams[3]))); - - Console.WriteLine("Edited scale of Primitive: " + part.Name); - } - } + SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID); + if (part != null) + { + if (part.Name == cmmdparams[0]) + { + part.Resize( + new LLVector3(Convert.ToSingle(cmmdparams[1]), Convert.ToSingle(cmmdparams[2]), + Convert.ToSingle(cmmdparams[3]))); + + Console.WriteLine("Edited scale of Primitive: " + part.Name); + } + } } } } @@ -1298,7 +1295,9 @@ namespace OpenSim.Region.Environment.Scenes { case "users": MainLog.Instance.Error("Current Region: " + RegionInfo.RegionName); - MainLog.Instance.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World")); + MainLog.Instance.Error( + String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", + "Agent ID", "Session ID", "Circuit", "IP", "World")); foreach (EntityBase entity in Entities.Values) { @@ -1321,8 +1320,8 @@ namespace OpenSim.Region.Environment.Scenes } break; case "modules": - MainLog.Instance.Error("The currently loaded modules in " + this.RegionInfo.RegionName + " are:"); - foreach (OpenSim.Region.Environment.Interfaces.IRegionModule module in this.Modules.Values) + MainLog.Instance.Error("The currently loaded modules in " + RegionInfo.RegionName + " are:"); + foreach (IRegionModule module in Modules.Values) { if (!module.IsSharedModule()) { @@ -1337,19 +1336,22 @@ namespace OpenSim.Region.Environment.Scenes { if (m_httpRequestModule != null) { - return m_httpRequestModule.MakeHttpRequest(url, type, body); + return m_httpRequestModule.MakeHttpRequest(url, type, body); } return LLUUID.Zero; } #region Script Engine - private List ScriptEngines = new List(); - public void AddScriptEngine(OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine, LogBase m_logger) + + private List ScriptEngines = new List(); + + public void AddScriptEngine(ScriptEngineInterface ScriptEngine, LogBase m_logger) { ScriptEngines.Add(ScriptEngine); ScriptEngine.InitializeEngine(this, m_logger); } + #endregion public LLUUID ConvertLocalIDToFullID(uint localID) @@ -1359,10 +1361,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - return ((SceneObjectGroup)ent).GetPartsFullID(localID); + return ((SceneObjectGroup) ent).GetPartsFullID(localID); } } } @@ -1376,10 +1378,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - return ((SceneObjectGroup)ent).GetChildPart(localID); + return ((SceneObjectGroup) ent).GetChildPart(localID); } } } @@ -1393,14 +1395,14 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(fullID); if (hasPrim != false) { - return ((SceneObjectGroup)ent).GetChildPart(fullID); + return ((SceneObjectGroup) ent).GetChildPart(fullID); } } } return null; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index c01157d..7b2e17f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -27,15 +27,12 @@ */ using System; using System.Collections.Generic; -using System.Reflection; using libsecondlife; +using OpenSim.Framework.Communications.Caches; using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; -using OpenSim.Framework.Communications.Caches; using OpenSim.Region.Terrain; -using OpenSim.Framework; -using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.Scenes { @@ -67,6 +64,7 @@ namespace OpenSim.Region.Environment.Scenes protected AssetCache assetCache; #region Update Methods + /// /// Normally called once every frame/tick to let the world preform anything required (like running the physics simulation) /// @@ -104,6 +102,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Add/Remove Agent/Avatar + /// /// /// @@ -126,7 +125,7 @@ namespace OpenSim.Region.Environment.Scenes /// public virtual RegionInfo RegionInfo { - get { return this.m_regInfo; } + get { return m_regInfo; } } public object SyncRoot @@ -140,6 +139,7 @@ namespace OpenSim.Region.Environment.Scenes } #region Shutdown + /// /// Tidy before shutdown /// @@ -147,7 +147,7 @@ namespace OpenSim.Region.Environment.Scenes { try { - this.EventManager.TriggerShutdown(); + EventManager.TriggerShutdown(); } catch (Exception e) { @@ -156,7 +156,5 @@ namespace OpenSim.Region.Environment.Scenes } #endregion - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index a86a1bc..a5d8667 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -1,5 +1,6 @@ using libsecondlife; using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.Scenes { @@ -9,41 +10,54 @@ namespace OpenSim.Region.Environment.Scenes public class EventManager { public delegate void OnFrameDelegate(); + public event OnFrameDelegate OnFrame; - public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore); + public delegate void OnBackupDelegate(IRegionDataStore datastore); + public event OnBackupDelegate OnBackup; public delegate void OnNewClientDelegate(IClientAPI client); + public event OnNewClientDelegate OnNewClient; public delegate void OnNewPresenceDelegate(ScenePresence presence); + public event OnNewPresenceDelegate OnNewPresence; public delegate void OnRemovePresenceDelegate(LLUUID uuid); + public event OnRemovePresenceDelegate OnRemovePresence; public delegate void OnParcelPrimCountUpdateDelegate(); + public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; public delegate void OnParcelPrimCountAddDelegate(SceneObjectGroup obj); + public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd; public delegate void OnScriptConsoleDelegate(string[] args); + public event OnScriptConsoleDelegate OnScriptConsole; public delegate void OnShutdownDelegate(); + public event OnShutdownDelegate OnShutdown; public delegate void ObjectGrabDelegate(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); + public delegate void OnPermissionErrorDelegate(LLUUID user, string reason); + public event ObjectGrabDelegate OnObjectGrab; public event OnPermissionErrorDelegate OnPermissionError; public delegate void NewRezScript(uint localID, LLUUID itemID, string script); + public event NewRezScript OnRezScript; public delegate void RemoveScript(uint localID, LLUUID itemID); + public event RemoveScript OnRemoveScript; public void TriggerPermissionError(LLUUID user, string reason) @@ -86,7 +100,7 @@ namespace OpenSim.Region.Environment.Scenes } } - public void TriggerOnBackup(Interfaces.IRegionDataStore dstore) + public void TriggerOnBackup(IRegionDataStore dstore) { if (OnBackup != null) { @@ -101,6 +115,7 @@ namespace OpenSim.Region.Environment.Scenes OnParcelPrimCountUpdate(); } } + public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) { if (OnParcelPrimCountAdd != null) @@ -137,4 +152,4 @@ namespace OpenSim.Region.Environment.Scenes } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 5655e72..effd4b2 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -1,20 +1,18 @@ -using System.Collections.Generic; -using System; -using OpenSim.Framework.Console; -using OpenSim.Framework.Types; - +using System; +using System.Collections.Generic; +using OpenSim.Framework.Console; +using OpenSim.Framework.Types; + namespace OpenSim.Region.Environment.Scenes { public class SceneManager { private readonly List m_localScenes; - private Scene m_currentScene = null; + private Scene m_currentScene = null; + public Scene CurrentScene { - get - { - return m_currentScene; - } + get { return m_currentScene; } } private Scene CurrentOrFirstScene @@ -83,18 +81,12 @@ namespace OpenSim.Region.Environment.Scenes public void SendCommandToScripts(string[] cmdparams) { - ForEach(delegate(Scene scene) - { - scene.SendCommandToScripts(cmdparams); - }); + ForEach(delegate(Scene scene) { scene.SendCommandToScripts(cmdparams); }); } public void BypassPermissions(bool bypassPermissions) { - ForEach(delegate(Scene scene) - { - scene.PermissionsMngr.BypassPermissions = bypassPermissions; - }); + ForEach(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; }); } private void ForEach(Action func) @@ -111,18 +103,12 @@ namespace OpenSim.Region.Environment.Scenes public void Backup() { - ForEach(delegate(Scene scene) - { - scene.Backup(); - }); + ForEach(delegate(Scene scene) { scene.Backup(); }); } public void HandleAlertCommand(string[] cmdparams) { - ForEach(delegate(Scene scene) - { - scene.HandleAlertCommand(cmdparams); - }); + ForEach(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); } public bool TrySetCurrentRegion(string regionName) @@ -161,8 +147,8 @@ namespace OpenSim.Region.Environment.Scenes if (!scenePrescence.childAgent) { log.Error(String.Format("Packet debug for {0} {1} set to {2}", - scenePrescence.Firstname, scenePrescence.Lastname, - newDebug)); + scenePrescence.Firstname, scenePrescence.Lastname, + newDebug)); scenePrescence.ControllingClient.SetDebug(newDebug); } @@ -219,18 +205,12 @@ namespace OpenSim.Region.Environment.Scenes public void ForceClientUpdate() { - ForEach(delegate(Scene scene) - { - scene.ForceClientUpdate(); - }); + ForEach(delegate(Scene scene) { scene.ForceClientUpdate(); }); } public void HandleEditCommand(string[] cmdparams) { - ForEach(delegate(Scene scene) - { - scene.HandleEditCommand(cmdparams); - }); + ForEach(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 99f1900..3182204 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1,17 +1,16 @@ +using System; using System.Collections.Generic; +using System.IO; using System.Text; using System.Xml; -using System.Xml.Serialization; -using System.IO; -using System; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; +using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; -using OpenSim.Region.Physics.Manager; -using OpenSim.Framework.Data; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes { @@ -31,6 +30,7 @@ namespace OpenSim.Region.Environment.Scenes public bool HasChanged = false; #region Properties + /// /// /// @@ -54,13 +54,13 @@ namespace OpenSim.Region.Environment.Scenes public Dictionary Children { - get { return this.m_parts; } + get { return m_parts; } set { m_parts = value; } } public SceneObjectPart RootPart { - get { return this.m_rootPart; } + get { return m_rootPart; } set { m_rootPart = value; } } @@ -70,9 +70,9 @@ namespace OpenSim.Region.Environment.Scenes set { m_regionHandle = value; - lock (this.m_parts) + lock (m_parts) { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.RegionHandle = m_regionHandle; } @@ -104,16 +104,18 @@ namespace OpenSim.Region.Environment.Scenes val.Y = 0.4f; } - lock (this.m_parts) + lock (m_parts) { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.GroupPosition = val; } } if (m_rootPart.PhysActor != null) { - m_rootPart.PhysActor.Position = new PhysicsVector(m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y, m_rootPart.GroupPosition.Z); + m_rootPart.PhysActor.Position = + new PhysicsVector(m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y, + m_rootPart.GroupPosition.Z); } } } @@ -152,10 +154,7 @@ namespace OpenSim.Region.Environment.Scenes protected virtual bool InSceneBackup { - get - { - return true; - } + get { return true; } } public bool IsSelected @@ -170,19 +169,22 @@ namespace OpenSim.Region.Environment.Scenes get { if (m_scene != null) - { return m_scene.RegionInfo.SimUUID; } + { + return m_scene.RegionInfo.SimUUID; + } return LLUUID.Zero; } } + #endregion #region Constructors + /// /// /// public SceneObjectGroup() { - } /// @@ -198,7 +200,7 @@ namespace OpenSim.Region.Environment.Scenes reader.Read(); reader.ReadStartElement("SceneObjectGroup"); reader.ReadStartElement("RootPart"); - this.m_rootPart = SceneObjectPart.FromXml(reader); + m_rootPart = SceneObjectPart.FromXml(reader); reader.ReadEndElement(); while (reader.Read()) @@ -211,7 +213,7 @@ namespace OpenSim.Region.Environment.Scenes reader.Read(); SceneObjectPart Part = SceneObjectPart.FromXml(reader); Part.LocalID = m_scene.PrimIDAllocate(); - this.AddPart(Part); + AddPart(Part); Part.RegionHandle = m_regionHandle; } break; @@ -221,23 +223,23 @@ namespace OpenSim.Region.Environment.Scenes } reader.Close(); sr.Close(); - this.m_rootPart.SetParent(this); - this.m_parts.Add(m_rootPart.UUID, m_rootPart); - this.m_rootPart.LocalID = m_scene.PrimIDAllocate(); - this.m_rootPart.ParentID = 0; - this.m_rootPart.RegionHandle = m_regionHandle; - this.UpdateParentIDs(); + m_rootPart.SetParent(this); + m_parts.Add(m_rootPart.UUID, m_rootPart); + m_rootPart.LocalID = m_scene.PrimIDAllocate(); + m_rootPart.ParentID = 0; + m_rootPart.RegionHandle = m_regionHandle; + UpdateParentIDs(); AttachToBackup(); - this.ScheduleGroupForFullUpdate(); + ScheduleGroupForFullUpdate(); } private void AttachToBackup() { if (InSceneBackup) { - m_scene.EventManager.OnBackup += this.ProcessBackup; + m_scene.EventManager.OnBackup += ProcessBackup; } } @@ -246,25 +248,27 @@ namespace OpenSim.Region.Environment.Scenes /// public SceneObjectGroup(byte[] data) { - } /// /// /// - public SceneObjectGroup(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) + public SceneObjectGroup(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos, + PrimitiveBaseShape shape) { m_regionHandle = regionHandle; m_scene = scene; // this.Pos = pos; LLVector3 rootOffset = new LLVector3(0, 0, 0); - SceneObjectPart newPart = new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset); - this.m_parts.Add(newPart.UUID, newPart); - this.SetPartAsRoot(newPart); + SceneObjectPart newPart = + new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset); + m_parts.Add(newPart.UUID, newPart); + SetPartAsRoot(newPart); AttachToBackup(); } + #endregion public string ToXmlString() @@ -276,9 +280,9 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.ToXml(writer); writer.WriteEndElement(); writer.WriteStartElement(String.Empty, "OtherParts", String.Empty); - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { - if (part.UUID != this.m_rootPart.UUID) + if (part.UUID != m_rootPart.UUID) { writer.WriteStartElement(String.Empty, "Part", String.Empty); part.ToXml(writer); @@ -292,35 +296,36 @@ namespace OpenSim.Region.Environment.Scenes } #region Copying + /// /// /// /// public new SceneObjectGroup Copy() { - SceneObjectGroup dupe = (SceneObjectGroup)this.MemberwiseClone(); + SceneObjectGroup dupe = (SceneObjectGroup) MemberwiseClone(); dupe.m_parts = new Dictionary(); dupe.m_parts.Clear(); dupe.AbsolutePosition = new LLVector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); dupe.m_scene = m_scene; - dupe.m_regionHandle = this.m_regionHandle; - dupe.CopyRootPart(this.m_rootPart); + dupe.m_regionHandle = m_regionHandle; + dupe.CopyRootPart(m_rootPart); /// may need to create a new Physics actor. if (dupe.RootPart.PhysActor != null) { dupe.RootPart.PhysActor = m_scene.phyScene.AddPrim( - new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, dupe.RootPart.AbsolutePosition.Z), - new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), - new Axiom.Math.Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, - dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z)); - + new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, + dupe.RootPart.AbsolutePosition.Z), + new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), + new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, + dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z)); } - List partList = new List(this.m_parts.Values); + List partList = new List(m_parts.Values); foreach (SceneObjectPart part in partList) { - if (part.UUID != this.m_rootPart.UUID) + if (part.UUID != m_rootPart.UUID) { dupe.CopyPart(part); } @@ -328,7 +333,7 @@ namespace OpenSim.Region.Environment.Scenes dupe.UpdateParentIDs(); dupe.AttachToBackup(); - + return dupe; } @@ -340,8 +345,8 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate()); newPart.SetParent(this); - this.m_parts.Add(newPart.UUID, newPart); - this.SetPartAsRoot(newPart); + m_parts.Add(newPart.UUID, newPart); + SetPartAsRoot(newPart); } /// @@ -352,18 +357,20 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate()); newPart.SetParent(this); - this.m_parts.Add(newPart.UUID, newPart); - this.SetPartAsNonRoot(newPart); + m_parts.Add(newPart.UUID, newPart); + SetPartAsNonRoot(newPart); } + #endregion #region Scheduling + /// /// /// public override void Update() { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.SendScheduledUpdates(); } @@ -371,7 +378,7 @@ namespace OpenSim.Region.Environment.Scenes public void ScheduleFullUpdateToAvatar(ScenePresence presence) { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.AddFullUpdateToAvatar(presence); } @@ -379,7 +386,7 @@ namespace OpenSim.Region.Environment.Scenes public void ScheduleTerseUpdateToAvatar(ScenePresence presence) { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.AddTerseUpdateToAvatar(presence); } @@ -391,7 +398,7 @@ namespace OpenSim.Region.Environment.Scenes public void ScheduleGroupForFullUpdate() { HasChanged = true; - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.ScheduleFullUpdate(); } @@ -403,7 +410,7 @@ namespace OpenSim.Region.Environment.Scenes public void ScheduleGroupForTerseUpdate() { HasChanged = true; - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.ScheduleTerseUpdate(); } @@ -415,7 +422,7 @@ namespace OpenSim.Region.Environment.Scenes public void SendGroupFullUpdate() { HasChanged = true; - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.SendFullUpdateToAllClients(); } @@ -427,7 +434,7 @@ namespace OpenSim.Region.Environment.Scenes public void SendGroupTerseUpdate() { HasChanged = true; - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.SendTerseUpdateToAllClients(); } @@ -436,6 +443,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region SceneGroupPart Methods + /// /// /// @@ -444,9 +452,9 @@ namespace OpenSim.Region.Environment.Scenes public SceneObjectPart GetChildPart(LLUUID primID) { SceneObjectPart childPart = null; - if (this.m_parts.ContainsKey(primID)) + if (m_parts.ContainsKey(primID)) { - childPart = this.m_parts[primID]; + childPart = m_parts[primID]; } return childPart; } @@ -458,7 +466,7 @@ namespace OpenSim.Region.Environment.Scenes /// public SceneObjectPart GetChildPart(uint localID) { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { if (part.LocalID == localID) { @@ -477,9 +485,9 @@ namespace OpenSim.Region.Environment.Scenes public bool HasChildPrim(LLUUID primID) { SceneObjectPart childPart = null; - if (this.m_parts.ContainsKey(primID)) + if (m_parts.ContainsKey(primID)) { - childPart = this.m_parts[primID]; + childPart = m_parts[primID]; return true; } return false; @@ -493,7 +501,7 @@ namespace OpenSim.Region.Environment.Scenes /// public bool HasChildPrim(uint localID) { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { if (part.LocalID == localID) { @@ -502,9 +510,11 @@ namespace OpenSim.Region.Environment.Scenes } return false; } + #endregion #region Packet Handlers + /// /// /// @@ -512,21 +522,28 @@ namespace OpenSim.Region.Environment.Scenes public void LinkToGroup(SceneObjectGroup objectGroup) { SceneObjectPart linkPart = objectGroup.m_rootPart; - Axiom.Math.Vector3 oldGroupPosition = new Vector3(linkPart.GroupPosition.X, linkPart.GroupPosition.Y, linkPart.GroupPosition.Z); - Axiom.Math.Quaternion oldRootRotation = new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z); + Vector3 oldGroupPosition = + new Vector3(linkPart.GroupPosition.X, linkPart.GroupPosition.Y, linkPart.GroupPosition.Z); + Quaternion oldRootRotation = + new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, + linkPart.RotationOffset.Z); - linkPart.OffsetPosition = linkPart.GroupPosition - this.AbsolutePosition; - linkPart.GroupPosition = this.AbsolutePosition; + linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; + linkPart.GroupPosition = AbsolutePosition; Vector3 axPos = new Vector3(linkPart.OffsetPosition.X, linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z); - Quaternion parentRot = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z); - axPos = parentRot.Inverse() * axPos; + Quaternion parentRot = + new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, + m_rootPart.RotationOffset.Z); + axPos = parentRot.Inverse()*axPos; linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); - Quaternion oldRot = new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z); - Quaternion newRot = parentRot.Inverse() * oldRot; + Quaternion oldRot = + new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, + linkPart.RotationOffset.Z); + Quaternion newRot = parentRot.Inverse()*oldRot; linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); - linkPart.ParentID = this.m_rootPart.LocalID; - this.m_parts.Add(linkPart.UUID, linkPart); + linkPart.ParentID = m_rootPart.LocalID; + m_parts.Add(linkPart.UUID, linkPart); linkPart.SetParent(this); if (linkPart.PhysActor != null) @@ -540,7 +557,7 @@ namespace OpenSim.Region.Environment.Scenes { if (part.UUID != objectGroup.m_rootPart.UUID) { - this.LinkNonRootPart(part, oldGroupPosition, oldRootRotation); + LinkNonRootPart(part, oldGroupPosition, oldRootRotation); } } @@ -549,7 +566,7 @@ namespace OpenSim.Region.Environment.Scenes m_scene.DeleteEntity(objectGroup.UUID); objectGroup.DeleteParts(); - this.ScheduleGroupForFullUpdate(); + ScheduleGroupForFullUpdate(); } private void DetachFromBackup(SceneObjectGroup objectGroup) @@ -561,26 +578,31 @@ namespace OpenSim.Region.Environment.Scenes private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation) { part.SetParent(this); - part.ParentID = this.m_rootPart.LocalID; - this.m_parts.Add(part.UUID, part); + part.ParentID = m_rootPart.LocalID; + m_parts.Add(part.UUID, part); Vector3 axiomOldPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); - axiomOldPos = oldGroupRotation * axiomOldPos; + axiomOldPos = oldGroupRotation*axiomOldPos; axiomOldPos += oldGroupPosition; LLVector3 oldAbsolutePosition = new LLVector3(axiomOldPos.x, axiomOldPos.y, axiomOldPos.z); - part.OffsetPosition = oldAbsolutePosition - this.AbsolutePosition; + part.OffsetPosition = oldAbsolutePosition - AbsolutePosition; - Quaternion axiomRootRotation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); + Quaternion axiomRootRotation = + new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, + m_rootPart.RotationOffset.Z); Vector3 axiomPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); - axiomPos = axiomRootRotation.Inverse() * axiomPos; + axiomPos = axiomRootRotation.Inverse()*axiomPos; part.OffsetPosition = new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z); - Quaternion axiomPartRotation = new Quaternion(part.RotationOffset.W, part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z); + Quaternion axiomPartRotation = + new Quaternion(part.RotationOffset.W, part.RotationOffset.X, part.RotationOffset.Y, + part.RotationOffset.Z); - axiomPartRotation = oldGroupRotation * axiomPartRotation; - axiomPartRotation = axiomRootRotation.Inverse() * axiomPartRotation; - part.RotationOffset = new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w); + axiomPartRotation = oldGroupRotation*axiomPartRotation; + axiomPartRotation = axiomRootRotation.Inverse()*axiomPartRotation; + part.RotationOffset = + new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w); } /// @@ -591,8 +613,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void GrabMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { - this.AbsolutePosition = pos; - this.m_rootPart.SendTerseUpdateToAllClients(); + AbsolutePosition = pos; + m_rootPart.SendTerseUpdateToAllClients(); } /// @@ -605,25 +627,25 @@ namespace OpenSim.Region.Environment.Scenes proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); proper.ObjectData[0].ItemID = LLUUID.Zero; - proper.ObjectData[0].CreationDate = (ulong)this.m_rootPart.CreationDate; - proper.ObjectData[0].CreatorID = this.m_rootPart.CreatorID; + proper.ObjectData[0].CreationDate = (ulong) m_rootPart.CreationDate; + proper.ObjectData[0].CreatorID = m_rootPart.CreatorID; proper.ObjectData[0].FolderID = LLUUID.Zero; proper.ObjectData[0].FromTaskID = LLUUID.Zero; proper.ObjectData[0].GroupID = LLUUID.Zero; - proper.ObjectData[0].InventorySerial = (short)this.m_rootPart.InventorySerial; - proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID; - proper.ObjectData[0].ObjectID = this.UUID; - proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID; - proper.ObjectData[0].TouchName = enc.GetBytes(this.m_rootPart.TouchName + "\0"); + proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; + proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; + proper.ObjectData[0].ObjectID = UUID; + proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; + proper.ObjectData[0].TouchName = enc.GetBytes(m_rootPart.TouchName + "\0"); proper.ObjectData[0].TextureID = new byte[0]; - proper.ObjectData[0].SitName = enc.GetBytes(this.m_rootPart.SitName + "\0"); - proper.ObjectData[0].Name = enc.GetBytes(this.m_rootPart.Name + "\0"); - proper.ObjectData[0].Description = enc.GetBytes(this.m_rootPart.Description + "\0"); - proper.ObjectData[0].OwnerMask = this.m_rootPart.OwnerMask; - proper.ObjectData[0].NextOwnerMask = this.m_rootPart.NextOwnerMask; - proper.ObjectData[0].GroupMask = this.m_rootPart.GroupMask; - proper.ObjectData[0].EveryoneMask = this.m_rootPart.EveryoneMask; - proper.ObjectData[0].BaseMask = this.m_rootPart.BaseMask; + proper.ObjectData[0].SitName = enc.GetBytes(m_rootPart.SitName + "\0"); + proper.ObjectData[0].Name = enc.GetBytes(m_rootPart.Name + "\0"); + proper.ObjectData[0].Description = enc.GetBytes(m_rootPart.Description + "\0"); + proper.ObjectData[0].OwnerMask = m_rootPart.OwnerMask; + proper.ObjectData[0].NextOwnerMask = m_rootPart.NextOwnerMask; + proper.ObjectData[0].GroupMask = m_rootPart.GroupMask; + proper.ObjectData[0].EveryoneMask = m_rootPart.EveryoneMask; + proper.ObjectData[0].BaseMask = m_rootPart.BaseMask; client.OutPacket(proper); } @@ -635,7 +657,7 @@ namespace OpenSim.Region.Environment.Scenes public void SetPartName(string name, uint localID) { name = name.Remove(name.Length - 1, 1); - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.Name = name; @@ -644,7 +666,7 @@ namespace OpenSim.Region.Environment.Scenes public void SetPartDescription(string des, uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.Description = des; @@ -653,7 +675,7 @@ namespace OpenSim.Region.Environment.Scenes public void SetPartText(string text, uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.Text = text; @@ -662,7 +684,7 @@ namespace OpenSim.Region.Environment.Scenes public void SetPartText(string text, LLUUID partID) { - SceneObjectPart part = this.GetChildPart(partID); + SceneObjectPart part = GetChildPart(partID); if (part != null) { part.Text = text; @@ -671,7 +693,7 @@ namespace OpenSim.Region.Environment.Scenes public string GetPartName(uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { return part.Name; @@ -681,7 +703,7 @@ namespace OpenSim.Region.Environment.Scenes public string GetPartDescription(uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { return part.Description; @@ -696,7 +718,7 @@ namespace OpenSim.Region.Environment.Scenes /// public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { return part.GetInventoryFileName(remoteClient, localID); @@ -706,7 +728,7 @@ namespace OpenSim.Region.Environment.Scenes public string RequestInventoryFile(uint localID, IXfer xferManager) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.RequestInventoryFile(xferManager); @@ -716,7 +738,7 @@ namespace OpenSim.Region.Environment.Scenes public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { SceneObjectPart.TaskInventoryItem taskItem = new SceneObjectPart.TaskInventoryItem(); @@ -732,14 +754,13 @@ namespace OpenSim.Region.Environment.Scenes return true; } return false; - } public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item, LLUUID copyItemID) { if (copyItemID != LLUUID.Zero) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { SceneObjectPart.TaskInventoryItem taskItem = new SceneObjectPart.TaskInventoryItem(); @@ -764,7 +785,7 @@ namespace OpenSim.Region.Environment.Scenes public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { return part.RemoveInventoryItem(remoteClient, localID, itemID); @@ -781,7 +802,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.UpdateExtraParam(type, inUse, data); @@ -795,30 +816,34 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdateTextureEntry(uint localID, byte[] textureEntry) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.UpdateTextureEntry(textureEntry); } } + #endregion #region Shape + /// /// /// /// public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock, uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.UpdateShape(shapeBlock); } } + #endregion #region Resize + /// /// /// @@ -826,30 +851,33 @@ namespace OpenSim.Region.Environment.Scenes /// public void Resize(LLVector3 scale, uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { part.Resize(scale); - if (part.UUID == this.m_rootPart.UUID) + if (part.UUID == m_rootPart.UUID) { if (m_rootPart.PhysActor != null) { - m_rootPart.PhysActor.Size = new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z); + m_rootPart.PhysActor.Size = + new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z); } } } } + #endregion #region Position + /// /// /// /// public void UpdateGroupPosition(LLVector3 pos) { - this.AbsolutePosition = pos; - this.ScheduleGroupForTerseUpdate(); + AbsolutePosition = pos; + ScheduleGroupForTerseUpdate(); } /// @@ -859,12 +887,12 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdateSinglePosition(LLVector3 pos, uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { - if (part.UUID == this.m_rootPart.UUID) + if (part.UUID == m_rootPart.UUID) { - this.UpdateRootPosition(pos); + UpdateRootPosition(pos); } else { @@ -880,40 +908,49 @@ namespace OpenSim.Region.Environment.Scenes private void UpdateRootPosition(LLVector3 pos) { LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - LLVector3 oldPos = new LLVector3(this.AbsolutePosition.X + this.m_rootPart.OffsetPosition.X, this.AbsolutePosition.Y + this.m_rootPart.OffsetPosition.Y, this.AbsolutePosition.Z + this.m_rootPart.OffsetPosition.Z); + LLVector3 oldPos = + new LLVector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, + AbsolutePosition.Y + m_rootPart.OffsetPosition.Y, + AbsolutePosition.Z + m_rootPart.OffsetPosition.Z); LLVector3 diff = oldPos - newPos; - Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); - Axiom.Math.Quaternion partRotation = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z); - axDiff = partRotation.Inverse() * axDiff; + Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); + Quaternion partRotation = + new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, + m_rootPart.RotationOffset.Z); + axDiff = partRotation.Inverse()*axDiff; diff.X = axDiff.x; diff.Y = axDiff.y; diff.Z = axDiff.z; - foreach (SceneObjectPart obPart in this.m_parts.Values) + foreach (SceneObjectPart obPart in m_parts.Values) { - if (obPart.UUID != this.m_rootPart.UUID) + if (obPart.UUID != m_rootPart.UUID) { obPart.OffsetPosition = obPart.OffsetPosition + diff; } } - this.AbsolutePosition = newPos; - this.ScheduleGroupForTerseUpdate(); + AbsolutePosition = newPos; + ScheduleGroupForTerseUpdate(); } + #endregion #region Rotation + /// /// /// /// public void UpdateGroupRotation(LLQuaternion rot) { - this.m_rootPart.UpdateRotation(rot); + m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) { - m_rootPart.PhysActor.Orientation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); + m_rootPart.PhysActor.Orientation = + new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, + m_rootPart.RotationOffset.Z); } - this.ScheduleGroupForTerseUpdate(); + ScheduleGroupForTerseUpdate(); } /// @@ -923,13 +960,15 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdateGroupRotation(LLVector3 pos, LLQuaternion rot) { - this.m_rootPart.UpdateRotation(rot); + m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) { - m_rootPart.PhysActor.Orientation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); + m_rootPart.PhysActor.Orientation = + new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, + m_rootPart.RotationOffset.Z); } - this.AbsolutePosition = pos; - this.ScheduleGroupForTerseUpdate(); + AbsolutePosition = pos; + ScheduleGroupForTerseUpdate(); } /// @@ -939,12 +978,12 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdateSingleRotation(LLQuaternion rot, uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { - if (part.UUID == this.m_rootPart.UUID) + if (part.UUID == m_rootPart.UUID) { - this.UpdateRootRotation(rot); + UpdateRootRotation(rot); } else { @@ -959,40 +998,48 @@ namespace OpenSim.Region.Environment.Scenes /// private void UpdateRootRotation(LLQuaternion rot) { - Axiom.Math.Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); - Axiom.Math.Quaternion oldParentRot = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z); + Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); + Quaternion oldParentRot = + new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, + m_rootPart.RotationOffset.Z); - this.m_rootPart.UpdateRotation(rot); + m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) { - m_rootPart.PhysActor.Orientation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); + m_rootPart.PhysActor.Orientation = + new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, + m_rootPart.RotationOffset.Z); } - foreach (SceneObjectPart prim in this.m_parts.Values) + foreach (SceneObjectPart prim in m_parts.Values) { - if (prim.UUID != this.m_rootPart.UUID) + if (prim.UUID != m_rootPart.UUID) { Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z); - axPos = oldParentRot * axPos; - axPos = axRot.Inverse() * axPos; + axPos = oldParentRot*axPos; + axPos = axRot.Inverse()*axPos; prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); - Axiom.Math.Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z); - Axiom.Math.Quaternion newRot = oldParentRot * primsRot; - newRot = axRot.Inverse() * newRot; + Quaternion primsRot = + new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, + prim.RotationOffset.Z); + Quaternion newRot = oldParentRot*primsRot; + newRot = axRot.Inverse()*newRot; prim.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); prim.ScheduleTerseUpdate(); } } - this.m_rootPart.ScheduleTerseUpdate(); + m_rootPart.ScheduleTerseUpdate(); } + #endregion + /// /// /// /// private void SetPartAsRoot(SceneObjectPart part) { - this.m_rootPart = part; + m_rootPart = part; } /// @@ -1001,7 +1048,7 @@ namespace OpenSim.Region.Environment.Scenes /// private void SetPartAsNonRoot(SceneObjectPart part) { - part.ParentID = this.m_rootPart.LocalID; + part.ParentID = m_rootPart.LocalID; } /// @@ -1014,6 +1061,7 @@ namespace OpenSim.Region.Environment.Scenes } #region Events + /// /// /// @@ -1021,7 +1069,7 @@ namespace OpenSim.Region.Environment.Scenes { if (OnPrimCountTainted != null) { - this.OnPrimCountTainted(); + OnPrimCountTainted(); } } @@ -1029,7 +1077,7 @@ namespace OpenSim.Region.Environment.Scenes /// Processes backup /// /// - public void ProcessBackup(OpenSim.Region.Environment.Interfaces.IRegionDataStore datastore) + public void ProcessBackup(IRegionDataStore datastore) { if (HasChanged) { @@ -1037,16 +1085,18 @@ namespace OpenSim.Region.Environment.Scenes HasChanged = false; } } + #endregion #region Client Updating + public void SendFullUpdateToClient(IClientAPI remoteClient) { - lock (this.m_parts) + lock (m_parts) { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { - this.SendPartFullUpdate(remoteClient, part); + SendPartFullUpdate(remoteClient, part); } } } @@ -1084,6 +1134,7 @@ namespace OpenSim.Region.Environment.Scenes part.SendTerseUpdateToClient(remoteClient); } } + #endregion public override void UpdateMovement() @@ -1114,7 +1165,7 @@ namespace OpenSim.Region.Environment.Scenes public void AddPart(SceneObjectPart part) { part.SetParent(this); - this.m_parts.Add(part.UUID, part); + m_parts.Add(part.UUID, part); } /// @@ -1122,18 +1173,18 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdateParentIDs() { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { - if (part.UUID != this.m_rootPart.UUID) + if (part.UUID != m_rootPart.UUID) { - part.ParentID = this.m_rootPart.LocalID; + part.ParentID = m_rootPart.LocalID; } } } public void RegenerateFullIDs() { - foreach (SceneObjectPart part in this.m_parts.Values) + foreach (SceneObjectPart part in m_parts.Values) { part.UUID = LLUUID.Random(); } @@ -1141,7 +1192,7 @@ namespace OpenSim.Region.Environment.Scenes public LLUUID GetPartsFullID(uint localID) { - SceneObjectPart part = this.GetChildPart(localID); + SceneObjectPart part = GetChildPart(localID); if (part != null) { return part.UUID; @@ -1175,26 +1226,25 @@ namespace OpenSim.Region.Environment.Scenes public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) { - } public void DeleteGroup() { - DetachFromBackup( this ); - foreach (SceneObjectPart part in this.m_parts.Values) + DetachFromBackup(this); + foreach (SceneObjectPart part in m_parts.Values) { - List avatars = this.RequestSceneAvatars(); + List avatars = RequestSceneAvatars(); for (int i = 0; i < avatars.Count; i++) { - avatars[i].ControllingClient.SendKillObject(this.m_regionHandle, part.LocalID); + avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalID); } } } public void DeleteParts() { - this.m_rootPart = null; - this.m_parts.Clear(); + m_rootPart = null; + m_parts.Clear(); } public override void SetText(string text, Vector3 color, double alpha) @@ -1202,4 +1252,4 @@ namespace OpenSim.Region.Environment.Scenes Text = text; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index abb69f4..deacd18 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -1,23 +1,19 @@ +using System; using System.Collections.Generic; -using System.Text; using System.Xml; using System.Xml.Serialization; -using System.IO; -using System; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; +using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes.Scripting; -using OpenSim.Framework; using OpenSim.Region.Physics.Manager; -using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.Scenes { - public class SceneObjectPart : IScriptHost { private const uint FULL_MASK_PERMISSIONS = 2147483647; @@ -25,8 +21,7 @@ namespace OpenSim.Region.Environment.Scenes private string m_inventoryFileName = ""; private LLUUID m_folderID = LLUUID.Zero; - [XmlIgnore] - public PhysicsActor PhysActor = null; + [XmlIgnore] public PhysicsActor PhysActor = null; protected Dictionary TaskInventory = new Dictionary(); @@ -57,19 +52,25 @@ namespace OpenSim.Region.Environment.Scenes #region Properties public LLUUID CreatorID; - public LLUUID ObjectCreator { get { return CreatorID; } } + + public LLUUID ObjectCreator + { + get { return CreatorID; } + } /// /// Serial count for inventory file , used to tell if inventory has changed /// no need for this to be part of Database backup /// protected uint m_inventorySerial = 0; + public uint InventorySerial { get { return m_inventorySerial; } } protected LLUUID m_uuid; + public LLUUID UUID { get { return m_uuid; } @@ -77,6 +78,7 @@ namespace OpenSim.Region.Environment.Scenes } protected uint m_localID; + public uint LocalID { get { return m_localID; } @@ -84,6 +86,7 @@ namespace OpenSim.Region.Environment.Scenes } protected string m_name; + public virtual string Name { get { return m_name; } @@ -91,20 +94,23 @@ namespace OpenSim.Region.Environment.Scenes } protected LLObject.ObjectFlags m_flags; + public uint ObjectFlags { - get { return (uint)m_flags; } - set { m_flags = (LLObject.ObjectFlags)value; } + get { return (uint) m_flags; } + set { m_flags = (LLObject.ObjectFlags) value; } } protected LLObject.MaterialType m_material; + public byte Material { - get { return (byte)m_material; } - set { m_material = (LLObject.MaterialType)value; } + get { return (byte) m_material; } + set { m_material = (LLObject.MaterialType) value; } } protected ulong m_regionHandle; + public ulong RegionHandle { get { return m_regionHandle; } @@ -113,6 +119,7 @@ namespace OpenSim.Region.Environment.Scenes //unkown if this will be kept, added as a way of removing the group position from the group class protected LLVector3 m_groupPosition; + public LLVector3 GroupPosition { get { return m_groupPosition; } @@ -120,6 +127,7 @@ namespace OpenSim.Region.Environment.Scenes } protected LLVector3 m_offsetPosition; + public LLVector3 OffsetPosition { get { return m_offsetPosition; } @@ -132,6 +140,7 @@ namespace OpenSim.Region.Environment.Scenes } protected LLQuaternion m_rotationOffset; + public LLQuaternion RotationOffset { get { return m_rotationOffset; } @@ -139,6 +148,7 @@ namespace OpenSim.Region.Environment.Scenes } protected LLVector3 m_velocity; + /// public LLVector3 Velocity { @@ -147,6 +157,7 @@ namespace OpenSim.Region.Environment.Scenes } protected LLVector3 m_angularVelocity; + /// public LLVector3 AngularVelocity { @@ -155,6 +166,7 @@ namespace OpenSim.Region.Environment.Scenes } protected LLVector3 m_acceleration; + /// public LLVector3 Acceleration { @@ -163,13 +175,15 @@ namespace OpenSim.Region.Environment.Scenes } private string m_description = ""; + public string Description { - get { return this.m_description; } - set { this.m_description = value; } + get { return m_description; } + set { m_description = value; } } private string m_text = ""; + public string Text { get { return m_text; } @@ -181,6 +195,7 @@ namespace OpenSim.Region.Environment.Scenes } private string m_sitName = ""; + public string SitName { get { return m_sitName; } @@ -188,6 +203,7 @@ namespace OpenSim.Region.Environment.Scenes } private string m_touchName = ""; + public string TouchName { get { return m_touchName; } @@ -195,17 +211,19 @@ namespace OpenSim.Region.Environment.Scenes } protected PrimitiveBaseShape m_shape; + public PrimitiveBaseShape Shape { - get { return this.m_shape; } + get { return m_shape; } set { m_shape = value; } } public LLVector3 Scale { - set { this.m_shape.Scale = value; } - get { return this.m_shape.Scale; } + set { m_shape.Scale = value; } + get { return m_shape.Scale; } } + #endregion public LLUUID ObjectOwner @@ -215,16 +233,16 @@ namespace OpenSim.Region.Environment.Scenes public SceneObjectGroup ParentGroup { - get { return m_parentGroup; } + get { return m_parentGroup; } } #region Constructors + /// /// /// public SceneObjectPart() { - } /// @@ -236,43 +254,44 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID, PrimitiveBaseShape shape, LLVector3 groupPosition, LLVector3 offsetPosition) - { - this.m_name = "Primitive"; - this.m_regionHandle = regionHandle; - this.m_parentGroup = parent; - - this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - this.OwnerID = ownerID; - this.CreatorID = this.OwnerID; - this.LastOwnerID = LLUUID.Zero; - this.UUID = LLUUID.Random(); - this.LocalID = (uint)(localID); - this.Shape = shape; - - this.GroupPosition = groupPosition; - this.OffsetPosition = offsetPosition; - this.RotationOffset = LLQuaternion.Identity; - this.Velocity = new LLVector3(0, 0, 0); - this.AngularVelocity = new LLVector3(0, 0, 0); - this.Acceleration = new LLVector3(0, 0, 0); - + public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID, + PrimitiveBaseShape shape, LLVector3 groupPosition, LLVector3 offsetPosition) + { + m_name = "Primitive"; + m_regionHandle = regionHandle; + m_parentGroup = parent; + + CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + OwnerID = ownerID; + CreatorID = OwnerID; + LastOwnerID = LLUUID.Zero; + UUID = LLUUID.Random(); + LocalID = (uint) (localID); + Shape = shape; + + GroupPosition = groupPosition; + OffsetPosition = offsetPosition; + RotationOffset = LLQuaternion.Identity; + Velocity = new LLVector3(0, 0, 0); + AngularVelocity = new LLVector3(0, 0, 0); + Acceleration = new LLVector3(0, 0, 0); + m_inventoryFileName = "taskinventory" + LLUUID.Random().ToString(); m_folderID = LLUUID.Random(); - + m_flags = 0; - m_flags |= LLObject.ObjectFlags.ObjectModify | - LLObject.ObjectFlags.ObjectCopy | - LLObject.ObjectFlags.ObjectYouOwner | - LLObject.ObjectFlags.Touch | - LLObject.ObjectFlags.ObjectMove | - LLObject.ObjectFlags.AllowInventoryDrop | - LLObject.ObjectFlags.ObjectTransfer | - LLObject.ObjectFlags.ObjectOwnerModify; - + m_flags |= LLObject.ObjectFlags.ObjectModify | + LLObject.ObjectFlags.ObjectCopy | + LLObject.ObjectFlags.ObjectYouOwner | + LLObject.ObjectFlags.Touch | + LLObject.ObjectFlags.ObjectMove | + LLObject.ObjectFlags.AllowInventoryDrop | + LLObject.ObjectFlags.ObjectTransfer | + LLObject.ObjectFlags.ObjectOwnerModify; + ScheduleFullUpdate(); } - + /// /// Re/create a SceneObjectPart (prim) /// currently not used, and maybe won't be @@ -283,23 +302,26 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, int creationDate, LLUUID ownerID, LLUUID creatorID, LLUUID lastOwnerID, uint localID, PrimitiveBaseShape shape, LLVector3 position, LLQuaternion rotation, uint flags) + public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, int creationDate, LLUUID ownerID, + LLUUID creatorID, LLUUID lastOwnerID, uint localID, PrimitiveBaseShape shape, + LLVector3 position, LLQuaternion rotation, uint flags) { - this.m_regionHandle = regionHandle; - this.m_parentGroup = parent; + m_regionHandle = regionHandle; + m_parentGroup = parent; - this.CreationDate = creationDate; - this.OwnerID = ownerID; - this.CreatorID = creatorID; - this.LastOwnerID = lastOwnerID; - this.UUID = LLUUID.Random(); - this.LocalID = (uint)(localID); - this.Shape = shape; + CreationDate = creationDate; + OwnerID = ownerID; + CreatorID = creatorID; + LastOwnerID = lastOwnerID; + UUID = LLUUID.Random(); + LocalID = (uint) (localID); + Shape = shape; - this.OffsetPosition = position; - this.RotationOffset = rotation; - this.ObjectFlags = flags; + OffsetPosition = position; + RotationOffset = rotation; + ObjectFlags = flags; } + #endregion /// @@ -309,8 +331,8 @@ namespace OpenSim.Region.Environment.Scenes /// public static SceneObjectPart FromXml(XmlReader xmlReader) { - XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); - return (SceneObjectPart)serializer.Deserialize(xmlReader); + XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); + return (SceneObjectPart) serializer.Deserialize(xmlReader); } /// @@ -319,7 +341,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void ToXml(XmlWriter xmlWriter) { - XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); + XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); serializer.Serialize(xmlWriter, this); } @@ -329,7 +351,6 @@ namespace OpenSim.Region.Environment.Scenes public void SetParent(SceneObjectGroup parent) { m_parentGroup = parent; - } public LLUUID GetRootPartUUID() @@ -342,34 +363,38 @@ namespace OpenSim.Region.Environment.Scenes } #region Copying + /// /// /// /// public SceneObjectPart Copy(uint localID) { - SceneObjectPart dupe = (SceneObjectPart)this.MemberwiseClone(); + SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone(); dupe.m_shape = m_shape.Copy(); dupe.m_regionHandle = m_regionHandle; dupe.UUID = LLUUID.Random(); dupe.LocalID = localID; dupe.GroupPosition = new LLVector3(GroupPosition.X, GroupPosition.Y, GroupPosition.Z); dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z); - dupe.RotationOffset = new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W); + dupe.RotationOffset = + new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W); dupe.Velocity = new LLVector3(0, 0, 0); dupe.Acceleration = new LLVector3(0, 0, 0); dupe.AngularVelocity = new LLVector3(0, 0, 0); - dupe.ObjectFlags = this.ObjectFlags; + dupe.ObjectFlags = ObjectFlags; - byte[] extraP = new byte[this.Shape.ExtraParams.Length]; - Array.Copy(this.Shape.ExtraParams, extraP, extraP.Length); + byte[] extraP = new byte[Shape.ExtraParams.Length]; + Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; return dupe; } + #endregion #region Update Scheduling + /// /// /// @@ -387,7 +412,7 @@ namespace OpenSim.Region.Environment.Scenes { m_parentGroup.HasChanged = true; } - this.TimeStampFull =(uint) Util.UnixTimeSinceEpoch(); + TimeStampFull = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 2; } @@ -402,7 +427,7 @@ namespace OpenSim.Region.Environment.Scenes { m_parentGroup.HasChanged = true; } - this.TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); + TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 1; } } @@ -426,56 +451,60 @@ namespace OpenSim.Region.Environment.Scenes } } } + #endregion #region Shape + /// /// /// /// public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) { - this.m_shape.PathBegin = shapeBlock.PathBegin; - this.m_shape.PathEnd = shapeBlock.PathEnd; - this.m_shape.PathScaleX = shapeBlock.PathScaleX; - this.m_shape.PathScaleY = shapeBlock.PathScaleY; - this.m_shape.PathShearX = shapeBlock.PathShearX; - this.m_shape.PathShearY = shapeBlock.PathShearY; - this.m_shape.PathSkew = shapeBlock.PathSkew; - this.m_shape.ProfileBegin = shapeBlock.ProfileBegin; - this.m_shape.ProfileEnd = shapeBlock.ProfileEnd; - this.m_shape.PathCurve = shapeBlock.PathCurve; - this.m_shape.ProfileCurve = shapeBlock.ProfileCurve; - this.m_shape.ProfileHollow = shapeBlock.ProfileHollow; - this.m_shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; - this.m_shape.PathRevolutions = shapeBlock.PathRevolutions; - this.m_shape.PathTaperX = shapeBlock.PathTaperX; - this.m_shape.PathTaperY = shapeBlock.PathTaperY; - this.m_shape.PathTwist = shapeBlock.PathTwist; - this.m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; + m_shape.PathBegin = shapeBlock.PathBegin; + m_shape.PathEnd = shapeBlock.PathEnd; + m_shape.PathScaleX = shapeBlock.PathScaleX; + m_shape.PathScaleY = shapeBlock.PathScaleY; + m_shape.PathShearX = shapeBlock.PathShearX; + m_shape.PathShearY = shapeBlock.PathShearY; + m_shape.PathSkew = shapeBlock.PathSkew; + m_shape.ProfileBegin = shapeBlock.ProfileBegin; + m_shape.ProfileEnd = shapeBlock.ProfileEnd; + m_shape.PathCurve = shapeBlock.PathCurve; + m_shape.ProfileCurve = shapeBlock.ProfileCurve; + m_shape.ProfileHollow = shapeBlock.ProfileHollow; + m_shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; + m_shape.PathRevolutions = shapeBlock.PathRevolutions; + m_shape.PathTaperX = shapeBlock.PathTaperX; + m_shape.PathTaperY = shapeBlock.PathTaperY; + m_shape.PathTwist = shapeBlock.PathTwist; + m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; ScheduleFullUpdate(); } + #endregion #region Inventory + public void AddInventoryItem(TaskInventoryItem item) { item.parent_id = m_folderID; item.creation_date = 1000; - item.ParentPartID = this.UUID; - this.TaskInventory.Add(item.item_id, item); - this.m_inventorySerial++; + item.ParentPartID = UUID; + TaskInventory.Add(item.item_id, item); + m_inventorySerial++; } public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID) { - if (localID == this.LocalID) + if (localID == LocalID) { - if (this.TaskInventory.ContainsKey(itemID)) + if (TaskInventory.ContainsKey(itemID)) { string type = TaskInventory[itemID].inv_type; - this.TaskInventory.Remove(itemID); - this.m_inventorySerial++; + TaskInventory.Remove(itemID); + m_inventorySerial++; if (type == "lsltext") { return 10; @@ -496,16 +525,17 @@ namespace OpenSim.Region.Environment.Scenes /// public bool GetInventoryFileName(IClientAPI client, uint localID) { - if (localID == this.m_localID) + if (localID == m_localID) { - if (this.m_inventorySerial > 0) + if (m_inventorySerial > 0) { - client.SendTaskInventory(this.m_uuid, (short)m_inventorySerial, Helpers.StringToField(m_inventoryFileName)); + client.SendTaskInventory(m_uuid, (short) m_inventorySerial, + Helpers.StringToField(m_inventoryFileName)); return true; } else { - client.SendTaskInventory(this.m_uuid, 0, new byte[0]); + client.SendTaskInventory(m_uuid, 0, new byte[0]); return false; } } @@ -515,8 +545,8 @@ namespace OpenSim.Region.Environment.Scenes public string RequestInventoryFile(IXfer xferManager) { byte[] fileData = new byte[0]; - InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID); - foreach (TaskInventoryItem item in this.TaskInventory.Values) + InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID); + foreach (TaskInventoryItem item in TaskInventory.Values) { invString.AddItemStart(); invString.AddNameValueLine("item_id", item.item_id.ToStringHyphenated()); @@ -550,49 +580,56 @@ namespace OpenSim.Region.Environment.Scenes } return ""; } + #endregion #region ExtraParams + public void UpdateExtraParam(ushort type, bool inUse, byte[] data) { - this.m_shape.ExtraParams = new byte[data.Length + 7]; + m_shape.ExtraParams = new byte[data.Length + 7]; int i = 0; - uint length = (uint)data.Length; - this.m_shape.ExtraParams[i++] = 1; - this.m_shape.ExtraParams[i++] = (byte)(type % 256); - this.m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256); + uint length = (uint) data.Length; + m_shape.ExtraParams[i++] = 1; + m_shape.ExtraParams[i++] = (byte) (type%256); + m_shape.ExtraParams[i++] = (byte) ((type >> 8)%256); - this.m_shape.ExtraParams[i++] = (byte)(length % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256); - Array.Copy(data, 0, this.m_shape.ExtraParams, i, data.Length); - - this.ScheduleFullUpdate(); + m_shape.ExtraParams[i++] = (byte) (length%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 8)%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 16)%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 24)%256); + Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length); + ScheduleFullUpdate(); } + #endregion #region Texture + /// /// /// /// public void UpdateTextureEntry(byte[] textureEntry) { - this.m_shape.TextureEntry = textureEntry; + m_shape.TextureEntry = textureEntry; ScheduleFullUpdate(); } + #endregion #region ParticleSystem - public void AddNewParticleSystem(libsecondlife.Primitive.ParticleSystem pSystem) + + public void AddNewParticleSystem(Primitive.ParticleSystem pSystem) { - this.m_particleSystem = pSystem.GetBytes(); + m_particleSystem = pSystem.GetBytes(); } + #endregion #region Position + /// /// /// @@ -600,46 +637,52 @@ namespace OpenSim.Region.Environment.Scenes public void UpdateOffSet(LLVector3 pos) { LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - this.OffsetPosition = newPos; + OffsetPosition = newPos; ScheduleTerseUpdate(); } - + public void UpdateGroupPosition(LLVector3 pos) { LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - this.GroupPosition = newPos; + GroupPosition = newPos; ScheduleTerseUpdate(); } + #endregion #region rotation + public void UpdateRotation(LLQuaternion rot) { - this.RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W); + RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W); ScheduleTerseUpdate(); } + #endregion #region Resizing/Scale + /// /// /// /// public void Resize(LLVector3 scale) { - this.m_shape.Scale = scale; + m_shape.Scale = scale; ScheduleFullUpdate(); } + #endregion #region Client Update Methods + public void AddFullUpdateToAllAvatars() { - List avatars = this.m_parentGroup.RequestSceneAvatars(); + List avatars = m_parentGroup.RequestSceneAvatars(); for (int i = 0; i < avatars.Count; i++) { avatars[i].AddFullPart(this); - // avatars[i].QueuePartForUpdate(this); + // avatars[i].QueuePartForUpdate(this); } } @@ -654,7 +697,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendFullUpdateToAllClients() { - List avatars = this.m_parentGroup.RequestSceneAvatars(); + List avatars = m_parentGroup.RequestSceneAvatars(); for (int i = 0; i < avatars.Count; i++) { m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this); @@ -691,26 +734,26 @@ namespace OpenSim.Region.Environment.Scenes LLQuaternion lRot; lRot = RotationOffset; - remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, this.ObjectFlags, m_uuid, OwnerID, - m_text, ParentID, this.m_particleSystem, lRot); + remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, ObjectFlags, m_uuid, + OwnerID, + m_text, ParentID, m_particleSystem, lRot); } /// Terse updates - public void AddTerseUpdateToAllAvatars() { - List avatars = this.m_parentGroup.RequestSceneAvatars(); - for (int i = 0; i < avatars.Count; i++) - { - avatars[i].AddTersePart(this); + List avatars = m_parentGroup.RequestSceneAvatars(); + for (int i = 0; i < avatars.Count; i++) + { + avatars[i].AddTersePart(this); // avatars[i].QueuePartForUpdate(this); - } + } } public void AddTerseUpdateToAvatar(ScenePresence presence) { presence.AddTersePart(this); - // presence.QueuePartForUpdate(this); + // presence.QueuePartForUpdate(this); } /// @@ -718,7 +761,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendTerseUpdateToAllClients() { - List avatars = this.m_parentGroup.RequestSceneAvatars(); + List avatars = m_parentGroup.RequestSceneAvatars(); for (int i = 0; i < avatars.Count; i++) { m_parentGroup.SendPartTerseUpdate(avatars[i].ControllingClient, this); @@ -741,8 +784,8 @@ namespace OpenSim.Region.Environment.Scenes public void SendTerseUpdateToClient(IClientAPI remoteClient) { LLVector3 lPos; - lPos = this.OffsetPosition; - LLQuaternion mRot = this.RotationOffset; + lPos = OffsetPosition; + LLQuaternion mRot = RotationOffset; remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); } @@ -753,9 +796,10 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) { - LLQuaternion mRot = this.RotationOffset; + LLQuaternion mRot = RotationOffset; remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); } + #endregion public virtual void UpdateMovement() @@ -778,11 +822,11 @@ namespace OpenSim.Region.Environment.Scenes public InventoryStringBuilder(LLUUID folderID, LLUUID parentID) { BuildString += "\tinv_object\t0\n\t{\n"; - this.AddNameValueLine("obj_id", folderID.ToStringHyphenated()); - this.AddNameValueLine("parent_id", parentID.ToStringHyphenated()); - this.AddNameValueLine("type", "category"); - this.AddNameValueLine("name", "Contents"); - this.AddSectionEnd(); + AddNameValueLine("obj_id", folderID.ToStringHyphenated()); + AddNameValueLine("parent_id", parentID.ToStringHyphenated()); + AddNameValueLine("type", "category"); + AddNameValueLine("name", "Contents"); + AddSectionEnd(); } public void AddItemStart() @@ -831,7 +875,7 @@ namespace OpenSim.Region.Environment.Scenes "", "", "", - "", + "", "", "lsltext", "" @@ -865,5 +909,4 @@ namespace OpenSim.Region.Environment.Scenes } } } -} - +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs index 8c8cebe..e8f29c8 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Environment.Scenes { public class AvatarAnimations { - public Dictionary AnimsLLUUID = new Dictionary(); public Dictionary AnimsNames = new Dictionary(); @@ -52,12 +51,10 @@ namespace OpenSim.Region.Environment.Scenes doc.Load(reader); foreach (XmlNode nod in doc.DocumentElement.ChildNodes) { - if (nod.Attributes["name"] != null) { AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText); } - } reader.Close(); @@ -71,4 +68,4 @@ namespace OpenSim.Region.Environment.Scenes } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs index efe613f..605e8a1 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Body.cs @@ -37,7 +37,6 @@ namespace OpenSim.Region.Environment.Scenes { public Avatar() { - } public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) @@ -61,7 +60,6 @@ namespace OpenSim.Region.Environment.Scenes { public ChildAgent() { - } public void processMovement(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) @@ -81,5 +79,4 @@ namespace OpenSim.Region.Environment.Scenes } } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 6d51fbc..64c6eaa 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -27,7 +27,6 @@ */ using System; using System.Collections.Generic; -using System.IO; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; @@ -72,7 +71,8 @@ namespace OpenSim.Region.Environment.Scenes private IScenePresenceBody m_body; private Vector3[] Dir_Vectors = new Vector3[6]; - private libsecondlife.LLVector3 lastPhysPos = new libsecondlife.LLVector3(); + private LLVector3 lastPhysPos = new LLVector3(); + private enum Dir_ControlFlags { DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS, @@ -82,48 +82,39 @@ namespace OpenSim.Region.Environment.Scenes DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS, DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG } + /// /// Position at which a significant movement was made /// private LLVector3 posLastSignificantMove = new LLVector3(); public delegate void SignificantClientMovement(IClientAPI remote_client); + public event SignificantClientMovement OnSignificantClientMovement; //public List InterestList = new List(); - // private Queue m_fullGroupUpdates = new Queue(); - // private Queue m_terseGroupUpdates = new Queue(); + // private Queue m_fullGroupUpdates = new Queue(); + // private Queue m_terseGroupUpdates = new Queue(); private Queue m_fullPartUpdates = new Queue(); private Queue m_tersePartUpdates = new Queue(); #region Properties + /// /// /// public PhysicsActor PhysActor { - set - { - this._physActor = value; - } - get - { - return _physActor; - } + set { _physActor = value; } + get { return _physActor; } } public bool Updated { - set - { - this.updateflag = value; - } - get - { - return this.updateflag; - } + set { updateflag = value; } + get { return updateflag; } } public ulong RegionHandle @@ -132,12 +123,14 @@ namespace OpenSim.Region.Environment.Scenes } private string m_firstname; + public string Firstname { get { return m_firstname; } } private string m_lastname; + public string Lastname { get { return m_lastname; } @@ -146,6 +139,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Constructor(s) + /// /// /// @@ -155,19 +149,18 @@ namespace OpenSim.Region.Environment.Scenes /// public ScenePresence(IClientAPI theClient, Scene world, RegionInfo reginfo) { - m_scene = world; - this.m_uuid = theClient.AgentId; + m_uuid = theClient.AgentId; m_regionInfo = reginfo; m_regionHandle = reginfo.RegionHandle; MainLog.Instance.Verbose("Avatar.cs "); ControllingClient = theClient; - this.m_firstname = ControllingClient.FirstName; - this.m_lastname = ControllingClient.LastName; + m_firstname = ControllingClient.FirstName; + m_lastname = ControllingClient.LastName; m_localId = m_scene.NextLocalId; AbsolutePosition = ControllingClient.StartPos; - + visualParams = new byte[218]; for (int i = 0; i < 218; i++) { @@ -175,37 +168,37 @@ namespace OpenSim.Region.Environment.Scenes } Wearables = AvatarWearable.DefaultWearables; - Animations = new ScenePresence.AvatarAnimations(); + Animations = new AvatarAnimations(); Animations.LoadAnims(); //register for events - ControllingClient.OnRequestWearables += this.SendOurAppearance; - ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance); - ControllingClient.OnCompleteMovementToRegion += this.CompleteMovement; - ControllingClient.OnCompleteMovementToRegion += this.SendInitialData; - ControllingClient.OnAgentUpdate += this.HandleAgentUpdate; + ControllingClient.OnRequestWearables += SendOurAppearance; + ControllingClient.OnSetAppearance += new SetAppearance(SetAppearance); + ControllingClient.OnCompleteMovementToRegion += CompleteMovement; + ControllingClient.OnCompleteMovementToRegion += SendInitialData; + ControllingClient.OnAgentUpdate += HandleAgentUpdate; // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); - Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD + Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK - Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT + Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT - Dir_Vectors[4] = new Vector3(0, 0, 1); //UP + Dir_Vectors[4] = new Vector3(0, 0, 1); //UP Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN - this.m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length); + m_textureEntry = new LLObject.TextureEntry(DefaultTexture, 0, DefaultTexture.Length); //temporary until we move some code into the body classes - this.m_body = new ChildAgent(); + m_body = new ChildAgent(); if (newAvatar) { //do we need to use newAvatar? not sure so have added this to kill the compile warning } - } + #endregion public void AddTersePart(SceneObjectPart part) @@ -228,10 +221,10 @@ namespace OpenSim.Region.Environment.Scenes while (terse) { SceneObjectPart part = m_tersePartUpdates.Dequeue(); - part.SendTerseUpdate(this.ControllingClient); + part.SendTerseUpdate(ControllingClient); terseCount++; - if ((m_tersePartUpdates.Count < 1) |(terseCount > 30)) + if ((m_tersePartUpdates.Count < 1) | (terseCount > 30)) { terse = false; } @@ -245,31 +238,30 @@ namespace OpenSim.Region.Environment.Scenes while (full) { SceneObjectPart part = m_fullPartUpdates.Dequeue(); - part.SendFullUpdate(this.ControllingClient); + part.SendFullUpdate(ControllingClient); fullCount++; if ((m_fullPartUpdates.Count < 1) | (fullCount > 40)) { full = false; } - } } } #region Status Methods + /// /// Not Used, most likely can be deleted /// /// public void ChildStatusChange(bool status) { - this.childAgent = status; + childAgent = status; - if (this.childAgent == true) + if (childAgent == true) { - this.Velocity = new LLVector3(0, 0, 0); - this.AbsolutePosition = new LLVector3(128, 128, 70); - + Velocity = new LLVector3(0, 0, 0); + AbsolutePosition = new LLVector3(128, 128, 70); } } @@ -280,17 +272,17 @@ namespace OpenSim.Region.Environment.Scenes public void MakeAvatar(LLVector3 pos, bool isFlying) { //this.childAvatar = false; - this.AbsolutePosition = pos; - this._physActor.Flying = isFlying; - this.newAvatar = true; - this.childAgent = false; - this.m_scene.SendAllSceneObjectsToClient(this); + AbsolutePosition = pos; + _physActor.Flying = isFlying; + newAvatar = true; + childAgent = false; + m_scene.SendAllSceneObjectsToClient(this); } protected void MakeChildAgent() { - this.Velocity = new LLVector3(0, 0, 0); - this.childAgent = true; + Velocity = new LLVector3(0, 0, 0); + childAgent = true; //this.Pos = new LLVector3(128, 128, 70); } @@ -300,8 +292,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void Teleport(LLVector3 pos) { - this.AbsolutePosition = pos; - this.SendTerseUpdateToALLClients(); + AbsolutePosition = pos; + SendTerseUpdateToALLClients(); } /// @@ -309,11 +301,12 @@ namespace OpenSim.Region.Environment.Scenes /// public void StopMovement() { - } + #endregion #region Event Handlers + /// /// /// @@ -322,14 +315,14 @@ namespace OpenSim.Region.Environment.Scenes public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) { LLObject.TextureEntry textureEnt = new LLObject.TextureEntry(texture, 0, texture.Length); - this.m_textureEntry = textureEnt; + m_textureEntry = textureEnt; for (int i = 0; i < visualParam.Length; i++) { - this.visualParams[i] = visualParam[i].ParamValue; + visualParams[i] = visualParam[i].ParamValue; } - this.SendArrearanceToAllOtherAgents(); + SendArrearanceToAllOtherAgents(); } /// @@ -337,16 +330,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void CompleteMovement() { - LLVector3 look = this.Velocity; + LLVector3 look = Velocity; if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) { look = new LLVector3(0.99f, 0.042f, 0); } - this.ControllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); - if (this.childAgent) + ControllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); + if (childAgent) { - this.childAgent = false; - + childAgent = false; + //this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient); } } @@ -363,47 +356,45 @@ namespace OpenSim.Region.Environment.Scenes bool DCFlagKeyPressed = false; Vector3 agent_control_v3 = new Vector3(0, 0, 0); Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); - bool oldflying = this.PhysActor.Flying; - this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); - if (this.PhysActor.Flying != oldflying) + bool oldflying = PhysActor.Flying; + PhysActor.Flying = ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); + if (PhysActor.Flying != oldflying) { update_movementflag = true; } - if (q != this.bodyRot) + if (q != bodyRot) { - this.bodyRot = q; + bodyRot = q; update_rotation = true; - } - foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) + } + foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags))) { - if ((flags & (uint)DCF) != 0) + if ((flags & (uint) DCF) != 0) { DCFlagKeyPressed = true; agent_control_v3 += Dir_Vectors[i]; - if ((movementflag & (uint)DCF) == 0) + if ((movementflag & (uint) DCF) == 0) { - movementflag += (byte)(uint)DCF; + movementflag += (byte) (uint) DCF; update_movementflag = true; } } else { - if ((movementflag & (uint)DCF) != 0) + if ((movementflag & (uint) DCF) != 0) { - movementflag -= (byte)(uint)DCF; + movementflag -= (byte) (uint) DCF; update_movementflag = true; - } } i++; } if ((update_movementflag) || (update_rotation && DCFlagKeyPressed)) { - this.AddNewMovement(agent_control_v3, q); + AddNewMovement(agent_control_v3, q); } UpdateMovementAnimations(update_movementflag); - } protected void UpdateMovementAnimations(bool update_movementflag) @@ -412,49 +403,48 @@ namespace OpenSim.Region.Environment.Scenes { if (movementflag != 0) { - if (this._physActor.Flying) + if (_physActor.Flying) { - this.SendAnimPack(Animations.AnimsLLUUID["FLY"], 1); + SendAnimPack(Animations.AnimsLLUUID["FLY"], 1); } else { - this.SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); + SendAnimPack(Animations.AnimsLLUUID["WALK"], 1); } } else { - this.SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); + SendAnimPack(Animations.AnimsLLUUID["STAND"], 1); } } - } protected void AddNewMovement(Vector3 vec, Quaternion rotation) { NewForce newVelocity = new NewForce(); - Vector3 direc = rotation * vec; + Vector3 direc = rotation*vec; direc.Normalize(); - direc = direc * ((0.03f) * 128f); - if (this._physActor.Flying) + direc = direc*((0.03f)*128f); + if (_physActor.Flying) direc *= 4; newVelocity.X = direc.x; newVelocity.Y = direc.y; newVelocity.Z = direc.z; - this.forcesList.Add(newVelocity); + forcesList.Add(newVelocity); } #endregion #region Overridden Methods + /// /// /// public override void LandRenegerated() { - } /// @@ -462,63 +452,65 @@ namespace OpenSim.Region.Environment.Scenes /// public override void Update() { - this.SendPrimUpdates(); + SendPrimUpdates(); - if (this.newCoarseLocations) { - this.SendCoarseLocations(); - this.newCoarseLocations = false; + if (newCoarseLocations) + { + SendCoarseLocations(); + newCoarseLocations = false; } - if (this.childAgent == false) + if (childAgent == false) { - /// check for user movement 'forces' (ie commands to move) - if (this.newForce) + if (newForce) { - this.SendTerseUpdateToALLClients(); + SendTerseUpdateToALLClients(); _updateCount = 0; } - /// check for scripted movement (?) + /// check for scripted movement (?) else if (movementflag != 0) { _updateCount++; if (_updateCount > 3) { - this.SendTerseUpdateToALLClients(); + SendTerseUpdateToALLClients(); _updateCount = 0; } } - /// check for physics-related movement - else if (this.lastPhysPos.GetDistanceTo(this.AbsolutePosition) > 0.02 ) + /// check for physics-related movement + else if (lastPhysPos.GetDistanceTo(AbsolutePosition) > 0.02) { - this.SendTerseUpdateToALLClients(); + SendTerseUpdateToALLClients(); _updateCount = 0; - this.lastPhysPos = this.AbsolutePosition; + lastPhysPos = AbsolutePosition; } - this.CheckForSignificantMovement(); - this.CheckForBorderCrossing(); - + CheckForSignificantMovement(); + CheckForBorderCrossing(); } } + #endregion #region Update Client(s) + /// /// /// /// public void SendTerseUpdateToClient(IClientAPI RemoteClient) { - LLVector3 pos = this.AbsolutePosition; - LLVector3 vel = this.Velocity; + LLVector3 pos = AbsolutePosition; + LLVector3 vel = Velocity; LLQuaternion rot; - rot.X = this.bodyRot.x; - rot.Y = this.bodyRot.y; - rot.Z = this.bodyRot.z; - rot.W = this.bodyRot.w; - RemoteClient.SendAvatarTerseUpdate(this.m_regionHandle, 64096, this.LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z), rot); + rot.X = bodyRot.x; + rot.Y = bodyRot.y; + rot.Z = bodyRot.z; + rot.W = bodyRot.w; + RemoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z), + new LLVector3(vel.X, vel.Y, vel.Z), rot); } /// @@ -526,42 +518,44 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendTerseUpdateToALLClients() { - List avatars = this.m_scene.RequestAvatarList(); + List avatars = m_scene.RequestAvatarList(); for (int i = 0; i < avatars.Count; i++) { - this.SendTerseUpdateToClient(avatars[i].ControllingClient); + SendTerseUpdateToClient(avatars[i].ControllingClient); } } - public void SendCoarseLocations() - { - List CoarseLocations = new List(); - List avatars = this.m_scene.RequestAvatarList(); + public void SendCoarseLocations() + { + List CoarseLocations = new List(); + List avatars = m_scene.RequestAvatarList(); for (int i = 0; i < avatars.Count; i++) { - if (avatars[i] != this && (!avatars[i].childAgent) ) { - CoarseLocations.Add(avatars[i].AbsolutePosition); - } + if (avatars[i] != this && (!avatars[i].childAgent)) + { + CoarseLocations.Add(avatars[i].AbsolutePosition); + } } - this.ControllingClient.SendCoarseLocationUpdate(CoarseLocations); - } + ControllingClient.SendCoarseLocationUpdate(CoarseLocations); + } - public void CoarseLocationChange(ScenePresence avatar) - { - newCoarseLocations = true; - } + public void CoarseLocationChange(ScenePresence avatar) + { + newCoarseLocations = true; + } - private void NotifyMyCoarseLocationChange() - { - List avatars = this.m_scene.RequestAvatarList(); - for (int i = 0; i < avatars.Count; i++) { - if (avatars[i] != this) { - avatars[i].CoarseLocationChange(this); - } + private void NotifyMyCoarseLocationChange() + { + List avatars = m_scene.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + if (avatars[i] != this) + { + avatars[i].CoarseLocationChange(this); + } } - - } + } /// @@ -570,16 +564,17 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) { - remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.m_firstname, this.m_lastname, this.m_uuid, this.LocalId, this.AbsolutePosition, this.m_textureEntry.ToBytes()); + remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, + LocalId, AbsolutePosition, m_textureEntry.ToBytes()); } public void SendFullUpdateToALLClients() { - List avatars = this.m_scene.RequestAvatarList(); - foreach (ScenePresence avatar in this.m_scene.RequestAvatarList()) + List avatars = m_scene.RequestAvatarList(); + foreach (ScenePresence avatar in m_scene.RequestAvatarList()) { - this.SendFullUpdateToOtherClient(avatar); - if (avatar.LocalId != this.LocalId) + SendFullUpdateToOtherClient(avatar); + if (avatar.LocalId != LocalId) { if (!avatar.childAgent) { @@ -595,15 +590,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendInitialData() { - this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.m_firstname, this.m_lastname, this.m_uuid, this.LocalId, this.AbsolutePosition, this.m_textureEntry.ToBytes()); - if (!this.childAgent) + ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId, + AbsolutePosition, m_textureEntry.ToBytes()); + if (!childAgent) { - this.m_scene.InformClientOfNeighbours(this.ControllingClient); - this.newAvatar = false; + m_scene.InformClientOfNeighbours(ControllingClient); + newAvatar = false; } - this.SendFullUpdateToALLClients(); - this.SendArrearanceToAllOtherAgents(); + SendFullUpdateToALLClients(); + SendArrearanceToAllOtherAgents(); } /// @@ -612,13 +608,13 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendOurAppearance(IClientAPI OurClient) { - this.ControllingClient.SendWearables(this.Wearables); + ControllingClient.SendWearables(Wearables); //this.SendFullUpdateToALLClients(); //this.SendArrearanceToAllOtherAgents(); - this.m_scene.SendAllSceneObjectsToClient(this); - this.ControllingClient.SendViewerTime(this.m_scene.TimePhase); + m_scene.SendAllSceneObjectsToClient(this); + ControllingClient.SendViewerTime(m_scene.TimePhase); //Please don't remove the following code (at least not yet), just leave it commented out //gives the user god powers, should help with debuging things in the future @@ -636,10 +632,10 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendArrearanceToAllOtherAgents() { - List avatars = this.m_scene.RequestAvatarList(); - foreach (ScenePresence avatar in this.m_scene.RequestAvatarList()) + List avatars = m_scene.RequestAvatarList(); + foreach (ScenePresence avatar in m_scene.RequestAvatarList()) { - this.SendAppearanceToOtherAgent(avatar); + SendAppearanceToOtherAgent(avatar); } } @@ -649,7 +645,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) { - avatarInfo.ControllingClient.SendAppearance(this.ControllingClient.AgentId, this.visualParams, this.m_textureEntry.ToBytes()); + avatarInfo.ControllingClient.SendAppearance(ControllingClient.AgentId, visualParams, + m_textureEntry.ToBytes()); } /// @@ -659,12 +656,12 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAnimPack(LLUUID animID, int seq) { - this.current_anim = animID; - this.anim_seq = seq; - List avatars = this.m_scene.RequestAvatarList(); + current_anim = animID; + anim_seq = seq; + List avatars = m_scene.RequestAvatarList(); for (int i = 0; i < avatars.Count; i++) { - avatars[i].ControllingClient.SendAnimation(animID, seq, this.ControllingClient.AgentId); + avatars[i].ControllingClient.SendAnimation(animID, seq, ControllingClient.AgentId); } } @@ -673,48 +670,51 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAnimPack() { - this.SendAnimPack(this.current_anim, this.anim_seq); + SendAnimPack(current_anim, anim_seq); } + #endregion #region Significant Movement Method protected void CheckForSignificantMovement() { - if (libsecondlife.Helpers.VecDist(this.AbsolutePosition, this.posLastSignificantMove) > 2.0) + if (Helpers.VecDist(AbsolutePosition, posLastSignificantMove) > 2.0) { - this.posLastSignificantMove = this.AbsolutePosition; + posLastSignificantMove = AbsolutePosition; if (OnSignificantClientMovement != null) { - OnSignificantClientMovement(this.ControllingClient); + OnSignificantClientMovement(ControllingClient); NotifyMyCoarseLocationChange(); } } } + #endregion #region Border Crossing Methods + /// /// /// protected void CheckForBorderCrossing() { - LLVector3 pos2 = this.AbsolutePosition; - LLVector3 vel = this.Velocity; + LLVector3 pos2 = AbsolutePosition; + LLVector3 vel = Velocity; float timeStep = 0.1f; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - pos2.Z = pos2.Z + (vel.Z * timeStep); + pos2.X = pos2.X + (vel.X*timeStep); + pos2.Y = pos2.Y + (vel.Y*timeStep); + pos2.Z = pos2.Z + (vel.Z*timeStep); if ((pos2.X < 0) || (pos2.X > 256)) { - this.CrossToNewRegion(); + CrossToNewRegion(); } if ((pos2.Y < 0) || (pos2.Y > 256)) { - this.CrossToNewRegion(); + CrossToNewRegion(); } } @@ -723,10 +723,10 @@ namespace OpenSim.Region.Environment.Scenes /// protected void CrossToNewRegion() { - LLVector3 pos = this.AbsolutePosition; + LLVector3 pos = AbsolutePosition; LLVector3 newpos = new LLVector3(pos.X, pos.Y, pos.Z); - uint neighbourx = this.m_regionInfo.RegionLocX; - uint neighboury = this.m_regionInfo.RegionLocY; + uint neighbourx = m_regionInfo.RegionLocX; + uint neighboury = m_regionInfo.RegionLocY; if (pos.X < 1.7F) { @@ -749,24 +749,28 @@ namespace OpenSim.Region.Environment.Scenes newpos.Y = 0.1F; } - LLVector3 vel = this.m_velocity; - ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); - RegionInfo neighbourRegion = this.m_scene.RequestNeighbouringRegionInfo(neighbourHandle); + LLVector3 vel = m_velocity; + ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256)); + RegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); if (neighbourRegion != null) { - bool res = this.m_scene.InformNeighbourOfCrossing(neighbourHandle, this.ControllingClient.AgentId, newpos, this._physActor.Flying); + bool res = + m_scene.InformNeighbourOfCrossing(neighbourHandle, ControllingClient.AgentId, newpos, + _physActor.Flying); if (res) { //TODO: following line is hard coded to port 9000, really need to change this as soon as possible - AgentCircuitData circuitdata = this.ControllingClient.RequestClientInfo(); - string capsPath = Util.GetCapsURL(this.ControllingClient.AgentId); - this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, capsPath); - this.MakeChildAgent(); - this.m_scene.SendKillObject(this.m_localId); - this.NotifyMyCoarseLocationChange(); + AgentCircuitData circuitdata = ControllingClient.RequestClientInfo(); + string capsPath = Util.GetCapsURL(ControllingClient.AgentId); + ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, + capsPath); + MakeChildAgent(); + m_scene.SendKillObject(m_localId); + NotifyMyCoarseLocationChange(); } } } + #endregion /// @@ -774,7 +778,6 @@ namespace OpenSim.Region.Environment.Scenes /// public static void LoadAnims() { - } /// @@ -783,21 +786,21 @@ namespace OpenSim.Region.Environment.Scenes public override void UpdateMovement() { newForce = false; - lock (this.forcesList) + lock (forcesList) { - if (this.forcesList.Count > 0) + if (forcesList.Count > 0) { - for (int i = 0; i < this.forcesList.Count; i++) + for (int i = 0; i < forcesList.Count; i++) { - NewForce force = this.forcesList[i]; + NewForce force = forcesList[i]; - this.updateflag = true; - this.Velocity = new LLVector3(force.X, force.Y, force.Z); - this.newForce = true; + updateflag = true; + Velocity = new LLVector3(force.X, force.Y, force.Z); + newForce = true; } - for (int i = 0; i < this.forcesList.Count; i++) + for (int i = 0; i < forcesList.Count; i++) { - this.forcesList.RemoveAt(0); + forcesList.RemoveAt(0); } } } @@ -824,7 +827,6 @@ namespace OpenSim.Region.Environment.Scenes public NewForce() { - } } @@ -833,5 +835,4 @@ namespace OpenSim.Region.Environment.Scenes throw new Exception("The method or operation is not implemented."); } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs index 7cf9cb7..dbd43be 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs @@ -1,20 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - +using Axiom.Math; +using libsecondlife; + namespace OpenSim.Region.Environment.Scenes.Scripting { public interface IScriptHost { - string Name { get; set;} - string SitName{ get; set;} - string TouchName { get; set;} + string Name { get; set; } + string SitName { get; set; } + string TouchName { get; set; } string Description { get; set; } LLUUID UUID { get; } - LLUUID ObjectOwner { get;} + LLUUID ObjectOwner { get; } LLUUID ObjectCreator { get; } LLVector3 AbsolutePosition { get; } - void SetText(string text, Axiom.Math.Vector3 color, double alpha); + void SetText(string text, Vector3 color, double alpha); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs index 875e4cb..6876cfb 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs @@ -1,14 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - +using System; +using Axiom.Math; +using libsecondlife; + namespace OpenSim.Region.Environment.Scenes.Scripting { public class NullScriptHost : IScriptHost - { - - LLVector3 m_pos = new LLVector3( 128, 128, 30 ); + { + private LLVector3 m_pos = new LLVector3(128, 128, 30); + public string Name { get { return "Object"; } @@ -39,18 +38,23 @@ namespace OpenSim.Region.Environment.Scenes.Scripting } public LLUUID ObjectOwner - { get { return LLUUID.Zero; } } + { + get { return LLUUID.Zero; } + } - public LLUUID ObjectCreator { get { return LLUUID.Zero; } } + public LLUUID ObjectCreator + { + get { return LLUUID.Zero; } + } public LLVector3 AbsolutePosition { get { return m_pos; } } - public void SetText(string text, Axiom.Math.Vector3 color, double alpha) + public void SetText(string text, Vector3 color, double alpha) { Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs index 5e8ff87..06bedaf 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs @@ -26,18 +26,16 @@ * */ /* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes.Scripting; - -//TODO: WHERE TO PLACE THIS? +using OpenSim.Framework.Console; + +//TODO: WHERE TO PLACE THIS? + namespace OpenSim.Region.Environment.Scenes.Scripting { public interface ScriptEngineInterface { - void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger); + void InitializeEngine(Scene Sceneworld, LogBase logger); void Shutdown(); // void StartScript(string ScriptID, IScriptHost ObjectID); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs index 83bd0ab..5355388 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs @@ -26,18 +26,18 @@ * */ /* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Reflection; - +using System; +using System.IO; +using System.Reflection; +using OpenSim.Framework.Console; + namespace OpenSim.Region.Environment.Scenes.Scripting { public class ScriptEngineLoader { - private OpenSim.Framework.Console.LogBase m_log; - public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger) + private LogBase m_log; + + public ScriptEngineLoader(LogBase logger) { m_log = logger; } @@ -47,12 +47,16 @@ namespace OpenSim.Region.Environment.Scenes.Scripting ScriptEngineInterface ret = null; try { - ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), - "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); + ret = + LoadAndInitAssembly( + Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), + "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); } catch (Exception e) { - m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString()); + m_log.Error("ScriptEngine", + "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + + e.StackTrace.ToString()); } return ret; } @@ -107,18 +111,14 @@ namespace OpenSim.Region.Environment.Scenes.Scripting ScriptEngineInterface ret; //try //{ - ret = (ScriptEngineInterface)Activator.CreateInstance(t); + ret = (ScriptEngineInterface) Activator.CreateInstance(t); //} //catch (Exception e) //{ // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); //} - return ret; - - - } - - + return ret; + } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs index a478827..92e6523 100644 --- a/OpenSim/Region/Environment/StorageManager.cs +++ b/OpenSim/Region/Environment/StorageManager.cs @@ -1,15 +1,7 @@ using System; -using System.Collections.Generic; -using System.Text; - -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - using System.Reflection; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment { @@ -19,10 +11,7 @@ namespace OpenSim.Region.Environment public IRegionDataStore DataStore { - get - { - return m_dataStore; - } + get { return m_dataStore; } } public StorageManager(IRegionDataStore storage) @@ -32,7 +21,7 @@ namespace OpenSim.Region.Environment public StorageManager(string dllName, string dataStoreFile, string dataStoreDB) { - OpenSim.Framework.Console.MainLog.Instance.Verbose("DATASTORE", "Attempting to load " + dllName); + MainLog.Instance.Verbose("DATASTORE", "Attempting to load " + dllName); Assembly pluginAssembly = Assembly.LoadFrom(dllName); foreach (Type pluginType in pluginAssembly.GetTypes()) @@ -43,12 +32,13 @@ namespace OpenSim.Region.Environment if (typeInterface != null) { - IRegionDataStore plug = (IRegionDataStore)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IRegionDataStore plug = + (IRegionDataStore) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(dataStoreFile, dataStoreDB); m_dataStore = plug; - OpenSim.Framework.Console.MainLog.Instance.Verbose("DATASTORE", "Added IRegionDataStore Interface"); + MainLog.Instance.Verbose("DATASTORE", "Added IRegionDataStore Interface"); } typeInterface = null; @@ -60,4 +50,4 @@ namespace OpenSim.Region.Environment //TODO: Add checking and warning to make sure it initialised. } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs index 3b4dd9a..0b815ba 100644 --- a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs +++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; - +using System.Collections.Generic; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Types { public class BasicQuadTreeNode @@ -36,9 +34,9 @@ namespace OpenSim.Region.Environment.Types } else { - if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2))) + if (obj.AbsolutePosition.X < (m_leftX + (m_width/2))) { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) + if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) { m_childNodes[0].AddObject(obj); } @@ -49,7 +47,7 @@ namespace OpenSim.Region.Environment.Types } else { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) + if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) { m_childNodes[1].AddObject(obj); } @@ -66,10 +64,17 @@ namespace OpenSim.Region.Environment.Types if (m_childNodes == null) { m_childNodes = new BasicQuadTreeNode[4]; - m_childNodes[0] = new BasicQuadTreeNode(this, m_leftX, m_leftY,(short) (m_width / 2), (short)( m_height / 2)); - m_childNodes[1] = new BasicQuadTreeNode(this,(short)( m_leftX + (m_width / 2)), m_leftY,(short)( m_width / 2),(short) (m_height / 2)); - m_childNodes[2] = new BasicQuadTreeNode(this, m_leftX, (short)( m_leftY + (m_height / 2)), (short)(m_width / 2),(short)( m_height / 2)); - m_childNodes[3] = new BasicQuadTreeNode(this, (short)( m_leftX + (m_width / 2)),(short)( m_height + (m_height / 2)),(short)( m_width / 2), (short)(m_height / 2)); + m_childNodes[0] = + new BasicQuadTreeNode(this, m_leftX, m_leftY, (short) (m_width/2), (short) (m_height/2)); + m_childNodes[1] = + new BasicQuadTreeNode(this, (short) (m_leftX + (m_width/2)), m_leftY, (short) (m_width/2), + (short) (m_height/2)); + m_childNodes[2] = + new BasicQuadTreeNode(this, m_leftX, (short) (m_leftY + (m_height/2)), (short) (m_width/2), + (short) (m_height/2)); + m_childNodes[3] = + new BasicQuadTreeNode(this, (short) (m_leftX + (m_width/2)), (short) (m_height + (m_height/2)), + (short) (m_width/2), (short) (m_height/2)); } else { @@ -88,9 +93,9 @@ namespace OpenSim.Region.Environment.Types } else { - if (x < (m_leftX + (m_width / 2))) + if (x < (m_leftX + (m_width/2))) { - if (y < (m_leftY + (m_height / 2))) + if (y < (m_leftY + (m_height/2))) { return m_childNodes[0].GetObjectsFrom(x, y); } @@ -101,7 +106,7 @@ namespace OpenSim.Region.Environment.Types } else { - if (y < (m_leftY + (m_height / 2))) + if (y < (m_leftY + (m_height/2))) { return m_childNodes[1].GetObjectsFrom(x, y); } @@ -127,7 +132,8 @@ namespace OpenSim.Region.Environment.Types List outBounds = new List(); foreach (SceneObjectGroup group in m_objects) { - if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) + if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && + ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) { //still in bounds } @@ -151,9 +157,10 @@ namespace OpenSim.Region.Environment.Types public void PassUp(SceneObjectGroup group) { - if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) + if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && + ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) { - this.AddObject(group); + AddObject(group); } else { @@ -164,4 +171,4 @@ namespace OpenSim.Region.Environment.Types } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs index 3b7c182..6e26aaf 100644 --- a/OpenSim/Region/Environment/Types/UpdateQueue.cs +++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; -using libsecondlife; - +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Region.Environment.Scenes; + namespace OpenSim.Region.Environment.Types { public class UpdateQueue @@ -48,7 +46,6 @@ namespace OpenSim.Region.Environment.Types } return part; - } - + } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs index ac5ac89..61541e8 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs @@ -25,22 +25,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System.Collections.Generic; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.ExtensionsScriptModule.CSharp; -using OpenSim.Region.ExtensionsScriptModule.JScript; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine; - +using System.Collections.Generic; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.ExtensionsScriptModule.CSharp; +using OpenSim.Region.ExtensionsScriptModule.JScript; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine; + namespace OpenSim.Region.ExtensionsScriptModule -{ - public class ScriptManager : IRegionModule +{ + public class ScriptManager : IRegionModule, IExtensionScriptModule { - List scripts = new List(); + readonly List scripts = new List(); Scene m_scene; - Dictionary compilers = new Dictionary(); + readonly Dictionary compilers = new Dictionary(); private void LoadFromCompiler(Dictionary compiledscripts) { @@ -65,15 +64,17 @@ namespace OpenSim.Region.ExtensionsScriptModule JavaEngine javaCompiler = new JavaEngine(); compilers.Add(javaCompiler.FileExt(), javaCompiler); - } + } + + public delegate TResult ModuleAPIMethod1(TParam0 param0); + public delegate TResult ModuleAPIMethod2(TParam0 param0, TParam1 param1); public void Initialise(Scene scene) { System.Console.WriteLine("Initialising Extensions Scripting Module"); - m_scene = scene; - - m_scene.RegisterAPIMethod("API_CompileExtensionScript", new ModuleAPIMethod1(Compile)); - m_scene.RegisterAPIMethod("API_AddExtensionScript", new ModuleAPIMethod1(AddPreCompiledScript)); + m_scene = scene; + + m_scene.RegisterModuleInterface(this); } public void PostInitialise() @@ -133,6 +134,12 @@ namespace OpenSim.Region.ExtensionsScriptModule return true; } + } + + public interface IExtensionScriptModule + { + bool Compile(string filename); + bool AddPreCompiledScript(IScript script); } interface IScriptCompiler -- cgit v1.1