Patch from Johan: LibSL updated to the latest revision (1568) and all packets are now

recycled to improve performance and memory usage.
afrisby
Adam Johnson 2007-12-28 08:51:39 +00:00
parent 8cd72beb86
commit 79496381fc
11 changed files with 308 additions and 242 deletions

View File

@ -26,11 +26,9 @@
*
*/
using System;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Console;
namespace OpenSim.Framework
{
@ -42,6 +40,7 @@ namespace OpenSim.Framework
public void ForEachClient(ForEachClientDelegate whatToDo)
{
// Wasteful, I know
IClientAPI[] LocalClients = new IClientAPI[0];
lock (m_clients)
@ -56,11 +55,9 @@ namespace OpenSim.Framework
{
whatToDo(LocalClients[i]);
}
catch (Exception e)
catch (System.Exception e)
{
MainLog.Instance.Warn("CLIENT",
"Unable to do ForEachClient for one of the clients" + "\n Reason: " +
e.ToString());
OpenSim.Framework.Console.MainLog.Instance.Warn("CLIENT", "Unable to do ForEachClient for one of the clients" + "\n Reason: " + e.ToString());
}
}
}
@ -110,19 +107,20 @@ namespace OpenSim.Framework
IClientAPI client;
try
{
if (m_clients.TryGetValue(circuits[i], out client))
{
Remove(client.CircuitCode);
client.Close(false);
}
}
catch (Exception e)
catch (System.Exception e)
{
MainLog.Instance.Error("CLIENT",
"Unable to shutdown circuit for: " + agentId.ToString() + "\n Reason: " +
e.ToString());
OpenSim.Framework.Console.MainLog.Instance.Error("CLIENT", "Unable to shutdown circuit for: " + agentId.ToString() + "\n Reason: " + e.ToString());
}
}
}
private uint[] GetAllCircuits(LLUUID agentId)
@ -150,7 +148,8 @@ namespace OpenSim.Framework
public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock)
{
ViewerEffectPacket packet = new ViewerEffectPacket();
ViewerEffectPacket packet = (ViewerEffectPacket) PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
// TODO: don't create new blocks if recycling an old packet
packet.Effect = effectBlock;
// Wasteful, I know
@ -170,6 +169,7 @@ namespace OpenSim.Framework
packet.AgentData.SessionID = LocalClients[i].SessionId;
LocalClients[i].OutPacket(packet, ThrottleOutPacketType.Task);
}
}
}

View File

