Mantis #2003 - thank you, SachaMagne, for a patch that implements

the first part of gesture persistence.
----------------------------------------------------------
Attachments no longer vanish on walking crossing. Teleport is still
problematic, but will now be blocked with message "Inconsistent
attachment state" rather than losing the attachment. Detach to be
able to TP in that case.
0.6.0-stable
Melanie Thielker 2008-08-20 01:48:51 +00:00
parent 2c6d8ba501
commit f206ffd5a8
8 changed files with 163 additions and 9 deletions

View File

@ -299,7 +299,8 @@ namespace OpenSim.Framework
public delegate void ScriptReset(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID);
public delegate void GetScriptRunning(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID);
public delegate void SetScriptRunning(IClientAPI remoteClient, LLUUID objectID, LLUUID itemID, bool running);
public delegate void ActivateGesture(IClientAPI client, LLUUID gestureid, LLUUID assetId);
public delegate void DeactivateGesture(IClientAPI client, LLUUID gestureid);
public delegate void TerrainUnacked(IClientAPI remoteClient, int patchX, int patchY);
@ -512,6 +513,10 @@ namespace OpenSim.Framework
event UpdateVector OnAutoPilotGo;
event TerrainUnacked OnUnackedTerrain;
event ActivateGesture OnActivateGesture;
event DeactivateGesture OnDeactivateGesture;
// void ActivateGesture(LLUUID assetId, LLUUID gestureId);
// [Obsolete("IClientAPI.OutPacket SHOULD NOT EXIST outside of LLClientView please refactor appropriately.")]
void OutPacket(Packet newPack, ThrottleOutPacketType packType);

View File

@ -247,6 +247,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private GetScriptRunning handlerGetScriptRunning = null;
private SetScriptRunning handlerSetScriptRunning = null;
private UpdateVector handlerAutoPilotGo = null;
//Gesture
private ActivateGesture handlerActivateGesture = null;
private DeactivateGesture handlerDeactivateGesture = null;
//private TerrainUnacked handlerUnackedTerrain = null;
@ -931,6 +934,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event TerrainUnacked OnUnackedTerrain;
public event ActivateGesture OnActivateGesture;
public event DeactivateGesture OnDeactivateGesture;
// voire si c'est necessaire
public void ActivateGesture(LLUUID assetId, LLUUID gestureId)
{
}
public void DeactivateGesture(LLUUID assetId, LLUUID gestureId)
{
}
#region Scene/Avatar to Client
/// <summary>
@ -2065,6 +2079,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion
// Gesture
#region Appearance/ Wearables Methods
/// <summary>
@ -5879,6 +5897,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion
#region Gesture Managment
case PacketType.ActivateGestures:
ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
handlerActivateGesture = OnActivateGesture;
if (handlerActivateGesture != null)
{
handlerActivateGesture(this,
activateGesturePacket.Data[0].AssetID,
activateGesturePacket.Data[0].ItemID);
}
else m_log.Error("Null pointer for activateGesture");
break;
case PacketType.DeactivateGestures:
DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
handlerDeactivateGesture = OnDeactivateGesture;
if (handlerDeactivateGesture != null)
{
handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
}
break;
#endregion
#region unimplemented handlers
case PacketType.StartPingCheck:

View File

@ -306,9 +306,19 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
public event RegionHandleRequest OnRegionHandleRequest;
public event ParcelInfoRequest OnParcelInfoRequest;
public event ActivateGesture OnActivateGesture;
public event DeactivateGesture OnDeactivateGesture;
#pragma warning restore 67
#endregion
public void ActivateGesture(LLUUID assetId, LLUUID gestureId)
{
}
public void DeactivateGesture(LLUUID assetId, LLUUID gestureId)
{
}
#region Overrriden Methods IGNORE

View File

