Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs
	OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
avinationmerge
Melanie 2012-04-24 21:30:12 +01:00
commit c5520dc83f
15 changed files with 303 additions and 360 deletions

View File

@ -79,14 +79,7 @@ namespace OpenSim.Data.MySQL
{ {
ret.PrincipalID = principalID; ret.PrincipalID = principalID;
if (m_ColumnNames == null) CheckColumnNames(result);
{
m_ColumnNames = new List<string>();
DataTable schemaTable = result.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
m_ColumnNames.Add(row["ColumnName"].ToString());
}
foreach (string s in m_ColumnNames) foreach (string s in m_ColumnNames)
{ {
@ -105,6 +98,20 @@ namespace OpenSim.Data.MySQL
} }
} }
private void CheckColumnNames(IDataReader result)
{
if (m_ColumnNames != null)
return;
List<string> columnNames = new List<string>();
DataTable schemaTable = result.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
columnNames.Add(row["ColumnName"].ToString());
m_ColumnNames = columnNames;
}
public bool Store(AuthenticationData data) public bool Store(AuthenticationData data)
{ {
if (data.Data.ContainsKey("UUID")) if (data.Data.ContainsKey("UUID"))

View File

@ -91,15 +91,17 @@ namespace OpenSim.Data.MySQL
if (m_ColumnNames != null) if (m_ColumnNames != null)
return; return;
m_ColumnNames = new List<string>(); List<string> columnNames = new List<string>();
DataTable schemaTable = reader.GetSchemaTable(); DataTable schemaTable = reader.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows) foreach (DataRow row in schemaTable.Rows)
{ {
if (row["ColumnName"] != null && if (row["ColumnName"] != null &&
(!m_Fields.ContainsKey(row["ColumnName"].ToString()))) (!m_Fields.ContainsKey(row["ColumnName"].ToString())))
m_ColumnNames.Add(row["ColumnName"].ToString()); columnNames.Add(row["ColumnName"].ToString());
} }
m_ColumnNames = columnNames;
} }
public virtual T[] Get(string field, string key) public virtual T[] Get(string field, string key)

View File

@ -162,17 +162,7 @@ namespace OpenSim.Data.MySQL
ret.sizeX = Convert.ToInt32(result["sizeX"]); ret.sizeX = Convert.ToInt32(result["sizeX"]);
ret.sizeY = Convert.ToInt32(result["sizeY"]); ret.sizeY = Convert.ToInt32(result["sizeY"]);
if (m_ColumnNames == null) CheckColumnNames(result);
{
m_ColumnNames = new List<string>();
DataTable schemaTable = result.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
{
if (row["ColumnName"] != null)
m_ColumnNames.Add(row["ColumnName"].ToString());
}
}
foreach (string s in m_ColumnNames) foreach (string s in m_ColumnNames)
{ {
@ -187,6 +177,10 @@ namespace OpenSim.Data.MySQL
if (s == "locY") if (s == "locY")
continue; continue;
object value = result[s];
if (value is DBNull)
ret.Data[s] = null;
else
ret.Data[s] = result[s].ToString(); ret.Data[s] = result[s].ToString();
} }
@ -198,6 +192,23 @@ namespace OpenSim.Data.MySQL
return retList; return retList;
} }
private void CheckColumnNames(IDataReader result)
{
if (m_ColumnNames != null)
return;
List<string> columnNames = new List<string>();
DataTable schemaTable = result.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
{
if (row["ColumnName"] != null)
columnNames.Add(row["ColumnName"].ToString());
}
m_ColumnNames = columnNames;
}
public bool Store(RegionData data) public bool Store(RegionData data)
{ {
if (data.Data.ContainsKey("uuid")) if (data.Data.ContainsKey("uuid"))

View File

@ -225,7 +225,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
int tc = 0; int tc = 0;
double[,] hm = whichScene.Heightmap.GetDoubles(); double[,] hm = whichScene.Heightmap.GetDoubles();
tc = Environment.TickCount; tc = Environment.TickCount;
m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
EntityBase[] objs = whichScene.GetEntities(); EntityBase[] objs = whichScene.GetEntities();
Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
//SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
@ -541,7 +541,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
g.Dispose(); g.Dispose();
} // lock entities objs } // lock entities objs
m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms");
return mapbmp; return mapbmp;
} }

View File