@ -0,0 +1,131 @@
/*
* 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 OpenSim 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.Collections;
using libsecondlife.Packets;
namespace OpenSim.Framework
{
public sealed class PacketPool
{
// Set up a thread-safe singleton pattern
static PacketPool()
{
}
private static readonly PacketPool instance = new PacketPool();
public static PacketPool Instance
{
get { return instance; }
}
private Hashtable pool = new Hashtable();
public Packet GetPacket(PacketType type)
{
Packet packet = null;
lock (pool)
{
if (pool[type] == null || ((Stack) pool[type]).Count == 0)
{
// Creating a new packet if we cannot reuse an old package
packet = Packet.BuildPacket(type);
}
else
{
// Recycle old packages
packet = (Packet) ((Stack) pool[type]).Pop();
}
}
return packet;
}
private byte[] decoded_header = new byte[10];
private PacketType GetType(byte[] bytes)
{
ushort id;
libsecondlife.PacketFrequency freq;
Buffer.BlockCopy(bytes, 0, decoded_header, 0, 10);
if((bytes[0] & libsecondlife.Helpers.MSG_ZEROCODED)!=0)
{
libsecondlife.Helpers.ZeroDecodeCommand(bytes, decoded_header);
}
if (decoded_header[6] == 0xFF)
{
if (decoded_header[7] == 0xFF)
{
id = (ushort)((decoded_header[8] << 8) + decoded_header[9]);
freq = libsecondlife.PacketFrequency.Low;
}
else
{
id = (ushort)decoded_header[7];
freq = libsecondlife.PacketFrequency.Medium;
}
}
else
{
id = (ushort)decoded_header[6];
freq = libsecondlife.PacketFrequency.High;
}
return Packet.GetType(id, freq);
}
public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer)
{
PacketType type = GetType(bytes);
int i = 0;
Packet packet = GetPacket(type);
packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer);
return packet;
}
public void ReturnPacket(Packet packet)
{
lock (pool)
{
PacketType type = packet.Type;
if (pool[type] == null)
{
pool[type] = new Stack();
}
((Stack) pool[type]).Push(packet);
}
}
}
}

View File

@ -66,6 +66,7 @@ namespace OpenSim.Region.ClientStack
private int m_packetsReceived = 0;
private int m_probesWithNoIngressPackets = 0;
private int m_lastPacketsReceived = 0;
private byte[] ZeroOutBuffer = new byte[4096];
private readonly Encoding m_encoding = Encoding.ASCII;
private readonly LLUUID m_agentId;
@ -215,7 +216,7 @@ namespace OpenSim.Region.ClientStack
{
m_scene.RemoveClient(AgentId);
// Send the STOP packet
DisableSimulatorPacket disable = new DisableSimulatorPacket();
DisableSimulatorPacket disable = (DisableSimulatorPacket) PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
OutPacket(disable, ThrottleOutPacketType.Task);
@ -256,7 +257,7 @@ namespace OpenSim.Region.ClientStack
public void Kick(string message)
{
KickUserPacket kupack = new KickUserPacket();
KickUserPacket kupack = (KickUserPacket) PacketPool.Instance.GetPacket(PacketType.KickUser);
kupack.UserInfo.AgentID = AgentId;
kupack.UserInfo.SessionID = SessionId;
kupack.TargetBlock.TargetIP = (uint) 0;
@ -558,8 +559,7 @@ namespace OpenSim.Region.ClientStack
/// <param name="regionInfo"></param>
public void SendRegionHandshake(RegionInfo regionInfo)
{
RegionHandshakePacket handshake =
(RegionHandshakePacket) PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
RegionHandshakePacket handshake = (RegionHandshakePacket) PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
handshake.RegionInfo.BillableFactor = regionInfo.EstateSettings.billableFactor;
handshake.RegionInfo.IsEstateManager = false;
@ -596,7 +596,7 @@ namespace OpenSim.Region.ClientStack
/// <param name="regInfo"></param>
public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look)
{
AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
AgentMovementCompletePacket mov = (AgentMovementCompletePacket) PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
mov.SimData.ChannelVersion = m_channelVersion;
mov.AgentData.SessionID = m_sessionId;
mov.AgentData.AgentID = AgentId;
@ -631,7 +631,7 @@ namespace OpenSim.Region.ClientStack
public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
{
ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket) PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
reply.ChatData.Audible = 1;
reply.ChatData.Message = message;
reply.ChatData.ChatType = type;
@ -652,7 +652,7 @@ namespace OpenSim.Region.ClientStack
public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent,
LLUUID imSessionID, string fromName, byte dialog, uint timeStamp)
{
ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket();
ImprovedInstantMessagePacket msg = (ImprovedInstantMessagePacket) PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
msg.AgentData.AgentID = fromAgent;
msg.AgentData.SessionID = fromAgentSession;
msg.MessageBlock.FromAgentName = Helpers.StringToField(fromName);
@ -740,7 +740,8 @@ namespace OpenSim.Region.ClientStack
IPAddress neighbourIP = neighbourEndPoint.Address;
ushort neighbourPort = (ushort) neighbourEndPoint.Port;
EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket) PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
// TODO: don't create new blocks if recycling an old packet
enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
@ -776,7 +777,8 @@ namespace OpenSim.Region.ClientStack
{
LLVector3 look = new LLVector3(lookAt.X*10, lookAt.Y*10, lookAt.Z*10);
CrossedRegionPacket newSimPack = new CrossedRegionPacket();
CrossedRegionPacket newSimPack = (CrossedRegionPacket) PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
// TODO: don't create new blocks if recycling an old packet
newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
newSimPack.AgentData.AgentID = AgentId;
newSimPack.AgentData.SessionID = m_sessionId;
@ -798,7 +800,8 @@ namespace OpenSim.Region.ClientStack
public void SendMapBlock(List<MapBlockData> mapBlocks)
{
MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
MapBlockReplyPacket mapReply = (MapBlockReplyPacket) PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
// TODO: don't create new blocks if recycling an old packet
mapReply.AgentData.AgentID = AgentId;
mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count];
mapReply.AgentData.Flags = 0;
@ -820,7 +823,7 @@ namespace OpenSim.Region.ClientStack
public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags)
{
TeleportLocalPacket tpLocal = new TeleportLocalPacket();
TeleportLocalPacket tpLocal = (TeleportLocalPacket) PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
tpLocal.Info.AgentID = AgentId;
tpLocal.Info.TeleportFlags = flags;
tpLocal.Info.LocationID = 2;
@ -832,7 +835,7 @@ namespace OpenSim.Region.ClientStack
public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
uint flags, string capsURL)
{
TeleportFinishPacket teleport = new TeleportFinishPacket();
TeleportFinishPacket teleport = (TeleportFinishPacket) PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
teleport.Info.AgentID = AgentId;
teleport.Info.RegionHandle = regionHandle;
teleport.Info.SimAccess = simAccess;
@ -858,7 +861,7 @@ namespace OpenSim.Region.ClientStack
/// </summary>
public void SendTeleportFailed()
{
TeleportFailedPacket tpFailed = new TeleportFailedPacket();
TeleportFailedPacket tpFailed = (TeleportFailedPacket) PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
tpFailed.Info.AgentID = AgentId;
tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport");
OutPacket(tpFailed, ThrottleOutPacketType.Task);
@ -869,14 +872,14 @@ namespace OpenSim.Region.ClientStack
/// </summary>
public void SendTeleportLocationStart()
{
TeleportStartPacket tpStart = new TeleportStartPacket();
TeleportStartPacket tpStart = (TeleportStartPacket) PacketPool.Instance.GetPacket(PacketType.TeleportStart);
tpStart.Info.TeleportFlags = 16; // Teleport via location
OutPacket(tpStart, ThrottleOutPacketType.Task);
}
public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance)
{
MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket();
MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket) PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
money.MoneyData.AgentID = AgentId;
money.MoneyData.TransactionID = transaction;
money.MoneyData.TransactionSuccess = success;
@ -887,7 +890,7 @@ namespace OpenSim.Region.ClientStack
public void SendStartPingCheck(byte seq)
{
StartPingCheckPacket pc = new StartPingCheckPacket();
StartPingCheckPacket pc = (StartPingCheckPacket) PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
pc.PingID.PingID = seq;
pc.Header.Reliable = false;
OutPacket(pc, ThrottleOutPacketType.Task);
@ -895,7 +898,8 @@ namespace OpenSim.Region.ClientStack
public void SendKillObject(ulong regionHandle, uint localID)
{
KillObjectPacket kill = new KillObjectPacket();
KillObjectPacket kill = (KillObjectPacket) PacketPool.Instance.GetPacket(PacketType.KillObject);
// TODO: don't create new blocks if recycling an old packet
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
kill.ObjectData[0].ID = localID;
@ -1088,7 +1092,7 @@ namespace OpenSim.Region.ClientStack
private InventoryDescendentsPacket CreateInventoryDescendentsPacket(LLUUID ownerID, LLUUID folderID)
{
InventoryDescendentsPacket descend = new InventoryDescendentsPacket();
InventoryDescendentsPacket descend = (InventoryDescendentsPacket) PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
descend.AgentData.AgentID = AgentId;
descend.AgentData.OwnerID = ownerID;
descend.AgentData.FolderID = folderID;
@ -1101,7 +1105,8 @@ namespace OpenSim.Region.ClientStack
{
Encoding enc = Encoding.ASCII;
uint FULL_MASK_PERMISSIONS = 2147483647;
FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket();
FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket) PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
// TODO: don't create new blocks if recycling an old packet
inventoryReply.AgentData.AgentID = AgentId;
inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
@ -1142,7 +1147,8 @@ namespace OpenSim.Region.ClientStack
{
Encoding enc = Encoding.ASCII;
uint FULL_MASK_PERMISSIONS = 2147483647;
UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket();
UpdateCreateInventoryItemPacket InventoryReply = (UpdateCreateInventoryItemPacket) PacketPool.Instance.GetPacket(PacketType.UpdateCreateInventoryItem);
// TODO: don't create new blocks if recycling an old packet
InventoryReply.AgentData.AgentID = AgentId;
InventoryReply.AgentData.SimApproved = true;
InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
@ -1180,7 +1186,8 @@ namespace OpenSim.Region.ClientStack
public void SendRemoveInventoryItem(LLUUID itemID)
{
RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket();
RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket) PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
// TODO: don't create new blocks if recycling an old packet
remove.AgentData.AgentID = AgentId;
remove.AgentData.SessionID = m_sessionId;
remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
@ -1192,7 +1199,7 @@ namespace OpenSim.Region.ClientStack
public void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName)
{
ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket();
ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket) PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
replytask.InventoryData.TaskID = taskID;
replytask.InventoryData.Serial = serial;
replytask.InventoryData.Filename = fileName;
@ -1201,7 +1208,7 @@ namespace OpenSim.Region.ClientStack
public void SendXferPacket(ulong xferID, uint packet, byte[] data)
{
SendXferPacketPacket sendXfer = new SendXferPacketPacket();
SendXferPacketPacket sendXfer = (SendXferPacketPacket) PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
sendXfer.XferID.ID = xferID;
sendXfer.XferID.Packet = packet;
sendXfer.DataPacket.Data = data;
@ -1219,7 +1226,7 @@ namespace OpenSim.Region.ClientStack
/// <param name="message"></param>
public void SendAlertMessage(string message)
{
AlertMessagePacket alertPack = new AlertMessagePacket();
AlertMessagePacket alertPack = (AlertMessagePacket) PacketPool.Instance.GetPacket(PacketType.AlertMessage);
alertPack.AlertData.Message = Helpers.StringToField(message);
OutPacket(alertPack, ThrottleOutPacketType.Task);
}
@ -1231,7 +1238,7 @@ namespace OpenSim.Region.ClientStack
/// <param name="modal"></param>
public void SendAgentAlertMessage(string message, bool modal)
{
AgentAlertMessagePacket alertPack = new AgentAlertMessagePacket();
AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket) PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
alertPack.AgentData.AgentID = AgentId;
alertPack.AlertData.Message = Helpers.StringToField(message);
alertPack.AlertData.Modal = modal;
@ -1241,7 +1248,7 @@ namespace OpenSim.Region.ClientStack
public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message,
string url)
{
LoadURLPacket loadURL = new LoadURLPacket();
LoadURLPacket loadURL = (LoadURLPacket) PacketPool.Instance.GetPacket(PacketType.LoadURL);
loadURL.Data.ObjectName = Helpers.StringToField(objectname);
loadURL.Data.ObjectID = objectID;
loadURL.Data.OwnerID = ownerID;
@ -1255,7 +1262,8 @@ namespace OpenSim.Region.ClientStack
public void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID)
{
PreloadSoundPacket preSound = new PreloadSoundPacket();
PreloadSoundPacket preSound = (PreloadSoundPacket) PacketPool.Instance.GetPacket(PacketType.PreloadSound);
// TODO: don't create new blocks if recycling an old packet
preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
preSound.DataBlock[0].ObjectID = objectID;
@ -1266,7 +1274,7 @@ namespace OpenSim.Region.ClientStack
public void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags)
{
AttachedSoundPacket sound = new AttachedSoundPacket();
AttachedSoundPacket sound = (AttachedSoundPacket) PacketPool.Instance.GetPacket(PacketType.AttachedSound);
sound.DataBlock.SoundID = soundID;
sound.DataBlock.ObjectID = objectID;
sound.DataBlock.OwnerID = ownerID;
@ -1278,7 +1286,7 @@ namespace OpenSim.Region.ClientStack
public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel)
{
SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket();
SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket) PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
viewertime.TimeInfo.SunDirection = sunPos;
viewertime.TimeInfo.SunAngVelocity = sunVel;
viewertime.TimeInfo.UsecSinceStart = (ulong) Util.UnixTimeSinceEpoch();
@ -1288,7 +1296,7 @@ namespace OpenSim.Region.ClientStack
public void SendViewerTime(int phase)
{
Console.WriteLine("SunPhase: {0}", phase);
SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket();
SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket) PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
//viewertime.TimeInfo.SecPerDay = 86400;
//viewertime.TimeInfo.SecPerYear = 31536000;
viewertime.TimeInfo.SecPerDay = 1000;
@ -1337,7 +1345,7 @@ namespace OpenSim.Region.ClientStack
string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL,
LLUUID partnerID)
{
AvatarPropertiesReplyPacket avatarReply = new AvatarPropertiesReplyPacket();
AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
avatarReply.AgentData.AgentID = AgentId;
avatarReply.AgentData.AvatarID = avatarID;
avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText);
@ -1362,11 +1370,12 @@ namespace OpenSim.Region.ClientStack
/// <param name="wearables"></param>
public void SendWearables(AvatarWearable[] wearables, int serial)
{
AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket) PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
aw.AgentData.AgentID = AgentId;
aw.AgentData.SerialNum = (uint) serial;
aw.AgentData.SessionID = m_sessionId;
// TODO: don't create new blocks if recycling an old packet
aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
AgentWearablesUpdatePacket.WearableDataBlock awb;
for (int i = 0; i < wearables.Length; i++)
@ -1389,7 +1398,8 @@ namespace OpenSim.Region.ClientStack
/// <param name="textureEntry"></param>
public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry)
{
AvatarAppearancePacket avp = new AvatarAppearancePacket();
AvatarAppearancePacket avp = (AvatarAppearancePacket) PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
// TODO: don't create new blocks if recycling an old packet
avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
avp.ObjectData.TextureEntry = textureEntry;
@ -1408,7 +1418,8 @@ namespace OpenSim.Region.ClientStack
public void SendAnimations(LLUUID[] animations, int[] seqs, LLUUID sourceAgentId)
{
AvatarAnimationPacket ani = new AvatarAnimationPacket();
AvatarAnimationPacket ani = (AvatarAnimationPacket) PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
// TODO: don't create new blocks if recycling an old packet
ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
ani.AnimationSourceList[0].ObjectID = sourceAgentId;
@ -1442,7 +1453,8 @@ namespace OpenSim.Region.ClientStack
public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID,
uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID)
{
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
ObjectUpdatePacket objupdate = (ObjectUpdatePacket) PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
// TODO: don't create new blocks if recycling an old packet
objupdate.RegionData.RegionHandle = regionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
@ -1474,7 +1486,8 @@ namespace OpenSim.Region.ClientStack
{
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock =
CreateAvatarImprovedBlock(localID, position, velocity, rotation);
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket) PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
// TODO: don't create new blocks if recycling an old packet
terse.RegionData.RegionHandle = regionHandle;
terse.RegionData.TimeDilation = timeDilation;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
@ -1485,7 +1498,8 @@ namespace OpenSim.Region.ClientStack
public void SendCoarseLocationUpdate(List<LLVector3> CoarseLocations)
{
CoarseLocationUpdatePacket loc = new CoarseLocationUpdatePacket();
CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket) PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
// TODO: don't create new blocks if recycling an old packet
int total = CoarseLocations.Count;
CoarseLocationUpdatePacket.IndexBlock ib =
new CoarseLocationUpdatePacket.IndexBlock();
@ -1517,7 +1531,8 @@ namespace OpenSim.Region.ClientStack
/// <param name="attachPoint"></param>
public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
{
ObjectAttachPacket attach = new ObjectAttachPacket();
ObjectAttachPacket attach = (ObjectAttachPacket) PacketPool.Instance.GetPacket(PacketType.ObjectAttach);
// TODO: don't create new blocks if recycling an old packet
attach.AgentData.AgentID = AgentId;
attach.AgentData.SessionID = m_sessionId;
attach.AgentData.AttachmentPoint = attachPoint;
@ -1536,7 +1551,8 @@ namespace OpenSim.Region.ClientStack
LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem,
LLQuaternion rotation, byte clickAction)
{
ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
ObjectUpdatePacket outPacket = (ObjectUpdatePacket) PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
// TODO: don't create new blocks if recycling an old packet
outPacket.RegionData.RegionHandle = regionHandle;
outPacket.RegionData.TimeDilation = timeDilation;
outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
@ -1579,7 +1595,8 @@ namespace OpenSim.Region.ClientStack
{
LLVector3 velocity = new LLVector3(0f, 0f, 0f);
LLVector3 rotationalvelocity = new LLVector3(0f, 0f, 0f);
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket) PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
// TODO: don't create new blocks if recycling an old packet
terse.RegionData.RegionHandle = regionHandle;
terse.RegionData.TimeDilation = timeDilation;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
@ -1591,7 +1608,8 @@ namespace OpenSim.Region.ClientStack
public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position,
LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity)
{
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket) PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
// TODO: don't create new blocks if recycling an old packet
terse.RegionData.RegionHandle = regionHandle;
terse.RegionData.TimeDilation = timeDilation;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
@ -1928,8 +1946,8 @@ namespace OpenSim.Region.ClientStack
public void SendNameReply(LLUUID profileId, string firstname, string lastname)
{
UUIDNameReplyPacket packet = new UUIDNameReplyPacket();
UUIDNameReplyPacket packet = (UUIDNameReplyPacket) PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
// TODO: don't create new blocks if recycling an old packet
packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
packet.UUIDNameBlock[0].ID = profileId;
@ -1977,7 +1995,8 @@ namespace OpenSim.Region.ClientStack
{
//System.Console.WriteLine("texture cached: " + packet.ToString());
AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket) packet;
AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket();
AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket) PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
// TODO: don't create new blocks if recycling an old packet
cachedresp.AgentData.AgentID = AgentId;
cachedresp.AgentData.SessionID = m_sessionId;
cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
@ -2137,7 +2156,8 @@ namespace OpenSim.Region.ClientStack
{
//should be getting the map layer from the grid server
//send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
MapLayerReplyPacket mapReply = new MapLayerReplyPacket();
MapLayerReplyPacket mapReply = (MapLayerReplyPacket) PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
// TODO: don't create new blocks if recycling an old packet
mapReply.AgentData.AgentID = AgentId;
mapReply.AgentData.Flags = 0;
mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
@ -2282,14 +2302,10 @@ namespace OpenSim.Region.ClientStack
try
{
byte[] sendbuffer = Pack.ToBytes();
if (Pack is RegionHandshakePacket)
{
PacketPool.Instance.ReturnPacket(Pack);
}
if (Pack.Header.Zerocoded)
{
byte[] ZeroOutBuffer = new byte[4096];
int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode);
}
@ -2342,7 +2358,7 @@ namespace OpenSim.Region.ClientStack
{
//reply to pingcheck
StartPingCheckPacket startPing = (StartPingCheckPacket) NewPack;
CompletePingCheckPacket endPing = new CompletePingCheckPacket();
CompletePingCheckPacket endPing = (CompletePingCheckPacket) PacketPool.Instance.GetPacket(PacketType.CompletePingCheck);
endPing.PingID.PingID = startPing.PingID.PingID;
OutPacket(endPing, ThrottleOutPacketType.Task);
}
@ -2371,7 +2387,8 @@ namespace OpenSim.Region.ClientStack
{
if (Pack.Header.Reliable)
{
PacketAckPacket ack_it = new PacketAckPacket();
PacketAckPacket ack_it = (PacketAckPacket) PacketPool.Instance.GetPacket(PacketType.PacketAck);
// TODO: don't create new blocks if recycling an old packet
ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
ack_it.Packets[0].ID = Pack.Header.Sequence;
@ -2426,7 +2443,8 @@ namespace OpenSim.Region.ClientStack
//MainLog.Instance.Verbose("NETWORK", "Sending PacketAck");
int i = 0;
PacketAckPacket acks = new PacketAckPacket();
PacketAckPacket acks = (PacketAckPacket) PacketPool.Instance.GetPacket(PacketType.PacketAck);
// TODO: don't create new blocks if recycling an old packet
acks.Packets = new PacketAckPacket.PacketsBlock[m_pendingAcks.Count];
foreach (uint ack in m_pendingAcks.Values)
@ -2852,8 +2870,7 @@ namespace OpenSim.Region.ClientStack
MainLog.Instance.Warn("CLIENT", "unhandled packet " + PacketType.ObjectPermissions.ToString());
ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
List<ObjectPermissionsPacket.ObjectDataBlock> permChanges =
new List<ObjectPermissionsPacket.ObjectDataBlock>();
List<ObjectPermissionsPacket.ObjectDataBlock> permChanges = new List<ObjectPermissionsPacket.ObjectDataBlock>();
for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
{
@ -3163,11 +3180,11 @@ namespace OpenSim.Region.ClientStack
case PacketType.TeleportLandmarkRequest:
TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket) Pack;
TeleportStartPacket tpStart = new TeleportStartPacket();
TeleportStartPacket tpStart = (TeleportStartPacket) PacketPool.Instance.GetPacket(PacketType.TeleportStart);
tpStart.Info.TeleportFlags = 8; // tp via lm
OutPacket(tpStart, ThrottleOutPacketType.Task);
TeleportProgressPacket tpProgress = new TeleportProgressPacket();
TeleportProgressPacket tpProgress = (TeleportProgressPacket) PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark");
tpProgress.Info.TeleportFlags = 8;
tpProgress.AgentData.AgentID = tpReq.Info.AgentID;
@ -3182,7 +3199,7 @@ namespace OpenSim.Region.ClientStack
if (lm.RegionID == m_scene.RegionInfo.RegionID)
{
TeleportLocalPacket tpLocal = new TeleportLocalPacket();
TeleportLocalPacket tpLocal = (TeleportLocalPacket) PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
tpLocal.Info.AgentID = tpReq.Info.AgentID;
tpLocal.Info.TeleportFlags = 8; // Teleport via landmark
@ -3192,7 +3209,7 @@ namespace OpenSim.Region.ClientStack
}
else
{
TeleportCancelPacket tpCancel = new TeleportCancelPacket();
TeleportCancelPacket tpCancel = (TeleportCancelPacket) PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
tpCancel.Info.AgentID = tpReq.Info.AgentID;
tpCancel.Info.SessionID = tpReq.Info.SessionID;
OutPacket(tpCancel, ThrottleOutPacketType.Task);
@ -3202,7 +3219,7 @@ namespace OpenSim.Region.ClientStack
{
Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented");
TeleportCancelPacket tpCancel = new TeleportCancelPacket();
TeleportCancelPacket tpCancel = (TeleportCancelPacket) PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
tpCancel.Info.AgentID = tpReq.Info.AgentID;
tpCancel.Info.SessionID = tpReq.Info.SessionID;
OutPacket(tpCancel, ThrottleOutPacketType.Task);
@ -3220,7 +3237,7 @@ namespace OpenSim.Region.ClientStack
else
{
//no event handler so cancel request
TeleportCancelPacket tpCancel = new TeleportCancelPacket();
TeleportCancelPacket tpCancel = (TeleportCancelPacket) PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
OutPacket(tpCancel, ThrottleOutPacketType.Task);
@ -3521,13 +3538,15 @@ namespace OpenSim.Region.ClientStack
shape.PathTwist = addPacket.ObjectData.PathTwist;
shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("89556747-24cb-43ed-920b-47caed15465f"));
shape.Textures = ntex;
shape.TextureEntry = ntex.ToBytes();
//shape.Textures = ntex;
return shape;
}
public void SendLogoutPacket()
{
LogoutReplyPacket logReply = new LogoutReplyPacket();
LogoutReplyPacket logReply = (LogoutReplyPacket) PacketPool.Instance.GetPacket(PacketType.LogoutReply);
// TODO: don't create new blocks if recycling an old packet
logReply.AgentData.AgentID = AgentId;
logReply.AgentData.SessionID = SessionId;
logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];

View File

@ -30,7 +30,6 @@ using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
@ -38,103 +37,6 @@ using OpenSim.Framework.Console;
namespace OpenSim.Region.ClientStack
{
public sealed class PacketPool
{
// Set up a thread-safe singleton pattern
static PacketPool()
{
}
private static readonly PacketPool instance = new PacketPool();
public static PacketPool Instance
{
get { return instance; }
}
private Hashtable pool = new Hashtable();
public Packet GetPacket(PacketType type)
{
Packet packet = null;
lock (pool)
{
if (pool[type] == null || ((Stack) pool[type]).Count == 0)
{
// Creating a new packet if we cannot reuse an old package
packet = Packet.BuildPacket(type);
}
else
{
// Recycle old packages
packet = (Packet) ((Stack) pool[type]).Pop();
}
}
return packet;
}
public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer)
{
Packet packet = GetPacket(GetType(bytes, packetEnd, zeroBuffer));
int i = 0;
packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer);
return packet;
}
public PacketType GetType(byte[] bytes, int packetEnd, byte[] zeroBuffer)
{
//Function removed from LibSL revision 1540
// We're using it.. so Built it into UDP server for now..
ushort id;
PacketFrequency freq;
int i = 0, end = packetEnd;
Header header = Header.BuildHeader(bytes, ref i, ref end);
if (header.Zerocoded)
{
end = Helpers.ZeroDecode(bytes, end + 1, zeroBuffer) - 1;
bytes = zeroBuffer;
}
if (bytes[6] == 0xFF)
{
if (bytes[7] == 0xFF)
{
id = (ushort) ((bytes[8] << 8) + bytes[9]);
freq = PacketFrequency.Low;
}
else
{
id = (ushort) bytes[7];
freq = PacketFrequency.Medium;
}
}
else
{
id = (ushort) bytes[6];
freq = PacketFrequency.High;
}
return Packet.GetType(id, freq);
}
public void ReturnPacket(Packet packet)
{
lock (pool)
{
PacketType type = packet.Type;
if (pool[type] == null)
{
pool[type] = new Stack();
}
((Stack) pool[type]).Push(packet);
}
}
}
public class UDPServer : ClientStackNetworkHandler
{
protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();

View File

@ -32,6 +32,7 @@ using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.LandManagement
{
@ -110,7 +111,9 @@ namespace OpenSim.Region.Environment.LandManagement
public void sendLandProperties(int sequence_id, bool snap_selection, int request_result,
IClientAPI remote_client)
{
ParcelPropertiesPacket updatePacket = new ParcelPropertiesPacket();
ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties);
// TODO: don't create new blocks if recycling an old packet
updatePacket.ParcelData.AABBMax = landData.AABBMax;
updatePacket.ParcelData.AABBMin = landData.AABBMin;
updatePacket.ParcelData.Area = landData.area;
@ -334,7 +337,7 @@ namespace OpenSim.Region.Environment.LandManagement
if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both)
{
replyPacket = new ParcelAccessListReplyPacket();
replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
replyPacket.Data.AgentID = agentID;
replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access;
replyPacket.Data.LocalID = landData.localID;
@ -346,7 +349,7 @@ namespace OpenSim.Region.Environment.LandManagement
if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both)
{
replyPacket = new ParcelAccessListReplyPacket();
replyPacket = (ParcelAccessListReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
replyPacket.Data.AgentID = agentID;
replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban;
replyPacket.Data.LocalID = landData.localID;
@ -657,7 +660,8 @@ namespace OpenSim.Region.Environment.LandManagement
bool firstCall = true;
int MAX_OBJECTS_PER_PACKET = 251;
ForceObjectSelectPacket pack = new ForceObjectSelectPacket();
ForceObjectSelectPacket pack = (ForceObjectSelectPacket) PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
// TODO: don't create new blocks if recycling an old packet
ForceObjectSelectPacket.DataBlock[] data;
while (resultLocalIDs.Count > 0)
{
@ -695,7 +699,9 @@ namespace OpenSim.Region.Environment.LandManagement
public void sendLandObjectOwners(IClientAPI remote_client)
{
Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID, int>();
ParcelObjectOwnersReplyPacket pack = new ParcelObjectOwnersReplyPacket();
ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
// TODO: don't create new blocks if recycling an old packet
foreach (SceneObjectGroup obj in primsOverMe)
{
if (!ownersAndCount.ContainsKey(obj.OwnerID))
@ -725,7 +731,6 @@ namespace OpenSim.Region.Environment.LandManagement
num++;
}
pack.Data = dataBlock;
}
remote_client.OutPacket(pack, ThrottleOutPacketType.Task);

View File

@ -33,6 +33,7 @@ using libsecondlife.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Environment.LandManagement
@ -493,7 +494,7 @@ namespace OpenSim.Region.Environment.LandManagement
if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
{
byteArrayCount = 0;
packet = new ParcelOverlayPacket();
packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
packet.ParcelData.Data = byteArray;
packet.ParcelData.SequenceID = sequenceID;
remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task);

View File

@ -29,6 +29,8 @@ using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework;
using OpenSim.Framework.UserManagement;
using OpenSim.Framework.Console;
namespace OpenSim.Region.Environment.Scenes
{
@ -164,7 +166,9 @@ namespace OpenSim.Region.Environment.Scenes
List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query);
AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
// TODO: don't create new blocks if recycling an old packet
AvatarPickerReplyPacket.DataBlock[] searchData =
new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count];
AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();

View File

@ -474,7 +474,7 @@ namespace OpenSim.Region.Environment.Scenes
if (!avatar.IsChildAgent)
avatar.ControllingClient.Kick("The simulator is going down.");
avatar.ControllingClient.OutPacket(new DisableSimulatorPacket(),
avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(libsecondlife.Packets.PacketType.DisableSimulator),
ThrottleOutPacketType.Task);
});
@ -1017,20 +1017,18 @@ namespace OpenSim.Region.Environment.Scenes
LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection);
if (PermissionsMngr.CanRezObject(ownerID, pos))
{
// rez ON the ground, not IN the ground
pos.Z += 0.25F;
AddNewPrim(ownerID, pos, rot, shape);
}
}
public virtual void AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape)
{
SceneObjectGroup sceneOb =
new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
AddEntity(sceneOb);
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
// if grass or tree, make phantom
@ -1055,6 +1053,7 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
}
}
}
public void AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position,
Tree treeType, bool newTree)
@ -1499,7 +1498,7 @@ namespace OpenSim.Region.Environment.Scenes
m_innerScene.removeUserCount(true);
}
// Tell a single agent to disconnect from the region.
DisableSimulatorPacket disable = new DisableSimulatorPacket();
libsecondlife.Packets.DisableSimulatorPacket disable = (libsecondlife.Packets.DisableSimulatorPacket) PacketPool.Instance.GetPacket(libsecondlife.Packets.PacketType.DisableSimulator);
presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task);
}
}

View File

@ -74,13 +74,11 @@ namespace OpenSim.Region.Environment.Scenes
{
get { return m_rootPart.RotationOffset; }
}
public LLUUID GroupID
{
get { return m_rootPart.GroupID; }
set { m_rootPart.GroupID = value; }
}
/// <summary>
///
/// </summary>
@ -638,7 +636,9 @@ namespace OpenSim.Region.Environment.Scenes
public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags)
{
//RootPart.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags);
ObjectPropertiesFamilyPacket objPropFamilyPack = new ObjectPropertiesFamilyPacket();
ObjectPropertiesFamilyPacket objPropFamilyPack = (ObjectPropertiesFamilyPacket) PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
// TODO: don't create new blocks if recycling an old packet
ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
objPropDB.RequestFlags = RequestFlags;
objPropDB.ObjectID = RootPart.UUID;
@ -1045,7 +1045,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="client"></param>
public void GetProperites(IClientAPI client)
{
ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
ObjectPropertiesPacket proper = (ObjectPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
// TODO: don't create new blocks if recycling an old packet
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
proper.ObjectData[0].ItemID = LLUUID.Zero;
@ -1297,6 +1299,7 @@ namespace OpenSim.Region.Environment.Scenes
m_rootPart.PhysActor.IsPhysical);
bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
}
}

View File

@ -83,7 +83,9 @@ namespace OpenSim.Region.Environment.Scenes
private void statsHeartBeat(object sender, EventArgs e)
{
m_report.Enabled = false;
SimStatsPacket statpack = new SimStatsPacket();
SimStatsPacket statpack = (SimStatsPacket) PacketPool.Instance.GetPacket(PacketType.SimStats);
// TODO: don't create new blocks if recycling an old packet
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[11];
statpack.Region = new SimStatsPacket.RegionBlock();
statpack.Region.RegionX = ReportingRegion.RegionLocX;

Binary file not shown.