@ -2343,6 +2343,11 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public void AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, LLQuaternion rot, LLVector3 pos)
{
m_innerScene.AttachObject(controllingClient, localID, attachPoint, rot, pos);
}
public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient)
{
ScenePresence presence;

View File

@ -2020,7 +2020,7 @@ namespace OpenSim.Region.Environment.Scenes
// with the deeded object, it goes back to them
grp.SetFromAssetID(grp.RootPart.LastOwnerID);
m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition);
AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition);
}
}
}
@ -2161,9 +2161,56 @@ namespace OpenSim.Region.Environment.Scenes
client.OnUnackedTerrain += TerrainUnAcked;
//Gesture
client.OnActivateGesture += ActivateGesture;
client.OnDeactivateGesture += DeactivateGesture;
// EventManager.TriggerOnNewClient(client);
}
// Gesture
public virtual void ActivateGesture(IClientAPI client, LLUUID assetId, LLUUID gestureId)
{
// UserProfileCacheService User = CommsManager.SecureInventoryService.UpdateItem(gestureid, agentID);
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId);
if (userInfo != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId);
if (item != null)
{
item.Flags = 1;
userInfo.UpdateItem(item);
}
else m_log.Error("Unable to find gesture");
}
else m_log.Error("Gesture : Unable to find user ");
m_log.DebugFormat("Asset : {0} gesture :{1}", gestureId.ToString(), assetId.ToString());
}
public virtual void DeactivateGesture(IClientAPI client, LLUUID gestureId)
{
// UserProfileCacheService User = CommsManager.SecureInventoryService.UpdateItem(gestureid, agentID);
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId);
if (userInfo != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId);
if (item != null)
{
item.Flags = 0;
userInfo.UpdateItem(item);
}
else m_log.Error("Unable to find gesture");
}
else m_log.Error("Gesture : Unable to find user ");
m_log.DebugFormat("gesture : {0} ", gestureId.ToString());
}
public virtual void TeleportClientHome(LLUUID agentId, IClientAPI client)
{
UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);

View File

@ -615,6 +615,12 @@ namespace OpenSim.Region.Environment.Scenes
if (destRegionUp)
{
if(!avatar.ValidateAttachments())
{
avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
return;
}
avatar.Close();
// Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport

View File

@ -1972,7 +1972,7 @@ namespace OpenSim.Region.Environment.Scenes
LLVector3 vel = m_velocity;
ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
if (neighbourRegion != null)
if (neighbourRegion != null && ValidateAttachments())
{
// When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar
// This means we need to remove the current caps handler here and possibly compensate later,
@ -2343,15 +2343,41 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public void CrossAttachmentsIntoNewRegion(ulong regionHandle)
public bool ValidateAttachments()
{
lock (m_attachments)
{
// Validate
foreach (SceneObjectGroup gobj in m_attachments)
{
if(gobj == null)
return false;
if(gobj.RootPart == null)
{
return false;
}
}
}
return true;
}
public bool CrossAttachmentsIntoNewRegion(ulong regionHandle)
{
m_attachmentsTransported = true;
lock (m_attachments)
{
// Validate
foreach (SceneObjectGroup gobj in m_attachments)
{
if(gobj == null || gobj.RootPart == null)
return false;
}
foreach (SceneObjectGroup gobj in m_attachments)
{
// If the prim group is null then something must have happened to it!
if (gobj != null)
if (gobj != null && gobj.RootPart != null)
{
// Set the parent localID to 0 so it transfers over properly.
gobj.RootPart.SetParentLocalId(0);
@ -2362,6 +2388,8 @@ namespace OpenSim.Region.Environment.Scenes
}
}
m_attachments.Clear();
return true;
}
}
@ -2903,10 +2931,9 @@ namespace OpenSim.Region.Environment.Scenes
m_log.InfoFormat("[ATTACHEMENT] Attach from world {0}",
itemID.ToString());
// Attach from world
if (att.ParentGroup != null)
m_scene.RezSingleAttachment(att.ParentGroup,
ControllingClient, itemID, (uint)attachpoint, 0, 0);
// Attach from world, if not already attached
if (att.ParentGroup != null && !att.IsAttachment)
m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, (uint)0, att.ParentGroup.GroupRotation, LLVector3.Zero);
}
}
}

View File

@ -207,6 +207,10 @@ namespace OpenSim.Region.Examples.SimpleModule
public event RegionHandleRequest OnRegionHandleRequest;
public event ParcelInfoRequest OnParcelInfoRequest;
public event ActivateGesture OnActivateGesture;
public event DeactivateGesture OnDeactivateGesture;
#pragma warning restore 67
private LLUUID myID = LLUUID.Random();
@ -295,6 +299,11 @@ namespace OpenSim.Region.Examples.SimpleModule
get { return m_scene; }
}
public virtual void ActivateGesture(LLUUID assetId, LLUUID gestureId)
{
}
public virtual void OutPacket(Packet newPack, ThrottleOutPacketType packType)
{
}