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 System.Collections.Generic;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework.Console;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
@ -42,6 +40,7 @@ namespace OpenSim.Framework
public void ForEachClient(ForEachClientDelegate whatToDo) public void ForEachClient(ForEachClientDelegate whatToDo)
{ {
// Wasteful, I know // Wasteful, I know
IClientAPI[] LocalClients = new IClientAPI[0]; IClientAPI[] LocalClients = new IClientAPI[0];
lock (m_clients) lock (m_clients)
@ -56,11 +55,9 @@ namespace OpenSim.Framework
{ {
whatToDo(LocalClients[i]); whatToDo(LocalClients[i]);
} }
catch (Exception e) catch (System.Exception e)
{ {
MainLog.Instance.Warn("CLIENT", OpenSim.Framework.Console.MainLog.Instance.Warn("CLIENT", "Unable to do ForEachClient for one of the clients" + "\n Reason: " + e.ToString());
"Unable to do ForEachClient for one of the clients" + "\n Reason: " +
e.ToString());
} }
} }
} }
@ -110,19 +107,20 @@ namespace OpenSim.Framework
IClientAPI client; IClientAPI client;
try try
{ {
if (m_clients.TryGetValue(circuits[i], out client)) if (m_clients.TryGetValue(circuits[i], out client))
{ {
Remove(client.CircuitCode); Remove(client.CircuitCode);
client.Close(false); client.Close(false);
} }
} }
catch (Exception e) catch (System.Exception e)
{ {
MainLog.Instance.Error("CLIENT", OpenSim.Framework.Console.MainLog.Instance.Error("CLIENT", "Unable to shutdown circuit for: " + agentId.ToString() + "\n Reason: " + e.ToString());
"Unable to shutdown circuit for: " + agentId.ToString() + "\n Reason: " +
e.ToString());
} }
} }
} }
private uint[] GetAllCircuits(LLUUID agentId) private uint[] GetAllCircuits(LLUUID agentId)
@ -137,7 +135,7 @@ namespace OpenSim.Framework
} }
for (int i = 0; i < LocalClients.Length; i++) for (int i = 0; i < LocalClients.Length; i++ )
{ {
if (LocalClients[i].AgentId == agentId) if (LocalClients[i].AgentId == agentId)
{ {
@ -150,7 +148,8 @@ namespace OpenSim.Framework
public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock) 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; packet.Effect = effectBlock;
// Wasteful, I know // Wasteful, I know
@ -170,6 +169,7 @@ namespace OpenSim.Framework
packet.AgentData.SessionID = LocalClients[i].SessionId; packet.AgentData.SessionID = LocalClients[i].SessionId;
LocalClients[i].OutPacket(packet, ThrottleOutPacketType.Task); LocalClients[i].OutPacket(packet, ThrottleOutPacketType.Task);
} }
} }
} }
@ -178,4 +178,4 @@ namespace OpenSim.Framework
return m_clients.TryGetValue(circuitId, out user); return m_clients.TryGetValue(circuitId, out user);
} }
} }
} }

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

View File

@ -30,7 +30,6 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
@ -38,103 +37,6 @@ using OpenSim.Framework.Console;
namespace OpenSim.Region.ClientStack 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 public class UDPServer : ClientStackNetworkHandler
{ {
protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
@ -386,4 +288,4 @@ namespace OpenSim.Region.ClientStack
} }
} }
} }
} }

View File

@ -32,6 +32,7 @@ using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.LandManagement 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, public void sendLandProperties(int sequence_id, bool snap_selection, int request_result,
IClientAPI remote_client) 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.AABBMax = landData.AABBMax;
updatePacket.ParcelData.AABBMin = landData.AABBMin; updatePacket.ParcelData.AABBMin = landData.AABBMin;
updatePacket.ParcelData.Area = landData.area; 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) 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.AgentID = agentID;
replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access; replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access;
replyPacket.Data.LocalID = landData.localID; 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) 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.AgentID = agentID;
replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban; replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban;
replyPacket.Data.LocalID = landData.localID; replyPacket.Data.LocalID = landData.localID;
@ -657,7 +660,8 @@ namespace OpenSim.Region.Environment.LandManagement
bool firstCall = true; bool firstCall = true;
int MAX_OBJECTS_PER_PACKET = 251; 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; ForceObjectSelectPacket.DataBlock[] data;
while (resultLocalIDs.Count > 0) while (resultLocalIDs.Count > 0)
{ {
@ -695,7 +699,9 @@ namespace OpenSim.Region.Environment.LandManagement
public void sendLandObjectOwners(IClientAPI remote_client) public void sendLandObjectOwners(IClientAPI remote_client)
{ {
Dictionary<LLUUID, int> ownersAndCount = new Dictionary<LLUUID, int>(); 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) foreach (SceneObjectGroup obj in primsOverMe)
{ {
if (!ownersAndCount.ContainsKey(obj.OwnerID)) if (!ownersAndCount.ContainsKey(obj.OwnerID))
@ -725,7 +731,6 @@ namespace OpenSim.Region.Environment.LandManagement
num++; num++;
} }
pack.Data = dataBlock; pack.Data = dataBlock;
} }
remote_client.OutPacket(pack, ThrottleOutPacketType.Task); remote_client.OutPacket(pack, ThrottleOutPacketType.Task);
@ -810,4 +815,4 @@ namespace OpenSim.Region.Environment.LandManagement
} }
#endregion #endregion
} }

