Should allow multiple worlds (and UDP servers) to be ran in one instance, just missing backend comms and working Avatar/primitives classes.

This commit is contained in:
MW
2007-05-27 18:52:42 +00:00
parent 06387d0344
commit c746a2f9f4
62 changed files with 1623 additions and 1784 deletions

View File

@@ -4,6 +4,7 @@ using System.Text;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Physics.Manager;
using OpenSim.Framework.Interfaces;
namespace OpenSim.world
{
@@ -22,7 +23,7 @@ namespace OpenSim.world
public ObjectUpdatePacket CreateUpdatePacket()
{
return null;
}
public void SendInitialPosition()
@@ -35,7 +36,7 @@ namespace OpenSim.world
}
public void SendOurAppearance(ClientView OurClient)
public void SendOurAppearance(IClientAPI OurClient)
{
}
@@ -57,7 +58,7 @@ namespace OpenSim.world
public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
{
return null;
}
// Sends animation update

View File

@@ -17,7 +17,7 @@ namespace OpenSim.world
public static AvatarAnimations Animations;
public string firstname;
public string lastname;
public ClientView ControllingClient;
public IClientAPI ControllingClient;
public LLUUID current_anim;
public int anim_seq;
private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
@@ -37,7 +37,7 @@ namespace OpenSim.world
private bool m_regionTerraform;
private bool childAvatar = false;
public Avatar(ClientView TheClient, World world, string regionName, Dictionary<uint, ClientView> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater)
public Avatar(IClientAPI TheClient, World world, string regionName, Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater)
{
m_world = world;
// m_clientThreads = clientThreads;
@@ -49,7 +49,7 @@ namespace OpenSim.world
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Avatar.cs - Loading details from grid (DUMMY)");
ControllingClient = TheClient;
localid = 8880000 + (this.m_world._localNumber++);
Pos = ControllingClient.startpos;
Pos = ControllingClient.StartPos;
visualParams = new byte[218];
for (int i = 0; i < 218; i++)
{
@@ -66,14 +66,14 @@ namespace OpenSim.world
this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
//register for events
ControllingClient.OnRequestWearables += new ClientView.GenericCall(this.SendOurAppearance);
ControllingClient.OnRequestWearables += new GenericCall(this.SendOurAppearance);
ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.CompleteMovement);
ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.SendInitialPosition);
ControllingClient.OnAgentUpdate += new ClientView.GenericCall3(this.HandleAgentUpdate);
ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.CompleteMovement);
ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.SendInitialPosition);
ControllingClient.OnAgentUpdate += new GenericCall3(this.HandleAgentUpdate);
ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
ControllingClient.OnChildAgentStatus += new ClientView.StatusChange(this.ChildStatusChange);
ControllingClient.OnStopMovement += new ClientView.GenericCall2(this.StopMovement);
ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
}
public PhysicsActor PhysActor

View File

