diff options
27 files changed, 429 insertions, 238 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs index b53806c..1c1afd0 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs | |||
@@ -148,7 +148,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests | |||
148 | 148 | ||
149 | Rest.main.SceneManager.ForEachScene(delegate(Scene s) | 149 | Rest.main.SceneManager.ForEachScene(delegate(Scene s) |
150 | { | 150 | { |
151 | s.ForEachScenePresence(delegate(ScenePresence sp) | 151 | s.ForEachRootScenePresence(delegate(ScenePresence sp) |
152 | { | 152 | { |
153 | if (sp.Firstname == names[0] && sp.Lastname == names[1]) | 153 | if (sp.Firstname == names[0] && sp.Lastname == names[1]) |
154 | { | 154 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index b16ca53..4d8fb90 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
45 | private const int DEBUG_CHANNEL = 2147483647; | 45 | private const int DEBUG_CHANNEL = 2147483647; |
46 | 46 | ||
47 | private bool m_enabled = true; | 47 | private bool m_enabled = true; |
48 | private int m_saydistance = 30; | 48 | private int m_saydistance = 20; |
49 | private int m_shoutdistance = 100; | 49 | private int m_shoutdistance = 100; |
50 | private int m_whisperdistance = 10; | 50 | private int m_whisperdistance = 10; |
51 | private List<Scene> m_scenes = new List<Scene>(); | 51 | private List<Scene> m_scenes = new List<Scene>(); |
@@ -242,7 +242,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
242 | 242 | ||
243 | foreach (Scene s in m_scenes) | 243 | foreach (Scene s in m_scenes) |
244 | { | 244 | { |
245 | s.ForEachScenePresence( | 245 | // This should use ForEachClient, but clients don't have a position. |
246 | // If camera is moved into client, then camera position can be used | ||
247 | s.ForEachRootScenePresence( | ||
246 | delegate(ScenePresence presence) | 248 | delegate(ScenePresence presence) |
247 | { | 249 | { |
248 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | 250 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
@@ -306,12 +308,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
306 | 308 | ||
307 | if (c.Scene != null) | 309 | if (c.Scene != null) |
308 | { | 310 | { |
309 | ((Scene)c.Scene).ForEachRootScenePresence | 311 | ((Scene)c.Scene).ForEachRootClient |
310 | ( | 312 | ( |
311 | delegate(ScenePresence presence) | 313 | delegate(IClientAPI client) |
312 | { | 314 | { |
313 | IClientAPI client = presence.ControllingClient; | ||
314 | |||
315 | // don't forward SayOwner chat from objects to | 315 | // don't forward SayOwner chat from objects to |
316 | // non-owner agents | 316 | // non-owner agents |
317 | if ((c.Type == ChatTypeEnum.Owner) && | 317 | if ((c.Type == ChatTypeEnum.Owner) && |
@@ -321,7 +321,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
321 | 321 | ||
322 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 322 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
323 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 323 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); |
324 | receiverIDs.Add(presence.UUID); | 324 | receiverIDs.Add(client.AgentId); |
325 | } | 325 | } |
326 | ); | 326 | ); |
327 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | 327 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 00556c4..bb2cd1f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -98,9 +98,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
98 | 98 | ||
99 | public void SendGeneralAlert(string message) | 99 | public void SendGeneralAlert(string message) |
100 | { | 100 | { |
101 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 101 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
102 | { | 102 | { |
103 | presence.ControllingClient.SendAlertMessage(message); | 103 | client.SendAlertMessage(message); |
104 | }); | 104 | }); |
105 | } | 105 | } |
106 | 106 | ||
@@ -162,9 +162,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
162 | public void SendNotificationToUsersInRegion( | 162 | public void SendNotificationToUsersInRegion( |
163 | UUID fromAvatarID, string fromAvatarName, string message) | 163 | UUID fromAvatarID, string fromAvatarName, string message) |
164 | { | 164 | { |
165 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 165 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
166 | { | 166 | { |
167 | presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); | 167 | client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); |
168 | }); | 168 | }); |
169 | } | 169 | } |
170 | 170 | ||
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs index 93e65c3..41a80ce 100644 --- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs +++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs | |||
@@ -145,58 +145,39 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
145 | param.Add(mBlock); | 145 | param.Add(mBlock); |
146 | return param; | 146 | return param; |
147 | } | 147 | } |
148 | public void SendProfileToClient(ScenePresence presence) | 148 | |
149 | public void SendProfileToClient(IClientAPI client) | ||
149 | { | 150 | { |
150 | IClientAPI client = presence.ControllingClient; | 151 | SendProfileToClient(client, m_scene.RegionInfo.WindlightSettings); |
151 | if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) | ||
152 | { | ||
153 | if (presence.IsChildAgent == false) | ||
154 | { | ||
155 | List<byte[]> param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings); | ||
156 | client.SendGenericMessage("Windlight", param); | ||
157 | } | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | //We probably don't want to spam chat with this.. probably | ||
162 | //m_log.Debug("[WINDLIGHT]: Module disabled"); | ||
163 | } | ||
164 | } | 152 | } |
165 | public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl) | 153 | |
154 | public void SendProfileToClient(IClientAPI client, RegionLightShareData wl) | ||
166 | { | 155 | { |
167 | IClientAPI client = presence.ControllingClient; | ||
168 | if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) | 156 | if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) |
169 | { | 157 | { |
170 | if (presence.IsChildAgent == false) | 158 | List<byte[]> param = compileWindlightSettings(wl); |
171 | { | 159 | client.SendGenericMessage("Windlight", param); |
172 | List<byte[]> param = compileWindlightSettings(wl); | ||
173 | client.SendGenericMessage("Windlight", param); | ||
174 | } | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | //We probably don't want to spam chat with this.. probably | ||
179 | //m_log.Debug("[WINDLIGHT]: Module disabled"); | ||
180 | } | 160 | } |
181 | } | 161 | } |
162 | |||
182 | private void EventManager_OnMakeRootAgent(ScenePresence presence) | 163 | private void EventManager_OnMakeRootAgent(ScenePresence presence) |
183 | { | 164 | { |
184 | if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) | 165 | if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) |
185 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); | 166 | m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); |
186 | SendProfileToClient(presence); | 167 | SendProfileToClient(presence.ControllingClient); |
187 | } | 168 | } |
169 | |||
188 | private void EventManager_OnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID pUUID) | 170 | private void EventManager_OnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID pUUID) |
189 | { | 171 | { |
190 | ScenePresence Sc; | 172 | IClientAPI client; |
191 | if (m_scene.TryGetScenePresence(pUUID,out Sc)) | 173 | m_scene.TryGetClient(pUUID, out client); |
192 | { | 174 | SendProfileToClient(client, wl); |
193 | SendProfileToClient(Sc,wl); | ||
194 | } | ||
195 | } | 175 | } |
176 | |||
196 | private void EventManager_OnSaveNewWindlightProfile() | 177 | private void EventManager_OnSaveNewWindlightProfile() |
197 | { | 178 | { |
198 | if (m_scene.RegionInfo.WindlightSettings.valid) | 179 | if (m_scene.RegionInfo.WindlightSettings.valid) |
199 | m_scene.ForEachScenePresence(SendProfileToClient); | 180 | m_scene.ForEachRootClient(SendProfileToClient); |
200 | } | 181 | } |
201 | 182 | ||
202 | public void PostInitialise() | 183 | public void PostInitialise() |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index a14a84b..640a60b 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -95,7 +95,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
95 | private Queue m_pendingQ; | 95 | private Queue m_pendingQ; |
96 | private Scene m_scene; | 96 | private Scene m_scene; |
97 | private int m_whisperdistance = 10; | 97 | private int m_whisperdistance = 10; |
98 | private int m_saydistance = 30; | 98 | private int m_saydistance = 20; |
99 | private int m_shoutdistance = 100; | 99 | private int m_shoutdistance = 100; |
100 | 100 | ||
101 | #region IRegionModule Members | 101 | #region IRegionModule Members |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 1471bc9..0067615 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -678,13 +678,14 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
678 | if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) | 678 | if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) |
679 | return; | 679 | return; |
680 | 680 | ||
681 | Scene.ForEachRootScenePresence(delegate(ScenePresence p) | 681 | Scene.ForEachRootClient(delegate(IClientAPI client) |
682 | { | 682 | { |
683 | if (p.UUID != senderID) | 683 | if (client.AgentId != senderID) |
684 | { | 684 | { |
685 | // make sure they are still there, we could be working down a long list | 685 | // make sure they are still there, we could be working down a long list |
686 | // Also make sure they are actually in the region | 686 | // Also make sure they are actually in the region |
687 | if (p != null && !p.IsChildAgent) | 687 | ScenePresence p; |
688 | if(Scene.TryGetScenePresence(client.AgentId, out p)) | ||
688 | { | 689 | { |
689 | if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient)) | 690 | if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient)) |
690 | { | 691 | { |
@@ -952,9 +953,9 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
952 | 953 | ||
953 | public void sendRegionInfoPacketToAll() | 954 | public void sendRegionInfoPacketToAll() |
954 | { | 955 | { |
955 | Scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 956 | Scene.ForEachRootClient(delegate(IClientAPI client) |
956 | { | 957 | { |
957 | HandleRegionInfoRequest(sp.ControllingClient); | 958 | HandleRegionInfoRequest(client); |
958 | }); | 959 | }); |
959 | } | 960 | } |
960 | 961 | ||
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index d2c1289..a838e1e 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs | |||
@@ -488,9 +488,9 @@ namespace OpenSim.Region.CoreModules | |||
488 | 488 | ||
489 | private void SunUpdateToAllClients() | 489 | private void SunUpdateToAllClients() |
490 | { | 490 | { |
491 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 491 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
492 | { | 492 | { |
493 | SunToClient(sp.ControllingClient); | 493 | SunToClient(client); |
494 | }); | 494 | }); |
495 | } | 495 | } |
496 | 496 | ||
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index bea5db1..a488725 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |||
@@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules | |||
435 | m_frameLastUpdateClientArray = m_frame; | 435 | m_frameLastUpdateClientArray = m_frame; |
436 | } | 436 | } |
437 | 437 | ||
438 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 438 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
439 | { | 439 | { |
440 | sp.ControllingClient.SendWindData(windSpeeds); | 440 | client.SendWindData(windSpeeds); |
441 | }); | 441 | }); |
442 | } | 442 | } |
443 | } | 443 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index cd5ac6c..1a3e3bb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1460,12 +1460,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1460 | /// <param name="stats">Stats on the Simulator's performance</param> | 1460 | /// <param name="stats">Stats on the Simulator's performance</param> |
1461 | private void SendSimStatsPackets(SimStats stats) | 1461 | private void SendSimStatsPackets(SimStats stats) |
1462 | { | 1462 | { |
1463 | ForEachRootScenePresence( | 1463 | ForEachRootClient(delegate(IClientAPI client) |
1464 | delegate(ScenePresence agent) | 1464 | { |
1465 | { | 1465 | client.SendSimStats(stats); |
1466 | agent.ControllingClient.SendSimStats(stats); | 1466 | }); |
1467 | } | ||
1468 | ); | ||
1469 | } | 1467 | } |
1470 | 1468 | ||
1471 | /// <summary> | 1469 | /// <summary> |
@@ -4387,35 +4385,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4387 | return m_sceneGraph.GetScenePresence(localID); | 4385 | return m_sceneGraph.GetScenePresence(localID); |
4388 | } | 4386 | } |
4389 | 4387 | ||
4388 | /// <summary> | ||
4389 | /// Returns true if scene presence is a child (no avatar in this scene) | ||
4390 | /// </summary> | ||
4391 | /// <param name="avatarID"></param> | ||
4392 | /// <returns></returns> | ||
4390 | public override bool PresenceChildStatus(UUID avatarID) | 4393 | public override bool PresenceChildStatus(UUID avatarID) |
4391 | { | 4394 | { |
4392 | ScenePresence cp = GetScenePresence(avatarID); | 4395 | ScenePresence sp; |
4393 | 4396 | return TryGetScenePresence(avatarID, out sp) && sp.IsChildAgent; | |
4394 | // FIXME: This is really crap - some logout code is relying on a NullReferenceException to halt its processing | ||
4395 | // This needs to be fixed properly by cleaning up the logout code. | ||
4396 | //if (cp != null) | ||
4397 | // return cp.IsChildAgent; | ||
4398 | |||
4399 | //return false; | ||
4400 | |||
4401 | return cp.IsChildAgent; | ||
4402 | } | 4397 | } |
4403 | 4398 | ||
4404 | /// <summary> | 4399 | /// <summary> |
4405 | /// Performs action on all ROOT (not child) scene presences. | 4400 | /// Performs action on all avatars in the scene (root scene presences) |
4406 | /// This is just a shortcut function since frequently actions only appy to root SPs | 4401 | /// Avatars may be an NPC or a 'real' client. |
4407 | /// </summary> | 4402 | /// </summary> |
4408 | /// <param name="action"></param> | 4403 | /// <param name="action"></param> |
4409 | public void ForEachRootScenePresence(Action<ScenePresence> action) | 4404 | public void ForEachRootScenePresence(Action<ScenePresence> action) |
4410 | { | 4405 | { |
4411 | if(m_sceneGraph != null) | 4406 | if(m_sceneGraph != null) |
4412 | { | 4407 | { |
4413 | m_sceneGraph.ForEachRootScenePresence(action); | 4408 | m_sceneGraph.ForEachAvatar(action); |
4414 | } | 4409 | } |
4415 | } | 4410 | } |
4416 | 4411 | ||
4417 | /// <summary> | 4412 | /// <summary> |
4418 | /// Performs action on all scene presences. | 4413 | /// Performs action on all scene presences (root and child) |
4419 | /// </summary> | 4414 | /// </summary> |
4420 | /// <param name="action"></param> | 4415 | /// <param name="action"></param> |
4421 | public void ForEachScenePresence(Action<ScenePresence> action) | 4416 | public void ForEachScenePresence(Action<ScenePresence> action) |
@@ -4427,25 +4422,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4427 | } | 4422 | } |
4428 | 4423 | ||
4429 | /// <summary> | 4424 | /// <summary> |
4430 | /// Perform the given action for each object | ||
4431 | /// </summary> | ||
4432 | /// <param name="action"></param> | ||
4433 | // public void ForEachObject(Action<SceneObjectGroup> action) | ||
4434 | // { | ||
4435 | // List<SceneObjectGroup> presenceList; | ||
4436 | // | ||
4437 | // lock (m_sceneObjects) | ||
4438 | // { | ||
4439 | // presenceList = new List<SceneObjectGroup>(m_sceneObjects.Values); | ||
4440 | // } | ||
4441 | // | ||
4442 | // foreach (SceneObjectGroup presence in presenceList) | ||
4443 | // { | ||
4444 | // action(presence); | ||
4445 | // } | ||
4446 | // } | ||
4447 | |||
4448 | /// <summary> | ||
4449 | /// Get a group via its UUID | 4425 | /// Get a group via its UUID |
4450 | /// </summary> | 4426 | /// </summary> |
4451 | /// <param name="fullID"></param> | 4427 | /// <param name="fullID"></param> |
@@ -4517,6 +4493,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4517 | return m_sceneGraph.TryGetAvatarByName(avatarName, out avatar); | 4493 | return m_sceneGraph.TryGetAvatarByName(avatarName, out avatar); |
4518 | } | 4494 | } |
4519 | 4495 | ||
4496 | /// <summary> | ||
4497 | /// Perform an action on all clients with an avatar in this scene (root only) | ||
4498 | /// </summary> | ||
4499 | /// <param name="action"></param> | ||
4500 | public void ForEachRootClient(Action<IClientAPI> action) | ||
4501 | { | ||
4502 | ForEachRootScenePresence(delegate(ScenePresence presence) | ||
4503 | { | ||
4504 | action(presence.ControllingClient); | ||
4505 | }); | ||
4506 | } | ||
4507 | |||
4508 | /// <summary> | ||
4509 | /// Perform an action on all clients connected to the region (root and child) | ||
4510 | /// </summary> | ||
4511 | /// <param name="action"></param> | ||
4520 | public void ForEachClient(Action<IClientAPI> action) | 4512 | public void ForEachClient(Action<IClientAPI> action) |
4521 | { | 4513 | { |
4522 | m_clientManager.ForEachSync(action); | 4514 | m_clientManager.ForEachSync(action); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e1fde64..d780fb3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -1265,7 +1265,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1265 | /// This is just a shortcut function since frequently actions only appy to root SPs | 1265 | /// This is just a shortcut function since frequently actions only appy to root SPs |
1266 | /// </summary> | 1266 | /// </summary> |
1267 | /// <param name="action"></param> | 1267 | /// <param name="action"></param> |
1268 | public void ForEachRootScenePresence(Action<ScenePresence> action) | 1268 | public void ForEachAvatar(Action<ScenePresence> action) |
1269 | { | 1269 | { |
1270 | ForEachScenePresence(delegate(ScenePresence sp) | 1270 | ForEachScenePresence(delegate(ScenePresence sp) |
1271 | { | 1271 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 3bfd866..eeb087f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -458,16 +458,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | ForEachCurrentScene( | 458 | ForEachCurrentScene( |
459 | delegate(Scene scene) | 459 | delegate(Scene scene) |
460 | { | 460 | { |
461 | scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) | 461 | scene.ForEachRootClient(delegate(IClientAPI client) |
462 | { | 462 | { |
463 | if (name == null || scenePresence.Name == name) | 463 | if (name == null || client.Name == name) |
464 | { | 464 | { |
465 | m_log.DebugFormat("Packet debug for {0} {1} set to {2}", | 465 | m_log.DebugFormat("Packet debug for {0} {1} set to {2}", |
466 | scenePresence.Firstname, | 466 | client.FirstName, |
467 | scenePresence.Lastname, | 467 | client.LastName, |
468 | newDebug); | 468 | newDebug); |
469 | 469 | ||
470 | scenePresence.ControllingClient.DebugPacketLevel = newDebug; | 470 | client.DebugPacketLevel = newDebug; |
471 | } | 471 | } |
472 | }); | 472 | }); |
473 | } | 473 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6204b4f..84d0e71 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -1473,7 +1473,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1473 | { | 1473 | { |
1474 | SceneObjectPart part = parts[i]; | 1474 | SceneObjectPart part = parts[i]; |
1475 | 1475 | ||
1476 | Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 1476 | Scene.ForEachRootScenePresence(delegate(ScenePresence avatar) |
1477 | { | 1477 | { |
1478 | if (avatar.ParentID == LocalId) | 1478 | if (avatar.ParentID == LocalId) |
1479 | avatar.StandUp(); | 1479 | avatar.StandUp(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 948518a..c8f28c7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -1025,7 +1025,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1025 | public PrimitiveBaseShape Shape | 1025 | public PrimitiveBaseShape Shape |
1026 | { | 1026 | { |
1027 | get { return m_shape; } | 1027 | get { return m_shape; } |
1028 | set { m_shape = value; } | 1028 | set { m_shape = value;} |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | /// <summary> | 1031 | /// <summary> |
@@ -1389,12 +1389,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1389 | /// <param name="AgentID"></param> | 1389 | /// <param name="AgentID"></param> |
1390 | private void SendRootPartPropertiesToClient(UUID AgentID) | 1390 | private void SendRootPartPropertiesToClient(UUID AgentID) |
1391 | { | 1391 | { |
1392 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 1392 | m_parentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
1393 | { | 1393 | { |
1394 | // Ugly reference :( | 1394 | // Ugly reference :( |
1395 | if (avatar.UUID == AgentID) | 1395 | if (client.AgentId == AgentID) |
1396 | { | 1396 | { |
1397 | m_parentGroup.SendPropertiesToClient(avatar.ControllingClient); | 1397 | m_parentGroup.SendPropertiesToClient(client); |
1398 | } | 1398 | } |
1399 | }); | 1399 | }); |
1400 | } | 1400 | } |
@@ -1514,9 +1514,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1514 | if (volume < 0) | 1514 | if (volume < 0) |
1515 | volume = 0; | 1515 | volume = 0; |
1516 | 1516 | ||
1517 | m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 1517 | m_parentGroup.Scene.ForEachRootClient(delegate(IClientAPI client) |
1518 | { | 1518 | { |
1519 | sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); | 1519 | client.SendAttachedSoundGainChange(UUID, (float)volume); |
1520 | }); | 1520 | }); |
1521 | } | 1521 | } |
1522 | 1522 | ||
@@ -2270,7 +2270,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2270 | } | 2270 | } |
2271 | else | 2271 | else |
2272 | { | 2272 | { |
2273 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) | 2273 | m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) |
2274 | { | 2274 | { |
2275 | if (av.LocalId == localId) | 2275 | if (av.LocalId == localId) |
2276 | { | 2276 | { |
@@ -2401,7 +2401,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2401 | } | 2401 | } |
2402 | else | 2402 | else |
2403 | { | 2403 | { |
2404 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) | 2404 | m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) |
2405 | { | 2405 | { |
2406 | if (av.LocalId == localId) | 2406 | if (av.LocalId == localId) |
2407 | { | 2407 | { |
@@ -2524,7 +2524,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2524 | } | 2524 | } |
2525 | else | 2525 | else |
2526 | { | 2526 | { |
2527 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) | 2527 | m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) |
2528 | { | 2528 | { |
2529 | if (av.LocalId == localId) | 2529 | if (av.LocalId == localId) |
2530 | { | 2530 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index aa1c15e..9bf5bea 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1072,7 +1072,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | // send the animations of the other presences to me | 1074 | // send the animations of the other presences to me |
1075 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | 1075 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
1076 | { | 1076 | { |
1077 | if (presence != this) | 1077 | if (presence != this) |
1078 | presence.Animator.SendAnimPackToClient(ControllingClient); | 1078 | presence.Animator.SendAnimPackToClient(ControllingClient); |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index f8120aa..28f04b3 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs | |||
@@ -123,15 +123,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
123 | { | 123 | { |
124 | foreach (Scene scene in m_scenes.Values) | 124 | foreach (Scene scene in m_scenes.Values) |
125 | { | 125 | { |
126 | scene.ForEachScenePresence( | 126 | scene.ForEachRootScenePresence( |
127 | delegate(ScenePresence sp) | 127 | delegate(ScenePresence sp) |
128 | { | 128 | { |
129 | if (sp.ControllingClient is LLClientView && !((LLClientView)sp.ControllingClient).ChildAgentStatus()) | 129 | bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp); |
130 | { | 130 | MainConsole.Instance.OutputFormat( |
131 | bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp); | 131 | "{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); |
132 | MainConsole.Instance.OutputFormat( | ||
133 | "{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); | ||
134 | } | ||
135 | }); | 132 | }); |
136 | } | 133 | } |
137 | } | 134 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 45a5f9a..ff91cfa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -1827,7 +1827,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1827 | if (flexi) | 1827 | if (flexi) |
1828 | { | 1828 | { |
1829 | part.Shape.FlexiEntry = true; // this setting flexi true isn't working, but the below parameters do | 1829 | part.Shape.FlexiEntry = true; // this setting flexi true isn't working, but the below parameters do |
1830 | // work once the prim is already flexi | 1830 | // work once the prim is already flexi |
1831 | part.Shape.FlexiSoftness = softness; | 1831 | part.Shape.FlexiSoftness = softness; |
1832 | part.Shape.FlexiGravity = gravity; | 1832 | part.Shape.FlexiGravity = gravity; |
1833 | part.Shape.FlexiDrag = friction; | 1833 | part.Shape.FlexiDrag = friction; |
@@ -1837,10 +1837,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1837 | part.Shape.FlexiForceY = (float)Force.y; | 1837 | part.Shape.FlexiForceY = (float)Force.y; |
1838 | part.Shape.FlexiForceZ = (float)Force.z; | 1838 | part.Shape.FlexiForceZ = (float)Force.z; |
1839 | part.Shape.PathCurve = 0x80; | 1839 | part.Shape.PathCurve = 0x80; |
1840 | part.ParentGroup.HasGroupChanged = true; | ||
1841 | part.ScheduleFullUpdate(); | ||
1840 | } | 1842 | } |
1841 | |||
1842 | part.ParentGroup.HasGroupChanged = true; | ||
1843 | part.ScheduleFullUpdate(); | ||
1844 | } | 1843 | } |
1845 | 1844 | ||
1846 | /// <summary> | 1845 | /// <summary> |
@@ -11199,7 +11198,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11199 | 11198 | ||
11200 | if (checkAgents) | 11199 | if (checkAgents) |
11201 | { | 11200 | { |
11202 | World.ForEachScenePresence(delegate(ScenePresence sp) | 11201 | World.ForEachRootScenePresence(delegate(ScenePresence sp) |
11203 | { | 11202 | { |
11204 | if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X)) | 11203 | if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X)) |
11205 | { | 11204 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 6de0773..ed5a2fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -510,7 +510,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
510 | senseEntity(sp); | 510 | senseEntity(sp); |
511 | if ((ts.type & AGENT_BY_USERNAME) != 0) | 511 | if ((ts.type & AGENT_BY_USERNAME) != 0) |
512 | { | 512 | { |
513 | m_CmdManager.m_ScriptEngine.World.ForEachScenePresence( | 513 | m_CmdManager.m_ScriptEngine.World.ForEachRootScenePresence( |
514 | delegate (ScenePresence ssp) | 514 | delegate (ScenePresence ssp) |
515 | { | 515 | { |
516 | if (ssp.Lastname == "Resident") | 516 | if (ssp.Lastname == "Resident") |
@@ -529,7 +529,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
529 | } | 529 | } |
530 | else | 530 | else |
531 | { | 531 | { |
532 | m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity); | 532 | m_CmdManager.m_ScriptEngine.World.ForEachRootScenePresence(senseEntity); |
533 | } | 533 | } |
534 | return sensedEntities; | 534 | return sensedEntities; |
535 | } | 535 | } |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 30d3147..d8089ac 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | |||
@@ -473,7 +473,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
473 | // Grab the asset data from the response stream | 473 | // Grab the asset data from the response stream |
474 | using (MemoryStream stream = new MemoryStream()) | 474 | using (MemoryStream stream = new MemoryStream()) |
475 | { | 475 | { |
476 | responseStream.CopyTo(stream, Int32.MaxValue); | 476 | responseStream.CopyTo(stream, 4096); |
477 | asset.Data = stream.ToArray(); | 477 | asset.Data = stream.ToArray(); |
478 | } | 478 | } |
479 | } | 479 | } |
diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs new file mode 100644 index 0000000..7084ab4 --- /dev/null +++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Linq; | ||
32 | using pCampBot.Interfaces; | ||
33 | |||
34 | namespace pCampBot | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Click (grab) on random objects in the scene. | ||
38 | /// </summary> | ||
39 | /// <remarks> | ||
40 | /// The viewer itself does not give the option of grabbing objects that haven't been signalled as grabbable. | ||
41 | /// </remarks> | ||
42 | public class GrabbingBehaviour : IBehaviour | ||
43 | { | ||
44 | public void Action(Bot bot) | ||
45 | { | ||
46 | Dictionary<UUID, Primitive> objects = bot.Objects; | ||
47 | |||
48 | Primitive prim = objects.ElementAt(bot.Random.Next(0, objects.Count)).Value; | ||
49 | |||
50 | // This appears to be a typical message sent when a viewer user clicks a clickable object | ||
51 | bot.Client.Self.Grab(prim.LocalID); | ||
52 | bot.Client.Self.GrabUpdate(prim.ID, Vector3.Zero); | ||
53 | bot.Client.Self.DeGrab(prim.LocalID); | ||
54 | } | ||
55 | } | ||
56 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs new file mode 100644 index 0000000..3ce08bf --- /dev/null +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Threading; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using pCampBot.Interfaces; | ||
34 | |||
35 | namespace pCampBot | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Stress physics by moving and bouncing around bots a whole lot. | ||
39 | /// </summary> | ||
40 | /// <remarks> | ||
41 | /// TODO: talkarray should be in a separate behaviour. | ||
42 | /// </remarks> | ||
43 | public class PhysicsBehaviour : IBehaviour | ||
44 | { | ||
45 | private string[] talkarray; | ||
46 | |||
47 | public PhysicsBehaviour() | ||
48 | { | ||
49 | talkarray = readexcuses(); | ||
50 | } | ||
51 | |||
52 | public void Action(Bot bot) | ||
53 | { | ||
54 | int walkorrun = bot.Random.Next(4); // Randomize between walking and running. The greater this number, | ||
55 | // the greater the bot's chances to walk instead of run. | ||
56 | bot.Client.Self.Jump(false); | ||
57 | if (walkorrun == 0) | ||
58 | { | ||
59 | bot.Client.Self.Movement.AlwaysRun = true; | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | bot.Client.Self.Movement.AlwaysRun = false; | ||
64 | } | ||
65 | |||
66 | // TODO: unused: Vector3 pos = client.Self.SimPosition; | ||
67 | Vector3 newpos = new Vector3(bot.Random.Next(1, 254), bot.Random.Next(1, 254), bot.Random.Next(1, 254)); | ||
68 | bot.Client.Self.Movement.TurnToward(newpos); | ||
69 | |||
70 | bot.Client.Self.Movement.AtPos = true; | ||
71 | Thread.Sleep(bot.Random.Next(3000, 13000)); | ||
72 | bot.Client.Self.Movement.AtPos = false; | ||
73 | bot.Client.Self.Jump(true); | ||
74 | |||
75 | string randomf = talkarray[bot.Random.Next(talkarray.Length)]; | ||
76 | if (talkarray.Length > 1 && randomf.Length > 1) | ||
77 | bot.Client.Self.Chat(randomf, 0, ChatType.Normal); | ||
78 | } | ||
79 | |||
80 | private string[] readexcuses() | ||
81 | { | ||
82 | string allexcuses = ""; | ||
83 | |||
84 | string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); | ||
85 | if (File.Exists(file)) | ||
86 | { | ||
87 | StreamReader csr = File.OpenText(file); | ||
88 | allexcuses = csr.ReadToEnd(); | ||
89 | csr.Close(); | ||
90 | } | ||
91 | |||
92 | return allexcuses.Split(Environment.NewLine.ToCharArray()); | ||
93 | } | ||
94 | } | ||
95 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/Bot.cs index a8b2426..1b30766 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs | |||
@@ -38,20 +38,45 @@ using OpenMetaverse.Assets; | |||
38 | using Nini.Config; | 38 | using Nini.Config; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
41 | using pCampBot.Interfaces; | ||
41 | using Timer = System.Timers.Timer; | 42 | using Timer = System.Timers.Timer; |
42 | 43 | ||
43 | namespace pCampBot | 44 | namespace pCampBot |
44 | { | 45 | { |
45 | public class PhysicsBot | 46 | public class Bot |
46 | { | 47 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 49 | ||
49 | public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events | 50 | public delegate void AnEvent(Bot callbot, EventType someevent); // event delegate for bot events |
50 | 51 | ||
51 | public BotManager BotManager { get; private set; } | 52 | public BotManager BotManager { get; private set; } |
52 | private IConfig startupConfig; // bot config, passed from BotManager | 53 | private IConfig startupConfig; // bot config, passed from BotManager |
53 | 54 | ||
54 | /// <summary> | 55 | /// <summary> |
56 | /// Behaviours implemented by this bot. | ||
57 | /// </summary> | ||
58 | /// <remarks> | ||
59 | /// Lock this list before manipulating it. | ||
60 | /// </remarks> | ||
61 | public List<IBehaviour> Behaviours { get; private set; } | ||
62 | |||
63 | /// <summary> | ||
64 | /// Objects that the bot has discovered. | ||
65 | /// </summary> | ||
66 | /// <remarks> | ||
67 | /// Returns a list copy. Inserting new objects manually will have no effect. | ||
68 | /// </remarks> | ||
69 | public Dictionary<UUID, Primitive> Objects | ||
70 | { | ||
71 | get | ||
72 | { | ||
73 | lock (m_objects) | ||
74 | return new Dictionary<UUID, Primitive>(m_objects); | ||
75 | } | ||
76 | } | ||
77 | private Dictionary<UUID, Primitive> m_objects = new Dictionary<UUID, Primitive>(); | ||
78 | |||
79 | /// <summary> | ||
55 | /// Is this bot connected to the grid? | 80 | /// Is this bot connected to the grid? |
56 | /// </summary> | 81 | /// </summary> |
57 | public bool IsConnected { get; private set; } | 82 | public bool IsConnected { get; private set; } |
@@ -74,25 +99,33 @@ namespace pCampBot | |||
74 | 99 | ||
75 | protected List<uint> objectIDs = new List<uint>(); | 100 | protected List<uint> objectIDs = new List<uint>(); |
76 | 101 | ||
77 | protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here | 102 | /// <summary> |
103 | /// Random number generator. | ||
104 | /// </summary> | ||
105 | public Random Random { get; private set; } | ||
78 | 106 | ||
79 | /// <summary> | 107 | /// <summary> |
80 | /// New instance of a SecondLife client | 108 | /// New instance of a SecondLife client |
81 | /// </summary> | 109 | /// </summary> |
82 | public GridClient client = new GridClient(); | 110 | public GridClient Client { get; private set; } |
83 | |||
84 | protected string[] talkarray; | ||
85 | 111 | ||
86 | /// <summary> | 112 | /// <summary> |
87 | /// Constructor | 113 | /// Constructor |
88 | /// </summary> | 114 | /// </summary> |
89 | /// <param name="bm"></param> | 115 | /// <param name="bm"></param> |
116 | /// <param name="behaviours">Behaviours for this bot to perform</param> | ||
90 | /// <param name="firstName"></param> | 117 | /// <param name="firstName"></param> |
91 | /// <param name="lastName"></param> | 118 | /// <param name="lastName"></param> |
92 | /// <param name="password"></param> | 119 | /// <param name="password"></param> |
93 | /// <param name="loginUri"></param> | 120 | /// <param name="loginUri"></param> |
94 | public PhysicsBot(BotManager bm, string firstName, string lastName, string password, string loginUri) | 121 | /// <param name="behaviours"></param> |
122 | public Bot( | ||
123 | BotManager bm, List<IBehaviour> behaviours, | ||
124 | string firstName, string lastName, string password, string loginUri) | ||
95 | { | 125 | { |
126 | Client = new GridClient(); | ||
127 | |||
128 | Random = new Random(Environment.TickCount);// We do stuff randomly here | ||
96 | FirstName = firstName; | 129 | FirstName = firstName; |
97 | LastName = lastName; | 130 | LastName = lastName; |
98 | Name = string.Format("{0} {1}", FirstName, LastName); | 131 | Name = string.Format("{0} {1}", FirstName, LastName); |
@@ -102,7 +135,8 @@ namespace pCampBot | |||
102 | BotManager = bm; | 135 | BotManager = bm; |
103 | startupConfig = bm.Config; | 136 | startupConfig = bm.Config; |
104 | readconfig(); | 137 | readconfig(); |
105 | talkarray = readexcuses(); | 138 | |
139 | Behaviours = behaviours; | ||
106 | } | 140 | } |
107 | 141 | ||
108 | //We do our actions here. This is where one would | 142 | //We do our actions here. This is where one would |
@@ -110,34 +144,16 @@ namespace pCampBot | |||
110 | private void Action() | 144 | private void Action() |
111 | { | 145 | { |
112 | while (true) | 146 | while (true) |
113 | { | 147 | lock (Behaviours) |
114 | int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number, | 148 | Behaviours.ForEach( |
115 | // the greater the bot's chances to walk instead of run. | 149 | b => |
116 | client.Self.Jump(false); | 150 | { |
117 | if (walkorrun == 0) | 151 | // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); |
118 | { | 152 | b.Action(this); |
119 | client.Self.Movement.AlwaysRun = true; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | client.Self.Movement.AlwaysRun = false; | ||
124 | } | ||
125 | |||
126 | // TODO: unused: Vector3 pos = client.Self.SimPosition; | ||
127 | Vector3 newpos = new Vector3(somthing.Next(1, 254), somthing.Next(1, 254), somthing.Next(1, 254)); | ||
128 | client.Self.Movement.TurnToward(newpos); | ||
129 | |||
130 | client.Self.Movement.AtPos = true; | ||
131 | Thread.Sleep(somthing.Next(3000, 13000)); | ||
132 | client.Self.Movement.AtPos = false; | ||
133 | client.Self.Jump(true); | ||
134 | |||
135 | string randomf = talkarray[somthing.Next(talkarray.Length)]; | ||
136 | if (talkarray.Length > 1 && randomf.Length > 1) | ||
137 | client.Self.Chat(randomf, 0, ChatType.Normal); | ||
138 | 153 | ||
139 | Thread.Sleep(somthing.Next(1000, 10000)); | 154 | Thread.Sleep(Random.Next(1000, 10000)); |
140 | } | 155 | } |
156 | ); | ||
141 | } | 157 | } |
142 | 158 | ||
143 | /// <summary> | 159 | /// <summary> |
@@ -145,7 +161,7 @@ namespace pCampBot | |||
145 | /// </summary> | 161 | /// </summary> |
146 | public void readconfig() | 162 | public void readconfig() |
147 | { | 163 | { |
148 | wear = startupConfig.GetString("wear","no"); | 164 | wear = startupConfig.GetString("wear", "no"); |
149 | } | 165 | } |
150 | 166 | ||
151 | /// <summary> | 167 | /// <summary> |
@@ -156,7 +172,7 @@ namespace pCampBot | |||
156 | if (m_actionThread != null) | 172 | if (m_actionThread != null) |
157 | m_actionThread.Abort(); | 173 | m_actionThread.Abort(); |
158 | 174 | ||
159 | client.Network.Logout(); | 175 | Client.Network.Logout(); |
160 | } | 176 | } |
161 | 177 | ||
162 | /// <summary> | 178 | /// <summary> |
@@ -164,50 +180,50 @@ namespace pCampBot | |||
164 | /// </summary> | 180 | /// </summary> |
165 | public void startup() | 181 | public void startup() |
166 | { | 182 | { |
167 | client.Settings.LOGIN_SERVER = LoginUri; | 183 | Client.Settings.LOGIN_SERVER = LoginUri; |
168 | client.Settings.ALWAYS_DECODE_OBJECTS = false; | 184 | Client.Settings.ALWAYS_DECODE_OBJECTS = false; |
169 | client.Settings.AVATAR_TRACKING = false; | 185 | Client.Settings.AVATAR_TRACKING = false; |
170 | client.Settings.OBJECT_TRACKING = false; | 186 | Client.Settings.OBJECT_TRACKING = false; |
171 | client.Settings.SEND_AGENT_THROTTLE = true; | 187 | Client.Settings.SEND_AGENT_THROTTLE = true; |
172 | client.Settings.SEND_PINGS = true; | 188 | Client.Settings.SEND_PINGS = true; |
173 | client.Settings.STORE_LAND_PATCHES = false; | 189 | Client.Settings.STORE_LAND_PATCHES = false; |
174 | client.Settings.USE_ASSET_CACHE = false; | 190 | Client.Settings.USE_ASSET_CACHE = false; |
175 | client.Settings.MULTIPLE_SIMS = true; | 191 | Client.Settings.MULTIPLE_SIMS = true; |
176 | client.Throttle.Asset = 100000; | 192 | Client.Throttle.Asset = 100000; |
177 | client.Throttle.Land = 100000; | 193 | Client.Throttle.Land = 100000; |
178 | client.Throttle.Task = 100000; | 194 | Client.Throttle.Task = 100000; |
179 | client.Throttle.Texture = 100000; | 195 | Client.Throttle.Texture = 100000; |
180 | client.Throttle.Wind = 100000; | 196 | Client.Throttle.Wind = 100000; |
181 | client.Throttle.Total = 400000; | 197 | Client.Throttle.Total = 400000; |
182 | client.Network.LoginProgress += this.Network_LoginProgress; | 198 | Client.Network.LoginProgress += this.Network_LoginProgress; |
183 | client.Network.SimConnected += this.Network_SimConnected; | 199 | Client.Network.SimConnected += this.Network_SimConnected; |
184 | client.Network.Disconnected += this.Network_OnDisconnected; | 200 | Client.Network.Disconnected += this.Network_OnDisconnected; |
185 | client.Objects.ObjectUpdate += Objects_NewPrim; | 201 | Client.Objects.ObjectUpdate += Objects_NewPrim; |
186 | 202 | ||
187 | if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) | 203 | if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) |
188 | { | 204 | { |
189 | IsConnected = true; | 205 | IsConnected = true; |
190 | 206 | ||
191 | Thread.Sleep(somthing.Next(1000, 10000)); | 207 | Thread.Sleep(Random.Next(1000, 10000)); |
192 | m_actionThread = new Thread(Action); | 208 | m_actionThread = new Thread(Action); |
193 | m_actionThread.Start(); | 209 | m_actionThread.Start(); |
194 | 210 | ||
195 | // OnConnected(this, EventType.CONNECTED); | 211 | // OnConnected(this, EventType.CONNECTED); |
196 | if (wear == "save") | 212 | if (wear == "save") |
197 | { | 213 | { |
198 | client.Appearance.SetPreviousAppearance(); | 214 | Client.Appearance.SetPreviousAppearance(); |
199 | SaveDefaultAppearance(); | 215 | SaveDefaultAppearance(); |
200 | } | 216 | } |
201 | else if (wear != "no") | 217 | else if (wear != "no") |
202 | { | 218 | { |
203 | MakeDefaultAppearance(wear); | 219 | MakeDefaultAppearance(wear); |
204 | } | 220 | } |
205 | client.Self.Jump(true); | 221 | Client.Self.Jump(true); |
206 | } | 222 | } |
207 | else | 223 | else |
208 | { | 224 | { |
209 | MainConsole.Instance.OutputFormat( | 225 | MainConsole.Instance.OutputFormat( |
210 | "{0} {1} cannot login: {2}", FirstName, LastName, client.Network.LoginMessage); | 226 | "{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage); |
211 | 227 | ||
212 | if (OnDisconnected != null) | 228 | if (OnDisconnected != null) |
213 | { | 229 | { |
@@ -227,11 +243,11 @@ namespace pCampBot | |||
227 | Array wtypes = Enum.GetValues(typeof(WearableType)); | 243 | Array wtypes = Enum.GetValues(typeof(WearableType)); |
228 | foreach (WearableType wtype in wtypes) | 244 | foreach (WearableType wtype in wtypes) |
229 | { | 245 | { |
230 | UUID wearable = client.Appearance.GetWearableAsset(wtype); | 246 | UUID wearable = Client.Appearance.GetWearableAsset(wtype); |
231 | if (wearable != UUID.Zero) | 247 | if (wearable != UUID.Zero) |
232 | { | 248 | { |
233 | client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback); | 249 | Client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback); |
234 | client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback); | 250 | Client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback); |
235 | } | 251 | } |
236 | } | 252 | } |
237 | } | 253 | } |
@@ -306,11 +322,11 @@ namespace pCampBot | |||
306 | UUID assetID = UUID.Random(); | 322 | UUID assetID = UUID.Random(); |
307 | AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); | 323 | AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); |
308 | asset.Decode(); | 324 | asset.Decode(); |
309 | asset.Owner = client.Self.AgentID; | 325 | asset.Owner = Client.Self.AgentID; |
310 | asset.WearableType = GetWearableType(clothing[i]); | 326 | asset.WearableType = GetWearableType(clothing[i]); |
311 | asset.Encode(); | 327 | asset.Encode(); |
312 | transid = client.Assets.RequestUpload(asset,true); | 328 | transid = Client.Assets.RequestUpload(asset,true); |
313 | client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, | 329 | Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, |
314 | transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) | 330 | transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) |
315 | { | 331 | { |
316 | if (success) | 332 | if (success) |
@@ -328,11 +344,11 @@ namespace pCampBot | |||
328 | UUID assetID = UUID.Random(); | 344 | UUID assetID = UUID.Random(); |
329 | AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); | 345 | AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); |
330 | asset.Decode(); | 346 | asset.Decode(); |
331 | asset.Owner = client.Self.AgentID; | 347 | asset.Owner = Client.Self.AgentID; |
332 | asset.WearableType = GetWearableType(bodyparts[i]); | 348 | asset.WearableType = GetWearableType(bodyparts[i]); |
333 | asset.Encode(); | 349 | asset.Encode(); |
334 | transid = client.Assets.RequestUpload(asset,true); | 350 | transid = Client.Assets.RequestUpload(asset,true); |
335 | client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, | 351 | Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, |
336 | transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) | 352 | transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) |
337 | { | 353 | { |
338 | if (success) | 354 | if (success) |
@@ -352,7 +368,7 @@ namespace pCampBot | |||
352 | else | 368 | else |
353 | { | 369 | { |
354 | MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count)); | 370 | MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count)); |
355 | client.Appearance.WearOutfit(listwearables, false); | 371 | Client.Appearance.WearOutfit(listwearables, false); |
356 | } | 372 | } |
357 | } | 373 | } |
358 | catch (Exception ex) | 374 | catch (Exception ex) |
@@ -363,8 +379,8 @@ namespace pCampBot | |||
363 | 379 | ||
364 | public InventoryFolder FindClothingFolder() | 380 | public InventoryFolder FindClothingFolder() |
365 | { | 381 | { |
366 | UUID rootfolder = client.Inventory.Store.RootFolder.UUID; | 382 | UUID rootfolder = Client.Inventory.Store.RootFolder.UUID; |
367 | List<InventoryBase> listfolders = client.Inventory.Store.GetContents(rootfolder); | 383 | List<InventoryBase> listfolders = Client.Inventory.Store.GetContents(rootfolder); |
368 | InventoryFolder clothfolder = new InventoryFolder(UUID.Random()); | 384 | InventoryFolder clothfolder = new InventoryFolder(UUID.Random()); |
369 | foreach (InventoryBase folder in listfolders) | 385 | foreach (InventoryBase folder in listfolders) |
370 | { | 386 | { |
@@ -419,6 +435,9 @@ namespace pCampBot | |||
419 | 435 | ||
420 | if (prim != null) | 436 | if (prim != null) |
421 | { | 437 | { |
438 | lock (m_objects) | ||
439 | m_objects[prim.ID] = prim; | ||
440 | |||
422 | if (prim.Textures != null) | 441 | if (prim.Textures != null) |
423 | { | 442 | { |
424 | if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) | 443 | if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) |
@@ -430,10 +449,8 @@ namespace pCampBot | |||
430 | { | 449 | { |
431 | UUID textureID = prim.Textures.FaceTextures[i].TextureID; | 450 | UUID textureID = prim.Textures.FaceTextures[i].TextureID; |
432 | 451 | ||
433 | if (textureID != null && textureID != UUID.Zero) | 452 | if (textureID != UUID.Zero) |
434 | { | ||
435 | GetTexture(textureID); | 453 | GetTexture(textureID); |
436 | } | ||
437 | } | 454 | } |
438 | } | 455 | } |
439 | 456 | ||
@@ -453,10 +470,9 @@ namespace pCampBot | |||
453 | return; | 470 | return; |
454 | 471 | ||
455 | BotManager.AssetsReceived[textureID] = false; | 472 | BotManager.AssetsReceived[textureID] = false; |
456 | client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); | 473 | Client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); |
457 | } | 474 | } |
458 | } | 475 | } |
459 | |||
460 | 476 | ||
461 | public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) | 477 | public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) |
462 | { | 478 | { |
@@ -473,20 +489,5 @@ namespace pCampBot | |||
473 | // SaveAsset((AssetWearable) asset); | 489 | // SaveAsset((AssetWearable) asset); |
474 | // } | 490 | // } |
475 | } | 491 | } |
476 | |||
477 | public string[] readexcuses() | ||
478 | { | ||
479 | string allexcuses = ""; | ||
480 | |||
481 | string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); | ||
482 | if (File.Exists(file)) | ||
483 | { | ||
484 | StreamReader csr = File.OpenText(file); | ||
485 | allexcuses = csr.ReadToEnd(); | ||
486 | csr.Close(); | ||
487 | } | ||
488 | |||
489 | return allexcuses.Split(Environment.NewLine.ToCharArray()); | ||
490 | } | ||
491 | } | 492 | } |
492 | } | 493 | } |
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index b05bd6d..704770a 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -37,6 +37,7 @@ using log4net.Repository; | |||
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
40 | using pCampBot.Interfaces; | ||
40 | 41 | ||
41 | namespace pCampBot | 42 | namespace pCampBot |
42 | { | 43 | { |
@@ -48,7 +49,7 @@ namespace pCampBot | |||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 50 | ||
50 | protected CommandConsole m_console; | 51 | protected CommandConsole m_console; |
51 | protected List<PhysicsBot> m_lBot; | 52 | protected List<Bot> m_lBot; |
52 | protected Random somthing = new Random(Environment.TickCount); | 53 | protected Random somthing = new Random(Environment.TickCount); |
53 | protected int numbots = 0; | 54 | protected int numbots = 0; |
54 | public IConfig Config { get; private set; } | 55 | public IConfig Config { get; private set; } |
@@ -102,7 +103,7 @@ namespace pCampBot | |||
102 | // "add bots <number>", | 103 | // "add bots <number>", |
103 | // "Add more bots", HandleAddBots); | 104 | // "Add more bots", HandleAddBots); |
104 | 105 | ||
105 | m_lBot = new List<PhysicsBot>(); | 106 | m_lBot = new List<Bot>(); |
106 | } | 107 | } |
107 | 108 | ||
108 | /// <summary> | 109 | /// <summary> |
@@ -119,10 +120,24 @@ namespace pCampBot | |||
119 | string password = cs.GetString("password"); | 120 | string password = cs.GetString("password"); |
120 | string loginUri = cs.GetString("loginuri"); | 121 | string loginUri = cs.GetString("loginuri"); |
121 | 122 | ||
123 | HashSet<string> behaviourSwitches = new HashSet<string>(); | ||
124 | Array.ForEach<string>( | ||
125 | cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b)); | ||
126 | |||
122 | for (int i = 0; i < botcount; i++) | 127 | for (int i = 0; i < botcount; i++) |
123 | { | 128 | { |
124 | string lastName = string.Format("{0}_{1}", lastNameStem, i); | 129 | string lastName = string.Format("{0}_{1}", lastNameStem, i); |
125 | startupBot(i, this, firstName, lastName, password, loginUri); | 130 | |
131 | List<IBehaviour> behaviours = new List<IBehaviour>(); | ||
132 | |||
133 | // Hard-coded for now | ||
134 | if (behaviourSwitches.Contains("p")) | ||
135 | behaviours.Add(new PhysicsBehaviour()); | ||
136 | |||
137 | if (behaviourSwitches.Contains("g")) | ||
138 | behaviours.Add(new GrabbingBehaviour()); | ||
139 | |||
140 | startupBot(i, this, behaviours, firstName, lastName, password, loginUri); | ||
126 | } | 141 | } |
127 | } | 142 | } |
128 | 143 | ||
@@ -150,14 +165,17 @@ namespace pCampBot | |||
150 | /// This starts up the bot and stores the thread for the bot in the thread array | 165 | /// This starts up the bot and stores the thread for the bot in the thread array |
151 | /// </summary> | 166 | /// </summary> |
152 | /// <param name="pos">The position in the thread array to stick the bot's thread</param> | 167 | /// <param name="pos">The position in the thread array to stick the bot's thread</param> |
153 | /// <param name="cs">Configuration of the bot</param> | 168 | /// <param name="bm"></param> |
169 | /// <param name="behaviours">Behaviours for this bot to perform.</param> | ||
154 | /// <param name="firstName">First name</param> | 170 | /// <param name="firstName">First name</param> |
155 | /// <param name="lastName">Last name</param> | 171 | /// <param name="lastName">Last name</param> |
156 | /// <param name="password">Password</param> | 172 | /// <param name="password">Password</param> |
157 | /// <param name="loginUri">Login URI</param> | 173 | /// <param name="loginUri">Login URI</param> |
158 | public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri) | 174 | public void startupBot( |
175 | int pos, BotManager bm, List<IBehaviour> behaviours, | ||
176 | string firstName, string lastName, string password, string loginUri) | ||
159 | { | 177 | { |
160 | PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri); | 178 | Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri); |
161 | 179 | ||
162 | pb.OnConnected += handlebotEvent; | 180 | pb.OnConnected += handlebotEvent; |
163 | pb.OnDisconnected += handlebotEvent; | 181 | pb.OnDisconnected += handlebotEvent; |
@@ -176,7 +194,7 @@ namespace pCampBot | |||
176 | /// </summary> | 194 | /// </summary> |
177 | /// <param name="callbot"></param> | 195 | /// <param name="callbot"></param> |
178 | /// <param name="eventt"></param> | 196 | /// <param name="eventt"></param> |
179 | private void handlebotEvent(PhysicsBot callbot, EventType eventt) | 197 | private void handlebotEvent(Bot callbot, EventType eventt) |
180 | { | 198 | { |
181 | switch (eventt) | 199 | switch (eventt) |
182 | { | 200 | { |
@@ -201,7 +219,7 @@ namespace pCampBot | |||
201 | public void doBotShutdown() | 219 | public void doBotShutdown() |
202 | { | 220 | { |
203 | lock (m_lBot) | 221 | lock (m_lBot) |
204 | foreach (PhysicsBot pb in m_lBot) | 222 | foreach (Bot pb in m_lBot) |
205 | pb.shutdown(); | 223 | pb.shutdown(); |
206 | } | 224 | } |
207 | 225 | ||
@@ -227,7 +245,7 @@ namespace pCampBot | |||
227 | 245 | ||
228 | lock (m_lBot) | 246 | lock (m_lBot) |
229 | { | 247 | { |
230 | foreach (PhysicsBot pb in m_lBot) | 248 | foreach (Bot pb in m_lBot) |
231 | { | 249 | { |
232 | MainConsole.Instance.OutputFormat( | 250 | MainConsole.Instance.OutputFormat( |
233 | outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected")); | 251 | outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected")); |
diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs new file mode 100644 index 0000000..d4ae0f0 --- /dev/null +++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | |||
30 | namespace pCampBot.Interfaces | ||
31 | { | ||
32 | public interface IBehaviour | ||
33 | { | ||
34 | void Action(Bot bot); | ||
35 | } | ||
36 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index a69fbf0..4d3b06d 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs | |||
@@ -26,6 +26,8 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | ||
30 | using log4net; | ||
29 | using Nini.Config; | 31 | using Nini.Config; |
30 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
31 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
@@ -44,6 +46,8 @@ namespace pCampBot | |||
44 | 46 | ||
45 | public class pCampBot | 47 | public class pCampBot |
46 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
47 | [STAThread] | 51 | [STAThread] |
48 | public static void Main(string[] args) | 52 | public static void Main(string[] args) |
49 | { | 53 | { |
@@ -60,9 +64,17 @@ namespace pCampBot | |||
60 | 64 | ||
61 | //startup specified number of bots. 1 is the default | 65 | //startup specified number of bots. 1 is the default |
62 | bm.dobotStartup(botcount, config); | 66 | bm.dobotStartup(botcount, config); |
67 | |||
63 | while (true) | 68 | while (true) |
64 | { | 69 | { |
65 | MainConsole.Instance.Prompt(); | 70 | try |
71 | { | ||
72 | MainConsole.Instance.Prompt(); | ||
73 | } | ||
74 | catch (Exception e) | ||
75 | { | ||
76 | m_log.ErrorFormat("Command error: {0}", e); | ||
77 | } | ||
66 | } | 78 | } |
67 | } | 79 | } |
68 | } | 80 | } |
@@ -72,12 +84,13 @@ namespace pCampBot | |||
72 | //Set up our nifty config.. thanks to nini | 84 | //Set up our nifty config.. thanks to nini |
73 | ArgvConfigSource cs = new ArgvConfigSource(args); | 85 | ArgvConfigSource cs = new ArgvConfigSource(args); |
74 | 86 | ||
75 | cs.AddSwitch("Startup", "botcount","n"); | 87 | cs.AddSwitch("Startup", "botcount", "n"); |
76 | cs.AddSwitch("Startup", "loginuri","l"); | 88 | cs.AddSwitch("Startup", "loginuri", "l"); |
77 | cs.AddSwitch("Startup", "firstname"); | 89 | cs.AddSwitch("Startup", "firstname"); |
78 | cs.AddSwitch("Startup", "lastname"); | 90 | cs.AddSwitch("Startup", "lastname"); |
79 | cs.AddSwitch("Startup", "password"); | 91 | cs.AddSwitch("Startup", "password"); |
80 | cs.AddSwitch("Startup", "help","h"); | 92 | cs.AddSwitch("Startup", "behaviours", "b"); |
93 | cs.AddSwitch("Startup", "help", "h"); | ||
81 | cs.AddSwitch("Startup", "wear"); | 94 | cs.AddSwitch("Startup", "wear"); |
82 | 95 | ||
83 | IConfig ol = cs.Configs["Startup"]; | 96 | IConfig ol = cs.Configs["Startup"]; |
@@ -98,6 +111,7 @@ namespace pCampBot | |||
98 | " -firstname first name for the bots\n" + | 111 | " -firstname first name for the bots\n" + |
99 | " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" + | 112 | " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" + |
100 | " -password password for the bots\n" + | 113 | " -password password for the bots\n" + |
114 | " -b, behaviours behaviours for bots. Current options p (physics), g (grab). Comma separated, e.g. p,g. Default is p", | ||
101 | " -wear set appearance folder to load from (default: no)\n" + | 115 | " -wear set appearance folder to load from (default: no)\n" + |
102 | " -h, -help show this message" | 116 | " -h, -help show this message" |
103 | ); | 117 | ); |
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 80f4c0e..e71fb05 100755 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -339,9 +339,9 @@ | |||
339 | ;; Distance in meters that whispers should travel. | 339 | ;; Distance in meters that whispers should travel. |
340 | ; whisper_distance = 10 | 340 | ; whisper_distance = 10 |
341 | 341 | ||
342 | ;# {say_distance} {} {Distance at which normal chat is heard, in meters? (SL uses 20 here)} {} 30 | 342 | ;# {say_distance} {} {Distance at which normal chat is heard, in meters?} {} 20 |
343 | ;; Distance in meters that ordinary chat should travel. | 343 | ;; Distance in meters that ordinary chat should travel. |
344 | ; say_distance = 30 | 344 | ; say_distance = 20 |
345 | 345 | ||
346 | ;# {shout_distance} {Distance at which a shout is heard, in meters?} {} 100 | 346 | ;# {shout_distance} {Distance at which a shout is heard, in meters?} {} 100 |
347 | ;; Distance in meters that shouts should travel. | 347 | ;; Distance in meters that shouts should travel. |
diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index e9d8717..a02de72 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini | |||
@@ -563,8 +563,8 @@ | |||
563 | ; Distance in meters that whispers should travel. Default is 10m | 563 | ; Distance in meters that whispers should travel. Default is 10m |
564 | whisper_distance = 10 | 564 | whisper_distance = 10 |
565 | 565 | ||
566 | ; Distance in meters that ordinary chat should travel. Default is 30m | 566 | ; Distance in meters that ordinary chat should travel. Default is 20m |
567 | say_distance = 30 | 567 | say_distance = 20 |
568 | 568 | ||
569 | ; Distance in meters that shouts should travel. Default is 100m | 569 | ; Distance in meters that shouts should travel. Default is 100m |
570 | shout_distance = 100 | 570 | shout_distance = 100 |
diff --git a/prebuild.xml b/prebuild.xml index a6f11c4..ecc60fb 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -2519,6 +2519,7 @@ | |||
2519 | 2519 | ||
2520 | <ReferencePath>../../../bin/</ReferencePath> | 2520 | <ReferencePath>../../../bin/</ReferencePath> |
2521 | <Reference name="System"/> | 2521 | <Reference name="System"/> |
2522 | <Reference name="System.Core"/> | ||
2522 | <Reference name="OpenMetaverseTypes" path="../../../bin/"/> | 2523 | <Reference name="OpenMetaverseTypes" path="../../../bin/"/> |
2523 | <Reference name="OpenMetaverse" path="../../../bin/"/> | 2524 | <Reference name="OpenMetaverse" path="../../../bin/"/> |
2524 | <Reference name="OpenSim.Framework"/> | 2525 | <Reference name="OpenSim.Framework"/> |