* Refactored permissions handling to extract info out of permisisons block in ClientView

* Changed some uint constants to Enum values
ThreadPoolClientBranch
lbsa71 2008-02-10 14:27:21 +00:00
parent 8d37e91454
commit e0424254bd
3 changed files with 173 additions and 184 deletions

View File

@ -406,9 +406,7 @@ namespace OpenSim.Framework
// We keep all this information for fraud purposes in the future. // We keep all this information for fraud purposes in the future.
public delegate void MoneyBalanceRequest(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, LLUUID TransactionID); public delegate void MoneyBalanceRequest(IClientAPI remoteClient, LLUUID agentID, LLUUID sessionID, LLUUID TransactionID);
public delegate void ObjectPermissions( public delegate void ObjectPermissions(IClientAPI controller, LLUUID agentID, LLUUID sessionID, byte field, uint localId, uint mask, byte set);
IClientAPI remoteClinet, LLUUID AgentID, LLUUID SessionID,
List<ObjectPermissionsPacket.ObjectDataBlock> permChanges);
public interface IClientAPI public interface IClientAPI
{ {

View File

@ -51,11 +51,11 @@ namespace OpenSim.Region.ClientStack
/// </summary> /// </summary>
public class ClientView : IClientAPI public class ClientView : IClientAPI
{ {
// ~ClientView() // ~ClientView()
// { // {
// System.Console.WriteLine("[CLIENTVIEW]: Destructor called"); // System.Console.WriteLine("[CLIENTVIEW]: Destructor called");
// } // }
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/* static variables */ /* static variables */
@ -239,10 +239,10 @@ namespace OpenSim.Region.ClientStack
private void CloseCleanup() private void CloseCleanup()
{ {
m_scene.RemoveClient(AgentId); m_scene.RemoveClient(AgentId);
//m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
//m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true)); //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
// Send the STOP packet // Send the STOP packet
DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
OutPacket(disable, ThrottleOutPacketType.Task); OutPacket(disable, ThrottleOutPacketType.Task);
@ -368,7 +368,7 @@ namespace OpenSim.Region.ClientStack
if (m_debug > 0) if (m_debug > 0)
{ {
string info = String.Empty; string info = String.Empty;
if (m_debug < 255 && packet.Type == PacketType.AgentUpdate) if (m_debug < 255 && packet.Type == PacketType.AgentUpdate)
return; return;
if (m_debug < 254 && packet.Type == PacketType.ViewerEffect) if (m_debug < 254 && packet.Type == PacketType.ViewerEffect)
@ -1006,7 +1006,7 @@ namespace OpenSim.Region.ClientStack
int MAX_ITEMS_PER_PACKET = 6; int MAX_ITEMS_PER_PACKET = 6;
Encoding enc = Encoding.ASCII; Encoding enc = Encoding.ASCII;
uint FULL_MASK_PERMISSIONS = 2147483647; uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
InventoryDescendentsPacket descend; InventoryDescendentsPacket descend;
int i; int i;
int count; int count;
@ -1179,7 +1179,7 @@ namespace OpenSim.Region.ClientStack
public void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item) public void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item)
{ {
Encoding enc = Encoding.ASCII; Encoding enc = Encoding.ASCII;
uint FULL_MASK_PERMISSIONS = 2147483647; uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply); FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
inventoryReply.AgentData.AgentID = AgentId; inventoryReply.AgentData.AgentID = AgentId;
@ -1221,7 +1221,7 @@ namespace OpenSim.Region.ClientStack
public void SendInventoryItemCreateUpdate(InventoryItemBase Item) public void SendInventoryItemCreateUpdate(InventoryItemBase Item)
{ {
Encoding enc = Encoding.ASCII; Encoding enc = Encoding.ASCII;
uint FULL_MASK_PERMISSIONS = 2147483647; uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
UpdateCreateInventoryItemPacket InventoryReply = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.UpdateCreateInventoryItem); UpdateCreateInventoryItemPacket InventoryReply = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.UpdateCreateInventoryItem);
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
InventoryReply.AgentData.AgentID = AgentId; InventoryReply.AgentData.AgentID = AgentId;
@ -1601,9 +1601,9 @@ namespace OpenSim.Region.ClientStack
terse.RegionData.TimeDilation = timeDilation; terse.RegionData.TimeDilation = timeDilation;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock; terse.ObjectData[0] = terseBlock;
terse.Header.Reliable = false; terse.Header.Reliable = false;
OutPacket(terse, ThrottleOutPacketType.Task); OutPacket(terse, ThrottleOutPacketType.Task);
} }
@ -1695,7 +1695,7 @@ namespace OpenSim.Region.ClientStack
outPacket.ObjectData[0].PSBlock = particleSystem; outPacket.ObjectData[0].PSBlock = particleSystem;
outPacket.ObjectData[0].ClickAction = clickAction; outPacket.ObjectData[0].ClickAction = clickAction;
//outPacket.ObjectData[0].Flags = 0; //outPacket.ObjectData[0].Flags = 0;
// Sound Radius // Sound Radius
outPacket.ObjectData[0].Radius = 20; outPacket.ObjectData[0].Radius = 20;
@ -1707,7 +1707,7 @@ namespace OpenSim.Region.ClientStack
if (textureanim.Length > 0) if (textureanim.Length > 0)
outPacket.ObjectData[0].TextureAnim = textureanim; outPacket.ObjectData[0].TextureAnim = textureanim;
OutPacket(outPacket, ThrottleOutPacketType.Task); OutPacket(outPacket, ThrottleOutPacketType.Task);
} }
@ -1978,7 +1978,7 @@ namespace OpenSim.Region.ClientStack
objectData.PathTwistBegin = primData.PathTwistBegin; objectData.PathTwistBegin = primData.PathTwistBegin;
objectData.ExtraParams = primData.ExtraParams; objectData.ExtraParams = primData.ExtraParams;
} }
/// <summary> /// <summary>
/// Set some default values in a ObjectUpdatePacket /// Set some default values in a ObjectUpdatePacket
/// </summary> /// </summary>
@ -3100,15 +3100,25 @@ namespace OpenSim.Region.ClientStack
} }
break; break;
case PacketType.ObjectPermissions: case PacketType.ObjectPermissions:
m_log.Warn("[CLIENT]: unhandled packet " + PacketType.ObjectPermissions.ToString()); if (OnObjectPermissions != null)
ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
List<ObjectPermissionsPacket.ObjectDataBlock> permChanges =
new List<ObjectPermissionsPacket.ObjectDataBlock>();
for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
{ {
permChanges.Add(newobjPerms.ObjectData[i]); ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
LLUUID AgentID = newobjPerms.AgentData.AgentID;
LLUUID SessionID = newobjPerms.AgentData.SessionID;
for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
{
ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
byte field = permChanges.Field;
uint localID = permChanges.ObjectLocalID;
uint mask = permChanges.Mask;
byte set = permChanges.Set;
OnObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
}
} }
// Here's our data, // Here's our data,
@ -3123,12 +3133,6 @@ namespace OpenSim.Region.ClientStack
// Unfortunately, we have to pass the event the packet because objData is an array // Unfortunately, we have to pass the event the packet because objData is an array
// That means multiple object perms may be updated in a single packet. // That means multiple object perms may be updated in a single packet.
LLUUID AgentID = newobjPerms.AgentData.AgentID;
LLUUID SessionID = newobjPerms.AgentData.SessionID;
if (OnObjectPermissions != null)
{
OnObjectPermissions(this, AgentID, SessionID, permChanges);
}
break; break;
@ -3481,8 +3485,8 @@ namespace OpenSim.Region.ClientStack
{ {
OnMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID); OnMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
} }
break; break;
case PacketType.UUIDNameRequest: case PacketType.UUIDNameRequest:
UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;