@@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
@@ -6,7 +6,8 @@
<ProjectGuid>{642A14A8-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.World</AssemblyName>
@@ -15,9 +16,11 @@
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>OpenSim.World</RootNamespace>
<StartupObject></StartupObject>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
@@ -28,7 +31,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
@@ -37,7 +41,8 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@@ -46,7 +51,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
@@ -55,26 +61,27 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<Reference Include="System">
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<Reference Include="System.Xml">
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<Reference Include="libsecondlife.dll">
<HintPath>..\..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Axiom.MathLib.dll" >
<Reference Include="Axiom.MathLib.dll">
<HintPath>..\..\bin\Axiom.MathLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<Reference Include="Db4objects.Db4o.dll">
<HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
@@ -84,43 +91,43 @@
<Name>OpenSim.Terrain.BasicTerrain</Name>
<Project>{2270B8FE-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\Common\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\Common\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj">
<Name>OpenSim.GenericConfig.Xml</Name>
<Project>{E88EF749-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
<Name>OpenSim.Physics.Manager</Name>
<Project>{8BE16150-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\Common\OpenSim.Servers\OpenSim.Servers.csproj">
<Name>OpenSim.Servers</Name>
<Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj">
<Name>XMLRPC</Name>
<Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -142,9 +149,6 @@
<Compile Include="Primitive.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Primitive2.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SceneObject.cs">
<SubType>Code</SubType>
</Compile>
@@ -192,4 +196,4 @@
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>

View File

@@ -7,11 +7,485 @@ using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
using OpenSim.Physics.Manager;
using OpenSim.Framework.Types;
using OpenSim.Framework.Inventory;
namespace OpenSim.world
{
public class Primitive : Entity
{
protected PrimData primData;
//private ObjectUpdatePacket OurPacket;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
private Dictionary<uint, IClientAPI> m_clientThreads;
private ulong m_regionHandle;
private const uint FULL_MASK_PERMISSIONS = 2147483647;
private bool physicsEnabled = false;
private Dictionary<LLUUID, InventoryItem> inventoryItems;
#region Properties
public LLVector3 Scale
{
set
{
this.primData.Scale = value;
//this.dirtyFlag = true;
}
get
{
return this.primData.Scale;
}
}
public PhysicsActor PhysActor
{
set
{
this._physActor = value;
}
}
public override LLVector3 Pos
{
get
{
return base.Pos;
}
set
{
base.Pos = value;
}
}
#endregion
public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world)
{
m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
}
public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner)
{
m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.primData = new PrimData();
this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
this.primData.OwnerID = owner;
}
public byte[] GetByteArray()
{
byte[] result = null;
List<byte[]> dataArrays = new List<byte[]>();
dataArrays.Add(primData.ToBytes());
foreach (Entity child in children)
{
if (child is OpenSim.world.Primitive)
{
dataArrays.Add(((OpenSim.world.Primitive)child).GetByteArray());
}
}
byte[] primstart = Helpers.StringToField("<Prim>");
byte[] primend = Helpers.StringToField("</Prim>");
int totalLength = primstart.Length + primend.Length;
for (int i = 0; i < dataArrays.Count; i++)
{
totalLength += dataArrays[i].Length;
}
result = new byte[totalLength];
int arraypos = 0;
Array.Copy(primstart, 0, result, 0, primstart.Length);
arraypos += primstart.Length;
for (int i = 0; i < dataArrays.Count; i++)
{
Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
arraypos += dataArrays[i].Length;
}
Array.Copy(primend, 0, result, arraypos, primend.Length);
return result;
}
#region Overridden Methods
public override void update()
{
LLVector3 pos2 = new LLVector3(0, 0, 0);
}
public override void BackUp()
{
}
#endregion
#region Packet handlers
public void UpdatePosition(LLVector3 pos)
{
}
public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
{
this.primData.PathBegin = addPacket.PathBegin;
this.primData.PathEnd = addPacket.PathEnd;
this.primData.PathScaleX = addPacket.PathScaleX;
this.primData.PathScaleY = addPacket.PathScaleY;
this.primData.PathShearX = addPacket.PathShearX;
this.primData.PathShearY = addPacket.PathShearY;
this.primData.PathSkew = addPacket.PathSkew;
this.primData.ProfileBegin = addPacket.ProfileBegin;
this.primData.ProfileEnd = addPacket.ProfileEnd;
this.primData.PathCurve = addPacket.PathCurve;
this.primData.ProfileCurve = addPacket.ProfileCurve;
this.primData.ProfileHollow = addPacket.ProfileHollow;
this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
this.primData.PathRevolutions = addPacket.PathRevolutions;
this.primData.PathTaperX = addPacket.PathTaperX;
this.primData.PathTaperY = addPacket.PathTaperY;
this.primData.PathTwist = addPacket.PathTwist;
this.primData.PathTwistBegin = addPacket.PathTwistBegin;
}
public void UpdateTexture(byte[] tex)
{
this.primData.Texture = tex;
//this.dirtyFlag = true;
}
public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
{
}
public void AssignToParent(Primitive prim)
{
}
public void GetProperites(IClientAPI client)
{
ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
proper.ObjectData[0].ItemID = LLUUID.Zero;
proper.ObjectData[0].CreationDate = (ulong)this.primData.CreationDate;
proper.ObjectData[0].CreatorID = this.primData.OwnerID;
proper.ObjectData[0].FolderID = LLUUID.Zero;
proper.ObjectData[0].FromTaskID = LLUUID.Zero;
proper.ObjectData[0].GroupID = LLUUID.Zero;
proper.ObjectData[0].InventorySerial = 0;
proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
proper.ObjectData[0].ObjectID = this.uuid;
proper.ObjectData[0].OwnerID = primData.OwnerID;
proper.ObjectData[0].TouchName = new byte[0];
proper.ObjectData[0].TextureID = new byte[0];
proper.ObjectData[0].SitName = new byte[0];
proper.ObjectData[0].Name = new byte[0];
proper.ObjectData[0].Description = new byte[0];
proper.ObjectData[0].OwnerMask = this.primData.OwnerMask;
proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask;
proper.ObjectData[0].GroupMask = this.primData.GroupMask;
proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask;
proper.ObjectData[0].BaseMask = this.primData.BaseMask;
client.OutPacket(proper);
}
#endregion
# region Inventory Methods
public bool AddToInventory(InventoryItem item)
{
return false;
}
public InventoryItem RemoveFromInventory(LLUUID itemID)
{
return null;
}
public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
{
}
public void RequestXferInventory(IClientAPI simClient, ulong xferID)
{
//will only currently work if the total size of the inventory data array is under about 1000 bytes
SendXferPacketPacket send = new SendXferPacketPacket();
send.XferID.ID = xferID;
send.XferID.Packet = 1 + 2147483648;
send.DataPacket.Data = this.ConvertInventoryToBytes();
simClient.OutPacket(send);
}
public byte[] ConvertInventoryToBytes()
{
System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] result = new byte[0];
List<byte[]> inventoryData = new List<byte[]>();
int totallength = 0;
foreach (InventoryItem invItem in inventoryItems.Values)
{
byte[] data = enc.GetBytes(invItem.ExportString());
inventoryData.Add(data);
totallength += data.Length;
}
//TODO: copy arrays into the single result array
return result;
}
public void CreateInventoryFromBytes(byte[] data)
{
}
#endregion
#region Update viewers Methods
//should change these mehtods, so that outgoing packets are sent through the avatar class
public void SendFullUpdateToClient(IClientAPI remoteClient)
{
LLVector3 lPos;
if (this._physActor != null && this.physicsEnabled)
{
PhysicsVector pPos = this._physActor.Position;
lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
}
else
{
lPos = this.Pos;
}
ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
outPacket.ObjectData[0] = this.CreateUpdateBlock();
byte[] pb = lPos.GetBytes();
Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
remoteClient.OutPacket(outPacket);
}
public void SendFullUpdateToAllClients()
{
}
public void SendTerseUpdateToClient(IClientAPI RemoteClient)
{
}
public void SendTerseUpdateToALLClients()
{
}
#endregion
#region Create Methods
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
{
PrimData PData = new PrimData();
this.primData = PData;
this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
PData.OwnerID = ownerID;
PData.PCode = addPacket.ObjectData.PCode;
PData.PathBegin = addPacket.ObjectData.PathBegin;
PData.PathEnd = addPacket.ObjectData.PathEnd;
PData.PathScaleX = addPacket.ObjectData.PathScaleX;
PData.PathScaleY = addPacket.ObjectData.PathScaleY;
PData.PathShearX = addPacket.ObjectData.PathShearX;
PData.PathShearY = addPacket.ObjectData.PathShearY;
PData.PathSkew = addPacket.ObjectData.PathSkew;
PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
PData.Scale = addPacket.ObjectData.Scale;
PData.PathCurve = addPacket.ObjectData.PathCurve;
PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
PData.ParentID = 0;
PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
PData.PathTaperX = addPacket.ObjectData.PathTaperX;
PData.PathTaperY = addPacket.ObjectData.PathTaperY;
PData.PathTwist = addPacket.ObjectData.PathTwist;
PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
LLVector3 pos1 = addPacket.ObjectData.RayEnd;
this.primData.FullID = this.uuid = LLUUID.Random();
this.localid = (uint)(localID);
this.primData.Position = this.Pos = pos1;
}
public void CreateFromBytes(byte[] data)
{
}
public void CreateFromPrimData(PrimData primData)
{
this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
}
public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
{
}
#endregion
#region Packet Update Methods
protected void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
{
objdata.PSBlock = new byte[0];
objdata.ExtraParams = new byte[1];
objdata.MediaURL = new byte[0];
objdata.NameValue = new byte[0];
objdata.Text = new byte[0];
objdata.TextColor = new byte[4];
objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
objdata.JointPivot = new LLVector3(0, 0, 0);
objdata.Material = 3;
objdata.TextureAnim = new byte[0];
objdata.Sound = LLUUID.Zero;
LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
this.primData.Texture = objdata.TextureEntry = ntex.ToBytes();
objdata.State = 0;
objdata.Data = new byte[0];
objdata.ObjectData = new byte[60];
objdata.ObjectData[46] = 128;
objdata.ObjectData[47] = 63;
}
protected void SetPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData)
{
objectData.OwnerID = this.primData.OwnerID;
objectData.PCode = this.primData.PCode;
objectData.PathBegin = this.primData.PathBegin;
objectData.PathEnd = this.primData.PathEnd;
objectData.PathScaleX = this.primData.PathScaleX;
objectData.PathScaleY = this.primData.PathScaleY;
objectData.PathShearX = this.primData.PathShearX;
objectData.PathShearY = this.primData.PathShearY;
objectData.PathSkew = this.primData.PathSkew;
objectData.ProfileBegin = this.primData.ProfileBegin;
objectData.ProfileEnd = this.primData.ProfileEnd;
objectData.Scale = this.primData.Scale;
objectData.PathCurve = this.primData.PathCurve;
objectData.ProfileCurve = this.primData.ProfileCurve;
objectData.ParentID = this.primData.ParentID;
objectData.ProfileHollow = this.primData.ProfileHollow;
objectData.PathRadiusOffset = this.primData.PathRadiusOffset;
objectData.PathRevolutions = this.primData.PathRevolutions;
objectData.PathTaperX = this.primData.PathTaperX;
objectData.PathTaperY = this.primData.PathTaperY;
objectData.PathTwist = this.primData.PathTwist;
objectData.PathTwistBegin = this.primData.PathTwistBegin;
}
#endregion
protected ObjectUpdatePacket.ObjectDataBlock CreateUpdateBlock()
{
ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
this.SetDefaultPacketValues(objupdate);
objupdate.UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
this.SetPacketShapeData(objupdate);
byte[] pb = this.Pos.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData, 0, pb.Length);
return objupdate;
}
protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
{
uint ID = this.localid;
byte[] bytes = new byte[60];
int i = 0;
ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
dat.TextureEntry = new byte[0];
bytes[i++] = (byte)(ID % 256);
bytes[i++] = (byte)((ID >> 8) % 256);
bytes[i++] = (byte)((ID >> 16) % 256);
bytes[i++] = (byte)((ID >> 24) % 256);
bytes[i++] = 0;
bytes[i++] = 0;
LLVector3 lPos;
Axiom.MathLib.Quaternion lRot;
if (this._physActor != null && this.physicsEnabled)
{
PhysicsVector pPos = this._physActor.Position;
lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
lRot = this._physActor.Orientation;
}
else
{
lPos = this.Pos;
lRot = this.rotation;
}
byte[] pb = lPos.GetBytes();
Array.Copy(pb, 0, bytes, i, pb.Length);
i += 12;
ushort ac = 32767;
//vel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//accel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
ushort rw, rx, ry, rz;
rw = (ushort)(32768 * (lRot.w + 1));
rx = (ushort)(32768 * (lRot.x + 1));
ry = (ushort)(32768 * (lRot.y + 1));
rz = (ushort)(32768 * (lRot.z + 1));
//rot
bytes[i++] = (byte)(rx % 256);
bytes[i++] = (byte)((rx >> 8) % 256);
bytes[i++] = (byte)(ry % 256);
bytes[i++] = (byte)((ry >> 8) % 256);
bytes[i++] = (byte)(rz % 256);
bytes[i++] = (byte)((rz >> 8) % 256);
bytes[i++] = (byte)(rw % 256);
bytes[i++] = (byte)((rw >> 8) % 256);
//rotation vel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
dat.Data = bytes;
return dat;
}
}
}

