* Some more presence refactoring

afrisby
lbsa71 2007-09-20 23:28:08 +00:00
parent 7335e5710b
commit 101369e25a
6 changed files with 470 additions and 470 deletions

View File

@ -191,7 +191,7 @@ namespace OpenSim.Region.ClientStack
#endregion #endregion
#region Objects/Prims #region Objects/m_sceneObjects
case PacketType.ObjectLink: case PacketType.ObjectLink:
// OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
ObjectLinkPacket link = (ObjectLinkPacket)Pack; ObjectLinkPacket link = (ObjectLinkPacket)Pack;

View File

@ -8,428 +8,433 @@ using OpenSim.Framework.Types;
using OpenSim.Framework.Utilities; using OpenSim.Framework.Utilities;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
public partial class Scene public partial class Scene
{ {
//split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
// or at least some of they can be moved somewhere else // or at least some of they can be moved somewhere else
public void AddInventoryItem(LLUUID userID, InventoryItemBase item) public void AddInventoryItem(LLUUID avatarId, InventoryItemBase item)
{ {
if (Avatars.ContainsKey(userID)) ScenePresence avatar;
{
AddInventoryItem(Avatars[userID].ControllingClient, item); if ( TryGetAvatar( avatarId, out avatar ))
} {
} AddInventoryItem(avatar.ControllingClient, item);
}
public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) }
{
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item)
if (userInfo != null) {
{ CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
userInfo.AddItem(remoteClient.AgentId, item); if (userInfo != null)
remoteClient.SendInventoryItemUpdate(item); {
} userInfo.AddItem(remoteClient.AgentId, item);
} remoteClient.SendInventoryItemUpdate(item);
}
public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data) }
{
if (Avatars.ContainsKey(userID)) public LLUUID CapsUpdateInventoryItemAsset(LLUUID avatarId, LLUUID itemID, byte[] data)
{ {
return CapsUpdateInventoryItemAsset(Avatars[userID].ControllingClient, itemID, data); ScenePresence avatar;
}
return LLUUID.Zero; if (TryGetAvatar(avatarId, out avatar))
} {
return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) }
{
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); return LLUUID.Zero;
if (userInfo != null) }
{
if (userInfo.RootFolder != null) public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
if (item != null) if (userInfo != null)
{ {
AssetBase asset; if (userInfo.RootFolder != null)
asset = new AssetBase(); {
asset.FullID = LLUUID.Random(); InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
asset.Type = (sbyte) item.assetType; if (item != null)
asset.InvType = (sbyte) item.invType; {
asset.Name = item.inventoryName; AssetBase asset;
asset.Data = data; asset = new AssetBase();
commsManager.AssetCache.AddAsset(asset); asset.FullID = LLUUID.Random();
asset.Type = (sbyte) item.assetType;
item.assetID = asset.FullID; asset.InvType = (sbyte) item.invType;
userInfo.UpdateItem(remoteClient.AgentId, item); asset.Name = item.inventoryName;
asset.Data = data;
// remoteClient.SendInventoryItemUpdate(item); commsManager.AssetCache.AddAsset(asset);
if (item.invType == 7)
{ item.assetID = asset.FullID;
//do we want to know about updated note cards? userInfo.UpdateItem(remoteClient.AgentId, item);
}
else if (item.invType == 10) // remoteClient.SendInventoryItemUpdate(item);
{ if (item.invType == 7)
// do we want to know about updated scripts {
} //do we want to know about updated note cards?
}
return (asset.FullID); else if (item.invType == 10)
} {
} // do we want to know about updated scripts
} }
return LLUUID.Zero;
} return (asset.FullID);
}
}
}
return LLUUID.Zero;
}
public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID,
LLUUID itemID) LLUUID itemID)
{ {
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
if (userInfo != null) if (userInfo != null)
{ {
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
if (item != null) if (item != null)
{ {
AgentAssetTransactions transactions = AgentAssetTransactions transactions =
commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
if (transactions != null) if (transactions != null)
{ {
AssetBase asset = null; AssetBase asset = null;
bool addToCache = false; bool addToCache = false;
asset = commsManager.AssetCache.GetAsset(assetID); asset = commsManager.AssetCache.GetAsset(assetID);
if (asset == null) if (asset == null)
{ {
asset = transactions.GetTransactionAsset(transactionID); asset = transactions.GetTransactionAsset(transactionID);
addToCache = true; addToCache = true;
} }
if (asset != null) if (asset != null)
{ {
if (asset.FullID == assetID) if (asset.FullID == assetID)
{ {
asset.Name = item.inventoryName; asset.Name = item.inventoryName;
asset.Description = item.inventoryDescription; asset.Description = item.inventoryDescription;
asset.InvType = (sbyte) item.invType; asset.InvType = (sbyte) item.invType;
asset.Type = (sbyte) item.assetType; asset.Type = (sbyte) item.assetType;
item.assetID = asset.FullID; item.assetID = asset.FullID;
if (addToCache) if (addToCache)
{ {
commsManager.AssetCache.AddAsset(asset); commsManager.AssetCache.AddAsset(asset);
} }
userInfo.UpdateItem(remoteClient.AgentId, item); userInfo.UpdateItem(remoteClient.AgentId, item);
} }
} }
} }
} }
} }
} }
} }
/// <summary> /// <summary>
/// temporary method to test out creating new inventory items /// temporary method to test out creating new inventory items
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="transActionID"></param> /// <param name="transActionID"></param>
/// <param name="folderID"></param> /// <param name="folderID"></param>
/// <param name="callbackID"></param> /// <param name="callbackID"></param>
/// <param name="description"></param> /// <param name="description"></param>
/// <param name="name"></param> /// <param name="name"></param>
/// <param name="invType"></param> /// <param name="invType"></param>
/// <param name="type"></param> /// <param name="type"></param>
/// <param name="wearableType"></param> /// <param name="wearableType"></param>
/// <param name="nextOwnerMask"></param> /// <param name="nextOwnerMask"></param>
public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID,
uint callbackID, string description, string name, sbyte invType, sbyte type, uint callbackID, string description, string name, sbyte invType, sbyte type,
byte wearableType, uint nextOwnerMask) byte wearableType, uint nextOwnerMask)
{ {
if (transActionID == LLUUID.Zero) if (transActionID == LLUUID.Zero)
{ {
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
if (userInfo != null) if (userInfo != null)
{ {
AssetBase asset = new AssetBase(); AssetBase asset = new AssetBase();
asset.Name = name; asset.Name = name;
asset.Description = description; asset.Description = description;
asset.InvType = invType; asset.InvType = invType;
asset.Type = type; asset.Type = type;
asset.FullID = LLUUID.Random(); asset.FullID = LLUUID.Random();
asset.Data = new byte[1]; asset.Data = new byte[1];
commsManager.AssetCache.AddAsset(asset); commsManager.AssetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase(); InventoryItemBase item = new InventoryItemBase();
item.avatarID = remoteClient.AgentId; item.avatarID = remoteClient.AgentId;
item.creatorsID = remoteClient.AgentId; item.creatorsID = remoteClient.AgentId;
item.inventoryID = LLUUID.Random(); item.inventoryID = LLUUID.Random();
item.assetID = asset.FullID; item.assetID = asset.FullID;
item.inventoryDescription = description; item.inventoryDescription = description;
item.inventoryName = name; item.inventoryName = name;
item.assetType = invType; item.assetType = invType;
item.invType = invType; item.invType = invType;
item.parentFolderID = folderID; item.parentFolderID = folderID;
item.inventoryCurrentPermissions = 2147483647; item.inventoryCurrentPermissions = 2147483647;
item.inventoryNextPermissions = nextOwnerMask; item.inventoryNextPermissions = nextOwnerMask;
userInfo.AddItem(remoteClient.AgentId, item); userInfo.AddItem(remoteClient.AgentId, item);
remoteClient.SendInventoryItemUpdate(item); remoteClient.SendInventoryItemUpdate(item);
} }
} }
else else
{ {
commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID,
callbackID, description, name, invType, callbackID, description, name, invType,
type, wearableType, nextOwnerMask); type, wearableType, nextOwnerMask);
//System.Console.WriteLine("request to create inventory item from transaction " + transActionID); //System.Console.WriteLine("request to create inventory item from transaction " + transActionID);
} }
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="primLocalID"></param> /// <param name="primLocalID"></param>
public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID)
{ {
bool hasPrim = false; bool hasPrim = false;
foreach (EntityBase ent in Entities.Values) foreach (EntityBase ent in Entities.Values)
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID); hasPrim = ((SceneObjectGroup) ent).HasChildPrim(primLocalID);
if (hasPrim != false) if (hasPrim != false)
{ {
bool fileChange = ((SceneObjectGroup) ent).GetPartInventoryFileName(remoteClient, primLocalID); bool fileChange = ((SceneObjectGroup) ent).GetPartInventoryFileName(remoteClient, primLocalID);
if (fileChange) if (fileChange)
{ {
if (XferManager != null) if (XferManager != null)
{ {
((SceneObjectGroup) ent).RequestInventoryFile(primLocalID, XferManager); ((SceneObjectGroup) ent).RequestInventoryFile(primLocalID, XferManager);
} }
} }
break; break;
} }
} }
} }
} }
public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID)
{ {
bool hasPrim = false; bool hasPrim = false;
foreach (EntityBase ent in Entities.Values) foreach (EntityBase ent in Entities.Values)
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
if (hasPrim != false) if (hasPrim != false)
{ {
int type = ((SceneObjectGroup) ent).RemoveInventoryItem(remoteClient, localID, itemID); int type = ((SceneObjectGroup) ent).RemoveInventoryItem(remoteClient, localID, itemID);
((SceneObjectGroup) ent).GetProperites(remoteClient); ((SceneObjectGroup) ent).GetProperites(remoteClient);
if (type == 10) if (type == 10)
{ {
EventManager.TriggerRemoveScript(localID, itemID); EventManager.TriggerRemoveScript(localID, itemID);
} }
} }
} }
} }
} }
public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
{ {
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
LLUUID copyID = LLUUID.Random(); LLUUID copyID = LLUUID.Random();
if (userInfo != null) if (userInfo != null)
{ {
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
if (item != null) if (item != null)
{ {
bool isTexture = false; bool isTexture = false;
bool rezzed = false; bool rezzed = false;
if (item.invType == 0) if (item.invType == 0)
{ {
isTexture = true; isTexture = true;
} }
AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
if (rezAsset != null) if (rezAsset != null)
{ {
string script = Util.FieldToString(rezAsset.Data); string script = Util.FieldToString(rezAsset.Data);
//Console.WriteLine("rez script "+script); //Console.WriteLine("rez script "+script);
EventManager.TriggerRezScript(localID, copyID, script); EventManager.TriggerRezScript(localID, copyID, script);
rezzed = true; rezzed = true;
} }
else else
{ {
//lets try once more incase the asset cache is being slow getting the asset from server //lets try once more incase the asset cache is being slow getting the asset from server
rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture);
if (rezAsset != null) if (rezAsset != null)
{ {
string script = Util.FieldToString(rezAsset.Data); string script = Util.FieldToString(rezAsset.Data);
// Console.WriteLine("rez script " + script); // Console.WriteLine("rez script " + script);
EventManager.TriggerRezScript(localID, copyID, script); EventManager.TriggerRezScript(localID, copyID, script);
rezzed = true; rezzed = true;
} }
} }
if (rezzed) if (rezzed)
{ {
bool hasPrim = false; bool hasPrim = false;
foreach (EntityBase ent in Entities.Values) foreach (EntityBase ent in Entities.Values)
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
if (hasPrim != false) if (hasPrim != false)
{ {
bool added = bool added =
((SceneObjectGroup) ent).AddInventoryItem(remoteClient, localID, item, ((SceneObjectGroup) ent).AddInventoryItem(remoteClient, localID, item,
copyID); copyID);
((SceneObjectGroup) ent).GetProperites(remoteClient); ((SceneObjectGroup) ent).GetProperites(remoteClient);
} }
} }
} }
} }
} }
} }
} }
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="packet"></param> /// <param name="packet"></param>
/// <param name="simClient"></param> /// <param name="simClient"></param>
public void DeRezObject(Packet packet, IClientAPI remoteClient) public void DeRezObject(Packet packet, IClientAPI remoteClient)
{ {
DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet; DeRezObjectPacket DeRezPacket = (DeRezObjectPacket) packet;
if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero)
{ {
//currently following code not used (or don't know of any case of destination being zero //currently following code not used (or don't know of any case of destination being zero
} }
else else
{ {
foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData)
{ {
EntityBase selectedEnt = null; EntityBase selectedEnt = null;
//OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString());
foreach (EntityBase ent in Entities.Values) foreach (EntityBase ent in Entities.Values)
{ {
if (ent.LocalId == Data.ObjectLocalID) if (ent.LocalId == Data.ObjectLocalID)
{ {
selectedEnt = ent; selectedEnt = ent;
break; break;
} }
} }
if (selectedEnt != null) if (selectedEnt != null)
{ {
if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID))
{ {
string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString();
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
if (userInfo != null) if (userInfo != null)
{ {
AssetBase asset = new AssetBase(); AssetBase asset = new AssetBase();
asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId); asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId);
asset.Description = asset.Description =
((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId); ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId);
asset.InvType = 6; asset.InvType = 6;
asset.Type = 6; asset.Type = 6;
asset.FullID = LLUUID.Random(); asset.FullID = LLUUID.Random();
asset.Data = Helpers.StringToField(sceneObjectXml); asset.Data = Helpers.StringToField(sceneObjectXml);
commsManager.AssetCache.AddAsset(asset); commsManager.AssetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase(); InventoryItemBase item = new InventoryItemBase();
item.avatarID = remoteClient.AgentId; item.avatarID = remoteClient.AgentId;
item.creatorsID = remoteClient.AgentId; item.creatorsID = remoteClient.AgentId;
item.inventoryID = LLUUID.Random(); item.inventoryID = LLUUID.Random();
item.assetID = asset.FullID; item.assetID = asset.FullID;
item.inventoryDescription = asset.Description; item.inventoryDescription = asset.Description;
item.inventoryName = asset.Name; item.inventoryName = asset.Name;
item.assetType = asset.Type; item.assetType = asset.Type;
item.invType = asset.InvType; item.invType = asset.InvType;
item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; item.parentFolderID = DeRezPacket.AgentBlock.DestinationID;
item.inventoryCurrentPermissions = 2147483647; item.inventoryCurrentPermissions = 2147483647;
item.inventoryNextPermissions = 2147483647; item.inventoryNextPermissions = 2147483647;
userInfo.AddItem(remoteClient.AgentId, item); userInfo.AddItem(remoteClient.AgentId, item);
remoteClient.SendInventoryItemUpdate(item); remoteClient.SendInventoryItemUpdate(item);
} }
SceneObjectPart rootPart = SceneObjectPart rootPart =
((SceneObjectGroup) selectedEnt).GetChildPart(((SceneObjectGroup) selectedEnt).UUID); ((SceneObjectGroup) selectedEnt).GetChildPart(((SceneObjectGroup) selectedEnt).UUID);
if (rootPart.PhysActor != null) if (rootPart.PhysActor != null)
{ {
phyScene.RemovePrim(rootPart.PhysActor); phyScene.RemovePrim(rootPart.PhysActor);
rootPart.PhysActor = null; rootPart.PhysActor = null;
} }
storageManager.DataStore.RemoveObject(((SceneObjectGroup) selectedEnt).UUID, storageManager.DataStore.RemoveObject(((SceneObjectGroup) selectedEnt).UUID,
m_regInfo.SimUUID); m_regInfo.SimUUID);
((SceneObjectGroup) selectedEnt).DeleteGroup(); ((SceneObjectGroup) selectedEnt).DeleteGroup();
lock (Entities) lock (Entities)
{ {
Entities.Remove(((SceneObjectGroup) selectedEnt).UUID); Entities.Remove(((SceneObjectGroup) selectedEnt).UUID);
} }
((SceneObjectGroup) selectedEnt).DeleteParts(); ((SceneObjectGroup) selectedEnt).DeleteParts();
} }
} }
} }
} }
} }
public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos)
{ {
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
if (userInfo != null) if (userInfo != null)
{ {
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
if (item != null) if (item != null)
{ {
AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
if (rezAsset != null) if (rezAsset != null)
{ {
AddRezObject(Util.FieldToString(rezAsset.Data), pos); AddRezObject(Util.FieldToString(rezAsset.Data), pos);
userInfo.DeleteItem(remoteClient.AgentId, item); userInfo.DeleteItem(remoteClient.AgentId, item);
remoteClient.SendRemoveInventoryItem(itemID); remoteClient.SendRemoveInventoryItem(itemID);
} }
else else
{ {
//lets try once more incase the asset cache is being slow getting the asset from server //lets try once more incase the asset cache is being slow getting the asset from server
rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false);
if (rezAsset != null) if (rezAsset != null)
{ {
AddRezObject(Util.FieldToString(rezAsset.Data), pos); AddRezObject(Util.FieldToString(rezAsset.Data), pos);
userInfo.DeleteItem(remoteClient.AgentId, item); userInfo.DeleteItem(remoteClient.AgentId, item);
remoteClient.SendRemoveInventoryItem(itemID); remoteClient.SendRemoveInventoryItem(itemID);
} }
} }
} }
} }
} }
} }
private void AddRezObject(string xmlData, LLVector3 pos) private void AddRezObject(string xmlData, LLVector3 pos)
{ {
SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
AddEntity(group); AddEntity(group);
group.AbsolutePosition = pos; group.AbsolutePosition = pos;
SceneObjectPart rootPart = group.GetChildPart(group.UUID); SceneObjectPart rootPart = group.GetChildPart(group.UUID);
if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
rootPart.PhysActor = phyScene.AddPrim( rootPart.PhysActor = phyScene.AddPrim(
new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
rootPart.AbsolutePosition.Z), rootPart.AbsolutePosition.Z),
new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
} }
} }
} }