View File

@ -46,9 +46,9 @@ using OpenSim.Region.Environment.Modules;
using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using OpenSim.Region.Terrain; using OpenSim.Region.Terrain;
using Caps=OpenSim.Region.Capabilities.Caps; using Caps = OpenSim.Region.Capabilities.Caps;
using Image=System.Drawing.Image; using Image = System.Drawing.Image;
using Timer=System.Timers.Timer; using Timer = System.Timers.Timer;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
@ -193,10 +193,10 @@ namespace OpenSim.Region.Environment.Scenes
} }
// Local reference to the objects in the scene (which are held in innerScene) // Local reference to the objects in the scene (which are held in innerScene)
// public Dictionary<LLUUID, SceneObjectGroup> Objects // public Dictionary<LLUUID, SceneObjectGroup> Objects
// { // {
// get { return m_innerScene.SceneObjects; } // get { return m_innerScene.SceneObjects; }
// } // }
// Reference to all of the agents in the scene (root and child) // Reference to all of the agents in the scene (root and child)
protected Dictionary<LLUUID, ScenePresence> m_scenePresences protected Dictionary<LLUUID, ScenePresence> m_scenePresences
@ -205,11 +205,11 @@ namespace OpenSim.Region.Environment.Scenes
set { m_innerScene.ScenePresences = value; } set { m_innerScene.ScenePresences = value; }
} }
// protected Dictionary<LLUUID, SceneObjectGroup> m_sceneObjects // protected Dictionary<LLUUID, SceneObjectGroup> m_sceneObjects
// { // {
// get { return m_innerScene.SceneObjects; } // get { return m_innerScene.SceneObjects; }
// set { m_innerScene.SceneObjects = value; } // set { m_innerScene.SceneObjects = value; }
// } // }
public Dictionary<LLUUID, EntityBase> Entities public Dictionary<LLUUID, EntityBase> Entities
{ {
@ -278,7 +278,7 @@ namespace OpenSim.Region.Environment.Scenes
//m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>(); //m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>();
m_log.Info("[SCENE]: Creating LandMap"); m_log.Info("[SCENE]: Creating LandMap");
Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY);
httpListener = httpServer; httpListener = httpServer;
m_dumpAssetsToFile = dumpAssetsToFile; m_dumpAssetsToFile = dumpAssetsToFile;
@ -308,13 +308,13 @@ namespace OpenSim.Region.Environment.Scenes
{ {
OSString = System.Environment.OSVersion.ToString(); OSString = System.Environment.OSVersion.ToString();
} }
else else
{ {
OSString = Util.ReadEtcIssue(); OSString = Util.ReadEtcIssue();
} }
if (OSString.Length > 45) if (OSString.Length > 45)
{ {
OSString = OSString.Substring(0,45); OSString = OSString.Substring(0, 45);
} }
m_simulatorVersion = "OpenSimulator v0.5-SVN on " + OSString + " ChilTasks:" + m_sendTasksToChild.ToString() + " PhysPrim:" + m_physicalPrim.ToString(); m_simulatorVersion = "OpenSimulator v0.5-SVN on " + OSString + " ChilTasks:" + m_sendTasksToChild.ToString() + " PhysPrim:" + m_physicalPrim.ToString();
@ -383,7 +383,7 @@ namespace OpenSim.Region.Environment.Scenes
int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX); int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX);
int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY); int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY);
if ((resultX <= 1) && if ((resultX <= 1) &&
( resultY <= 1)) (resultY <= 1))
{ {
try try
{ {
@ -434,11 +434,11 @@ namespace OpenSim.Region.Environment.Scenes
{ {
// Now we figure out what to set the timer to that does the notifications and calls, RestartNow() // Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
m_restartTimer.Interval = 15000; m_restartTimer.Interval = 15000;
m_incrementsof15seconds = (int) seconds/15; m_incrementsof15seconds = (int)seconds / 15;
m_RestartTimerCounter = 0; m_RestartTimerCounter = 0;
m_restartTimer.AutoReset = true; m_restartTimer.AutoReset = true;
m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
m_log.Error("[REGION]: Restarting Region in " + (seconds/60) + " minutes"); m_log.Error("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
m_restartTimer.Start(); m_restartTimer.Start();
SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes"); SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes");
//SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes"); //SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes");
@ -455,11 +455,11 @@ namespace OpenSim.Region.Environment.Scenes
if (m_RestartTimerCounter <= m_incrementsof15seconds) if (m_RestartTimerCounter <= m_incrementsof15seconds)
{ {
if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + SendRegionMessageFromEstateTools(LLUUID.Random(), LLUUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " +
((8 - m_RestartTimerCounter) * 15) + " seconds"); ((8 - m_RestartTimerCounter) * 15) + " seconds");
// SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) + // SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) +
//" seconds"); //" seconds");
} }
else else
{ {
@ -548,7 +548,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
} }
} }
m_scripts_enabled = !ScriptEngine; m_scripts_enabled = !ScriptEngine;
@ -612,7 +612,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
m_log.Debug("[SCENE]: Starting timer"); m_log.Debug("[SCENE]: Starting timer");
m_heartbeatTimer.Enabled = true; m_heartbeatTimer.Enabled = true;
m_heartbeatTimer.Interval = (int) (m_timespan*1000); m_heartbeatTimer.Interval = (int)(m_timespan * 1000);
m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
} }
@ -650,7 +650,7 @@ namespace OpenSim.Region.Environment.Scenes
updateLock.WaitOne(); updateLock.WaitOne();
float physicsFPS = 0; float physicsFPS = 0;
int agentsInScene = m_innerScene.GetRootAgentCount() + m_innerScene.GetChildAgentCount(); int agentsInScene = m_innerScene.GetRootAgentCount() + m_innerScene.GetChildAgentCount();
if (agentsInScene > 21) if (agentsInScene > 21)
{ {
@ -681,41 +681,41 @@ namespace OpenSim.Region.Environment.Scenes
// Loop it // Loop it
if (m_frame == Int32.MaxValue) if (m_frame == Int32.MaxValue)
m_frame = 0; m_frame = 0;
physicsMS2 = System.Environment.TickCount;
if ((m_frame%m_update_physics == 0) && m_physics_enabled) physicsMS2 = System.Environment.TickCount;
if ((m_frame % m_update_physics == 0) && m_physics_enabled)
m_innerScene.UpdatePreparePhysics(); m_innerScene.UpdatePreparePhysics();
physicsMS2 = System.Environment.TickCount - physicsMS2; physicsMS2 = System.Environment.TickCount - physicsMS2;
if (m_frame%m_update_entitymovement == 0) if (m_frame % m_update_entitymovement == 0)
m_innerScene.UpdateEntityMovement(); m_innerScene.UpdateEntityMovement();
physicsMS = System.Environment.TickCount; physicsMS = System.Environment.TickCount;
if ((m_frame%m_update_physics == 0) && m_physics_enabled) if ((m_frame % m_update_physics == 0) && m_physics_enabled)
physicsFPS = m_innerScene.UpdatePhysics( physicsFPS = m_innerScene.UpdatePhysics(
Math.Max(SinceLastFrame.TotalSeconds, m_timespan) Math.Max(SinceLastFrame.TotalSeconds, m_timespan)
); );
physicsMS = System.Environment.TickCount - physicsMS; physicsMS = System.Environment.TickCount - physicsMS;
physicsMS += physicsMS2; physicsMS += physicsMS2;
otherMS = System.Environment.TickCount; otherMS = System.Environment.TickCount;
if (m_frame%m_update_entities == 0) if (m_frame % m_update_entities == 0)
m_innerScene.UpdateEntities(); m_innerScene.UpdateEntities();
if (m_frame%m_update_events == 0) if (m_frame % m_update_events == 0)
UpdateEvents(); UpdateEvents();
if (m_frame%m_update_backup == 0) if (m_frame % m_update_backup == 0)
UpdateStorageBackup(); UpdateStorageBackup();
if (m_frame%m_update_terrain == 0) if (m_frame % m_update_terrain == 0)
UpdateTerrain(); UpdateTerrain();
if (m_frame%m_update_land == 0) if (m_frame % m_update_land == 0)
UpdateLand(); UpdateLand();
otherMS = System.Environment.TickCount - otherMS; otherMS = System.Environment.TickCount - otherMS;
// if (m_frame%m_update_avatars == 0) // if (m_frame%m_update_avatars == 0)
// UpdateInWorldTime(); // UpdateInWorldTime();
m_statsReporter.AddPhysicsFPS(physicsFPS); m_statsReporter.AddPhysicsFPS(physicsFPS);
@ -732,7 +732,7 @@ namespace OpenSim.Region.Environment.Scenes
m_statsReporter.addOtherMS(otherMS); m_statsReporter.addOtherMS(otherMS);
m_statsReporter.SetActiveScripts(m_innerScene.GetActiveScripts()); m_statsReporter.SetActiveScripts(m_innerScene.GetActiveScripts());
m_statsReporter.addScriptLines(m_innerScene.GetScriptLPS()); m_statsReporter.addScriptLines(m_innerScene.GetScriptLPS());
} }
catch (NotImplementedException) catch (NotImplementedException)
{ {
@ -746,7 +746,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
updateLock.ReleaseMutex(); updateLock.ReleaseMutex();
m_timedilation = m_timespan/(float) SinceLastFrame.TotalSeconds; m_timedilation = m_timespan / (float)SinceLastFrame.TotalSeconds;
m_lastupdate = DateTime.Now; m_lastupdate = DateTime.Now;
} }
} }
@ -871,10 +871,10 @@ namespace OpenSim.Region.Environment.Scenes
public void ExportWorldMap(string fileName) public void ExportWorldMap(string fileName)
{ {
List<MapBlockData> mapBlocks = List<MapBlockData> mapBlocks =
CommsManager.GridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9), CommsManager.GridService.RequestNeighbourMapBlocks((int)(RegionInfo.RegionLocX - 9),
(int) (RegionInfo.RegionLocY - 9), (int)(RegionInfo.RegionLocY - 9),
(int) (RegionInfo.RegionLocX + 9), (int)(RegionInfo.RegionLocX + 9),
(int) (RegionInfo.RegionLocY + 9)); (int)(RegionInfo.RegionLocY + 9));
List<AssetBase> textures = new List<AssetBase>(); List<AssetBase> textures = new List<AssetBase>();
List<Image> bitImages = new List<Image>(); List<Image> bitImages = new List<Image>();
@ -909,9 +909,9 @@ namespace OpenSim.Region.Environment.Scenes
for (int i = 0; i < mapBlocks.Count; i++) for (int i = 0; i < mapBlocks.Count; i++)
{ {
ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10); ushort x = (ushort)((mapBlocks[i].X - RegionInfo.RegionLocX) + 10);
ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10); ushort y = (ushort)((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10);
g.DrawImage(bitImages[i], (x*128), (y*128), 128, 128); g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128);
} }
mapTexture.Save(fileName, ImageFormat.Jpeg); mapTexture.Save(fileName, ImageFormat.Jpeg);
} }
@ -1019,17 +1019,17 @@ namespace OpenSim.Region.Environment.Scenes
public void loadAllLandObjectsFromStorage() public void loadAllLandObjectsFromStorage()
{ {
m_log.Info("[SCENE]: Loading land objects from storage"); m_log.Info("[SCENE]: Loading land objects from storage");
List<LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); List<LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID);
if (landData.Count == 0) if (landData.Count == 0)
{ {
m_LandManager.NoLandDataFromStorage(); m_LandManager.NoLandDataFromStorage();
} }
else else
{ {
m_LandManager.IncomingLandObjectsFromStorage(landData); m_LandManager.IncomingLandObjectsFromStorage(landData);
} }
} }
#endregion #endregion
@ -1042,7 +1042,7 @@ namespace OpenSim.Region.Environment.Scenes
public virtual void LoadPrimsFromStorage(bool m_permissions) public virtual void LoadPrimsFromStorage(bool m_permissions)
{ {
m_log.Info("[SCENE]: Loading objects from datastore"); m_log.Info("[SCENE]: Loading objects from datastore");
List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(m_regInfo.RegionID); List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(m_regInfo.RegionID);
foreach (SceneObjectGroup group in PrimsFromDB) foreach (SceneObjectGroup group in PrimsFromDB)
{ {
@ -1054,7 +1054,7 @@ namespace OpenSim.Region.Environment.Scenes
group.ApplyPhysics(m_physicalPrim); group.ApplyPhysics(m_physicalPrim);
//rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); //rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
} }
m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
} }
@ -1075,7 +1075,7 @@ namespace OpenSim.Region.Environment.Scenes
return myID; return myID;
} }
public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection) public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection)
{ {
LLVector3 pos = LLVector3.Zero; LLVector3 pos = LLVector3.Zero;
if (RayEndIsIntersection == (byte)1) if (RayEndIsIntersection == (byte)1)
@ -1095,42 +1095,42 @@ namespace OpenSim.Region.Environment.Scenes
//ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID)); //ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID));
//if (presence != null) //if (presence != null)
//{ //{
//Vector3 CameraPosition = presence.CameraPosition; //Vector3 CameraPosition = presence.CameraPosition;
//Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z); //Vector3 rayEnd = new Vector3(pos.X, pos.Y, pos.Z);
//float rayMag = m_innerScene.Vector3Distance(CameraPosition, rayEnd); //float rayMag = m_innerScene.Vector3Distance(CameraPosition, rayEnd);
//LLVector3 rayDirectionLL = Util.GetNormal(pos); //LLVector3 rayDirectionLL = Util.GetNormal(pos);
//Vector3 rayDirection = new Vector3(rayDirectionLL.X, rayDirectionLL.Y, rayDirectionLL.Z); //Vector3 rayDirection = new Vector3(rayDirectionLL.X, rayDirectionLL.Y, rayDirectionLL.Z);
//Ray rezRay = new Ray(CameraPosition, rayDirection); //Ray rezRay = new Ray(CameraPosition, rayDirection);
//Vector3 RezDirectionFromCamera = rezRay.Direction; //Vector3 RezDirectionFromCamera = rezRay.Direction;
//rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); //rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay);
//} //}
//if ((rayTracing != null) && (rayTracing.HitTF)) //if ((rayTracing != null) && (rayTracing.HitTF))
//{ //{
// We raytraced and found a prim in the way of the ground.. so // We raytraced and found a prim in the way of the ground.. so
// We will rez the object somewhere close to the prim. Better math needed. This is a Stub // We will rez the object somewhere close to the prim. Better math needed. This is a Stub
//Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z);
//Vector3 Newpos = rayTracing.ipoint; //Vector3 Newpos = rayTracing.ipoint;
//Vector3 NewScale = //Vector3 NewScale =
//new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); //new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z);
//Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; //Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation;
//Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z);
//LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; //LLQuaternion primLocalRot = rayTracing.obj.RotationOffset;
//Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); //Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z);
//Quaternion NewRot = LocalRot * ParentRot; //Quaternion NewRot = LocalRot * ParentRot;
//Vector3 RezPoint = Newpos; //Vector3 RezPoint = Newpos;
//m_log.Info("[REZINFO]: Possible Rez Point:" + RezPoint.ToString()); //m_log.Info("[REZINFO]: Possible Rez Point:" + RezPoint.ToString());
//pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z); //pos = new LLVector3(RezPoint.x, RezPoint.y, RezPoint.z);
//} //}
return pos; return pos;
@ -1150,16 +1150,16 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public virtual void AddNewPrim(LLUUID ownerID, LLVector3 RayEnd, LLQuaternion rot, PrimitiveBaseShape shape, public virtual void AddNewPrim(LLUUID ownerID, LLVector3 RayEnd, LLQuaternion rot, PrimitiveBaseShape shape,
byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID, byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID,
byte RayEndIsIntersection) byte RayEndIsIntersection)
{ {
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); AddNewPrim(ownerID, pos, rot, shape);
@ -1192,9 +1192,9 @@ namespace OpenSim.Region.Environment.Scenes
PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); PrimitiveBaseShape treeShape = new PrimitiveBaseShape();
treeShape.PathCurve = 16; treeShape.PathCurve = 16;
treeShape.PathEnd = 49900; treeShape.PathEnd = 49900;
treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree; treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree;
treeShape.Scale = scale; treeShape.Scale = scale;
treeShape.State = (byte) treeType; treeShape.State = (byte)treeType;
return AddNewPrim(uuid, position, rotation, treeShape); return AddNewPrim(uuid, position, rotation, treeShape);
} }
@ -1399,8 +1399,8 @@ namespace OpenSim.Region.Environment.Scenes
else else
{ {
m_innerScene.removeUserCount(true); m_innerScene.removeUserCount(true);
CommsManager.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, CommsManager.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle,
avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y,
avatar.AbsolutePosition.Z); avatar.AbsolutePosition.Z);
m_sceneGridService.SendCloseChildAgentConnections(avatar); m_sceneGridService.SendCloseChildAgentConnections(avatar);
} }
@ -1451,7 +1451,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
m_log.Warn( m_log.Warn(
String.Format("[SCENE] Tried to remove non-existent scene prescence with agent ID {0} from scene Entities list", agentID)); String.Format("[SCENE] Tried to remove non-existent scene prescence with agent ID {0} from scene Entities list", agentID));
} }
} }
try try
@ -1468,8 +1468,8 @@ namespace OpenSim.Region.Environment.Scenes
} }
// Remove client agent from profile, so new logins will work // Remove client agent from profile, so new logins will work
CommsManager.UserService.clearUserAgent(agentID); CommsManager.UserService.clearUserAgent(agentID);
//m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
//m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
} }
@ -1525,9 +1525,9 @@ namespace OpenSim.Region.Environment.Scenes
m_sceneGridService.OnCloseAgentConnection += CloseConnection; m_sceneGridService.OnCloseAgentConnection += CloseConnection;
m_sceneGridService.OnRegionUp += OtherRegionUp; m_sceneGridService.OnRegionUp += OtherRegionUp;
m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
m_sceneGridService.KillObject = SendKillObject; m_sceneGridService.KillObject = SendKillObject;
@ -1652,7 +1652,7 @@ namespace OpenSim.Region.Environment.Scenes
childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY);
// Not Implemented: // Not Implemented:
//TODO: Do we need to pass the message on to one of our neighbors? //TODO: Do we need to pass the message on to one of our neighbors?
} }
return true; return true;
} }
@ -1680,7 +1680,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.
libsecondlife.Packets.DisableSimulatorPacket disable = (libsecondlife.Packets.DisableSimulatorPacket) PacketPool.Instance.GetPacket(libsecondlife.Packets.PacketType.DisableSimulator); 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);
presence.ControllingClient.Close(true); presence.ControllingClient.Close(true);
} }
@ -1794,9 +1794,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="mod"></param> /// <param name="mod"></param>
public void RegisterModuleInterface<M>(M mod) public void RegisterModuleInterface<M>(M mod)
{ {
if (!ModuleInterfaces.ContainsKey(typeof (M))) if (!ModuleInterfaces.ContainsKey(typeof(M)))
{ {
ModuleInterfaces.Add(typeof (M), mod); ModuleInterfaces.Add(typeof(M), mod);
} }
} }
@ -1806,9 +1806,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns> /// <returns></returns>
public T RequestModuleInterface<T>() public T RequestModuleInterface<T>()
{ {
if (ModuleInterfaces.ContainsKey(typeof (T))) if (ModuleInterfaces.ContainsKey(typeof(T)))
{ {
return (T) ModuleInterfaces[typeof (T)]; return (T)ModuleInterfaces[typeof(T)];
} }
else else
{ {
@ -1816,7 +1816,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
#endregion #endregion
@ -1851,11 +1851,11 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID,string message,LLUUID TextureID,int ch,string[] buttonlabels) public void SendDialogToUser(LLUUID avatarID, string objectName, LLUUID objectID, LLUUID ownerID, string message, LLUUID TextureID, int ch, string[] buttonlabels)
{ {
if (m_scenePresences.ContainsKey(avatarID)) if (m_scenePresences.ContainsKey(avatarID))
{ {
m_scenePresences[avatarID].ControllingClient.SendDialog(objectName,objectID,ownerID,message,TextureID,ch,buttonlabels); m_scenePresences[avatarID].ControllingClient.SendDialog(objectName, objectID, ownerID, message, TextureID, ch, buttonlabels);
} }
} }
@ -1883,7 +1883,7 @@ namespace OpenSim.Region.Environment.Scenes
m_LandManager.resetAllLandPrimCounts(); m_LandManager.resetAllLandPrimCounts();
m_eventManager.TriggerParcelPrimCountUpdate(); m_eventManager.TriggerParcelPrimCountUpdate();
m_LandManager.finalizeLandPrimCountUpdate(); m_LandManager.finalizeLandPrimCountUpdate();
m_LandManager.landPrimCountTainted = false; m_LandManager.landPrimCountTainted = false;
} }
/// <summary> /// <summary>
@ -1895,7 +1895,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (obj is SceneObjectGroup) if (obj is SceneObjectGroup)
{ {
m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj); m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj);
} }
} }
} }
@ -1910,9 +1910,9 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
/// <param name="message">object containing the instant message data</param> /// <param name="message">object containing the instant message data</param>
/// <returns>void</returns> /// <returns>void</returns>
public void TriggerGridInstantMessage(GridInstantMessage message,InstantMessageReceiver options) public void TriggerGridInstantMessage(GridInstantMessage message, InstantMessageReceiver options)
{ {
m_eventManager.TriggerGridInstantMessage(message,options); m_eventManager.TriggerGridInstantMessage(message, options);
} }
@ -2096,8 +2096,8 @@ namespace OpenSim.Region.Environment.Scenes
if (controller.AgentId != godID) if (controller.AgentId != godID)
controller.Kick(Helpers.FieldToUTF8String(reason)); controller.Kick(Helpers.FieldToUTF8String(reason));
} }
); );
// This is a bit crude. It seems the client will be null before it actually stops the thread // This is a bit crude. It seems the client will be null before it actually stops the thread
@ -2108,7 +2108,7 @@ namespace OpenSim.Region.Environment.Scenes
ScenePresence p = GetScenePresence(controller.AgentId); ScenePresence p = GetScenePresence(controller.AgentId);
bool childagent = !p.Equals(null) && p.IsChildAgent; bool childagent = !p.Equals(null) && p.IsChildAgent;
if (controller.AgentId != godID && !childagent) if (controller.AgentId != godID && !childagent)
// Do we really want to kick the initiator of this madness? // Do we really want to kick the initiator of this madness?
{ {
controller.Close(true); controller.Close(true);
} }
@ -2138,29 +2138,16 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
/// <summary> public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, byte field, uint localId, uint mask, byte set)
///
/// </summary>
/// <param name="controller"></param>
/// <param name="agentID"></param>
/// <param name="sessionID"></param>
/// <param name="permChanges"></param>
public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID,
List<ObjectPermissionsPacket.ObjectDataBlock> permChanges)
{ {
// Check for spoofing.. since this is permissions we're talking about here! // Check for spoofing.. since this is permissions we're talking about here!
if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) if ((controller.SessionId == sessionID) && (controller.AgentId == agentID))
{ {
for (int i = 0; i < permChanges.Count; i++)
{ // Tell the object to do permission update
// Tell the object to do permission update SceneObjectGroup chObjectGroup = GetGroupByPrim(localId);
byte field = permChanges[i].Field; chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set);
uint localID = permChanges[i].ObjectLocalID;
uint mask = permChanges[i].Mask;
byte addRemTF = permChanges[i].Set;
SceneObjectGroup chObjectGroup = GetGroupByPrim(localID);
chObjectGroup.UpdatePermissions(agentID, field, localID, mask, addRemTF);
}
} }
} }
@ -2226,7 +2213,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate();
} }
} }
} }
@ -2246,7 +2233,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID); SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID);
if (part != null) if (part != null)
{ {
if (part.Name == cmdparams[0]) if (part.Name == cmdparams[0])
@ -2493,20 +2480,20 @@ namespace OpenSim.Region.Environment.Scenes
/// ///
/// </summary> /// </summary>
/// <param name="action"></param> /// <param name="action"></param>
// public void ForEachObject(Action<SceneObjectGroup> action) // public void ForEachObject(Action<SceneObjectGroup> action)
// { // {
// List<SceneObjectGroup> presenceList; // List<SceneObjectGroup> presenceList;
// //
// lock (m_sceneObjects) // lock (m_sceneObjects)
// { // {
// presenceList = new List<SceneObjectGroup>(m_sceneObjects.Values); // presenceList = new List<SceneObjectGroup>(m_sceneObjects.Values);
// } // }
// //
// foreach (SceneObjectGroup presence in presenceList) // foreach (SceneObjectGroup presence in presenceList)
// { // {
// action(presence); // action(presence);
// } // }
// } // }
/// <summary> /// <summary>
/// ///