View File

@@ -14,8 +14,8 @@ namespace OpenSim.world
public class SceneObject : Entity
{
private LLUUID rootUUID;
private Dictionary<LLUUID, Primitive2> ChildPrimitives = new Dictionary<LLUUID, Primitive2>();
private Dictionary<uint, ClientView> m_clientThreads;
private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>();
private Dictionary<uint, IClientAPI> m_clientThreads;
private World m_world;
public SceneObject()
@@ -42,7 +42,7 @@ namespace OpenSim.world
}
public void GetProperites(ClientView client)
public void GetProperites(IClientAPI client)
{
/*
ObjectPropertiesPacket proper = new ObjectPropertiesPacket();

View File

@@ -6,10 +6,8 @@ using libsecondlife.Packets;
using OpenSim.Physics.Manager;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using OpenSim.Framework.Terrain;
using OpenSim.Framework.Inventory;
using OpenSim.Framework.Utilities;
using OpenSim.Assets;
namespace OpenSim.world
{
@@ -35,10 +33,10 @@ namespace OpenSim.world
public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
{
foreach (ClientView client in m_clientThreads.Values)
foreach (IClientAPI client in m_clientThreads.Values)
{
// int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos);
int dis = 0; // (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos);
switch (type)
{
@@ -72,190 +70,57 @@ namespace OpenSim.world
public void RezObject(AssetBase primAsset, LLVector3 pos)
{
PrimData primd = new PrimData(primAsset.Data);
Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
nPrim.CreateFromStorage(primd, pos, this._primCount, true);
this.Entities.Add(nPrim.uuid, nPrim);
this._primCount++;
}
public void DeRezObject(Packet packet, ClientView simClient)
public void DeRezObject(Packet packet, IClientAPI simClient)
{
DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
}
//Needs to delete object from physics at a later date
if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
{
//currently following code not used (or don't know of any case of destination being zero
}
else
{
foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
{
Entity selectedEnt = null;
//OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
foreach (Entity ent in this.Entities.Values)
{
if (ent.localid == Data.ObjectLocalID)
{
AssetBase primAsset = new AssetBase();
primAsset.FullID = LLUUID.Random();//DeRezPacket.AgentBlock.TransactionID.Combine(LLUUID.Zero); //should be combining with securesessionid
primAsset.InvType = 6;
primAsset.Type = 6;
primAsset.Name = "Prim";
primAsset.Description = "";
primAsset.Data = ((Primitive)ent).GetByteArray();
this._assetCache.AddAsset(primAsset);
this._inventoryCache.AddNewInventoryItem(simClient, DeRezPacket.AgentBlock.DestinationID, primAsset);
selectedEnt = ent;
break;
}
}
if (selectedEnt != null)
{
this.localStorage.RemovePrim(selectedEnt.uuid);
KillObjectPacket kill = new KillObjectPacket();
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
kill.ObjectData[0].ID = selectedEnt.localid;
foreach (ClientView client in m_clientThreads.Values)
{
client.OutPacket(kill);
}
lock (Entities)
{
Entities.Remove(selectedEnt.uuid);
}
}
}
}
public void SendAvatarsToClient(IClientAPI remoteClient)
{
}
public void SendAvatarsToClient(ClientView remoteClient)
{
foreach (ClientView client in m_clientThreads.Values)
{
if (client.AgentID != remoteClient.AgentID)
{
// ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket();
// RemoteClient.OutPacket(objupdate);
client.ClientAvatar.SendUpdateToOtherClient(remoteClient.ClientAvatar);
client.ClientAvatar.SendAppearanceToOtherAgent(remoteClient.ClientAvatar);
}
}
}
public void LinkObjects(uint parentPrim, List<uint> childPrims)
{
Primitive parentprim = null;
foreach (Entity ent in Entities.Values)
{
if (ent.localid == parentPrim)
{
parentprim = (OpenSim.world.Primitive)ent;
}
}
for (int i = 0; i < childPrims.Count; i++)
{
uint childId = childPrims[i];
foreach (Entity ent in Entities.Values)
{
if (ent.localid == childId)
{
((OpenSim.world.Primitive)ent).MakeParent(parentprim);
}
}
}
}
public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
{
foreach (Entity ent in Entities.Values)
{
if (ent.localid == primLocalID)
{
((OpenSim.world.Primitive)ent).UpdateShape(shapeBlock);
break;
}
}
}
public void SelectPrim(uint primLocalID, ClientView remoteClient)
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
{
foreach (Entity ent in Entities.Values)
{
if (ent.localid == primLocalID)
{
((OpenSim.world.Primitive)ent).GetProperites(remoteClient);
break;
}
}
}
public void UpdatePrimFlags(uint localID, Packet packet, ClientView remoteClient)
public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient)
{
foreach (Entity ent in Entities.Values)
{
if (ent.localid == localID)
{
((OpenSim.world.Primitive)ent).UpdateObjectFlags((ObjectFlagUpdatePacket) packet);
break;
}
}
}
public void UpdatePrimTexture(uint localID, byte[] texture, ClientView remoteClient)
public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
{
foreach (Entity ent in Entities.Values)
{
if (ent.localid == localID)
{
((OpenSim.world.Primitive)ent).UpdateTexture(texture);
break;
}
}
}
public void UpdatePrimPosition(uint localID, LLVector3 pos, ClientView remoteClient)
public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
{
foreach (Entity ent in Entities.Values)
{
if (ent.localid == localID)
{
((OpenSim.world.Primitive)ent).UpdatePosition(pos);
break;
}
}
}
public void UpdatePrimRotation(uint localID, LLQuaternion rot, ClientView remoteClient)
public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
{
foreach (Entity ent in Entities.Values)
{
if (ent.localid == localID)
{
ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
((OpenSim.world.Primitive)ent).UpdateFlag = true;
break;
}
}
}
public void UpdatePrimScale(uint localID, LLVector3 scale, ClientView remoteClient)
public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
{
foreach (Entity ent in Entities.Values)
{
if (ent.localid == localID)
{
((OpenSim.world.Primitive)ent).Scale = scale;
break;
}
}
}
}
}

View File

@@ -96,7 +96,7 @@ namespace OpenSim.world
pos.Y = y;
Primitive prim = entity as Primitive;
// Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
prim.UpdatePosition(pos);
//prim.UpdatePosition(pos);
// Console.WriteLine("script- setting entity " + localID + " positon");
}
}

View File

@@ -6,13 +6,11 @@ using System.Text;
using System.Reflection;
using System.IO;
using System.Threading;
using System.Timers;
using OpenSim.Physics.Manager;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using OpenSim.Framework.Terrain;
using OpenSim.Framework.Inventory;
using OpenSim.Assets;
//using OpenSim.world.scripting;
using OpenSim.RegionServer.world.scripting;
using OpenSim.Terrain;
@@ -20,6 +18,7 @@ namespace OpenSim.world
{
public partial class World : WorldBase, ILocalStorageReceiver, IScriptAPI
{
protected System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer();
public object LockPhysicsEngine = new object();
public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
@@ -57,15 +56,16 @@ namespace OpenSim.world
/// <param name="clientThreads">Dictionary to contain client threads</param>
/// <param name="regionHandle">Region Handle for this region</param>
/// <param name="regionName">Region Name for this region</param>
public World(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName)
public World(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo)
{
try
{
updateLock = new Mutex(false);
m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_regionName = regionName;
m_regInfo = regInfo;
m_regionHandle = m_regInfo.RegionHandle;
m_regionName = m_regInfo.RegionName;
this.m_datastore = m_regInfo.DataStore;
m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
m_scripts = new Dictionary<string, ScriptFactory>();
@@ -85,6 +85,8 @@ namespace OpenSim.world
Avatar.LoadAnims();
this.SetDefaultScripts();
this.LoadScriptEngines();
}
catch (Exception e)
{
@@ -93,6 +95,13 @@ namespace OpenSim.world
}
#endregion
public void StartTimer()
{
m_heartbeatTimer.Enabled = true;
m_heartbeatTimer.Interval = 100;
m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
}
#region Script Methods
/// <summary>
/// Loads a new script into the specified entity
@@ -167,6 +176,18 @@ namespace OpenSim.world
#endregion
#region Update Methods
/// <summary>
/// Performs per-frame updates regularly
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Heartbeat(object sender, System.EventArgs e)
{
this.Update();
}
/// <summary>
/// Performs per-frame updates on the world, this should be the central world loop
/// </summary>
@@ -327,7 +348,7 @@ namespace OpenSim.world
}
this.localStorage.SaveMap(this.Terrain.getHeights1D());
foreach (ClientView client in m_clientThreads.Values)
foreach (IClientAPI client in m_clientThreads.Values)
{
this.SendLayerData(client);
}
@@ -358,7 +379,7 @@ namespace OpenSim.world
}
this.localStorage.SaveMap(this.Terrain.getHeights1D());
foreach (ClientView client in m_clientThreads.Values)
foreach (IClientAPI client in m_clientThreads.Values)
{
this.SendLayerData(client);
}
@@ -388,7 +409,7 @@ namespace OpenSim.world
{
/* Dont save here, rely on tainting system instead */
foreach (ClientView client in m_clientThreads.Values)
foreach (IClientAPI client in m_clientThreads.Values)
{
this.SendLayerData(pointx, pointy, client);
}
@@ -436,23 +457,9 @@ namespace OpenSim.world
/// Sends prims to a client
/// </summary>
/// <param name="RemoteClient">Client to send to</param>
public void GetInitialPrims(ClientView RemoteClient)
public void GetInitialPrims(IClientAPI RemoteClient)
{
try
{
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
{
if (Entities[UUID] is Primitive)
{
Primitive primitive = Entities[UUID] as Primitive;
primitive.UpdateClient(RemoteClient);
}
}
}
catch (Exception e)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: GetInitialPrims() - Failed with exception " + e.ToString());
}
}
/// <summary>
@@ -477,67 +484,32 @@ namespace OpenSim.world
/// <param name="prim">The object to load</param>
public void PrimFromStorage(PrimData prim)
{
try
{
if (prim.LocalID >= this._primCount)
{
_primCount = prim.LocalID + 1;
}
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: PrimFromStorage() - Reloading prim (localId " + prim.LocalID + " ) from storage");
Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
nPrim.CreateFromStorage(prim);
this.Entities.Add(nPrim.uuid, nPrim);
}
catch (Exception e)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: PrimFromStorage() - Failed with exception " + e.ToString());
}
}
public void AddNewPrim(Packet addPacket, ClientView agentClient)
public void AddNewPrim(Packet addPacket, IClientAPI agentClient)
{
AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentID);
AddNewPrim((ObjectAddPacket)addPacket, agentClient.AgentId);
}
public void AddNewPrim(ObjectAddPacket addPacket, LLUUID ownerID)
{
try
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs: AddNewPrim() - Creating new prim");
Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this);
prim.CreateFromPacket(addPacket, ownerID, this._primCount);
PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z);
PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f);
if (OpenSim.world.Avatar.PhysicsEngineFlying)
{
lock (this.LockPhysicsEngine)
{
prim.PhysActor = this.phyScene.AddPrim(pVec, pSize);
}
}
this.Entities.Add(prim.uuid, prim);
this._primCount++;
}
catch (Exception e)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "World.cs: AddNewPrim() - Failed with exception " + e.ToString());
}
}
#endregion
#region Add/Remove Avatar Methods
public override Avatar AddViewerAgent(ClientView agentClient)
public override bool AddNewAvatar(IClientAPI agentClient, bool child)
{
Avatar newAvatar = null;
return newAvatar;
return false;
}
public override void RemoveViewerAgent(ClientView agentClient)
public override bool RemoveAvatar(LLUUID agentID)
{
return false;
}
#endregion

