diff options
author | Dan Lake | 2010-03-17 06:40:00 -0700 |
---|---|---|
committer | John Hurliman | 2010-03-17 11:21:27 -0700 |
commit | 73e9b0be725a73a489b29f3fe2df236c897ef3b5 (patch) | |
tree | 0d039d61d327e98ed22e4bce30de65c24fc5780d /OpenSim/Region/CoreModules | |
parent | minor logging changes to BaseHttpServer, OSHttpRequest (diff) | |
download | opensim-SC_OLD-73e9b0be725a73a489b29f3fe2df236c897ef3b5.zip opensim-SC_OLD-73e9b0be725a73a489b29f3fe2df236c897ef3b5.tar.gz opensim-SC_OLD-73e9b0be725a73a489b29f3fe2df236c897ef3b5.tar.bz2 opensim-SC_OLD-73e9b0be725a73a489b29f3fe2df236c897ef3b5.tar.xz |
Inconsistent locking of ScenePresence array in SceneGraph. Fixed by eliminating option to return the actual list. Callers can now either request a copy of the array as a new List or ask the SceneGraph to call a delegate function on every ScenePresence. Iteration and locking of the ScenePresences now takes place only within the SceneGraph class.
This patch also applies a fix to Combat/CombatModule.cs which had unlocked iteration of the ScenePresences and inconsistent try/catch around the use of those ScenePresences.
Diffstat (limited to 'OpenSim/Region/CoreModules')
3 files changed, 46 insertions, 67 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 3614915..9df6074 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | |||
@@ -89,60 +89,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
89 | get { return true; } | 89 | get { return true; } |
90 | } | 90 | } |
91 | 91 | ||
92 | private void KillAvatar(uint killerObjectLocalID, ScenePresence DeadAvatar) | 92 | private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar) |
93 | { | 93 | { |
94 | string deadAvatarMessage; | ||
95 | ScenePresence killingAvatar = null; | ||
96 | string killingAvatarMessage; | ||
97 | |||
94 | if (killerObjectLocalID == 0) | 98 | if (killerObjectLocalID == 0) |
95 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You committed suicide!", true); | 99 | deadAvatarMessage = "You committed suicide!"; |
96 | else | 100 | else |
97 | { | 101 | { |
98 | bool foundResult = false; | 102 | // Try to get the avatar responsible for the killing |
99 | string resultstring = String.Empty; | 103 | killingAvatar = deadAvatar.Scene.GetScenePresence(killerObjectLocalID); |
100 | ScenePresence[] allav = DeadAvatar.Scene.GetScenePresences(); | 104 | if (killingAvatar == null) |
101 | try | ||
102 | { | 105 | { |
103 | for (int i = 0; i < allav.Length; i++) | 106 | // Try to get the object which was responsible for the killing |
107 | SceneObjectPart part = deadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID); | ||
108 | if (part == null) | ||
104 | { | 109 | { |
105 | ScenePresence av = allav[i]; | 110 | // Cause of death: Unknown |
106 | 111 | deadAvatarMessage = "You died!"; | |
107 | if (av.LocalId == killerObjectLocalID) | ||
108 | { | ||
109 | av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); | ||
110 | resultstring = av.Firstname + " " + av.Lastname; | ||
111 | foundResult = true; | ||
112 | } | ||
113 | } | 112 | } |
114 | } catch (InvalidOperationException) | 113 | else |
115 | { | ||
116 | |||
117 | } | ||
118 | |||
119 | if (!foundResult) | ||
120 | { | ||
121 | SceneObjectPart part = DeadAvatar.Scene.GetSceneObjectPart(killerObjectLocalID); | ||
122 | if (part != null) | ||
123 | { | 114 | { |
124 | ScenePresence av = DeadAvatar.Scene.GetScenePresence(part.OwnerID); | 115 | // Try to find the avatar wielding the killing object |
125 | if (av != null) | 116 | killingAvatar = deadAvatar.Scene.GetScenePresence(part.OwnerID); |
126 | { | 117 | if (killingAvatar == null) |
127 | av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); | 118 | deadAvatarMessage = String.Format("You impaled yourself on {0} owned by {1}!", part.Name, deadAvatar.Scene.GetUserName(part.OwnerID)); |
128 | resultstring = av.Firstname + " " + av.Lastname; | ||
129 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You got killed by " + resultstring + "!", true); | ||
130 | } | ||
131 | else | 119 | else |
132 | { | 120 | { |
133 | string killer = DeadAvatar.Scene.GetUserName(part.OwnerID); | 121 | killingAvatarMessage = String.Format("You fragged {0}!", deadAvatar.Name); |
134 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true); | 122 | deadAvatarMessage = String.Format("You got killed by {0}!", killingAvatar.Name); |
135 | } | 123 | } |
136 | //DeadAvatar.Scene. part.ObjectOwner | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | DeadAvatar.ControllingClient.SendAgentAlertMessage("You died!", true); | ||
141 | } | 124 | } |
142 | } | 125 | } |
126 | else | ||
127 | { | ||
128 | killingAvatarMessage = String.Format("You fragged {0}!", deadAvatar.Name); | ||
129 | deadAvatarMessage = String.Format("You got killed by {0}!", killingAvatar.Name); | ||
130 | } | ||
143 | } | 131 | } |
144 | DeadAvatar.Health = 100; | 132 | try |
145 | DeadAvatar.Scene.TeleportClientHome(DeadAvatar.UUID, DeadAvatar.ControllingClient); | 133 | { |
134 | deadAvatar.ControllingClient.SendAgentAlertMessage(deadAvatarMessage, true); | ||
135 | if(killingAvatar != null) | ||
136 | killingAvatar.ControllingClient.SendAlertMessage("You fragged " + deadAvatar.Firstname + " " + deadAvatar.Lastname); | ||
137 | } | ||
138 | catch (InvalidOperationException) | ||
139 | { } | ||
140 | |||
141 | deadAvatar.Health = 100; | ||
142 | deadAvatar.Scene.TeleportClientHome(deadAvatar.UUID, deadAvatar.ControllingClient); | ||
146 | } | 143 | } |
147 | 144 | ||
148 | private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) | 145 | private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index b8e013c..c31266c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -87,31 +87,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
87 | 87 | ||
88 | public void SendAlertToUser(string firstName, string lastName, string message, bool modal) | 88 | public void SendAlertToUser(string firstName, string lastName, string message, bool modal) |
89 | { | 89 | { |
90 | ScenePresence[] presenceList = m_scene.GetScenePresences(); | 90 | ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); |
91 | 91 | if(presence != null) | |
92 | for (int i = 0; i < presenceList.Length; i++) | 92 | presence.ControllingClient.SendAgentAlertMessage(message, modal); |
93 | { | ||
94 | ScenePresence presence = presenceList[i]; | ||
95 | |||
96 | if (presence.Firstname == firstName && presence.Lastname == lastName) | ||
97 | { | ||
98 | presence.ControllingClient.SendAgentAlertMessage(message, modal); | ||
99 | break; | ||
100 | } | ||
101 | } | ||
102 | } | 93 | } |
103 | 94 | ||
104 | public void SendGeneralAlert(string message) | 95 | public void SendGeneralAlert(string message) |
105 | { | 96 | { |
106 | ScenePresence[] presenceList = m_scene.GetScenePresences(); | 97 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
107 | |||
108 | for (int i = 0; i < presenceList.Length; i++) | ||
109 | { | 98 | { |
110 | ScenePresence presence = presenceList[i]; | ||
111 | |||
112 | if (!presence.IsChildAgent) | 99 | if (!presence.IsChildAgent) |
113 | presence.ControllingClient.SendAlertMessage(message); | 100 | presence.ControllingClient.SendAlertMessage(message); |
114 | } | 101 | }); |
115 | } | 102 | } |
116 | 103 | ||
117 | public void SendDialogToUser( | 104 | public void SendDialogToUser( |
@@ -179,14 +166,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
179 | public void SendNotificationToUsersInRegion( | 166 | public void SendNotificationToUsersInRegion( |
180 | UUID fromAvatarID, string fromAvatarName, string message) | 167 | UUID fromAvatarID, string fromAvatarName, string message) |
181 | { | 168 | { |
182 | ScenePresence[] presences = m_scene.GetScenePresences(); | 169 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
183 | |||
184 | for (int i = 0; i < presences.Length; i++) | ||
185 | { | 170 | { |
186 | ScenePresence presence = presences[i]; | ||
187 | if (!presence.IsChildAgent) | 171 | if (!presence.IsChildAgent) |
188 | presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); | 172 | presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); |
189 | } | 173 | }); |
190 | } | 174 | } |
191 | 175 | ||
192 | /// <summary> | 176 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index e3bab2d..464d922 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -469,12 +469,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
469 | private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) | 469 | private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) |
470 | { | 470 | { |
471 | // Get a fresh list that will not change as people get teleported away | 471 | // Get a fresh list that will not change as people get teleported away |
472 | ScenePresence[] presences = m_scene.GetScenePresences(); | 472 | List<ScenePresence> presences = m_scene.GetScenePresences(); |
473 | 473 | ||
474 | for (int i = 0; i < presences.Length; i++) | 474 | foreach(ScenePresence p in presences) |
475 | { | 475 | { |
476 | ScenePresence p = presences[i]; | ||
477 | |||
478 | if (p.UUID != senderID) | 476 | if (p.UUID != senderID) |
479 | { | 477 | { |
480 | // make sure they are still there, we could be working down a long list | 478 | // make sure they are still there, we could be working down a long list |