Merge branch 'master' into bigmerge

Conflicts:
	OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
	OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
	OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
	OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
avinationmerge
Melanie 2011-11-04 01:18:37 +00:00
commit 24235006f4
27 changed files with 430 additions and 239 deletions

View File

@ -148,7 +148,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests
Rest.main.SceneManager.ForEachScene(delegate(Scene s)
{
s.ForEachScenePresence(delegate(ScenePresence sp)
s.ForEachRootScenePresence(delegate(ScenePresence sp)
{
if (sp.Firstname == names[0] && sp.Lastname == names[1])
{

View File

@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
private const int DEBUG_CHANNEL = 2147483647;
private bool m_enabled = true;
private int m_saydistance = 30;
private int m_saydistance = 20;
private int m_shoutdistance = 100;
private int m_whisperdistance = 10;
private List<Scene> m_scenes = new List<Scene>();
@ -242,7 +242,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
foreach (Scene s in m_scenes)
{
s.ForEachScenePresence(
// This should use ForEachClient, but clients don't have a position.
// If camera is moved into client, then camera position can be used
s.ForEachRootScenePresence(
delegate(ScenePresence presence)
{
ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
@ -306,12 +308,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
if (c.Scene != null)
{
((Scene)c.Scene).ForEachRootScenePresence
((Scene)c.Scene).ForEachRootClient
(
delegate(ScenePresence presence)
delegate(IClientAPI client)
{
IClientAPI client = presence.ControllingClient;
// don't forward SayOwner chat from objects to
// non-owner agents
if ((c.Type == ChatTypeEnum.Owner) &&
@ -321,7 +321,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
(byte)sourceType, (byte)ChatAudibleLevel.Fully);
receiverIDs.Add(presence.UUID);
receiverIDs.Add(client.AgentId);
}
);
(c.Scene as Scene).EventManager.TriggerOnChatToClients(

View File

@ -98,9 +98,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
public void SendGeneralAlert(string message)
{
m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
m_scene.ForEachRootClient(delegate(IClientAPI client)
{
presence.ControllingClient.SendAlertMessage(message);
client.SendAlertMessage(message);
});
}
@ -162,9 +162,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
public void SendNotificationToUsersInRegion(
UUID fromAvatarID, string fromAvatarName, string message)
{
m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
m_scene.ForEachRootClient(delegate(IClientAPI client)
{
presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
});
}

View File

@ -145,58 +145,39 @@ namespace OpenSim.Region.CoreModules.World.LightShare
param.Add(mBlock);
return param;
}
public void SendProfileToClient(ScenePresence presence)
public void SendProfileToClient(IClientAPI client)
{
SendProfileToClient(client, m_scene.RegionInfo.WindlightSettings);
}
public void SendProfileToClient(IClientAPI client, RegionLightShareData wl)
{
IClientAPI client = presence.ControllingClient;
if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
{
if (presence.IsChildAgent == false)
{
List<byte[]> param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings);
client.SendGenericMessage("Windlight", param);
}
}
else
{
//We probably don't want to spam chat with this.. probably
//m_log.Debug("[WINDLIGHT]: Module disabled");
}
}
public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl)
{
IClientAPI client = presence.ControllingClient;
if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
{
if (presence.IsChildAgent == false)
{
List<byte[]> param = compileWindlightSettings(wl);
client.SendGenericMessage("Windlight", param);
}
}
else
{
//We probably don't want to spam chat with this.. probably
//m_log.Debug("[WINDLIGHT]: Module disabled");
List<byte[]> param = compileWindlightSettings(wl);
client.SendGenericMessage("Windlight", param);
}
}
private void EventManager_OnMakeRootAgent(ScenePresence presence)
{
if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
SendProfileToClient(presence);
SendProfileToClient(presence.ControllingClient);
}
private void EventManager_OnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID pUUID)
{
ScenePresence Sc;
if (m_scene.TryGetScenePresence(pUUID,out Sc))
{
SendProfileToClient(Sc,wl);
}
IClientAPI client;
m_scene.TryGetClient(pUUID, out client);
SendProfileToClient(client, wl);
}
private void EventManager_OnSaveNewWindlightProfile()
{
if (m_scene.RegionInfo.WindlightSettings.valid)
m_scene.ForEachScenePresence(SendProfileToClient);
m_scene.ForEachRootClient(SendProfileToClient);
}
public void PostInitialise()

View File

@ -95,7 +95,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
private Queue m_pendingQ;
private Scene m_scene;
private int m_whisperdistance = 10;
private int m_saydistance = 30;
private int m_saydistance = 20;
private int m_shoutdistance = 100;
#region IRegionModule Members

View File

@ -678,13 +678,14 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false))
return;
Scene.ForEachRootScenePresence(delegate(ScenePresence p)
Scene.ForEachRootClient(delegate(IClientAPI client)
{
if (p.UUID != senderID)
if (client.AgentId != senderID)
{
// make sure they are still there, we could be working down a long list
// Also make sure they are actually in the region
if (p != null && !p.IsChildAgent)
ScenePresence p;
if(Scene.TryGetScenePresence(client.AgentId, out p))
{
if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
{
@ -952,9 +953,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
public void sendRegionInfoPacketToAll()
{
Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
Scene.ForEachRootClient(delegate(IClientAPI client)
{
HandleRegionInfoRequest(sp.ControllingClient);
HandleRegionInfoRequest(client);
});
}

View File

@ -488,9 +488,9 @@ namespace OpenSim.Region.CoreModules
private void SunUpdateToAllClients()
{
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
m_scene.ForEachRootClient(delegate(IClientAPI client)
{
SunToClient(sp.ControllingClient);
SunToClient(client);
});
}

View File

@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules
m_frameLastUpdateClientArray = m_frame;
}
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
m_scene.ForEachRootClient(delegate(IClientAPI client)
{
sp.ControllingClient.SendWindData(windSpeeds);
client.SendWindData(windSpeeds);
});
}
}

View File

@ -1460,12 +1460,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="stats">Stats on the Simulator's performance</param>
private void SendSimStatsPackets(SimStats stats)
{
ForEachRootScenePresence(
delegate(ScenePresence agent)
{
agent.ControllingClient.SendSimStats(stats);
}
);
ForEachRootClient(delegate(IClientAPI client)
{
client.SendSimStats(stats);
});
}
/// <summary>
@ -4387,35 +4385,32 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.GetScenePresence(localID);
}
/// <summary>
/// Returns true if scene presence is a child (no avatar in this scene)
/// </summary>
/// <param name="avatarID"></param>
/// <returns></returns>
public override bool PresenceChildStatus(UUID avatarID)
{
ScenePresence cp = GetScenePresence(avatarID);
// FIXME: This is really crap - some logout code is relying on a NullReferenceException to halt its processing
// This needs to be fixed properly by cleaning up the logout code.
//if (cp != null)
// return cp.IsChildAgent;
//return false;
return cp.IsChildAgent;
ScenePresence sp;
return TryGetScenePresence(avatarID, out sp) && sp.IsChildAgent;
}
/// <summary>
/// Performs action on all ROOT (not child) scene presences.
/// This is just a shortcut function since frequently actions only appy to root SPs
/// Performs action on all avatars in the scene (root scene presences)
/// Avatars may be an NPC or a 'real' client.
/// </summary>
/// <param name="action"></param>
public void ForEachRootScenePresence(Action<ScenePresence> action)
{
if(m_sceneGraph != null)
{
m_sceneGraph.ForEachRootScenePresence(action);
m_sceneGraph.ForEachAvatar(action);
}
}
/// <summary>
/// Performs action on all scene presences.
/// Performs action on all scene presences (root and child)
/// </summary>
/// <param name="action"></param>
public void ForEachScenePresence(Action<ScenePresence> action)
@ -4426,25 +4421,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// Perform the given action for each object
/// </summary>
/// <param name="action"></param>
// public void ForEachObject(Action<SceneObjectGroup> action)
// {
// List<SceneObjectGroup> presenceList;
//
// lock (m_sceneObjects)
// {
// presenceList = new List<SceneObjectGroup>(m_sceneObjects.Values);
// }
//
// foreach (SceneObjectGroup presence in presenceList)
// {
// action(presence);
// }
// }
/// <summary>
/// Get a group via its UUID
/// </summary>
@ -4517,6 +4493,22 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.TryGetAvatarByName(avatarName, out avatar);
}
/// <summary>
/// Perform an action on all clients with an avatar in this scene (root only)
/// </summary>
/// <param name="action"></param>
public void ForEachRootClient(Action<IClientAPI> action)
{
ForEachRootScenePresence(delegate(ScenePresence presence)
{
action(presence.ControllingClient);
});
}
/// <summary>
/// Perform an action on all clients connected to the region (root and child)
/// </summary>
/// <param name="action"></param>
public void ForEachClient(Action<IClientAPI> action)
{
m_clientManager.ForEachSync(action);

View File

@ -1265,7 +1265,7 @@ namespace OpenSim.Region.Framework.Scenes
/// This is just a shortcut function since frequently actions only appy to root SPs
/// </summary>
/// <param name="action"></param>
public void ForEachRootScenePresence(Action<ScenePresence> action)
public void ForEachAvatar(Action<ScenePresence> action)
{
ForEachScenePresence(delegate(ScenePresence sp)
{

View File

@ -458,16 +458,16 @@ namespace OpenSim.Region.Framework.Scenes
ForEachCurrentScene(
delegate(Scene scene)
{
scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
scene.ForEachRootClient(delegate(IClientAPI client)
{
if (name == null || scenePresence.Name == name)
if (name == null || client.Name == name)
{
m_log.DebugFormat("Packet debug for {0} {1} set to {2}",
scenePresence.Firstname,
scenePresence.Lastname,
client.FirstName,
client.LastName,
newDebug);
scenePresence.ControllingClient.DebugPacketLevel = newDebug;
client.DebugPacketLevel = newDebug;
}
});
}

View File

@ -1473,7 +1473,7 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart part = parts[i];
Scene.ForEachScenePresence(delegate(ScenePresence avatar)
Scene.ForEachRootScenePresence(delegate(ScenePresence avatar)
{
if (avatar.ParentID == LocalId)
avatar.StandUp();

View File

@ -1025,7 +1025,7 @@ namespace OpenSim.Region.Framework.Scenes
public PrimitiveBaseShape Shape
{
get { return m_shape; }
set { m_shape = value; }
set { m_shape = value;}
}
/// <summary>
@ -1389,12 +1389,12 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="AgentID"></param>
private void SendRootPartPropertiesToClient(UUID AgentID)
{
m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar)
m_parentGroup.Scene.ForEachClient(delegate(IClientAPI client)
{
// Ugly reference :(
if (avatar.UUID == AgentID)
if (client.AgentId == AgentID)
{
m_parentGroup.SendPropertiesToClient(avatar.ControllingClient);
m_parentGroup.SendPropertiesToClient(client);
}
});
}
@ -1514,9 +1514,9 @@ namespace OpenSim.Region.Framework.Scenes
if (volume < 0)
volume = 0;
m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
m_parentGroup.Scene.ForEachRootClient(delegate(IClientAPI client)
{
sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume);
client.SendAttachedSoundGainChange(UUID, (float)volume);
});
}
@ -2270,7 +2270,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av)
{
if (av.LocalId == localId)
{
@ -2401,7 +2401,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av)
{
if (av.LocalId == localId)
{
@ -2524,7 +2524,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av)
m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av)
{
if (av.LocalId == localId)
{

View File

@ -1072,7 +1072,7 @@ namespace OpenSim.Region.Framework.Scenes
}
// send the animations of the other presences to me
m_scene.ForEachScenePresence(delegate(ScenePresence presence)
m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
{
if (presence != this)
presence.Animator.SendAnimPackToClient(ControllingClient);

View File

@ -123,15 +123,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
{
foreach (Scene scene in m_scenes.Values)
{
scene.ForEachScenePresence(
scene.ForEachRootScenePresence(
delegate(ScenePresence sp)
{
if (sp.ControllingClient is LLClientView && !((LLClientView)sp.ControllingClient).ChildAgentStatus())
{
bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp);
MainConsole.Instance.OutputFormat(
"{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt");
}
bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp);
MainConsole.Instance.OutputFormat(
"{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt");
});
}
}

View File

@ -1827,7 +1827,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (flexi)
{
part.Shape.FlexiEntry = true; // this setting flexi true isn't working, but the below parameters do
// work once the prim is already flexi
// work once the prim is already flexi
part.Shape.FlexiSoftness = softness;
part.Shape.FlexiGravity = gravity;
part.Shape.FlexiDrag = friction;
@ -1837,10 +1837,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
part.Shape.FlexiForceY = (float)Force.y;
part.Shape.FlexiForceZ = (float)Force.z;
part.Shape.PathCurve = 0x80;
part.ParentGroup.HasGroupChanged = true;
part.ScheduleFullUpdate();
}
part.ParentGroup.HasGroupChanged = true;
part.ScheduleFullUpdate();
}
/// <summary>
@ -11199,7 +11198,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (checkAgents)
{
World.ForEachScenePresence(delegate(ScenePresence sp)
World.ForEachRootScenePresence(delegate(ScenePresence sp)
{
if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X))
{

View File

@ -510,7 +510,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
senseEntity(sp);
if ((ts.type & AGENT_BY_USERNAME) != 0)
{
m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(
m_CmdManager.m_ScriptEngine.World.ForEachRootScenePresence(
delegate (ScenePresence ssp)
{
if (ssp.Lastname == "Resident")
@ -529,7 +529,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
}
else
{
m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity);
m_CmdManager.m_ScriptEngine.World.ForEachRootScenePresence(senseEntity);
}
return sensedEntities;
}

View File

@ -473,7 +473,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
// Grab the asset data from the response stream
using (MemoryStream stream = new MemoryStream())
{
responseStream.CopyTo(stream, Int32.MaxValue);
responseStream.CopyTo(stream, 4096);
asset.Data = stream.ToArray();
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using OpenMetaverse;
using System;
using System.Collections.Generic;
using System.Linq;
using pCampBot.Interfaces;
namespace pCampBot
{
/// <summary>
/// Click (grab) on random objects in the scene.
/// </summary>
/// <remarks>
/// The viewer itself does not give the option of grabbing objects that haven't been signalled as grabbable.
/// </remarks>
public class GrabbingBehaviour : IBehaviour
{
public void Action(Bot bot)
{
Dictionary<UUID, Primitive> objects = bot.Objects;
Primitive prim = objects.ElementAt(bot.Random.Next(0, objects.Count)).Value;
// This appears to be a typical message sent when a viewer user clicks a clickable object
bot.Client.Self.Grab(prim.LocalID);
bot.Client.Self.GrabUpdate(prim.ID, Vector3.Zero);
bot.Client.Self.DeGrab(prim.LocalID);
}
}
}

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.IO;
using System.Threading;
using OpenMetaverse;
using OpenSim.Framework;
using pCampBot.Interfaces;
namespace pCampBot
{
/// <summary>
/// Stress physics by moving and bouncing around bots a whole lot.
/// </summary>
/// <remarks>
/// TODO: talkarray should be in a separate behaviour.
/// </remarks>
public class PhysicsBehaviour : IBehaviour
{
private string[] talkarray;
public PhysicsBehaviour()
{
talkarray = readexcuses();
}
public void Action(Bot bot)
{
int walkorrun = bot.Random.Next(4); // Randomize between walking and running. The greater this number,
// the greater the bot's chances to walk instead of run.
bot.Client.Self.Jump(false);
if (walkorrun == 0)
{
bot.Client.Self.Movement.AlwaysRun = true;
}
else
{
bot.Client.Self.Movement.AlwaysRun = false;
}
// TODO: unused: Vector3 pos = client.Self.SimPosition;
Vector3 newpos = new Vector3(bot.Random.Next(1, 254), bot.Random.Next(1, 254), bot.Random.Next(1, 254));
bot.Client.Self.Movement.TurnToward(newpos);
bot.Client.Self.Movement.AtPos = true;
Thread.Sleep(bot.Random.Next(3000, 13000));
bot.Client.Self.Movement.AtPos = false;
bot.Client.Self.Jump(true);
string randomf = talkarray[bot.Random.Next(talkarray.Length)];
if (talkarray.Length > 1 && randomf.Length > 1)
bot.Client.Self.Chat(randomf, 0, ChatType.Normal);
}
private string[] readexcuses()
{
string allexcuses = "";
string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt");
if (File.Exists(file))
{
StreamReader csr = File.OpenText(file);
allexcuses = csr.ReadToEnd();
csr.Close();
}
return allexcuses.Split(Environment.NewLine.ToCharArray());
}
}
}

View File

@ -38,19 +38,44 @@ using OpenMetaverse.Assets;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using pCampBot.Interfaces;
using Timer = System.Timers.Timer;
namespace pCampBot
{
public class PhysicsBot
public class Bot
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events
public delegate void AnEvent(Bot callbot, EventType someevent); // event delegate for bot events
public BotManager BotManager { get; private set; }
private IConfig startupConfig; // bot config, passed from BotManager
/// <summary>
/// Behaviours implemented by this bot.
/// </summary>
/// <remarks>
/// Lock this list before manipulating it.
/// </remarks>
public List<IBehaviour> Behaviours { get; private set; }
/// <summary>
/// Objects that the bot has discovered.
/// </summary>
/// <remarks>
/// Returns a list copy. Inserting new objects manually will have no effect.
/// </remarks>
public Dictionary<UUID, Primitive> Objects
{
get
{
lock (m_objects)
return new Dictionary<UUID, Primitive>(m_objects);
}
}
private Dictionary<UUID, Primitive> m_objects = new Dictionary<UUID, Primitive>();
/// <summary>
/// Is this bot connected to the grid?
/// </summary>
@ -74,25 +99,33 @@ namespace pCampBot
protected List<uint> objectIDs = new List<uint>();
protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here
/// <summary>
/// Random number generator.
/// </summary>
public Random Random { get; private set; }
/// <summary>
/// New instance of a SecondLife client
/// </summary>
public GridClient client = new GridClient();
protected string[] talkarray;
public GridClient Client { get; private set; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="bm"></param>
/// <param name="behaviours">Behaviours for this bot to perform</param>
/// <param name="firstName"></param>
/// <param name="lastName"></param>
/// <param name="password"></param>
/// <param name="loginUri"></param>
public PhysicsBot(BotManager bm, string firstName, string lastName, string password, string loginUri)
/// <param name="behaviours"></param>
public Bot(
BotManager bm, List<IBehaviour> behaviours,
string firstName, string lastName, string password, string loginUri)
{
Client = new GridClient();
Random = new Random(Environment.TickCount);// We do stuff randomly here
FirstName = firstName;
LastName = lastName;
Name = string.Format("{0} {1}", FirstName, LastName);
@ -102,7 +135,8 @@ namespace pCampBot
BotManager = bm;
startupConfig = bm.Config;
readconfig();
talkarray = readexcuses();
Behaviours = behaviours;
}
//We do our actions here. This is where one would
@ -110,34 +144,16 @@ namespace pCampBot
private void Action()
{
while (true)
{
int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number,
// the greater the bot's chances to walk instead of run.
client.Self.Jump(false);
if (walkorrun == 0)
{
client.Self.Movement.AlwaysRun = true;
}
else
{
client.Self.Movement.AlwaysRun = false;
}
lock (Behaviours)
Behaviours.ForEach(
b =>
{
// m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType());
b.Action(this);
// TODO: unused: Vector3 pos = client.Self.SimPosition;
Vector3 newpos = new Vector3(somthing.Next(1, 254), somthing.Next(1, 254), somthing.Next(1, 254));
client.Self.Movement.TurnToward(newpos);
client.Self.Movement.AtPos = true;
Thread.Sleep(somthing.Next(3000, 13000));
client.Self.Movement.AtPos = false;
client.Self.Jump(true);
string randomf = talkarray[somthing.Next(talkarray.Length)];
if (talkarray.Length > 1 && randomf.Length > 1)
client.Self.Chat(randomf, 0, ChatType.Normal);
Thread.Sleep(somthing.Next(1000, 10000));
}
Thread.Sleep(Random.Next(1000, 10000));
}
);
}
/// <summary>
@ -145,7 +161,7 @@ namespace pCampBot
/// </summary>
public void readconfig()
{
wear = startupConfig.GetString("wear","no");
wear = startupConfig.GetString("wear", "no");
}
/// <summary>
@ -156,7 +172,7 @@ namespace pCampBot
if (m_actionThread != null)
m_actionThread.Abort();
client.Network.Logout();
Client.Network.Logout();
}
/// <summary>
@ -164,50 +180,50 @@ namespace pCampBot
/// </summary>
public void startup()
{
client.Settings.LOGIN_SERVER = LoginUri;
client.Settings.ALWAYS_DECODE_OBJECTS = false;
client.Settings.AVATAR_TRACKING = false;
client.Settings.OBJECT_TRACKING = false;
client.Settings.SEND_AGENT_THROTTLE = true;
client.Settings.SEND_PINGS = true;
client.Settings.STORE_LAND_PATCHES = false;
client.Settings.USE_ASSET_CACHE = false;
client.Settings.MULTIPLE_SIMS = true;
client.Throttle.Asset = 100000;
client.Throttle.Land = 100000;
client.Throttle.Task = 100000;
client.Throttle.Texture = 100000;
client.Throttle.Wind = 100000;
client.Throttle.Total = 400000;
client.Network.LoginProgress += this.Network_LoginProgress;
client.Network.SimConnected += this.Network_SimConnected;
client.Network.Disconnected += this.Network_OnDisconnected;
client.Objects.ObjectUpdate += Objects_NewPrim;
Client.Settings.LOGIN_SERVER = LoginUri;
Client.Settings.ALWAYS_DECODE_OBJECTS = false;
Client.Settings.AVATAR_TRACKING = false;
Client.Settings.OBJECT_TRACKING = false;
Client.Settings.SEND_AGENT_THROTTLE = true;
Client.Settings.SEND_PINGS = true;
Client.Settings.STORE_LAND_PATCHES = false;
Client.Settings.USE_ASSET_CACHE = false;
Client.Settings.MULTIPLE_SIMS = true;
Client.Throttle.Asset = 100000;
Client.Throttle.Land = 100000;
Client.Throttle.Task = 100000;
Client.Throttle.Texture = 100000;
Client.Throttle.Wind = 100000;
Client.Throttle.Total = 400000;
Client.Network.LoginProgress += this.Network_LoginProgress;
Client.Network.SimConnected += this.Network_SimConnected;
Client.Network.Disconnected += this.Network_OnDisconnected;
Client.Objects.ObjectUpdate += Objects_NewPrim;
if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
{
IsConnected = true;
Thread.Sleep(somthing.Next(1000, 10000));
Thread.Sleep(Random.Next(1000, 10000));
m_actionThread = new Thread(Action);
m_actionThread.Start();
// OnConnected(this, EventType.CONNECTED);
if (wear == "save")
{
client.Appearance.SetPreviousAppearance();
Client.Appearance.SetPreviousAppearance();
SaveDefaultAppearance();
}
else if (wear != "no")
{
MakeDefaultAppearance(wear);
}
client.Self.Jump(true);
Client.Self.Jump(true);
}
else
{
MainConsole.Instance.OutputFormat(
"{0} {1} cannot login: {2}", FirstName, LastName, client.Network.LoginMessage);
"{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage);
if (OnDisconnected != null)
{
@ -227,11 +243,11 @@ namespace pCampBot
Array wtypes = Enum.GetValues(typeof(WearableType));
foreach (WearableType wtype in wtypes)
{
UUID wearable = client.Appearance.GetWearableAsset(wtype);
UUID wearable = Client.Appearance.GetWearableAsset(wtype);
if (wearable != UUID.Zero)
{
client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback);
client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback);
Client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback);
Client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback);
}
}
}
@ -306,11 +322,11 @@ namespace pCampBot
UUID assetID = UUID.Random();
AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i]));
asset.Decode();
asset.Owner = client.Self.AgentID;
asset.Owner = Client.Self.AgentID;
asset.WearableType = GetWearableType(clothing[i]);
asset.Encode();
transid = client.Assets.RequestUpload(asset,true);
client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing,
transid = Client.Assets.RequestUpload(asset,true);
Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing,
transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item)
{
if (success)
@ -328,11 +344,11 @@ namespace pCampBot
UUID assetID = UUID.Random();
AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i]));
asset.Decode();
asset.Owner = client.Self.AgentID;
asset.Owner = Client.Self.AgentID;
asset.WearableType = GetWearableType(bodyparts[i]);
asset.Encode();
transid = client.Assets.RequestUpload(asset,true);
client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart,
transid = Client.Assets.RequestUpload(asset,true);
Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart,
transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item)
{
if (success)
@ -352,7 +368,7 @@ namespace pCampBot
else
{
MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count));
client.Appearance.WearOutfit(listwearables, false);
Client.Appearance.WearOutfit(listwearables, false);
}
}
catch (Exception ex)
@ -363,8 +379,8 @@ namespace pCampBot
public InventoryFolder FindClothingFolder()
{
UUID rootfolder = client.Inventory.Store.RootFolder.UUID;
List<InventoryBase> listfolders = client.Inventory.Store.GetContents(rootfolder);
UUID rootfolder = Client.Inventory.Store.RootFolder.UUID;
List<InventoryBase> listfolders = Client.Inventory.Store.GetContents(rootfolder);
InventoryFolder clothfolder = new InventoryFolder(UUID.Random());
foreach (InventoryBase folder in listfolders)
{
@ -419,6 +435,9 @@ namespace pCampBot
if (prim != null)
{
lock (m_objects)
m_objects[prim.ID] = prim;
if (prim.Textures != null)
{
if (prim.Textures.DefaultTexture.TextureID != UUID.Zero)
@ -430,10 +449,8 @@ namespace pCampBot
{
UUID textureID = prim.Textures.FaceTextures[i].TextureID;
if (textureID != null && textureID != UUID.Zero)
{
if (textureID != UUID.Zero)
GetTexture(textureID);
}
}
}
@ -453,10 +470,9 @@ namespace pCampBot
return;
BotManager.AssetsReceived[textureID] = false;
client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture);
Client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture);
}
}
public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture)
{
@ -473,20 +489,5 @@ namespace pCampBot
// SaveAsset((AssetWearable) asset);
// }
}
public string[] readexcuses()
{
string allexcuses = "";
string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt");
if (File.Exists(file))
{
StreamReader csr = File.OpenText(file);
allexcuses = csr.ReadToEnd();
csr.Close();
}
return allexcuses.Split(Environment.NewLine.ToCharArray());
}
}
}

View File

@ -37,6 +37,7 @@ using log4net.Repository;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using pCampBot.Interfaces;
namespace pCampBot
{
@ -48,7 +49,7 @@ namespace pCampBot
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected CommandConsole m_console;
protected List<PhysicsBot> m_lBot;
protected List<Bot> m_lBot;
protected Random somthing = new Random(Environment.TickCount);
protected int numbots = 0;
public IConfig Config { get; private set; }
@ -102,7 +103,7 @@ namespace pCampBot
// "add bots <number>",
// "Add more bots", HandleAddBots);
m_lBot = new List<PhysicsBot>();
m_lBot = new List<Bot>();
}
/// <summary>
@ -119,10 +120,24 @@ namespace pCampBot
string password = cs.GetString("password");
string loginUri = cs.GetString("loginuri");
HashSet<string> behaviourSwitches = new HashSet<string>();
Array.ForEach<string>(
cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
for (int i = 0; i < botcount; i++)
{
string lastName = string.Format("{0}_{1}", lastNameStem, i);
startupBot(i, this, firstName, lastName, password, loginUri);
List<IBehaviour> behaviours = new List<IBehaviour>();
// Hard-coded for now
if (behaviourSwitches.Contains("p"))
behaviours.Add(new PhysicsBehaviour());
if (behaviourSwitches.Contains("g"))
behaviours.Add(new GrabbingBehaviour());
startupBot(i, this, behaviours, firstName, lastName, password, loginUri);
}
}
@ -150,14 +165,17 @@ namespace pCampBot
/// This starts up the bot and stores the thread for the bot in the thread array
/// </summary>
/// <param name="pos">The position in the thread array to stick the bot's thread</param>
/// <param name="cs">Configuration of the bot</param>
/// <param name="bm"></param>
/// <param name="behaviours">Behaviours for this bot to perform.</param>
/// <param name="firstName">First name</param>
/// <param name="lastName">Last name</param>
/// <param name="password">Password</param>
/// <param name="loginUri">Login URI</param>
public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri)
public void startupBot(
int pos, BotManager bm, List<IBehaviour> behaviours,
string firstName, string lastName, string password, string loginUri)
{
PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri);
Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
pb.OnConnected += handlebotEvent;
pb.OnDisconnected += handlebotEvent;
@ -176,7 +194,7 @@ namespace pCampBot
/// </summary>
/// <param name="callbot"></param>
/// <param name="eventt"></param>
private void handlebotEvent(PhysicsBot callbot, EventType eventt)
private void handlebotEvent(Bot callbot, EventType eventt)
{
switch (eventt)
{
@ -201,7 +219,7 @@ namespace pCampBot
public void doBotShutdown()
{
lock (m_lBot)
foreach (PhysicsBot pb in m_lBot)
foreach (Bot pb in m_lBot)
pb.shutdown();
}
@ -227,7 +245,7 @@ namespace pCampBot
lock (m_lBot)
{
foreach (PhysicsBot pb in m_lBot)
foreach (Bot pb in m_lBot)
{
MainConsole.Instance.OutputFormat(
outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected"));

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace pCampBot.Interfaces
{
public interface IBehaviour
{
void Action(Bot bot);
}
}

View File

@ -26,6 +26,8 @@
*/
using System;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
@ -44,6 +46,8 @@ namespace pCampBot
public class pCampBot
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
[STAThread]
public static void Main(string[] args)
{
@ -60,9 +64,17 @@ namespace pCampBot
//startup specified number of bots. 1 is the default
bm.dobotStartup(botcount, config);
while (true)
{
MainConsole.Instance.Prompt();
try
{
MainConsole.Instance.Prompt();
}
catch (Exception e)
{
m_log.ErrorFormat("Command error: {0}", e);
}
}
}
}
@ -72,12 +84,13 @@ namespace pCampBot
//Set up our nifty config.. thanks to nini
ArgvConfigSource cs = new ArgvConfigSource(args);
cs.AddSwitch("Startup", "botcount","n");
cs.AddSwitch("Startup", "loginuri","l");
cs.AddSwitch("Startup", "botcount", "n");
cs.AddSwitch("Startup", "loginuri", "l");
cs.AddSwitch("Startup", "firstname");
cs.AddSwitch("Startup", "lastname");
cs.AddSwitch("Startup", "password");
cs.AddSwitch("Startup", "help","h");
cs.AddSwitch("Startup", "behaviours", "b");
cs.AddSwitch("Startup", "help", "h");
cs.AddSwitch("Startup", "wear");
IConfig ol = cs.Configs["Startup"];
@ -98,6 +111,7 @@ namespace pCampBot
" -firstname first name for the bots\n" +
" -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" +
" -password password for the bots\n" +
" -b, behaviours behaviours for bots. Current options p (physics), g (grab). Comma separated, e.g. p,g. Default is p",
" -wear set appearance folder to load from (default: no)\n" +
" -h, -help show this message"
);

View File

@ -339,9 +339,9 @@
;; Distance in meters that whispers should travel.
; whisper_distance = 10
;# {say_distance} {} {Distance at which normal chat is heard, in meters? (SL uses 20 here)} {} 30
;# {say_distance} {} {Distance at which normal chat is heard, in meters?} {} 20
;; Distance in meters that ordinary chat should travel.
; say_distance = 30
; say_distance = 20
;# {shout_distance} {Distance at which a shout is heard, in meters?} {} 100
;; Distance in meters that shouts should travel.

View File

@ -563,8 +563,8 @@
; Distance in meters that whispers should travel. Default is 10m
whisper_distance = 10
; Distance in meters that ordinary chat should travel. Default is 30m
say_distance = 30
; Distance in meters that ordinary chat should travel. Default is 20m
say_distance = 20
; Distance in meters that shouts should travel. Default is 100m
shout_distance = 100

View File

@ -2519,6 +2519,7 @@
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Core"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenSim.Framework"/>