View File

@@ -9,28 +9,27 @@ using System.Threading;
using OpenSim.Physics.Manager;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using OpenSim.Framework.Terrain;
using OpenSim.Framework.Inventory;
using OpenSim.Assets;
using OpenSim.RegionServer.world.scripting;
using OpenSim.Terrain;
namespace OpenSim.world
{
public class WorldBase
public class WorldBase : IWorld
{
public Dictionary<libsecondlife.LLUUID, Entity> Entities;
protected Dictionary<uint, IClientAPI> m_clientThreads;
protected ulong m_regionHandle;
protected string m_regionName;
protected InventoryCache _inventoryCache;
protected AssetCache _assetCache;
// protected InventoryCache _inventoryCache;
// protected AssetCache _assetCache;
protected RegionInfo m_regInfo;
public TerrainEngine Terrain; //TODO: Replace TerrainManager with this.
protected libsecondlife.TerrainManager TerrainManager; // To be referenced via TerrainEngine
#region Properties
/*
public InventoryCache InventoryCache
{
set
@@ -46,6 +45,7 @@ namespace OpenSim.world
this._assetCache = value;
}
}
*/
#endregion
#region Constructors
@@ -56,14 +56,7 @@ namespace OpenSim.world
#endregion
#region Setup Methods
/// <summary>
/// Register Packet handler Methods with the packet server (which will register them with the SimClient)
/// </summary>
/// <param name="packetServer"></param>
public virtual void RegisterPacketHandlers(PacketServer packetServer)
{
}
#endregion
#region Update Methods
@@ -90,7 +83,7 @@ namespace OpenSim.world
/// Send the region heightmap to the client
/// </summary>
/// <param name="RemoteClient">Client to send to</param>
public virtual void SendLayerData(ClientView RemoteClient)
public virtual void SendLayerData(IClientAPI RemoteClient)
{
try
{
@@ -122,7 +115,7 @@ namespace OpenSim.world
/// <param name="px">Patch coordinate (x) 0..16</param>
/// <param name="py">Patch coordinate (y) 0..16</param>
/// <param name="RemoteClient">The client to send to</param>
public void SendLayerData(int px, int py, ClientView RemoteClient)
public void SendLayerData(int px, int py, IClientAPI RemoteClient)
{
try
{
@@ -144,25 +137,23 @@ namespace OpenSim.world
#endregion
#region Add/Remove Agent/Avatar
/// <summary>
/// Add a new Agent's avatar
/// </summary>
/// <param name="agentClient"></param>
public virtual Avatar AddViewerAgent(ClientView agentClient)
public virtual bool AddNewAvatar(IClientAPI remoteClient, bool child)
{
return false;
}
public virtual bool RemoveAvatar(LLUUID agentID)
{
return false;
}
#endregion
public virtual RegionInfo GetRegionInfo()
{
return null;
}
/// <summary>
/// Remove a Agent's avatar
/// </summary>
/// <param name="agentClient"></param>
public virtual void RemoveViewerAgent(ClientView agentClient)
{
}
#endregion
#region Shutdown
/// <summary>
/// Tidy before shutdown

View File

@@ -87,7 +87,7 @@ namespace OpenSim.RegionServer.world.scripting
{
Primitive prim = m_entity as Primitive;
// Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
prim.UpdatePosition( value );
// prim.UpdatePosition( value );
}
}
}