@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
public void TerrainToBitmap(Bitmap mapbmp) public void TerrainToBitmap(Bitmap mapbmp)
{ {
int tc = Environment.TickCount; int tc = Environment.TickCount;
m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain");
double[,] hm = m_scene.Heightmap.GetDoubles(); double[,] hm = m_scene.Heightmap.GetDoubles();
bool ShadowDebugContinue = true; bool ShadowDebugContinue = true;
@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
} }
} }
} }
m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
} }
} }
} }

View File

@ -278,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
public void TerrainToBitmap(Bitmap mapbmp) public void TerrainToBitmap(Bitmap mapbmp)
{ {
int tc = Environment.TickCount; int tc = Environment.TickCount;
m_log.Info("[MAPTILE]: Generating Maptile Step 1: Terrain"); m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain");
// These textures should be in the AssetCache anyway, as every client conneting to this // These textures should be in the AssetCache anyway, as every client conneting to this
// region needs them. Except on start, when the map is recreated (before anyone connected), // region needs them. Except on start, when the map is recreated (before anyone connected),
@ -412,7 +412,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
} }
} }
} }
m_log.Info("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
} }
} }
} }

View File

@ -58,6 +58,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
private Scene m_scene; private Scene m_scene;
private IFriendsModule m_friendsModule; private IFriendsModule m_friendsModule;
private IUserManagement m_userManagementModule; private IUserManagement m_userManagementModule;
private IPresenceService m_presenceService;
// private IAvatarFactoryModule m_avatarFactory; // private IAvatarFactoryModule m_avatarFactory;
@ -99,8 +100,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
m_userManagementModule = m_scene.RequestModuleInterface<IUserManagement>(); m_userManagementModule = m_scene.RequestModuleInterface<IUserManagement>();
m_presenceService = m_scene.RequestModuleInterface<IPresenceService>();
if (m_friendsModule != null && m_userManagementModule != null) if (m_friendsModule != null && m_userManagementModule != null && m_presenceService != null)
{ {
m_scene.AddCommand( m_scene.AddCommand(
"Friends", this, "friends show", "Friends", this, "friends show",
@ -162,7 +164,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId); MainConsole.Instance.OutputFormat("Friends for {0} {1} {2}:", firstName, lastName, userId);
MainConsole.Instance.OutputFormat("UUID, Name, MyFlags, TheirFlags"); MainConsole.Instance.OutputFormat(
"{0,-36} {1,-36} {2,-7} {3,7} {4,10}", "UUID", "Name", "Status", "MyFlags", "TheirFlags");
foreach (FriendInfo friend in friends) foreach (FriendInfo friend in friends)
{ {
@ -175,14 +178,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
UUID friendId; UUID friendId;
string friendName; string friendName;
string onlineText;
if (UUID.TryParse(friend.Friend, out friendId)) if (UUID.TryParse(friend.Friend, out friendId))
friendName = m_userManagementModule.GetUserName(friendId); friendName = m_userManagementModule.GetUserName(friendId);
else else
friendName = friend.Friend; friendName = friend.Friend;
OpenSim.Services.Interfaces.PresenceInfo[] pi = m_presenceService.GetAgents(new string[] { friend.Friend });
if (pi.Length > 0)
onlineText = "online";
else
onlineText = "offline";
MainConsole.Instance.OutputFormat( MainConsole.Instance.OutputFormat(
"{0} {1} {2} {3}", friend.Friend, friendName, friend.MyFlags, friend.TheirFlags); "{0,-36} {1,-36} {2,-7} {3,-7} {4,-10}",
friend.Friend, friendName, onlineText, friend.MyFlags, friend.TheirFlags);
} }
} }
} }

View File

@ -338,6 +338,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
_parent_scene.geom_name_map[prim_geom] = Name; _parent_scene.geom_name_map[prim_geom] = Name;
_parent_scene.actor_name_map[prim_geom] = this;
if (childPrim) if (childPrim)
{ {

View File

@ -29,22 +29,21 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using log4net;
using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces;
namespace OpenSim.Region.ScriptEngine.Shared.Api namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
public class ApiManager public class ApiManager
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>();
public string[] GetApis() public string[] GetApis()
{ {
if (m_Apis.Count > 0) if (m_Apis.Count <= 0)
{ {
List<string> l = new List<string>(m_Apis.Keys);
return l.ToArray();
}
Assembly a = Assembly.GetExecutingAssembly(); Assembly a = Assembly.GetExecutingAssembly();
Type[] types = a.GetExportedTypes(); Type[] types = a.GetExportedTypes();
@ -62,9 +61,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_Apis[name] = t; m_Apis[name] = t;
} }
} }
}
List<string> ret = new List<string>(m_Apis.Keys); // m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count);
return ret.ToArray();
return new List<string>(m_Apis.Keys).ToArray();
} }
public IScriptApi CreateApi(string api) public IScriptApi CreateApi(string api)