View File

@ -69,13 +69,13 @@ namespace OpenSim.Region.Environment.Scenes
public void InstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, public void InstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID,
uint timestamp, string fromAgentName, string message, byte dialog) uint timestamp, string fromAgentName, string message, byte dialog)
{ {
if (Avatars.ContainsKey(toAgentID)) if (m_scenePresences.ContainsKey(toAgentID))
{ {
if (Avatars.ContainsKey(fromAgentID)) if (m_scenePresences.ContainsKey(fromAgentID))
{ {
// Local sim message // Local sim message
ScenePresence fromAvatar = Avatars[fromAgentID]; ScenePresence fromAvatar = m_scenePresences[fromAgentID];
ScenePresence toAvatar = Avatars[toAgentID]; ScenePresence toAvatar = m_scenePresences[toAgentID];
string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname; string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname;
toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID, toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID,
imSessionID, fromName, dialog, timestamp); imSessionID, fromName, dialog, timestamp);

View File

@ -52,23 +52,20 @@ using Timer = System.Timers.Timer;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
public delegate bool FilterAvatarList(ScenePresence avatar);
public delegate void ForEachScenePresenceDelegate(ScenePresence presence);
public partial class Scene : SceneBase public partial class Scene : SceneBase
{ {
public delegate bool FilterAvatarList(ScenePresence avatar);
protected Timer m_heartbeatTimer = new Timer(); protected Timer m_heartbeatTimer = new Timer();
protected Dictionary<LLUUID, ScenePresence> Avatars; protected Dictionary<LLUUID, ScenePresence> m_scenePresences;
protected Dictionary<LLUUID, SceneObjectGroup> Prims; protected Dictionary<LLUUID, SceneObjectGroup> m_sceneObjects;
public PhysicsScene phyScene;
/// publicized so it can be accessed from SceneObjectGroup. /// publicized so it can be accessed from SceneObjectGroup.
protected float timeStep = 0.1f; protected float timeStep = 0.1f;
private Random Rand = new Random(); private Random Rand = new Random();
private uint _primCount = 702000; private uint _primCount = 702000;
private Mutex _primAllocateMutex = new Mutex(false); private readonly Mutex _primAllocateMutex = new Mutex(false);
private int storageCount; private int storageCount;
private int terrainCheckCount; private int terrainCheckCount;
private int landPrimCheckCount; private int landPrimCheckCount;
@ -78,7 +75,7 @@ namespace OpenSim.Region.Environment.Scenes
public BasicQuadTreeNode QuadTree; public BasicQuadTreeNode QuadTree;
private Mutex updateLock; private readonly Mutex updateLock;
protected ModuleLoader m_moduleLoader; protected ModuleLoader m_moduleLoader;
protected StorageManager storageManager; protected StorageManager storageManager;
@ -108,30 +105,28 @@ namespace OpenSim.Region.Environment.Scenes
get { return authenticateHandler; } get { return authenticateHandler; }
} }
/// <summary> private readonly LandManager m_LandManager;
///
/// </summary>
public PhysicsScene PhysScene
{
set { phyScene = value; }
get { return (phyScene); }
}
private LandManager m_LandManager;
public LandManager LandManager public LandManager LandManager
{ {
get { return m_LandManager; } get { return m_LandManager; }
} }
private EstateManager m_estateManager; private readonly EstateManager m_estateManager;
private PhysicsScene phyScene;
public PhysicsScene PhysScene
{
set { phyScene = value; }
get { return (phyScene); }
}
public EstateManager EstateManager public EstateManager EstateManager
{ {
get { return m_estateManager; } get { return m_estateManager; }
} }
private PermissionManager m_permissionManager; private readonly PermissionManager m_permissionManager;
public PermissionManager PermissionsMngr public PermissionManager PermissionsMngr
{ {
@ -140,7 +135,7 @@ namespace OpenSim.Region.Environment.Scenes
public Dictionary<LLUUID, SceneObjectGroup> Objects public Dictionary<LLUUID, SceneObjectGroup> Objects
{ {
get { return Prims; } get { return m_sceneObjects; }
} }
public int TimePhase public int TimePhase
@ -191,8 +186,8 @@ namespace OpenSim.Region.Environment.Scenes
MainLog.Instance.Verbose("Creating new entitities instance"); MainLog.Instance.Verbose("Creating new entitities instance");
Entities = new Dictionary<LLUUID, EntityBase>(); Entities = new Dictionary<LLUUID, EntityBase>();
Avatars = new Dictionary<LLUUID, ScenePresence>(); m_scenePresences = new Dictionary<LLUUID, ScenePresence>();
Prims = new Dictionary<LLUUID, SceneObjectGroup>(); m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>();
MainLog.Instance.Verbose("Creating LandMap"); MainLog.Instance.Verbose("Creating LandMap");
Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY); Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY);
@ -804,15 +799,15 @@ namespace OpenSim.Region.Environment.Scenes
Entities[client.AgentId] = newAvatar; Entities[client.AgentId] = newAvatar;
} }
} }
lock (Avatars) lock (m_scenePresences)
{ {
if (Avatars.ContainsKey(client.AgentId)) if (m_scenePresences.ContainsKey(client.AgentId))
{ {
Avatars[client.AgentId] = newAvatar; m_scenePresences[client.AgentId] = newAvatar;
} }
else else
{ {
Avatars.Add(client.AgentId, newAvatar); m_scenePresences.Add(client.AgentId, newAvatar);
} }
} }
@ -841,11 +836,11 @@ namespace OpenSim.Region.Environment.Scenes
} }
}); });
lock (Avatars) lock (m_scenePresences)
{ {
if (Avatars.ContainsKey(agentID)) if (m_scenePresences.ContainsKey(agentID))
{ {
Avatars.Remove(agentID); m_scenePresences.Remove(agentID);
} }
} }
lock (Entities) lock (Entities)
@ -865,18 +860,18 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
#region Request Avatars List Methods #region Request m_scenePresences List Methods
//The idea is to have a group of method that return a list of avatars meeting some requirement //The idea is to have a group of method that return a list of avatars meeting some requirement
// ie it could be all Avatars within a certain range of the calling prim/avatar. // ie it could be all m_scenePresences within a certain range of the calling prim/avatar.
/// <summary> /// <summary>
/// Request a List of all Avatars in this World /// Request a List of all m_scenePresences in this World
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<ScenePresence> GetScenePresences() public List<ScenePresence> GetScenePresences()
{ {
List<ScenePresence> result = new List<ScenePresence>(Avatars.Values); List<ScenePresence> result = new List<ScenePresence>(m_scenePresences.Values);
return result; return result;
} }
@ -892,14 +887,14 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// Request a filtered list of Avatars in this World /// Request a filtered list of m_scenePresences in this World
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<ScenePresence> GetScenePresences(FilterAvatarList filter) public List<ScenePresence> GetScenePresences(FilterAvatarList filter)
{ {
List<ScenePresence> result = new List<ScenePresence>(); List<ScenePresence> result = new List<ScenePresence>();
foreach (ScenePresence avatar in Avatars.Values) foreach (ScenePresence avatar in m_scenePresences.Values)
{ {
if (filter(avatar)) if (filter(avatar))
{ {
@ -917,9 +912,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns> /// <returns></returns>
public ScenePresence GetScenePresence(LLUUID avatarID) public ScenePresence GetScenePresence(LLUUID avatarID)
{ {
if (Avatars.ContainsKey(avatarID)) if (m_scenePresences.ContainsKey(avatarID))
{ {
return Avatars[avatarID]; return m_scenePresences[avatarID];
} }
return null; return null;
} }
@ -928,9 +923,9 @@ namespace OpenSim.Region.Environment.Scenes
/// ///
/// </summary> /// </summary>
/// <param name="whatToDo"></param> /// <param name="whatToDo"></param>
public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo) public void ForEachScenePresence(Action<ScenePresence> whatToDo)
{ {
foreach (ScenePresence presence in Avatars.Values) foreach (ScenePresence presence in m_scenePresences.Values)
{ {
whatToDo(presence); whatToDo(presence);
} }
@ -1031,9 +1026,9 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (regionHandle == m_regInfo.RegionHandle) if (regionHandle == m_regInfo.RegionHandle)
{ {
if (Avatars.ContainsKey(agentID)) if (m_scenePresences.ContainsKey(agentID))
{ {
Avatars[agentID].MakeAvatar(position, isFlying); m_scenePresences[agentID].MakeAvatar(position, isFlying);
} }
} }
} }
@ -1098,11 +1093,11 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (regionHandle == m_regionHandle) if (regionHandle == m_regionHandle)
{ {
if (Avatars.ContainsKey(remoteClient.AgentId)) if (m_scenePresences.ContainsKey(remoteClient.AgentId))
{ {
remoteClient.SendTeleportLocationStart(); remoteClient.SendTeleportLocationStart();
remoteClient.SendLocalTeleport(position, lookAt, flags); remoteClient.SendLocalTeleport(position, lookAt, flags);
Avatars[remoteClient.AgentId].Teleport(position); m_scenePresences[remoteClient.AgentId].Teleport(position);
} }
} }
else else
@ -1184,9 +1179,9 @@ namespace OpenSim.Region.Environment.Scenes
public void SendUrlToUser(LLUUID avatarID, string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, public void SendUrlToUser(LLUUID avatarID, string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned,
string message, string url) string message, string url)
{ {
if (Avatars.ContainsKey(avatarID)) if (m_scenePresences.ContainsKey(avatarID))
{ {
Avatars[avatarID].ControllingClient.SendLoadURL(objectname, objectID, ownerID, groupOwned, message, url); m_scenePresences[avatarID].ControllingClient.SendLoadURL(objectname, objectID, ownerID, groupOwned, message, url);
} }
} }
@ -1200,7 +1195,7 @@ namespace OpenSim.Region.Environment.Scenes
public void SendGeneralAlert(string message) public void SendGeneralAlert(string message)
{ {
foreach (ScenePresence presence in Avatars.Values) foreach (ScenePresence presence in m_scenePresences.Values)
{ {
presence.ControllingClient.SendAlertMessage(message); presence.ControllingClient.SendAlertMessage(message);
} }
@ -1208,15 +1203,15 @@ namespace OpenSim.Region.Environment.Scenes
public void SendAlertToUser(LLUUID agentID, string message, bool modal) public void SendAlertToUser(LLUUID agentID, string message, bool modal)
{ {
if (Avatars.ContainsKey(agentID)) if (m_scenePresences.ContainsKey(agentID))
{ {
Avatars[agentID].ControllingClient.SendAgentAlertMessage(message, modal); m_scenePresences[agentID].ControllingClient.SendAgentAlertMessage(message, modal);
} }
} }
public void SendAlertToUser(string firstName, string lastName, string message, bool modal) public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
{ {
foreach (ScenePresence presence in Avatars.Values) foreach (ScenePresence presence in m_scenePresences.Values)
{ {
if ((presence.Firstname == firstName) && (presence.Lastname == lastName)) if ((presence.Firstname == firstName) && (presence.Lastname == lastName))
{ {
@ -1405,7 +1400,7 @@ namespace OpenSim.Region.Environment.Scenes
internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
{ {
ScenePresence presence; ScenePresence presence;
if (Avatars.TryGetValue(avatarId, out presence)) if (m_scenePresences.TryGetValue(avatarId, out presence))
{ {
if (!presence.childAgent) if (!presence.childAgent)
{ {

View File

@ -314,7 +314,7 @@ namespace OpenSim.Region.Environment.Scenes
/// may need to create a new Physics actor. /// may need to create a new Physics actor.
if (dupe.RootPart.PhysActor != null) if (dupe.RootPart.PhysActor != null)
{ {
dupe.RootPart.PhysActor = m_scene.phyScene.AddPrim( dupe.RootPart.PhysActor = m_scene.PhysScene.AddPrim(
new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y,
dupe.RootPart.AbsolutePosition.Z), dupe.RootPart.AbsolutePosition.Z),
new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z),

View File

@ -291,7 +291,7 @@ namespace OpenSim.Region.Environment.Scenes
private void RemoveFromPhysicalScene() private void RemoveFromPhysicalScene()
{ {
m_scene.phyScene.RemoveAvatar( this.PhysActor ); m_scene.PhysScene.RemoveAvatar( this.PhysActor );
} }
/// <summary> /// <summary>
@ -844,7 +844,7 @@ namespace OpenSim.Region.Environment.Scenes
public void AddToPhysicalScene( ) public void AddToPhysicalScene( )
{ {
PhysicsScene scene = m_scene.phyScene; PhysicsScene scene = m_scene.PhysScene;
PhysicsVector pVec = PhysicsVector pVec =
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,