From efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Dec 2007 21:41:48 +0000 Subject: * Optimized usings * shortened references * Removed redundant 'this' * Normalized EOF --- OpenSim/Region/Environment/EstateManager.cs | 24 +- .../Environment/Interfaces/IAvatarFactory.cs | 1 - .../Region/Environment/Interfaces/IHttpRequests.cs | 2 +- .../Environment/Interfaces/IRegionDataStore.cs | 7 +- OpenSim/Region/Environment/LandManagement/Land.cs | 61 ++- .../Environment/LandManagement/LandManager.cs | 95 ++--- OpenSim/Region/Environment/ModuleLoader.cs | 2 +- .../Environment/Modules/AvatarFactoryModule.cs | 17 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 10 +- .../Environment/Modules/ScriptsHttpRequests.cs | 260 +++++++------ OpenSim/Region/Environment/Modules/SunModule.cs | 37 +- .../Environment/Modules/TextureDownloadModule.cs | 42 ++- .../Region/Environment/Modules/WorldCommModule.cs | 4 +- OpenSim/Region/Environment/Modules/XMLRPCModule.cs | 9 +- OpenSim/Region/Environment/PermissionManager.cs | 31 +- .../Region/Environment/Scenes/AvatarAnimations.cs | 17 +- .../Region/Environment/Scenes/AvatarAppearance.cs | 14 +- OpenSim/Region/Environment/Scenes/EntityBase.cs | 5 +- .../Environment/Scenes/IScenePresenceBody.cs | 1 - OpenSim/Region/Environment/Scenes/InnerScene.cs | 123 +++--- .../Region/Environment/Scenes/Scene.Inventory.cs | 189 +++++----- .../Environment/Scenes/Scene.PacketHandlers.cs | 19 +- OpenSim/Region/Environment/Scenes/Scene.cs | 400 ++++++++++---------- OpenSim/Region/Environment/Scenes/SceneBase.cs | 11 +- .../Scenes/SceneCommunicationService.cs | 72 ++-- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 12 +- OpenSim/Region/Environment/Scenes/SceneManager.cs | 9 +- .../Region/Environment/Scenes/SceneObjectGroup.cs | 93 ++--- .../Region/Environment/Scenes/SceneObjectPart.cs | 414 +++++++++++---------- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 132 +++---- .../Region/Environment/Scenes/SceneXmlLoader.cs | 25 +- .../Scenes/Scripting/ScriptEngineInterface.cs | 2 +- .../Scenes/Scripting/ScriptEngineLoader.cs | 2 +- .../Region/Environment/Scenes/SimStatsReporter.cs | 69 ++-- 34 files changed, 1119 insertions(+), 1092 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index 081a8cd..3ca9796 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs @@ -334,6 +334,7 @@ namespace OpenSim.Region.Environment } } } + private void estateRestartSim(EstateOwnerMessagePacket packet) { // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. @@ -341,26 +342,25 @@ namespace OpenSim.Region.Environment { float timeSeconds = 0; timeSeconds = BitConverter.ToInt16(block.Parameter, 1); - timeSeconds = (int)((timeSeconds / 100) - 3); + timeSeconds = (int) ((timeSeconds/100) - 3); m_scene.Restart(timeSeconds); - } } + private void EstateChangeCovenant(EstateOwnerMessagePacket packet) { foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) { LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter)); m_regInfo.CovenantID = newCovenantID; - } - } + public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID) { RegionInfoPacket rinfopack = new RegionInfoPacket(); RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock(); - + rinfoblk.BillableFactor = 0; rinfoblk.EstateID = 02; rinfoblk.MaxAgents = 100; @@ -369,20 +369,20 @@ namespace OpenSim.Region.Environment rinfoblk.PricePerMeter = 0; rinfoblk.RedirectGridX = 0; rinfoblk.RedirectGridY = 0; - rinfoblk.RegionFlags = (uint)m_regInfo.EstateSettings.regionFlags; - rinfoblk.SimAccess = (byte)m_regInfo.EstateSettings.simAccess; + rinfoblk.RegionFlags = (uint) m_regInfo.EstateSettings.regionFlags; + rinfoblk.SimAccess = (byte) m_regInfo.EstateSettings.simAccess; rinfoblk.SunHour = m_regInfo.EstateSettings.sunHour; rinfoblk.TerrainLowerLimit = 20; rinfoblk.TerrainRaiseLimit = 20; rinfoblk.UseEstateSun = true; rinfoblk.WaterHeight = m_regInfo.EstateSettings.waterHeight; rinfoblk.SimName = Helpers.StringToField(m_regInfo.RegionName); - + rinfopack.RegionInfo = rinfoblk; client.OutPacket(rinfopack, ThrottleOutPacketType.Task); - } + public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID) { EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket(); @@ -390,10 +390,12 @@ namespace OpenSim.Region.Environment edata.CovenantID = m_regInfo.CovenantID; edata.CovenantTimestamp = 0; edata.EstateOwnerID = m_regInfo.MasterAvatarAssignedUUID; - edata.EstateName = Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName); + edata.EstateName = + Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName); einfopack.Data = edata; client.OutPacket(einfopack, ThrottleOutPacketType.Task); } + #endregion #region Outgoing Packets @@ -451,4 +453,4 @@ namespace OpenSim.Region.Environment #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs index ee4d8bc..fb83150 100644 --- a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs +++ b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs @@ -27,7 +27,6 @@ */ using libsecondlife; -using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Interfaces diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs index c974616..6aa8f35 100644 --- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs @@ -26,9 +26,9 @@ * */ +using System.Collections.Generic; using libsecondlife; using OpenSim.Region.Environment.Modules; -using System.Collections.Generic; namespace OpenSim.Region.Environment.Interfaces { diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index 91aa5ff..78ad428 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; @@ -51,10 +52,10 @@ namespace OpenSim.Region.Environment.Interfaces void StoreTerrain(double[,] terrain, LLUUID regionID); double[,] LoadTerrain(LLUUID regionID); - void StoreLandObject(Land Parcel,LLUUID regionUUID); + void StoreLandObject(Land Parcel, LLUUID regionUUID); void RemoveLandObject(LLUUID globalID); - List LoadLandObjects(LLUUID regionUUID); + List LoadLandObjects(LLUUID regionUUID); void Shutdown(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 7977c78..ff16319 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -32,7 +32,6 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.LandManagement { @@ -98,7 +97,6 @@ namespace OpenSim.Region.Environment.LandManagement return newLand; } - #endregion #region Packet Request Handling @@ -202,7 +200,7 @@ namespace OpenSim.Region.Environment.LandManagement //Needs later group support LandData newData = landData.Copy(); newData.authBuyerID = packet.ParcelData.AuthBuyerID; - newData.category = (Parcel.ParcelCategory)packet.ParcelData.Category; + newData.category = (Parcel.ParcelCategory) packet.ParcelData.Category; newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); newData.groupID = packet.ParcelData.GroupID; newData.landingType = packet.ParcelData.LandingType; @@ -222,8 +220,6 @@ namespace OpenSim.Region.Environment.LandManagement m_scene.LandManager.updateLandObject(landData.localID, newData); sendLandUpdateToAvatarsOverMe(); - - } } @@ -242,13 +238,13 @@ namespace OpenSim.Region.Environment.LandManagement public bool isBannedFromLand(LLUUID avatar) { - if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseBanList) > 0) + if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseBanList) > 0) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = avatar; entry.Flags = ParcelManager.AccessList.Ban; entry.Time = new DateTime(); - if (this.landData.parcelAccessList.Contains(entry)) + if (landData.parcelAccessList.Contains(entry)) { //They are banned, so lets send them a notice about this parcel return true; @@ -259,13 +255,13 @@ namespace OpenSim.Region.Environment.LandManagement public bool isRestrictedFromLand(LLUUID avatar) { - if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseAccessList) > 0) + if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseAccessList) > 0) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = avatar; entry.Flags = ParcelManager.AccessList.Access; entry.Time = new DateTime(); - if (!this.landData.parcelAccessList.Contains(entry)) + if (!landData.parcelAccessList.Contains(entry)) { //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel return true; @@ -310,7 +306,7 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); - listBlock.Flags = (uint)0; + listBlock.Flags = (uint) 0; listBlock.ID = entry.AgentID; listBlock.Time = 0; @@ -322,7 +318,7 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); - listBlock.Flags = (uint)0; + listBlock.Flags = (uint) 0; listBlock.ID = LLUUID.Zero; listBlock.Time = 0; @@ -331,38 +327,37 @@ namespace OpenSim.Region.Environment.LandManagement return list.ToArray(); } - public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, IClientAPI remote_client) + public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, + IClientAPI remote_client) { - ParcelAccessListReplyPacket replyPacket; - if (flags == (uint)ParcelManager.AccessList.Access || flags == (uint)ParcelManager.AccessList.Both) + if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both) { replyPacket = new ParcelAccessListReplyPacket(); replyPacket.Data.AgentID = agentID; - replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Access; - replyPacket.Data.LocalID = this.landData.localID; + replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access; + replyPacket.Data.LocalID = landData.localID; replyPacket.Data.SequenceID = 0; replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); - remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); } - if (flags == (uint)ParcelManager.AccessList.Ban || flags == (uint)ParcelManager.AccessList.Both) + if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both) { replyPacket = new ParcelAccessListReplyPacket(); replyPacket.Data.AgentID = agentID; - replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Ban; - replyPacket.Data.LocalID = this.landData.localID; + replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban; + replyPacket.Data.LocalID = landData.localID; replyPacket.Data.SequenceID = 0; replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); - remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); } - } - public void updateAccessList(uint flags, List entries, IClientAPI remote_client) + public void updateAccessList(uint flags, List entries, IClientAPI remote_client) { LandData newData = landData.Copy(); @@ -370,11 +365,11 @@ namespace OpenSim.Region.Environment.LandManagement { entries.Clear(); } - + List toRemove = new List(); foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList) { - if (entry.Flags == (ParcelManager.AccessList)flags) + if (entry.Flags == (ParcelManager.AccessList) flags) { toRemove.Add(entry); } @@ -388,8 +383,8 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); temp.AgentID = entry.AgentID; - temp.Time = new DateTime() ; //Pointless? Yes. - temp.Flags = (ParcelManager.AccessList)flags; + temp.Time = new DateTime(); //Pointless? Yes. + temp.Flags = (ParcelManager.AccessList) flags; if (!newData.parcelAccessList.Contains(temp)) { @@ -398,7 +393,6 @@ namespace OpenSim.Region.Environment.LandManagement } m_scene.LandManager.updateLandObject(landData.localID, newData); - } #endregion @@ -437,7 +431,6 @@ namespace OpenSim.Region.Environment.LandManagement new LLVector3((float) (max_x*4), (float) (max_y*4), (float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4))); landData.area = tempArea; - } public void updateLandBitmapByteArray() @@ -650,9 +643,9 @@ namespace OpenSim.Region.Environment.LandManagement { resultLocalIDs.Add(obj.LocalId); } - // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support - // { - // } + // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support + // { + // } else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && obj.OwnerID != remote_client.AgentId) { @@ -732,10 +725,8 @@ namespace OpenSim.Region.Environment.LandManagement num++; } - + pack.Data = dataBlock; - - } remote_client.OutPacket(pack, ThrottleOutPacketType.Task); } diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index ecd458d..772fe2e 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -27,11 +27,13 @@ */ using System; using System.Collections.Generic; +using Axiom.Math; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.LandManagement { @@ -93,7 +95,7 @@ namespace OpenSim.Region.Environment.LandManagement private readonly RegionInfo m_regInfo; public bool allowedForcefulBans = true; - + #endregion #region Constructors @@ -103,14 +105,13 @@ namespace OpenSim.Region.Environment.LandManagement m_scene = scene; m_regInfo = reginfo; landIDList.Initialize(); - scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel); - scene.EventManager.OnClientMovement += new EventManager.ClientMovement(this.handleAnyClientMovement); + scene.EventManager.OnAvatarEnteringNewParcel += + new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel); + scene.EventManager.OnClientMovement += new EventManager.ClientMovement(handleAnyClientMovement); } - - #endregion - + #region Member Functions #region Land Object From Storage Functions @@ -147,7 +148,6 @@ namespace OpenSim.Region.Environment.LandManagement /// public Land createBaseLand() { - return new Land(LLUUID.Zero, false, m_scene); } @@ -175,7 +175,7 @@ namespace OpenSim.Region.Environment.LandManagement } } landList[lastLandLocalID].forceUpdateLandInfo(); - m_scene.EventManager.TriggerLandObjectAdded(new_land,m_scene.RegionInfo.RegionID); + m_scene.EventManager.TriggerLandObjectAdded(new_land, m_scene.RegionInfo.RegionID); return new_land; } @@ -207,7 +207,7 @@ namespace OpenSim.Region.Environment.LandManagement if (landList.ContainsKey(local_id)) { landList[local_id].landData = newData.Copy(); - m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]); + m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]); } else { @@ -335,7 +335,7 @@ namespace OpenSim.Region.Environment.LandManagement //Now add the new land object Land result = addLandObject(newLand); - updateLandObject(startLandObject.landData.localID,startLandObject.landData); + updateLandObject(startLandObject.landData.localID, startLandObject.landData); result.sendLandUpdateToAvatarsOverMe(); @@ -463,11 +463,11 @@ namespace OpenSim.Region.Environment.LandManagement Land southParcel = null; if (x > 0) { - westParcel = getLandObject((x - 1) * 4, y * 4); + westParcel = getLandObject((x - 1)*4, y*4); } if (y > 0) { - southParcel = getLandObject(x * 4, (y - 1) * 4); + southParcel = getLandObject(x*4, (y - 1)*4); } if (x == 0) @@ -496,14 +496,15 @@ namespace OpenSim.Region.Environment.LandManagement packet = new ParcelOverlayPacket(); packet.ParcelData.Data = byteArray; packet.ParcelData.SequenceID = sequenceID; - remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task); sequenceID++; byteArray = new byte[LAND_BLOCKS_PER_PACKET]; } } - catch (System.Exception e) + catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Debug("LAND", "Skipped Land checks because avatar is out of bounds: " + e.Message); + MainLog.Instance.Debug("LAND", + "Skipped Land checks because avatar is out of bounds: " + e.Message); } } } @@ -599,7 +600,6 @@ namespace OpenSim.Region.Environment.LandManagement public List parcelsNearPoint(LLVector3 position) { - List parcelsNear = new List(); int x, y; for (x = -4; x <= 4; x += 4) @@ -617,22 +617,25 @@ namespace OpenSim.Region.Environment.LandManagement } } - return parcelsNear; - + return parcelsNear; } public void sendYouAreBannedNotice(ScenePresence avatar) { if (allowedForcefulBans) { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); - avatar.PhysicsActor.Position = new OpenSim.Region.Physics.Manager.PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, avatar.lastKnownAllowedPosition.z); - avatar.PhysicsActor.Velocity = new OpenSim.Region.Physics.Manager.PhysicsVector(0, 0, 0); + avatar.PhysicsActor.Position = + new PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, + avatar.lastKnownAllowedPosition.z); + avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0); } else { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); } } @@ -651,7 +654,8 @@ namespace OpenSim.Region.Environment.LandManagement } else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); } else { @@ -668,7 +672,6 @@ namespace OpenSim.Region.Environment.LandManagement public void sendOutNearestBanLine(IClientAPI avatar) { - List avatars = m_scene.GetAvatars(); foreach (ScenePresence presence in avatars) { @@ -679,15 +682,14 @@ namespace OpenSim.Region.Environment.LandManagement { if (checkBan.isBannedFromLand(avatar.AgentId)) { - checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); + checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar); return; //Only send one } else if (checkBan.isRestrictedFromLand(avatar.AgentId)) { - checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); + checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar); return; //Only send one } - } return; } @@ -696,8 +698,8 @@ namespace OpenSim.Region.Environment.LandManagement public void sendLandUpdate(ScenePresence avatar) { - Land over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), - (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); + Land over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), + (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); if (over != null) { @@ -705,10 +707,10 @@ namespace OpenSim.Region.Environment.LandManagement if (avatar.currentParcelUUID != over.landData.globalID) { avatar.currentParcelUUID = over.landData.globalID; - m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, this.m_scene.RegionInfo.RegionID); + m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, + m_scene.RegionInfo.RegionID); } } - } public void handleSignificantClientMovement(IClientAPI remote_client) @@ -722,16 +724,18 @@ namespace OpenSim.Region.Environment.LandManagement Land parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); if (parcel != null) { - if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) + if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && + clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) { - - handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); //They are going below the safety line! + handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); + //They are going below the safety line! if (!parcel.isBannedFromLand(clientAvatar.UUID)) { clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; } } - else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && parcel.isBannedFromLand(clientAvatar.UUID)) + else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && + parcel.isBannedFromLand(clientAvatar.UUID)) { sendYouAreBannedNotice(clientAvatar); } @@ -739,30 +743,33 @@ namespace OpenSim.Region.Environment.LandManagement } } - public void handleAnyClientMovement(ScenePresence avatar) //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. + public void handleAnyClientMovement(ScenePresence avatar) + //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. { Land over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); if (over != null) { if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) { - avatar.lastKnownAllowedPosition = new Axiom.Math.Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); - - + avatar.lastKnownAllowedPosition = + new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); } } } - public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client) + public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, + int landLocalID, IClientAPI remote_client) { if (landList.ContainsKey(landLocalID)) { - landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID,remote_client); + landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client); } } - public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID,uint flags, int landLocalID, List entries, IClientAPI remote_client) + public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, + List entries, + IClientAPI remote_client) { if (landList.ContainsKey(landLocalID)) { @@ -849,4 +856,4 @@ namespace OpenSim.Region.Environment.LandManagement } #endregion -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index b1ab330..fcf0f72 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -220,7 +220,7 @@ namespace OpenSim.Region.Environment { if (pluginType.GetInterface("IRegionModule") != null) { - modules.Add((IRegionModule)Activator.CreateInstance(pluginType)); + modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); } } } diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs index 0b95aee..c31a79b 100644 --- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs @@ -27,11 +27,12 @@ */ using System; -using libsecondlife; using System.Collections.Generic; +using libsecondlife; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -59,9 +60,9 @@ namespace OpenSim.Region.Environment.Modules { m_avatarsAppearance[avatarId] = appearance; } - catch (System.NullReferenceException) + catch (NullReferenceException) { - OpenSim.Framework.Console.MainLog.Instance.Error("AVATAR", "Unable to load appearance for uninitialized avatar"); + MainLog.Instance.Error("AVATAR", "Unable to load appearance for uninitialized avatar"); } return true; } @@ -98,17 +99,17 @@ namespace OpenSim.Region.Environment.Modules public void NewClient(IClientAPI client) { - client.OnAvatarNowWearing += AvatarIsWearing; + client.OnAvatarNowWearing += AvatarIsWearing; } public void RemoveClient(IClientAPI client) { - // client.OnAvatarNowWearing -= AvatarIsWearing; + // client.OnAvatarNowWearing -= AvatarIsWearing; } public void AvatarIsWearing(Object sender, AvatarWearingArgs e) { - IClientAPI clientView = (IClientAPI)sender; + IClientAPI clientView = (IClientAPI) sender; CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId); if (profile != null) { @@ -127,7 +128,7 @@ namespace OpenSim.Region.Environment.Modules { assetId = baseItem.assetID; //temporary dictionary storage. This should be storing to a database - + if (m_avatarsAppearance.ContainsKey(clientView.AgentId)) { AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId]; @@ -158,4 +159,4 @@ namespace OpenSim.Region.Environment.Modules return visualParams; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 069eb3f..d6df978 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -176,10 +176,10 @@ namespace OpenSim.Region.Environment.Modules foreach (Scene s in m_scenes) { s.ForEachScenePresence(delegate(ScenePresence presence) - { - TrySendChatMessage(presence, fromPos, regionPos, - fromAgentID, fromName, e.Type, message); - }); + { + TrySendChatMessage(presence, fromPos, regionPos, + fromAgentID, fromName, e.Type, message); + }); } } } @@ -373,4 +373,4 @@ namespace OpenSim.Region.Environment.Modules m_tcp.Close(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs index d47004b..f8798dc 100644 --- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs @@ -27,18 +27,15 @@ */ using System; +using System.Collections.Generic; using System.IO; using System.Net; using System.Text; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; -using System.Collections; -using System.Collections.Generic; using System.Threading; using libsecondlife; using Nini.Config; -using Nwc.XmlRpc; -using OpenSim.Framework.Servers; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; /***************************************************** * @@ -85,120 +82,120 @@ using OpenSim.Framework.Servers; namespace OpenSim.Region.Environment.Modules { - public class ScriptHTTPRequests : IRegionModule, IHttpRequests - { - private Scene m_scene; - private Queue rpcQueue = new Queue(); - private object HttpListLock = new object(); - private string m_name = "HttpScriptRequests"; - private int httpTimeout = 300; - - // - private Dictionary m_pendingRequests; - - public ScriptHTTPRequests() - { - } - - public void Initialise(Scene scene, IConfigSource config) - { - m_scene = scene; - - m_scene.RegisterModuleInterface(this); - - m_pendingRequests = new Dictionary(); - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return m_name; } - } - - public bool IsSharedModule - { - get { return true; } - } - - public LLUUID MakeHttpRequest(string url, string parameters, string body) { - return LLUUID.Zero; - } - - public LLUUID StartHttpRequest(uint localID, LLUUID itemID, string url, List parameters, string body) - { - LLUUID reqID = LLUUID.Random(); - HttpRequestClass htc = new HttpRequestClass(); - - // Parameters are expected in {key, value, ... , key, value} - if( parameters != null ) - { - string[] parms = parameters.ToArray(); - for (int i = 0; i < parms.Length / 2; i += 2) + public class ScriptHTTPRequests : IRegionModule, IHttpRequests + { + private Scene m_scene; + private Queue rpcQueue = new Queue(); + private object HttpListLock = new object(); + private string m_name = "HttpScriptRequests"; + private int httpTimeout = 300; + + // + private Dictionary m_pendingRequests; + + public ScriptHTTPRequests() + { + } + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + + m_scene.RegisterModuleInterface(this); + + m_pendingRequests = new Dictionary(); + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return m_name; } + } + + public bool IsSharedModule + { + get { return true; } + } + + public LLUUID MakeHttpRequest(string url, string parameters, string body) + { + return LLUUID.Zero; + } + + public LLUUID StartHttpRequest(uint localID, LLUUID itemID, string url, List parameters, string body) + { + LLUUID reqID = LLUUID.Random(); + HttpRequestClass htc = new HttpRequestClass(); + + // Parameters are expected in {key, value, ... , key, value} + if (parameters != null) + { + string[] parms = parameters.ToArray(); + for (int i = 0; i < parms.Length/2; i += 2) { - switch( Int32.Parse(parms[i]) ) + switch (Int32.Parse(parms[i])) { case HttpRequestClass.HTTP_METHOD: - htc.httpMethod = parms[i + 1]; - break; + htc.httpMethod = parms[i + 1]; + break; case HttpRequestClass.HTTP_MIMETYPE: - - htc.httpMIMEType = parms[i + 1]; - break; + + htc.httpMIMEType = parms[i + 1]; + break; case HttpRequestClass.HTTP_BODY_MAXLENGTH: - - // TODO implement me - break; + + // TODO implement me + break; case HttpRequestClass.HTTP_VERIFY_CERT: - - // TODO implement me - break; + + // TODO implement me + break; } } - } - - htc.localID = localID; - htc.itemID = itemID; - htc.url = url; - htc.reqID = reqID; - htc.httpTimeout = httpTimeout; - htc.outbound_body = body; - - lock (HttpListLock) - { - m_pendingRequests.Add(reqID, htc); - } - - htc.process(); - - return reqID; - } - - public void StopHttpRequest(uint m_localID, LLUUID m_itemID) - { - lock (HttpListLock) - { - - HttpRequestClass tmpReq; - if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq)) - { - tmpReq.Stop(); - m_pendingRequests.Remove(m_itemID); - } - } - } - - /* + } + + htc.localID = localID; + htc.itemID = itemID; + htc.url = url; + htc.reqID = reqID; + htc.httpTimeout = httpTimeout; + htc.outbound_body = body; + + lock (HttpListLock) + { + m_pendingRequests.Add(reqID, htc); + } + + htc.process(); + + return reqID; + } + + public void StopHttpRequest(uint m_localID, LLUUID m_itemID) + { + lock (HttpListLock) + { + HttpRequestClass tmpReq; + if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq)) + { + tmpReq.Stop(); + m_pendingRequests.Remove(m_itemID); + } + } + } + + /* * TODO * Not sure how important ordering is is here - the next first * one completed in the list is returned, based soley on its list @@ -206,10 +203,11 @@ namespace OpenSim.Region.Environment.Modules * finsihed. I thought about setting up a queue for this, but * it will need some refactoring and this works 'enough' right now */ - public HttpRequestClass GetNextCompletedRequest() - { - lock (HttpListLock) - { + + public HttpRequestClass GetNextCompletedRequest() + { + lock (HttpListLock) + { foreach (LLUUID luid in m_pendingRequests.Keys) { HttpRequestClass tmpReq; @@ -225,18 +223,16 @@ namespace OpenSim.Region.Environment.Modules } } return null; - } - - - } + } + } - // - // HTTP REAQUEST - // This class was originally in LSLLongCmdHandler - // - // TODO: setter/getter methods, maybe pass some in - // constructor - // + // + // HTTP REAQUEST + // This class was originally in LSLLongCmdHandler + // + // TODO: setter/getter methods, maybe pass some in + // constructor + // public class HttpRequestClass { @@ -280,9 +276,9 @@ namespace OpenSim.Region.Environment.Modules * TODO: More work on the response codes. Right now * returning 200 for success or 499 for exception */ + public void SendRequest() { - HttpWebResponse response = null; StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; @@ -292,14 +288,14 @@ namespace OpenSim.Region.Environment.Modules try { request = (HttpWebRequest) - WebRequest.Create(url); + WebRequest.Create(url); request.Method = httpMethod; request.ContentType = httpMIMEType; request.Timeout = httpTimeout; // execute the request response = (HttpWebResponse) - request.GetResponse(); + request.GetResponse(); Stream resStream = response.GetResponseStream(); @@ -317,11 +313,9 @@ namespace OpenSim.Region.Environment.Modules // continue building the string sb.Append(tempString); } - } - while (count > 0); // any more data to read? + } while (count > 0); // any more data to read? response_body = sb.ToString(); - } catch (Exception e) { @@ -333,7 +327,6 @@ namespace OpenSim.Region.Environment.Modules status = 200; finished = true; - } public void Stop() @@ -342,8 +335,9 @@ namespace OpenSim.Region.Environment.Modules { httpThread.Abort(); } - catch (Exception) { } + catch (Exception) + { + } } } - - } \ No newline at end of file +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/SunModule.cs b/OpenSim/Region/Environment/Modules/SunModule.cs index 233c83c..bd6cd63 100644 --- a/OpenSim/Region/Environment/Modules/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/SunModule.cs @@ -28,13 +28,12 @@ using System; using System.Collections.Generic; +using libsecondlife; using Nini.Config; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; using OpenSim.Framework; using OpenSim.Framework.Console; -using libsecondlife; - +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules { @@ -55,17 +54,20 @@ namespace OpenSim.Region.Environment.Modules { m_start = DateTime.Now.Ticks; m_frame = 0; - + // Just in case they don't have the stanzas - try { + try + { m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day); m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame); - } catch (Exception) { + } + catch (Exception) + { m_day_length = m_real_day; m_frame_mod = m_default_frame; } - - m_dilation = (int)(m_real_day / m_day_length); + + m_dilation = (int) (m_real_day/m_day_length); m_scene = scene; m_log = MainLog.Instance; scene.EventManager.OnFrame += SunUpdate; @@ -94,10 +96,11 @@ namespace OpenSim.Region.Environment.Modules { client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); } - + public void SunUpdate() { - if (m_frame < m_frame_mod) { + if (m_frame < m_frame_mod) + { m_frame++; return; } @@ -115,20 +118,20 @@ namespace OpenSim.Region.Environment.Modules // time when the simulator starts, then run time forward // faster based on time dilation factor. This means that // ticks don't get out of hand - private double HourOfTheDay() + private double HourOfTheDay() { - long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; + long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation; DateTime dt = new DateTime(m_start + m_addticks); - return (double)dt.Hour + ((double)dt.Minute / 60.0); + return (double) dt.Hour + ((double) dt.Minute/60.0); } - private LLVector3 SunPos(double hour) + private LLVector3 SunPos(double hour) { // now we have our radian position - double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); + double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0); double z = Math.Sin(rad); double x = Math.Cos(rad); - return new LLVector3((float)x, 0f, (float)z); + return new LLVector3((float) x, 0f, (float) z); } // TODO: clear this out. This is here so that I remember to diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 0adace1..813be8d 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -32,6 +32,7 @@ using libsecondlife; using libsecondlife.Packets; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -48,7 +49,8 @@ namespace OpenSim.Region.Environment.Modules private BlockingQueue QueueSenders = new BlockingQueue(); - private Dictionary m_userTextureServices = new Dictionary(); + private Dictionary m_userTextureServices = + new Dictionary(); private Thread m_thread; @@ -72,7 +74,6 @@ namespace OpenSim.Region.Environment.Modules m_scene = scene; m_scene.EventManager.OnNewClient += NewClient; } - } public void PostInitialise() @@ -115,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules public void TextureRequest(Object sender, TextureRequestArgs e) { - IClientAPI client = (IClientAPI)sender; + IClientAPI client = (IClientAPI) sender; UserTextureDownloadService textureService; if (TryGetUserTextureService(client.AgentId, out textureService)) { @@ -175,7 +176,8 @@ namespace OpenSim.Region.Environment.Modules { if (!m_textureSenders.ContainsKey(e.RequestedAssetID)) { - TextureSender requestHandler = new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); + TextureSender requestHandler = + new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); m_textureSenders.Add(e.RequestedAssetID, requestHandler); m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); } @@ -183,7 +185,8 @@ namespace OpenSim.Region.Environment.Modules { m_textureSenders[e.RequestedAssetID].UpdateRequest(e.DiscardLevel, e.PacketNumber); m_textureSenders[e.RequestedAssetID].counter = 0; - if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && (m_textureSenders[e.RequestedAssetID].Sending ==false)) + if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && + (m_textureSenders[e.RequestedAssetID].Sending == false)) { m_textureSenders[e.RequestedAssetID].Sending = true; m_sharedSendersQueue.Enqueue(m_textureSenders[e.RequestedAssetID]); @@ -256,7 +259,7 @@ namespace OpenSim.Region.Environment.Modules { m_asset = asset; NumPackets = CalculateNumPackets(asset.Data.Length); - PacketCounter = (int)StartPacketNumber; + PacketCounter = (int) StartPacketNumber; ImageLoaded = true; } @@ -264,14 +267,15 @@ namespace OpenSim.Region.Environment.Modules { RequestedDiscardLevel = discardLevel; StartPacketNumber = packetNumber; - PacketCounter = (int)StartPacketNumber; + PacketCounter = (int) StartPacketNumber; } public bool SendTexturePacket() { SendPacket(); counter++; - if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))) ) + if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || + ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1))))) { return true; } @@ -290,7 +294,7 @@ namespace OpenSim.Region.Environment.Modules im.Header.Reliable = false; im.ImageID.Packets = 1; im.ImageID.ID = m_asset.FullID; - im.ImageID.Size = (uint)m_asset.Data.Length; + im.ImageID.Size = (uint) m_asset.Data.Length; im.ImageData.Data = m_asset.Data; im.ImageID.Codec = 2; RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); @@ -300,9 +304,9 @@ namespace OpenSim.Region.Environment.Modules { ImageDataPacket im = new ImageDataPacket(); im.Header.Reliable = false; - im.ImageID.Packets = (ushort)(NumPackets); + im.ImageID.Packets = (ushort) (NumPackets); im.ImageID.ID = m_asset.FullID; - im.ImageID.Size = (uint)m_asset.Data.Length; + im.ImageID.Size = (uint) m_asset.Data.Length; im.ImageData.Data = new byte[600]; Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600); im.ImageID.Codec = 2; @@ -314,18 +318,20 @@ namespace OpenSim.Region.Environment.Modules { ImagePacketPacket im = new ImagePacketPacket(); im.Header.Reliable = false; - im.ImageID.Packet = (ushort)(PacketCounter); + im.ImageID.Packet = (ushort) (PacketCounter); im.ImageID.ID = m_asset.FullID; - int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); + int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1)); if (size > 1000) size = 1000; im.ImageData.Data = new byte[size]; try { - Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size); + Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size); } - catch (System.ArgumentOutOfRangeException) + catch (ArgumentOutOfRangeException) { - OpenSim.Framework.Console.MainLog.Instance.Warn("TEXTURE", "Unable to separate texture into multiple packets: Array bounds failure on asset:" + m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); + MainLog.Instance.Warn("TEXTURE", + "Unable to separate texture into multiple packets: Array bounds failure on asset:" + + m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); return; } RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); @@ -342,14 +348,12 @@ namespace OpenSim.Region.Environment.Modules { //over 600 bytes so split up file int restData = (length - 600); - int restPackets = ((restData + 999) / 1000); + int restPackets = ((restData + 999)/1000); numPackets = restPackets; } return numPackets; } } - - } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs index 0dad998..6b9ae46 100644 --- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs @@ -135,7 +135,7 @@ namespace OpenSim.Region.Environment.Modules { m_listenerManager.Remove(handle); } - + // This method scans nearby objects and determines if they are listeners, // and if so if this message fits the filter. If it does, then // enqueue the message for delivery to the objects listen event handler. @@ -490,4 +490,4 @@ namespace OpenSim.Region.Environment.Modules return m_id; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs index f13b2bb..481ba3f 100644 --- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs +++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs @@ -33,10 +33,10 @@ using System.Threading; using libsecondlife; using Nini.Config; using Nwc.XmlRpc; +using OpenSim.Framework.Console; using OpenSim.Framework.Servers; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Console; /***************************************************** * @@ -116,15 +116,16 @@ namespace OpenSim.Region.Environment.Modules public void PostInitialise() { - if ( IsEnabled() ) + if (IsEnabled()) { m_openChannels = new Dictionary(); m_pendingResponse = new Dictionary(); // Start http server // Attach xmlrpc handlers - m_log.Verbose("REMOTE_DATA", "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); - BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); + m_log.Verbose("REMOTE_DATA", + "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); + BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort); httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); httpServer.Start(); } diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 53fa08a..76601ec 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -35,13 +35,13 @@ namespace OpenSim.Region.Environment public class PermissionManager { protected Scene m_scene; - + // These are here for testing. They will be taken out - private uint PERM_ALL = (uint)2147483647; - private uint PERM_COPY = (uint)32768; - private uint PERM_MODIFY = (uint)16384; - private uint PERM_MOVE = (uint)524288; - private uint PERM_TRANS = (uint)8192; + private uint PERM_ALL = (uint) 2147483647; + private uint PERM_COPY = (uint) 32768; + private uint PERM_MODIFY = (uint) 16384; + private uint PERM_MOVE = (uint) 524288; + private uint PERM_TRANS = (uint) 8192; // Bypasses the permissions engine (always returns OK) // disable in any production environment // TODO: Change this to false when permissions are a desired default @@ -109,10 +109,11 @@ namespace OpenSim.Region.Environment string reason = "Insufficient permission"; - Land land = this.m_scene.LandManager.getLandObject(position.X, position.Y); + Land land = m_scene.LandManager.getLandObject(position.X, position.Y); if (land == null) return false; - if ((land.landData.landFlags & ((int)Parcel.ParcelFlags.CreateObjects)) == (int)Parcel.ParcelFlags.CreateObjects) + if ((land.landData.landFlags & ((int) Parcel.ParcelFlags.CreateObjects)) == + (int) Parcel.ParcelFlags.CreateObjects) permission = true; //TODO: check for group rights @@ -143,8 +144,6 @@ namespace OpenSim.Region.Environment #region Object Permissions - - public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) { if (!m_scene.Entities.ContainsKey(objID)) @@ -158,7 +157,7 @@ namespace OpenSim.Region.Environment return 0; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objID]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[objID]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -274,7 +273,7 @@ namespace OpenSim.Region.Environment public virtual bool CanEditObjectPosition(LLUUID user, LLUUID obj) { - bool permission = GenericObjectPermission(user,obj); + bool permission = GenericObjectPermission(user, obj); if (!permission) { if (!m_scene.Entities.ContainsKey(obj)) @@ -288,7 +287,7 @@ namespace OpenSim.Region.Environment return false; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -298,6 +297,7 @@ namespace OpenSim.Region.Environment } return permission; } + public virtual bool CanCopyObject(LLUUID user, LLUUID obj) { bool permission = GenericObjectPermission(user, obj); @@ -314,7 +314,7 @@ namespace OpenSim.Region.Environment return false; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -324,6 +324,7 @@ namespace OpenSim.Region.Environment } return permission; } + public virtual bool CanReturnObject(LLUUID user, LLUUID obj) { return GenericObjectPermission(user, obj); @@ -491,4 +492,4 @@ namespace OpenSim.Region.Environment #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs index cffe846..5466865 100644 --- a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs +++ b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs @@ -25,11 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; using System.Collections.Generic; using System.Xml; using libsecondlife; -using libsecondlife.Packets; - +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -37,11 +37,11 @@ namespace OpenSim.Region.Environment.Scenes { public Dictionary AnimsLLUUID = new Dictionary(); public Dictionary AnimsNames = new Dictionary(); - + public AvatarAnimations() { } - + public void LoadAnims() { //MainLog.Instance.Verbose("CLIENT", "Loading avatar animations"); @@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment.Scenes } } } - + // MainLog.Instance.Verbose("CLIENT", "Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); try @@ -68,11 +68,10 @@ namespace OpenSim.Region.Environment.Scenes AnimsNames.Add(kp.Value, kp.Key); } } - catch (System.InvalidOperationException) + catch (InvalidOperationException) { - OpenSim.Framework.Console.MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar"); + MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar"); } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs index 2ec4dbe..1583124 100644 --- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs +++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -26,15 +26,9 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Framework.Communications; -using OpenSim.Region.Environment.Types; namespace OpenSim.Region.Environment.Scenes { @@ -106,8 +100,8 @@ namespace OpenSim.Region.Environment.Scenes // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters. // (float)m_visualParams[25] = Height // (float)m_visualParams[125] = LegLength - m_avatarHeight = (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f))) - + (((float)m_visualParams[125] / 255.0f) / 1.5f); + m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f))) + + (((float) m_visualParams[125]/255.0f)/1.5f); } /// @@ -144,4 +138,4 @@ namespace OpenSim.Region.Environment.Scenes return textu; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index 4556c63..18799e4 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -145,7 +145,6 @@ namespace OpenSim.Region.Environment.Scenes return (EntityBase) MemberwiseClone(); } - public abstract void SetText(string text, Vector3 color, double alpha); } @@ -161,15 +160,13 @@ namespace OpenSim.Region.Environment.Scenes public EntityIntersection() { - - } + public EntityIntersection(Vector3 _ipoint, float _normal, bool _HitTF) { ipoint = _ipoint; normal = _normal; HitTF = _HitTF; } - } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs index b9d1232..3e87981 100644 --- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs +++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs @@ -27,7 +27,6 @@ */ using libsecondlife; -using libsecondlife.Packets; using OpenSim.Framework; namespace OpenSim.Region.Environment.Scenes diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 0ca3405..4233853 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; @@ -44,10 +43,13 @@ namespace OpenSim.Region.Environment.Scenes public class InnerScene { #region Events + public event PhysicsCrash UnRecoverableError; + #endregion #region Fields + public Dictionary ScenePresences; public Dictionary SceneObjects; public Dictionary Entities; @@ -65,6 +67,7 @@ namespace OpenSim.Region.Environment.Scenes internal object m_syncRoot = new object(); public PhysicsScene _PhyScene; + #endregion public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) @@ -79,28 +82,27 @@ namespace OpenSim.Region.Environment.Scenes public PhysicsScene PhysicsScene { - get - { return _PhyScene; } + get { return _PhyScene; } set { // If we're not doing the initial set // Then we've got to remove the previous // event handler - try - { - _PhyScene.OnPhysicsCrash -= physicsBasedCrash; - } - catch (System.NullReferenceException) - { - // This occurs when storing to _PhyScene the first time. - // Is there a better way to check the event handler before - // getting here - // This can be safely ignored. We're setting the first inital - // there are no event handler's registered. - } - + try + { + _PhyScene.OnPhysicsCrash -= physicsBasedCrash; + } + catch (NullReferenceException) + { + // This occurs when storing to _PhyScene the first time. + // Is there a better way to check the event handler before + // getting here + // This can be safely ignored. We're setting the first inital + // there are no event handler's registered. + } + _PhyScene = value; - + _PhyScene.OnPhysicsCrash += physicsBasedCrash; } } @@ -113,6 +115,7 @@ namespace OpenSim.Region.Environment.Scenes } #region Update Methods + internal void UpdatePreparePhysics() { // If we are using a threaded physics engine @@ -141,7 +144,7 @@ namespace OpenSim.Region.Environment.Scenes { lock (m_syncRoot) { - return _PhyScene.Simulate((float)elapsed); + return _PhyScene.Simulate((float) elapsed); } } @@ -151,12 +154,14 @@ namespace OpenSim.Region.Environment.Scenes foreach (EntityBase entity in moveEntities) { - entity.UpdateMovement(); + entity.UpdateMovement(); } } + #endregion #region Entity Methods + public void AddEntityFromStorage(SceneObjectGroup sceneObject) { sceneObject.RegionHandle = m_regInfo.RegionHandle; @@ -181,14 +186,17 @@ namespace OpenSim.Region.Environment.Scenes m_numPrim++; } } + public void AddPhysicalPrim(int number) { m_physicalPrim++; } + public void RemovePhysicalPrim(int number) { m_physicalPrim--; } + public void RemovePrim(uint localID, LLUUID avatar_deleter) { List EntityList = GetEntities(); @@ -197,9 +205,9 @@ namespace OpenSim.Region.Environment.Scenes { if (obj is SceneObjectGroup) { - if (((SceneObjectGroup)obj).LocalId == localID) + if (((SceneObjectGroup) obj).LocalId == localID) { - m_parentScene.RemoveEntity((SceneObjectGroup)obj); + m_parentScene.RemoveEntity((SceneObjectGroup) obj); m_numPrim--; return; } @@ -253,7 +261,8 @@ namespace OpenSim.Region.Environment.Scenes return newAvatar; } - public void SwapRootChildAgent(bool direction_RC_CR_T_F) + + public void SwapRootChildAgent(bool direction_RC_CR_T_F) { if (direction_RC_CR_T_F) { @@ -266,25 +275,29 @@ namespace OpenSim.Region.Environment.Scenes m_numRootAgents++; } } + public void removeUserCount(bool TypeRCTF) { if (TypeRCTF) { m_numRootAgents--; } - else + else { m_numChildAgents--; } } + public void RemoveAPrimCount() { m_numPrim--; } + public void AddAPrimCount() { m_numPrim++; } + public int GetChildAgentCount() { return m_numChildAgents; @@ -375,8 +388,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(localID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(localID)) + return (SceneObjectGroup) ent; } } return null; @@ -390,8 +403,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(fullID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(fullID)) + return (SceneObjectGroup) ent; } } return null; @@ -406,7 +419,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectGroup reportingG = (SceneObjectGroup)ent; + SceneObjectGroup reportingG = (SceneObjectGroup) ent; EntityIntersection result = reportingG.TestIntersection(hray); if (result.HitTF) { @@ -417,7 +430,6 @@ namespace OpenSim.Region.Environment.Scenes } } } - } return returnResult; } @@ -531,17 +543,16 @@ namespace OpenSim.Region.Environment.Scenes //float distResult = Vector3Distance(avPosition, objPosition); //if (distResult > 512) //{ - //int x = 0; + //int x = 0; //} //if (distResult < presence.DrawDistance) //{ - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); //} - } - else + else { - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); } } } @@ -554,9 +565,11 @@ namespace OpenSim.Region.Environment.Scenes action(presence.ControllingClient); } } + #endregion #region Client Event handlers + /// /// /// @@ -583,13 +596,12 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, LLUUID ObjectID) + public void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, + LLUUID ObjectID) { SceneObjectGroup group = GetGroupByPrim(ObjectID); if (group != null) group.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags); - - } /// @@ -708,10 +720,9 @@ namespace OpenSim.Region.Environment.Scenes { if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) { - group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); + group.UpdatePrimFlags(localID, (ushort) packet.Type, true, packet.ToBytes()); } } - } public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) @@ -763,7 +774,7 @@ namespace OpenSim.Region.Environment.Scenes public void UpdateExtraParam(LLUUID agentID, uint primLocalID, ushort type, bool inUse, byte[] data) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - + if (group != null) { if (PermissionsMngr.CanEditObject(agentID, group.UUID)) @@ -771,7 +782,6 @@ namespace OpenSim.Region.Environment.Scenes group.UpdateExtraParam(primLocalID, type, inUse, data); } } - } /// @@ -786,7 +796,6 @@ namespace OpenSim.Region.Environment.Scenes { if (PermissionsMngr.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID))) { - group.UpdateShape(shapeBlock, primLocalID); } } @@ -806,9 +815,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; } } @@ -823,9 +832,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); } } } @@ -857,7 +866,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectGroup obj = (SceneObjectGroup)ent; + SceneObjectGroup obj = (SceneObjectGroup) ent; sceneObjects.Add(obj.LocalId, obj); } } @@ -882,9 +891,9 @@ namespace OpenSim.Region.Environment.Scenes } else { - MainLog.Instance.Verbose("SCENE", - "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", - primIds); + MainLog.Instance.Verbose("SCENE", + "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", + primIds); } } @@ -903,9 +912,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; } } @@ -929,7 +938,6 @@ namespace OpenSim.Region.Environment.Scenes { MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); } - } /// @@ -943,8 +951,11 @@ namespace OpenSim.Region.Environment.Scenes // We don't really need the double floating point precision... // so casting it to a single - return (float)Math.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.z - v2.z) * (v1.z - v2.z)); + return + (float) + Math.Sqrt((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y) + (v1.z - v2.z)*(v1.z - v2.z)); } + #endregion } -} +} \ 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 0689177..4c6e1c8 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -26,14 +26,12 @@ * */ -using Axiom.Math; +using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Region.Physics.Manager; -using System.Collections.Generic; namespace OpenSim.Region.Environment.Scenes { @@ -41,7 +39,7 @@ namespace OpenSim.Region.Environment.Scenes { //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete // or at least some of they can be moved somewhere else - + /// /// Add an inventory item to an avatar's inventory. /// @@ -57,7 +55,7 @@ namespace OpenSim.Region.Environment.Scenes remoteClient.SendInventoryItemCreateUpdate(item); } } - + /// /// AddInventoryItem(LLUUID, InventoryItemBase) /// @@ -71,10 +69,10 @@ namespace OpenSim.Region.Environment.Scenes if (!TryGetAvatar(avatarId, out avatar)) { MainLog.Instance.Error( - "AGENTINVENTORY", "Could not find avatar {0} to add inventory item", avatarId); + "AGENTINVENTORY", "Could not find avatar {0} to add inventory item", avatarId); return; } - + AddInventoryItem(avatar.ControllingClient, item); } @@ -95,7 +93,9 @@ namespace OpenSim.Region.Environment.Scenes InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); if (item != null) { - AssetBase asset = CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, (sbyte) item.assetType, data); + AssetBase asset = + CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, + (sbyte) item.assetType, data); AssetCache.AddAsset(asset); item.assetID = asset.FullID; @@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes } return LLUUID.Zero; } - + /// /// CapsUpdatedInventoryItemAsset(IClientAPI, LLUUID, byte[]) /// @@ -132,14 +132,14 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Error( - "AGENTINVENTORY", - "Avatar {0} cannot be found to update its inventory item asset", - avatarId); + "AGENTINVENTORY", + "Avatar {0} cannot be found to update its inventory item asset", + avatarId); } return LLUUID.Zero; - } - + } + /// /// Capability originating call to update the asset of a script in a prim's (task's) inventory /// @@ -149,17 +149,17 @@ namespace OpenSim.Region.Environment.Scenes /// Indicates whether the script to update is currently running /// /// Asset LLUID created - public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, - LLUUID primId, bool isScriptRunning, byte[] data) + public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, + LLUUID primId, bool isScriptRunning, byte[] data) { // TODO Not currently doing anything with the isScriptRunning bool - + MainLog.Instance.Verbose( "PRIMINVENTORY", "Prim inventory script save functionality not yet implemented." - + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}", + + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}", remoteClient, itemId, primId, isScriptRunning); - + // TODO // Retrieve client LLUID // Retrieve sog containing primID @@ -170,13 +170,13 @@ namespace OpenSim.Region.Environment.Scenes // Trigger rerunning of script (use TriggerRezScript event, see RezScript) // return new asset id } - + /// /// CapsUpdateTaskInventoryScriptAsset(IClientAPI, LLUUID, LLUUID, bool, byte[]) /// - private void CapsUpdateTaskInventoryScriptAsset(LLUUID avatarId, LLUUID itemId, + private void CapsUpdateTaskInventoryScriptAsset(LLUUID avatarId, LLUUID itemId, LLUUID primId, bool isScriptRunning, byte[] data) - { + { ScenePresence avatar; if (TryGetAvatar(avatarId, out avatar)) @@ -187,10 +187,10 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Error( - "PRIMINVENTORY", - "Avatar {0} cannot be found to update its prim item asset", - avatarId); - } + "PRIMINVENTORY", + "Avatar {0} cannot be found to update its prim item asset", + avatarId); + } } /// @@ -204,74 +204,75 @@ namespace OpenSim.Region.Environment.Scenes /// The name of the updated item /// The description of the updated item /// The permissions of the updated item - public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, + public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID itemID, string name, string description, uint nextOwnerMask) - { - CachedUserInfo userInfo + { + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); - + if (userInfo != null && userInfo.RootFolder != null) { InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); if (item != null) - { + { if (LLUUID.Zero == transactionID) { item.inventoryName = name; item.inventoryDescription = description; item.inventoryNextPermissions = nextOwnerMask; - + userInfo.UpdateItem(remoteClient.AgentId, item); } - else - { - AgentAssetTransactions transactions + else + { + AgentAssetTransactions transactions = CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); - + if (transactions != null) { - LLUUID assetID = libsecondlife.LLUUID.Combine(transactionID, remoteClient.SecureSessionId); - AssetBase asset + LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); + AssetBase asset = AssetCache.GetAsset( - assetID, (item.assetType == (int)AssetType.Texture ? true : false)); - + assetID, (item.assetType == (int) AssetType.Texture ? true : false)); + if (asset == null) { asset = transactions.GetTransactionAsset(transactionID); } - + if (asset != null && asset.FullID == assetID) { asset.Name = item.inventoryName; asset.Description = item.inventoryDescription; asset.InvType = (sbyte) item.invType; - asset.Type = (sbyte) item.assetType; + asset.Type = (sbyte) item.assetType; item.assetID = asset.FullID; - + AssetCache.AddAsset(asset); } - + userInfo.UpdateItem(remoteClient.AgentId, item); } } } else - { + { MainLog.Instance.Warn( - "AGENTINVENTORY", - "Item ID " + itemID + " not found for an inventory item update."); + "AGENTINVENTORY", + "Item ID " + itemID + " not found for an inventory item update."); } } else { MainLog.Instance.Warn( "AGENTINVENTORY", - "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); + "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); } } - public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName) + public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, + LLUUID newFolderID, string newName) { InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID); if (item == null) @@ -308,7 +309,7 @@ namespace OpenSim.Region.Environment.Scenes } asset.Name = (newName.Length == 0) ? item.inventoryName : newName; - + // TODO: preserve current permissions? CreateNewInventoryItem(remoteClient, newFolderID, callbackID, asset, item.inventoryNextPermissions); } @@ -325,12 +326,13 @@ namespace OpenSim.Region.Environment.Scenes return asset; } - public void MoveInventoryItem(IClientAPI remoteClient,LLUUID folderID, LLUUID itemID, int length, string newName) + public void MoveInventoryItem(IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length, + string newName) { MainLog.Instance.Verbose( - "AGENTINVENTORY", + "AGENTINVENTORY", "Moving item for " + remoteClient.AgentId.ToString()); - + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo == null) { @@ -364,8 +366,6 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + itemID.ToString() + ", no root folder"); return; } - - } private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID, @@ -406,7 +406,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, - uint callbackID, string description, string name, sbyte invType, sbyte assetType, + uint callbackID, string description, string name, sbyte invType, + sbyte assetType, byte wearableType, uint nextOwnerMask) { if (transActionID == LLUUID.Zero) @@ -437,8 +438,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(localID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(localID)) + return (SceneObjectGroup) ent; } } return null; @@ -491,13 +492,13 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Warn( - "PRIMINVENTORY", - "Removal of item {0} requested of prim {1} but this prim does not exist", + "PRIMINVENTORY", + "Removal of item {0} requested of prim {1} but this prim does not exist", itemID, localID); - } + } } - + /// /// Update an item in a prim (task) inventory. /// This method does not handle scripts, RezScript(IClientAPI, LLUUID, unit) @@ -506,7 +507,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, + public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint primLocalID) { SceneObjectGroup group = GetGroupByPrim(primLocalID); @@ -515,17 +516,17 @@ namespace OpenSim.Region.Environment.Scenes // TODO Retrieve itemID from client's inventory to pass on //group.AddInventoryItem(rmoteClient, primLocalID, null); MainLog.Instance.Verbose( - "PRIMINVENTORY", + "PRIMINVENTORY", "UpdateTaskInventory called with script {0}, folder {1}, primLocalID {2}, user {3}", itemID, folderID, primLocalID, remoteClient.Name); - } + } else { MainLog.Instance.Warn( - "PRIMINVENTORY", - "Update with script {0} requested of prim {1} for {2} but this prim does not exist", + "PRIMINVENTORY", + "Update with script {0} requested of prim {1} for {2} but this prim does not exist", itemID, primLocalID, remoteClient.Name); - } + } } /// @@ -551,7 +552,7 @@ namespace OpenSim.Region.Environment.Scenes { isTexture = true; } - + AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture); if (rezAsset != null) @@ -569,18 +570,18 @@ namespace OpenSim.Region.Environment.Scenes // TODO: do we care about the value of this bool? group.AddInventoryItem(remoteClient, localID, item, copyID); group.GetProperites(remoteClient); - + MainLog.Instance.Verbose( - "PRIMINVENTORY", - "Rezzed script {0} (asset {1}) into prim {2} for user {3}", - item.inventoryName, rezAsset.FullID, localID, remoteClient.Name); + "PRIMINVENTORY", + "Rezzed script {0} (asset {1}) into prim {2} for user {3}", + item.inventoryName, rezAsset.FullID, localID, remoteClient.Name); } else { MainLog.Instance.Warn( "PRIMINVENTORY", "Could not rez script {0} into prim {1} for user {2}" - + " because the prim could not be found in the region!", + + " because the prim could not be found in the region!", item.inventoryName, localID, remoteClient.Name); } } @@ -589,7 +590,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn( "PRIMINVENTORY", "Could not rez script {0} into prim {1} for user {2}" - + " because the item asset {3} could not be found!", + + " because the item asset {3} could not be found!", item.inventoryName, localID, item.assetID, remoteClient.Name); } } @@ -638,7 +639,8 @@ namespace OpenSim.Region.Environment.Scenes if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) { string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); - CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { AssetBase asset = CreateAsset( @@ -661,9 +663,10 @@ namespace OpenSim.Region.Environment.Scenes item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; item.inventoryCurrentPermissions = 2147483647; item.inventoryNextPermissions = 2147483647; - item.inventoryEveryOnePermissions = ((SceneObjectGroup)selectedEnt).RootPart.EveryoneMask; - item.inventoryBasePermissions = ((SceneObjectGroup)selectedEnt).RootPart.BaseMask; - item.inventoryCurrentPermissions = ((SceneObjectGroup)selectedEnt).RootPart.OwnerMask; + item.inventoryEveryOnePermissions = + ((SceneObjectGroup) selectedEnt).RootPart.EveryoneMask; + item.inventoryBasePermissions = ((SceneObjectGroup) selectedEnt).RootPart.BaseMask; + item.inventoryCurrentPermissions = ((SceneObjectGroup) selectedEnt).RootPart.OwnerMask; userInfo.AddItem(remoteClient.AgentId, item); remoteClient.SendInventoryItemCreateUpdate(item); @@ -730,20 +733,20 @@ namespace OpenSim.Region.Environment.Scenes //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) //{ - //PrimitiveBaseShape pbs = rootPart.Shape; - //rootPart.PhysActor = PhysicsScene.AddPrimShape( - //rootPart.Name, - //pbs, - //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), UsePhysics); - - // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - - // } + //PrimitiveBaseShape pbs = rootPart.Shape; + //rootPart.PhysActor = PhysicsScene.AddPrimShape( + //rootPart.Name, + //pbs, + //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), UsePhysics); + + // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); + + // } rootPart.ScheduleFullUpdate(); } } -} +} \ 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 6a7c266..999b70f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -29,8 +29,6 @@ using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.UserManagement; -using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -45,7 +43,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, float south, float east, + public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, + float south, float east, IClientAPI remoteUser) { // Do a permissions check before allowing terraforming. @@ -157,7 +156,7 @@ namespace OpenSim.Region.Environment.Scenes } } } - + public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query) { //EventManager.TriggerAvatarPickerRequest(); @@ -166,13 +165,14 @@ namespace OpenSim.Region.Environment.Scenes AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query); AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); - AvatarPickerReplyPacket.DataBlock[] searchData = new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; + AvatarPickerReplyPacket.DataBlock[] searchData = + new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); agentData.AgentID = avatarID; agentData.QueryID = RequestID; replyPacket.AgentData = agentData; - byte[] bytes = new byte[AvatarResponses.Count * 32]; + byte[] bytes = new byte[AvatarResponses.Count*32]; int i = 0; foreach (AvatarPickerAvatar item in AvatarResponses) @@ -180,10 +180,9 @@ namespace OpenSim.Region.Environment.Scenes LLUUID translatedIDtem = item.AvatarID; searchData[i] = new AvatarPickerReplyPacket.DataBlock(); searchData[i].AvatarID = translatedIDtem; - searchData[i].FirstName = Helpers.StringToField((string)item.firstName); - searchData[i].LastName = Helpers.StringToField((string)item.lastName); + searchData[i].FirstName = Helpers.StringToField((string) item.firstName); + searchData[i].LastName = Helpers.StringToField((string) item.lastName); i++; - } if (AvatarResponses.Count == 0) { @@ -193,4 +192,4 @@ namespace OpenSim.Region.Environment.Scenes client.SendAvatarPickerReply(replyPacket); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 0144c4c..c0fda61 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -27,27 +27,28 @@ */ using System; using System.Collections.Generic; -using System.IO; -using System.Net; +using System.Drawing; +using System.Drawing.Imaging; using System.Threading; using System.Timers; -using System.Xml; using Axiom.Math; using libsecondlife; +using libsecondlife.Packets; +using OpenJPEGNet; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Region.Environment.LandManagement; using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Modules; using OpenSim.Region.Environment.Scenes.Scripting; -using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; using OpenSim.Region.Terrain; -using Timer = System.Timers.Timer; +using Caps=OpenSim.Region.Capabilities.Caps; +using Image=System.Drawing.Image; +using Timer=System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { @@ -56,6 +57,7 @@ namespace OpenSim.Region.Environment.Scenes public partial class Scene : SceneBase { #region Fields + protected Timer m_heartbeatTimer = new Timer(); protected Timer m_restartWaitTimer = new Timer(); @@ -88,7 +90,7 @@ namespace OpenSim.Region.Environment.Scenes protected SceneCommunicationService m_sceneGridService; protected SceneXmlLoader m_sceneXmlLoader; - protected Dictionary m_capsHandlers = new Dictionary(); + protected Dictionary m_capsHandlers = new Dictionary(); protected BaseHttpServer httpListener; protected Dictionary Modules = new Dictionary(); @@ -122,6 +124,7 @@ namespace OpenSim.Region.Environment.Scenes private int m_update_terrain = 50; private int m_update_land = 1; private int m_update_avatars = 1; + #endregion #region Properties @@ -145,6 +148,7 @@ namespace OpenSim.Region.Environment.Scenes set { m_innerScene.PhysicsScene = value; } get { return (m_innerScene.PhysicsScene); } } + // This gets locked so things stay thread safe. public object SyncRoot { @@ -204,7 +208,8 @@ namespace OpenSim.Region.Environment.Scenes #region Constructors - public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, + public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, + CommunicationsManager commsMan, SceneCommunicationService sceneGridService, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SendTasksToChild) { @@ -230,9 +235,11 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager = new LandManager(this, m_regInfo); //Bind Storage Manager functions to some land manager functions for this scene - EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); - EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); - + EventManager.OnLandObjectAdded += + new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); + EventManager.OnLandObjectRemoved += + new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); + m_estateManager = new EstateManager(this, m_regInfo); m_permissionManager = permissionManager; @@ -258,7 +265,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneObjects = new Dictionary(); MainLog.Instance.Verbose("SCENE", "Creating LandMap"); - Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY); + Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); ScenePresence.LoadAnims(); @@ -276,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes protected virtual void RegisterDefaultSceneEvents() { m_eventManager.OnParcelPrimCountAdd += m_LandManager.addPrimToLandPrimCounts; - m_eventManager.OnParcelPrimCountUpdate += this.addPrimsToParcelCounts; + m_eventManager.OnParcelPrimCountUpdate += addPrimsToParcelCounts; m_eventManager.OnPermissionError += SendPermissionAlert; } @@ -295,68 +302,65 @@ namespace OpenSim.Region.Environment.Scenes if (RegionInfo.RegionHandle != otherRegion.RegionHandle) { - for (int i = 0; i < m_neighbours.Count; i++) + for (int i = 0; i < m_neighbours.Count; i++) + { + // The purpose of this loop is to re-update the known neighbors + // when another region comes up on top of another one. + // The latest region in that location ends up in the + // 'known neighbors list' + // Additionally, the commFailTF property gets reset to false. + if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) { - // The purpose of this loop is to re-update the known neighbors - // when another region comes up on top of another one. - // The latest region in that location ends up in the - // 'known neighbors list' - // Additionally, the commFailTF property gets reset to false. - if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) + lock (m_neighbours) { - lock (m_neighbours) - { - m_neighbours[i] = otherRegion; - } + m_neighbours[i] = otherRegion; } } + } - // If the value isn't in the neighbours, add it. - // If the RegionInfo isn't exact but is for the same XY World location, - // then the above loop will fix that. + // If the value isn't in the neighbours, add it. + // If the RegionInfo isn't exact but is for the same XY World location, + // then the above loop will fix that. - if (!(m_neighbours.Contains(otherRegion))) + if (!(m_neighbours.Contains(otherRegion))) + { + lock (m_neighbours) { - lock (m_neighbours) - { - m_neighbours.Add(otherRegion); - } + m_neighbours.Add(otherRegion); } - if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) + } + if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && + (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) { try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - InformClientOfNeighbor(agent, otherRegion); - } - } - - ); + { + // If agent is a root agent. + if (!agent.IsChildAgent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + InformClientOfNeighbor(agent, otherRegion); + } + } + ); } - catch (System.NullReferenceException) + catch (NullReferenceException) { // This means that we're not booted up completely yet. // This shouldn't happen too often anymore. - MainLog.Instance.Error("SCENE", "Couldn't inform client of regionup because we got a null reference exception"); + MainLog.Instance.Error("SCENE", + "Couldn't inform client of regionup because we got a null reference exception"); } } else { - MainLog.Instance.Verbose("INTERGRID", "Got notice about far away Region: " + otherRegion.RegionName.ToString() + - " at (" + otherRegion.RegionLocX.ToString() + ", " + otherRegion.RegionLocY.ToString() + ")" ); + MainLog.Instance.Verbose("INTERGRID", + "Got notice about far away Region: " + otherRegion.RegionName.ToString() + + " at (" + otherRegion.RegionLocX.ToString() + ", " + + otherRegion.RegionLocY.ToString() + ")"); } - - - - } return true; } @@ -379,11 +383,11 @@ namespace OpenSim.Region.Environment.Scenes { // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() m_restartTimer.Interval = 15000; - m_incrementsof15seconds = (int)seconds / 15; + m_incrementsof15seconds = (int) seconds/15; m_RestartTimerCounter = 0; m_restartTimer.AutoReset = true; m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); - MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds / 60) + " minutes"); + MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds/60) + " minutes"); m_restartTimer.Start(); SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes"); } @@ -399,7 +403,8 @@ namespace OpenSim.Region.Environment.Scenes if (m_RestartTimerCounter <= m_incrementsof15seconds) { if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) - SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter) * 15) + " seconds"); + SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) + + " seconds"); } else { @@ -432,21 +437,19 @@ namespace OpenSim.Region.Environment.Scenes { try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - InformClientOfNeighbor(agent, region); - } - } - - ); + { + // If agent is a root agent. + if (!agent.IsChildAgent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + InformClientOfNeighbor(agent, region); + } + } + ); } - catch (System.NullReferenceException) + catch (NullReferenceException) { // This means that we're not booted up completely yet. // This shouldn't happen too often anymore. @@ -464,24 +467,22 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn("SCENE", "Closing down the single simulator: " + RegionInfo.RegionName); // Kick all ROOT agents with the message, 'The simulator is going down' ForEachScenePresence(delegate(ScenePresence avatar) - { - if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) - avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); + { + if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) + avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); - if (!avatar.IsChildAgent) - avatar.ControllingClient.Kick("The simulator is going down."); + if (!avatar.IsChildAgent) + avatar.ControllingClient.Kick("The simulator is going down."); - avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task); - }); + avatar.ControllingClient.OutPacket(new DisableSimulatorPacket(), + ThrottleOutPacketType.Task); + }); // Wait here, or the kick messages won't actually get to the agents before the scene terminates. Thread.Sleep(500); // Stop all client threads. - ForEachScenePresence(delegate(ScenePresence avatar) - { - avatar.ControllingClient.Close(true); - }); + ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(true); }); // Stop updating the scene objects and agents. m_heartbeatTimer.Close(); // close the inner scene @@ -509,7 +510,7 @@ namespace OpenSim.Region.Environment.Scenes public void StartTimer() { m_heartbeatTimer.Enabled = true; - m_heartbeatTimer.Interval = (int)(m_timespan * 1000); + m_heartbeatTimer.Interval = (int) (m_timespan*1000); m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); } @@ -555,30 +556,30 @@ namespace OpenSim.Region.Environment.Scenes if (m_frame == Int32.MaxValue) m_frame = 0; - if (m_frame % m_update_physics == 0) + if (m_frame%m_update_physics == 0) m_innerScene.UpdatePreparePhysics(); - if (m_frame % m_update_entitymovement == 0) + if (m_frame%m_update_entitymovement == 0) m_innerScene.UpdateEntityMovement(); - if (m_frame % m_update_physics == 0) + if (m_frame%m_update_physics == 0) physicsFPS = m_innerScene.UpdatePhysics( Math.Max(SinceLastFrame.TotalSeconds, m_timespan) ); - if (m_frame % m_update_entities == 0) + if (m_frame%m_update_entities == 0) m_innerScene.UpdateEntities(); - if (m_frame % m_update_events == 0) + if (m_frame%m_update_events == 0) UpdateEvents(); - if (m_frame % m_update_backup == 0) + if (m_frame%m_update_backup == 0) UpdateStorageBackup(); - if (m_frame % m_update_terrain == 0) + if (m_frame%m_update_terrain == 0) UpdateTerrain(); - if (m_frame % m_update_land == 0) + if (m_frame%m_update_land == 0) UpdateLand(); // if (m_frame%m_update_avatars == 0) @@ -592,7 +593,6 @@ namespace OpenSim.Region.Environment.Scenes m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount()); m_statsReporter.SetObjects(m_innerScene.GetTotalObjects()); m_statsReporter.SetActiveObjects(m_innerScene.GetActiveObjects()); - } catch (NotImplementedException) { @@ -606,10 +606,11 @@ namespace OpenSim.Region.Environment.Scenes { updateLock.ReleaseMutex(); - m_timedilation = m_timespan / (float)SinceLastFrame.TotalSeconds; + m_timedilation = m_timespan/(float) SinceLastFrame.TotalSeconds; m_lastupdate = DateTime.Now; } } + //Updates the time in the viewer. private void UpdateInWorldTime() { @@ -631,7 +632,7 @@ namespace OpenSim.Region.Environment.Scenes } } - private void SendSimStatsPackets(libsecondlife.Packets.SimStatsPacket pack) + private void SendSimStatsPackets(SimStatsPacket pack) { List StatSendAgents = GetScenePresences(); foreach (ScenePresence agent in StatSendAgents) @@ -639,11 +640,10 @@ namespace OpenSim.Region.Environment.Scenes if (!agent.IsChildAgent) { agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task); - } } - } + private void UpdateLand() { if (m_LandManager.landPrimCountTainted) @@ -676,7 +676,7 @@ 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)) { client.SendLayerData(x, y, terData); } @@ -724,13 +724,17 @@ namespace OpenSim.Region.Environment.Scenes public void ExportWorldMap(string fileName) { - List mapBlocks = this.CommsManager.GridService.RequestNeighbourMapBlocks((int)(this.RegionInfo.RegionLocX - 9), (int)(this.RegionInfo.RegionLocY - 9), (int)(this.RegionInfo.RegionLocX + 9), (int)(this.RegionInfo.RegionLocY + 9)); + List mapBlocks = + CommsManager.GridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9), + (int) (RegionInfo.RegionLocY - 9), + (int) (RegionInfo.RegionLocX + 9), + (int) (RegionInfo.RegionLocY + 9)); List textures = new List(); - List bitImages = new List(); + List bitImages = new List(); foreach (MapBlockData mapBlock in mapBlocks) { - AssetBase texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); + AssetBase texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true); if (texAsset != null) { @@ -738,7 +742,7 @@ namespace OpenSim.Region.Environment.Scenes } else { - texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); + texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true); if (texAsset != null) { textures.Add(texAsset); @@ -748,22 +752,22 @@ namespace OpenSim.Region.Environment.Scenes foreach (AssetBase asset in textures) { - System.Drawing.Image image = OpenJPEGNet.OpenJPEG.DecodeToImage(asset.Data); + Image image = OpenJPEG.DecodeToImage(asset.Data); bitImages.Add(image); } - System.Drawing.Bitmap mapTexture = new System.Drawing.Bitmap(2560, 2560); - System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mapTexture); - System.Drawing.SolidBrush sea = new System.Drawing.SolidBrush(System.Drawing.Color.DarkBlue); + Bitmap mapTexture = new Bitmap(2560, 2560); + Graphics g = Graphics.FromImage(mapTexture); + SolidBrush sea = new SolidBrush(Color.DarkBlue); g.FillRectangle(sea, 0, 0, 2560, 2560); for (int i = 0; i < mapBlocks.Count; i++) { - ushort x = (ushort)((mapBlocks[i].X - this.RegionInfo.RegionLocX) + 10); - ushort y = (ushort)((mapBlocks[i].Y - this.RegionInfo.RegionLocY) + 10); - g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); + ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10); + ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10); + g.DrawImage(bitImages[i], (x*128), (y*128), 128, 128); } - mapTexture.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); + mapTexture.Save(fileName, ImageFormat.Jpeg); } /// @@ -861,7 +865,7 @@ namespace OpenSim.Region.Environment.Scenes public void loadAllLandObjectsFromStorage() { MainLog.Instance.Verbose("SCENE", "Loading land objects from storage"); - List landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); + List landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); if (landData.Count == 0) { m_LandManager.NoLandDataFromStorage(); @@ -871,7 +875,7 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager.IncomingLandObjectsFromStorage(landData); } } - + #endregion #region Primitives Methods @@ -889,8 +893,8 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); rootPart.ApplySanePermissions(); - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = PhysicsScene.AddPrimShape( rootPart.Name, rootPart.Shape, @@ -931,9 +935,8 @@ namespace OpenSim.Region.Environment.Scenes if (PermissionsMngr.CanRezObject(ownerID, pos)) { - EntityIntersection rayTracing = null; - ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID)); + ScenePresence presence = ((ScenePresence) GetScenePresence(ownerID)); if (presence != null) { Vector3 CameraPosition = presence.CameraPosition; @@ -941,14 +944,13 @@ namespace OpenSim.Region.Environment.Scenes float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd); - Vector3 rayDirection = new Vector3(rayEnd.x / raydistance, rayEnd.y / raydistance, rayEnd.z / raydistance); + Vector3 rayDirection = new Vector3(rayEnd.x/raydistance, rayEnd.y/raydistance, rayEnd.z/raydistance); Ray rezRay = new Ray(CameraPosition, rayDirection); Vector3 RezDirectionFromCamera = rezRay.Direction; rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); - } if ((rayTracing != null) && (rayTracing.HitTF)) @@ -957,7 +959,8 @@ namespace OpenSim.Region.Environment.Scenes // We will rez the object somewhere close to the prim. Better math needed. This is a Stub //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); Vector3 Newpos = rayTracing.ipoint; - Vector3 NewScale = new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); + Vector3 NewScale = + new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); @@ -965,7 +968,7 @@ namespace OpenSim.Region.Environment.Scenes LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); - Quaternion NewRot = LocalRot * ParentRot; + Quaternion NewRot = LocalRot*ParentRot; Vector3 RezPoint = Newpos; @@ -990,8 +993,8 @@ namespace OpenSim.Region.Environment.Scenes //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; } // if not phantom, add to physics - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = PhysicsScene.AddPrimShape( @@ -1007,14 +1010,14 @@ namespace OpenSim.Region.Environment.Scenes } public void AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position, - Tree treeType, bool newTree) + Tree treeType, bool newTree) { PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); treeShape.PathCurve = 16; treeShape.PathEnd = 49900; - treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree; + treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree; treeShape.Scale = scale; - treeShape.State = (byte)treeType; + treeShape.State = (byte) treeType; AddNewPrim(LLUUID.Random(), position, rotation, treeShape); } @@ -1135,7 +1138,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); client.OnParcelAccessListRequest += new ParcelAccessListRequest(m_LandManager.handleParcelAccessRequest); - client.OnParcelAccessListUpdateRequest += new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); + client.OnParcelAccessListUpdateRequest += + new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest; @@ -1157,8 +1161,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; client.OnRezScript += RezScript; - - client.OnRequestTaskInventory += RequestTaskInventory; + + client.OnRequestTaskInventory += RequestTaskInventory; client.OnRemoveTaskItem += RemoveTaskInventory; client.OnUpdateTaskInventory += UpdateTaskInventory; @@ -1216,23 +1220,23 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.removeUserCount(true); } } - catch (System.NullReferenceException) + catch (NullReferenceException) { // We don't know which count to remove it from // Avatar is already disposed :/ } m_eventManager.TriggerOnRemovePresence(agentID); Broadcast(delegate(IClientAPI client) - { - try - { - client.SendKillObject(avatar.RegionHandle, avatar.LocalId); - } - catch (System.NullReferenceException) { - //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. - } - }); + try + { + client.SendKillObject(avatar.RegionHandle, avatar.LocalId); + } + catch (NullReferenceException) + { + //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. + } + }); ForEachScenePresence( delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); @@ -1251,7 +1255,7 @@ namespace OpenSim.Region.Environment.Scenes { avatar.Close(); } - catch (System.NullReferenceException) + catch (NullReferenceException) { //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. } @@ -1263,19 +1267,22 @@ namespace OpenSim.Region.Environment.Scenes // Remove client agent from profile, so new logins will work CommsManager.UserService.clearUserAgent(agentID); } - public override void CloseAllAgents(uint circuitcode) + + public override void CloseAllAgents(uint circuitcode) { // Called by ClientView to kill all circuit codes ClientManager.CloseAllAgents(circuitcode); - } + public void NotifyMyCoarseLocationChange() { ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); } + #endregion #region Entities + /// /// /// @@ -1312,7 +1319,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneGridService.OnCloseAgentConnection += CloseConnection; m_sceneGridService.OnRegionUp += OtherRegionUp; m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; - + m_sceneGridService.KillObject = SendKillObject; } @@ -1321,17 +1328,16 @@ namespace OpenSim.Region.Environment.Scenes /// /// public void UnRegisterReginWithComms() - { - + { m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; m_sceneGridService.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= NewUserConnection; m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; m_sceneGridService.OnCloseAgentConnection -= CloseConnection; - + m_sceneGridService.Close(); } - + /// /// @@ -1344,18 +1350,19 @@ namespace OpenSim.Region.Environment.Scenes { if (agent.CapsPath != "") { - OpenSim.Region.Capabilities.Caps cap = - new OpenSim.Region.Capabilities.Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, + Caps cap = + new Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, agent.CapsPath, agent.AgentID, m_dumpAssetsToFile); - Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + - "/CAPS/" + agent.CapsPath + "0000/"); + Util.SetCapsURL(agent.AgentID, + "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + + "/CAPS/" + agent.CapsPath + "0000/"); cap.RegisterHandlers(); - + cap.AddNewInventoryItem = AddInventoryItem; cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; - + if (m_capsHandlers.ContainsKey(agent.AgentID)) { //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + @@ -1364,7 +1371,7 @@ namespace OpenSim.Region.Environment.Scenes { m_capsHandlers[agent.AgentID] = cap; } - catch (System.Collections.Generic.KeyNotFoundException) + catch (KeyNotFoundException) { // Fix for a potential race condition. m_capsHandlers.Add(agent.AgentID, cap); @@ -1396,10 +1403,10 @@ namespace OpenSim.Region.Environment.Scenes { m_scenePresences[agentID].MakeRootAgent(position, isFlying); } - catch (System.Exception e) + catch (Exception e) { MainLog.Instance.Verbose("SCENE", "Unable to do Agent Crossing."); - MainLog.Instance.Debug("SCENE",e.ToString()); + MainLog.Instance.Debug("SCENE", e.ToString()); } //m_innerScene.SwapRootChildAgent(false); } @@ -1419,11 +1426,11 @@ namespace OpenSim.Region.Environment.Scenes childAgentUpdate.ChildAgentDataUpdate(cAgentData); // Not Implemented: //TODO: Do we need to pass the message on to one of our neighbors? - } } return true; } + /// /// Tell a single agent to disconnect from the region. /// @@ -1445,7 +1452,7 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.removeUserCount(true); } // Tell a single agent to disconnect from the region. - libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); + DisableSimulatorPacket disable = new DisableSimulatorPacket(); presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); } } @@ -1511,7 +1518,8 @@ namespace OpenSim.Region.Environment.Scenes { if (m_scenePresences.ContainsKey(remoteClient.AgentId)) { - m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, position, lookAt, flags); + m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, + position, lookAt, flags); } } @@ -1551,9 +1559,9 @@ namespace OpenSim.Region.Environment.Scenes /// public void RegisterModuleInterface(M mod) { - if (!ModuleInterfaces.ContainsKey(typeof(M))) + if (!ModuleInterfaces.ContainsKey(typeof (M))) { - ModuleInterfaces.Add(typeof(M), mod); + ModuleInterfaces.Add(typeof (M), mod); } } @@ -1563,9 +1571,9 @@ namespace OpenSim.Region.Environment.Scenes /// public T RequestModuleInterface() { - if (ModuleInterfaces.ContainsKey(typeof(T))) + if (ModuleInterfaces.ContainsKey(typeof (T))) { - return (T)ModuleInterfaces[typeof(T)]; + return (T) ModuleInterfaces[typeof (T)]; } else { @@ -1642,7 +1650,7 @@ namespace OpenSim.Region.Environment.Scenes { if (obj is SceneObjectGroup) { - m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj); + m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj); } } } @@ -1650,6 +1658,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Console Commands + #region Alert Methods private void SendPermissionAlert(LLUUID user, string reason) @@ -1692,7 +1701,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, IClientAPI controllingClient) + public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, + IClientAPI controllingClient) { // First check that this is the sim owner if (agentID == RegionInfo.MasterAvatarAssignedUUID) @@ -1736,37 +1746,38 @@ namespace OpenSim.Region.Environment.Scenes if (agentID == kickUserID) { ClientManager.ForEachClient(delegate(IClientAPI controller) - { - ScenePresence p = GetScenePresence(controller.AgentId); - bool childagent = !p.Equals(null) && p.IsChildAgent; - if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? { - controller.Kick(Helpers.FieldToUTF8String(reason)); - - if (childagent) + ScenePresence p = GetScenePresence(controller.AgentId); + bool childagent = !p.Equals(null) && p.IsChildAgent; + if (controller.AgentId != godID && !childagent) + // Do we really want to kick the initiator of this madness? { - m_innerScene.removeUserCount(false); + controller.Kick(Helpers.FieldToUTF8String(reason)); + + if (childagent) + { + m_innerScene.removeUserCount(false); + } + else + { + m_innerScene.removeUserCount(true); + } } - else - { - m_innerScene.removeUserCount(true); - } - } - } ); // This is a bit crude. It seems the client will be null before it actually stops the thread // The thread will kill itself eventually :/ // Is there another way to make sure *all* clients get this 'inter region' message? ClientManager.ForEachClient(delegate(IClientAPI controller) - { - ScenePresence p = GetScenePresence(controller.AgentId); - bool childagent = !p.Equals(null) && p.IsChildAgent; - if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? { - controller.Close(true); + ScenePresence p = GetScenePresence(controller.AgentId); + bool childagent = !p.Equals(null) && p.IsChildAgent; + if (controller.AgentId != godID && !childagent) + // Do we really want to kick the initiator of this madness? + { + controller.Close(true); + } } - } ); } else @@ -1799,7 +1810,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, List permChanges) + public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, + List permChanges) { // Check for spoofing.. since this is permissions we're talking about here! if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) @@ -1879,7 +1891,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); + ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); } } } @@ -1899,7 +1911,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); + SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID); if (part != null) { if (part.Name == cmdparams[0]) @@ -1967,10 +1979,12 @@ namespace OpenSim.Region.Environment.Scenes { m_eventManager.TriggerOnPluginConsole(args); } + public double GetLandHeight(int x, int y) { return Terrain.GetHeight(x, y); } + public LLUUID GetLandOwner(float x, float y) { Land land = LandManager.getLandObject(x, y); @@ -1983,7 +1997,7 @@ namespace OpenSim.Region.Environment.Scenes return land.landData.ownerID; } } - + public LandData GetLandData(float x, float y) { return LandManager.getLandObject(x, y).landData; @@ -2034,6 +2048,7 @@ namespace OpenSim.Region.Environment.Scenes { return m_innerScene.ConvertLocalIDToFullID(localID); } + public void SwapRootAgentCount(bool rootChildChildRootTF) { m_innerScene.SwapRootChildAgent(rootChildChildRootTF); @@ -2108,13 +2123,16 @@ namespace OpenSim.Region.Environment.Scenes // We don't want to try to send messages if there are no avatar. if (!(m_scenePresences.Equals(null))) { - try { - List presenceList = GetScenePresences(); + try + { + List presenceList = GetScenePresences(); foreach (ScenePresence presence in presenceList) { action(presence); } - } catch (Exception e) { + } + catch (Exception e) + { MainLog.Instance.Verbose("BUG", e.ToString()); } } @@ -2181,4 +2199,4 @@ namespace OpenSim.Region.Environment.Scenes #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 35d88eb..fe8f8da 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -26,8 +26,6 @@ * */ using System; -using System.Collections.Generic; -using System.Timers; using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; @@ -43,8 +41,9 @@ namespace OpenSim.Region.Environment.Scenes public event restart OnRestart; #endregion - + #region Fields + private readonly ClientManager m_clientManager = new ClientManager(); public ClientManager ClientManager @@ -92,8 +91,6 @@ namespace OpenSim.Region.Environment.Scenes /// public abstract void Update(); - - #endregion #region Terrain Methods @@ -163,8 +160,8 @@ namespace OpenSim.Region.Environment.Scenes public abstract bool OtherRegionUp(RegionInfo thisRegion); - #endregion + #region Shutdown /// @@ -184,4 +181,4 @@ namespace OpenSim.Region.Environment.Scenes #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index b184af2..3942397 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -29,11 +29,10 @@ using System; using System.Collections.Generic; using System.Net; -using System.Text; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -52,7 +51,7 @@ namespace OpenSim.Region.Environment.Scenes public event PrimCrossing OnPrimCrossingIntoRegion; public event RegionUp OnRegionUp; public event ChildAgentUpdate OnChildAgentUpdate; - + public KillObjectDelegate KillObject; public string _debugRegionName = ""; @@ -60,10 +59,7 @@ namespace OpenSim.Region.Environment.Scenes public string debugRegionName { get { return _debugRegionName; } - set - { - _debugRegionName = value; - } + set { _debugRegionName = value; } } public SceneCommunicationService(CommunicationsManager commsMan) @@ -90,7 +86,6 @@ namespace OpenSim.Region.Environment.Scenes regionCommsHost.OnCloseAgentConnection += CloseConnection; regionCommsHost.OnRegionUp += newRegionUp; regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; - } else { @@ -102,7 +97,6 @@ namespace OpenSim.Region.Environment.Scenes { if (regionCommsHost != null) { - regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; regionCommsHost.OnRegionUp -= newRegionUp; regionCommsHost.OnExpectUser -= NewUserConnection; @@ -115,6 +109,7 @@ namespace OpenSim.Region.Environment.Scenes } #region CommsManager Event handlers + /// /// /// @@ -139,6 +134,7 @@ namespace OpenSim.Region.Environment.Scenes } return true; } + protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { if (OnChildAgentUpdate != null) @@ -155,6 +151,7 @@ namespace OpenSim.Region.Environment.Scenes OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); } } + protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { if (OnPrimCrossingIntoRegion != null) @@ -174,12 +171,13 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Inform Client of Neighbours + private delegate void InformClientOfNeighbourDelegate( ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); private void InformClientOfNeighbourCompleted(IAsyncResult iar) { - InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; + InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState; icon.EndInvoke(iar); } @@ -215,8 +213,6 @@ namespace OpenSim.Region.Environment.Scenes //blah.Address = region.RemotingAddress; //blah.Port = region.RemotingPort; - - } /// @@ -227,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes { List neighbours = new List(); - //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); for (int i = 0; i < lstneighbours.Count; i++) { // We don't want to keep sending to regions that consistently fail on comms. @@ -245,7 +241,6 @@ namespace OpenSim.Region.Environment.Scenes { for (int i = 0; i < neighbours.Count; i++) { - AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); agent.BaseFolder = LLUUID.Zero; agent.InventoryFolder = LLUUID.Zero; @@ -259,6 +254,7 @@ namespace OpenSim.Region.Environment.Scenes } } } + /// /// This informs a single neighboring region about agent "avatar". /// Calls an asynchronous method to do so.. so it doesn't lag the sim. @@ -278,11 +274,12 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle); private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) { - InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate)iar.AsyncState; + InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState; icon.EndInvoke(iar); } @@ -290,7 +287,8 @@ namespace OpenSim.Region.Environment.Scenes private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle) { MainLog.Instance.Notice("INTERGRID", "Starting to inform neighbors that I'm here"); - bool regionAccepted = m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle); + bool regionAccepted = + m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle); if (regionAccepted) { @@ -301,6 +299,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here"); } } + /// /// Called by scene when region is initialized (not always when it's listening for agents) /// This is an inter-region message that informs the surrounding neighbors that the sim is up. @@ -317,7 +316,6 @@ namespace OpenSim.Region.Environment.Scenes { for (int i = 0; i < neighbours.Count; i++) { - InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; d.BeginInvoke(region, neighbours[i].RegionHandle, @@ -325,9 +323,10 @@ namespace OpenSim.Region.Environment.Scenes d); } } - + //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); } + public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData); /// @@ -340,7 +339,7 @@ namespace OpenSim.Region.Environment.Scenes private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData) { MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent."); - bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle,cAgentData); + bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); if (regionAccepted) { @@ -351,11 +350,13 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Notice("INTERGRID", "Failed sending a neighbor an update about my agent"); } } + private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) { - SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate)iar.AsyncState; + SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate) iar.AsyncState; icon.EndInvoke(iar); } + public void SendChildAgentDataUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { // This assumes that we know what our neighbors are. @@ -363,9 +364,8 @@ namespace OpenSim.Region.Environment.Scenes d.BeginInvoke(regionHandle, cAgentData, SendChildAgentDataUpdateCompleted, d); - } - + /// /// Helper function to request neighbors from grid-comms @@ -401,15 +401,13 @@ namespace OpenSim.Region.Environment.Scenes /// /// public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, - LLVector3 lookAt, uint flags) + LLVector3 lookAt, uint flags) { if (regionHandle == m_regionInfo.RegionHandle) { - avatar.ControllingClient.SendTeleportLocationStart(); avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); avatar.Teleport(position); - } else { @@ -424,20 +422,22 @@ namespace OpenSim.Region.Environment.Scenes agent.child = true; avatar.Close(); m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); - m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false); + m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, + position, false); AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); - avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); + avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), + capsPath); avatar.MakeChildAgent(); if (KillObject != null) { KillObject(avatar.LocalId); } - uint newRegionX = (uint)(regionHandle >> 40); - uint newRegionY = (((uint)(regionHandle)) >> 8); - uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); - uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); - if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) + uint newRegionX = (uint) (regionHandle >> 40); + uint newRegionY = (((uint) (regionHandle)) >> 8); + uint oldRegionX = (uint) (m_regionInfo.RegionHandle >> 40); + uint oldRegionY = (((uint) (m_regionInfo.RegionHandle)) >> 8); + if (Util.fast_distance2d((int) (newRegionX - oldRegionX), (int) (newRegionY - oldRegionY)) > 3) { CloseChildAgentConnections(avatar); } @@ -465,7 +465,8 @@ namespace OpenSim.Region.Environment.Scenes { foreach (ulong regionHandle in presence.KnownChildRegions) { - m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, presence.ControllingClient.AgentId); + m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, + presence.ControllingClient.AgentId); presence.RemoveNeighbourRegion(regionHandle); } } @@ -474,6 +475,5 @@ namespace OpenSim.Region.Environment.Scenes { return m_commsProvider.GridService.GetGridSettings(); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 9c8c62b..a6a8fb6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -105,7 +105,7 @@ namespace OpenSim.Region.Environment.Scenes public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID); public event LandObjectAdded OnLandObjectAdded; - + public delegate void LandObjectRemoved(LLUUID globalID); public event LandObjectRemoved OnLandObjectRemoved; @@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes public void TriggerOnClientMovement(ScenePresence avatar) { - if(OnClientMovement != null) + if (OnClientMovement != null) OnClientMovement(avatar); } @@ -223,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes { if (OnSceneGroupMove != null) { - return OnSceneGroupMove(groupID, delta); + return OnSceneGroupMove(groupID, delta); } return true; } @@ -236,13 +236,14 @@ namespace OpenSim.Region.Environment.Scenes } } - public void TriggerLandObjectAdded(Land newParcel,LLUUID regionID) + public void TriggerLandObjectAdded(Land newParcel, LLUUID regionID) { if (OnLandObjectAdded != null) { OnLandObjectAdded(newParcel, regionID); } } + public void TriggerLandObjectRemoved(LLUUID globalID) { if (OnLandObjectRemoved != null) @@ -250,10 +251,11 @@ namespace OpenSim.Region.Environment.Scenes OnLandObjectRemoved(globalID); } } + public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel) { //triggerLandObjectRemoved(localParcelID); - TriggerLandObjectAdded(newParcel,newParcel.m_scene.RegionInfo.RegionID); + TriggerLandObjectAdded(newParcel, newParcel.m_scene.RegionInfo.RegionID); } public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID) diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index e822874..1eac61b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -84,7 +84,6 @@ namespace OpenSim.Region.Environment.Scenes { if (m_localScenes[i].Equals(cscene)) { - m_localScenes[i].Close(); } } @@ -99,7 +98,8 @@ namespace OpenSim.Region.Environment.Scenes public void HandleRestart(RegionInfo rdata) { - MainLog.Instance.Error("SCENEMANAGER", "Got Restart message for region:" + rdata.RegionName +" Sending up to main"); + MainLog.Instance.Error("SCENEMANAGER", + "Got Restart message for region:" + rdata.RegionName + " Sending up to main"); int RegionSceneElement = -1; for (int i = 0; i < m_localScenes.Count; i++) { @@ -127,7 +127,6 @@ namespace OpenSim.Region.Environment.Scenes for (int i = 0; i < m_localScenes.Count; i++) { - if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) { // Inform other regions to tell their avatar about me @@ -223,7 +222,7 @@ namespace OpenSim.Region.Environment.Scenes { ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); }); } - + public void HandleAlertCommandOnCurrentScene(string[] cmdparams) { ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); @@ -423,4 +422,4 @@ namespace OpenSim.Region.Environment.Scenes m_localScenes.ForEach(action); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 20d596a..5b74c9b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Text; using System.Xml; @@ -38,7 +39,6 @@ using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Physics.Manager; -using System.Drawing; namespace OpenSim.Region.Environment.Scenes { @@ -74,11 +74,13 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_rootPart.RotationOffset; } } + public LLUUID GroupID { get { return m_rootPart.GroupID; } set { m_rootPart.GroupID = value; } } + /// /// /// @@ -242,7 +244,7 @@ namespace OpenSim.Region.Environment.Scenes part.ParentID = 0; part.LinkNum = 0; m_parts.Add(part.UUID, part); - + SetPartAsRoot(part); RegionHandle = regionHandle; @@ -295,7 +297,6 @@ namespace OpenSim.Region.Environment.Scenes sr.Close(); - m_rootPart.LocalID = m_scene.PrimIDAllocate(); m_rootPart.ParentID = 0; m_rootPart.RegionHandle = m_regionHandle; @@ -376,9 +377,10 @@ namespace OpenSim.Region.Environment.Scenes foreach (SceneObjectPart part in m_parts.Values) { - - Vector3 partPosition = new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); - Quaternion parentrotation = new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z); + Vector3 partPosition = + new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); + Quaternion parentrotation = + new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z); // Telling the prim to raytrace. EntityIntersection inter = part.TestIntersection(hRay, parentrotation); @@ -389,14 +391,11 @@ namespace OpenSim.Region.Environment.Scenes float idist = 256f; - - if (inter.HitTF) { // We need to find the closest prim to return to the testcaller along the ray if (inter.distance < idist) { - idist = inter.distance; returnresult.HitTF = true; returnresult.ipoint = inter.ipoint; @@ -405,15 +404,11 @@ namespace OpenSim.Region.Environment.Scenes returnresult.distance = inter.distance; } } - - } return returnresult; - } - /// /// /// @@ -524,7 +519,7 @@ namespace OpenSim.Region.Environment.Scenes /// public SceneObjectGroup Copy(LLUUID cAgentID, LLUUID cGroupID) { - SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); + SceneObjectGroup dupe = (SceneObjectGroup) MemberwiseClone(); dupe.m_parts = new Dictionary(); dupe.m_parts.Clear(); //dupe.OwnerID = AgentID; @@ -549,9 +544,8 @@ namespace OpenSim.Region.Environment.Scenes 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), - dupe.RootPart.PhysActor.IsPhysical); + dupe.RootPart.PhysActor.IsPhysical); dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); - } // Now we've made a copy that replaces this one, we need to // switch the owner to the person who did the copying @@ -559,8 +553,8 @@ namespace OpenSim.Region.Environment.Scenes // So, we have to make a copy of this one, set it in it's place then set the owner on this one SetRootPartOwner(m_rootPart, cAgentID, cGroupID); - - + + m_rootPart.ScheduleFullUpdate(); List partList = new List(m_parts.Values); @@ -571,7 +565,6 @@ namespace OpenSim.Region.Environment.Scenes dupe.CopyPart(part, OwnerID, GroupID); SetPartOwner(part, cAgentID, cGroupID); part.ScheduleFullUpdate(); - } } dupe.UpdateParentIDs(); @@ -601,7 +594,7 @@ namespace OpenSim.Region.Environment.Scenes part.OwnerID = cAgentID; part.GroupID = cGroupID; - + if (part.OwnerID != cAgentID) { // Apply Next Owner Permissions if we're not bypassing permissions @@ -637,6 +630,7 @@ namespace OpenSim.Region.Environment.Scenes m_parts.Add(part.UUID, part); } } + /// /// /// @@ -666,8 +660,8 @@ namespace OpenSim.Region.Environment.Scenes objPropDB.Description = Helpers.StringToField(RootPart.Description); objPropFamilyPack.ObjectData = objPropDB; remoteClient.OutPacket(objPropFamilyPack, ThrottleOutPacketType.Task); - } + public void SetPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) { part.OwnerID = cAgentID; @@ -884,12 +878,12 @@ namespace OpenSim.Region.Environment.Scenes Quaternion parentRot = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); - axPos = parentRot.Inverse() * axPos; + 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 newRot = parentRot.Inverse()*oldRot; linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); linkPart.ParentID = m_rootPart.LocalID; linkPart.LinkNum = m_parts.Count; @@ -949,7 +943,7 @@ namespace OpenSim.Region.Environment.Scenes linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z); - axPos = parentRot * axPos; + axPos = parentRot*axPos; linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; linkPart.OffsetPosition = new LLVector3(0, 0, 0); @@ -960,7 +954,7 @@ namespace OpenSim.Region.Environment.Scenes linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z); - Quaternion newRot = parentRot * oldRot; + Quaternion newRot = parentRot*oldRot; linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); // Add physics information back to delinked part if appropriate @@ -978,7 +972,6 @@ namespace OpenSim.Region.Environment.Scenes linkPart.RotationOffset.Y, linkPart.RotationOffset.Z), m_rootPart.PhysActor.IsPhysical); m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true); - } SceneObjectGroup objectGroup = new SceneObjectGroup(m_scene, m_regionHandle, linkPart); @@ -990,8 +983,8 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Verbose("SCENE", - "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}", - partID, LocalId); + "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}", + partID, LocalId); } } @@ -1008,7 +1001,7 @@ namespace OpenSim.Region.Environment.Scenes 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 - AbsolutePosition; @@ -1018,15 +1011,15 @@ namespace OpenSim.Region.Environment.Scenes 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); - axiomPartRotation = oldGroupRotation * axiomPartRotation; - axiomPartRotation = axiomRootRotation.Inverse() * axiomPartRotation; + axiomPartRotation = oldGroupRotation*axiomPartRotation; + axiomPartRotation = axiomRootRotation.Inverse()*axiomPartRotation; part.RotationOffset = new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w); } @@ -1056,12 +1049,12 @@ 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)m_rootPart.CreationDate; + 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)m_rootPart.InventorySerial; + 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; @@ -1155,7 +1148,7 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Warn( - "SCENE", + "SCENE", "Couldn't find part {0} in object group {1} ({2}) to retreive prim inventory", localID, LocalId, UUID); } @@ -1272,10 +1265,8 @@ namespace OpenSim.Region.Environment.Scenes public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF) { SceneObjectPart updatePart = GetChildPart(localID); - updatePart.UpdatePermissions(AgentID,field,localID,mask,addRemTF); + updatePart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); } - - #endregion @@ -1304,9 +1295,8 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z), m_rootPart.PhysActor.IsPhysical); - bool UsePhysics = ((m_rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - } } @@ -1350,11 +1340,10 @@ namespace OpenSim.Region.Environment.Scenes if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { AbsolutePosition = pos; - } //we need to do a terse update even if the move wasn't allowed // so that the position is reset in the client (the object snaps back) - ScheduleGroupForTerseUpdate(); + ScheduleGroupForTerseUpdate(); } /// @@ -1394,7 +1383,7 @@ namespace OpenSim.Region.Environment.Scenes Quaternion partRotation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); - axDiff = partRotation.Inverse() * axDiff; + axDiff = partRotation.Inverse()*axDiff; diff.X = axDiff.x; diff.Y = axDiff.y; diff.Z = axDiff.z; @@ -1496,14 +1485,14 @@ namespace OpenSim.Region.Environment.Scenes 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); Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z); - Quaternion newRot = oldParentRot * primsRot; - newRot = axRot.Inverse() * newRot; + Quaternion newRot = oldParentRot*primsRot; + newRot = axRot.Inverse()*newRot; prim.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); prim.ScheduleTerseUpdate(); } @@ -1736,10 +1725,10 @@ namespace OpenSim.Region.Environment.Scenes public override void SetText(string text, Vector3 color, double alpha) { - Color = Color.FromArgb(0xff - (int)(alpha * 0xff), - (int)(color.x * 0xff), - (int)(color.y * 0xff), - (int)(color.z * 0xff)); + Color = Color.FromArgb(0xff - (int) (alpha*0xff), + (int) (color.x*0xff), + (int) (color.y*0xff), + (int) (color.z*0xff)); Text = text; } @@ -1748,4 +1737,4 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.ApplyPhysics(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index f226150..90a975c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Xml; using System.Xml.Serialization; using Axiom.Math; @@ -38,23 +39,26 @@ using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Physics.Manager; -using System.Drawing; namespace OpenSim.Region.Environment.Scenes { public class SceneObjectPart : IScriptHost { - private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer; - private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner; + private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = + LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer; + + private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = + LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | + LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner; + private const uint OBJNEXT_OWNER = 2147483647; - + private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647; private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647; 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(); public LLUUID LastOwnerID; @@ -72,25 +76,20 @@ namespace OpenSim.Region.Environment.Scenes private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); private LLUUID m_SitTargetAvatar = LLUUID.Zero; - - // Main grid has default permissions as follows // public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER; - public uint NextOwnerMask = OBJNEXT_OWNER; + public uint NextOwnerMask = OBJNEXT_OWNER; public uint GroupMask = (uint) LLObject.ObjectFlags.None; public uint EveryoneMask = (uint) LLObject.ObjectFlags.None; public uint BaseMask = FULL_MASK_PERMISSIONS_OWNER; protected byte[] m_particleSystem = new byte[0]; - [XmlIgnore] - public uint TimeStampFull = 0; - [XmlIgnore] - public uint TimeStampTerse = 0; - [XmlIgnore] - public uint TimeStampLastActivity = 0; // Will be used for AutoReturn + [XmlIgnore] public uint TimeStampFull = 0; + [XmlIgnore] public uint TimeStampTerse = 0; + [XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn /// /// Only used internally to schedule client updates @@ -145,16 +144,16 @@ namespace OpenSim.Region.Environment.Scenes 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 = 0; 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; @@ -168,7 +167,6 @@ 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 { @@ -225,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes if (PhysActor != null) { if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0 - || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) + || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) { m_rotationOffset.X = PhysActor.Orientation.x; m_rotationOffset.Y = PhysActor.Orientation.y; @@ -281,6 +279,7 @@ namespace OpenSim.Region.Environment.Scenes } set { m_velocity = value; } } + public LLVector3 RotationalVelocity { get @@ -351,6 +350,7 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_sitTargetPosition; } } + public Quaternion SitTargetOrientation { get { return m_sitTargetOrientation; } @@ -383,6 +383,7 @@ namespace OpenSim.Region.Environment.Scenes } private int m_linkNum = 0; + public int LinkNum { get { return m_linkNum; } @@ -390,13 +391,14 @@ namespace OpenSim.Region.Environment.Scenes } private byte m_clickAction = 0; + public byte ClickAction { get { return m_clickAction; } set { m_clickAction = value; - this.ScheduleFullUpdate(); + ScheduleFullUpdate(); } } @@ -423,6 +425,7 @@ namespace OpenSim.Region.Environment.Scenes // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out. protected SceneObjectGroup m_parentGroup; + public SceneObjectGroup ParentGroup { get { return m_parentGroup; } @@ -434,7 +437,6 @@ namespace OpenSim.Region.Environment.Scenes set { m_updateFlag = value; } } - #region Constructors /// @@ -469,18 +471,18 @@ namespace OpenSim.Region.Environment.Scenes m_regionHandle = regionHandle; m_parentGroup = parent; - CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; OwnerID = ownerID; CreatorID = OwnerID; LastOwnerID = LLUUID.Zero; UUID = LLUUID.Random(); - LocalID = (uint)(localID); + LocalID = (uint) (localID); Shape = shape; // Todo: Add More Object Parameter from above! OwnershipCost = 0; - ObjectSaleType = (byte)0; + ObjectSaleType = (byte) 0; SalePrice = 0; - Category = (uint)0; + Category = (uint) 0; LastOwnerID = CreatorID; // End Todo: /// GroupPosition = groupPosition; @@ -495,9 +497,9 @@ namespace OpenSim.Region.Environment.Scenes m_folderID = LLUUID.Random(); m_flags = 0; - m_flags |= LLObject.ObjectFlags.Touch | - LLObject.ObjectFlags.AllowInventoryDrop | - LLObject.ObjectFlags.CreateSelected; + m_flags |= LLObject.ObjectFlags.Touch | + LLObject.ObjectFlags.AllowInventoryDrop | + LLObject.ObjectFlags.CreateSelected; ApplySanePermissions(); @@ -520,18 +522,18 @@ namespace OpenSim.Region.Environment.Scenes { m_regionHandle = regionHandle; m_parentGroup = parent; - TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); + TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); CreationDate = creationDate; OwnerID = ownerID; CreatorID = creatorID; LastOwnerID = lastOwnerID; UUID = LLUUID.Random(); - LocalID = (uint)(localID); + LocalID = (uint) (localID); Shape = shape; OwnershipCost = 0; - ObjectSaleType = (byte)0; + ObjectSaleType = (byte) 0; SalePrice = 0; - Category = (uint)0; + Category = (uint) 0; LastOwnerID = CreatorID; OffsetPosition = position; RotationOffset = rotation; @@ -552,18 +554,18 @@ namespace OpenSim.Region.Environment.Scenes /// public static SceneObjectPart FromXml(XmlReader xmlReader) { - XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); - SceneObjectPart newobject = (SceneObjectPart)serializer.Deserialize(xmlReader); + XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); + SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader); return newobject; } public void ApplyPhysics() { - bool isPhysical = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); - bool isPhantom = ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) != 0); + bool isPhysical = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); + bool isPhantom = ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0); bool usePhysics = isPhysical && !isPhantom; - + if (usePhysics) { PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape( @@ -576,101 +578,102 @@ namespace OpenSim.Region.Environment.Scenes RotationOffset.Y, RotationOffset.Z), usePhysics); } - DoPhysicsPropertyUpdate(usePhysics, true); + DoPhysicsPropertyUpdate(usePhysics, true); } + public void ApplyNextOwnerPermissions() { BaseMask = NextOwnerMask; OwnerMask = NextOwnerMask; } + public void ApplySanePermissions() { // These are some flags that The OwnerMask should never have - OwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Physics; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Touch; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary; - OwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - OwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - OwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - OwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Money; - OwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - OwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - OwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - - + OwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Physics; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Phantom; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Scripted; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Touch; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Temporary; + OwnerMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + OwnerMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + OwnerMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + OwnerMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Money; + OwnerMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + OwnerMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + OwnerMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + + // These are some flags that the next owner mask should never have - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Physics; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Touch; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Money; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Physics; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Phantom; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Scripted; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Touch; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Temporary; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Money; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + // These are some flags that the GroupMask should never have - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - GroupMask &= ~(uint)LLObject.ObjectFlags.Physics; - GroupMask &= ~(uint)LLObject.ObjectFlags.Phantom; - GroupMask &= ~(uint)LLObject.ObjectFlags.Scripted; - GroupMask &= ~(uint)LLObject.ObjectFlags.Touch; - GroupMask &= ~(uint)LLObject.ObjectFlags.Temporary; - GroupMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - GroupMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - GroupMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - GroupMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - GroupMask &= ~(uint)LLObject.ObjectFlags.Money; - GroupMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - GroupMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - GroupMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + GroupMask &= ~(uint) LLObject.ObjectFlags.Physics; + GroupMask &= ~(uint) LLObject.ObjectFlags.Phantom; + GroupMask &= ~(uint) LLObject.ObjectFlags.Scripted; + GroupMask &= ~(uint) LLObject.ObjectFlags.Touch; + GroupMask &= ~(uint) LLObject.ObjectFlags.Temporary; + GroupMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + GroupMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + GroupMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + GroupMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + GroupMask &= ~(uint) LLObject.ObjectFlags.Money; + GroupMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + GroupMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + GroupMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + // These are some flags that EveryoneMask should never have - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Physics; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Phantom; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Scripted; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Touch; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Temporary; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Money; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Physics; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Phantom; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Scripted; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Touch; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Temporary; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Money; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; - // These are some flags that ObjectFlags (m_flags) should never have - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove; + // These are some flags that ObjectFlags (m_flags) should never have + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectYouOfficer; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectCopy; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectModify; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectMove; } /// @@ -679,13 +682,12 @@ 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); } public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot) { - // In this case we're using a sphere with a radius of the largest dimention of the prim // TODO: Change to take shape into account @@ -693,35 +695,34 @@ namespace OpenSim.Region.Environment.Scenes EntityIntersection returnresult = new EntityIntersection(); Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z); - Quaternion qRotation = new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); - + Quaternion qRotation = + new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); - Quaternion worldRotation = (qRotation * parentrot); + Quaternion worldRotation = (qRotation*parentrot); Matrix3 worldRotM = worldRotation.ToRotationMatrix(); - Vector3 rOrigin = iray.Origin; Vector3 rDirection = iray.Direction; // Buidling the first part of the Quadratic equation - Vector3 r2ndDirection = rDirection * rDirection; + Vector3 r2ndDirection = rDirection*rDirection; float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; // Buidling the second part of the Quadratic equation Vector3 tmVal2 = rOrigin - vAbsolutePosition; - Vector3 r2Direction = rDirection * 2.0f; - Vector3 tmVal3 = r2Direction * tmVal2; + Vector3 r2Direction = rDirection*2.0f; + Vector3 tmVal3 = r2Direction*tmVal2; float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z; // Buidling the third part of the Quadratic equation - Vector3 tmVal4 = rOrigin * rOrigin; - Vector3 tmVal5 = vAbsolutePosition * vAbsolutePosition; + Vector3 tmVal4 = rOrigin*rOrigin; + Vector3 tmVal5 = vAbsolutePosition*vAbsolutePosition; - Vector3 tmVal6 = vAbsolutePosition * rOrigin; + Vector3 tmVal6 = vAbsolutePosition*rOrigin; // Set Radius to the largest dimention of the prim @@ -735,21 +736,22 @@ namespace OpenSim.Region.Environment.Scenes //radius = radius; - float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - (2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius))); + float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - + (2.0f*(tmVal6.x + tmVal6.y + tmVal6.z + (radius*radius))); // Yuk Quadradrics.. Solve first - float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3); + float rootsqr = (itestPart2*itestPart2) - (4.0f*itestPart1*itestPart3); if (rootsqr < 0.0f) { // No intersection return returnresult; } - float root = ((-itestPart2) - (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); + float root = ((-itestPart2) - (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f); if (root < 0.0f) { // perform second quadratic root solution - root = ((-itestPart2) + (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); + root = ((-itestPart2) + (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f); // is there any intersection? if (root < 0.0f) @@ -761,7 +763,9 @@ namespace OpenSim.Region.Environment.Scenes // We got an intersection. putting together an EntityIntersection object with the // intersection information - Vector3 ipoint = new Vector3(iray.Origin.x + (iray.Direction.x * root), iray.Origin.y + (iray.Direction.y * root), iray.Origin.z + (iray.Direction.z * root)); + Vector3 ipoint = + new Vector3(iray.Origin.x + (iray.Direction.x*root), iray.Origin.y + (iray.Direction.y*root), + iray.Origin.z + (iray.Direction.z*root)); returnresult.HitTF = true; returnresult.ipoint = ipoint; @@ -775,7 +779,7 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 distanceConvert1 = new LLVector3(iray.Origin.x, iray.Origin.y, iray.Origin.z); LLVector3 distanceConvert2 = new LLVector3(ipoint.x, ipoint.y, ipoint.z); - float distance = (float)Util.GetDistanceTo(distanceConvert1, distanceConvert2); + float distance = (float) Util.GetDistanceTo(distanceConvert1, distanceConvert2); returnresult.distance = distance; @@ -783,7 +787,6 @@ namespace OpenSim.Region.Environment.Scenes } - /// /// /// @@ -797,6 +800,7 @@ namespace OpenSim.Region.Environment.Scenes m_sitTargetPosition = offset; m_sitTargetOrientation = orientation; } + public LLVector3 GetSitTargetPositionLL() { return new LLVector3(m_sitTargetPosition.x, m_sitTargetPosition.y, m_sitTargetPosition.z); @@ -804,13 +808,17 @@ namespace OpenSim.Region.Environment.Scenes public LLQuaternion GetSitTargetOrientationLL() { - return new LLQuaternion( m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z,m_sitTargetOrientation.w); + return + new LLQuaternion(m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z, + m_sitTargetOrientation.w); } // Utility function so the databases don't have to reference axiom.math public void SetSitTargetLL(LLVector3 offset, LLQuaternion orientation) { - if (!(offset.X == 0 && offset.Y == 0 && offset.Z == 0 && (orientation.W == 0 || orientation.W == 1) && orientation.X == 0 && orientation.Y == 0 && orientation.Z == 0)) + if ( + !(offset.X == 0 && offset.Y == 0 && offset.Z == 0 && (orientation.W == 0 || orientation.W == 1) && + orientation.X == 0 && orientation.Y == 0 && orientation.Z == 0)) { m_sitTargetPosition = new Vector3(offset.X, offset.Y, offset.Z); m_sitTargetOrientation = new Quaternion(orientation.W, orientation.X, orientation.Y, orientation.Z); @@ -869,7 +877,7 @@ namespace OpenSim.Region.Environment.Scenes /// public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID) { - SceneObjectPart dupe = (SceneObjectPart)MemberwiseClone(); + SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone(); dupe.m_shape = m_shape.Copy(); dupe.m_regionHandle = m_regionHandle; dupe.UUID = LLUUID.Random(); @@ -896,7 +904,7 @@ namespace OpenSim.Region.Environment.Scenes byte[] extraP = new byte[Shape.ExtraParams.Length]; Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; - bool UsePhysics = ((dupe.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool UsePhysics = ((dupe.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); dupe.DoPhysicsPropertyUpdate(UsePhysics, true); return dupe; @@ -923,7 +931,7 @@ namespace OpenSim.Region.Environment.Scenes { m_parentGroup.HasChanged = true; } - TimeStampFull = (uint)Util.UnixTimeSinceEpoch(); + TimeStampFull = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 2; } @@ -931,11 +939,10 @@ namespace OpenSim.Region.Environment.Scenes { LLObject.ObjectFlags prevflag = m_flags; //uint objflags = m_flags; - if ((ObjectFlags & (uint)flag) == 0) + if ((ObjectFlags & (uint) flag) == 0) { //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString()); m_flags |= flag; - } //uint currflag = (uint)m_flags; //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); @@ -945,11 +952,10 @@ namespace OpenSim.Region.Environment.Scenes public void RemFlag(LLObject.ObjectFlags flag) { LLObject.ObjectFlags prevflag = m_flags; - if ((ObjectFlags & (uint)flag) != 0) + if ((ObjectFlags & (uint) flag) != 0) { //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString()); m_flags &= ~flag; - } //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); //ScheduleFullUpdate(); @@ -966,7 +972,7 @@ namespace OpenSim.Region.Environment.Scenes { m_parentGroup.HasChanged = true; } - TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); + TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 1; } } @@ -1074,7 +1080,7 @@ namespace OpenSim.Region.Environment.Scenes { if (m_inventorySerial > 0) { - client.SendTaskInventory(m_uuid, (short)m_inventorySerial, + client.SendTaskInventory(m_uuid, (short) m_inventorySerial, Helpers.StringToField(m_inventoryFileName)); return true; } @@ -1134,7 +1140,7 @@ namespace OpenSim.Region.Environment.Scenes bool IsTemporary = false; bool IsPhantom = false; bool castsShadows = false; - bool wasUsingPhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool wasUsingPhysics = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); //bool IsLocked = false; int i = 0; @@ -1162,7 +1168,6 @@ namespace OpenSim.Region.Environment.Scenes { DoPhysicsPropertyUpdate(usePhysics, false); } - } else { @@ -1174,9 +1179,6 @@ namespace OpenSim.Region.Environment.Scenes } - - - if (IsPhantom) { AddFlag(LLObject.ObjectFlags.Phantom); @@ -1220,19 +1222,18 @@ namespace OpenSim.Region.Environment.Scenes // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); ScheduleFullUpdate(); } + public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) { - if (PhysActor != null) { if (UsePhysics != PhysActor.IsPhysical || isNew) { - if (PhysActor.IsPhysical) { if (!isNew) - this.ParentGroup.m_scene.RemovePhysicalPrim(1); - + ParentGroup.m_scene.RemovePhysicalPrim(1); + PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; } @@ -1244,7 +1245,7 @@ namespace OpenSim.Region.Environment.Scenes //PhysActor = null; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { //PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape( //Name, @@ -1256,8 +1257,8 @@ namespace OpenSim.Region.Environment.Scenes //RotationOffset.Y, RotationOffset.Z), UsePhysics); if (UsePhysics) { - this.ParentGroup.m_scene.AddPhysicalPrim(1); - + ParentGroup.m_scene.AddPhysicalPrim(1); + PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds += PhysicsOutOfBounds; } @@ -1271,15 +1272,15 @@ namespace OpenSim.Region.Environment.Scenes { m_shape.ExtraParams = new byte[data.Length + 7]; int i = 0; - uint length = (uint)data.Length; + 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); + m_shape.ExtraParams[i++] = (byte) (type%256); + m_shape.ExtraParams[i++] = (byte) ((type >> 8)%256); - 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); + 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(); @@ -1305,7 +1306,7 @@ namespace OpenSim.Region.Environment.Scenes { if (PhysActor != null) { - return new LLVector3(PhysActor.CenterOfMass.X,PhysActor.CenterOfMass.Y,PhysActor.CenterOfMass.Z); + return new LLVector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); } else { @@ -1323,7 +1324,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdateTextureEntry(byte[] textureEntry) { - m_shape.Textures = new LLObject.TextureEntry( textureEntry, 0, textureEntry.Length ); + m_shape.Textures = new LLObject.TextureEntry(textureEntry, 0, textureEntry.Length); ScheduleFullUpdate(); } @@ -1337,20 +1338,20 @@ namespace OpenSim.Region.Environment.Scenes { if (tex.FaceTextures[i] != null) { - tmpcolor = tex.GetFace((uint)i).RGBA; - tmpcolor.A = tmpcolor.A * 255; - tmpcolor.R = tmpcolor.R * 255; - tmpcolor.G = tmpcolor.G * 255; - tmpcolor.B = tmpcolor.B * 255; + tmpcolor = tex.GetFace((uint) i).RGBA; + tmpcolor.A = tmpcolor.A*255; + tmpcolor.R = tmpcolor.R*255; + tmpcolor.G = tmpcolor.G*255; + tmpcolor.B = tmpcolor.B*255; tex.FaceTextures[i].RGBA = tmpcolor; } } tmpcolor = tex.DefaultTexture.RGBA; - tmpcolor.A = tmpcolor.A * 255; - tmpcolor.R = tmpcolor.R * 255; - tmpcolor.G = tmpcolor.G * 255; - tmpcolor.B = tmpcolor.B * 255; - tex.DefaultTexture.RGBA = tmpcolor; + tmpcolor.A = tmpcolor.A*255; + tmpcolor.R = tmpcolor.R*255; + tmpcolor.G = tmpcolor.G*255; + tmpcolor.B = tmpcolor.B*255; + tex.DefaultTexture.RGBA = tmpcolor; UpdateTextureEntry(tex.ToBytes()); } @@ -1416,34 +1417,33 @@ namespace OpenSim.Region.Environment.Scenes // Are we the owner? if (AgentID == OwnerID) { - MainLog.Instance.Verbose("PERMISSIONS", "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + addRemTF.ToString()); - + MainLog.Instance.Verbose("PERMISSIONS", + "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + + addRemTF.ToString()); + //Field 8 = EveryoneMask - if (field == (byte)8) + if (field == (byte) 8) { MainLog.Instance.Verbose("PERMISSIONS", "Left over: " + (OwnerMask - EveryoneMask)); - if (addRemTF == (byte)0) + if (addRemTF == (byte) 0) { //EveryoneMask = (uint)0; EveryoneMask &= ~mask; //EveryoneMask &= ~(uint)57344; - - } else { //EveryoneMask = (uint)0; EveryoneMask |= mask; //EveryoneMask |= (uint)57344; - } //ScheduleFullUpdate(); SendFullUpdateToAllClients(); } //Field 16 = NextownerMask - if (field == (byte)16) + if (field == (byte) 16) { - if (addRemTF == (byte)0) + if (addRemTF == (byte) 0) { NextOwnerMask &= ~mask; } @@ -1453,7 +1453,6 @@ namespace OpenSim.Region.Environment.Scenes } SendFullUpdateToAllClients(); } - } } @@ -1482,7 +1481,8 @@ namespace OpenSim.Region.Environment.Scenes for (int i = 0; i < avatars.Count; i++) { // Ugly reference :( - m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, avatars[i].GenerateClientFlags(this.UUID)); + m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, + avatars[i].GenerateClientFlags(UUID)); } } @@ -1515,19 +1515,19 @@ namespace OpenSim.Region.Environment.Scenes { LLQuaternion lRot; lRot = RotationOffset; - clientFlags &= ~(uint)LLObject.ObjectFlags.CreateSelected; + clientFlags &= ~(uint) LLObject.ObjectFlags.CreateSelected; - if (remoteClient.AgentId == OwnerID) + if (remoteClient.AgentId == OwnerID) { - if ((uint)(m_flags & LLObject.ObjectFlags.CreateSelected) != 0) + if ((uint) (m_flags & LLObject.ObjectFlags.CreateSelected) != 0) { - clientFlags |= (uint)LLObject.ObjectFlags.CreateSelected; + clientFlags |= (uint) LLObject.ObjectFlags.CreateSelected; m_flags &= ~LLObject.ObjectFlags.CreateSelected; } } - byte[] color = new byte[] { m_color.R, m_color.G, m_color.B, m_color.A }; + byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, clientFlags, m_uuid, OwnerID, m_text, color, ParentID, m_particleSystem, lRot, m_clickAction); @@ -1574,26 +1574,28 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 lPos; lPos = OffsetPosition; LLQuaternion mRot = RotationOffset; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, + RotationalVelocity); } } public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) { LLQuaternion mRot = RotationOffset; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, + RotationalVelocity); //System.Console.WriteLine("RVel:" + RotationalVelocity); } } @@ -1603,13 +1605,16 @@ namespace OpenSim.Region.Environment.Scenes public virtual void UpdateMovement() { } + #region Events + public void PhysicsRequestingTerseUpdate() { ScheduleTerseUpdate(); //SendTerseUpdateToAllClients(); } + #endregion public void PhysicsOutOfBounds(PhysicsVector pos) @@ -1626,10 +1631,10 @@ namespace OpenSim.Region.Environment.Scenes public void SetText(string text, Vector3 color, double alpha) { - Color = Color.FromArgb(0xff - (int)(alpha * 0xff), - (int)(color.x * 0xff), - (int)(color.y * 0xff), - (int)(color.z * 0xff)); + Color = Color.FromArgb(0xff - (int) (alpha*0xff), + (int) (color.x*0xff), + (int) (color.y*0xff), + (int) (color.z*0xff)); Text = text; } @@ -1725,7 +1730,6 @@ namespace OpenSim.Region.Environment.Scenes public TaskInventoryItem() { } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 9a937a2..9454de0 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -32,7 +32,6 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Communications; using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; @@ -60,14 +59,14 @@ namespace OpenSim.Region.Environment.Scenes private bool m_setAlwaysRun = false; private Quaternion m_bodyRot; - + public bool IsRestrictedToRegion = false; // Agent moves with a PID controller causing a force to be exerted. private bool m_newForce = false; private bool m_newCoarseLocations = true; private bool m_gotAllObjectsInScene = false; - + // Default AV Height private float m_avHeight = 127.0f; @@ -76,7 +75,7 @@ namespace OpenSim.Region.Environment.Scenes private readonly Vector3[] Dir_Vectors = new Vector3[6]; private LLVector3 lastPhysPos = new LLVector3(); - + // Position of agent's camera in world (region cordinates) protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); @@ -85,17 +84,18 @@ namespace OpenSim.Region.Environment.Scenes protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0); protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0); protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0); - private uint m_AgentControlFlags = (uint)0; + private uint m_AgentControlFlags = (uint) 0; private LLQuaternion m_headrotation = new LLQuaternion(); - private byte m_state = (byte)0; + private byte m_state = (byte) 0; // Agent's Draw distance. protected float m_DrawDistance = 0f; protected AvatarAppearance m_appearance; - private readonly List m_knownChildRegions = new List(); //neighbouring regions we have enabled a child agent in - + private readonly List m_knownChildRegions = new List(); + //neighbouring regions we have enabled a child agent in + /// /// Implemented Control Flags @@ -172,6 +172,7 @@ namespace OpenSim.Region.Environment.Scenes } protected bool m_allowMovement = true; + public bool AllowMovement { get { return m_allowMovement; } @@ -181,8 +182,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager /// - private readonly IClientAPI m_controllingClient; + protected PhysicsActor m_physicsActor; public IClientAPI ControllingClient @@ -228,6 +229,7 @@ namespace OpenSim.Region.Environment.Scenes m_pos = value; } } + /// /// Current Velocity of the avatar. /// @@ -294,6 +296,7 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_knownChildRegions; } } + #endregion #region Constructor(s) @@ -336,7 +339,7 @@ namespace OpenSim.Region.Environment.Scenes public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) : this(client, world, reginfo) { - m_appearance = appearance; + m_appearance = appearance; } private void RegisterToEvents() @@ -366,6 +369,7 @@ namespace OpenSim.Region.Environment.Scenes Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN Dir_Vectors[5] = new Vector3(0, 0, -0.5f); //DOWN_Nudge } + #endregion public void QueuePartForUpdate(SceneObjectPart part) @@ -381,7 +385,7 @@ namespace OpenSim.Region.Environment.Scenes public uint GenerateClientFlags(LLUUID ObjectID) { - return m_scene.PermissionsMngr.GenerateClientFlags(this.m_uuid, ObjectID); + return m_scene.PermissionsMngr.GenerateClientFlags(m_uuid, ObjectID); } public void SendPrimUpdates() @@ -461,6 +465,7 @@ namespace OpenSim.Region.Environment.Scenes } #region Status Methods + /// /// This turns a child agent, into a root agent /// This is called when an agent teleports into a region, or if an @@ -531,6 +536,7 @@ namespace OpenSim.Region.Environment.Scenes public void StopMovement() { } + public void StopFlying() { // It turns out to get the agent to stop flying, you have to feed it stop flying velocities @@ -560,9 +566,11 @@ namespace OpenSim.Region.Environment.Scenes m_knownChildRegions.Remove(regionHandle); } } + #endregion #region Event Handlers + /// /// Sets avatar height in the phyiscs plugin /// @@ -603,7 +611,6 @@ namespace OpenSim.Region.Environment.Scenes /// public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData) { - //if (m_isChildAgent) //{ // // Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); @@ -639,7 +646,7 @@ namespace OpenSim.Region.Environment.Scenes // The Agent's Draw distance setting m_DrawDistance = agentData.AgentData.Far; - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { StandUp(); } @@ -649,7 +656,7 @@ namespace OpenSim.Region.Environment.Scenes return; } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) + if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) { // TODO: This doesn't quite work yet -- probably a parent ID problem // m_parentID = (what should this be?) @@ -672,7 +679,7 @@ namespace OpenSim.Region.Environment.Scenes Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); bool oldflying = PhysicsActor.Flying; - PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + PhysicsActor.Flying = ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); if (PhysicsActor.Flying != oldflying) { update_movementflag = true; @@ -686,23 +693,23 @@ namespace OpenSim.Region.Environment.Scenes if (m_parentID == 0) { - 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 ((m_movementflag & (uint)DCF) == 0) + if ((m_movementflag & (uint) DCF) == 0) { - m_movementflag += (byte)(uint)DCF; + m_movementflag += (byte) (uint) DCF; update_movementflag = true; } } else { - if ((m_movementflag & (uint)DCF) != 0) + if ((m_movementflag & (uint) DCF) != 0) { - m_movementflag -= (byte)(uint)DCF; + m_movementflag -= (byte) (uint) DCF; update_movementflag = true; } } @@ -719,8 +726,9 @@ namespace OpenSim.Region.Environment.Scenes if (m_physicsActor.Flying) { // Are the landing controls requirements filled? - bool controlland = (((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - + bool controlland = (((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || + ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + // Are the collision requirements fulfilled? bool colliding = (m_physicsActor.IsColliding == true); @@ -748,7 +756,6 @@ namespace OpenSim.Region.Environment.Scenes { if (m_parentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); if (part != null) { @@ -757,7 +764,7 @@ namespace OpenSim.Region.Environment.Scenes part.SetAvatarOnSitTarget(LLUUID.Zero); } - m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); m_parentPosition = new LLVector3(); if (m_physicsActor == null) @@ -778,14 +785,14 @@ namespace OpenSim.Region.Environment.Scenes bool autopilot = true; LLVector3 pos = new LLVector3(); - LLQuaternion sitOrientation = new LLQuaternion(0,0,0,1); + LLQuaternion sitOrientation = new LLQuaternion(0, 0, 0, 1); SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); if (part != null) { // TODO: determine position to sit at based on scene geometry; don't trust offset from client // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - + // Is a sit target available? Vector3 avSitOffSet = part.GetSitTargetPosition(); @@ -793,15 +800,17 @@ namespace OpenSim.Region.Environment.Scenes LLUUID avOnTargetAlready = part.GetAvatarOnSitTarget(); bool SitTargetUnOccupied = (!(avOnTargetAlready != LLUUID.Zero)); - bool SitTargetisSet = (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1)); + bool SitTargetisSet = + (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && + avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1)); if (SitTargetisSet && SitTargetUnOccupied) { part.SetAvatarOnSitTarget(UUID); - offset = new LLVector3(avSitOffSet.x,avSitOffSet.y,avSitOffSet.z); - sitOrientation = new LLQuaternion(avSitOrientation.w,avSitOrientation.x,avSitOrientation.y,avSitOrientation.z); + offset = new LLVector3(avSitOffSet.x, avSitOffSet.y, avSitOffSet.z); + sitOrientation = + new LLQuaternion(avSitOrientation.w, avSitOrientation.x, avSitOrientation.y, avSitOrientation.z); autopilot = false; - } @@ -817,43 +826,37 @@ namespace OpenSim.Region.Environment.Scenes if (autopilot) { - if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) { autopilot = false; - + RemoveFromPhysicalScene(); AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight); - } - else + else { - } } else { RemoveFromPhysicalScene(); - - } } // Physactor != null } // part != null - + avatarSitResponse.SitTransform.AutoPilot = autopilot; avatarSitResponse.SitTransform.SitPosition = offset; avatarSitResponse.SitTransform.SitRotation = sitOrientation; remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); - + // This calls HandleAgentSit twice, once from here, and the client calls // HandleAgentSit itself after it gets to the location // It doesn't get to the location until we've moved them there though // which happens in HandleAgentSit :P if (!autopilot) HandleAgentSit(remoteClient, UUID); - } public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset) @@ -863,7 +866,6 @@ namespace OpenSim.Region.Environment.Scenes StandUp(); } - SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); @@ -919,7 +921,6 @@ namespace OpenSim.Region.Environment.Scenes // This may seem stupid, but Our Full updates don't send avatar rotation :P // So we're also sending a terse update (which has avatar rotation) SendTerseUpdateToAllClients(); - } /// @@ -1003,7 +1004,7 @@ namespace OpenSim.Region.Environment.Scenes // We are flying SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); } - else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && + else if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && PhysicsActor.IsColliding) { // Client is pressing the page down button and moving and is colliding with something @@ -1014,7 +1015,8 @@ namespace OpenSim.Region.Environment.Scenes // Client is moving and falling at a velocity greater then 6 meters per unit SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); } - else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) + else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && + (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) { // Client is moving, and colliding and pressing the page up button but isn't flying SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); @@ -1034,7 +1036,7 @@ namespace OpenSim.Region.Environment.Scenes { // Not moving - if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && + if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && PhysicsActor.IsColliding) { // Client pressing the page down button @@ -1045,7 +1047,8 @@ namespace OpenSim.Region.Environment.Scenes // Not colliding and not flying, and we're falling at high speed SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); } - else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) + else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && + (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) { // This is the standing jump SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); @@ -1063,6 +1066,7 @@ namespace OpenSim.Region.Environment.Scenes } } } + /// /// Adds a new movement /// @@ -1075,10 +1079,10 @@ namespace OpenSim.Region.Environment.Scenes } m_rotation = rotation; NewForce newVelocity = new NewForce(); - Vector3 direc = rotation * vec; + Vector3 direc = rotation*vec; direc.Normalize(); - direc *= 0.03f * 128f; + direc *= 0.03f*128f; if (m_physicsActor.Flying) { direc *= 4; @@ -1108,7 +1112,6 @@ namespace OpenSim.Region.Environment.Scenes SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); } } - } newVelocity.X = direc.x; @@ -1173,7 +1176,7 @@ namespace OpenSim.Region.Environment.Scenes { LLVector3 pos = m_pos; LLVector3 vel = Velocity; - LLQuaternion rot=new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); + LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_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); } @@ -1213,7 +1216,8 @@ namespace OpenSim.Region.Environment.Scenes public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) { remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, - LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID); + LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), + m_parentID); } /// @@ -1303,10 +1307,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAnimPack(LLUUID[] animations, int[] seqs) { - m_scene.Broadcast(delegate(IClientAPI client) - { - client.SendAnimations(animations, seqs, m_controllingClient.AgentId); - }); + m_scene.Broadcast( + delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId); }); } /// @@ -1320,6 +1322,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Significant Movement Method + /// /// This checks for a significant movement and sends a courselocationchange update /// @@ -1349,9 +1352,9 @@ namespace OpenSim.Region.Environment.Scenes 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)) { @@ -1411,7 +1414,7 @@ namespace OpenSim.Region.Environment.Scenes } LLVector3 vel = m_velocity; - ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); + ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256)); SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); if (neighbourRegion != null) { @@ -1432,6 +1435,7 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + /// /// This allows the Sim owner the abiility to kick users from their sim currently. /// It tells the client that the agent has permission to do so. @@ -1445,7 +1449,7 @@ namespace OpenSim.Region.Environment.Scenes adb.AgentID = agentID; adb.SessionID = sessionID; // More security - gdb.GodLevel = (byte)100; + gdb.GodLevel = (byte) 100; gdb.Token = token; //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock; respondPacket.GrantData = gdb; @@ -1462,7 +1466,8 @@ namespace OpenSim.Region.Environment.Scenes // m_DrawDistance = cAgentData.drawdistance; m_pos = new LLVector3(cAgentData.Position.x, cAgentData.Position.y, cAgentData.Position.z); - m_CameraCenter = new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z); + m_CameraCenter = + new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z); m_godlevel = cAgentData.godlevel; ControllingClient.SetChildAgentThrottle(cAgentData.throttles); //cAgentData.AVHeight; @@ -1555,6 +1560,7 @@ namespace OpenSim.Region.Environment.Scenes m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; } + // Event called by the physics plugin to tell the avatar about a collision. private void PhysicsCollisionUpdate(EventArgs e) { @@ -1567,4 +1573,4 @@ namespace OpenSim.Region.Environment.Scenes RemoveFromPhysicalScene(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs index aeb9c61..8c4a951 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs @@ -28,17 +28,16 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Xml; using System.IO; -using libsecondlife; +using System.Xml; using Axiom.Math; +using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes { - public class SceneXmlLoader // can move to a module? + public class SceneXmlLoader // can move to a module? { protected InnerScene m_innerScene; protected RegionInfo m_regInfo; @@ -78,8 +77,9 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); // Apply loadOffsets for load/import and move combinations rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && + m_parentScene.m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( rootPart.Name, @@ -91,7 +91,6 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - } primCount++; } @@ -115,7 +114,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); primCount++; } } @@ -152,8 +151,9 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.AddEntityFromStorage(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && + m_parentScene.m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( rootPart.Name, @@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2()); primCount++; } } @@ -188,6 +188,5 @@ namespace OpenSim.Region.Environment.Scenes stream.Close(); file.Close(); } - } -} +} \ 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 294a6c9..d781806 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting 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 d3fdad6..5dbe500 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs @@ -121,4 +121,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting return ret; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index bfdacfe..b183c04 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -27,22 +27,19 @@ */ using System; -using System.Collections.Generic; -using System.Text; using System.Timers; using libsecondlife.Packets; using OpenSim.Framework; -using Timer = System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { public class SimStatsReporter { public delegate void SendStatResult(SimStatsPacket pack); - + public event SendStatResult OnSendStatsResult; - private enum Stats : uint + private enum Stats : uint { TimeDilation = 0, SimFPS = 1, @@ -72,7 +69,7 @@ namespace OpenSim.Region.Environment.Scenes private RegionInfo ReportingRegion; private Timer m_report = new Timer(); - + public SimStatsReporter(RegionInfo regionData) { @@ -93,23 +90,24 @@ namespace OpenSim.Region.Environment.Scenes statpack.Region.RegionY = ReportingRegion.RegionLocY; try { - statpack.Region.RegionFlags = (uint)ReportingRegion.EstateSettings.regionFlags; + statpack.Region.RegionFlags = (uint) ReportingRegion.EstateSettings.regionFlags; } - catch(System.Exception) + catch (Exception) { - statpack.Region.RegionFlags = (uint)0; + statpack.Region.RegionFlags = (uint) 0; } - statpack.Region.ObjectCapacity = (uint)15000; + statpack.Region.ObjectCapacity = (uint) 15000; #region various statistic googly moogly - float simfps = (int)(m_fps * 5); + + float simfps = (int) (m_fps*5); if (simfps > 45) simfps = simfps - (simfps - 45); if (simfps < 0) simfps = 0; - float physfps = (m_pfps / statsUpdatesEveryMS); + float physfps = (m_pfps/statsUpdatesEveryMS); if (physfps > 50) physfps = physfps - (physfps - 50); @@ -120,49 +118,49 @@ namespace OpenSim.Region.Environment.Scenes #endregion sb[0] = new SimStatsPacket.StatBlock(); - sb[0].StatID = (uint)Stats.TimeDilation; + sb[0].StatID = (uint) Stats.TimeDilation; sb[0].StatValue = (m_timeDilation); sb[1] = new SimStatsPacket.StatBlock(); - sb[1].StatID = (uint)Stats.SimFPS; + sb[1].StatID = (uint) Stats.SimFPS; sb[1].StatValue = simfps; sb[2] = new SimStatsPacket.StatBlock(); - sb[2].StatID = (uint)Stats.PhysicsFPS; + sb[2].StatID = (uint) Stats.PhysicsFPS; sb[2].StatValue = physfps; sb[3] = new SimStatsPacket.StatBlock(); - sb[3].StatID = (uint)Stats.AgentUpdates; - sb[3].StatValue = (m_agentUpdates / statsUpdatesEveryMS); + sb[3].StatID = (uint) Stats.AgentUpdates; + sb[3].StatValue = (m_agentUpdates/statsUpdatesEveryMS); sb[4] = new SimStatsPacket.StatBlock(); - sb[4].StatID = (uint)Stats.Agents; + sb[4].StatID = (uint) Stats.Agents; sb[4].StatValue = m_rootAgents; sb[5] = new SimStatsPacket.StatBlock(); - sb[5].StatID = (uint)Stats.ChildAgents; + sb[5].StatID = (uint) Stats.ChildAgents; sb[5].StatValue = m_childAgents; sb[6] = new SimStatsPacket.StatBlock(); - sb[6].StatID = (uint)Stats.TotalPrim; + sb[6].StatID = (uint) Stats.TotalPrim; sb[6].StatValue = m_numPrim; sb[7] = new SimStatsPacket.StatBlock(); - sb[7].StatID = (uint)Stats.ActivePrim; + sb[7].StatID = (uint) Stats.ActivePrim; sb[7].StatValue = m_activePrim; sb[8] = new SimStatsPacket.StatBlock(); - sb[8].StatID = (uint)Stats.InPacketsPerSecond; - sb[8].StatValue = (int)(m_inPacketsPerSecond / statsUpdatesEveryMS); + sb[8].StatID = (uint) Stats.InPacketsPerSecond; + sb[8].StatValue = (int) (m_inPacketsPerSecond/statsUpdatesEveryMS); sb[9] = new SimStatsPacket.StatBlock(); - sb[9].StatID = (uint)Stats.OutPacketsPerSecond; - sb[9].StatValue = (int)(m_outPacketsPerSecond / statsUpdatesEveryMS); + sb[9].StatID = (uint) Stats.OutPacketsPerSecond; + sb[9].StatValue = (int) (m_outPacketsPerSecond/statsUpdatesEveryMS); sb[10] = new SimStatsPacket.StatBlock(); - sb[10].StatID = (uint)Stats.UnAckedBytes; - sb[10].StatValue = (int) (m_unAckedBytes / statsUpdatesEveryMS); - + sb[10].StatID = (uint) Stats.UnAckedBytes; + sb[10].StatValue = (int) (m_unAckedBytes/statsUpdatesEveryMS); + statpack.Stat = sb; if (OnSendStatsResult != null) @@ -181,8 +179,8 @@ namespace OpenSim.Region.Environment.Scenes m_inPacketsPerSecond = 0; m_outPacketsPerSecond = 0; m_unAckedBytes = 0; - } + public void SetTimeDilation(float td) { m_timeDilation = td; @@ -191,47 +189,56 @@ namespace OpenSim.Region.Environment.Scenes if (m_timeDilation < 0) m_timeDilation = 0.0f; - } + public void SetRootAgents(int rootAgents) { m_rootAgents = rootAgents; } + public void SetChildAgents(int childAgents) { m_childAgents = childAgents; } + public void SetObjects(int objects) { m_numPrim = objects; } + public void SetActiveObjects(int objects) { m_activePrim = objects; } + public void AddFPS(int frames) { m_fps += frames; } + public void AddPhysicsFPS(float frames) { m_pfps += frames; } + public void AddAgentUpdates(float numUpdates) { m_agentUpdates += numUpdates; } + public void AddInPackets(int numPackets) { m_inPacketsPerSecond += numPackets; } + public void AddOutPackets(int numPackets) { m_outPacketsPerSecond += numPackets; } + public void AddunAckedBytes(int numBytes) { m_unAckedBytes += numBytes; } } -} +} \ No newline at end of file -- cgit v1.1