View File

@ -89,7 +89,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected IScriptEngine m_ScriptEngine; protected IScriptEngine m_ScriptEngine;
protected SceneObjectPart m_host; protected SceneObjectPart m_host;
protected uint m_localID; protected uint m_localID;
/// <summary>
/// The UUID of the item that hosts this script
/// </summary>
protected UUID m_itemID; protected UUID m_itemID;
protected bool throwErrorOnNotImplemented = true; protected bool throwErrorOnNotImplemented = true;
protected AsyncCommandManager AsyncCommands = null; protected AsyncCommandManager AsyncCommands = null;
protected float m_ScriptDelayFactor = 1.0f; protected float m_ScriptDelayFactor = 1.0f;
@ -336,28 +341,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
protected UUID InventorySelf() /// <summary>
/// Get the inventory item that hosts ourselves.
/// </summary>
/// <remarks>
/// FIXME: It would be far easier to pass in TaskInventoryItem rather than just m_itemID so that we don't need
/// to keep looking ourselves up.
/// </remarks>
/// <returns></returns>
protected TaskInventoryItem GetSelfInventoryItem()
{ {
UUID invItemID = new UUID(); TaskInventoryItem invItem = null;
bool unlock = false; bool unlock = false;
if (!m_host.TaskInventory.IsReadLockedByMe()) if (!m_host.TaskInventory.IsReadLockedByMe())
{ {
m_host.TaskInventory.LockItemsForRead(true); m_host.TaskInventory.LockItemsForRead(true);
unlock = true; unlock = true;
} }
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{ invItem = m_host.TaskInventory[m_itemID];
if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
{
invItemID = inv.Key;
break;
}
}
if (unlock) if (unlock)
{ {
m_host.TaskInventory.LockItemsForRead(false); m_host.TaskInventory.LockItemsForRead(false);
} }
return invItemID;
return invItem;
} }
protected UUID InventoryKey(string name, int type) protected UUID InventoryKey(string name, int type)
@ -941,8 +951,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llRegionSayTo(string target, int channel, string msg) public void llRegionSayTo(string target, int channel, string msg)
{ {
string error = String.Empty;
if (msg.Length > 1023) if (msg.Length > 1023)
msg = msg.Substring(0, 1023); msg = msg.Substring(0, 1023);
@ -2952,15 +2960,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llGiveMoney(string destination, int amount) public LSL_Integer llGiveMoney(string destination, int amount)
{ {
UUID invItemID=InventorySelf();
if (invItemID == UUID.Zero)
return 0;
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.TaskInventory.LockItemsForRead(true); TaskInventoryItem item = GetSelfInventoryItem();
TaskInventoryItem item = m_host.TaskInventory[invItemID];
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero) if (item.PermsGranter == UUID.Zero)
return 0; return 0;
@ -3214,19 +3216,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llTakeControls(int controls, int accept, int pass_on) public void llTakeControls(int controls, int accept, int pass_on)
{ {
TaskInventoryItem item; TaskInventoryItem item = GetSelfInventoryItem();
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter != UUID.Zero) if (item.PermsGranter != UUID.Zero)
{ {
@ -3246,26 +3236,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llReleaseControls() public void llReleaseControls()
{ {
TaskInventoryItem item;
m_host.TaskInventory.LockItemsForRead(true);
lock (m_host.TaskInventory)
{
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
}
m_host.TaskInventory.LockItemsForRead(false);
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
TaskInventoryItem item = GetSelfInventoryItem();
if (item.PermsGranter != UUID.Zero) if (item.PermsGranter != UUID.Zero)
{ {
ScenePresence presence = World.GetScenePresence(item.PermsGranter); ScenePresence presence = World.GetScenePresence(item.PermsGranter);
@ -3290,74 +3264,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_UrlModule.ReleaseURL(url); m_UrlModule.ReleaseURL(url);
} }
public void llAttachToAvatar(int attachment) /// <summary>
{ /// Attach the object containing this script to the avatar that owns it.
m_host.AddScriptLPS(1); /// </summary>
/// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
TaskInventoryItem item; /// <returns>true if the attach suceeded, false if it did not</returns>
public bool AttachToAvatar(int attachmentPoint)
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter != m_host.OwnerID)
return;
if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
{ {
SceneObjectGroup grp = m_host.ParentGroup; SceneObjectGroup grp = m_host.ParentGroup;
ScenePresence presence = World.GetScenePresence(m_host.OwnerID); ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
if (attachmentsModule != null) if (attachmentsModule != null)
attachmentsModule.AttachObject(presence, grp, (uint)attachment, false); return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
}
}
public void llDetachFromAvatar()
{
m_host.AddScriptLPS(1);
if (m_host.ParentGroup.AttachmentPoint == 0)
return;
TaskInventoryItem item;
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else else
{ return false;
item = m_host.TaskInventory[InventorySelf()];
} }
m_host.TaskInventory.LockItemsForRead(false);
/// <summary>
if (item.PermsGranter != m_host.OwnerID) /// Detach the object containing this script from the avatar it is attached to.
return; /// </summary>
/// <remarks>
if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) /// Nothing happens if the object is not attached.
/// </remarks>
public void DetachFromAvatar()
{ {
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
if (attachmentsModule != null)
Util.FireAndForget(DetachWrapper, m_host); Util.FireAndForget(DetachWrapper, m_host);
} }
}
private void DetachWrapper(object o) private void DetachWrapper(object o)
{ {
@ -3372,6 +3306,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
attachmentsModule.DetachSingleAttachmentToInv(presence, itemID); attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
} }
public void llAttachToAvatar(int attachmentPoint)
{
m_host.AddScriptLPS(1);
TaskInventoryItem item = GetSelfInventoryItem();
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter != m_host.OwnerID)
return;
if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
AttachToAvatar(attachmentPoint);
}
public void llDetachFromAvatar()
{
m_host.AddScriptLPS(1);
if (m_host.ParentGroup.AttachmentPoint == 0)
return;
TaskInventoryItem item = GetSelfInventoryItem();
if (item.PermsGranter != m_host.OwnerID)
return;
if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
DetachFromAvatar();
}
public void llTakeCamera(string avatar) public void llTakeCamera(string avatar)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
@ -3626,23 +3591,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf(); TaskInventoryItem item = GetSelfInventoryItem();
if (invItemID == UUID.Zero)
return;
TaskInventoryItem item;
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero) if (item.PermsGranter == UUID.Zero)
return; return;
@ -3666,24 +3616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID invItemID=InventorySelf(); TaskInventoryItem item = GetSelfInventoryItem();
if (invItemID == UUID.Zero)
return;
TaskInventoryItem item;
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero) if (item.PermsGranter == UUID.Zero)
return; return;
@ -3738,30 +3671,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llRequestPermissions(string agent, int perm) public void llRequestPermissions(string agent, int perm)
{ {
UUID agentID = new UUID(); UUID agentID;
if (!UUID.TryParse(agent, out agentID)) if (!UUID.TryParse(agent, out agentID))
return; return;
UUID invItemID = InventorySelf(); TaskInventoryItem item = GetSelfInventoryItem();
if (invItemID == UUID.Zero)
return; // Not in a prim? How??
TaskInventoryItem item;
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(invItemID))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[invItemID];
}
m_host.TaskInventory.LockItemsForRead(false);
if (agentID == UUID.Zero || perm == 0) // Releasing permissions if (agentID == UUID.Zero || perm == 0) // Releasing permissions
{ {
@ -3795,8 +3710,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
{ {
m_host.TaskInventory.LockItemsForWrite(true); m_host.TaskInventory.LockItemsForWrite(true);
m_host.TaskInventory[invItemID].PermsGranter = agentID; m_host.TaskInventory[m_itemID].PermsGranter = agentID;
m_host.TaskInventory[invItemID].PermsMask = perm; m_host.TaskInventory[m_itemID].PermsMask = perm;
m_host.TaskInventory.LockItemsForWrite(false); m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@ -3834,8 +3749,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
{ {
m_host.TaskInventory.LockItemsForWrite(true); m_host.TaskInventory.LockItemsForWrite(true);
m_host.TaskInventory[invItemID].PermsGranter = agentID; m_host.TaskInventory[m_itemID].PermsGranter = agentID;
m_host.TaskInventory[invItemID].PermsMask = perm; m_host.TaskInventory[m_itemID].PermsMask = perm;
m_host.TaskInventory.LockItemsForWrite(false); m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
@ -3859,8 +3774,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_waitingForScriptAnswer) if (!m_waitingForScriptAnswer)
{ {
m_host.TaskInventory.LockItemsForWrite(true); m_host.TaskInventory.LockItemsForWrite(true);
m_host.TaskInventory[invItemID].PermsGranter = agentID; m_host.TaskInventory[m_itemID].PermsGranter = agentID;
m_host.TaskInventory[invItemID].PermsMask = 0; m_host.TaskInventory[m_itemID].PermsMask = 0;
m_host.TaskInventory.LockItemsForWrite(false); m_host.TaskInventory.LockItemsForWrite(false);
presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
@ -3868,7 +3783,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
presence.ControllingClient.SendScriptQuestion( presence.ControllingClient.SendScriptQuestion(
m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm); m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, m_itemID, perm);
return; return;
} }
@ -3885,23 +3800,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (taskID != m_host.UUID) if (taskID != m_host.UUID)
return; return;
UUID invItemID = InventorySelf();
if (invItemID == UUID.Zero)
return;
client.OnScriptAnswer -= handleScriptAnswer; client.OnScriptAnswer -= handleScriptAnswer;
m_waitingForScriptAnswer = false; m_waitingForScriptAnswer = false;
if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
llReleaseControls(); llReleaseControls();
m_host.TaskInventory.LockItemsForWrite(true); m_host.TaskInventory.LockItemsForWrite(true);
m_host.TaskInventory[invItemID].PermsMask = answer; m_host.TaskInventory[m_itemID].PermsMask = answer;
m_host.TaskInventory.LockItemsForWrite(false); m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] { "run_time_permissions", new Object[] {
new LSL_Integer(answer) }, new LSL_Integer(answer) },
@ -3912,41 +3820,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.TaskInventory.LockItemsForRead(true); return GetSelfInventoryItem().PermsGranter.ToString();
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 10 && item.ItemID == m_itemID)
{
m_host.TaskInventory.LockItemsForRead(false);
return item.PermsGranter.ToString();
}
}
m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero.ToString();
} }
public LSL_Integer llGetPermissions() public LSL_Integer llGetPermissions()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.TaskInventory.LockItemsForRead(true); int perms = GetSelfInventoryItem().PermsMask;
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 10 && item.ItemID == m_itemID)
{
int perms = item.PermsMask;
if (m_automaticLinkPermission) if (m_automaticLinkPermission)
perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
m_host.TaskInventory.LockItemsForRead(false);
return perms;
}
}
m_host.TaskInventory.LockItemsForRead(false);
return 0; return perms;
} }
public LSL_Integer llGetLinkNumber() public LSL_Integer llGetLinkNumber()
@ -3984,16 +3870,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llCreateLink(string target, int parent) public void llCreateLink(string target, int parent)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf();
UUID targetID; UUID targetID;
if (!UUID.TryParse(target, out targetID)) if (!UUID.TryParse(target, out targetID))
return; return;
TaskInventoryItem item; TaskInventoryItem item = GetSelfInventoryItem();
m_host.TaskInventory.LockItemsForRead(true);
item = m_host.TaskInventory[invItemID];
m_host.TaskInventory.LockItemsForRead(false);
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission) && !m_automaticLinkPermission)
@ -4049,17 +3932,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llBreakLink(int linknum) public void llBreakLink(int linknum)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf();
m_host.TaskInventory.LockItemsForRead(true); if ((GetSelfInventoryItem().PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission) && !m_automaticLinkPermission)
{ {
ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
m_host.TaskInventory.LockItemsForRead(false);
return; return;
} }
m_host.TaskInventory.LockItemsForRead(false);
if (linknum < ScriptBaseClass.LINK_THIS) if (linknum < ScriptBaseClass.LINK_THIS)
return; return;
@ -4159,12 +4038,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf(); TaskInventoryItem item = GetSelfInventoryItem();
TaskInventoryItem item;
m_host.TaskInventory.LockItemsForRead(true);
item = m_host.TaskInventory[invItemID];
m_host.TaskInventory.LockItemsForRead(false);
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission) && !m_automaticLinkPermission)
@ -5037,22 +4911,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_String llGetScriptName() public LSL_String llGetScriptName()
{ {
string result = String.Empty;
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.TaskInventory.LockItemsForRead(true); TaskInventoryItem item = GetSelfInventoryItem();
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 10 && item.ItemID == m_itemID)
{
result = item.Name!=null?item.Name:String.Empty;
break;
}
}
m_host.TaskInventory.LockItemsForRead(false);
return result; return item.Name != null ? item.Name : String.Empty;
} }
public LSL_Integer llGetLinkNumberOfSides(int link) public LSL_Integer llGetLinkNumberOfSides(int link)
@ -10437,22 +10300,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llGetCameraPos() public LSL_Vector llGetCameraPos()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf();
if (invItemID == UUID.Zero) TaskInventoryItem item = GetSelfInventoryItem();
if (item.PermsGranter == UUID.Zero)
return new LSL_Vector(); return new LSL_Vector();
m_host.TaskInventory.LockItemsForRead(true); if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
{
m_host.TaskInventory.LockItemsForRead(false);
return new LSL_Vector();
}
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{ {
ShoutError("No permissions to track the camera"); ShoutError("No permissions to track the camera");
m_host.TaskInventory.LockItemsForRead(false);
return new LSL_Vector(); return new LSL_Vector();
} }
m_host.TaskInventory.LockItemsForRead(false); m_host.TaskInventory.LockItemsForRead(false);
@ -10469,20 +10325,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Rotation llGetCameraRot() public LSL_Rotation llGetCameraRot()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf();
if (invItemID == UUID.Zero) TaskInventoryItem item = GetSelfInventoryItem();
if (item.PermsGranter == UUID.Zero)
return new LSL_Rotation(); return new LSL_Rotation();
m_host.TaskInventory.LockItemsForRead(true); if ((item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
{
m_host.TaskInventory.LockItemsForRead(false);
return new LSL_Rotation();
}
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{ {
ShoutError("No permissions to track the camera"); ShoutError("No permissions to track the camera");
m_host.TaskInventory.LockItemsForRead(false);
return new LSL_Rotation(); return new LSL_Rotation();
} }
m_host.TaskInventory.LockItemsForRead(false); m_host.TaskInventory.LockItemsForRead(false);
@ -10670,30 +10521,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
// our key in the object we are in
UUID invItemID = InventorySelf();
if (invItemID == UUID.Zero) return;
// the object we are in // the object we are in
UUID objectID = m_host.ParentUUID; UUID objectID = m_host.ParentUUID;
if (objectID == UUID.Zero) return; if (objectID == UUID.Zero)
return;
TaskInventoryItem item = GetSelfInventoryItem();
UUID agentID;
m_host.TaskInventory.LockItemsForRead(true);
// we need the permission first, to know which avatar we want to set the camera for // we need the permission first, to know which avatar we want to set the camera for
agentID = m_host.TaskInventory[invItemID].PermsGranter; UUID agentID = item.PermsGranter;
if (agentID == UUID.Zero) if (agentID == UUID.Zero)
{
m_host.TaskInventory.LockItemsForRead(false);
return; return;
}
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
{
m_host.TaskInventory.LockItemsForRead(false);
return; return;
}
m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(agentID); ScenePresence presence = World.GetScenePresence(agentID);
@ -10735,34 +10577,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
// our key in the object we are in
UUID invItemID=InventorySelf();
if (invItemID == UUID.Zero) return;
// the object we are in // the object we are in
UUID objectID = m_host.ParentUUID; UUID objectID = m_host.ParentUUID;
if (objectID == UUID.Zero) return; if (objectID == UUID.Zero)
return;
TaskInventoryItem item = GetSelfInventoryItem();
// we need the permission first, to know which avatar we want to clear the camera for // we need the permission first, to know which avatar we want to clear the camera for
UUID agentID; UUID agentID = item.PermsGranter;
m_host.TaskInventory.LockItemsForRead(true);
agentID = m_host.TaskInventory[invItemID].PermsGranter;
if (agentID == UUID.Zero) if (agentID == UUID.Zero)
{
m_host.TaskInventory.LockItemsForRead(false);
return; return;
}
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) if ((item.PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
{
m_host.TaskInventory.LockItemsForRead(false);
return; return;
}
m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(agentID); ScenePresence presence = World.GetScenePresence(agentID);
// we are not interested in child-agents // we are not interested in child-agents
if (presence.IsChildAgent) return; if (presence.IsChildAgent)
return;
presence.ControllingClient.SendClearFollowCamProperties(objectID); presence.ControllingClient.SendClearFollowCamProperties(objectID);
} }
@ -12231,8 +12066,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
try try
{ {
UUID invItemID=InventorySelf(); TaskInventoryItem item = GetSelfInventoryItem();
if (invItemID == UUID.Zero) if (item == null)
{ {
replydata = "SERVICE_ERROR"; replydata = "SERVICE_ERROR";
return; return;
@ -12240,10 +12075,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.TaskInventory.LockItemsForRead(true);
TaskInventoryItem item = m_host.TaskInventory[invItemID];
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero) if (item.PermsGranter == UUID.Zero)
{ {
replydata = "MISSING_PERMISSION_DEBIT"; replydata = "MISSING_PERMISSION_DEBIT";

View File

@ -218,6 +218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
/// <summary>
/// Initialize the LSL interface.
/// </summary>
/// <remarks>
/// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no
/// guarantee the interface is present on Initialize(). There needs to be another post initialize call from
/// ScriptInstance.
/// </remarks>
private void InitLSL() private void InitLSL()
{ {
if (m_LSL_Api != null) if (m_LSL_Api != null)
@ -1616,7 +1624,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public Object osParseJSONNew(string JSON) public Object osParseJSONNew(string JSON)
{ {
CheckThreatLevel(ThreatLevel.None, "osParseJSON"); CheckThreatLevel(ThreatLevel.None, "osParseJSONNew");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
@ -3139,5 +3147,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
} }
} }
public void osForceAttachToAvatar(int attachmentPoint)
{
CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
m_host.AddScriptLPS(1);
InitLSL();
((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
}
public void osForceDetachFromAvatar()
{
CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
m_host.AddScriptLPS(1);
InitLSL();
((LSL_Api)m_LSL_Api).DetachFromAvatar();
}
} }
} }

View File

@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osAvatarPlayAnimation(string avatar, string animation); void osAvatarPlayAnimation(string avatar, string animation);
void osAvatarStopAnimation(string avatar, string animation); void osAvatarStopAnimation(string avatar, string animation);
// Attachment commands
/// <summary>
/// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
/// </summary>
/// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
void osForceAttachToAvatar(int attachment);
/// <summary>
/// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
/// </summary>
/// <remarks>Nothing happens if the object is not attached.</remarks>
void osForceDetachFromAvatar();
//texture draw functions //texture draw functions
string osMovePen(string drawList, int x, int y); string osMovePen(string drawList, int x, int y);
string osDrawLine(string drawList, int startX, int startY, int endX, int endY); string osDrawLine(string drawList, int startX, int startY, int endX, int endY);

View File

@ -289,6 +289,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
} }
// Avatar functions
public void osForceAttachToAvatar(int attachmentPoint)
{
m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint);
}
public void osForceDetachFromAvatar()
{
m_OSSL_Functions.osForceDetachFromAvatar();
}
// Texture Draw functions // Texture Draw functions

View File

@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
public IScriptApi GetApi(string name) public IScriptApi GetApi(string name)
{ {
if (m_Apis.ContainsKey(name)) if (m_Apis.ContainsKey(name))
{
// m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName);
return m_Apis[name]; return m_Apis[name];
}
// m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName);
return null; return null;
} }

View File

@ -355,7 +355,26 @@ namespace OpenSim.Services.LLLoginService
private void SetDefaultValues() private void SetDefaultValues()
{ {
DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; TimeZoneInfo gridTimeZone;
try
{
// First try to fetch DST from Pacific Standard Time, because this is
// the one expected by the viewer. "US/Pacific" is the string to search
// on linux and mac, and should work also on Windows (to confirm)
gridTimeZone = TimeZoneInfo.FindSystemTimeZoneById("US/Pacific");
}
catch (Exception e)
{
m_log.WarnFormat(
"[TIMEZONE]: {0} Falling back to system time. System time should be set to Pacific Standard Time to provide the expected time",
e.Message);
gridTimeZone = TimeZoneInfo.Local;
}
DST = gridTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
StipendSinceLogin = "N"; StipendSinceLogin = "N";
Gendered = "Y"; Gendered = "Y";
EverLoggedIn = "Y"; EverLoggedIn = "Y";