diff options
Bring us up to date.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 133 |
1 files changed, 51 insertions, 82 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 35a8df7..7a86f98 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -124,6 +124,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
124 | 124 | ||
125 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | 125 | protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); |
126 | 126 | ||
127 | public Object AttachmentsSyncLock { get; private set; } | ||
128 | |||
127 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); | 129 | private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>(); |
128 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; | 130 | private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; |
129 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; | 131 | private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; |
@@ -199,7 +201,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
199 | 201 | ||
200 | private float m_health = 100f; | 202 | private float m_health = 100f; |
201 | 203 | ||
202 | protected RegionInfo m_regionInfo; | ||
203 | protected ulong crossingFromRegion; | 204 | protected ulong crossingFromRegion; |
204 | 205 | ||
205 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; | 206 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
@@ -770,23 +771,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
770 | #endregion | 771 | #endregion |
771 | 772 | ||
772 | #region Constructor(s) | 773 | #region Constructor(s) |
773 | 774 | ||
774 | public ScenePresence( | 775 | public ScenePresence( |
775 | IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance, PresenceType type) | 776 | IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) |
776 | { | 777 | { |
778 | AttachmentsSyncLock = new Object(); | ||
779 | |||
777 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 780 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
778 | m_sceneViewer = new SceneViewer(this); | 781 | m_sceneViewer = new SceneViewer(this); |
779 | m_animator = new ScenePresenceAnimator(this); | 782 | m_animator = new ScenePresenceAnimator(this); |
780 | PresenceType = type; | 783 | PresenceType = type; |
781 | m_DrawDistance = world.DefaultDrawDistance; | 784 | m_DrawDistance = world.DefaultDrawDistance; |
782 | m_rootRegionHandle = reginfo.RegionHandle; | 785 | m_rootRegionHandle = world.RegionInfo.RegionHandle; |
783 | m_controllingClient = client; | 786 | m_controllingClient = client; |
784 | m_firstname = m_controllingClient.FirstName; | 787 | m_firstname = m_controllingClient.FirstName; |
785 | m_lastname = m_controllingClient.LastName; | 788 | m_lastname = m_controllingClient.LastName; |
786 | m_name = String.Format("{0} {1}", m_firstname, m_lastname); | 789 | m_name = String.Format("{0} {1}", m_firstname, m_lastname); |
787 | m_scene = world; | 790 | m_scene = world; |
788 | m_uuid = client.AgentId; | 791 | m_uuid = client.AgentId; |
789 | m_regionInfo = reginfo; | ||
790 | m_localId = m_scene.AllocateLocalId(); | 792 | m_localId = m_scene.AllocateLocalId(); |
791 | 793 | ||
792 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | 794 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); |
@@ -1302,7 +1304,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1302 | 1304 | ||
1303 | //m_log.DebugFormat("Completed movement"); | 1305 | //m_log.DebugFormat("Completed movement"); |
1304 | 1306 | ||
1305 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); | 1307 | m_controllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |
1306 | SendInitialData(); | 1308 | SendInitialData(); |
1307 | 1309 | ||
1308 | // Create child agents in neighbouring regions | 1310 | // Create child agents in neighbouring regions |
@@ -3226,8 +3228,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3226 | /// </returns> | 3228 | /// </returns> |
3227 | protected int HaveNeighbor(Cardinals car, ref int[] fix) | 3229 | protected int HaveNeighbor(Cardinals car, ref int[] fix) |
3228 | { | 3230 | { |
3229 | uint neighbourx = m_regionInfo.RegionLocX; | 3231 | uint neighbourx = m_scene.RegionInfo.RegionLocX; |
3230 | uint neighboury = m_regionInfo.RegionLocY; | 3232 | uint neighboury = m_scene.RegionInfo.RegionLocY; |
3231 | 3233 | ||
3232 | int dir = (int)car; | 3234 | int dir = (int)car; |
3233 | 3235 | ||
@@ -3247,8 +3249,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3247 | 3249 | ||
3248 | if (neighbourRegion == null) | 3250 | if (neighbourRegion == null) |
3249 | { | 3251 | { |
3250 | fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx); | 3252 | fix[0] = (int)(m_scene.RegionInfo.RegionLocX - neighbourx); |
3251 | fix[1] = (int)(m_regionInfo.RegionLocY - neighboury); | 3253 | fix[1] = (int)(m_scene.RegionInfo.RegionLocY - neighboury); |
3252 | return dir * (-1); | 3254 | return dir * (-1); |
3253 | } | 3255 | } |
3254 | else | 3256 | else |
@@ -3494,26 +3496,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3494 | catch { } | 3496 | catch { } |
3495 | 3497 | ||
3496 | // Attachment objects | 3498 | // Attachment objects |
3497 | if (m_attachments != null && m_attachments.Count > 0) | 3499 | lock (m_attachments) |
3498 | { | 3500 | { |
3499 | cAgent.AttachmentObjects = new List<ISceneObject>(); | 3501 | if (m_attachments.Count > 0) |
3500 | cAgent.AttachmentObjectStates = new List<string>(); | ||
3501 | // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); | ||
3502 | m_InTransitScriptStates.Clear(); | ||
3503 | foreach (SceneObjectGroup sog in m_attachments) | ||
3504 | { | 3502 | { |
3505 | // We need to make a copy and pass that copy | 3503 | cAgent.AttachmentObjects = new List<ISceneObject>(); |
3506 | // because of transfers withn the same sim | 3504 | cAgent.AttachmentObjectStates = new List<string>(); |
3507 | ISceneObject clone = sog.CloneForNewScene(); | 3505 | // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); |
3508 | // Attachment module assumes that GroupPosition holds the offsets...! | 3506 | m_InTransitScriptStates.Clear(); |
3509 | ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; | 3507 | |
3510 | ((SceneObjectGroup)clone).IsAttachment = false; | 3508 | foreach (SceneObjectGroup sog in m_attachments) |
3511 | cAgent.AttachmentObjects.Add(clone); | 3509 | { |
3512 | string state = sog.GetStateSnapshot(); | 3510 | // We need to make a copy and pass that copy |
3513 | cAgent.AttachmentObjectStates.Add(state); | 3511 | // because of transfers withn the same sim |
3514 | m_InTransitScriptStates.Add(state); | 3512 | ISceneObject clone = sog.CloneForNewScene(); |
3515 | // Let's remove the scripts of the original object here | 3513 | // Attachment module assumes that GroupPosition holds the offsets...! |
3516 | sog.RemoveScriptInstances(true); | 3514 | ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; |
3515 | ((SceneObjectGroup)clone).IsAttachment = false; | ||
3516 | cAgent.AttachmentObjects.Add(clone); | ||
3517 | string state = sog.GetStateSnapshot(); | ||
3518 | cAgent.AttachmentObjectStates.Add(state); | ||
3519 | m_InTransitScriptStates.Add(state); | ||
3520 | // Let's remove the scripts of the original object here | ||
3521 | sog.RemoveScriptInstances(true); | ||
3522 | } | ||
3517 | } | 3523 | } |
3518 | } | 3524 | } |
3519 | } | 3525 | } |
@@ -3931,7 +3937,8 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
3931 | 3937 | ||
3932 | public void Close() | 3938 | public void Close() |
3933 | { | 3939 | { |
3934 | m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); | 3940 | if (!IsChildAgent) |
3941 | m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false); | ||
3935 | 3942 | ||
3936 | lock (m_knownChildRegions) | 3943 | lock (m_knownChildRegions) |
3937 | { | 3944 | { |
@@ -4035,8 +4042,13 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4035 | m_attachments.Clear(); | 4042 | m_attachments.Clear(); |
4036 | } | 4043 | } |
4037 | 4044 | ||
4045 | /// <summary> | ||
4046 | /// This is currently just being done for information. | ||
4047 | /// </summary> | ||
4038 | public bool ValidateAttachments() | 4048 | public bool ValidateAttachments() |
4039 | { | 4049 | { |
4050 | bool validated = true; | ||
4051 | |||
4040 | lock (m_attachments) | 4052 | lock (m_attachments) |
4041 | { | 4053 | { |
4042 | // Validate | 4054 | // Validate |
@@ -4045,21 +4057,22 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4045 | if (gobj == null) | 4057 | if (gobj == null) |
4046 | { | 4058 | { |
4047 | m_log.WarnFormat( | 4059 | m_log.WarnFormat( |
4048 | "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null", Name); | 4060 | "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null. Continuing", Name); |
4049 | return false; | ||
4050 | } | ||
4051 | 4061 | ||
4052 | if (gobj.IsDeleted) | 4062 | validated = false; |
4063 | } | ||
4064 | else if (gobj.IsDeleted) | ||
4053 | { | 4065 | { |
4054 | m_log.WarnFormat( | 4066 | m_log.WarnFormat( |
4055 | "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted", | 4067 | "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted. Continuing", |
4056 | gobj.Name, gobj.UUID, Name); | 4068 | gobj.Name, gobj.UUID, Name); |
4057 | return false; | 4069 | |
4070 | validated = false; | ||
4058 | } | 4071 | } |
4059 | } | 4072 | } |
4060 | } | 4073 | } |
4061 | 4074 | ||
4062 | return true; | 4075 | return validated; |
4063 | } | 4076 | } |
4064 | 4077 | ||
4065 | /// <summary> | 4078 | /// <summary> |
@@ -4091,29 +4104,6 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4091 | } | 4104 | } |
4092 | } | 4105 | } |
4093 | 4106 | ||
4094 | |||
4095 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) | ||
4096 | { | ||
4097 | m_controllingClient = client; | ||
4098 | m_regionInfo = region; | ||
4099 | m_scene = scene; | ||
4100 | |||
4101 | RegisterToEvents(); | ||
4102 | |||
4103 | /* | ||
4104 | AbsolutePosition = client.StartPos; | ||
4105 | |||
4106 | Animations = new AvatarAnimations(); | ||
4107 | Animations.LoadAnims(); | ||
4108 | |||
4109 | m_animations = new List<UUID>(); | ||
4110 | m_animations.Add(Animations.AnimsUUID["STAND"]); | ||
4111 | m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); | ||
4112 | |||
4113 | SetDirectionVectors(); | ||
4114 | */ | ||
4115 | } | ||
4116 | |||
4117 | internal void PushForce(Vector3 impulse) | 4107 | internal void PushForce(Vector3 impulse) |
4118 | { | 4108 | { |
4119 | if (PhysicsActor != null) | 4109 | if (PhysicsActor != null) |
@@ -4141,6 +4131,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4141 | obj.ignoreControls = (ScriptControlled)controls; | 4131 | obj.ignoreControls = (ScriptControlled)controls; |
4142 | obj.eventControls = (ScriptControlled)controls; | 4132 | obj.eventControls = (ScriptControlled)controls; |
4143 | } | 4133 | } |
4134 | |||
4144 | if (pass_on == 1 && accept == 1) | 4135 | if (pass_on == 1 && accept == 1) |
4145 | { | 4136 | { |
4146 | IgnoredControls = ScriptControlled.CONTROL_ZERO; | 4137 | IgnoredControls = ScriptControlled.CONTROL_ZERO; |
@@ -4161,6 +4152,7 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4161 | scriptedcontrols[Script_item_UUID] = obj; | 4152 | scriptedcontrols[Script_item_UUID] = obj; |
4162 | } | 4153 | } |
4163 | } | 4154 | } |
4155 | |||
4164 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); | 4156 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); |
4165 | } | 4157 | } |
4166 | 4158 | ||
@@ -4351,29 +4343,6 @@ if (m_animator.m_jumping) force.Z = m_animator.m_jumpVelocity; // add for ju | |||
4351 | return(new Vector3(x,y,z)); | 4343 | return(new Vector3(x,y,z)); |
4352 | } | 4344 | } |
4353 | 4345 | ||
4354 | public void SaveChangedAttachments() | ||
4355 | { | ||
4356 | // Need to copy this list because DetachToInventoryPrep mods it | ||
4357 | List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(GetAttachments().ToArray()); | ||
4358 | |||
4359 | IAttachmentsModule attachmentsModule = m_scene.AttachmentsModule; | ||
4360 | if (attachmentsModule != null) | ||
4361 | { | ||
4362 | foreach (SceneObjectGroup grp in attachments) | ||
4363 | { | ||
4364 | if (grp.HasGroupChanged) // Resizer scripts? | ||
4365 | { | ||
4366 | grp.IsAttachment = false; | ||
4367 | grp.AbsolutePosition = grp.RootPart.AttachedPos; | ||
4368 | // grp.DetachToInventoryPrep(); | ||
4369 | attachmentsModule.UpdateKnownItem(ControllingClient, | ||
4370 | grp, grp.GetFromItemID(), grp.OwnerID); | ||
4371 | grp.IsAttachment = true; | ||
4372 | } | ||
4373 | } | ||
4374 | } | ||
4375 | } | ||
4376 | |||
4377 | private void CheckLandingPoint(ref Vector3 pos) | 4346 | private void CheckLandingPoint(ref Vector3 pos) |
4378 | { | 4347 | { |
4379 | // Never constrain lures | 4348 | // Never constrain lures |