View File

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

View File

@ -29,6 +29,8 @@ using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.UserManagement;
using OpenSim.Framework.Console;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
@ -164,7 +166,9 @@ namespace OpenSim.Region.Environment.Scenes
List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>(); List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query); 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 = AvatarPickerReplyPacket.DataBlock[] searchData =
new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count];
AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
@ -192,4 +196,4 @@ namespace OpenSim.Region.Environment.Scenes
client.SendAvatarPickerReply(replyPacket); client.SendAvatarPickerReply(replyPacket);
} }
} }
} }

View File

@ -474,7 +474,7 @@ namespace OpenSim.Region.Environment.Scenes
if (!avatar.IsChildAgent) if (!avatar.IsChildAgent)
avatar.ControllingClient.Kick("The simulator is going down."); 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); ThrottleOutPacketType.Task);
}); });
@ -1016,43 +1016,42 @@ namespace OpenSim.Region.Environment.Scenes
// It's wrong many times though. // It's wrong many times though.
LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection); LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection);
if (PermissionsMngr.CanRezObject(ownerID, pos)) if (PermissionsMngr.CanRezObject(ownerID, pos))
{ {
// rez ON the ground, not IN the ground
// rez ON the ground, not IN the ground
pos.Z += 0.25F; pos.Z += 0.25F;
AddNewPrim(ownerID, pos, rot, shape); SceneObjectGroup sceneOb =
} new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape);
} AddEntity(sceneOb);
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
public virtual void AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape) // if grass or tree, make phantom
{ //rootPart.ApplySanePermissions();
SceneObjectGroup sceneOb = if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255) || (rootPart.Shape.PCode == 111))
new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape); {
rootPart.AddFlag(LLObject.ObjectFlags.Phantom);
AddEntity(sceneOb); //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom;
SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); }
// if grass or tree, make phantom // if not phantom, add to physics
//rootPart.ApplySanePermissions(); bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim);
if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255) || (rootPart.Shape.PCode == 111)) if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
{ {
rootPart.AddFlag(LLObject.ObjectFlags.Phantom); rootPart.PhysActor =
//rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; PhysicsScene.AddPrimShape(
} rootPart.Name,
// if not phantom, add to physics rootPart.Shape,
bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); new PhysicsVector(pos.X, pos.Y, pos.Z),
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z),
{ new Quaternion(), UsePhysics);
rootPart.PhysActor = // subscribe to physics events.
PhysicsScene.AddPrimShape( rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
rootPart.Name, }
rootPart.Shape,
new PhysicsVector(pos.X, pos.Y, pos.Z),
new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z),
new Quaternion(), UsePhysics);
// subscribe to physics events.
rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
} }
} }
@ -1499,7 +1498,7 @@ namespace OpenSim.Region.Environment.Scenes
m_innerScene.removeUserCount(true); m_innerScene.removeUserCount(true);
} }
// Tell a single agent to disconnect from the region. // 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); presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task);
} }
} }
@ -2246,4 +2245,4 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
} }
} }

View File

@ -74,13 +74,11 @@ namespace OpenSim.Region.Environment.Scenes
{ {
get { return m_rootPart.RotationOffset; } get { return m_rootPart.RotationOffset; }
} }
public LLUUID GroupID public LLUUID GroupID
{ {
get { return m_rootPart.GroupID; } get { return m_rootPart.GroupID; }
set { m_rootPart.GroupID = value; } set { m_rootPart.GroupID = value; }
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -638,7 +636,9 @@ namespace OpenSim.Region.Environment.Scenes
public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags) public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags)
{ {
//RootPart.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, 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(); ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
objPropDB.RequestFlags = RequestFlags; objPropDB.RequestFlags = RequestFlags;
objPropDB.ObjectID = RootPart.UUID; objPropDB.ObjectID = RootPart.UUID;
@ -1045,7 +1045,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="client"></param> /// <param name="client"></param>
public void GetProperites(IClientAPI client) 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 = new ObjectPropertiesPacket.ObjectDataBlock[1];
proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
proper.ObjectData[0].ItemID = LLUUID.Zero; proper.ObjectData[0].ItemID = LLUUID.Zero;
@ -1297,6 +1299,7 @@ namespace OpenSim.Region.Environment.Scenes
m_rootPart.PhysActor.IsPhysical); m_rootPart.PhysActor.IsPhysical);
bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
} }
} }
@ -1737,4 +1740,4 @@ namespace OpenSim.Region.Environment.Scenes
m_rootPart.ApplyPhysics(); m_rootPart.ApplyPhysics();
} }
} }
} }

View File

@ -83,7 +83,9 @@ namespace OpenSim.Region.Environment.Scenes
private void statsHeartBeat(object sender, EventArgs e) private void statsHeartBeat(object sender, EventArgs e)
{ {
m_report.Enabled = false; 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]; SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[11];
statpack.Region = new SimStatsPacket.RegionBlock(); statpack.Region = new SimStatsPacket.RegionBlock();
statpack.Region.RegionX = ReportingRegion.RegionLocX; statpack.Region.RegionX = ReportingRegion.RegionLocX;
@ -241,4 +243,4 @@ namespace OpenSim.Region.Environment.Scenes
m_unAckedBytes += numBytes; m_unAckedBytes += numBytes;
} }
} }
} }

Binary file not shown.