From 976728029b12853747401288c38a54c8bd7a5c50 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Mon, 23 Nov 2009 01:12:46 -0500 Subject: * Moved 40 more Packet handlers to the PacketDelegate and out of the 5000 line switch. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 1392 +++++++++++++++++--- 1 file changed, 1245 insertions(+), 147 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 6c1d14a..7f7b820 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4324,15 +4324,57 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit); AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit); AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger); + AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest); + AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest); + AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest); + AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo); + AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest); + AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle); + AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause); + AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume); + AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease); + AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink); + AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink); + AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd); + AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape); + AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams); + AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate); + AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects); + AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect); + AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect); + AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition); + AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale); + AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation); + AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate); + AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage); + AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab); + AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate); + AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab); + AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart); + AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate); + AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop); + AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription); + AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName); + AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions); + AddLocalPacketHandler(PacketType.Undo, HandleUndo); + AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay); + AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily); + AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch); + AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes); + AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction); + AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial); //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); + } #region Packet Handlers + #region Scene/Avatar + private bool HandleAgentUpdate(IClientAPI sener, Packet Pack) { if (OnAgentUpdate != null) @@ -4977,289 +5019,1324 @@ namespace OpenSim.Region.ClientStack.LindenUDP wearingArgs.NowWearing.Add(wearable); } - AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing; - if (handlerAvatarNowWearing != null) + AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing; + if (handlerAvatarNowWearing != null) + { + handlerAvatarNowWearing(this, wearingArgs); + } + } + return true; + } + + private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack) + { + RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; + if (handlerRezSingleAttachment != null) + { + RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (rez.AgentData.SessionID != SessionId || + rez.AgentData.AgentID != AgentId) + return true; + } + #endregion + + handlerRezSingleAttachment(this, rez.ObjectData.ItemID, + rez.ObjectData.AttachmentPt); + } + + return true; + } + + private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack) + { + RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv; + if (handlerRezMultipleAttachments != null) + { + RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack; + handlerRezMultipleAttachments(this, rez.HeaderData, + rez.ObjectData); + } + + return true; + } + + private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack) + { + UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; + if (handlerDetachAttachmentIntoInv != null) + { + DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; + + #region Packet Session and User Check + // UNSUPPORTED ON THIS PACKET + #endregion + + UUID itemID = detachtoInv.ObjectData.ItemID; + // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID; + + handlerDetachAttachmentIntoInv(itemID, this); + } + return true; + } + + private bool HandleObjectAttach(IClientAPI sender, Packet Pack) + { + if (OnObjectAttach != null) + { + ObjectAttachPacket att = (ObjectAttachPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (att.AgentData.SessionID != SessionId || + att.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectAttach handlerObjectAttach = OnObjectAttach; + + if (handlerObjectAttach != null) + { + if (att.ObjectData.Length > 0) + { + handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation, false); + } + } + } + return true; + } + + private bool HandleObjectDetach(IClientAPI sender, Packet Pack) + { + ObjectDetachPacket dett = (ObjectDetachPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dett.AgentData.SessionID != SessionId || + dett.AgentData.AgentID != AgentId) + return true; + } + #endregion + + for (int j = 0; j < dett.ObjectData.Length; j++) + { + uint obj = dett.ObjectData[j].ObjectLocalID; + ObjectDeselect handlerObjectDetach = OnObjectDetach; + if (handlerObjectDetach != null) + { + handlerObjectDetach(obj, this); + } + + } + return true; + } + + private bool HandleObjectDrop(IClientAPI sender, Packet Pack) + { + ObjectDropPacket dropp = (ObjectDropPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dropp.AgentData.SessionID != SessionId || + dropp.AgentData.AgentID != AgentId) + return true; + } + #endregion + + for (int j = 0; j < dropp.ObjectData.Length; j++) + { + uint obj = dropp.ObjectData[j].ObjectLocalID; + ObjectDrop handlerObjectDrop = OnObjectDrop; + if (handlerObjectDrop != null) + { + handlerObjectDrop(obj, this); + } + } + return true; + } + + private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack) + { + SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (run.AgentData.SessionID != SessionId || + run.AgentData.AgentID != AgentId) + return true; + } + #endregion + + SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun; + if (handlerSetAlwaysRun != null) + handlerSetAlwaysRun(this, run.AgentData.AlwaysRun); + + return true; + } + + private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack) + { + GenericCall2 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; + if (handlerCompleteMovementToRegion != null) + { + handlerCompleteMovementToRegion(); + } + handlerCompleteMovementToRegion = null; + + return true; + } + + private bool HandleAgentAnimation(IClientAPI sender, Packet Pack) + { + AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (AgentAni.AgentData.SessionID != SessionId || + AgentAni.AgentData.AgentID != AgentId) + return true; + } + #endregion + + StartAnim handlerStartAnim = null; + StopAnim handlerStopAnim = null; + + for (int i = 0; i < AgentAni.AnimationList.Length; i++) + { + if (AgentAni.AnimationList[i].StartAnim) + { + handlerStartAnim = OnStartAnim; + if (handlerStartAnim != null) + { + handlerStartAnim(this, AgentAni.AnimationList[i].AnimID); + } + } + else + { + handlerStopAnim = OnStopAnim; + if (handlerStopAnim != null) + { + handlerStopAnim(this, AgentAni.AnimationList[i].AnimID); + } + } + } + return true; + } + + private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack) + { + if (OnAgentRequestSit != null) + { + AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (agentRequestSit.AgentData.SessionID != SessionId || + agentRequestSit.AgentData.AgentID != AgentId) + return true; + } + #endregion + + AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit; + if (handlerAgentRequestSit != null) + handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, + agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); + } + return true; + } + + private bool HandleAgentSit(IClientAPI sender, Packet Pack) + { + if (OnAgentSit != null) + { + AgentSitPacket agentSit = (AgentSitPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (agentSit.AgentData.SessionID != SessionId || + agentSit.AgentData.AgentID != AgentId) + return true; + } + #endregion + + AgentSit handlerAgentSit = OnAgentSit; + if (handlerAgentSit != null) + { + OnAgentSit(this, agentSit.AgentData.AgentID); + } + } + return true; + } + + private bool HandleSoundTrigger(IClientAPI sender, Packet Pack) + { + SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + // UNSUPPORTED ON THIS PACKET + } + #endregion + + SoundTrigger handlerSoundTrigger = OnSoundTrigger; + if (handlerSoundTrigger != null) + { + handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID, + soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID, + soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position, + soundTriggerPacket.SoundData.Handle); + + } + return true; + } + + private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack) + { + AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (avRequestQuery.AgentData.SessionID != SessionId || + avRequestQuery.AgentData.AgentID != AgentId) + return true; + } + #endregion + + AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; + AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; + //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name)); + + AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest; + if (handlerAvatarPickerRequest != null) + { + handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, + Utils.BytesToString(querydata.Name)); + } + return true; + } + + private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack) + { + AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId || + avRequestDataUpdatePacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest; + + if (handlerAgentDataUpdateRequest != null) + { + handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID); + } + + return true; + } + + private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack) + { + UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest; + if (handlerUserInfoRequest != null) + { + handlerUserInfoRequest(this); + } + else + { + SendUserInfoReply(false, true, ""); + } + return true; + + } + + private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack) + { + UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (updateUserInfo.AgentData.SessionID != SessionId || + updateUserInfo.AgentData.AgentID != AgentId) + return true; + } + #endregion + + UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo; + if (handlerUpdateUserInfo != null) + { + bool visible = true; + string DirectoryVisibility = + Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility); + if (DirectoryVisibility == "hidden") + visible = false; + + handlerUpdateUserInfo( + updateUserInfo.UserData.IMViaEMail, + visible, this); + } + return true; + } + + private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack) + { + SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId || + avSetStartLocationRequestPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId) + { + TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest; + if (handlerSetStartLocationRequest != null) + { + handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos, + avSetStartLocationRequestPacket.StartLocationData.LocationLookAt, + avSetStartLocationRequestPacket.StartLocationData.LocationID); + } + } + return true; + } + + private bool HandleAgentThrottle(IClientAPI sender, Packet Pack) + { + AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (atpack.AgentData.SessionID != SessionId || + atpack.AgentData.AgentID != AgentId) + return true; + } + #endregion + + m_udpClient.SetThrottles(atpack.Throttle.Throttles); + return true; + } + + private bool HandleAgentPause(IClientAPI sender, Packet Pack) + { + m_udpClient.IsPaused = true; + return true; + } + + private bool HandleAgentResume(IClientAPI sender, Packet Pack) + { + m_udpClient.IsPaused = false; + SendStartPingCheck(m_udpClient.CurrentPingSequence++); + return true; + } + + private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack) + { + ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls; + if (handlerForceReleaseControls != null) + { + handlerForceReleaseControls(this, AgentId); + } + return true; + } + + #endregion Scene/Avatar + + #region Objects/m_sceneObjects + + private bool HandleObjectLink(IClientAPI sender, Packet Pack) + { + ObjectLinkPacket link = (ObjectLinkPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (link.AgentData.SessionID != SessionId || + link.AgentData.AgentID != AgentId) + return true; + } + #endregion + + uint parentprimid = 0; + List childrenprims = new List(); + if (link.ObjectData.Length > 1) + { + parentprimid = link.ObjectData[0].ObjectLocalID; + + for (int i = 1; i < link.ObjectData.Length; i++) + { + childrenprims.Add(link.ObjectData[i].ObjectLocalID); + } + } + LinkObjects handlerLinkObjects = OnLinkObjects; + if (handlerLinkObjects != null) + { + handlerLinkObjects(this, parentprimid, childrenprims); + } + return true; + } + + private bool HandleObjectDelink(IClientAPI sender, Packet Pack) + { + ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (delink.AgentData.SessionID != SessionId || + delink.AgentData.AgentID != AgentId) + return true; + } + #endregion + + // It appears the prim at index 0 is not always the root prim (for + // instance, when one prim of a link set has been edited independently + // of the others). Therefore, we'll pass all the ids onto the delink + // method for it to decide which is the root. + List prims = new List(); + for (int i = 0; i < delink.ObjectData.Length; i++) + { + prims.Add(delink.ObjectData[i].ObjectLocalID); + } + DelinkObjects handlerDelinkObjects = OnDelinkObjects; + if (handlerDelinkObjects != null) + { + handlerDelinkObjects(prims); + } + + return true; + } + + private bool HandleObjectAdd(IClientAPI sender, Packet Pack) + { + if (OnAddPrim != null) + { + ObjectAddPacket addPacket = (ObjectAddPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (addPacket.AgentData.SessionID != SessionId || + addPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); + // m_log.Info("[REZData]: " + addPacket.ToString()); + //BypassRaycast: 1 + //RayStart: <69.79469, 158.2652, 98.40343> + //RayEnd: <61.97724, 141.995, 92.58341> + //RayTargetID: 00000000-0000-0000-0000-000000000000 + + //Check to see if adding the prim is allowed; useful for any module wanting to restrict the + //object from rezing initially + + AddNewPrim handlerAddPrim = OnAddPrim; + if (handlerAddPrim != null) + handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection); + } + return true; + } + + private bool HandleObjectShape(IClientAPI sender, Packet Pack) + { + ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (shapePacket.AgentData.SessionID != SessionId || + shapePacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + UpdateShape handlerUpdatePrimShape = null; + for (int i = 0; i < shapePacket.ObjectData.Length; i++) + { + handlerUpdatePrimShape = OnUpdatePrimShape; + if (handlerUpdatePrimShape != null) + { + UpdateShapeArgs shapeData = new UpdateShapeArgs(); + shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID; + shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin; + shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve; + shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd; + shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset; + shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions; + shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX; + shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY; + shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX; + shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY; + shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew; + shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX; + shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY; + shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist; + shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin; + shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin; + shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve; + shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd; + shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow; + + handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID, + shapeData); + } + } + return true; + } + + private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack) + { + ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (extraPar.AgentData.SessionID != SessionId || + extraPar.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams; + if (handlerUpdateExtraParams != null) + { + for (int i = 0; i < extraPar.ObjectData.Length; i++) + { + handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID, + extraPar.ObjectData[i].ParamType, + extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData); + } + } + return true; + } + + private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack) + { + ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dupe.AgentData.SessionID != SessionId || + dupe.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; + + ObjectDuplicate handlerObjectDuplicate = null; + + for (int i = 0; i < dupe.ObjectData.Length; i++) + { + handlerObjectDuplicate = OnObjectDuplicate; + if (handlerObjectDuplicate != null) + { + handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, + dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, + AgentandGroupData.GroupID); + } + } + + return true; + } + + private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack) + { + RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (incomingRequest.AgentData.SessionID != SessionId || + incomingRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectRequest handlerObjectRequest = null; + + for (int i = 0; i < incomingRequest.ObjectData.Length; i++) + { + handlerObjectRequest = OnObjectRequest; + if (handlerObjectRequest != null) + { + handlerObjectRequest(incomingRequest.ObjectData[i].ID, this); + } + } + return true; + } + + private bool HandleObjectSelect(IClientAPI sender, Packet Pack) + { + ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (incomingselect.AgentData.SessionID != SessionId || + incomingselect.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectSelect handlerObjectSelect = null; + + for (int i = 0; i < incomingselect.ObjectData.Length; i++) + { + handlerObjectSelect = OnObjectSelect; + if (handlerObjectSelect != null) + { + handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); + } + } + return true; + } + + private bool HandleObjectDeselect(IClientAPI sender, Packet Pack) + { + ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (incomingdeselect.AgentData.SessionID != SessionId || + incomingdeselect.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectDeselect handlerObjectDeselect = null; + + for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) + { + handlerObjectDeselect = OnObjectDeselect; + if (handlerObjectDeselect != null) + { + OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); + } + } + return true; + } + + private bool HandleObjectPosition(IClientAPI sender, Packet Pack) + { + // DEPRECATED: but till libsecondlife removes it, people will use it + ObjectPositionPacket position = (ObjectPositionPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (position.AgentData.SessionID != SessionId || + position.AgentData.AgentID != AgentId) + return true; + } + #endregion + + + for (int i = 0; i < position.ObjectData.Length; i++) + { + UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition; + if (handlerUpdateVector != null) + handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this); + } + + return true; + } + + private bool HandleObjectScale(IClientAPI sender, Packet Pack) + { + // DEPRECATED: but till libsecondlife removes it, people will use it + ObjectScalePacket scale = (ObjectScalePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (scale.AgentData.SessionID != SessionId || + scale.AgentData.AgentID != AgentId) + return true; + } + #endregion + + for (int i = 0; i < scale.ObjectData.Length; i++) + { + UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; + if (handlerUpdatePrimGroupScale != null) + handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this); + } + + return true; + } + + private bool HandleObjectRotation(IClientAPI sender, Packet Pack) + { + // DEPRECATED: but till libsecondlife removes it, people will use it + ObjectRotationPacket rotation = (ObjectRotationPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (rotation.AgentData.SessionID != SessionId || + rotation.AgentData.AgentID != AgentId) + return true; + } + #endregion + + for (int i = 0; i < rotation.ObjectData.Length; i++) + { + UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; + if (handlerUpdatePrimRotation != null) + handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this); + } + + return true; + } + + private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack) + { + ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (flags.AgentData.SessionID != SessionId || + flags.AgentData.AgentID != AgentId) + return true; + } + #endregion + + UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags; + + if (handlerUpdatePrimFlags != null) + { + byte[] data = Pack.ToBytes(); + // 46,47,48 are special positions within the packet + // This may change so perhaps we need a better way + // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?) + bool UsePhysics = (data[46] != 0) ? true : false; + bool IsTemporary = (data[47] != 0) ? true : false; + bool IsPhantom = (data[48] != 0) ? true : false; + handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this); + } + return true; + } + + private bool HandleObjectImage(IClientAPI sender, Packet Pack) + { + ObjectImagePacket imagePack = (ObjectImagePacket)Pack; + + UpdatePrimTexture handlerUpdatePrimTexture = null; + for (int i = 0; i < imagePack.ObjectData.Length; i++) + { + handlerUpdatePrimTexture = OnUpdatePrimTexture; + if (handlerUpdatePrimTexture != null) + { + handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, + imagePack.ObjectData[i].TextureEntry, this); + } + } + return true; + } + + private bool HandleObjectGrab(IClientAPI sender, Packet Pack) + { + ObjectGrabPacket grab = (ObjectGrabPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (grab.AgentData.SessionID != SessionId || + grab.AgentData.AgentID != AgentId) + return true; + } + #endregion + + GrabObject handlerGrabObject = OnGrabObject; + + if (handlerGrabObject != null) + { + List touchArgs = new List(); + if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0)) + { + foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo) + { + SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs(); + arg.Binormal = surfaceInfo.Binormal; + arg.FaceIndex = surfaceInfo.FaceIndex; + arg.Normal = surfaceInfo.Normal; + arg.Position = surfaceInfo.Position; + arg.STCoord = surfaceInfo.STCoord; + arg.UVCoord = surfaceInfo.UVCoord; + touchArgs.Add(arg); + } + } + handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs); + } + return true; + } + + private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack) + { + ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (grabUpdate.AgentData.SessionID != SessionId || + grabUpdate.AgentData.AgentID != AgentId) + return true; + } + #endregion + + MoveObject handlerGrabUpdate = OnGrabUpdate; + + if (handlerGrabUpdate != null) + { + List touchArgs = new List(); + if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0)) + { + foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo) + { + SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs(); + arg.Binormal = surfaceInfo.Binormal; + arg.FaceIndex = surfaceInfo.FaceIndex; + arg.Normal = surfaceInfo.Normal; + arg.Position = surfaceInfo.Position; + arg.STCoord = surfaceInfo.STCoord; + arg.UVCoord = surfaceInfo.UVCoord; + touchArgs.Add(arg); + } + } + handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, + grabUpdate.ObjectData.GrabPosition, this, touchArgs); + } + return true; + } + + private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack) + { + ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (deGrab.AgentData.SessionID != SessionId || + deGrab.AgentData.AgentID != AgentId) + return true; + } + #endregion + + DeGrabObject handlerDeGrabObject = OnDeGrabObject; + if (handlerDeGrabObject != null) + { + List touchArgs = new List(); + if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0)) { - handlerAvatarNowWearing(this, wearingArgs); + foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo) + { + SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs(); + arg.Binormal = surfaceInfo.Binormal; + arg.FaceIndex = surfaceInfo.FaceIndex; + arg.Normal = surfaceInfo.Normal; + arg.Position = surfaceInfo.Position; + arg.STCoord = surfaceInfo.STCoord; + arg.UVCoord = surfaceInfo.UVCoord; + touchArgs.Add(arg); + } } + handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs); } return true; } - private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack) + private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack) { - RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; - if (handlerRezSingleAttachment != null) + //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet"); + ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) { - RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack; + if (spinStart.AgentData.SessionID != SessionId || + spinStart.AgentData.AgentID != AgentId) + return true; + } + #endregion - #region Packet Session and User Check - if (m_checkPackets) - { - if (rez.AgentData.SessionID != SessionId || - rez.AgentData.AgentID != AgentId) - return true; - } - #endregion + SpinStart handlerSpinStart = OnSpinStart; + if (handlerSpinStart != null) + { + handlerSpinStart(spinStart.ObjectData.ObjectID, this); + } + return true; + } - handlerRezSingleAttachment(this, rez.ObjectData.ItemID, - rez.ObjectData.AttachmentPt); + private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack) + { + //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet"); + ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (spinUpdate.AgentData.SessionID != SessionId || + spinUpdate.AgentData.AgentID != AgentId) + return true; } + #endregion + Vector3 axis; + float angle; + spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle); + //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle); + + SpinObject handlerSpinUpdate = OnSpinUpdate; + if (handlerSpinUpdate != null) + { + handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this); + } return true; } - private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack) + private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack) { - RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv; - if (handlerRezMultipleAttachments != null) + //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet"); + ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) { - RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack; - handlerRezMultipleAttachments(this, rez.HeaderData, - rez.ObjectData); + if (spinStop.AgentData.SessionID != SessionId || + spinStop.AgentData.AgentID != AgentId) + return true; } + #endregion + SpinStop handlerSpinStop = OnSpinStop; + if (handlerSpinStop != null) + { + handlerSpinStop(spinStop.ObjectData.ObjectID, this); + } return true; } - private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack) + private bool HandleObjectDescription(IClientAPI sender, Packet Pack) { - UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; - if (handlerDetachAttachmentIntoInv != null) + ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) { - DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; + if (objDes.AgentData.SessionID != SessionId || + objDes.AgentData.AgentID != AgentId) + return true; + } + #endregion - #region Packet Session and User Check - // UNSUPPORTED ON THIS PACKET - #endregion + GenericCall7 handlerObjectDescription = null; - UUID itemID = detachtoInv.ObjectData.ItemID; - // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID; + for (int i = 0; i < objDes.ObjectData.Length; i++) + { + handlerObjectDescription = OnObjectDescription; + if (handlerObjectDescription != null) + { + handlerObjectDescription(this, objDes.ObjectData[i].LocalID, + Util.FieldToString(objDes.ObjectData[i].Description)); + } + } + return true; + } - handlerDetachAttachmentIntoInv(itemID, this); + private bool HandleObjectName(IClientAPI sender, Packet Pack) + { + ObjectNamePacket objName = (ObjectNamePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (objName.AgentData.SessionID != SessionId || + objName.AgentData.AgentID != AgentId) + return true; + } + #endregion + + GenericCall7 handlerObjectName = null; + for (int i = 0; i < objName.ObjectData.Length; i++) + { + handlerObjectName = OnObjectName; + if (handlerObjectName != null) + { + handlerObjectName(this, objName.ObjectData[i].LocalID, + Util.FieldToString(objName.ObjectData[i].Name)); + } } return true; } - private bool HandleObjectAttach(IClientAPI sender, Packet Pack) + private bool HandleObjectPermissions(IClientAPI sender, Packet Pack) { - if (OnObjectAttach != null) + if (OnObjectPermissions != null) { - ObjectAttachPacket att = (ObjectAttachPacket)Pack; + ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (att.AgentData.SessionID != SessionId || - att.AgentData.AgentID != AgentId) + if (newobjPerms.AgentData.SessionID != SessionId || + newobjPerms.AgentData.AgentID != AgentId) return true; } #endregion - ObjectAttach handlerObjectAttach = OnObjectAttach; + UUID AgentID = newobjPerms.AgentData.AgentID; + UUID SessionID = newobjPerms.AgentData.SessionID; - if (handlerObjectAttach != null) + ObjectPermissions handlerObjectPermissions = null; + + for (int i = 0; i < newobjPerms.ObjectData.Length; i++) { - if (att.ObjectData.Length > 0) - { - handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation, false); - } + ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i]; + + byte field = permChanges.Field; + uint localID = permChanges.ObjectLocalID; + uint mask = permChanges.Mask; + byte set = permChanges.Set; + + handlerObjectPermissions = OnObjectPermissions; + + if (handlerObjectPermissions != null) + handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set); } } + + // Here's our data, + // PermField contains the field the info goes into + // PermField determines which mask we're changing + // + // chmask is the mask of the change + // setTF is whether we're adding it or taking it away + // + // objLocalID is the localID of the object. + + // 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. + return true; } - private bool HandleObjectDetach(IClientAPI sender, Packet Pack) + private bool HandleUndo(IClientAPI sender, Packet Pack) { - ObjectDetachPacket dett = (ObjectDetachPacket)Pack; + UndoPacket undoitem = (UndoPacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (dett.AgentData.SessionID != SessionId || - dett.AgentData.AgentID != AgentId) + if (undoitem.AgentData.SessionID != SessionId || + undoitem.AgentData.AgentID != AgentId) return true; } #endregion - for (int j = 0; j < dett.ObjectData.Length; j++) + if (undoitem.ObjectData.Length > 0) { - uint obj = dett.ObjectData[j].ObjectLocalID; - ObjectDeselect handlerObjectDetach = OnObjectDetach; - if (handlerObjectDetach != null) + for (int i = 0; i < undoitem.ObjectData.Length; i++) { - handlerObjectDetach(obj, this); - } + UUID objiD = undoitem.ObjectData[i].ObjectID; + AgentSit handlerOnUndo = OnUndo; + if (handlerOnUndo != null) + { + handlerOnUndo(this, objiD); + } + } } return true; } - private bool HandleObjectDrop(IClientAPI sender, Packet Pack) + private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack) { - ObjectDropPacket dropp = (ObjectDropPacket)Pack; + ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (dropp.AgentData.SessionID != SessionId || - dropp.AgentData.AgentID != AgentId) + if (dupeOnRay.AgentData.SessionID != SessionId || + dupeOnRay.AgentData.AgentID != AgentId) return true; } #endregion - for (int j = 0; j < dropp.ObjectData.Length; j++) + ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null; + + for (int i = 0; i < dupeOnRay.ObjectData.Length; i++) { - uint obj = dropp.ObjectData[j].ObjectLocalID; - ObjectDrop handlerObjectDrop = OnObjectDrop; - if (handlerObjectDrop != null) + handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay; + if (handlerObjectDuplicateOnRay != null) { - handlerObjectDrop(obj, this); + handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags, + dupeOnRay.AgentData.AgentID, dupeOnRay.AgentData.GroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd, + dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection, + dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates); } } + return true; } - private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack) + private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack) { - SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; + //This powers the little tooltip that appears when you move your mouse over an object + RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (run.AgentData.SessionID != SessionId || - run.AgentData.AgentID != AgentId) + if (packToolTip.AgentData.SessionID != SessionId || + packToolTip.AgentData.AgentID != AgentId) return true; } #endregion - SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun; - if (handlerSetAlwaysRun != null) - handlerSetAlwaysRun(this, run.AgentData.AlwaysRun); + RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; - return true; - } + RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily; - private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack) - { - GenericCall2 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; - if (handlerCompleteMovementToRegion != null) + if (handlerRequestObjectPropertiesFamily != null) { - handlerCompleteMovementToRegion(); + handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags, + packObjBlock.ObjectID); } - handlerCompleteMovementToRegion = null; return true; } - private bool HandleAgentAnimation(IClientAPI sender, Packet Pack) + private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack) { - AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; + //This lets us set objects to appear in search (stuff like DataSnapshot, etc) + ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack; + ObjectIncludeInSearch handlerObjectIncludeInSearch = null; #region Packet Session and User Check if (m_checkPackets) { - if (AgentAni.AgentData.SessionID != SessionId || - AgentAni.AgentData.AgentID != AgentId) + if (packInSearch.AgentData.SessionID != SessionId || + packInSearch.AgentData.AgentID != AgentId) return true; } #endregion - StartAnim handlerStartAnim = null; - StopAnim handlerStopAnim = null; - - for (int i = 0; i < AgentAni.AnimationList.Length; i++) + foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData) { - if (AgentAni.AnimationList[i].StartAnim) - { - handlerStartAnim = OnStartAnim; - if (handlerStartAnim != null) - { - handlerStartAnim(this, AgentAni.AnimationList[i].AnimID); - } - } - else + bool inSearch = objData.IncludeInSearch; + uint localID = objData.ObjectLocalID; + + handlerObjectIncludeInSearch = OnObjectIncludeInSearch; + + if (handlerObjectIncludeInSearch != null) { - handlerStopAnim = OnStopAnim; - if (handlerStopAnim != null) - { - handlerStopAnim(this, AgentAni.AnimationList[i].AnimID); - } + handlerObjectIncludeInSearch(this, inSearch, localID); } } return true; } - private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack) + private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack) { - if (OnAgentRequestSit != null) - { - AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; + ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack; - #region Packet Session and User Check - if (m_checkPackets) - { - if (agentRequestSit.AgentData.SessionID != SessionId || - agentRequestSit.AgentData.AgentID != AgentId) - return true; - } - #endregion + #region Packet Session and User Check + if (m_checkPackets) + { + if (scriptAnswer.AgentData.SessionID != SessionId || + scriptAnswer.AgentData.AgentID != AgentId) + return true; + } + #endregion - AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit; - if (handlerAgentRequestSit != null) - handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, - agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); + ScriptAnswer handlerScriptAnswer = OnScriptAnswer; + if (handlerScriptAnswer != null) + { + handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); } return true; } - private bool HandleAgentSit(IClientAPI sender, Packet Pack) + private bool HandleObjectClickAction(IClientAPI sender, Packet Pack) { - if (OnAgentSit != null) - { - AgentSitPacket agentSit = (AgentSitPacket)Pack; + ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack; - #region Packet Session and User Check - if (m_checkPackets) - { - if (agentSit.AgentData.SessionID != SessionId || - agentSit.AgentData.AgentID != AgentId) - return true; - } - #endregion + #region Packet Session and User Check + if (m_checkPackets) + { + if (ocpacket.AgentData.SessionID != SessionId || + ocpacket.AgentData.AgentID != AgentId) + return true; + } + #endregion - AgentSit handlerAgentSit = OnAgentSit; - if (handlerAgentSit != null) + GenericCall7 handlerObjectClickAction = OnObjectClickAction; + if (handlerObjectClickAction != null) + { + foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData) { - OnAgentSit(this, agentSit.AgentData.AgentID); + byte action = odata.ClickAction; + uint localID = odata.ObjectLocalID; + handlerObjectClickAction(this, localID, action.ToString()); } } return true; } - private bool HandleSoundTrigger(IClientAPI sender, Packet Pack) + private bool HandleObjectMaterial(IClientAPI sender, Packet Pack) { - SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack; + ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - // UNSUPPORTED ON THIS PACKET + if (ompacket.AgentData.SessionID != SessionId || + ompacket.AgentData.AgentID != AgentId) + return true; } #endregion - SoundTrigger handlerSoundTrigger = OnSoundTrigger; - if (handlerSoundTrigger != null) + GenericCall7 handlerObjectMaterial = OnObjectMaterial; + if (handlerObjectMaterial != null) { - handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID, - soundTriggerPacket.SoundData.ObjectID, soundTriggerPacket.SoundData.ParentID, - soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position, - soundTriggerPacket.SoundData.Handle); - + foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData) + { + byte material = odata.Material; + uint localID = odata.ObjectLocalID; + handlerObjectMaterial(this, localID, material.ToString()); + } } return true; } + #endregion Objects/m_sceneObjects #endregion Packet Handlers @@ -5755,9 +6832,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Main packet processing conditional switch (Pack.Type) { - #region Scene/Avatar #region CommentedOut /* + #region Scene/Avatar + + case PacketType.AvatarPropertiesRequest: AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; @@ -6419,8 +7498,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - */ - #endregion + case PacketType.AvatarPickerRequest: AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; @@ -6444,7 +7522,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Utils.BytesToString(querydata.Name)); } break; - + case PacketType.AgentDataUpdateRequest: AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack; @@ -6564,7 +7642,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion - #region Objects/m_sceneObjects + + //#region Objects/m_sceneObjects case PacketType.ObjectLink: ObjectLinkPacket link = (ObjectLinkPacket)Pack; @@ -6723,6 +7802,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.ObjectDuplicate: ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; @@ -6775,6 +7855,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.ObjectSelect: ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; @@ -6798,6 +7879,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.ObjectDeselect: ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; @@ -6821,6 +7903,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.ObjectPosition: // DEPRECATED: but till libsecondlife removes it, people will use it ObjectPositionPacket position = (ObjectPositionPacket)Pack; @@ -6843,6 +7926,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.ObjectScale: // DEPRECATED: but till libsecondlife removes it, people will use it ObjectScalePacket scale = (ObjectScalePacket)Pack; @@ -6864,6 +7948,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.ObjectRotation: // DEPRECATED: but till libsecondlife removes it, people will use it ObjectRotationPacket rotation = (ObjectRotationPacket)Pack; @@ -6885,6 +7970,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.ObjectFlagUpdate: ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; @@ -6925,6 +8011,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.ObjectGrab: ObjectGrabPacket grab = (ObjectGrabPacket)Pack; @@ -6959,6 +8046,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs); } break; + case PacketType.ObjectGrabUpdate: ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack; @@ -6994,6 +8082,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP grabUpdate.ObjectData.GrabPosition, this, touchArgs); } break; + case PacketType.ObjectDeGrab: ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack; @@ -7027,6 +8116,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs); } break; + case PacketType.ObjectSpinStart: //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet"); ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack; @@ -7070,6 +8160,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this); } break; + + case PacketType.ObjectSpinStop: //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet"); ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack; @@ -7114,6 +8206,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.ObjectName: ObjectNamePacket objName = (ObjectNamePacket)Pack; @@ -7137,6 +8230,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.ObjectPermissions: if (OnObjectPermissions != null) { @@ -7212,6 +8306,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.ObjectDuplicateOnRay: ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack; @@ -7239,6 +8334,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.RequestObjectPropertiesFamily: //This powers the little tooltip that appears when you move your mouse over an object RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; @@ -7263,6 +8359,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.ObjectIncludeInSearch: //This lets us set objects to appear in search (stuff like DataSnapshot, etc) ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack; @@ -7358,8 +8455,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + //#endregion + */ #endregion - #region Inventory/Asset/Other related packets case PacketType.RequestImage: -- cgit v1.1 From 3ebb528c794450e9fe45cb8fa39d1bcf71a34052 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Mon, 23 Nov 2009 11:44:22 -0500 Subject: * Resolves mantis 4390 http://opensimulator.org/mantis/view.php?id=4390 --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index e6b31ca..a0aba2a 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -835,7 +835,7 @@ namespace OpenSim.Region.Physics.OdePlugin // allows us to have different settings // We only need to test p2 for 'jump crouch purposes' - if (p2 is OdeCharacter) + if (p2 is OdeCharacter && p1.PhysicsActorType == (int)ActorTypes.Prim) { // Testing if the collision is at the feet of the avatar -- cgit v1.1 From 889ce36afa67c521f3e50e4833a894ffd39af490 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 23 Nov 2009 16:02:05 +0100 Subject: Added some [DebuggerNonUserCode] modifiers to functions that throw EventAbortException() to ease debugging on Visual Studio --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++++ OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs | 2 ++ OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | 2 ++ OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 5 ++++- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 50b2fb5..b549b5c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; //for [DebuggerNonUserCode] using System.Runtime.Remoting.Lifetime; using System.Text; using System.Threading; @@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api get { return m_ScriptEngine.World; } } + [DebuggerNonUserCode] public void state(string newState) { m_ScriptEngine.SetState(m_itemID, newState); @@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// Reset the named script. The script must be present /// in the same prim. /// + [DebuggerNonUserCode] public void llResetScript() { m_host.AddScriptLPS(1); @@ -3755,6 +3758,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(3000); } + [DebuggerNonUserCode] public void llRemoveInventory(string name) { m_host.AddScriptLPS(1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 7f67599..15e0408 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; //for [DebuggerNonUserCode] using System.Reflection; using System.Runtime.Remoting.Lifetime; using OpenSim.Region.ScriptEngine.Shared; @@ -131,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return (eventFlags); } + [DebuggerNonUserCode] public void ExecuteEvent(string state, string FunctionName, object[] args) { // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 121159c..a44abb0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs @@ -33,6 +33,7 @@ using System.Threading; using System.Reflection; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; //for [DebuggerNonUserCode] using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api.Runtime; @@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return (int)m_Executor.GetStateEventFlags(state); } + [DebuggerNonUserCode] public void ExecuteEvent(string state, string FunctionName, object[] args) { m_Executor.ExecuteEvent(state, FunctionName, args); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 41b5d49..ed3fdbe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -27,6 +27,7 @@ using System; using System.IO; +using System.Diagnostics; //for [DebuggerNonUserCode] using System.Runtime.Remoting; using System.Runtime.Remoting.Lifetime; using System.Threading; @@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance return true; } + [DebuggerNonUserCode] //Prevents the debugger from farting in this function public void SetState(string state) { if (state == State) @@ -555,7 +557,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance new DetectParams[0])); PostEvent(new EventParams("state_entry", new Object[0], new DetectParams[0])); - + throw new EventAbortException(); } @@ -824,6 +826,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance new Object[0], new DetectParams[0])); } + [DebuggerNonUserCode] //Stops the VS debugger from farting in this function public void ApiResetScript() { // bool running = Running; diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a60c0ba..8b94f28 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -30,6 +30,7 @@ using System.IO; using System.Threading; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; //for [DebuggerNonUserCode] using System.Security; using System.Security.Policy; using System.Reflection; @@ -1119,6 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine return false; } + [DebuggerNonUserCode] public void ApiResetScript(UUID itemID) { IScriptInstance instance = GetInstance(itemID); @@ -1170,6 +1172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine return UUID.Zero; } + [DebuggerNonUserCode] public void SetState(UUID itemID, string newState) { IScriptInstance instance = GetInstance(itemID); -- cgit v1.1 From 73c2162ff60850d96761aa07a1950dbbb2ec3e80 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 23 Nov 2009 19:51:40 +0100 Subject: Fixed nullrefs --- .../Region/CoreModules/Avatar/Chat/ChatModule.cs | 42 ++++++++++++---------- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 +++-- 2 files changed, 29 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index cd59bdb..5c24f03 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -266,25 +266,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat } // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); - - ((Scene)c.Scene).ForEachScenePresence( - delegate(ScenePresence presence) - { - // ignore chat from child agents - if (presence.IsChildAgent) return; - - IClientAPI client = presence.ControllingClient; - - // don't forward SayOwner chat from objects to - // non-owner agents - if ((c.Type == ChatTypeEnum.Owner) && - (null != c.SenderObject) && - (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) - return; - - client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, - (byte)sourceType, (byte)ChatAudibleLevel.Fully); - }); + if (c.Scene != null) + { + ((Scene)c.Scene).ForEachScenePresence + ( + delegate(ScenePresence presence) + { + // ignore chat from child agents + if (presence.IsChildAgent) return; + + IClientAPI client = presence.ControllingClient; + + // don't forward SayOwner chat from objects to + // non-owner agents + if ((c.Type == ChatTypeEnum.Owner) && + (null != c.SenderObject) && + (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) + return; + + client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, + (byte)sourceType, (byte)ChatAudibleLevel.Fully); + } + ); + } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 66fb918..83208e9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -840,8 +840,12 @@ namespace OpenSim.Region.Framework.Scenes public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) { SceneObjectPart part = GetSceneObjectPart(localID); - SceneObjectGroup group = part.ParentGroup; - if (group != null) + SceneObjectGroup group = null; + if (part != null) + { + group = part.ParentGroup; + } + if (part != null && group != null) { TaskInventoryItem item = group.GetInventoryItem(localID, itemID); if (item == null) -- cgit v1.1 From 247c66b3fe792692468ede6a516d85c6c9852d23 Mon Sep 17 00:00:00 2001 From: CasperW Date: Mon, 23 Nov 2009 20:25:53 +0100 Subject: Swap the locking of m_EventQueue and m_Script to ease locks on script inventory operations --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 234 +++++++++++---------- 1 file changed, 119 insertions(+), 115 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index ed3fdbe..063d50f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -640,154 +640,158 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance /// public object EventProcessor() { + + EventParams data = null; + + lock (m_EventQueue) + { lock (m_Script) { - EventParams data = null; - - lock (m_EventQueue) + data = (EventParams) m_EventQueue.Dequeue(); + if (data == null) // Shouldn't happen { - data = (EventParams) m_EventQueue.Dequeue(); - if (data == null) // Shouldn't happen + if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) { - if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) - { - m_CurrentResult = m_Engine.QueueEventHandler(this); - } - else - { - m_CurrentResult = null; - } - return 0; + m_CurrentResult = m_Engine.QueueEventHandler(this); } - - if (data.EventName == "timer") - m_TimerQueued = false; - if (data.EventName == "control") + else { - if (m_ControlEventsInQueue > 0) - m_ControlEventsInQueue--; + m_CurrentResult = null; } - if (data.EventName == "collision") - m_CollisionInQueue = false; + return 0; } - - //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); - m_DetectParams = data.DetectParams; - - if (data.EventName == "state") // Hardcoded state change + if (data.EventName == "timer") + m_TimerQueued = false; + if (data.EventName == "control") { - // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", - // m_PrimName, m_ScriptName, data.Params[0].ToString()); - m_State=data.Params[0].ToString(); - AsyncCommandManager.RemoveScript(m_Engine, - m_LocalID, m_ItemID); + if (m_ControlEventsInQueue > 0) + m_ControlEventsInQueue--; + } + if (data.EventName == "collision") + m_CollisionInQueue = false; + } + } + lock(m_Script) + { + + //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this); - SceneObjectPart part = m_Engine.World.GetSceneObjectPart( - m_LocalID); - if (part != null) - { - part.SetScriptEvents(m_ItemID, - (int)m_Script.GetStateEventFlags(State)); - } + m_DetectParams = data.DetectParams; + + if (data.EventName == "state") // Hardcoded state change + { +// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", +// m_PrimName, m_ScriptName, data.Params[0].ToString()); + m_State=data.Params[0].ToString(); + AsyncCommandManager.RemoveScript(m_Engine, + m_LocalID, m_ItemID); + + SceneObjectPart part = m_Engine.World.GetSceneObjectPart( + m_LocalID); + if (part != null) + { + part.SetScriptEvents(m_ItemID, + (int)m_Script.GetStateEventFlags(State)); } - else + } + else + { + if (m_Engine.World.PipeEventsForScript(m_LocalID) || + data.EventName == "control") // Don't freeze avies! { - if (m_Engine.World.PipeEventsForScript(m_LocalID) || - data.EventName == "control") // Don't freeze avies! - { - SceneObjectPart part = m_Engine.World.GetSceneObjectPart( - m_LocalID); - // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", - // m_PrimName, m_ScriptName, data.EventName, m_State); + SceneObjectPart part = m_Engine.World.GetSceneObjectPart( + m_LocalID); + // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", + // m_PrimName, m_ScriptName, data.EventName, m_State); - try - { - m_CurrentEvent = data.EventName; - m_EventStart = DateTime.Now; - m_InEvent = true; + try + { + m_CurrentEvent = data.EventName; + m_EventStart = DateTime.Now; + m_InEvent = true; - m_Script.ExecuteEvent(State, data.EventName, data.Params); + m_Script.ExecuteEvent(State, data.EventName, data.Params); - m_InEvent = false; - m_CurrentEvent = String.Empty; + m_InEvent = false; + m_CurrentEvent = String.Empty; - if (m_SaveState) - { - // This will be the very first event we deliver - // (state_entry) in default state - // + if (m_SaveState) + { + // This will be the very first event we deliver + // (state_entry) in default state + // - SaveState(m_Assembly); + SaveState(m_Assembly); - m_SaveState = false; - } + m_SaveState = false; } - catch (Exception e) - { - // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); - m_InEvent = false; - m_CurrentEvent = String.Empty; + } + catch (Exception e) + { + // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); + m_InEvent = false; + m_CurrentEvent = String.Empty; - if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) - { - try - { - // DISPLAY ERROR INWORLD - string text = FormatException(e); - - if (text.Length > 1000) - text = text.Substring(0, 1000); - m_Engine.World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - part.AbsolutePosition, - part.Name, part.UUID, false); - } - catch (Exception) - { - } - // catch (Exception e2) // LEGIT: User Scripting - // { - // m_log.Error("[SCRIPT]: "+ - // "Error displaying error in-world: " + - // e2.ToString()); - // m_log.Error("[SCRIPT]: " + - // "Errormessage: Error compiling script:\r\n" + - // e.ToString()); - // } - } - else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) + if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) + { + try { - m_InSelfDelete = true; - if (part != null && part.ParentGroup != null) - m_Engine.World.DeleteSceneObject(part.ParentGroup, false); + // DISPLAY ERROR INWORLD + string text = FormatException(e); + + if (text.Length > 1000) + text = text.Substring(0, 1000); + m_Engine.World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.DebugChannel, 2147483647, + part.AbsolutePosition, + part.Name, part.UUID, false); } - else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) + catch (Exception) { - m_InSelfDelete = true; - if (part != null && part.ParentGroup != null) - part.Inventory.RemoveInventoryItem(m_ItemID); } + // catch (Exception e2) // LEGIT: User Scripting + // { + // m_log.Error("[SCRIPT]: "+ + // "Error displaying error in-world: " + + // e2.ToString()); + // m_log.Error("[SCRIPT]: " + + // "Errormessage: Error compiling script:\r\n" + + // e.ToString()); + // } + } + else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) + { + m_InSelfDelete = true; + if (part != null && part.ParentGroup != null) + m_Engine.World.DeleteSceneObject(part.ParentGroup, false); + } + else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException)) + { + m_InSelfDelete = true; + if (part != null && part.ParentGroup != null) + part.Inventory.RemoveInventoryItem(m_ItemID); } } } + } - lock (m_EventQueue) + lock (m_EventQueue) + { + if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) { - if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) - { - m_CurrentResult = m_Engine.QueueEventHandler(this); - } - else - { - m_CurrentResult = null; - } + m_CurrentResult = m_Engine.QueueEventHandler(this); + } + else + { + m_CurrentResult = null; } + } - m_DetectParams = null; + m_DetectParams = null; - return 0; - } + return 0; + } } public int EventTime() -- cgit v1.1 From 3bfbd2952d948f4d451ec74a618587e60faf1cca Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Mon, 23 Nov 2009 20:19:00 -0500 Subject: * Moved 60 more packet handlers to Packet Handler Delegates. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 2076 +++++++++++++++++++- 1 file changed, 2055 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 7f7b820..222fb1b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4363,11 +4363,71 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes); AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction); AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial); + AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage); + AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest); + AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest); + AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer); + AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket); + AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket); + AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer); + AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder); + AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder); + AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder); + AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem); + AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory); + AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents); + AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents); + AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem); + AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem); + AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem); + AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem); + AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder); + AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects); + AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory); + AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory); + AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory); + AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory); + AddLocalPacketHandler(PacketType.RezScript, HandleRezScript); + AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest); + AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest); + AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest); + AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest); + AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); + AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest); + AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest); + AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest); + AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest); + AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate); + AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest); + AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide); + AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin); + AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate); + AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects); + AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest); + AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner); + AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease); + AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim); + AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects); + AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime); + AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest); + AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest); + AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage); + AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo); + AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest); + AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers); + AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser); + AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest); + AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest); + AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice); + AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo); + AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy); + AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning); + AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning); + AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset); //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); - } @@ -6338,6 +6398,1943 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Objects/m_sceneObjects + #region Inventory/Asset/Other related packets + + private bool HandleRequestImage(IClientAPI sender, Packet Pack) + { + RequestImagePacket imageRequest = (RequestImagePacket)Pack; + //m_log.Debug("image request: " + Pack.ToString()); + + #region Packet Session and User Check + if (m_checkPackets) + { + if (imageRequest.AgentData.SessionID != SessionId || + imageRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + //handlerTextureRequest = null; + for (int i = 0; i < imageRequest.RequestImage.Length; i++) + { + if (OnRequestTexture != null) + { + TextureRequestArgs args = new TextureRequestArgs(); + + RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i]; + + args.RequestedAssetID = block.Image; + args.DiscardLevel = block.DiscardLevel; + args.PacketNumber = block.Packet; + args.Priority = block.DownloadPriority; + args.requestSequence = imageRequest.Header.Sequence; + + // NOTE: This is not a built in part of the LLUDP protocol, but we double the + // priority of avatar textures to get avatars rezzing in faster than the + // surrounding scene + if ((ImageType)block.Type == ImageType.Baked) + args.Priority *= 2.0f; + + //handlerTextureRequest = OnRequestTexture; + + //if (handlerTextureRequest != null) + //OnRequestTexture(this, args); + + // in the end, we null this, so we have to check if it's null + if (m_imageManager != null) + { + m_imageManager.EnqueueReq(args); + } + } + } + return true; + } + + private bool HandleTransferRequest(IClientAPI sender, Packet Pack) + { + //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); + + TransferRequestPacket transfer = (TransferRequestPacket)Pack; + //m_log.Debug("Transfer Request: " + transfer.ToString()); + // Validate inventory transfers + // Has to be done here, because AssetCache can't do it + // + UUID taskID = UUID.Zero; + if (transfer.TransferInfo.SourceType == 3) + { + taskID = new UUID(transfer.TransferInfo.Params, 48); + UUID itemID = new UUID(transfer.TransferInfo.Params, 64); + UUID requestID = new UUID(transfer.TransferInfo.Params, 80); + if (!(((Scene)m_scene).Permissions.BypassPermissions())) + { + if (taskID != UUID.Zero) // Prim + { + SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID); + if (part == null) + return true; + + if (part.OwnerID != AgentId) + return true; + + if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) + return true; + + TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID); + if (ti == null) + return true; + + if (ti.OwnerID != AgentId) + return true; + + if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) + return true; + + if (ti.AssetID != requestID) + return true; + } + else // Agent + { + IInventoryService invService = m_scene.RequestModuleInterface(); + InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, AgentId); + assetRequestItem = invService.GetItem(assetRequestItem); + if (assetRequestItem == null) + { + assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); + if (assetRequestItem == null) + return true; + } + + // At this point, we need to apply perms + // only to notecards and scripts. All + // other asset types are always available + // + if (assetRequestItem.AssetType == 10) + { + if (!((Scene)m_scene).Permissions.CanViewScript(itemID, UUID.Zero, AgentId)) + { + SendAgentAlertMessage("Insufficient permissions to view script", false); + return true; + } + } + else if (assetRequestItem.AssetType == 7) + { + if (!((Scene)m_scene).Permissions.CanViewNotecard(itemID, UUID.Zero, AgentId)) + { + SendAgentAlertMessage("Insufficient permissions to view notecard", false); + return true; + } + } + + if (assetRequestItem.AssetID != requestID) + return true; + } + } + } + + //m_assetCache.AddAssetRequest(this, transfer); + + MakeAssetRequest(transfer, taskID); + + /* RequestAsset = OnRequestAsset; + if (RequestAsset != null) + { + RequestAsset(this, transfer); + }*/ + return true; + } + + private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack) + { + AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; + + + // m_log.Debug("upload request " + request.ToString()); + // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); + UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); + + UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest; + + if (handlerAssetUploadRequest != null) + { + handlerAssetUploadRequest(this, temp, + request.AssetBlock.TransactionID, request.AssetBlock.Type, + request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, + request.AssetBlock.Tempfile); + } + return true; + } + + private bool HandleRequestXfer(IClientAPI sender, Packet Pack) + { + RequestXferPacket xferReq = (RequestXferPacket)Pack; + + RequestXfer handlerRequestXfer = OnRequestXfer; + + if (handlerRequestXfer != null) + { + handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); + } + return true; + } + + private bool HandleSendXferPacket(IClientAPI sender, Packet Pack) + { + SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; + + XferReceive handlerXferReceive = OnXferReceive; + if (handlerXferReceive != null) + { + handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); + } + return true; + } + + private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack) + { + ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; + + ConfirmXfer handlerConfirmXfer = OnConfirmXfer; + if (handlerConfirmXfer != null) + { + handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); + } + return true; + } + + private bool HandleAbortXfer(IClientAPI sender, Packet Pack) + { + AbortXferPacket abortXfer = (AbortXferPacket)Pack; + AbortXfer handlerAbortXfer = OnAbortXfer; + if (handlerAbortXfer != null) + { + handlerAbortXfer(this, abortXfer.XferID.ID); + } + + return true; + } + + private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack) + { + CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (invFolder.AgentData.SessionID != SessionId || + invFolder.AgentData.AgentID != AgentId) + return true; + } + #endregion + + CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder; + if (handlerCreateInventoryFolder != null) + { + handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID, + (ushort)invFolder.FolderData.Type, + Util.FieldToString(invFolder.FolderData.Name), + invFolder.FolderData.ParentID); + } + return true; + } + + private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack) + { + if (OnUpdateInventoryFolder != null) + { + UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (invFolderx.AgentData.SessionID != SessionId || + invFolderx.AgentData.AgentID != AgentId) + return true; + } + #endregion + + UpdateInventoryFolder handlerUpdateInventoryFolder = null; + + for (int i = 0; i < invFolderx.FolderData.Length; i++) + { + handlerUpdateInventoryFolder = OnUpdateInventoryFolder; + if (handlerUpdateInventoryFolder != null) + { + OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID, + (ushort)invFolderx.FolderData[i].Type, + Util.FieldToString(invFolderx.FolderData[i].Name), + invFolderx.FolderData[i].ParentID); + } + } + } + return true; + } + + private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack) + { + if (OnMoveInventoryFolder != null) + { + MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (invFoldery.AgentData.SessionID != SessionId || + invFoldery.AgentData.AgentID != AgentId) + return true; + } + #endregion + + MoveInventoryFolder handlerMoveInventoryFolder = null; + + for (int i = 0; i < invFoldery.InventoryData.Length; i++) + { + handlerMoveInventoryFolder = OnMoveInventoryFolder; + if (handlerMoveInventoryFolder != null) + { + OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID, + invFoldery.InventoryData[i].ParentID); + } + } + } + return true; + } + + private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack) + { + CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (createItem.AgentData.SessionID != SessionId || + createItem.AgentData.AgentID != AgentId) + return true; + } + #endregion + + CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem; + if (handlerCreateNewInventoryItem != null) + { + handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, + createItem.InventoryBlock.FolderID, + createItem.InventoryBlock.CallbackID, + Util.FieldToString(createItem.InventoryBlock.Description), + Util.FieldToString(createItem.InventoryBlock.Name), + createItem.InventoryBlock.InvType, + createItem.InventoryBlock.Type, + createItem.InventoryBlock.WearableType, + createItem.InventoryBlock.NextOwnerMask, + Util.UnixTimeSinceEpoch()); + } + return true; + } + + private bool HandleFetchInventory(IClientAPI sender, Packet Pack) + { + if (OnFetchInventory != null) + { + FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (FetchInventoryx.AgentData.SessionID != SessionId || + FetchInventoryx.AgentData.AgentID != AgentId) + return true; + } + #endregion + + FetchInventory handlerFetchInventory = null; + + for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++) + { + handlerFetchInventory = OnFetchInventory; + + if (handlerFetchInventory != null) + { + OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID, + FetchInventoryx.InventoryData[i].OwnerID); + } + } + } + return true; + } + + private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack) + { + FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (Fetch.AgentData.SessionID != SessionId || + Fetch.AgentData.AgentID != AgentId) + return true; + } + #endregion + + FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents; + if (handlerFetchInventoryDescendents != null) + { + handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, + Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, + Fetch.InventoryData.SortOrder); + } + return true; + } + + private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack) + { + PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (Purge.AgentData.SessionID != SessionId || + Purge.AgentData.AgentID != AgentId) + return true; + } + #endregion + + PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents; + if (handlerPurgeInventoryDescendents != null) + { + handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); + } + return true; + } + + private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack) + { + UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (inventoryItemUpdate.AgentData.SessionID != SessionId || + inventoryItemUpdate.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (OnUpdateInventoryItem != null) + { + UpdateInventoryItem handlerUpdateInventoryItem = null; + for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++) + { + handlerUpdateInventoryItem = OnUpdateInventoryItem; + + if (handlerUpdateInventoryItem != null) + { + InventoryItemBase itemUpd = new InventoryItemBase(); + itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID; + itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name); + itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description); + itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID; + itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned; + itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask; + itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask; + itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask; + itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate; + itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID; + itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType; + itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice; + itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType; + itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags; + + OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID, + inventoryItemUpdate.InventoryData[i].ItemID, + itemUpd); + } + } + } + return true; + } + + private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack) + { + CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (copyitem.AgentData.SessionID != SessionId || + copyitem.AgentData.AgentID != AgentId) + return true; + } + #endregion + + CopyInventoryItem handlerCopyInventoryItem = null; + if (OnCopyInventoryItem != null) + { + foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) + { + handlerCopyInventoryItem = OnCopyInventoryItem; + if (handlerCopyInventoryItem != null) + { + handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, + datablock.OldItemID, datablock.NewFolderID, + Util.FieldToString(datablock.NewName)); + } + } + } + return true; + } + + private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack) + { + MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (moveitem.AgentData.SessionID != SessionId || + moveitem.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (OnMoveInventoryItem != null) + { + MoveInventoryItem handlerMoveInventoryItem = null; + InventoryItemBase itm = null; + List items = new List(); + foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) + { + itm = new InventoryItemBase(datablock.ItemID, AgentId); + itm.Folder = datablock.FolderID; + itm.Name = Util.FieldToString(datablock.NewName); + // weird, comes out as empty string + //m_log.DebugFormat("[XXX] new name: {0}", itm.Name); + items.Add(itm); + } + handlerMoveInventoryItem = OnMoveInventoryItem; + if (handlerMoveInventoryItem != null) + { + handlerMoveInventoryItem(this, items); + } + } + return true; + } + + private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack) + { + RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (removeItem.AgentData.SessionID != SessionId || + removeItem.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (OnRemoveInventoryItem != null) + { + RemoveInventoryItem handlerRemoveInventoryItem = null; + List uuids = new List(); + foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) + { + uuids.Add(datablock.ItemID); + } + handlerRemoveInventoryItem = OnRemoveInventoryItem; + if (handlerRemoveInventoryItem != null) + { + handlerRemoveInventoryItem(this, uuids); + } + + } + return true; + } + + private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack) + { + RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (removeFolder.AgentData.SessionID != SessionId || + removeFolder.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (OnRemoveInventoryFolder != null) + { + RemoveInventoryFolder handlerRemoveInventoryFolder = null; + List uuids = new List(); + foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData) + { + uuids.Add(datablock.FolderID); + } + handlerRemoveInventoryFolder = OnRemoveInventoryFolder; + if (handlerRemoveInventoryFolder != null) + { + handlerRemoveInventoryFolder(this, uuids); + } + } + return true; + } + + private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack) + { + RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack; + #region Packet Session and User Check + if (m_checkPackets) + { + if (removeObject.AgentData.SessionID != SessionId || + removeObject.AgentData.AgentID != AgentId) + return true; + } + #endregion + if (OnRemoveInventoryFolder != null) + { + RemoveInventoryFolder handlerRemoveInventoryFolder = null; + List uuids = new List(); + foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData) + { + uuids.Add(datablock.FolderID); + } + handlerRemoveInventoryFolder = OnRemoveInventoryFolder; + if (handlerRemoveInventoryFolder != null) + { + handlerRemoveInventoryFolder(this, uuids); + } + } + + if (OnRemoveInventoryItem != null) + { + RemoveInventoryItem handlerRemoveInventoryItem = null; + List uuids = new List(); + foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData) + { + uuids.Add(datablock.ItemID); + } + handlerRemoveInventoryItem = OnRemoveInventoryItem; + if (handlerRemoveInventoryItem != null) + { + handlerRemoveInventoryItem(this, uuids); + } + } + return true; + } + + private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack) + { + RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (requesttask.AgentData.SessionID != SessionId || + requesttask.AgentData.AgentID != AgentId) + return true; + } + #endregion + + RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory; + if (handlerRequestTaskInventory != null) + { + handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID); + } + return true; + } + + private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack) + { + UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (updatetask.AgentData.SessionID != SessionId || + updatetask.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (OnUpdateTaskInventory != null) + { + if (updatetask.UpdateData.Key == 0) + { + UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory; + if (handlerUpdateTaskInventory != null) + { + TaskInventoryItem newTaskItem = new TaskInventoryItem(); + newTaskItem.ItemID = updatetask.InventoryData.ItemID; + newTaskItem.ParentID = updatetask.InventoryData.FolderID; + newTaskItem.CreatorID = updatetask.InventoryData.CreatorID; + newTaskItem.OwnerID = updatetask.InventoryData.OwnerID; + newTaskItem.GroupID = updatetask.InventoryData.GroupID; + newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask; + newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask; + newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask; + newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask; + newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask; + //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned; + newTaskItem.Type = updatetask.InventoryData.Type; + newTaskItem.InvType = updatetask.InventoryData.InvType; + newTaskItem.Flags = updatetask.InventoryData.Flags; + //newTaskItem.SaleType=updatetask.InventoryData.SaleType; + //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;; + newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name); + newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description); + newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate; + handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID, + newTaskItem, updatetask.UpdateData.LocalID); + } + } + } + + return true; + } + + private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack) + { + RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (removeTask.AgentData.SessionID != SessionId || + removeTask.AgentData.AgentID != AgentId) + return true; + } + #endregion + + RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem; + + if (handlerRemoveTaskItem != null) + { + handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); + } + + return true; + } + + private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack) + { + MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (moveTaskInventoryPacket.AgentData.SessionID != SessionId || + moveTaskInventoryPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem; + + if (handlerMoveTaskItem != null) + { + handlerMoveTaskItem( + this, moveTaskInventoryPacket.AgentData.FolderID, + moveTaskInventoryPacket.InventoryData.LocalID, + moveTaskInventoryPacket.InventoryData.ItemID); + } + + return true; + } + + private bool HandleRezScript(IClientAPI sender, Packet Pack) + { + //m_log.Debug(Pack.ToString()); + RezScriptPacket rezScriptx = (RezScriptPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (rezScriptx.AgentData.SessionID != SessionId || + rezScriptx.AgentData.AgentID != AgentId) + return true; + } + #endregion + + RezScript handlerRezScript = OnRezScript; + InventoryItemBase item = new InventoryItemBase(); + item.ID = rezScriptx.InventoryBlock.ItemID; + item.Folder = rezScriptx.InventoryBlock.FolderID; + item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString(); + item.Owner = rezScriptx.InventoryBlock.OwnerID; + item.BasePermissions = rezScriptx.InventoryBlock.BaseMask; + item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask; + item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask; + item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask; + item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask; + item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned; + item.GroupID = rezScriptx.InventoryBlock.GroupID; + item.AssetType = rezScriptx.InventoryBlock.Type; + item.InvType = rezScriptx.InventoryBlock.InvType; + item.Flags = rezScriptx.InventoryBlock.Flags; + item.SaleType = rezScriptx.InventoryBlock.SaleType; + item.SalePrice = rezScriptx.InventoryBlock.SalePrice; + item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name); + item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description); + item.CreationDate = rezScriptx.InventoryBlock.CreationDate; + + if (handlerRezScript != null) + { + handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID); + } + return true; + } + + private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack) + { + RequestMapLayer(); + return true; + } + + private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack) + { + MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (MapRequest.AgentData.SessionID != SessionId || + MapRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks; + if (handlerRequestMapBlocks != null) + { + handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, + MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags); + } + return true; + } + + private bool HandleMapNameRequest(IClientAPI sender, Packet Pack) + { + MapNameRequestPacket map = (MapNameRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (map.AgentData.SessionID != SessionId || + map.AgentData.AgentID != AgentId) + return true; + } + #endregion + + string mapName = Util.UTF8.GetString(map.NameData.Name, 0, + map.NameData.Name.Length - 1); + RequestMapName handlerMapNameRequest = OnMapNameRequest; + if (handlerMapNameRequest != null) + { + handlerMapNameRequest(this, mapName); + } + return true; + } + + private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack) + { + TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (tpReq.Info.SessionID != SessionId || + tpReq.Info.AgentID != AgentId) + return true; + } + #endregion + + UUID lmid = tpReq.Info.LandmarkID; + AssetLandmark lm; + if (lmid != UUID.Zero) + { + //AssetBase lma = m_assetCache.GetAsset(lmid, false); + AssetBase lma = m_assetService.Get(lmid.ToString()); + + if (lma == null) + { + // Failed to find landmark + TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); + tpCancel.Info.SessionID = tpReq.Info.SessionID; + tpCancel.Info.AgentID = tpReq.Info.AgentID; + OutPacket(tpCancel, ThrottleOutPacketType.Task); + } + + try + { + lm = new AssetLandmark(lma); + } + catch (NullReferenceException) + { + // asset not found generates null ref inside the assetlandmark constructor. + TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); + tpCancel.Info.SessionID = tpReq.Info.SessionID; + tpCancel.Info.AgentID = tpReq.Info.AgentID; + OutPacket(tpCancel, ThrottleOutPacketType.Task); + return true; + } + } + else + { + // Teleport home request + UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest; + if (handlerTeleportHomeRequest != null) + { + handlerTeleportHomeRequest(AgentId, this); + } + return true; + } + + TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; + if (handlerTeleportLandmarkRequest != null) + { + handlerTeleportLandmarkRequest(this, lm.RegionID, lm.Position); + } + else + { + //no event handler so cancel request + + + TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); + tpCancel.Info.AgentID = tpReq.Info.AgentID; + tpCancel.Info.SessionID = tpReq.Info.SessionID; + OutPacket(tpCancel, ThrottleOutPacketType.Task); + + } + return true; + } + + private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack) + { + TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; + // m_log.Debug(tpLocReq.ToString()); + + #region Packet Session and User Check + if (m_checkPackets) + { + if (tpLocReq.AgentData.SessionID != SessionId || + tpLocReq.AgentData.AgentID != AgentId) + return true; + } + #endregion + + TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest; + if (handlerTeleportLocationRequest != null) + { + handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, + tpLocReq.Info.LookAt, 16); + } + else + { + //no event handler so cancel request + TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); + tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; + tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; + OutPacket(tpCancel, ThrottleOutPacketType.Task); + } + return true; + } + + #endregion Inventory/Asset/Other related packets + + private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack) + { + UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; + + foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) + { + UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest; + if (handlerNameRequest != null) + { + handlerNameRequest(UUIDBlock.ID, this); + } + } + return true; + } + + #region Parcel related packets + + private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack) + { + RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack; + + RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest; + if (handlerRegionHandleRequest != null) + { + handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID); + } + return true; + } + + private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack) + { + ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (pirPack.AgentData.SessionID != SessionId || + pirPack.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest; + if (handlerParcelInfoRequest != null) + { + handlerParcelInfoRequest(this, pirPack.Data.ParcelID); + } + return true; + } + + private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack) + { + ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (requestPacket.AgentData.SessionID != SessionId || + requestPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest; + + if (handlerParcelAccessListRequest != null) + { + handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, + requestPacket.Data.Flags, requestPacket.Data.SequenceID, + requestPacket.Data.LocalID, this); + } + return true; + } + + private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack) + { + ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (updatePacket.AgentData.SessionID != SessionId || + updatePacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + List entries = new List(); + foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List) + { + ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + entry.AgentID = block.ID; + entry.Flags = (AccessList)block.Flags; + entry.Time = new DateTime(); + entries.Add(entry); + } + + ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest; + if (handlerParcelAccessListUpdateRequest != null) + { + handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, + updatePacket.AgentData.SessionID, updatePacket.Data.Flags, + updatePacket.Data.LocalID, entries, this); + } + return true; + } + + private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack) + { + ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (propertiesRequest.AgentData.SessionID != SessionId || + propertiesRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest; + if (handlerParcelPropertiesRequest != null) + { + handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), + (int)Math.Round(propertiesRequest.ParcelData.South), + (int)Math.Round(propertiesRequest.ParcelData.East), + (int)Math.Round(propertiesRequest.ParcelData.North), + propertiesRequest.ParcelData.SequenceID, + propertiesRequest.ParcelData.SnapSelection, this); + } + return true; + } + + private bool HandleParcelDivide(IClientAPI sender, Packet Pack) + { + ParcelDividePacket landDivide = (ParcelDividePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (landDivide.AgentData.SessionID != SessionId || + landDivide.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest; + if (handlerParcelDivideRequest != null) + { + handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West), + (int)Math.Round(landDivide.ParcelData.South), + (int)Math.Round(landDivide.ParcelData.East), + (int)Math.Round(landDivide.ParcelData.North), this); + } + return true; + } + + private bool HandleParcelJoin(IClientAPI sender, Packet Pack) + { + ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (landJoin.AgentData.SessionID != SessionId || + landJoin.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest; + + if (handlerParcelJoinRequest != null) + { + handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West), + (int)Math.Round(landJoin.ParcelData.South), + (int)Math.Round(landJoin.ParcelData.East), + (int)Math.Round(landJoin.ParcelData.North), this); + } + return true; + } + + private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack) + { + ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (parcelPropertiesPacket.AgentData.SessionID != SessionId || + parcelPropertiesPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest; + + if (handlerParcelPropertiesUpdateRequest != null) + { + LandUpdateArgs args = new LandUpdateArgs(); + + args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID; + args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category; + args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc); + args.GroupID = parcelPropertiesPacket.ParcelData.GroupID; + args.LandingType = parcelPropertiesPacket.ParcelData.LandingType; + args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale; + args.MediaID = parcelPropertiesPacket.ParcelData.MediaID; + args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL); + args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL); + args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name); + args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags; + args.PassHours = parcelPropertiesPacket.ParcelData.PassHours; + args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice; + args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice; + args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID; + args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation; + args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt; + handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this); + } + return true; + } + + private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack) + { + ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (selectPacket.AgentData.SessionID != SessionId || + selectPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + List returnIDs = new List(); + + foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in + selectPacket.ReturnIDs) + { + returnIDs.Add(rb.ReturnID); + } + + ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects; + + if (handlerParcelSelectObjects != null) + { + handlerParcelSelectObjects(selectPacket.ParcelData.LocalID, + Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this); + } + return true; + } + + private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack) + { + ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (reqPacket.AgentData.SessionID != SessionId || + reqPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest; + + if (handlerParcelObjectOwnerRequest != null) + { + handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); + } + return true; + + } + + private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack) + { + ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (godForceOwnerPacket.AgentData.SessionID != SessionId || + godForceOwnerPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner; + if (handlerParcelGodForceOwner != null) + { + handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this); + } + return true; + } + + private bool HandleParcelRelease(IClientAPI sender, Packet Pack) + { + ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (releasePacket.AgentData.SessionID != SessionId || + releasePacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest; + if (handlerParcelAbandonRequest != null) + { + handlerParcelAbandonRequest(releasePacket.Data.LocalID, this); + } + return true; + } + + private bool HandleParcelReclaim(IClientAPI sender, Packet Pack) + { + ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (reclaimPacket.AgentData.SessionID != SessionId || + reclaimPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelReclaim handlerParcelReclaim = OnParcelReclaim; + if (handlerParcelReclaim != null) + { + handlerParcelReclaim(reclaimPacket.Data.LocalID, this); + } + return true; + } + + private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack) + { + ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (parcelReturnObjects.AgentData.SessionID != SessionId || + parcelReturnObjects.AgentData.AgentID != AgentId) + return true; + } + #endregion + + UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length]; + for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++) + puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID; + + UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length]; + + for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++) + puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID; + + ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest; + if (handlerParcelReturnObjectsRequest != null) + { + handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this); + + } + return true; + } + + private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack) + { + ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId || + parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime; + if (handlerParcelSetOtherCleanTime != null) + { + handlerParcelSetOtherCleanTime(this, + parcelSetOtherCleanTimePacket.ParcelData.LocalID, + parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime); + } + return true; + } + + private bool HandleLandStatRequest(IClientAPI sender, Packet Pack) + { + LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (lsrp.AgentData.SessionID != SessionId || + lsrp.AgentData.AgentID != AgentId) + return true; + } + #endregion + + GodLandStatRequest handlerLandStatRequest = OnLandStatRequest; + if (handlerLandStatRequest != null) + { + handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this); + } + return true; + } + + private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack) + { + ParcelDwellRequestPacket dwellrq = + (ParcelDwellRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dwellrq.AgentData.SessionID != SessionId || + dwellrq.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest; + if (handlerParcelDwellRequest != null) + { + handlerParcelDwellRequest(dwellrq.Data.LocalID, this); + } + return true; + } + + #endregion Parcel related packets + + #region Estate Packets + + private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack) + { + EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; + //m_log.Debug(messagePacket.ToString()); + GodLandStatRequest handlerLandStatRequest; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (messagePacket.AgentData.SessionID != SessionId || + messagePacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + switch (Utils.BytesToString(messagePacket.MethodData.Method)) + { + case "getinfo": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice); + } + return true; + case "setregioninfo": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter), + convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter), + Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter))), + (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter)), + Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)), + convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter)); + } + return true; + // case "texturebase": + // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + // { + // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) + // { + // string s = Utils.BytesToString(block.Parameter); + // string[] splitField = s.Split(' '); + // if (splitField.Length == 2) + // { + // UUID tempUUID = new UUID(splitField[1]); + // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID); + // } + // } + // } + // break; + case "texturedetail": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) + { + string s = Utils.BytesToString(block.Parameter); + string[] splitField = s.Split(' '); + if (splitField.Length == 2) + { + Int16 corner = Convert.ToInt16(splitField[0]); + UUID textureUUID = new UUID(splitField[1]); + + OnSetEstateTerrainDetailTexture(this, corner, textureUUID); + } + } + } + + return true; + case "textureheights": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) + { + string s = Utils.BytesToString(block.Parameter); + string[] splitField = s.Split(' '); + if (splitField.Length == 3) + { + Int16 corner = Convert.ToInt16(splitField[0]); + float lowValue = (float)Convert.ToDecimal(splitField[1]); + float highValue = (float)Convert.ToDecimal(splitField[2]); + + OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue); + } + } + } + return true; + case "texturecommit": + OnCommitEstateTerrainTextureRequest(this); + break; + case "setregionterrain": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + if (messagePacket.ParamList.Length != 9) + { + m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length"); + } + else + { + try + { + string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float WaterHeight = (float)Convert.ToDecimal(tmp); + tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp); + tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter); + if (!tmp.Contains(".")) tmp += ".00"; + float TerrainLowerLimit = (float)Convert.ToDecimal(tmp); + bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter); + bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter); + float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter)); + bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter); + bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter); + float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter)); + + OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour); + + } + catch (Exception ex) + { + m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex); + } + } + } + + return true; + case "restart": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) + { + float timeSeconds; + Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds); + timeSeconds = (int)timeSeconds; + OnEstateRestartSimRequest(this, (int)timeSeconds); + + } + } + return true; + case "estatechangecovenantid": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList) + { + UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter)); + OnEstateChangeCovenantRequest(this, newCovenantID); + } + } + return true; + case "estateaccessdelta": // Estate access delta manages the banlist and allow list too. + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter))); + + } + return true; + case "simulatormessage": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + UUID invoice = messagePacket.MethodData.Invoice; + UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); + string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter); + string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter); + UUID sessionID = messagePacket.AgentData.SessionID; + OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message); + } + return true; + case "instantmessage": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + if (messagePacket.ParamList.Length < 5) + break; + UUID invoice = messagePacket.MethodData.Invoice; + UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); + string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter); + string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter); + UUID sessionID = messagePacket.AgentData.SessionID; + OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message); + } + return true; + case "setregiondebug": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + UUID invoice = messagePacket.MethodData.Invoice; + UUID SenderID = messagePacket.AgentData.AgentID; + bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter); + bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter); + bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter); + + OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics); + } + return true; + case "teleporthomeuser": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + UUID invoice = messagePacket.MethodData.Invoice; + UUID SenderID = messagePacket.AgentData.AgentID; + UUID Prey; + + UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey); + + OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey); + } + return true; + case "teleporthomeallusers": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + UUID invoice = messagePacket.MethodData.Invoice; + UUID SenderID = messagePacket.AgentData.AgentID; + OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID); + } + return true; + case "colliders": + handlerLandStatRequest = OnLandStatRequest; + if (handlerLandStatRequest != null) + { + handlerLandStatRequest(0, 1, 0, "", this); + } + return true; + case "scripts": + handlerLandStatRequest = OnLandStatRequest; + if (handlerLandStatRequest != null) + { + handlerLandStatRequest(0, 0, 0, "", this); + } + return true; + case "terrain": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + if (messagePacket.ParamList.Length > 0) + { + if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake") + { + BakeTerrain handlerBakeTerrain = OnBakeTerrain; + if (handlerBakeTerrain != null) + { + handlerBakeTerrain(this); + } + } + if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename") + { + if (messagePacket.ParamList.Length > 1) + { + RequestTerrain handlerRequestTerrain = OnRequestTerrain; + if (handlerRequestTerrain != null) + { + handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + } + } + } + if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename") + { + if (messagePacket.ParamList.Length > 1) + { + RequestTerrain handlerUploadTerrain = OnUploadTerrain; + if (handlerUploadTerrain != null) + { + handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + } + } + } + + } + + + } + return true; + + case "estatechangeinfo": + if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) + { + UUID invoice = messagePacket.MethodData.Invoice; + UUID SenderID = messagePacket.AgentData.AgentID; + UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); + UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); + + EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo; + if (handlerEstateChangeInfo != null) + { + handlerEstateChangeInfo(this, invoice, SenderID, param1, param2); + } + } + return true; + + default: + m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket); + return true; + } + + //int parcelID, uint reportType, uint requestflags, string filter + + //lsrp.RequestData.ParcelLocalID; + //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts + //lsrp.RequestData.RequestFlags; + //lsrp.RequestData.Filter; + + return true; + } + private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack) + { + RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (mPacket.SessionID != SessionId || + mPacket.AgentID != AgentId) + return true; + } + #endregion + + RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest; + if (handlerRegionInfoRequest != null) + { + handlerRegionInfoRequest(this); + } + return true; + } + private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack) + { + + //EstateCovenantRequestPacket.AgentDataBlock epack = + // ((EstateCovenantRequestPacket)Pack).AgentData; + + EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest; + if (handlerEstateCovenantRequest != null) + { + handlerEstateCovenantRequest(this); + } + return true; + + } + + #endregion Estate Packets + + #region GodPackets + + private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack) + { + RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack; + RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; + UUID token = rblock.Token; + + RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; + + RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers; + + if (handlerReqGodlikePowers != null) + { + handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this); + } + + return true; + } + private bool HandleGodKickUser(IClientAPI sender, Packet Pack) + { + GodKickUserPacket gkupack = (GodKickUserPacket)Pack; + + if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) + { + GodKickUser handlerGodKickUser = OnGodKickUser; + if (handlerGodKickUser != null) + { + handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, + gkupack.UserInfo.AgentID, (uint)0, gkupack.UserInfo.Reason); + } + } + else + { + SendAgentAlertMessage("Kick request denied", false); + } + //KickUserPacket kupack = new KickUserPacket(); + //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; + + //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID; + //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID; + + //kupack.TargetBlock.TargetIP = (uint)0; + //kupack.TargetBlock.TargetPort = (ushort)0; + //kupack.UserInfo.Reason = gkupack.UserInfo.Reason; + + //OutPacket(kupack, ThrottleOutPacketType.Task); + return true; + } + #endregion GodPackets + + #region Economy/Transaction Packets + + private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack) + { + MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (moneybalancerequestpacket.AgentData.SessionID != SessionId || + moneybalancerequestpacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest; + + if (handlerMoneyBalanceRequest != null) + { + handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID); + } + + return true; + } + private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack) + { + EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest; + if (handlerEconomoyDataRequest != null) + { + handlerEconomoyDataRequest(AgentId); + } + return true; + } + private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack) + { + RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; + + RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice; + if (handlerRequestPayPrice != null) + { + handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID); + } + return true; + } + private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack) + { + ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (objectSaleInfoPacket.AgentData.SessionID != SessionId || + objectSaleInfoPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo; + if (handlerObjectSaleInfo != null) + { + foreach (ObjectSaleInfoPacket.ObjectDataBlock d + in objectSaleInfoPacket.ObjectData) + { + handlerObjectSaleInfo(this, + objectSaleInfoPacket.AgentData.AgentID, + objectSaleInfoPacket.AgentData.SessionID, + d.LocalID, + d.SaleType, + d.SalePrice); + } + } + return true; + } + private bool HandleObjectBuy(IClientAPI sender, Packet Pack) + { + ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (objectBuyPacket.AgentData.SessionID != SessionId || + objectBuyPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectBuy handlerObjectBuy = OnObjectBuy; + + if (handlerObjectBuy != null) + { + foreach (ObjectBuyPacket.ObjectDataBlock d + in objectBuyPacket.ObjectData) + { + handlerObjectBuy(this, + objectBuyPacket.AgentData.AgentID, + objectBuyPacket.AgentData.SessionID, + objectBuyPacket.AgentData.GroupID, + objectBuyPacket.AgentData.CategoryID, + d.ObjectLocalID, + d.SaleType, + d.SalePrice); + } + } + return true; + } + + #endregion Economy/Transaction Packets + + #region Script Packets + private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack) + { + GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; + + GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning; + if (handlerGetScriptRunning != null) + { + handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); + } + return true; + } + private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack) + { + SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (setScriptRunning.AgentData.SessionID != SessionId || + setScriptRunning.AgentData.AgentID != AgentId) + return true; + } + #endregion + + SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning; + if (handlerSetScriptRunning != null) + { + handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); + } + return true; + } + + private bool HandleScriptReset(IClientAPI sender, Packet Pack) + { + ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (scriptResetPacket.AgentData.SessionID != SessionId || + scriptResetPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ScriptReset handlerScriptReset = OnScriptReset; + if (handlerScriptReset != null) + { + handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); + } + return true; + } + + #endregion Script Packets + + + #endregion Packet Handlers public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question) @@ -8456,9 +10453,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; //#endregion - */ - #endregion - #region Inventory/Asset/Other related packets + + //#region Inventory/Asset/Other related packets case PacketType.RequestImage: RequestImagePacket imageRequest = (RequestImagePacket)Pack; @@ -8592,12 +10588,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP MakeAssetRequest(transfer, taskID); - /* RequestAsset = OnRequestAsset; - if (RequestAsset != null) - { - RequestAsset(this, transfer); - }*/ + // RequestAsset = OnRequestAsset; + // if (RequestAsset != null) + // { + // RequestAsset(this, transfer); + // } + break; + case PacketType.AssetUploadRequest: AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; @@ -8616,6 +10614,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP request.AssetBlock.Tempfile); } break; + case PacketType.RequestXfer: RequestXferPacket xferReq = (RequestXferPacket)Pack; @@ -8626,6 +10625,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); } break; + case PacketType.SendXferPacket: SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; @@ -8635,6 +10635,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); } break; + case PacketType.ConfirmXferPacket: ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; @@ -8644,6 +10645,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); } break; + case PacketType.AbortXfer: AbortXferPacket abortXfer = (AbortXferPacket)Pack; AbortXfer handlerAbortXfer = OnAbortXfer; @@ -8653,6 +10655,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.CreateInventoryFolder: CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; @@ -8674,6 +10677,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP invFolder.FolderData.ParentID); } break; + case PacketType.UpdateInventoryFolder: if (OnUpdateInventoryFolder != null) { @@ -8703,6 +10707,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.MoveInventoryFolder: if (OnMoveInventoryFolder != null) { @@ -8730,6 +10735,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.CreateInventoryItem: CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; @@ -8757,6 +10763,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Util.UnixTimeSinceEpoch()); } break; + case PacketType.FetchInventory: if (OnFetchInventory != null) { @@ -8785,6 +10792,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.FetchInventoryDescendents: FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; @@ -8805,6 +10813,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Fetch.InventoryData.SortOrder); } break; + case PacketType.PurgeInventoryDescendents: PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack; @@ -8823,6 +10832,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); } break; + case PacketType.UpdateInventoryItem: UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack; @@ -8867,6 +10877,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.CopyInventoryItem: CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack; @@ -8894,6 +10905,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.MoveInventoryItem: MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack; @@ -8927,6 +10939,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.RemoveInventoryItem: RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack; @@ -8955,6 +10968,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.RemoveInventoryFolder: RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack; @@ -8982,6 +10996,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.RemoveInventoryObjects: RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack; #region Packet Session and User Check @@ -9022,6 +11037,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } break; + case PacketType.RequestTaskInventory: RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; @@ -9040,6 +11056,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID); } break; + case PacketType.UpdateTaskInventory: UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; @@ -9217,6 +11234,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerMapNameRequest(this, mapName); } break; + case PacketType.TeleportLandmarkRequest: TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; @@ -9287,7 +11305,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - + case PacketType.TeleportLocationRequest: TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; // m_log.Debug(tpLocReq.ToString()); @@ -9317,7 +11335,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #endregion + //#endregion case PacketType.UUIDNameRequest: UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; @@ -9332,7 +11350,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #region Parcel related packets + //#region Parcel related packets + case PacketType.RegionHandleRequest: RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack; @@ -9415,6 +11434,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP updatePacket.Data.LocalID, entries, this); } break; + case PacketType.ParcelPropertiesRequest: ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; @@ -9439,6 +11459,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP propertiesRequest.ParcelData.SnapSelection, this); } break; + case PacketType.ParcelDivide: ParcelDividePacket landDivide = (ParcelDividePacket)Pack; @@ -9460,6 +11481,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP (int)Math.Round(landDivide.ParcelData.North), this); } break; + case PacketType.ParcelJoin: ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack; @@ -9482,6 +11504,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP (int)Math.Round(landJoin.ParcelData.North), this); } break; + case PacketType.ParcelPropertiesUpdate: ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack; @@ -9520,6 +11543,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this); } break; + case PacketType.ParcelSelectObjects: ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; @@ -9548,6 +11572,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this); } break; + case PacketType.ParcelObjectOwnersRequest: //m_log.Debug(Pack.ToString()); ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; @@ -9568,6 +11593,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); } break; + case PacketType.ParcelGodForceOwner: ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack; @@ -9586,6 +11612,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this); } break; + case PacketType.ParcelRelease: ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack; @@ -9604,6 +11631,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerParcelAbandonRequest(releasePacket.Data.LocalID, this); } break; + case PacketType.ParcelReclaim: ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack; @@ -9622,6 +11650,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerParcelReclaim(reclaimPacket.Data.LocalID, this); } break; + case PacketType.ParcelReturnObjects: @@ -9713,9 +11742,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #endregion + //#endregion - #region Estate Packets + //#region Estate Packets case PacketType.EstateOwnerMessage: EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; @@ -10033,6 +12062,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerRegionInfoRequest(this); } break; + case PacketType.EstateCovenantRequest: //EstateCovenantRequestPacket.AgentDataBlock epack = @@ -10045,9 +12075,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #endregion + //#endregion - #region GodPackets + //#region GodPackets case PacketType.RequestGodlikePowers: RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack; @@ -10064,6 +12094,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.GodKickUser: GodKickUserPacket gkupack = (GodKickUserPacket)Pack; @@ -10093,9 +12124,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP //OutPacket(kupack, ThrottleOutPacketType.Task); break; - #endregion + //#endregion - #region Economy/Transaction Packets + //#region Economy/Transaction Packets case PacketType.MoneyBalanceRequest: MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack; @@ -10117,6 +12148,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.EconomyDataRequest: @@ -10126,6 +12158,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerEconomoyDataRequest(AgentId); } break; + case PacketType.RequestPayPrice: RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; @@ -10195,9 +12228,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #endregion + //#endregion - #region Script Packets + //#region Script Packets case PacketType.GetScriptRunning: GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; @@ -10247,8 +12280,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + //#endregion + */ #endregion - #region Gesture Managment case PacketType.ActivateGestures: -- cgit v1.1 From cf36420d19b1925b8d09c52a99a97830996a9f3e Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Mon, 23 Nov 2009 22:20:51 -0500 Subject: * This concludes the packet migrations from the big nasty switch into packet handler delegates. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 1813 ++++++++++++++++++-- 1 file changed, 1665 insertions(+), 148 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 222fb1b..07466e2 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4424,11 +4424,62 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning); AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning); AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset); - //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); - //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); - //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); - //AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); - + AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures); + AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures); + AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner); + AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV); + AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats); + AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest); + AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort); + AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest); + AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode); + AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth); + AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents); + AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery); + AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery); + AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery); + AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery); + AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery); + AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest); + AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard); + AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard); + AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard); + AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup); + AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest); + AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest); + AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest); + AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest); + AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest); + AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest); + AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo); + AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices); + AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate); + AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup); + AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest); + AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest); + AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate); + AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges); + AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest); + AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest); + AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest); + AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest); + AddLocalPacketHandler(PacketType.StartLure, HandleStartLure); + AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest); + AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest); + AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate); + AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete); + AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete); + AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete); + AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest); + AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest); + AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages); + AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete); + AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete); + AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate); + AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate); + AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate); + AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights); + AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery); } #region Packet Handlers @@ -7868,7 +7919,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; case "texturecommit": OnCommitEstateTerrainTextureRequest(this); - break; + return true; case "setregionterrain": if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) { @@ -7954,7 +8005,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) { if (messagePacket.ParamList.Length < 5) - break; + return true; UUID invoice = messagePacket.MethodData.Invoice; UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter); @@ -8081,259 +8132,1711 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; } - private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack) + private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack) + { + RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (mPacket.SessionID != SessionId || + mPacket.AgentID != AgentId) + return true; + } + #endregion + + RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest; + if (handlerRegionInfoRequest != null) + { + handlerRegionInfoRequest(this); + } + return true; + } + private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack) + { + + //EstateCovenantRequestPacket.AgentDataBlock epack = + // ((EstateCovenantRequestPacket)Pack).AgentData; + + EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest; + if (handlerEstateCovenantRequest != null) + { + handlerEstateCovenantRequest(this); + } + return true; + + } + + #endregion Estate Packets + + #region GodPackets + + private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack) + { + RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack; + RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; + UUID token = rblock.Token; + + RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; + + RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers; + + if (handlerReqGodlikePowers != null) + { + handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this); + } + + return true; + } + private bool HandleGodKickUser(IClientAPI sender, Packet Pack) + { + GodKickUserPacket gkupack = (GodKickUserPacket)Pack; + + if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) + { + GodKickUser handlerGodKickUser = OnGodKickUser; + if (handlerGodKickUser != null) + { + handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, + gkupack.UserInfo.AgentID, (uint)0, gkupack.UserInfo.Reason); + } + } + else + { + SendAgentAlertMessage("Kick request denied", false); + } + //KickUserPacket kupack = new KickUserPacket(); + //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; + + //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID; + //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID; + + //kupack.TargetBlock.TargetIP = (uint)0; + //kupack.TargetBlock.TargetPort = (ushort)0; + //kupack.UserInfo.Reason = gkupack.UserInfo.Reason; + + //OutPacket(kupack, ThrottleOutPacketType.Task); + return true; + } + #endregion GodPackets + + #region Economy/Transaction Packets + + private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack) + { + MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (moneybalancerequestpacket.AgentData.SessionID != SessionId || + moneybalancerequestpacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest; + + if (handlerMoneyBalanceRequest != null) + { + handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID); + } + + return true; + } + private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack) + { + EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest; + if (handlerEconomoyDataRequest != null) + { + handlerEconomoyDataRequest(AgentId); + } + return true; + } + private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack) + { + RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; + + RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice; + if (handlerRequestPayPrice != null) + { + handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID); + } + return true; + } + private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack) + { + ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (objectSaleInfoPacket.AgentData.SessionID != SessionId || + objectSaleInfoPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo; + if (handlerObjectSaleInfo != null) + { + foreach (ObjectSaleInfoPacket.ObjectDataBlock d + in objectSaleInfoPacket.ObjectData) + { + handlerObjectSaleInfo(this, + objectSaleInfoPacket.AgentData.AgentID, + objectSaleInfoPacket.AgentData.SessionID, + d.LocalID, + d.SaleType, + d.SalePrice); + } + } + return true; + } + private bool HandleObjectBuy(IClientAPI sender, Packet Pack) + { + ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (objectBuyPacket.AgentData.SessionID != SessionId || + objectBuyPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ObjectBuy handlerObjectBuy = OnObjectBuy; + + if (handlerObjectBuy != null) + { + foreach (ObjectBuyPacket.ObjectDataBlock d + in objectBuyPacket.ObjectData) + { + handlerObjectBuy(this, + objectBuyPacket.AgentData.AgentID, + objectBuyPacket.AgentData.SessionID, + objectBuyPacket.AgentData.GroupID, + objectBuyPacket.AgentData.CategoryID, + d.ObjectLocalID, + d.SaleType, + d.SalePrice); + } + } + return true; + } + + #endregion Economy/Transaction Packets + + #region Script Packets + private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack) + { + GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; + + GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning; + if (handlerGetScriptRunning != null) + { + handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); + } + return true; + } + private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack) + { + SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (setScriptRunning.AgentData.SessionID != SessionId || + setScriptRunning.AgentData.AgentID != AgentId) + return true; + } + #endregion + + SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning; + if (handlerSetScriptRunning != null) + { + handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); + } + return true; + } + + private bool HandleScriptReset(IClientAPI sender, Packet Pack) + { + ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (scriptResetPacket.AgentData.SessionID != SessionId || + scriptResetPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ScriptReset handlerScriptReset = OnScriptReset; + if (handlerScriptReset != null) + { + handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); + } + return true; + } + + #endregion Script Packets + + #region Gesture Managment + + private bool HandleActivateGestures(IClientAPI sender, Packet Pack) + { + ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (activateGesturePacket.AgentData.SessionID != SessionId || + activateGesturePacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + ActivateGesture handlerActivateGesture = OnActivateGesture; + if (handlerActivateGesture != null) + { + handlerActivateGesture(this, + activateGesturePacket.Data[0].AssetID, + activateGesturePacket.Data[0].ItemID); + } + else m_log.Error("Null pointer for activateGesture"); + + return true; + } + private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack) + { + DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (deactivateGesturePacket.AgentData.SessionID != SessionId || + deactivateGesturePacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture; + if (handlerDeactivateGesture != null) + { + handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID); + } + return true; + } + private bool HandleObjectOwner(IClientAPI sender, Packet Pack) + { + ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (objectOwnerPacket.AgentData.SessionID != SessionId || + objectOwnerPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + List localIDs = new List(); + + foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData) + localIDs.Add(d.ObjectLocalID); + + ObjectOwner handlerObjectOwner = OnObjectOwner; + if (handlerObjectOwner != null) + { + handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs); + } + return true; + } + + #endregion Gesture Managment + + private bool HandleAgentFOV(IClientAPI sender, Packet Pack) + { + AgentFOVPacket fovPacket = (AgentFOVPacket)Pack; + + if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter) + { + m_agentFOVCounter = fovPacket.FOVBlock.GenCounter; + AgentFOV handlerAgentFOV = OnAgentFOV; + if (handlerAgentFOV != null) + { + handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle); + } + } + return true; + } + + #region unimplemented handlers + + private bool HandleViewerStats(IClientAPI sender, Packet Pack) + { + // TODO: handle this packet + //m_log.Warn("[CLIENT]: unhandled ViewerStats packet"); + return true; + } + + private bool HandleMapItemRequest(IClientAPI sender, Packet Pack) + { + MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (mirpk.AgentData.SessionID != SessionId || + mirpk.AgentData.AgentID != AgentId) + return true; + } + #endregion + + //m_log.Debug(mirpk.ToString()); + MapItemRequest handlerMapItemRequest = OnMapItemRequest; + if (handlerMapItemRequest != null) + { + handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID, + mirpk.AgentData.Godlike, mirpk.RequestData.ItemType, + mirpk.RequestData.RegionHandle); + + } + return true; + } + + private bool HandleTransferAbort(IClientAPI sender, Packet Pack) + { + return true; + } + + private bool HandleMuteListRequest(IClientAPI sender, Packet Pack) + { + MuteListRequestPacket muteListRequest = + (MuteListRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (muteListRequest.AgentData.SessionID != SessionId || + muteListRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + MuteListRequest handlerMuteListRequest = OnMuteListRequest; + if (handlerMuteListRequest != null) + { + handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC); + } + else + { + SendUseCachedMuteList(); + } + return true; + } + + private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack) + { + return true; + } + + private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack) + { + return true; + } + + private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack) + { + return true; + } + + #endregion unimplemented handlers + + #region Dir handlers + + private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack) + { + DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack; + //m_log.Debug(dirPlacesQueryPacket.ToString()); + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dirPlacesQueryPacket.AgentData.SessionID != SessionId || + dirPlacesQueryPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery; + if (handlerDirPlacesQuery != null) + { + handlerDirPlacesQuery(this, + dirPlacesQueryPacket.QueryData.QueryID, + Utils.BytesToString( + dirPlacesQueryPacket.QueryData.QueryText), + (int)dirPlacesQueryPacket.QueryData.QueryFlags, + (int)dirPlacesQueryPacket.QueryData.Category, + Utils.BytesToString( + dirPlacesQueryPacket.QueryData.SimName), + dirPlacesQueryPacket.QueryData.QueryStart); + } + return true; + } + + private bool HandleDirFindQuery(IClientAPI sender, Packet Pack) + { + DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dirFindQueryPacket.AgentData.SessionID != SessionId || + dirFindQueryPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + DirFindQuery handlerDirFindQuery = OnDirFindQuery; + if (handlerDirFindQuery != null) + { + handlerDirFindQuery(this, + dirFindQueryPacket.QueryData.QueryID, + Utils.BytesToString( + dirFindQueryPacket.QueryData.QueryText), + dirFindQueryPacket.QueryData.QueryFlags, + dirFindQueryPacket.QueryData.QueryStart); + } + return true; + } + + private bool HandleDirLandQuery(IClientAPI sender, Packet Pack) + { + DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dirLandQueryPacket.AgentData.SessionID != SessionId || + dirLandQueryPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + DirLandQuery handlerDirLandQuery = OnDirLandQuery; + if (handlerDirLandQuery != null) + { + handlerDirLandQuery(this, + dirLandQueryPacket.QueryData.QueryID, + dirLandQueryPacket.QueryData.QueryFlags, + dirLandQueryPacket.QueryData.SearchType, + dirLandQueryPacket.QueryData.Price, + dirLandQueryPacket.QueryData.Area, + dirLandQueryPacket.QueryData.QueryStart); + } + return true; + } + + private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack) + { + DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dirPopularQueryPacket.AgentData.SessionID != SessionId || + dirPopularQueryPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery; + if (handlerDirPopularQuery != null) + { + handlerDirPopularQuery(this, + dirPopularQueryPacket.QueryData.QueryID, + dirPopularQueryPacket.QueryData.QueryFlags); + } + return true; + } + + private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack) + { + DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId || + dirClassifiedQueryPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery; + if (handlerDirClassifiedQuery != null) + { + handlerDirClassifiedQuery(this, + dirClassifiedQueryPacket.QueryData.QueryID, + Utils.BytesToString( + dirClassifiedQueryPacket.QueryData.QueryText), + dirClassifiedQueryPacket.QueryData.QueryFlags, + dirClassifiedQueryPacket.QueryData.Category, + dirClassifiedQueryPacket.QueryData.QueryStart); + } + return true; + } + + private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack) + { + EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (eventInfoRequestPacket.AgentData.SessionID != SessionId || + eventInfoRequestPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (OnEventInfoRequest != null) + { + OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID); + } + return true; + } + + #endregion + + #region Calling Card + + private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack) + { + OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (offerCallingCardPacket.AgentData.SessionID != SessionId || + offerCallingCardPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (OnOfferCallingCard != null) + { + OnOfferCallingCard(this, + offerCallingCardPacket.AgentBlock.DestID, + offerCallingCardPacket.AgentBlock.TransactionID); + } + return true; + } + + private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack) + { + AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (acceptCallingCardPacket.AgentData.SessionID != SessionId || + acceptCallingCardPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should + // contain exactly one entry + if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0) + { + OnAcceptCallingCard(this, + acceptCallingCardPacket.TransactionBlock.TransactionID, + acceptCallingCardPacket.FolderData[0].FolderID); + } + return true; + } + + private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack) + { + DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (declineCallingCardPacket.AgentData.SessionID != SessionId || + declineCallingCardPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (OnDeclineCallingCard != null) + { + OnDeclineCallingCard(this, + declineCallingCardPacket.TransactionBlock.TransactionID); + } + return true; + } + + #endregion Calling Card + + #region Groups + + private bool HandleActivateGroup(IClientAPI sender, Packet Pack) + { + ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (activateGroupPacket.AgentData.SessionID != SessionId || + activateGroupPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID); + m_GroupsModule.SendAgentGroupDataUpdate(this); + } + return true; + + } + + private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack) + { + GroupTitlesRequestPacket groupTitlesRequest = + (GroupTitlesRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupTitlesRequest.AgentData.SessionID != SessionId || + groupTitlesRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply); + + groupTitlesReply.AgentData = + new GroupTitlesReplyPacket.AgentDataBlock(); + + groupTitlesReply.AgentData.AgentID = AgentId; + groupTitlesReply.AgentData.GroupID = + groupTitlesRequest.AgentData.GroupID; + + groupTitlesReply.AgentData.RequestID = + groupTitlesRequest.AgentData.RequestID; + + List titles = + m_GroupsModule.GroupTitlesRequest(this, + groupTitlesRequest.AgentData.GroupID); + + groupTitlesReply.GroupData = + new GroupTitlesReplyPacket.GroupDataBlock[titles.Count]; + + int i = 0; + foreach (GroupTitlesData d in titles) + { + groupTitlesReply.GroupData[i] = + new GroupTitlesReplyPacket.GroupDataBlock(); + + groupTitlesReply.GroupData[i].Title = + Util.StringToBytes256(d.Name); + groupTitlesReply.GroupData[i].RoleID = + d.UUID; + groupTitlesReply.GroupData[i].Selected = + d.Selected; + i++; + } + + OutPacket(groupTitlesReply, ThrottleOutPacketType.Task); + } + return true; + } + private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack) + { + GroupProfileRequestPacket groupProfileRequest = + (GroupProfileRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupProfileRequest.AgentData.SessionID != SessionId || + groupProfileRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply); + + groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock(); + groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock(); + groupProfileReply.AgentData.AgentID = AgentId; + + GroupProfileData d = m_GroupsModule.GroupProfileRequest(this, + groupProfileRequest.GroupData.GroupID); + + groupProfileReply.GroupData.GroupID = d.GroupID; + groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name); + groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter); + groupProfileReply.GroupData.ShowInList = d.ShowInList; + groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle); + groupProfileReply.GroupData.PowersMask = d.PowersMask; + groupProfileReply.GroupData.InsigniaID = d.InsigniaID; + groupProfileReply.GroupData.FounderID = d.FounderID; + groupProfileReply.GroupData.MembershipFee = d.MembershipFee; + groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment; + groupProfileReply.GroupData.Money = d.Money; + groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount; + groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount; + groupProfileReply.GroupData.AllowPublish = d.AllowPublish; + groupProfileReply.GroupData.MaturePublish = d.MaturePublish; + groupProfileReply.GroupData.OwnerRole = d.OwnerRole; + + OutPacket(groupProfileReply, ThrottleOutPacketType.Task); + } + return true; + } + private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack) + { + GroupMembersRequestPacket groupMembersRequestPacket = + (GroupMembersRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupMembersRequestPacket.AgentData.SessionID != SessionId || + groupMembersRequestPacket.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + List members = + m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID); + + int memberCount = members.Count; + + while (true) + { + int blockCount = members.Count; + if (blockCount > 40) + blockCount = 40; + + GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply); + + groupMembersReply.AgentData = + new GroupMembersReplyPacket.AgentDataBlock(); + groupMembersReply.GroupData = + new GroupMembersReplyPacket.GroupDataBlock(); + groupMembersReply.MemberData = + new GroupMembersReplyPacket.MemberDataBlock[ + blockCount]; + + groupMembersReply.AgentData.AgentID = AgentId; + groupMembersReply.GroupData.GroupID = + groupMembersRequestPacket.GroupData.GroupID; + groupMembersReply.GroupData.RequestID = + groupMembersRequestPacket.GroupData.RequestID; + groupMembersReply.GroupData.MemberCount = memberCount; + + for (int i = 0; i < blockCount; i++) + { + GroupMembersData m = members[0]; + members.RemoveAt(0); + + groupMembersReply.MemberData[i] = + new GroupMembersReplyPacket.MemberDataBlock(); + groupMembersReply.MemberData[i].AgentID = + m.AgentID; + groupMembersReply.MemberData[i].Contribution = + m.Contribution; + groupMembersReply.MemberData[i].OnlineStatus = + Util.StringToBytes256(m.OnlineStatus); + groupMembersReply.MemberData[i].AgentPowers = + m.AgentPowers; + groupMembersReply.MemberData[i].Title = + Util.StringToBytes256(m.Title); + groupMembersReply.MemberData[i].IsOwner = + m.IsOwner; + } + OutPacket(groupMembersReply, ThrottleOutPacketType.Task); + if (members.Count == 0) + return true; + } + } + return true; + } + private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack) + { + GroupRoleDataRequestPacket groupRolesRequest = + (GroupRoleDataRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupRolesRequest.AgentData.SessionID != SessionId || + groupRolesRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply); + + groupRolesReply.AgentData = + new GroupRoleDataReplyPacket.AgentDataBlock(); + + groupRolesReply.AgentData.AgentID = AgentId; + + groupRolesReply.GroupData = + new GroupRoleDataReplyPacket.GroupDataBlock(); + + groupRolesReply.GroupData.GroupID = + groupRolesRequest.GroupData.GroupID; + + groupRolesReply.GroupData.RequestID = + groupRolesRequest.GroupData.RequestID; + + List titles = + m_GroupsModule.GroupRoleDataRequest(this, + groupRolesRequest.GroupData.GroupID); + + groupRolesReply.GroupData.RoleCount = + titles.Count; + + groupRolesReply.RoleData = + new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count]; + + int i = 0; + foreach (GroupRolesData d in titles) + { + groupRolesReply.RoleData[i] = + new GroupRoleDataReplyPacket.RoleDataBlock(); + + groupRolesReply.RoleData[i].RoleID = + d.RoleID; + groupRolesReply.RoleData[i].Name = + Util.StringToBytes256(d.Name); + groupRolesReply.RoleData[i].Title = + Util.StringToBytes256(d.Title); + groupRolesReply.RoleData[i].Description = + Util.StringToBytes1024(d.Description); + groupRolesReply.RoleData[i].Powers = + d.Powers; + groupRolesReply.RoleData[i].Members = + (uint)d.Members; + + i++; + } + + OutPacket(groupRolesReply, ThrottleOutPacketType.Task); + } + return true; + } + private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack) + { + GroupRoleMembersRequestPacket groupRoleMembersRequest = + (GroupRoleMembersRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupRoleMembersRequest.AgentData.SessionID != SessionId || + groupRoleMembersRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + List mappings = + m_GroupsModule.GroupRoleMembersRequest(this, + groupRoleMembersRequest.GroupData.GroupID); + + int mappingsCount = mappings.Count; + + while (mappings.Count > 0) + { + int pairs = mappings.Count; + if (pairs > 32) + pairs = 32; + + GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply); + groupRoleMembersReply.AgentData = + new GroupRoleMembersReplyPacket.AgentDataBlock(); + groupRoleMembersReply.AgentData.AgentID = + AgentId; + groupRoleMembersReply.AgentData.GroupID = + groupRoleMembersRequest.GroupData.GroupID; + groupRoleMembersReply.AgentData.RequestID = + groupRoleMembersRequest.GroupData.RequestID; + + groupRoleMembersReply.AgentData.TotalPairs = + (uint)mappingsCount; + + groupRoleMembersReply.MemberData = + new GroupRoleMembersReplyPacket.MemberDataBlock[pairs]; + + for (int i = 0; i < pairs; i++) + { + GroupRoleMembersData d = mappings[0]; + mappings.RemoveAt(0); + + groupRoleMembersReply.MemberData[i] = + new GroupRoleMembersReplyPacket.MemberDataBlock(); + + groupRoleMembersReply.MemberData[i].RoleID = + d.RoleID; + groupRoleMembersReply.MemberData[i].MemberID = + d.MemberID; + } + + OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task); + } + } + return true; + } + private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack) + { + CreateGroupRequestPacket createGroupRequest = + (CreateGroupRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (createGroupRequest.AgentData.SessionID != SessionId || + createGroupRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + m_GroupsModule.CreateGroup(this, + Utils.BytesToString(createGroupRequest.GroupData.Name), + Utils.BytesToString(createGroupRequest.GroupData.Charter), + createGroupRequest.GroupData.ShowInList, + createGroupRequest.GroupData.InsigniaID, + createGroupRequest.GroupData.MembershipFee, + createGroupRequest.GroupData.OpenEnrollment, + createGroupRequest.GroupData.AllowPublish, + createGroupRequest.GroupData.MaturePublish); + } + return true; + } + private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack) + { + UpdateGroupInfoPacket updateGroupInfo = + (UpdateGroupInfoPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (updateGroupInfo.AgentData.SessionID != SessionId || + updateGroupInfo.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + m_GroupsModule.UpdateGroupInfo(this, + updateGroupInfo.GroupData.GroupID, + Utils.BytesToString(updateGroupInfo.GroupData.Charter), + updateGroupInfo.GroupData.ShowInList, + updateGroupInfo.GroupData.InsigniaID, + updateGroupInfo.GroupData.MembershipFee, + updateGroupInfo.GroupData.OpenEnrollment, + updateGroupInfo.GroupData.AllowPublish, + updateGroupInfo.GroupData.MaturePublish); + } + + return true; + } + private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack) + { + SetGroupAcceptNoticesPacket setGroupAcceptNotices = + (SetGroupAcceptNoticesPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (setGroupAcceptNotices.AgentData.SessionID != SessionId || + setGroupAcceptNotices.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + m_GroupsModule.SetGroupAcceptNotices(this, + setGroupAcceptNotices.Data.GroupID, + setGroupAcceptNotices.Data.AcceptNotices, + setGroupAcceptNotices.NewData.ListInProfile); + } + + return true; + } + private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack) + { + GroupTitleUpdatePacket groupTitleUpdate = + (GroupTitleUpdatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupTitleUpdate.AgentData.SessionID != SessionId || + groupTitleUpdate.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + m_GroupsModule.GroupTitleUpdate(this, + groupTitleUpdate.AgentData.GroupID, + groupTitleUpdate.AgentData.TitleRoleID); + } + + return true; + } + private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack) + { + ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack; + if (m_GroupsModule != null) + { + ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup; + if (handlerParcelDeedToGroup != null) + { + handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this); + + } + } + + return true; + } + private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack) + { + GroupNoticesListRequestPacket groupNoticesListRequest = + (GroupNoticesListRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupNoticesListRequest.AgentData.SessionID != SessionId || + groupNoticesListRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + GroupNoticeData[] gn = + m_GroupsModule.GroupNoticesListRequest(this, + groupNoticesListRequest.Data.GroupID); + + GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply); + groupNoticesListReply.AgentData = + new GroupNoticesListReplyPacket.AgentDataBlock(); + groupNoticesListReply.AgentData.AgentID = AgentId; + groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID; + + groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length]; + + int i = 0; + foreach (GroupNoticeData g in gn) + { + groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock(); + groupNoticesListReply.Data[i].NoticeID = + g.NoticeID; + groupNoticesListReply.Data[i].Timestamp = + g.Timestamp; + groupNoticesListReply.Data[i].FromName = + Util.StringToBytes256(g.FromName); + groupNoticesListReply.Data[i].Subject = + Util.StringToBytes256(g.Subject); + groupNoticesListReply.Data[i].HasAttachment = + g.HasAttachment; + groupNoticesListReply.Data[i].AssetType = + g.AssetType; + i++; + } + + OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task); + } + + return true; + } + private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack) + { + GroupNoticeRequestPacket groupNoticeRequest = + (GroupNoticeRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupNoticeRequest.AgentData.SessionID != SessionId || + groupNoticeRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + m_GroupsModule.GroupNoticeRequest(this, + groupNoticeRequest.Data.GroupNoticeID); + } + return true; + } + private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack) + { + GroupRoleUpdatePacket groupRoleUpdate = + (GroupRoleUpdatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupRoleUpdate.AgentData.SessionID != SessionId || + groupRoleUpdate.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + foreach (GroupRoleUpdatePacket.RoleDataBlock d in + groupRoleUpdate.RoleData) + { + m_GroupsModule.GroupRoleUpdate(this, + groupRoleUpdate.AgentData.GroupID, + d.RoleID, + Utils.BytesToString(d.Name), + Utils.BytesToString(d.Description), + Utils.BytesToString(d.Title), + d.Powers, + d.UpdateType); + } + m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID); + } + return true; + } + private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack) + { + GroupRoleChangesPacket groupRoleChanges = + (GroupRoleChangesPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (groupRoleChanges.AgentData.SessionID != SessionId || + groupRoleChanges.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + foreach (GroupRoleChangesPacket.RoleChangeBlock d in + groupRoleChanges.RoleChange) + { + m_GroupsModule.GroupRoleChanges(this, + groupRoleChanges.AgentData.GroupID, + d.RoleID, + d.MemberID, + d.Change); + } + m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID); + } + return true; + } + private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack) + { + JoinGroupRequestPacket joinGroupRequest = + (JoinGroupRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (joinGroupRequest.AgentData.SessionID != SessionId || + joinGroupRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + m_GroupsModule.JoinGroupRequest(this, + joinGroupRequest.GroupData.GroupID); + } + return true; + } + private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack) + { + LeaveGroupRequestPacket leaveGroupRequest = + (LeaveGroupRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) + { + if (leaveGroupRequest.AgentData.SessionID != SessionId || + leaveGroupRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion + + if (m_GroupsModule != null) + { + m_GroupsModule.LeaveGroupRequest(this, + leaveGroupRequest.GroupData.GroupID); + } + return true; + } + private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack) { - RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; + EjectGroupMemberRequestPacket ejectGroupMemberRequest = + (EjectGroupMemberRequestPacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (mPacket.SessionID != SessionId || - mPacket.AgentID != AgentId) + if (ejectGroupMemberRequest.AgentData.SessionID != SessionId || + ejectGroupMemberRequest.AgentData.AgentID != AgentId) return true; } #endregion - RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest; - if (handlerRegionInfoRequest != null) + if (m_GroupsModule != null) { - handlerRegionInfoRequest(this); + foreach (EjectGroupMemberRequestPacket.EjectDataBlock e + in ejectGroupMemberRequest.EjectData) + { + m_GroupsModule.EjectGroupMemberRequest(this, + ejectGroupMemberRequest.GroupData.GroupID, + e.EjecteeID); + } } return true; } - private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack) + private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack) { + InviteGroupRequestPacket inviteGroupRequest = + (InviteGroupRequestPacket)Pack; - //EstateCovenantRequestPacket.AgentDataBlock epack = - // ((EstateCovenantRequestPacket)Pack).AgentData; + #region Packet Session and User Check + if (m_checkPackets) + { + if (inviteGroupRequest.AgentData.SessionID != SessionId || + inviteGroupRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion - EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest; - if (handlerEstateCovenantRequest != null) + if (m_GroupsModule != null) { - handlerEstateCovenantRequest(this); + foreach (InviteGroupRequestPacket.InviteDataBlock b in + inviteGroupRequest.InviteData) + { + m_GroupsModule.InviteGroupRequest(this, + inviteGroupRequest.GroupData.GroupID, + b.InviteeID, + b.RoleID); + } } return true; - } - #endregion Estate Packets - - #region GodPackets + #endregion Groups - private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack) + private bool HandleStartLure(IClientAPI sender, Packet Pack) { - RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack; - RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; - UUID token = rblock.Token; - - RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; + StartLurePacket startLureRequest = (StartLurePacket)Pack; - RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers; - - if (handlerReqGodlikePowers != null) + #region Packet Session and User Check + if (m_checkPackets) { - handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this); + if (startLureRequest.AgentData.SessionID != SessionId || + startLureRequest.AgentData.AgentID != AgentId) + return true; } + #endregion + StartLure handlerStartLure = OnStartLure; + if (handlerStartLure != null) + handlerStartLure(startLureRequest.Info.LureType, + Utils.BytesToString( + startLureRequest.Info.Message), + startLureRequest.TargetData[0].TargetID, + this); return true; } - private bool HandleGodKickUser(IClientAPI sender, Packet Pack) + private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack) { - GodKickUserPacket gkupack = (GodKickUserPacket)Pack; + TeleportLureRequestPacket teleportLureRequest = + (TeleportLureRequestPacket)Pack; - if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) - { - GodKickUser handlerGodKickUser = OnGodKickUser; - if (handlerGodKickUser != null) - { - handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, - gkupack.UserInfo.AgentID, (uint)0, gkupack.UserInfo.Reason); - } - } - else + #region Packet Session and User Check + if (m_checkPackets) { - SendAgentAlertMessage("Kick request denied", false); + if (teleportLureRequest.Info.SessionID != SessionId || + teleportLureRequest.Info.AgentID != AgentId) + return true; } - //KickUserPacket kupack = new KickUserPacket(); - //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; - - //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID; - //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID; - - //kupack.TargetBlock.TargetIP = (uint)0; - //kupack.TargetBlock.TargetPort = (ushort)0; - //kupack.UserInfo.Reason = gkupack.UserInfo.Reason; + #endregion - //OutPacket(kupack, ThrottleOutPacketType.Task); + TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest; + if (handlerTeleportLureRequest != null) + handlerTeleportLureRequest( + teleportLureRequest.Info.LureID, + teleportLureRequest.Info.TeleportFlags, + this); return true; } - #endregion GodPackets + private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack) + { + ClassifiedInfoRequestPacket classifiedInfoRequest = + (ClassifiedInfoRequestPacket)Pack; - #region Economy/Transaction Packets + #region Packet Session and User Check + if (m_checkPackets) + { + if (classifiedInfoRequest.AgentData.SessionID != SessionId || + classifiedInfoRequest.AgentData.AgentID != AgentId) + return true; + } + #endregion - private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack) + ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest; + if (handlerClassifiedInfoRequest != null) + handlerClassifiedInfoRequest( + classifiedInfoRequest.Data.ClassifiedID, + this); + return true; + } + private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack) { - MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack; + ClassifiedInfoUpdatePacket classifiedInfoUpdate = + (ClassifiedInfoUpdatePacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (moneybalancerequestpacket.AgentData.SessionID != SessionId || - moneybalancerequestpacket.AgentData.AgentID != AgentId) + if (classifiedInfoUpdate.AgentData.SessionID != SessionId || + classifiedInfoUpdate.AgentData.AgentID != AgentId) return true; } #endregion - MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest; + ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate; + if (handlerClassifiedInfoUpdate != null) + handlerClassifiedInfoUpdate( + classifiedInfoUpdate.Data.ClassifiedID, + classifiedInfoUpdate.Data.Category, + Utils.BytesToString( + classifiedInfoUpdate.Data.Name), + Utils.BytesToString( + classifiedInfoUpdate.Data.Desc), + classifiedInfoUpdate.Data.ParcelID, + classifiedInfoUpdate.Data.ParentEstate, + classifiedInfoUpdate.Data.SnapshotID, + new Vector3( + classifiedInfoUpdate.Data.PosGlobal), + classifiedInfoUpdate.Data.ClassifiedFlags, + classifiedInfoUpdate.Data.PriceForListing, + this); + return true; + } + private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack) + { + ClassifiedDeletePacket classifiedDelete = + (ClassifiedDeletePacket)Pack; - if (handlerMoneyBalanceRequest != null) + #region Packet Session and User Check + if (m_checkPackets) { - handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID); + if (classifiedDelete.AgentData.SessionID != SessionId || + classifiedDelete.AgentData.AgentID != AgentId) + return true; } + #endregion + ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete; + if (handlerClassifiedDelete != null) + handlerClassifiedDelete( + classifiedDelete.Data.ClassifiedID, + this); return true; } - private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack) + private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack) { - EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest; - if (handlerEconomoyDataRequest != null) + ClassifiedGodDeletePacket classifiedGodDelete = + (ClassifiedGodDeletePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) { - handlerEconomoyDataRequest(AgentId); + if (classifiedGodDelete.AgentData.SessionID != SessionId || + classifiedGodDelete.AgentData.AgentID != AgentId) + return true; } + #endregion + + ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete; + if (handlerClassifiedGodDelete != null) + handlerClassifiedGodDelete( + classifiedGodDelete.Data.ClassifiedID, + this); return true; } - private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack) + private bool HandleEventGodDelete(IClientAPI sender, Packet Pack) { - RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; + EventGodDeletePacket eventGodDelete = + (EventGodDeletePacket)Pack; - RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice; - if (handlerRequestPayPrice != null) + #region Packet Session and User Check + if (m_checkPackets) { - handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID); + if (eventGodDelete.AgentData.SessionID != SessionId || + eventGodDelete.AgentData.AgentID != AgentId) + return true; } + #endregion + + EventGodDelete handlerEventGodDelete = OnEventGodDelete; + if (handlerEventGodDelete != null) + handlerEventGodDelete( + eventGodDelete.EventData.EventID, + eventGodDelete.QueryData.QueryID, + Utils.BytesToString( + eventGodDelete.QueryData.QueryText), + eventGodDelete.QueryData.QueryFlags, + eventGodDelete.QueryData.QueryStart, + this); return true; } - private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack) + private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack) { - ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack; + EventNotificationAddRequestPacket eventNotificationAdd = + (EventNotificationAddRequestPacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (objectSaleInfoPacket.AgentData.SessionID != SessionId || - objectSaleInfoPacket.AgentData.AgentID != AgentId) + if (eventNotificationAdd.AgentData.SessionID != SessionId || + eventNotificationAdd.AgentData.AgentID != AgentId) return true; } #endregion - ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo; - if (handlerObjectSaleInfo != null) + EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest; + if (handlerEventNotificationAddRequest != null) + handlerEventNotificationAddRequest( + eventNotificationAdd.EventData.EventID, this); + return true; + } + private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack) + { + EventNotificationRemoveRequestPacket eventNotificationRemove = + (EventNotificationRemoveRequestPacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) { - foreach (ObjectSaleInfoPacket.ObjectDataBlock d - in objectSaleInfoPacket.ObjectData) - { - handlerObjectSaleInfo(this, - objectSaleInfoPacket.AgentData.AgentID, - objectSaleInfoPacket.AgentData.SessionID, - d.LocalID, - d.SaleType, - d.SalePrice); - } + if (eventNotificationRemove.AgentData.SessionID != SessionId || + eventNotificationRemove.AgentData.AgentID != AgentId) + return true; } + #endregion + + EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest; + if (handlerEventNotificationRemoveRequest != null) + handlerEventNotificationRemoveRequest( + eventNotificationRemove.EventData.EventID, this); return true; } - private bool HandleObjectBuy(IClientAPI sender, Packet Pack) + private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack) { - ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack; + RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (objectBuyPacket.AgentData.SessionID != SessionId || - objectBuyPacket.AgentData.AgentID != AgentId) + if (rimpInstantMessagePack.AgentData.SessionID != SessionId || + rimpInstantMessagePack.AgentData.AgentID != AgentId) return true; } #endregion - ObjectBuy handlerObjectBuy = OnObjectBuy; + RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages; + if (handlerRetrieveInstantMessages != null) + handlerRetrieveInstantMessages(this); + return true; + } + private bool HandlePickDelete(IClientAPI sender, Packet Pack) + { + PickDeletePacket pickDelete = + (PickDeletePacket)Pack; - if (handlerObjectBuy != null) + #region Packet Session and User Check + if (m_checkPackets) { - foreach (ObjectBuyPacket.ObjectDataBlock d - in objectBuyPacket.ObjectData) - { - handlerObjectBuy(this, - objectBuyPacket.AgentData.AgentID, - objectBuyPacket.AgentData.SessionID, - objectBuyPacket.AgentData.GroupID, - objectBuyPacket.AgentData.CategoryID, - d.ObjectLocalID, - d.SaleType, - d.SalePrice); - } + if (pickDelete.AgentData.SessionID != SessionId || + pickDelete.AgentData.AgentID != AgentId) + return true; } + #endregion + + PickDelete handlerPickDelete = OnPickDelete; + if (handlerPickDelete != null) + handlerPickDelete(this, pickDelete.Data.PickID); return true; } - - #endregion Economy/Transaction Packets - - #region Script Packets - private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack) + private bool HandlePickGodDelete(IClientAPI sender, Packet Pack) { - GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; + PickGodDeletePacket pickGodDelete = + (PickGodDeletePacket)Pack; - GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning; - if (handlerGetScriptRunning != null) + #region Packet Session and User Check + if (m_checkPackets) { - handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); + if (pickGodDelete.AgentData.SessionID != SessionId || + pickGodDelete.AgentData.AgentID != AgentId) + return true; } + #endregion + + PickGodDelete handlerPickGodDelete = OnPickGodDelete; + if (handlerPickGodDelete != null) + handlerPickGodDelete(this, + pickGodDelete.AgentData.AgentID, + pickGodDelete.Data.PickID, + pickGodDelete.Data.QueryID); return true; } - private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack) + private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack) { - SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack; + PickInfoUpdatePacket pickInfoUpdate = + (PickInfoUpdatePacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (setScriptRunning.AgentData.SessionID != SessionId || - setScriptRunning.AgentData.AgentID != AgentId) + if (pickInfoUpdate.AgentData.SessionID != SessionId || + pickInfoUpdate.AgentData.AgentID != AgentId) return true; } #endregion - SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning; - if (handlerSetScriptRunning != null) + PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate; + if (handlerPickInfoUpdate != null) + handlerPickInfoUpdate(this, + pickInfoUpdate.Data.PickID, + pickInfoUpdate.Data.CreatorID, + pickInfoUpdate.Data.TopPick, + Utils.BytesToString(pickInfoUpdate.Data.Name), + Utils.BytesToString(pickInfoUpdate.Data.Desc), + pickInfoUpdate.Data.SnapshotID, + pickInfoUpdate.Data.SortOrder, + pickInfoUpdate.Data.Enabled); + return true; + } + private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack) + { + AvatarNotesUpdatePacket avatarNotesUpdate = + (AvatarNotesUpdatePacket)Pack; + + #region Packet Session and User Check + if (m_checkPackets) { - handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); + if (avatarNotesUpdate.AgentData.SessionID != SessionId || + avatarNotesUpdate.AgentData.AgentID != AgentId) + return true; } + #endregion + + AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate; + if (handlerAvatarNotesUpdate != null) + handlerAvatarNotesUpdate(this, + avatarNotesUpdate.Data.TargetID, + Utils.BytesToString(avatarNotesUpdate.Data.Notes)); return true; } - - private bool HandleScriptReset(IClientAPI sender, Packet Pack) + private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack) { - ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack; + AvatarInterestsUpdatePacket avatarInterestUpdate = + (AvatarInterestsUpdatePacket)Pack; #region Packet Session and User Check if (m_checkPackets) { - if (scriptResetPacket.AgentData.SessionID != SessionId || - scriptResetPacket.AgentData.AgentID != AgentId) + if (avatarInterestUpdate.AgentData.SessionID != SessionId || + avatarInterestUpdate.AgentData.AgentID != AgentId) return true; } #endregion - ScriptReset handlerScriptReset = OnScriptReset; - if (handlerScriptReset != null) + AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate; + if (handlerAvatarInterestUpdate != null) + handlerAvatarInterestUpdate(this, + avatarInterestUpdate.PropertiesData.WantToMask, + Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText), + avatarInterestUpdate.PropertiesData.SkillsMask, + Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText), + Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText)); + return true; + } + private bool HandleGrantUserRights(IClientAPI sender, Packet Pack) + { + GrantUserRightsPacket GrantUserRights = + (GrantUserRightsPacket)Pack; + #region Packet Session and User Check + if (m_checkPackets) { - handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); + if (GrantUserRights.AgentData.SessionID != SessionId || + GrantUserRights.AgentData.AgentID != AgentId) + return true; } + #endregion + GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights; + if (GrantUserRightsHandler != null) + GrantUserRightsHandler(this, + GrantUserRights.AgentData.AgentID, + GrantUserRights.Rights[0].AgentRelated, + GrantUserRights.Rights[0].RelatedRights); return true; } + private bool HandlePlacesQuery(IClientAPI sender, Packet Pack) + { + PlacesQueryPacket placesQueryPacket = + (PlacesQueryPacket)Pack; - #endregion Script Packets - + PlacesQuery handlerPlacesQuery = OnPlacesQuery; + if (handlerPlacesQuery != null) + handlerPlacesQuery(placesQueryPacket.AgentData.QueryID, + placesQueryPacket.TransactionData.TransactionID, + Utils.BytesToString( + placesQueryPacket.QueryData.QueryText), + placesQueryPacket.QueryData.QueryFlags, + (byte)placesQueryPacket.QueryData.Category, + Utils.BytesToString( + placesQueryPacket.QueryData.SimName), + this); + return true; + } #endregion Packet Handlers @@ -8823,6 +10326,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (ProcessPacketMethod(Pack)) { + PacketPool.Instance.ReturnPacket(Pack); return; } @@ -12281,9 +13785,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; //#endregion - */ - #endregion - #region Gesture Managment + + //#region Gesture Managment case PacketType.ActivateGestures: ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack; @@ -12350,7 +13853,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #endregion + //#endregion case PacketType.AgentFOV: AgentFOVPacket fovPacket = (AgentFOVPacket)Pack; @@ -12366,7 +13869,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #region unimplemented handlers + //#region unimplemented handlers case PacketType.ViewerStats: // TODO: handle this packet @@ -12400,6 +13903,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // TODO: handle this packet //m_log.Warn("[CLIENT]: unhandled TransferAbort packet"); break; + case PacketType.MuteListRequest: MuteListRequestPacket muteListRequest = (MuteListRequestPacket)Pack; @@ -12423,6 +13927,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP SendUseCachedMuteList(); } break; + case PacketType.UseCircuitCode: // Don't display this one, we handle it at a lower level break; @@ -12437,6 +13942,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP //m_log.Warn("[CLIENT]: unhandled InventoryDescent packet"); break; + case PacketType.DirPlacesQuery: DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack; //m_log.Debug(dirPlacesQueryPacket.ToString()); @@ -12464,6 +13970,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP dirPlacesQueryPacket.QueryData.QueryStart); } break; + case PacketType.DirFindQuery: DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack; @@ -12487,6 +13994,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP dirFindQueryPacket.QueryData.QueryStart); } break; + case PacketType.DirLandQuery: DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack; @@ -12511,6 +14019,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP dirLandQueryPacket.QueryData.QueryStart); } break; + case PacketType.DirPopularQuery: DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack; @@ -12531,6 +14040,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP dirPopularQueryPacket.QueryData.QueryFlags); } break; + case PacketType.DirClassifiedQuery: DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack; @@ -12555,6 +14065,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP dirClassifiedQueryPacket.QueryData.QueryStart); } break; + case PacketType.EventInfoRequest: EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack; @@ -12573,7 +14084,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #region Calling Card + //#region Calling Card case PacketType.OfferCallingCard: OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack; @@ -12635,9 +14146,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP declineCallingCardPacket.TransactionBlock.TransactionID); } break; - #endregion + //#endregion - #region Groups + //#region Groups case PacketType.ActivateGroup: ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack; @@ -12657,6 +14168,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.GroupTitlesRequest: GroupTitlesRequestPacket groupTitlesRequest = (GroupTitlesRequestPacket)Pack; @@ -13118,8 +14630,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task); } - + break; + case PacketType.GroupNoticeRequest: GroupNoticeRequestPacket groupNoticeRequest = (GroupNoticeRequestPacket)Pack; @@ -13290,7 +14803,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; - #endregion + //#endregion + case PacketType.StartLure: StartLurePacket startLureRequest = (StartLurePacket)Pack; @@ -13522,6 +15036,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (handlerPickDelete != null) handlerPickDelete(this, pickDelete.Data.PickID); break; + case PacketType.PickGodDelete: PickGodDeletePacket pickGodDelete = (PickGodDeletePacket)Pack; @@ -13542,6 +15057,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP pickGodDelete.Data.PickID, pickGodDelete.Data.QueryID); break; + case PacketType.PickInfoUpdate: PickInfoUpdatePacket pickInfoUpdate = (PickInfoUpdatePacket)Pack; @@ -13567,6 +15083,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP pickInfoUpdate.Data.SortOrder, pickInfoUpdate.Data.Enabled); break; + case PacketType.AvatarNotesUpdate: AvatarNotesUpdatePacket avatarNotesUpdate = (AvatarNotesUpdatePacket)Pack; @@ -13599,7 +15116,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; } #endregion - + AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate; if (handlerAvatarInterestUpdate != null) handlerAvatarInterestUpdate(this, @@ -13646,11 +15163,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP placesQueryPacket.QueryData.SimName), this); break; + */ + #endregion default: m_log.Warn("[CLIENT]: unhandled packet " + Pack); break; - - #endregion } PacketPool.Instance.ReturnPacket(Pack); -- cgit v1.1 From 52952a75ca5c8c095a4a21a9aa885c9f894a9b01 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Nov 2009 15:20:02 +0000 Subject: minor: remove experimental tags from load iar and save iar commands --- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 1228eb1..2c0d113 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -92,12 +92,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver scene.AddCommand( this, "load iar", "load iar []", - "Load user inventory archive. EXPERIMENTAL", HandleLoadInvConsoleCommand); + "Load user inventory archive.", HandleLoadInvConsoleCommand); scene.AddCommand( this, "save iar", "save iar []", - "Save user inventory archive. EXPERIMENTAL", HandleSaveInvConsoleCommand); + "Save user inventory archive.", HandleSaveInvConsoleCommand); m_aScene = scene; } -- cgit v1.1 From d1147136946daf14724183b3191119be44ff8b16 Mon Sep 17 00:00:00 2001 From: CasperW Date: Tue, 24 Nov 2009 18:02:12 +0100 Subject: Drop all locking of part.TaskInventory in favour of a ReaderWriterLockSlim lock handler. This gives us: - Faster prim inventory actions. Multiple threads can read at once. - Fixes the known prim inventory thread locks - In the event of a thread lock occurring, it will usually self heal after sixty seconds with an error message in the console --- .../World/Archiver/ArchiveReadRequest.cs | 21 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 38 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 390 ++++++++------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 +- .../Shared/Api/Implementation/LSL_Api.cs | 532 ++++++++++++--------- .../Shared/Api/Implementation/OSSL_Api.cs | 36 +- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 22 +- 7 files changed, 579 insertions(+), 476 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 70a225e..f204faf 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -246,21 +246,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver // Fix ownership/creator of inventory items // Not doing so results in inventory items // being no copy/no mod for everyone - lock (part.TaskInventory) + part.TaskInventory.LockItemsForRead(true); + TaskInventoryDictionary inv = part.TaskInventory; + foreach (KeyValuePair kvp in inv) { - TaskInventoryDictionary inv = part.TaskInventory; - foreach (KeyValuePair kvp in inv) + if (!ResolveUserUuid(kvp.Value.OwnerID)) { - if (!ResolveUserUuid(kvp.Value.OwnerID)) - { - kvp.Value.OwnerID = masterAvatarId; - } - if (!ResolveUserUuid(kvp.Value.CreatorID)) - { - kvp.Value.CreatorID = masterAvatarId; - } + kvp.Value.OwnerID = masterAvatarId; + } + if (!ResolveUserUuid(kvp.Value.CreatorID)) + { + kvp.Value.CreatorID = masterAvatarId; } } + part.TaskInventory.LockItemsForRead(false); } if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cdec135..bbece2f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -389,12 +389,16 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes + /// Get the inventory list /// public TaskInventoryDictionary TaskInventory { - get { return m_inventory.Items; } - set { m_inventory.Items = value; } + get { + return m_inventory.Items; + } + set { + m_inventory.Items = value; + } } public uint ObjectFlags @@ -2101,17 +2105,18 @@ namespace OpenSim.Region.Framework.Scenes //Trys to fetch sound id from prim's inventory. //Prim's inventory doesn't support non script items yet - lock (TaskInventory) + TaskInventory.LockItemsForRead(true); + + foreach (KeyValuePair item in TaskInventory) { - foreach (KeyValuePair item in TaskInventory) + if (item.Value.Name == sound) { - if (item.Value.Name == sound) - { - soundID = item.Value.ItemID; - break; - } + soundID = item.Value.ItemID; + break; } } + + TaskInventory.LockItemsForRead(false); } List avatarts = m_parentGroup.Scene.GetAvatars(); @@ -2457,17 +2462,16 @@ namespace OpenSim.Region.Framework.Scenes if (!UUID.TryParse(sound, out soundID)) { // search sound file from inventory - lock (TaskInventory) + TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair item in TaskInventory) { - foreach (KeyValuePair item in TaskInventory) + if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) { - if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) - { - soundID = item.Value.ItemID; - break; - } + soundID = item.Value.ItemID; + break; } } + TaskInventory.LockItemsForRead(false); } if (soundID == UUID.Zero) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index f4ca877..4dc709e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -80,7 +80,9 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal TaskInventoryDictionary Items { - get { return m_items; } + get { + return m_items; + } set { m_items = value; @@ -116,22 +118,25 @@ namespace OpenSim.Region.Framework.Scenes /// Link number for the part public void ResetInventoryIDs() { - lock (Items) + m_items.LockItemsForWrite(true); + + if (0 == Items.Count) { - if (0 == Items.Count) - return; + m_items.LockItemsForWrite(false); + return; + } - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; - IList items = new List(Items.Values); - Items.Clear(); + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + IList items = new List(Items.Values); + Items.Clear(); - foreach (TaskInventoryItem item in items) - { - item.ResetIDs(m_part.UUID); - Items.Add(item.ItemID, item); - } + foreach (TaskInventoryItem item in items) + { + item.ResetIDs(m_part.UUID); + Items.Add(item.ItemID, item); } + m_items.LockItemsForWrite(false); } /// @@ -140,25 +145,25 @@ namespace OpenSim.Region.Framework.Scenes /// public void ChangeInventoryOwner(UUID ownerId) { - lock (Items) + m_items.LockItemsForWrite(true); + if (0 == Items.Count) { - if (0 == Items.Count) - { - return; - } + m_items.LockItemsForWrite(false); + return; + } - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; - IList items = new List(Items.Values); - foreach (TaskInventoryItem item in items) + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + IList items = new List(Items.Values); + foreach (TaskInventoryItem item in items) + { + if (ownerId != item.OwnerID) { - if (ownerId != item.OwnerID) - { - item.LastOwnerID = item.OwnerID; - item.OwnerID = ownerId; - } + item.LastOwnerID = item.OwnerID; + item.OwnerID = ownerId; } } + m_items.LockItemsForWrite(false); } /// @@ -167,24 +172,24 @@ namespace OpenSim.Region.Framework.Scenes /// public void ChangeInventoryGroup(UUID groupID) { - lock (Items) + m_items.LockItemsForWrite(true); + if (0 == Items.Count) { - if (0 == Items.Count) - { - return; - } + m_items.LockItemsForWrite(false); + return; + } - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; - IList items = new List(Items.Values); - foreach (TaskInventoryItem item in items) + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + IList items = new List(Items.Values); + foreach (TaskInventoryItem item in items) + { + if (groupID != item.GroupID) { - if (groupID != item.GroupID) - { - item.GroupID = groupID; - } + item.GroupID = groupID; } } + m_items.LockItemsForWrite(false); } /// @@ -192,14 +197,14 @@ namespace OpenSim.Region.Framework.Scenes /// public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) { - lock (m_items) + Items.LockItemsForRead(true); + IList items = new List(Items.Values); + Items.LockItemsForRead(false); + foreach (TaskInventoryItem item in items) { - foreach (TaskInventoryItem item in Items.Values) + if ((int)InventoryType.LSL == item.InvType) { - if ((int)InventoryType.LSL == item.InvType) - { - CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); - } + CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); } } } @@ -209,17 +214,20 @@ namespace OpenSim.Region.Framework.Scenes /// public void RemoveScriptInstances() { - lock (Items) + Items.LockItemsForRead(true); + IList items = new List(Items.Values); + Items.LockItemsForRead(false); + + foreach (TaskInventoryItem item in items) { - foreach (TaskInventoryItem item in Items.Values) + if ((int)InventoryType.LSL == item.InvType) { - if ((int)InventoryType.LSL == item.InvType) - { - RemoveScriptInstance(item.ItemID); - m_part.RemoveScriptEvents(item.ItemID); - } + RemoveScriptInstance(item.ItemID); + m_part.RemoveScriptEvents(item.ItemID); } } + + } /// @@ -244,8 +252,10 @@ namespace OpenSim.Region.Framework.Scenes if (stateSource == 1 && // Prim crossing m_part.ParentGroup.Scene.m_trustBinaries) { + m_items.LockItemsForWrite(true); m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsGranter = UUID.Zero; + m_items.LockItemsForWrite(false); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); m_part.ParentGroup.AddActiveScriptCount(1); @@ -266,8 +276,10 @@ namespace OpenSim.Region.Framework.Scenes { if (m_part.ParentGroup.m_savedScriptState != null) RestoreSavedScriptState(item.OldItemID, item.ItemID); + m_items.LockItemsForWrite(true); m_items[item.ItemID].PermsMask = 0; m_items[item.ItemID].PermsGranter = UUID.Zero; + m_items.LockItemsForWrite(false); string script = Utils.BytesToString(asset.Data); m_part.ParentGroup.Scene.EventManager.TriggerRezScript( m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); @@ -302,20 +314,22 @@ namespace OpenSim.Region.Framework.Scenes /// public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) { - lock (m_items) + m_items.LockItemsForRead(true); + if (m_items.ContainsKey(itemId)) { - if (m_items.ContainsKey(itemId)) - { - CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); - } - else - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", - itemId, m_part.Name, m_part.UUID); - } + TaskInventoryItem item = m_items[itemId]; + m_items.LockItemsForRead(false); + CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); } + else + { + m_items.LockItemsForRead(false); + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", + itemId, m_part.Name, m_part.UUID); + } + } /// @@ -346,11 +360,16 @@ namespace OpenSim.Region.Framework.Scenes /// private bool InventoryContainsName(string name) { - foreach (TaskInventoryItem item in Items.Values) + m_items.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_items.Values) { if (item.Name == name) + { + m_items.LockItemsForRead(false); return true; + } } + m_items.LockItemsForRead(false); return false; } @@ -392,7 +411,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) { + m_items.LockItemsForRead(true); List il = new List(m_items.Values); + m_items.LockItemsForRead(false); foreach (TaskInventoryItem i in il) { if (i.Name == item.Name) @@ -429,15 +450,14 @@ namespace OpenSim.Region.Framework.Scenes item.ParentPartID = m_part.UUID; item.Name = name; - lock (m_items) - { - m_items.Add(item.ItemID, item); - + m_items.LockItemsForWrite(true); + m_items.Add(item.ItemID, item); + m_items.LockItemsForWrite(false); if (allowedDrop) m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); else m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - } + m_inventorySerial++; //m_inventorySerial += 2; @@ -454,14 +474,13 @@ namespace OpenSim.Region.Framework.Scenes /// public void RestoreInventoryItems(ICollection items) { - lock (m_items) + m_items.LockItemsForWrite(true); + foreach (TaskInventoryItem item in items) { - foreach (TaskInventoryItem item in items) - { - m_items.Add(item.ItemID, item); - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - } + m_items.Add(item.ItemID, item); + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); } + m_items.LockItemsForWrite(false); m_inventorySerial++; } @@ -474,8 +493,9 @@ namespace OpenSim.Region.Framework.Scenes public TaskInventoryItem GetInventoryItem(UUID itemId) { TaskInventoryItem item; + m_items.LockItemsForRead(true); m_items.TryGetValue(itemId, out item); - + m_items.LockItemsForRead(false); return item; } @@ -487,45 +507,45 @@ namespace OpenSim.Region.Framework.Scenes /// false if the item did not exist, true if the update occurred successfully public bool UpdateInventoryItem(TaskInventoryItem item) { - lock (m_items) + m_items.LockItemsForWrite(true); + + if (m_items.ContainsKey(item.ItemID)) { - if (m_items.ContainsKey(item.ItemID)) + item.ParentID = m_part.UUID; + item.ParentPartID = m_part.UUID; + item.Flags = m_items[item.ItemID].Flags; + if (item.AssetID == UUID.Zero) { - item.ParentID = m_part.UUID; - item.ParentPartID = m_part.UUID; - item.Flags = m_items[item.ItemID].Flags; - if (item.AssetID == UUID.Zero) - { - item.AssetID = m_items[item.ItemID].AssetID; - } - else if ((InventoryType)item.Type == InventoryType.Notecard) - { - ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); + item.AssetID = m_items[item.ItemID].AssetID; + } + else if ((InventoryType)item.Type == InventoryType.Notecard) + { + ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); - if (presence != null) - { - presence.ControllingClient.SendAgentAlertMessage( - "Notecard saved", false); - } + if (presence != null) + { + presence.ControllingClient.SendAgentAlertMessage( + "Notecard saved", false); } + } - m_items[item.ItemID] = item; - m_inventorySerial++; - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; + m_items[item.ItemID] = item; + m_inventorySerial++; + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - return true; - } - else - { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", - item.ItemID, m_part.Name, m_part.UUID); - } + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; + m_items.LockItemsForWrite(false); + return true; + } + else + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", + item.ItemID, m_part.Name, m_part.UUID); } + m_items.LockItemsForWrite(false); return false; } @@ -538,51 +558,54 @@ namespace OpenSim.Region.Framework.Scenes /// in this prim's inventory. public int RemoveInventoryItem(UUID itemID) { - lock (m_items) + m_items.LockItemsForRead(true); + + if (m_items.ContainsKey(itemID)) { - if (m_items.ContainsKey(itemID)) + int type = m_items[itemID].InvType; + m_items.LockItemsForRead(false); + if (type == 10) // Script { - int type = m_items[itemID].InvType; - if (type == 10) // Script - { - m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); - } - m_items.Remove(itemID); - m_inventorySerial++; - m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - - HasInventoryChanged = true; - m_part.ParentGroup.HasGroupChanged = true; + m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); + } + m_items.LockItemsForWrite(true); + m_items.Remove(itemID); + m_items.LockItemsForWrite(false); + m_inventorySerial++; + m_part.TriggerScriptChangedEvent(Changed.INVENTORY); - int scriptcount = 0; - lock (m_items) - { - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.Type == 10) - { - scriptcount++; - } - } - } + HasInventoryChanged = true; + m_part.ParentGroup.HasGroupChanged = true; - if (scriptcount <= 0) + int scriptcount = 0; + m_items.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_items.Values) + { + if (item.Type == 10) { - m_part.RemFlag(PrimFlags.Scripted); + scriptcount++; } - - m_part.ScheduleFullUpdate(); - - return type; } - else + m_items.LockItemsForRead(false); + + + if (scriptcount <= 0) { - m_log.ErrorFormat( - "[PRIM INVENTORY]: " + - "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", - itemID, m_part.Name, m_part.UUID); + m_part.RemFlag(PrimFlags.Scripted); } + + m_part.ScheduleFullUpdate(); + + return type; + } + else + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", + itemID, m_part.Name, m_part.UUID); } + m_items.LockItemsForWrite(false); return -1; } @@ -635,52 +658,53 @@ namespace OpenSim.Region.Framework.Scenes // isn't available (such as drag from prim inventory to agent inventory) InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); - lock (m_items) + m_items.LockItemsForRead(true); + + foreach (TaskInventoryItem item in m_items.Values) { - foreach (TaskInventoryItem item in m_items.Values) - { - UUID ownerID = item.OwnerID; - uint everyoneMask = 0; - uint baseMask = item.BasePermissions; - uint ownerMask = item.CurrentPermissions; + UUID ownerID = item.OwnerID; + uint everyoneMask = 0; + uint baseMask = item.BasePermissions; + uint ownerMask = item.CurrentPermissions; - invString.AddItemStart(); - invString.AddNameValueLine("item_id", item.ItemID.ToString()); - invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); + invString.AddItemStart(); + invString.AddNameValueLine("item_id", item.ItemID.ToString()); + invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); - invString.AddPermissionsStart(); + invString.AddPermissionsStart(); - invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); - invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); - invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); - invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); - invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); + invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); + invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); + invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); + invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); + invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); - invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); - invString.AddNameValueLine("owner_id", ownerID.ToString()); + invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); + invString.AddNameValueLine("owner_id", ownerID.ToString()); - invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); + invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); - invString.AddNameValueLine("group_id", item.GroupID.ToString()); - invString.AddSectionEnd(); + invString.AddNameValueLine("group_id", item.GroupID.ToString()); + invString.AddSectionEnd(); - invString.AddNameValueLine("asset_id", item.AssetID.ToString()); - invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); - invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); - invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); + invString.AddNameValueLine("asset_id", item.AssetID.ToString()); + invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); + invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); + invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); - invString.AddSaleStart(); - invString.AddNameValueLine("sale_type", "not"); - invString.AddNameValueLine("sale_price", "0"); - invString.AddSectionEnd(); + invString.AddSaleStart(); + invString.AddNameValueLine("sale_type", "not"); + invString.AddNameValueLine("sale_price", "0"); + invString.AddSectionEnd(); - invString.AddNameValueLine("name", item.Name + "|"); - invString.AddNameValueLine("desc", item.Description + "|"); + invString.AddNameValueLine("name", item.Name + "|"); + invString.AddNameValueLine("desc", item.Description + "|"); - invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); - invString.AddSectionEnd(); - } + invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); + invString.AddSectionEnd(); } + int count = m_items.Count; + m_items.LockItemsForRead(false); fileData = Utils.StringToBytes(invString.BuildString); @@ -689,6 +713,7 @@ namespace OpenSim.Region.Framework.Scenes if (fileData.Length > 2) { + m_log.Debug("Sending task inventory list of " + count.ToString() + " items to client " + client.AgentId.ToString()); xferManager.AddNewFile(m_inventoryFileName, fileData); } } @@ -701,10 +726,9 @@ namespace OpenSim.Region.Framework.Scenes { if (HasInventoryChanged) { - lock (Items) - { - datastore.StorePrimInventory(m_part.UUID, Items.Values); - } + Items.LockItemsForRead(true); + datastore.StorePrimInventory(m_part.UUID, Items.Values); + Items.LockItemsForRead(false); HasInventoryChanged = false; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4e5fee1..4c8c94f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1615,21 +1615,19 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); if (part != null) { + part.TaskInventory.LockItemsForRead(true); TaskInventoryDictionary taskIDict = part.TaskInventory; if (taskIDict != null) { - lock (taskIDict) + foreach (UUID taskID in taskIDict.Keys) { - foreach (UUID taskID in taskIDict.Keys) - { - UnRegisterControlEventsToScript(LocalId, taskID); - taskIDict[taskID].PermsMask &= ~( - 2048 | //PERMISSION_CONTROL_CAMERA - 4); // PERMISSION_TAKE_CONTROLS - } + UnRegisterControlEventsToScript(LocalId, taskID); + taskIDict[taskID].PermsMask &= ~( + 2048 | //PERMISSION_CONTROL_CAMERA + 4); // PERMISSION_TAKE_CONTROLS } - } + part.TaskInventory.LockItemsForRead(false); // Reset sit target. if (part.GetAvatarOnSitTarget() == UUID) part.SetAvatarOnSitTarget(UUID.Zero); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b549b5c..a94cd46 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -275,40 +275,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected UUID InventorySelf() { UUID invItemID = new UUID(); - - lock (m_host.TaskInventory) + bool unlock = false; + if (!m_host.TaskInventory.IsReadLockedByMe()) + { + m_host.TaskInventory.LockItemsForRead(true); + unlock = true; + } + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) { - if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) - { - invItemID = inv.Key; - break; - } + invItemID = inv.Key; + break; } } - + if (unlock) + { + m_host.TaskInventory.LockItemsForRead(false); + } return invItemID; } protected UUID InventoryKey(string name, int type) { m_host.AddScriptLPS(1); - - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == name) { - if (inv.Value.Name == name) + m_host.TaskInventory.LockItemsForRead(false); + + if (inv.Value.Type != type) { - if (inv.Value.Type != type) - return UUID.Zero; - - return inv.Value.AssetID; + return UUID.Zero; } + + return inv.Value.AssetID; } } + m_host.TaskInventory.LockItemsForRead(false); return UUID.Zero; } @@ -316,17 +324,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + + m_host.TaskInventory.LockItemsForRead(true); + + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == name) { - if (inv.Value.Name == name) - { - return inv.Value.AssetID; - } + m_host.TaskInventory.LockItemsForRead(false); + return inv.Value.AssetID; } } + m_host.TaskInventory.LockItemsForRead(false); + + return UUID.Zero; } @@ -2537,12 +2549,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); + m_host.TaskInventory.LockItemsForRead(true); TaskInventoryItem item = m_host.TaskInventory[invItemID]; - - lock (m_host.TaskInventory) - { - item = m_host.TaskInventory[invItemID]; - } + m_host.TaskInventory.LockItemsForRead(false); if (item.PermsGranter == UUID.Zero) return 0; @@ -2617,6 +2626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (dist > m_ScriptDistanceFactor * 10.0f) return; + //Clone is thread-safe TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); foreach (KeyValuePair inv in partInventory) @@ -2750,13 +2760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { TaskInventoryItem item; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + if (!m_host.TaskInventory.ContainsKey(InventorySelf())) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) - return; - else - item = m_host.TaskInventory[InventorySelf()]; + m_host.TaskInventory.LockItemsForRead(false); + return; + } + else + { + item = m_host.TaskInventory[InventorySelf()]; } + m_host.TaskInventory.LockItemsForRead(false); if (item.PermsGranter != UUID.Zero) { @@ -2778,13 +2792,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { 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); @@ -2821,14 +2843,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api TaskInventoryItem item; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + + if (!m_host.TaskInventory.ContainsKey(InventorySelf())) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) - return; - else - item = m_host.TaskInventory[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; @@ -2853,13 +2881,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api TaskInventoryItem item; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + + if (!m_host.TaskInventory.ContainsKey(InventorySelf())) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) - return; - else - item = m_host.TaskInventory[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; @@ -3083,14 +3117,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api TaskInventoryItem item; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + if (!m_host.TaskInventory.ContainsKey(InventorySelf())) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) - return; - else - item = m_host.TaskInventory[InventorySelf()]; + m_host.TaskInventory.LockItemsForRead(false); + return; } - + else + { + item = m_host.TaskInventory[InventorySelf()]; + } + m_host.TaskInventory.LockItemsForRead(false); if (item.PermsGranter == UUID.Zero) return; @@ -3120,13 +3157,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api TaskInventoryItem item; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + if (!m_host.TaskInventory.ContainsKey(InventorySelf())) { - if (!m_host.TaskInventory.ContainsKey(InventorySelf())) - return; - else - item = m_host.TaskInventory[InventorySelf()]; + m_host.TaskInventory.LockItemsForRead(false); + return; } + else + { + item = m_host.TaskInventory[InventorySelf()]; + } + m_host.TaskInventory.LockItemsForRead(false); + if (item.PermsGranter == UUID.Zero) return; @@ -3199,10 +3241,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api TaskInventoryItem item; - lock (m_host.TaskInventory) + + 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 { @@ -3234,11 +3284,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms { - lock (m_host.TaskInventory) - { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = perm; - } + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[invItemID].PermsGranter = agentID; + m_host.TaskInventory[invItemID].PermsMask = perm; + m_host.TaskInventory.LockItemsForWrite(false); m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( "run_time_permissions", new Object[] { @@ -3258,11 +3307,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms { - lock (m_host.TaskInventory) - { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = perm; - } + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[invItemID].PermsGranter = agentID; + m_host.TaskInventory[invItemID].PermsMask = perm; + m_host.TaskInventory.LockItemsForWrite(false); m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( "run_time_permissions", new Object[] { @@ -3283,11 +3331,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!m_waitingForScriptAnswer) { - lock (m_host.TaskInventory) - { - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = 0; - } + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[invItemID].PermsGranter = agentID; + m_host.TaskInventory[invItemID].PermsMask = 0; + m_host.TaskInventory.LockItemsForWrite(false); presence.ControllingClient.OnScriptAnswer += handleScriptAnswer; m_waitingForScriptAnswer=true; @@ -3322,10 +3369,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0) llReleaseControls(); - lock (m_host.TaskInventory) - { - m_host.TaskInventory[invItemID].PermsMask = answer; - } + + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[invItemID].PermsMask = answer; + m_host.TaskInventory.LockItemsForWrite(false); + m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( "run_time_permissions", new Object[] { @@ -3337,16 +3385,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + + foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) + if (item.Type == 10 && item.ItemID == m_itemID) { - if (item.Type == 10 && item.ItemID == m_itemID) - { - return item.PermsGranter.ToString(); - } + m_host.TaskInventory.LockItemsForRead(false); + return item.PermsGranter.ToString(); } } + m_host.TaskInventory.LockItemsForRead(false); return UUID.Zero.ToString(); } @@ -3355,19 +3404,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + + foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) + if (item.Type == 10 && item.ItemID == m_itemID) { - if (item.Type == 10 && item.ItemID == m_itemID) - { - int perms = item.PermsMask; - if (m_automaticLinkPermission) - perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; - return perms; - } + int perms = item.PermsMask; + if (m_automaticLinkPermission) + perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; + m_host.TaskInventory.LockItemsForRead(false); + return perms; } } + m_host.TaskInventory.LockItemsForRead(false); return 0; } @@ -3400,11 +3450,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID invItemID = InventorySelf(); TaskInventoryItem item; - lock (m_host.TaskInventory) - { - item = m_host.TaskInventory[invItemID]; - } - + m_host.TaskInventory.LockItemsForRead(true); + item = m_host.TaskInventory[invItemID]; + m_host.TaskInventory.LockItemsForRead(false); + if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { @@ -3457,16 +3506,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); UUID invItemID = InventorySelf(); - lock (m_host.TaskInventory) - { + m_host.TaskInventory.LockItemsForRead(true); if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0 && !m_automaticLinkPermission) { ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!"); + m_host.TaskInventory.LockItemsForRead(false); return; } - } - + m_host.TaskInventory.LockItemsForRead(false); + if (linknum < ScriptBaseClass.LINK_THIS) return; @@ -3635,17 +3684,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); int count = 0; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Type == type || type == -1) { - if (inv.Value.Type == type || type == -1) - { - count = count + 1; - } + count = count + 1; } } - + + m_host.TaskInventory.LockItemsForRead(false); return count; } @@ -3654,16 +3702,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); ArrayList keys = new ArrayList(); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Type == type || type == -1) { - if (inv.Value.Type == type || type == -1) - { - keys.Add(inv.Value.Name); - } + keys.Add(inv.Value.Name); } } + m_host.TaskInventory.LockItemsForRead(false); if (keys.Count == 0) { @@ -3700,20 +3747,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // move the first object found with this inventory name - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == inventory) { - if (inv.Value.Name == inventory) - { - found = true; - objId = inv.Key; - assetType = inv.Value.Type; - objName = inv.Value.Name; - break; - } + found = true; + objId = inv.Key; + assetType = inv.Value.Type; + objName = inv.Value.Name; + break; } } + m_host.TaskInventory.LockItemsForRead(false); if (!found) { @@ -3763,20 +3809,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) + if (item.Name == name) { - if (item.Name == name) - { - if (item.ItemID == m_itemID) - throw new ScriptDeleteException(); - else - m_host.Inventory.RemoveInventoryItem(item.ItemID); - return; - } + if (item.ItemID == m_itemID) + throw new ScriptDeleteException(); + else + m_host.Inventory.RemoveInventoryItem(item.ItemID); + + m_host.TaskInventory.LockItemsForRead(false); + return; } } + m_host.TaskInventory.LockItemsForRead(false); } public void llSetText(string text, LSL_Vector color, double alpha) @@ -3865,6 +3912,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + //Clone is thread safe TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); foreach (TaskInventoryItem item in itemDictionary.Values) @@ -3955,17 +4003,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID soundId = UUID.Zero; if (!UUID.TryParse(impact_sound, out soundId)) { - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) + if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) { - if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) - { - soundId = item.AssetID; - break; - } + soundId = item.AssetID; + break; } } + m_host.TaskInventory.LockItemsForRead(false); } m_host.CollisionSound = soundId; m_host.CollisionSoundVolume = (float)impact_volume; @@ -4011,6 +4058,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID partItemID; foreach (SceneObjectPart part in parts) { + //Clone is thread safe TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone(); foreach (TaskInventoryItem item in itemsDictionary.Values) @@ -4218,17 +4266,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) + if (item.Type == 10 && item.ItemID == m_itemID) { - if (item.Type == 10 && item.ItemID == m_itemID) - { - result = item.Name!=null?item.Name:String.Empty; - break; - } + result = item.Name!=null?item.Name:String.Empty; + break; } } + m_host.TaskInventory.LockItemsForRead(false); return result; } @@ -4486,23 +4533,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == name) { - if (inv.Value.Name == name) + if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) { - if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) - { - return inv.Value.AssetID.ToString(); - } - else - { - return UUID.Zero.ToString(); - } + m_host.TaskInventory.LockItemsForRead(false); + return inv.Value.AssetID.ToString(); + } + else + { + m_host.TaskInventory.LockItemsForRead(false); + return UUID.Zero.ToString(); } } } + m_host.TaskInventory.LockItemsForRead(false); return UUID.Zero.ToString(); } @@ -5997,14 +6045,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected UUID GetTaskInventoryItem(string name) { - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == name) { - if (inv.Value.Name == name) - return inv.Key; + m_host.TaskInventory.LockItemsForRead(false); + return inv.Key; } } + m_host.TaskInventory.LockItemsForRead(false); return UUID.Zero; } @@ -6315,22 +6365,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // copy the first script found with this inventory name - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == name) { - if (inv.Value.Name == name) + // make sure the object is a script + if (10 == inv.Value.Type) { - // make sure the object is a script - if (10 == inv.Value.Type) - { - found = true; - srcId = inv.Key; - break; - } + found = true; + srcId = inv.Key; + break; } } } + m_host.TaskInventory.LockItemsForRead(false); if (!found) { @@ -8133,28 +8182,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == item) { - if (inv.Value.Name == item) + m_host.TaskInventory.LockItemsForRead(false); + switch (mask) { - switch (mask) - { - case 0: - return (int)inv.Value.BasePermissions; - case 1: - return (int)inv.Value.CurrentPermissions; - case 2: - return (int)inv.Value.GroupPermissions; - case 3: - return (int)inv.Value.EveryonePermissions; - case 4: - return (int)inv.Value.NextPermissions; - } + case 0: + return (int)inv.Value.BasePermissions; + case 1: + return (int)inv.Value.CurrentPermissions; + case 2: + return (int)inv.Value.GroupPermissions; + case 3: + return (int)inv.Value.EveryonePermissions; + case 4: + return (int)inv.Value.NextPermissions; } } } + m_host.TaskInventory.LockItemsForRead(false); return -1; } @@ -8169,16 +8218,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == item) { - if (inv.Value.Name == item) - { - return inv.Value.CreatorID.ToString(); - } + m_host.TaskInventory.LockItemsForRead(false); + return inv.Value.CreatorID.ToString(); } } + m_host.TaskInventory.LockItemsForRead(false); llSay(0, "No item name '" + item + "'"); @@ -8702,16 +8751,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == name) { - if (inv.Value.Name == name) - { - return inv.Value.Type; - } + m_host.TaskInventory.LockItemsForRead(false); + return inv.Value.Type; } } + m_host.TaskInventory.LockItemsForRead(false); return -1; } @@ -8742,17 +8791,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (invItemID == UUID.Zero) return new LSL_Vector(); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) { - if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) - return new LSL_Vector(); + 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"); - return new LSL_Vector(); - } + if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + { + ShoutError("No permissions to track the camera"); + m_host.TaskInventory.LockItemsForRead(false); + return new LSL_Vector(); } + m_host.TaskInventory.LockItemsForRead(false); ScenePresence presence = World.GetScenePresence(m_host.OwnerID); if (presence != null) @@ -8770,17 +8822,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (invItemID == UUID.Zero) return new LSL_Rotation(); - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) { - if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) - return new LSL_Rotation(); - - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) - { - ShoutError("No permissions to track the camera"); - return new LSL_Rotation(); - } + 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"); + m_host.TaskInventory.LockItemsForRead(false); + return new LSL_Rotation(); + } + m_host.TaskInventory.LockItemsForRead(false); ScenePresence presence = World.GetScenePresence(m_host.OwnerID); if (presence != null) @@ -8930,14 +8984,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (objectID == UUID.Zero) return; UUID agentID; - lock (m_host.TaskInventory) - { - // we need the permission first, to know which avatar we want to set the camera for - agentID = m_host.TaskInventory[invItemID].PermsGranter; + m_host.TaskInventory.LockItemsForRead(true); + // we need the permission first, to know which avatar we want to set the camera for + agentID = m_host.TaskInventory[invItemID].PermsGranter; - if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; + if (agentID == UUID.Zero) + { + m_host.TaskInventory.LockItemsForRead(false); + return; + } + if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) + { + m_host.TaskInventory.LockItemsForRead(false); + return; } + m_host.TaskInventory.LockItemsForRead(false); ScenePresence presence = World.GetScenePresence(agentID); @@ -8987,12 +9048,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // we need the permission first, to know which avatar we want to clear the camera for UUID agentID; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + agentID = m_host.TaskInventory[invItemID].PermsGranter; + if (agentID == UUID.Zero) { - agentID = m_host.TaskInventory[invItemID].PermsGranter; - if (agentID == UUID.Zero) return; - if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return; + m_host.TaskInventory.LockItemsForRead(false); + return; } + if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) + { + m_host.TaskInventory.LockItemsForRead(false); + return; + } + m_host.TaskInventory.LockItemsForRead(false); ScenePresence presence = World.GetScenePresence(agentID); @@ -9449,15 +9517,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal UUID ScriptByName(string name) { - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + + foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) + if (item.Type == 10 && item.Name == name) { - if (item.Type == 10 && item.Name == name) - return item.ItemID; + m_host.TaskInventory.LockItemsForRead(false); + return item.ItemID; } } + m_host.TaskInventory.LockItemsForRead(false); + return UUID.Zero; } @@ -9498,6 +9570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + //Clone is thread safe TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); UUID assetID = UUID.Zero; @@ -9560,6 +9633,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + //Clone is thread safe TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); UUID assetID = UUID.Zero; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7fdbac8..83322eb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -728,18 +728,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (target != null) { UUID animID=UUID.Zero; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == animation) { - if (inv.Value.Name == animation) - { - if (inv.Value.Type == (int)AssetType.Animation) - animID = inv.Value.AssetID; - continue; - } + if (inv.Value.Type == (int)AssetType.Animation) + animID = inv.Value.AssetID; + continue; } } + m_host.TaskInventory.LockItemsForRead(false); if (animID == UUID.Zero) target.Animator.AddAnimation(animation, m_host.UUID); else @@ -761,18 +760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (target != null) { UUID animID=UUID.Zero; - lock (m_host.TaskInventory) + m_host.TaskInventory.LockItemsForRead(true); + foreach (KeyValuePair inv in m_host.TaskInventory) { - foreach (KeyValuePair inv in m_host.TaskInventory) + if (inv.Value.Name == animation) { - if (inv.Value.Name == animation) - { - if (inv.Value.Type == (int)AssetType.Animation) - animID = inv.Value.AssetID; - continue; - } + if (inv.Value.Type == (int)AssetType.Animation) + animID = inv.Value.AssetID; + continue; } } + m_host.TaskInventory.LockItemsForRead(false); if (animID == UUID.Zero) target.Animator.RemoveAnimation(animation); @@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(name, out assetID)) { + m_host.TaskInventory.LockItemsForRead(true); foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { if (item.Type == 7 && item.Name == name) @@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api assetID = item.AssetID; } } + m_host.TaskInventory.LockItemsForRead(false); } if (assetID == UUID.Zero) @@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(name, out assetID)) { + m_host.TaskInventory.LockItemsForRead(true); foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { if (item.Type == 7 && item.Name == name) @@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api assetID = item.AssetID; } } + m_host.TaskInventory.LockItemsForRead(false); } if (assetID == UUID.Zero) @@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!UUID.TryParse(name, out assetID)) { + m_host.TaskInventory.LockItemsForRead(true); foreach (TaskInventoryItem item in m_host.TaskInventory.Values) { if (item.Type == 7 && item.Name == name) @@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api assetID = item.AssetID; } } + m_host.TaskInventory.LockItemsForRead(false); } if (assetID == UUID.Zero) diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 063d50f..0f4a9ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -238,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (part != null) { - lock (part.TaskInventory) + part.TaskInventory.LockItemsForRead(true); + if (part.TaskInventory.ContainsKey(m_ItemID)) { - if (part.TaskInventory.ContainsKey(m_ItemID)) - { - m_thisScriptTask = part.TaskInventory[m_ItemID]; - } + m_thisScriptTask = part.TaskInventory[m_ItemID]; } + part.TaskInventory.LockItemsForRead(false); } ApiManager am = new ApiManager(); @@ -429,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { int permsMask; UUID permsGranter; - lock (part.TaskInventory) + part.TaskInventory.LockItemsForRead(true); + if (!part.TaskInventory.ContainsKey(m_ItemID)) { - if (!part.TaskInventory.ContainsKey(m_ItemID)) - return; - - permsGranter = part.TaskInventory[m_ItemID].PermsGranter; - permsMask = part.TaskInventory[m_ItemID].PermsMask; + part.TaskInventory.LockItemsForRead(false); + return; } + permsGranter = part.TaskInventory[m_ItemID].PermsGranter; + permsMask = part.TaskInventory[m_ItemID].PermsMask; + part.TaskInventory.LockItemsForRead(false); if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0) { -- cgit v1.1 From 8383bde76880fc94a6644422d45baa28252b0231 Mon Sep 17 00:00:00 2001 From: CasperW Date: Tue, 24 Nov 2009 18:18:19 +0100 Subject: Removed some extra debug chatter --- .../CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d9a021f..b60b32b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -389,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { // Check if this is ours to handle // - m_log.Info("OnFridInstantMessage"); + //m_log.Info("OnFridInstantMessage"); if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered) return; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4dc709e..abb04cd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -713,7 +713,6 @@ namespace OpenSim.Region.Framework.Scenes if (fileData.Length > 2) { - m_log.Debug("Sending task inventory list of " + count.ToString() + " items to client " + client.AgentId.ToString()); xferManager.AddNewFile(m_inventoryFileName, fileData); } } -- cgit v1.1 From 88ead9ee63fe87b16d7c24b3a38bf6567f3166f6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Nov 2009 17:28:38 +0000 Subject: pass all command parameters to load/save oar, not just the filename unfortunately, these commands cannot yet be properly relocated to the region modules due to deficiencies in the region module infrastructure --- OpenSim/Region/Application/OpenSim.cs | 18 ++--------- OpenSim/Region/Application/OpenSimBase.cs | 5 --- .../CoreModules/World/Archiver/ArchiverModule.cs | 37 ++++++++++++++++++++++ .../Framework/Interfaces/IRegionArchiverModule.cs | 5 ++- OpenSim/Region/Framework/Scenes/SceneManager.cs | 12 +++---- 5 files changed, 49 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 60c34df..f9be1e2 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -1294,14 +1294,7 @@ namespace OpenSim { try { - if (cmdparams.Length > 2) - { - m_sceneManager.LoadArchiveToCurrentScene(cmdparams[2]); - } - else - { - m_sceneManager.LoadArchiveToCurrentScene(DEFAULT_OAR_BACKUP_FILENAME); - } + m_sceneManager.LoadArchiveToCurrentScene(cmdparams); } catch (Exception e) { @@ -1315,14 +1308,7 @@ namespace OpenSim /// protected void SaveOar(string module, string[] cmdparams) { - if (cmdparams.Length > 2) - { - m_sceneManager.SaveCurrentSceneToArchive(cmdparams[2]); - } - else - { - m_sceneManager.SaveCurrentSceneToArchive(DEFAULT_OAR_BACKUP_FILENAME); - } + m_sceneManager.SaveCurrentSceneToArchive(cmdparams); } private static string CombineParams(string[] commandParams, int pos) diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index cc18f1a..391856b 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -75,11 +75,6 @@ namespace OpenSim /// protected const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml"; - /// - /// The file used to load and save an opensimulator archive if no filename has been specified - /// - protected const string DEFAULT_OAR_BACKUP_FILENAME = "region.oar"; - public ConfigSettings ConfigurationSettings { get { return m_configSettings; } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 8d4f91b..181f4c6 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -45,6 +45,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver private Scene m_scene; + /// + /// The file used to load and save an opensimulator archive if no filename has been specified + /// + protected const string DEFAULT_OAR_BACKUP_FILENAME = "region.oar"; + public string Name { get { return "RegionArchiverModule"; } @@ -80,6 +85,38 @@ namespace OpenSim.Region.CoreModules.World.Archiver { } + /// + /// Load a whole region from an opensimulator archive. + /// + /// + public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) + { + if (cmdparams.Length > 2) + { + DearchiveRegion(cmdparams[2]); + } + else + { + DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME); + } + } + + /// + /// Save a region to a file, including all the assets needed to restore it. + /// + /// + public void HandleSaveOarConsoleCommand(string module, string[] cmdparams) + { + if (cmdparams.Length > 2) + { + ArchiveRegion(cmdparams[2]); + } + else + { + ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME); + } + } + public void ArchiveRegion(string savePath) { ArchiveRegion(savePath, Guid.Empty); diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs index 9ad2036..1a8babc 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs @@ -34,7 +34,10 @@ namespace OpenSim.Region.Framework.Interfaces /// Interface to region archive functionality /// public interface IRegionArchiverModule - { + { + void HandleLoadOarConsoleCommand(string module, string[] cmdparams); + void HandleSaveOarConsoleCommand(string module, string[] cmdparams); + /// /// Archive the region to the given path /// diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index dfaa7ea..c2e3370 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -241,24 +241,24 @@ namespace OpenSim.Region.Framework.Scenes /// Save the current scene to an OpenSimulator archive. This archive will eventually include the prim's assets /// as well as the details of the prims themselves. /// - /// - public void SaveCurrentSceneToArchive(string filename) + /// + public void SaveCurrentSceneToArchive(string[] cmdparams) { IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface(); if (archiver != null) - archiver.ArchiveRegion(filename); + archiver.HandleSaveOarConsoleCommand(string.Empty, cmdparams); } /// /// Load an OpenSim archive into the current scene. This will load both the shapes of the prims and upload /// their assets to the asset service. /// - /// - public void LoadArchiveToCurrentScene(string filename) + /// + public void LoadArchiveToCurrentScene(string[] cmdparams) { IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface(); if (archiver != null) - archiver.DearchiveRegion(filename); + archiver.HandleLoadOarConsoleCommand(string.Empty, cmdparams); } public string SaveCurrentSceneMapToXmlString() -- cgit v1.1 From 73dcbbd57ac3272bb416e20280a791aa03d2a185 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Nov 2009 17:32:14 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 07466e2..4221212 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -8130,8 +8130,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP //lsrp.RequestData.RequestFlags; //lsrp.RequestData.Filter; - return true; +// return true; } + private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack) { RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; @@ -8152,6 +8153,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } return true; } + private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack) { -- cgit v1.1 From c083ab682425d13a7369e3f82c82ccbc3c65102a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Nov 2009 17:47:09 +0000 Subject: make save and load oar slightly more robust by always closing the archive streams even if there has been an error --- .../World/Archiver/ArchiveReadRequest.cs | 15 ++++++++------- .../World/Archiver/ArchiveWriteRequestExecution.cs | 22 ++++++++++++++++------ .../Archiver/ArchiveWriteRequestPreparation.cs | 6 ++++++ 3 files changed, 30 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 70a225e..34b81d8 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -103,14 +103,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver List serialisedSceneObjects = new List(); List serialisedParcels = new List(); string filePath = "NONE"; + + TarArchiveReader archive = new TarArchiveReader(m_loadStream); + byte[] data; + TarArchiveReader.TarEntryType entryType; try { - TarArchiveReader archive = new TarArchiveReader(m_loadStream); - - byte[] data; - TarArchiveReader.TarEntryType entryType; - while ((data = archive.ReadEntry(out filePath, out entryType)) != null) { //m_log.DebugFormat( @@ -152,8 +151,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver } //m_log.Debug("[ARCHIVER]: Reached end of archive"); - - archive.Close(); } catch (Exception e) { @@ -163,6 +160,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); return; } + finally + { + archive.Close(); + } m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index f039be8..75c4557 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -80,6 +80,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected internal void ReceivedAllAssets( ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) { + try + { + Save(assetsFoundUuids, assetsNotFoundUuids); + } + finally + { + m_archiveWriter.Close(); + } + + m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName); + + m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty); + } + + protected internal void Save(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) + { foreach (UUID uuid in assetsNotFoundUuids) { m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid); @@ -143,12 +159,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver } m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); - - m_archiveWriter.Close(); - - m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName); - - m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty); } /// diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 9e4fbbe..f08d8ec 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -56,6 +56,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// Constructor /// + /// + /// The path to which to save data. + /// The id associated with this request + /// + /// If there was a problem opening a stream for the file specified by the savePath + /// public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) { m_scene = scene; -- cgit v1.1 From f605d59136ef5a6ada9f332fb775f58adc1ec36a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 24 Nov 2009 18:27:31 +0000 Subject: Make load/save iar slightly better in the face of io failures by always attempting to close the streams --- .../Archiver/InventoryArchiveReadRequest.cs | 68 ++++++++++---------- .../Archiver/InventoryArchiveWriteRequest.cs | 72 ++++++++++++---------- 2 files changed, 77 insertions(+), 63 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 9e76d79..8532d03 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -121,45 +121,51 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver byte[] data; TarArchiveReader.TarEntryType entryType; - while ((data = archive.ReadEntry(out filePath, out entryType)) != null) - { - if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) - { - if (LoadAsset(filePath, data)) - successfulAssetRestores++; - else - failedAssetRestores++; - if ((successfulAssetRestores) % 50 == 0) - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Loaded {0} assets...", - successfulAssetRestores); - } - else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) + try + { + while ((data = archive.ReadEntry(out filePath, out entryType)) != null) { - InventoryFolderBase foundFolder - = ReplicateArchivePathToUserInventory( - filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, - rootDestinationFolder, foldersCreated, nodesLoaded); - - if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) + if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { - InventoryItemBase item = LoadItem(data, foundFolder); - - if (item != null) + if (LoadAsset(filePath, data)) + successfulAssetRestores++; + else + failedAssetRestores++; + + if ((successfulAssetRestores) % 50 == 0) + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Loaded {0} assets...", + successfulAssetRestores); + } + else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) + { + InventoryFolderBase foundFolder + = ReplicateArchivePathToUserInventory( + filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, + rootDestinationFolder, foldersCreated, nodesLoaded); + + if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) { - successfulItemRestores++; - - // If we're loading an item directly into the given destination folder then we need to record - // it separately from any loaded root folders - if (rootDestinationFolder == foundFolder) - nodesLoaded.Add(item); + InventoryItemBase item = LoadItem(data, foundFolder); + + if (item != null) + { + successfulItemRestores++; + + // If we're loading an item directly into the given destination folder then we need to record + // it separately from any loaded root folders + if (rootDestinationFolder == foundFolder) + nodesLoaded.Add(item); + } } } } } - - archive.Close(); + finally + { + archive.Close(); + } m_log.DebugFormat( "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 6e11f36..c85d974 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -117,19 +117,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) - { - // We're almost done. Just need to write out the control file now - m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); - m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); - + { Exception reportedException = null; bool succeeded = true; - + try - { + { + // We're almost done. Just need to write out the control file now + m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); + m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); + m_archiveWriter.Close(); } - catch (IOException e) + catch (Exception e) { m_saveStream.Close(); reportedException = e; @@ -261,39 +261,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); } - m_archiveWriter = new TarArchiveWriter(m_saveStream); - - if (inventoryFolder != null) - { - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", - inventoryFolder.Name, inventoryFolder.ID, m_invPath); - - //recurse through all dirs getting dirs and files - SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); - } - else if (inventoryItem != null) - { - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", - inventoryItem.Name, inventoryItem.ID, m_invPath); - - SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH); - } - else + if (null == inventoryFolder && null == inventoryItem) { // We couldn't find the path indicated - m_saveStream.Close(); string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage); m_module.TriggerInventoryArchiveSaved( m_id, false, m_userInfo, m_invPath, m_saveStream, new Exception(errorMessage)); - return; + return; } + + m_archiveWriter = new TarArchiveWriter(m_saveStream); - // Don't put all this profile information into the archive right now. - //SaveUsers(); + try + { + if (inventoryFolder != null) + { + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", + inventoryFolder.Name, inventoryFolder.ID, m_invPath); + + //recurse through all dirs getting dirs and files + SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); + } + else if (inventoryItem != null) + { + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", + inventoryItem.Name, inventoryItem.ID, m_invPath); + + SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH); + } + + // Don't put all this profile information into the archive right now. + //SaveUsers(); + } + catch (Exception) + { + m_archiveWriter.Close(); + throw; + } new AssetsRequest( new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, -- cgit v1.1 From d5aceb6d95779b19d13eef9f2427c79233166a63 Mon Sep 17 00:00:00 2001 From: CasperW Date: Tue, 24 Nov 2009 23:33:12 +0100 Subject: Append a prefix to the god avatar names appearing in chat whilst in god mode (disabled by default, config entry admin_prefix) --- OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 5c24f03..1e63e3e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat private int m_shoutdistance = 100; private int m_whisperdistance = 10; private List m_scenes = new List(); - + private string m_adminPrefix = ""; internal object m_syncy = new object(); internal IConfig m_config; @@ -76,6 +76,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); + m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", ""); } public virtual void AddRegion(Scene scene) @@ -185,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) { string fromName = c.From; + string fromNamePrefix = ""; UUID fromID = UUID.Zero; string message = c.Message; IScene scene = c.Scene; @@ -207,7 +209,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat fromPos = avatar.AbsolutePosition; fromName = avatar.Name; fromID = c.Sender.AgentId; - + if (avatar.GodLevel > 200) + { + fromNamePrefix = m_adminPrefix; + } break; case ChatSourceType.Object: @@ -227,7 +232,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat s.ForEachScenePresence( delegate(ScenePresence presence) { - TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType); + TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType); } ); } -- cgit v1.1 From abddb60b8d0aba7b68e2494957aedfec66a772cc Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 25 Nov 2009 02:51:11 -0500 Subject: * Attempt number 1 to stop the repeating crouch animation that sometimes happens. * This tries to address it by correcting one potential bug where it never resets the falltimer. * This tries to address it by telling Physics that we're not flying this step.. instead of waiting until the next step when the next agent update comes along. --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 6 ++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 +++ 2 files changed, 9 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 2e4c260..da1104a 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -200,7 +200,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation else if (move.Z < 0f) { if (actor != null && actor.IsColliding) + { + //Console.WriteLine("LAND"); return "LAND"; + } else return "HOVER_DOWN"; } @@ -249,7 +252,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; if (landElapsed <= FALL_DELAY) + { + m_animTickFall = 0; return "LAND"; + } } m_animTickFall = 0; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5604e3d..33717b1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1445,7 +1445,10 @@ namespace OpenSim.Region.Framework.Scenes // nesting this check because LengthSquared() is expensive and we don't // want to do it every step when flying. if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) + { StopFlying(); + m_physicsActor.Flying = false; + } } } -- cgit v1.1 From a642968fd548e7bb7f3e47e937e209526226d0c0 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 25 Nov 2009 04:00:52 -0500 Subject: * Reverting last commit.. because it just made it worse. --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 6 ------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- 2 files changed, 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index da1104a..2e4c260 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -200,10 +200,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation else if (move.Z < 0f) { if (actor != null && actor.IsColliding) - { - //Console.WriteLine("LAND"); return "LAND"; - } else return "HOVER_DOWN"; } @@ -252,10 +249,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; if (landElapsed <= FALL_DELAY) - { - m_animTickFall = 0; return "LAND"; - } } m_animTickFall = 0; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 33717b1..5604e3d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1445,10 +1445,7 @@ namespace OpenSim.Region.Framework.Scenes // nesting this check because LengthSquared() is expensive and we don't // want to do it every step when flying. if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) - { StopFlying(); - m_physicsActor.Flying = false; - } } } -- cgit v1.1 From f9807884a425c2d91e8f2035993a0ca5e210eb43 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Nov 2009 15:28:43 +0000 Subject: Add MIT/X11 licensed NDesk.Options (http://www.ndesk.org/Options) DLL to aid command line parsing --- OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 181f4c6..98fdec3 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -26,9 +26,11 @@ */ using System; +using System.Collections.Generic; using System.IO; using System.Reflection; using log4net; +using NDesk.Options; using Nini.Config; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -91,7 +93,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) { - if (cmdparams.Length > 2) + OptionSet options = new OptionSet() {}; + List mainParams = options.Parse(cmdparams); + + foreach (string param in mainParams) + m_log.DebugFormat("Found param [{0}]", param); + + if (mainParams.Count > 2) { DearchiveRegion(cmdparams[2]); } -- cgit v1.1 From c18422ad3a09cfabd86eb86403a77a6c720980f0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Nov 2009 16:02:47 +0000 Subject: Implement oar merging An oar can now be merged with existing region contents by using the --merge option For example, load oar --merge my.oar Existing terrain, region settings and parcel data is left in place when an oar is merged. See http://opensimulator.org/wiki/OpenSim_Archives#Usage for more information --- .../Region/CoreModules/World/Archiver/ArchiverModule.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 98fdec3..27763bb 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs @@ -93,19 +93,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) { - OptionSet options = new OptionSet() {}; + bool mergeOar = false; + + OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); List mainParams = options.Parse(cmdparams); - - foreach (string param in mainParams) - m_log.DebugFormat("Found param [{0}]", param); + +// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar); +// +// foreach (string param in mainParams) +// m_log.DebugFormat("GOT PARAM [{0}]", param); if (mainParams.Count > 2) { - DearchiveRegion(cmdparams[2]); + DearchiveRegion(mainParams[2], mergeOar, Guid.Empty); } else { - DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME); + DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty); } } -- cgit v1.1 From a4d2a97bc6ead3aeba4e1be419d976925e5ee470 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Nov 2009 16:14:08 +0000 Subject: minor: remove some mono compiler warnings, add --merge load oar switch to help information --- OpenSim/Region/Application/HGCommands.cs | 2 +- OpenSim/Region/Application/OpenSim.cs | 2 +- OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs index f503db7..7ae161d 100644 --- a/OpenSim/Region/Application/HGCommands.cs +++ b/OpenSim/Region/Application/HGCommands.cs @@ -42,7 +42,7 @@ namespace OpenSim { public class HGCommands { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index f9be1e2..5228e4b 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -232,7 +232,7 @@ namespace OpenSim "Save named prim to XML2", SavePrimsXml2); m_console.Commands.AddCommand("region", false, "load oar", - "load oar ", + "load oar [--merge] ", "Load a region's data from OAR archive", LoadOar); m_console.Commands.AddCommand("region", false, "save oar", diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index cd59bdb..f4da910 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -57,7 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat #region ISharedRegionModule Members public virtual void Initialise(IConfigSource config) { - m_config = config.Configs["Chat"]; if (null == m_config) -- cgit v1.1 From 40464f6cc6ffc04bb5e4ede3d832e1cde75e9b5b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Nov 2009 16:23:37 +0000 Subject: Change chat config code so that enabled = false actually does disable the chat module --- OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index f4da910..6dacbba 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -62,15 +62,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat if (null == m_config) { m_log.Info("[CHAT]: no config found, plugin disabled"); + m_enabled = false; return; } - if (!m_config.GetBoolean("enabled", false)) + if (!m_config.GetBoolean("enabled", true)) { m_log.Info("[CHAT]: plugin disabled by configuration"); + m_enabled = false; return; } - m_enabled = true; m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); -- cgit v1.1 From c81f37cf82c3a9d2aae92d5f44734fc5098c5b75 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 Nov 2009 17:01:41 +0000 Subject: Change osTeleportAgent parameters from long to int. That numerical range is not even supported by the underlying type, so there is no need to ask for a type the script can not even supply. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++-- OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 83322eb..10165d3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -636,13 +636,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // Teleport functions - public void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { // High because there is no security check. High griefer potential // CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); - ulong regionHandle = Util.UIntsToLong((regionX * (uint)Constants.RegionSize), (regionY * (uint)Constants.RegionSize)); + ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); m_host.AddScriptLPS(1); UUID agentId = new UUID(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 2a403bf..470946a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces // Teleport commands void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); - void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); + void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); // Animation commands diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4928e90..6b88834 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -201,9 +201,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat); } - public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat) + public void osTeleportAgent(string agent, int regionX, int regionY, vector position, vector lookat) { - m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat); + m_OSSL_Functions.osTeleportAgent(agent, regionX, regionY, position, lookat); } public void osTeleportAgent(string agent, vector position, vector lookat) -- cgit v1.1 From 0b380f68d81267550b5adf45e16378e4648df933 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 Nov 2009 17:01:41 +0000 Subject: Change osTeleportAgent parameters from long to int. That numerical range is not even supported by the underlying type, so there is no need to ask for a type the script can not even supply. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 4 ++-- OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7fdbac8..e72fa70 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -636,13 +636,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // Teleport functions - public void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) + public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) { // High because there is no security check. High griefer potential // CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); - ulong regionHandle = Util.UIntsToLong((regionX * (uint)Constants.RegionSize), (regionY * (uint)Constants.RegionSize)); + ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); m_host.AddScriptLPS(1); UUID agentId = new UUID(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 2a403bf..470946a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces // Teleport commands void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); - void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); + void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); // Animation commands diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 4928e90..6b88834 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -201,9 +201,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat); } - public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat) + public void osTeleportAgent(string agent, int regionX, int regionY, vector position, vector lookat) { - m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat); + m_OSSL_Functions.osTeleportAgent(agent, regionX, regionY, position, lookat); } public void osTeleportAgent(string agent, vector position, vector lookat) -- cgit v1.1 From 59caa68e08691d8fac221e2bd42c712d5bcf69aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Nov 2009 17:49:38 +0000 Subject: minor: add doc to a few parcel methods --- .../Archiver/ArchiveWriteRequestPreparation.cs | 10 +++++++++ .../Region/CoreModules/World/Land/LandChannel.cs | 3 ++- .../CoreModules/World/Land/LandManagementModule.cs | 12 ++++++++++- .../Region/Framework/Interfaces/ILandChannel.cs | 25 +++++++++++++++++----- .../RegionCombinerLargeLandChannel.cs | 1 + 5 files changed, 44 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index f08d8ec..71bfe57 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -93,6 +93,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver List entities = m_scene.GetEntities(); List sceneObjects = new List(); + /* + foreach (ILandObject lo in m_scene.LandChannel.AllParcels()) + { + if (name == lo.LandData.Name) + { + // This is the parcel we want + } + } + */ + // Filter entities so that we only have scene objects. // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods // end up having to do this diff --git a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs index 4ed23bb..81024db 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs @@ -105,7 +105,7 @@ namespace OpenSim.Region.CoreModules.World.Land ILandObject obj = new LandObject(UUID.Zero, false, m_scene); obj.LandData.Name = "NO LAND"; return obj; - } + } public List AllParcels() { @@ -154,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_landManagementModule.UpdateLandObject(localID, data); } } + public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) { if (m_landManagementModule != null) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 968f46a..9a2ef50 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -67,7 +67,14 @@ namespace OpenSim.Region.CoreModules.World.Land private const int landArrayMax = ((int)((int)Constants.RegionSize / 4) >= 64) ? (int)((int)Constants.RegionSize / 4) : 64; #pragma warning restore 0429 + /// + /// Local land ids at specified region co-ordinates (region size / 4) + /// private readonly int[,] m_landIDList = new int[landArrayMax, landArrayMax]; + + /// + /// Land objects keyed by local id + /// private readonly Dictionary m_landList = new Dictionary(); private bool m_landPrimCountTainted; @@ -570,6 +577,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (x_float > Constants.RegionSize || x_float <= 0 || y_float > Constants.RegionSize || y_float <= 0) return null; + try { x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0)); @@ -584,6 +592,7 @@ namespace OpenSim.Region.CoreModules.World.Land { return null; } + lock (m_landList) { // Corner case. If an autoreturn happens during sim startup @@ -603,6 +612,7 @@ namespace OpenSim.Region.CoreModules.World.Land // they happen every time at border crossings throw new Exception("Error: Parcel not found at point " + x + ", " + y); } + lock (m_landIDList) { try @@ -617,7 +627,7 @@ namespace OpenSim.Region.CoreModules.World.Land return null; } } - } + } #endregion diff --git a/OpenSim/Region/Framework/Interfaces/ILandChannel.cs b/OpenSim/Region/Framework/Interfaces/ILandChannel.cs index 74f404f..6fe6118 100644 --- a/OpenSim/Region/Framework/Interfaces/ILandChannel.cs +++ b/OpenSim/Region/Framework/Interfaces/ILandChannel.cs @@ -33,26 +33,41 @@ namespace OpenSim.Region.Framework.Interfaces { public interface ILandChannel { - List ParcelsNearPoint(Vector3 position); + /// + /// Get all parcels + /// + /// List AllParcels(); /// - /// Get the land object at the specified point + /// Get the parcel at the specified point /// /// Value between 0 - 256 on the x axis of the point /// Value between 0 - 256 on the y axis of the point /// Land object at the point supplied ILandObject GetLandObject(int x, int y); - ILandObject GetLandObject(int localID); - /// - /// Get the land object at the specified point + /// Get the parcel at the specified point /// /// Value between 0 - 256 on the x axis of the point /// Value between 0 - 256 on the y axis of the point /// Land object at the point supplied ILandObject GetLandObject(float x, float y); + + /// + /// Get the parcels near the specified point + /// + /// + /// + List ParcelsNearPoint(Vector3 position); + + /// + /// Get the parcel given the land's local id. + /// + /// + /// + ILandObject GetLandObject(int localID); bool IsLandPrimCountTainted(); bool IsForcefulBansAllowed(); diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs index 146ec66..9da818a 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs @@ -118,6 +118,7 @@ public class RegionCombinerLargeLandChannel : ILandChannel return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); } } + ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); obj.LandData.Name = "NO LAND"; return obj; -- cgit v1.1 From a3755d831d016d7c4fb75c900663b63a2e6d28c4 Mon Sep 17 00:00:00 2001 From: OpenSim Master Date: Wed, 25 Nov 2009 10:55:33 -0800 Subject: Patch: Fix a bug in LAND animation when the TickCount wraps into negative numbers by Mic Bowman Signed-off-by: Teravus Ovares (Dan Olivares) --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 2e4c260..b37249d 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -247,8 +247,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation else if (m_movementAnimation == "LAND") { float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; - - if (landElapsed <= FALL_DELAY) + if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) return "LAND"; } -- cgit v1.1 From de927adf2709f50d0fe85a1c59e7677d862d0d72 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 Nov 2009 20:01:21 +0000 Subject: Add the dummy "Size" property to the list type --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 3f38bb6..1fc31c5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -429,6 +429,11 @@ namespace OpenSim.Region.ScriptEngine.Shared } } + public int Size + { + get { return 0; } + } + public object[] Data { get { -- cgit v1.1 From b9d22aa8213b62eb0c368b345ccfc105367c1aba Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 26 Nov 2009 01:59:08 +0100 Subject: Add nudge right and left to avatar movement (faster reaction times when stepping left or right.) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4c8c94f..9b04422 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes protected RegionInfo m_regionInfo; protected ulong crossingFromRegion; - private readonly Vector3[] Dir_Vectors = new Vector3[9]; + private readonly Vector3[] Dir_Vectors = new Vector3[11]; private bool m_isNudging = false; // Position of agent's camera in world (region cordinates) @@ -236,6 +236,8 @@ namespace OpenSim.Region.Framework.Scenes DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, + DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, + DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG } @@ -722,12 +724,14 @@ namespace OpenSim.Region.Framework.Scenes Dir_Vectors[5] = -Vector3.UnitZ; //DOWN Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE - Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge + Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE + Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE + Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge } private Vector3[] GetWalkDirectionVectors() { - Vector3[] vector = new Vector3[9]; + Vector3[] vector = new Vector3[11]; vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK vector[2] = Vector3.UnitY; //LEFT @@ -736,13 +740,15 @@ namespace OpenSim.Region.Framework.Scenes vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE - vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge + vector[8] = Vector3.UnitY; //LEFT_NUDGE + vector[9] = -Vector3.UnitY; //RIGHT_NUDGE + vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge return vector; } private bool[] GetDirectionIsNudge() { - bool[] isNudge = new bool[9]; + bool[] isNudge = new bool[11]; isNudge[0] = false; //FORWARD isNudge[1] = false; //BACK isNudge[2] = false; //LEFT @@ -751,7 +757,9 @@ namespace OpenSim.Region.Framework.Scenes isNudge[5] = false; //DOWN isNudge[6] = true; //FORWARD_NUDGE isNudge[7] = true; //BACK_NUDGE - isNudge[8] = true; //DOWN_Nudge + isNudge[8] = true; //LEFT_NUDGE + isNudge[9] = true; //RIGHT_NUDGE + isNudge[10] = true; //DOWN_Nudge return isNudge; } -- cgit v1.1 From 63b6b9cdce6382e2285b1a9d76e68a0ac10602ef Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 26 Nov 2009 02:35:27 +0100 Subject: Added animation support for my last commit --- OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 4 ++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 30a95ce..2c4a4b0 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -158,8 +158,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Check control flags bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS); bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); - bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; - bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; + bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); + bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9b04422..a1bb244 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -742,7 +742,7 @@ namespace OpenSim.Region.Framework.Scenes vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE vector[8] = Vector3.UnitY; //LEFT_NUDGE vector[9] = -Vector3.UnitY; //RIGHT_NUDGE - vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge + vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE return vector; } -- cgit v1.1 From a5f2803c79b8d3a25124bef5f68afd57b5feba96 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 26 Nov 2009 01:34:46 -0500 Subject: * Re-enable the AbsolutePosition = AbsolutePosition in the LSL_Api in the SetRot method if the object is not active physical. This is important for scripted rotating doors. without AbsolutePosition = AbsolutePosition, the door won't rotate. It's also important that we do not use AbsolutePosition = AbsolutePosition if the object is active physical because that would cause a complete rebuild of the object which would break vehicles. This is the best of both worlds right now. Doors as child prim should work again so long as you don't check the Physical box. * Thanks talentraspel * Thanks NixNerd * Thanks KittoFlora * Thanks lockd --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9c62775..fbbbfdc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1987,6 +1987,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; + + // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line + // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt + // It's perfectly okay when the object is not an active physical body though. + // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against + // but only if the object is not physial and active. This is important for rotating doors. + // without the absoluteposition = absoluteposition happening, the doors do not move in the physics + // scene + if (part.PhysActor != null && !part.PhysActor.IsPhysical) + { + part.ParentGroup.ResetChildPrimPhysicsPositions(); + } } /// -- cgit v1.1 From 88842edc95bafeb9f3b2f2ea0ab09394028a0916 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:08:20 +0000 Subject: Remove GetAssemblyName and friends from the SE interface. It's now handled internally --- .../Framework/Interfaces/IEntityInventory.cs | 6 -- .../Region/Framework/Interfaces/IScriptModule.cs | 1 - .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 93 ++------------------- .../Framework/Scenes/SceneObjectPartInventory.cs | 30 ------- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 95 ++++++++++++++++++++-- 5 files changed, 91 insertions(+), 134 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 2c906a2..2998f45 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -185,12 +185,6 @@ namespace OpenSim.Region.Framework.Interfaces List GetInventoryList(); /// - /// Get the names of the assemblies associated with scripts in this inventory. - /// - /// - string[] GetScriptAssemblies(); - - /// /// Get the xml representing the saved states of scripts in this inventory. /// /// diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 10835b9..72bb0f0 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces { string ScriptEngineName { get; } - string GetAssemblyName(UUID itemID); string GetXMLState(UUID itemID); bool CanBeDeleted(UUID itemID); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 3cec77f..9a6f2b8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes public string GetStateSnapshot() { - //m_log.Debug(" >>> GetStateSnapshot <<<"); - - List assemblies = new List(); Dictionary states = new Dictionary(); foreach (SceneObjectPart part in m_parts.Values) { - foreach (string a in part.Inventory.GetScriptAssemblies()) - { - if (a != "" && !assemblies.Contains(a)) - assemblies.Add(a); - } - foreach (KeyValuePair s in part.Inventory.GetScriptStates()) - { states[s.Key] = s.Value; - } } - if (states.Count < 1 || assemblies.Count < 1) + if (states.Count < 1) return ""; XmlDocument xmldoc = new XmlDocument(); @@ -342,94 +331,21 @@ namespace OpenSim.Region.Framework.Scenes xmldoc.AppendChild(rootElement); - XmlElement wrapper = xmldoc.CreateElement("", "Assemblies", - ""); - rootElement.AppendChild(wrapper); - - foreach (string assembly in assemblies) - { - string fn = Path.GetFileName(assembly); - if (fn == String.Empty) - continue; - - String filedata = String.Empty; - - if (File.Exists(assembly+".text")) - { - FileInfo tfi = new FileInfo(assembly+".text"); - - if (tfi == null) - continue; - - Byte[] tdata = new Byte[tfi.Length]; - - try - { - FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read); - tfs.Read(tdata, 0, tdata.Length); - tfs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message); - } - - filedata = new System.Text.ASCIIEncoding().GetString(tdata); - } - else - { - FileInfo fi = new FileInfo(assembly); - - if (fi == null) - continue; - - Byte[] data = new Byte[fi.Length]; - - try - { - FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message); - } - - filedata = System.Convert.ToBase64String(data); - } - XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); - XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); - assemblyName.Value = fn; - assemblyData.Attributes.Append(assemblyName); - - assemblyData.InnerText = filedata; - - wrapper.AppendChild(assemblyData); - } - - wrapper = xmldoc.CreateElement("", "ScriptStates", + XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates", ""); rootElement.AppendChild(wrapper); foreach (KeyValuePair state in states) { - XmlElement stateData = xmldoc.CreateElement("", "State", ""); - - XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", ""); - stateID.Value = state.Key.ToString(); - stateData.Attributes.Append(stateID); - XmlDocument sdoc = new XmlDocument(); sdoc.LoadXml(state.Value); - XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNodeList rootL = sdoc.GetElementsByTagName("State"); XmlNode rootNode = rootL[0]; XmlNode newNode = xmldoc.ImportNode(rootNode, true); - stateData.AppendChild(newNode); - wrapper.AppendChild(stateData); + wrapper.AppendChild(newNode); } return xmldoc.InnerXml; @@ -437,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetState(string objXMLData, UUID RegionID) { +m_log.Debug("SetState called with " + objXMLData); if (objXMLData == String.Empty) return; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index f4ca877..7f49ced 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -857,36 +857,6 @@ namespace OpenSim.Region.Framework.Scenes return ret; } - public string[] GetScriptAssemblies() - { - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - - List ret = new List(); - if (engines == null) // No engine at all - return new string[0]; - - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.InvType == (int)InventoryType.LSL) - { - foreach (IScriptModule e in engines) - { - if (e != null) - { - string n = e.GetAssemblyName(item.ItemID); - if (n != String.Empty) - { - if (!ret.Contains(n)) - ret.Add(n); - break; - } - } - } - } - } - return ret.ToArray(); - } - public Dictionary GetScriptStates() { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a60c0ba..0a9af2c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1245,20 +1245,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - public string GetAssemblyName(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return ""; - return instance.GetAssemblyName(); - } - public string GetXMLState(UUID itemID) { IScriptInstance instance = GetInstance(itemID); if (instance == null) return ""; - return instance.GetXMLState(); + string xml = instance.GetXMLState(); + + XmlDocument sdoc = new XmlDocument(); + sdoc.LoadXml(xml); + XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNode rootNode = rootL[0]; + + // Create + XmlDocument doc = new XmlDocument(); + XmlElement stateData = doc.CreateElement("", "State", ""); + XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); + stateID.Value = itemID.ToString(); + stateData.Attributes.Append(stateID); + XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); + assetID.Value = instance.AssetID.ToString(); + stateData.Attributes.Append(assetID); + doc.AppendChild(stateData); + + // Add ... + XmlNode xmlstate = doc.ImportNode(rootNode, true); + stateData.AppendChild(xmlstate); + + string assemName = instance.GetAssemblyName(); + + string fn = Path.GetFileName(assemName); + + string assem = String.Empty; + + if (File.Exists(assemName + ".text")) + { + FileInfo tfi = new FileInfo(assemName + ".text"); + + if (tfi != null) + { + Byte[] tdata = new Byte[tfi.Length]; + + try + { + FileStream tfs = File.Open(assemName + ".text", + FileMode.Open, FileAccess.Read); + tfs.Read(tdata, 0, tdata.Length); + tfs.Close(); + + assem = new System.Text.ASCIIEncoding().GetString(tdata); + } + catch (Exception e) + { + m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); + } + } + } + else + { + FileInfo fi = new FileInfo(assemName); + + if (fi != null) + { + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + + assem = System.Convert.ToBase64String(data); + } + catch (Exception e) + { + m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); + } + + } + } + + XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); + XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); + + assemblyName.Value = fn; + assemblyData.Attributes.Append(assemblyName); + + assemblyData.InnerText = assem; + + stateData.AppendChild(assemblyData); + + return doc.InnerXml; } public bool CanBeDeleted(UUID itemID) -- cgit v1.1 From 05fc504ff3698ec472c582f26a9ddfdd0ce2c8f6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:16:42 +0000 Subject: Remove the old remoting-type interregion code for prim/script crossing --- OpenSim/Region/Framework/Scenes/Scene.cs | 99 ---------------------- .../Framework/Scenes/SceneCommunicationService.cs | 72 ---------------- 2 files changed, 171 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f444e51..0ee818d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2381,103 +2381,6 @@ namespace OpenSim.Region.Framework.Scenes return successYN; } - /// - /// Handle a scene object that is crossing into this region from another. - /// NOTE: Unused as of 2009-02-09. Soon to be deleted. - /// - /// - /// - /// - /// - /// - public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod) - { - if (XMLMethod == 0) - { - m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID); - SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData); - if (sceneObject.IsAttachment) - sceneObject.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; - - return AddSceneObject(sceneObject); - } - else if ((XMLMethod == 100) && m_allowScriptCrossings) - { - m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor"); - - XmlDocument doc = new XmlDocument(); - doc.LoadXml(objXMLData); - - XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); - if (rootL.Count == 1) - { - XmlNode rootNode = rootL[0]; - if (rootNode != null) - { - XmlNodeList partL = rootNode.ChildNodes; - - foreach (XmlNode part in partL) - { - XmlNodeList nodeL = part.ChildNodes; - - switch (part.Name) - { - case "Assemblies": - foreach (XmlNode asm in nodeL) - { - string fn = asm.Attributes.GetNamedItem("Filename").Value; - - Byte[] filedata = Convert.FromBase64String(asm.InnerText); - string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); - path = Path.Combine(path, fn); - - if (!File.Exists(path)) - { - FileStream fs = File.Create(path); - fs.Write(filedata, 0, filedata.Length); - fs.Close(); - } - } - break; - case "ScriptStates": - foreach (XmlNode st in nodeL) - { - string id = st.Attributes.GetNamedItem("UUID").Value; - UUID uuid = new UUID(id); - XmlNode state = st.ChildNodes[0]; - - XmlDocument sdoc = new XmlDocument(); - XmlNode sxmlnode = sdoc.CreateNode( - XmlNodeType.XmlDeclaration, - "", ""); - sdoc.AppendChild(sxmlnode); - - XmlNode newnode = sdoc.ImportNode(state, true); - sdoc.AppendChild(newnode); - - string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); - spath = Path.Combine(spath, uuid.ToString()); - FileStream sfs = File.Create(spath + ".state"); - ASCIIEncoding enc = new ASCIIEncoding(); - Byte[] buf = enc.GetBytes(sdoc.InnerXml); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - } - break; - } - } - } - } - - SceneObjectPart RootPrim = GetSceneObjectPart(primID); - RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1); - - return true; - } - - return true; - } - public bool IncomingCreateObject(ISceneObject sog) { //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); @@ -3350,7 +3253,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; //m_eventManager.OnRegionUp += OtherRegionUp; //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; - m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; m_sceneGridService.KiPrimitive += SendKillObject; @@ -3374,7 +3276,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.KiPrimitive -= SendKillObject; m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; - m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; //m_eventManager.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= HandleNewUserConnection; diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 76c6cab..3892769 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes /// /// A Prim will arrive shortly /// - public event ExpectPrimDelegate OnExpectPrim; public event CloseAgentConnection OnCloseAgentConnection; /// @@ -116,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; - private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; //private RegionUp handlerRegionUp = null; // OnRegionUp; @@ -147,30 +145,6 @@ namespace OpenSim.Region.Framework.Scenes /// Thrown if region registration fails. public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) { - //m_interregionCommsOut = comms_out; - - //m_regionInfo = regionInfos; - //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; - //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); - - //if (regionCommsHost != null) - //{ - // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); - - // regionCommsHost.debugRegionName = regionInfos.RegionName; - // regionCommsHost.OnExpectPrim += IncomingPrimCrossing; - // regionCommsHost.OnExpectUser += NewUserConnection; - // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; - // regionCommsHost.OnCloseAgentConnection += CloseConnection; - // regionCommsHost.OnRegionUp += newRegionUp; - // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; - // regionCommsHost.OnLogOffUser += GridLogOffUser; - // regionCommsHost.OnGetLandData += FetchLandData; - //} - //else - //{ - // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); - //} } /// @@ -179,31 +153,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void Close() { - - //if (regionCommsHost != null) - //{ - // regionCommsHost.OnLogOffUser -= GridLogOffUser; - // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; - // regionCommsHost.OnRegionUp -= newRegionUp; - // regionCommsHost.OnExpectUser -= NewUserConnection; - // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; - // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; - // regionCommsHost.OnCloseAgentConnection -= CloseConnection; - // regionCommsHost.OnGetLandData -= FetchLandData; - - // try - // { - // m_commsProvider.GridService.DeregisterRegion(m_regionInfo); - // } - // catch (Exception e) - // { - // m_log.ErrorFormat( - // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", - // m_regionInfo.RegionName, e); - // } - - // regionCommsHost = null; - //} } #region CommsManager Event handlers @@ -263,27 +212,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// We have a new prim from a neighbor - /// - /// unique ID for the primative - /// XML2 encoded data of the primative - /// An Int that represents the version of the XMLMethod - /// True if the prim was accepted, false if it was not - protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod) - { - handlerExpectPrim = OnExpectPrim; - if (handlerExpectPrim != null) - { - return handlerExpectPrim(primID, objXMLData, XMLMethod); - } - else - { - return false; - } - - } - protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical) { handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion; -- cgit v1.1 From ac2fcbe224d4877dccc4d73e9c58771e40a4ae1c Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 26 Nov 2009 15:17:44 +0100 Subject: Improvements to rAdmin admin_shutdown and admin_restart. Both methods can now accept a parameter of noticetype = dialog in order to display a blue persistant dropdown instead of a short notice. Added an optional and configurable delay to the restart method, defaulting at 30 seconds as before. Both methods can also accept a noticetype = none dialog in order to act silently. --- OpenSim/Region/Framework/Scenes/Scene.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4ffa1a2..be1d4bf 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -873,6 +873,15 @@ namespace OpenSim.Region.Framework.Scenes /// float indicating duration before restart. public virtual void Restart(float seconds) { + Restart(seconds, true); + } + + /// + /// Given float seconds, this will restart the region. showDialog will optionally alert the users. + /// + /// float indicating duration before restart. + public virtual void Restart(float seconds, bool showDialog) + { // notifications are done in 15 second increments // so .. if the number of seconds is less then 15 seconds, it's not really a restart request // It's a 'Cancel restart' request. @@ -893,8 +902,11 @@ namespace OpenSim.Region.Framework.Scenes m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); m_restartTimer.Start(); - m_dialogModule.SendNotificationToUsersInRegion( - UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes"); + if (showDialog) + { + m_dialogModule.SendNotificationToUsersInRegion( + UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + (seconds / 60).ToString() + " Minutes"); + } } } -- cgit v1.1 From 22c325aa5ae06b897e5eb10404c0aa3727f8237b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:08:20 +0000 Subject: Remove GetAssemblyName and friends from the SE interface. It's now handled internally --- .../Framework/Interfaces/IEntityInventory.cs | 6 -- .../Region/Framework/Interfaces/IScriptModule.cs | 1 - .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 93 ++------------------- .../Framework/Scenes/SceneObjectPartInventory.cs | 30 ------- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 95 ++++++++++++++++++++-- 5 files changed, 91 insertions(+), 134 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 2c906a2..2998f45 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -185,12 +185,6 @@ namespace OpenSim.Region.Framework.Interfaces List GetInventoryList(); /// - /// Get the names of the assemblies associated with scripts in this inventory. - /// - /// - string[] GetScriptAssemblies(); - - /// /// Get the xml representing the saved states of scripts in this inventory. /// /// diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 10835b9..72bb0f0 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -34,7 +34,6 @@ namespace OpenSim.Region.Framework.Interfaces { string ScriptEngineName { get; } - string GetAssemblyName(UUID itemID); string GetXMLState(UUID itemID); bool CanBeDeleted(UUID itemID); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 3cec77f..9a6f2b8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes public string GetStateSnapshot() { - //m_log.Debug(" >>> GetStateSnapshot <<<"); - - List assemblies = new List(); Dictionary states = new Dictionary(); foreach (SceneObjectPart part in m_parts.Values) { - foreach (string a in part.Inventory.GetScriptAssemblies()) - { - if (a != "" && !assemblies.Contains(a)) - assemblies.Add(a); - } - foreach (KeyValuePair s in part.Inventory.GetScriptStates()) - { states[s.Key] = s.Value; - } } - if (states.Count < 1 || assemblies.Count < 1) + if (states.Count < 1) return ""; XmlDocument xmldoc = new XmlDocument(); @@ -342,94 +331,21 @@ namespace OpenSim.Region.Framework.Scenes xmldoc.AppendChild(rootElement); - XmlElement wrapper = xmldoc.CreateElement("", "Assemblies", - ""); - rootElement.AppendChild(wrapper); - - foreach (string assembly in assemblies) - { - string fn = Path.GetFileName(assembly); - if (fn == String.Empty) - continue; - - String filedata = String.Empty; - - if (File.Exists(assembly+".text")) - { - FileInfo tfi = new FileInfo(assembly+".text"); - - if (tfi == null) - continue; - - Byte[] tdata = new Byte[tfi.Length]; - - try - { - FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read); - tfs.Read(tdata, 0, tdata.Length); - tfs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message); - } - - filedata = new System.Text.ASCIIEncoding().GetString(tdata); - } - else - { - FileInfo fi = new FileInfo(assembly); - - if (fi == null) - continue; - - Byte[] data = new Byte[fi.Length]; - - try - { - FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (Exception e) - { - m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message); - } - - filedata = System.Convert.ToBase64String(data); - } - XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); - XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); - assemblyName.Value = fn; - assemblyData.Attributes.Append(assemblyName); - - assemblyData.InnerText = filedata; - - wrapper.AppendChild(assemblyData); - } - - wrapper = xmldoc.CreateElement("", "ScriptStates", + XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates", ""); rootElement.AppendChild(wrapper); foreach (KeyValuePair state in states) { - XmlElement stateData = xmldoc.CreateElement("", "State", ""); - - XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", ""); - stateID.Value = state.Key.ToString(); - stateData.Attributes.Append(stateID); - XmlDocument sdoc = new XmlDocument(); sdoc.LoadXml(state.Value); - XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNodeList rootL = sdoc.GetElementsByTagName("State"); XmlNode rootNode = rootL[0]; XmlNode newNode = xmldoc.ImportNode(rootNode, true); - stateData.AppendChild(newNode); - wrapper.AppendChild(stateData); + wrapper.AppendChild(newNode); } return xmldoc.InnerXml; @@ -437,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetState(string objXMLData, UUID RegionID) { +m_log.Debug("SetState called with " + objXMLData); if (objXMLData == String.Empty) return; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index abb04cd..2ef8258 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -880,36 +880,6 @@ namespace OpenSim.Region.Framework.Scenes return ret; } - public string[] GetScriptAssemblies() - { - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - - List ret = new List(); - if (engines == null) // No engine at all - return new string[0]; - - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.InvType == (int)InventoryType.LSL) - { - foreach (IScriptModule e in engines) - { - if (e != null) - { - string n = e.GetAssemblyName(item.ItemID); - if (n != String.Empty) - { - if (!ret.Contains(n)) - ret.Add(n); - break; - } - } - } - } - } - return ret.ToArray(); - } - public Dictionary GetScriptStates() { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 8b94f28..4dc6cb8 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1248,20 +1248,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - public string GetAssemblyName(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return ""; - return instance.GetAssemblyName(); - } - public string GetXMLState(UUID itemID) { IScriptInstance instance = GetInstance(itemID); if (instance == null) return ""; - return instance.GetXMLState(); + string xml = instance.GetXMLState(); + + XmlDocument sdoc = new XmlDocument(); + sdoc.LoadXml(xml); + XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState"); + XmlNode rootNode = rootL[0]; + + // Create + XmlDocument doc = new XmlDocument(); + XmlElement stateData = doc.CreateElement("", "State", ""); + XmlAttribute stateID = doc.CreateAttribute("", "UUID", ""); + stateID.Value = itemID.ToString(); + stateData.Attributes.Append(stateID); + XmlAttribute assetID = doc.CreateAttribute("", "Asset", ""); + assetID.Value = instance.AssetID.ToString(); + stateData.Attributes.Append(assetID); + doc.AppendChild(stateData); + + // Add ... + XmlNode xmlstate = doc.ImportNode(rootNode, true); + stateData.AppendChild(xmlstate); + + string assemName = instance.GetAssemblyName(); + + string fn = Path.GetFileName(assemName); + + string assem = String.Empty; + + if (File.Exists(assemName + ".text")) + { + FileInfo tfi = new FileInfo(assemName + ".text"); + + if (tfi != null) + { + Byte[] tdata = new Byte[tfi.Length]; + + try + { + FileStream tfs = File.Open(assemName + ".text", + FileMode.Open, FileAccess.Read); + tfs.Read(tdata, 0, tdata.Length); + tfs.Close(); + + assem = new System.Text.ASCIIEncoding().GetString(tdata); + } + catch (Exception e) + { + m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message); + } + } + } + else + { + FileInfo fi = new FileInfo(assemName); + + if (fi != null) + { + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + + assem = System.Convert.ToBase64String(data); + } + catch (Exception e) + { + m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message); + } + + } + } + + XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); + XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); + + assemblyName.Value = fn; + assemblyData.Attributes.Append(assemblyName); + + assemblyData.InnerText = assem; + + stateData.AppendChild(assemblyData); + + return doc.InnerXml; } public bool CanBeDeleted(UUID itemID) -- cgit v1.1 From a27d33cb634c78425eaa34cb5efd113e131baa51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 12:16:42 +0000 Subject: Remove the old remoting-type interregion code for prim/script crossing --- OpenSim/Region/Framework/Scenes/Scene.cs | 99 ---------------------- .../Framework/Scenes/SceneCommunicationService.cs | 72 ---------------- 2 files changed, 171 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index be1d4bf..f932659 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2393,103 +2393,6 @@ namespace OpenSim.Region.Framework.Scenes return successYN; } - /// - /// Handle a scene object that is crossing into this region from another. - /// NOTE: Unused as of 2009-02-09. Soon to be deleted. - /// - /// - /// - /// - /// - /// - public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod) - { - if (XMLMethod == 0) - { - m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID); - SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData); - if (sceneObject.IsAttachment) - sceneObject.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; - - return AddSceneObject(sceneObject); - } - else if ((XMLMethod == 100) && m_allowScriptCrossings) - { - m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor"); - - XmlDocument doc = new XmlDocument(); - doc.LoadXml(objXMLData); - - XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); - if (rootL.Count == 1) - { - XmlNode rootNode = rootL[0]; - if (rootNode != null) - { - XmlNodeList partL = rootNode.ChildNodes; - - foreach (XmlNode part in partL) - { - XmlNodeList nodeL = part.ChildNodes; - - switch (part.Name) - { - case "Assemblies": - foreach (XmlNode asm in nodeL) - { - string fn = asm.Attributes.GetNamedItem("Filename").Value; - - Byte[] filedata = Convert.FromBase64String(asm.InnerText); - string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); - path = Path.Combine(path, fn); - - if (!File.Exists(path)) - { - FileStream fs = File.Create(path); - fs.Write(filedata, 0, filedata.Length); - fs.Close(); - } - } - break; - case "ScriptStates": - foreach (XmlNode st in nodeL) - { - string id = st.Attributes.GetNamedItem("UUID").Value; - UUID uuid = new UUID(id); - XmlNode state = st.ChildNodes[0]; - - XmlDocument sdoc = new XmlDocument(); - XmlNode sxmlnode = sdoc.CreateNode( - XmlNodeType.XmlDeclaration, - "", ""); - sdoc.AppendChild(sxmlnode); - - XmlNode newnode = sdoc.ImportNode(state, true); - sdoc.AppendChild(newnode); - - string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString()); - spath = Path.Combine(spath, uuid.ToString()); - FileStream sfs = File.Create(spath + ".state"); - ASCIIEncoding enc = new ASCIIEncoding(); - Byte[] buf = enc.GetBytes(sdoc.InnerXml); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - } - break; - } - } - } - } - - SceneObjectPart RootPrim = GetSceneObjectPart(primID); - RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1); - - return true; - } - - return true; - } - public bool IncomingCreateObject(ISceneObject sog) { //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); @@ -3362,7 +3265,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; //m_eventManager.OnRegionUp += OtherRegionUp; //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; - m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; m_sceneGridService.KiPrimitive += SendKillObject; @@ -3386,7 +3288,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.KiPrimitive -= SendKillObject; m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; - m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; //m_eventManager.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= HandleNewUserConnection; diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 76c6cab..3892769 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes /// /// A Prim will arrive shortly /// - public event ExpectPrimDelegate OnExpectPrim; public event CloseAgentConnection OnCloseAgentConnection; /// @@ -116,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; - private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; //private RegionUp handlerRegionUp = null; // OnRegionUp; @@ -147,30 +145,6 @@ namespace OpenSim.Region.Framework.Scenes /// Thrown if region registration fails. public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) { - //m_interregionCommsOut = comms_out; - - //m_regionInfo = regionInfos; - //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; - //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); - - //if (regionCommsHost != null) - //{ - // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); - - // regionCommsHost.debugRegionName = regionInfos.RegionName; - // regionCommsHost.OnExpectPrim += IncomingPrimCrossing; - // regionCommsHost.OnExpectUser += NewUserConnection; - // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; - // regionCommsHost.OnCloseAgentConnection += CloseConnection; - // regionCommsHost.OnRegionUp += newRegionUp; - // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; - // regionCommsHost.OnLogOffUser += GridLogOffUser; - // regionCommsHost.OnGetLandData += FetchLandData; - //} - //else - //{ - // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); - //} } /// @@ -179,31 +153,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void Close() { - - //if (regionCommsHost != null) - //{ - // regionCommsHost.OnLogOffUser -= GridLogOffUser; - // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; - // regionCommsHost.OnRegionUp -= newRegionUp; - // regionCommsHost.OnExpectUser -= NewUserConnection; - // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; - // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; - // regionCommsHost.OnCloseAgentConnection -= CloseConnection; - // regionCommsHost.OnGetLandData -= FetchLandData; - - // try - // { - // m_commsProvider.GridService.DeregisterRegion(m_regionInfo); - // } - // catch (Exception e) - // { - // m_log.ErrorFormat( - // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", - // m_regionInfo.RegionName, e); - // } - - // regionCommsHost = null; - //} } #region CommsManager Event handlers @@ -263,27 +212,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// We have a new prim from a neighbor - /// - /// unique ID for the primative - /// XML2 encoded data of the primative - /// An Int that represents the version of the XMLMethod - /// True if the prim was accepted, false if it was not - protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod) - { - handlerExpectPrim = OnExpectPrim; - if (handlerExpectPrim != null) - { - return handlerExpectPrim(primID, objXMLData, XMLMethod); - } - else - { - return false; - } - - } - protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical) { handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion; -- cgit v1.1 From 2bc19a1e23594e00e2bc812d27d4b4804b438bdf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Nov 2009 16:39:30 +0000 Subject: Resolve issue where an iar load fails to preserve original item creators See http://opensimulator.org/mantis/view.php?id=4394 This change preserves the uuid when a profile is found rather than the ospa --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 8 ++++++++ .../Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 2 +- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 8532d03..b778389 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -348,9 +348,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); if (UUID.Zero != ospResolvedId) + { item.CreatorIdAsUuid = ospResolvedId; + + // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the + // database). Instead, replace with the UUID that we found. + item.CreatorId = ospResolvedId.ToString(); + } else + { item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; + } item.Owner = m_userInfo.UserProfile.ID; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 2c0d113..ecd60bd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); m_log.InfoFormat( - "[INVENTORY ARCHIVER]: Saving archive {0} from inventory path {1} for {2} {3}", + "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", savePath, invPath, firstName, lastName); Guid id = Guid.NewGuid(); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 7927352..e4dad18 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -259,9 +259,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name); Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); + +// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the +// UUID, not the OSPA itself. +// Assert.That( +// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), +// "Loaded item non-uuid creator doesn't match original"); Assert.That( - foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), + foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()), "Loaded item non-uuid creator doesn't match original"); + Assert.That( foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), "Loaded item uuid creator doesn't match original"); -- cgit v1.1 From ee0b5abc6236e0204af74c582d67695021b73790 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Nov 2009 16:51:10 +0000 Subject: minor: reduce region ready logging verbosity --- .../Scripting/RegionReadyModule/RegionReadyModule.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 91c25a6..c653e98 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -62,7 +62,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady public void Initialise(IConfigSource config) { - m_log.Info("[RegionReady] Initialising"); + //m_log.Info("[RegionReady] Initialising"); m_config = config.Configs["RegionReady"]; if (m_config != null) @@ -74,8 +74,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } } - if (!m_enabled) - m_log.Info("[RegionReady] disabled."); +// if (!m_enabled) +// m_log.Info("[RegionReady] disabled."); } public void AddRegion(Scene scene) @@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded; - m_log.InfoFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); + m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName); } public void RemoveRegion(Scene scene) @@ -120,7 +120,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady } #endregion - void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) { -- cgit v1.1 From 9d63f90467dbc60622a49f564a56fdd20de90f51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 17:03:09 +0000 Subject: Remove the old (Remoting) region crossing code. Fix the new code to pass script state and assembly again properly. Reintroduce respecting tht TrustBinaries flag. Changes the interregion protocol! No version bump because it was broken anyway, so with a version mismatch it will simply stay broken, but not crash. Region corssing still doesn't work because there is still monkey business with both rezzed prims being pushed across a border and attached prims when walking across a border. Teleport is untested by may work. --- .../Interregion/LocalInterregionComms.cs | 9 +- .../Interregion/RESTInterregionComms.cs | 6 +- .../Framework/Interfaces/IEntityInventory.cs | 2 - .../Region/Framework/Interfaces/IScriptModule.cs | 2 +- .../Scenes/AsyncSceneObjectGroupDeleter.cs | 5 - OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- .../Framework/Scenes/SceneObjectGroup.Inventory.cs | 99 ++++++---------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 11 -- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 - .../Framework/Scenes/SceneObjectPartInventory.cs | 25 ----- .../ScriptEngine/Interfaces/IScriptInstance.cs | 1 - .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 5 - OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 124 +++++++++++++++++++-- 13 files changed, 159 insertions(+), 137 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs index ee809bd..d9f6e33 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs @@ -263,8 +263,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion { // We need to make a local copy of the object ISceneObject sogClone = sog.CloneForNewScene(); - sogClone.SetState(sog.GetStateSnapshot(), - s.RegionInfo.RegionID); + sogClone.SetState(sog.GetStateSnapshot(), s); return s.IncomingCreateObject(sogClone); } else @@ -294,15 +293,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion #region Misc - public UUID GetRegionID(ulong regionhandle) + public Scene GetScene(ulong regionhandle) { foreach (Scene s in m_sceneList) { if (s.RegionInfo.RegionHandle == regionhandle) - return s.RegionInfo.RegionID; + return s; } // ? weird. should not happen - return m_sceneList[0].RegionInfo.RegionID; + return m_sceneList[0]; } public bool IsLocalRegion(ulong regionhandle) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 696225c..710e3ca 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs @@ -641,7 +641,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion if (args["extra"] != null) extraStr = args["extra"].AsString(); - UUID regionID = m_localBackend.GetRegionID(regionhandle); + IScene s = m_localBackend.GetScene(regionhandle); SceneObjectGroup sog = null; try { @@ -663,7 +663,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion { try { - sog.SetState(stateXmlStr, regionID); + sog.SetState(stateXmlStr, s); } catch (Exception ex) { @@ -695,8 +695,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion if (args["itemid"] != null) itemID = args["itemid"].AsUUID(); - //UUID regionID = m_localBackend.GetRegionID(regionhandle); - // This is the meaning of PUT object bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID); diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 2998f45..89a45da 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -191,7 +191,5 @@ namespace OpenSim.Region.Framework.Interfaces /// A /// Dictionary GetScriptStates(); - - bool CanBeDeleted(); } } diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 72bb0f0..f11e571 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces string ScriptEngineName { get; } string GetXMLState(UUID itemID); - bool CanBeDeleted(UUID itemID); + void SetXMLState(UUID itemID, string xml); bool PostScriptEvent(UUID itemID, string name, Object[] args); bool PostObjectEvent(UUID itemID, string name, Object[] args); diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 5b571c7..9a7863b 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs @@ -131,11 +131,6 @@ namespace OpenSim.Region.Framework.Scenes if (left > 0) { x = m_inventoryDeletes.Dequeue(); - if (!x.objectGroup.CanBeDeleted()) - { - m_inventoryDeletes.Enqueue(x); - return true; - } m_log.DebugFormat( "[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0ee818d..eb8567f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -618,7 +618,7 @@ namespace OpenSim.Region.Framework.Scenes startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); m_persistAfter *= 10000000; - m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine"); + m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); IConfig packetConfig = m_config.Configs["PacketPool"]; if (packetConfig != null) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 9a6f2b8..5a06bdb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs @@ -351,12 +351,29 @@ namespace OpenSim.Region.Framework.Scenes return xmldoc.InnerXml; } - public void SetState(string objXMLData, UUID RegionID) + public void SetState(string objXMLData, IScene ins) { -m_log.Debug("SetState called with " + objXMLData); + if (!(ins is Scene)) + return; + + Scene s = (Scene)ins; + if (objXMLData == String.Empty) return; + IScriptModule scriptModule = null; + + foreach (IScriptModule sm in s.RequestModuleInterfaces()) + { + if (sm.ScriptEngineName == s.DefaultScriptEngine) + scriptModule = sm; + else if (scriptModule == null) + scriptModule = sm; + } + + if (scriptModule == null) + return; + XmlDocument doc = new XmlDocument(); try { @@ -374,69 +391,23 @@ m_log.Debug("SetState called with " + objXMLData); } XmlNodeList rootL = doc.GetElementsByTagName("ScriptData"); - if (rootL.Count == 1) + if (rootL.Count != 1) + return; + + XmlElement rootE = (XmlElement)rootL[0]; + + XmlNodeList dataL = rootE.GetElementsByTagName("ScriptStates"); + if (dataL.Count != 1) + return; + + XmlElement dataE = (XmlElement)dataL[0]; + + foreach (XmlNode n in dataE.ChildNodes) { - XmlNode rootNode = rootL[0]; - if (rootNode != null) - { - XmlNodeList partL = rootNode.ChildNodes; - - foreach (XmlNode part in partL) - { - XmlNodeList nodeL = part.ChildNodes; - - switch (part.Name) - { - case "Assemblies": - foreach (XmlNode asm in nodeL) - { - string fn = asm.Attributes.GetNamedItem("Filename").Value; - - Byte[] filedata = Convert.FromBase64String(asm.InnerText); - string path = Path.Combine("ScriptEngines", RegionID.ToString()); - path = Path.Combine(path, fn); - - if (!File.Exists(path)) - { - FileStream fs = File.Create(path); - fs.Write(filedata, 0, filedata.Length); - fs.Close(); - - Byte[] textbytes = new System.Text.ASCIIEncoding().GetBytes(asm.InnerText); - fs = File.Create(path+".text"); - fs.Write(textbytes, 0, textbytes.Length); - fs.Close(); - } - } - break; - case "ScriptStates": - foreach (XmlNode st in nodeL) - { - string id = st.Attributes.GetNamedItem("UUID").Value; - UUID uuid = new UUID(id); - XmlNode state = st.ChildNodes[0]; - - XmlDocument sdoc = new XmlDocument(); - XmlNode sxmlnode = sdoc.CreateNode( - XmlNodeType.XmlDeclaration, - "", ""); - sdoc.AppendChild(sxmlnode); - - XmlNode newnode = sdoc.ImportNode(state, true); - sdoc.AppendChild(newnode); - - string spath = Path.Combine("ScriptEngines", RegionID.ToString()); - spath = Path.Combine(spath, uuid.ToString()); - FileStream sfs = File.Create(spath + ".state"); - System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); - Byte[] buf = enc.GetBytes(sdoc.InnerXml); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - } - break; - } - } - } + XmlElement stateE = (XmlElement)n; + UUID itemID = new UUID(stateE.GetAttribute("UUID")); + + scriptModule.SetXMLState(itemID, n.OuterXml); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bcc9b37..6ec2a01 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3341,17 +3341,6 @@ namespace OpenSim.Region.Framework.Scenes } #endregion - public bool CanBeDeleted() - { - foreach (SceneObjectPart part in Children.Values) - { - if (!part.CanBeDeleted()) - return false; - } - - return true; - } - public double GetUpdatePriority(IClientAPI client) { switch (Scene.UpdatePrioritizationScheme) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6f1b458..b6916f2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3797,10 +3797,5 @@ namespace OpenSim.Region.Framework.Scenes Inventory.ApplyNextOwnerPermissions(); } - - public bool CanBeDeleted() - { - return Inventory.CanBeDeleted(); - } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7f49ced..7a0d7b7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -886,30 +886,5 @@ namespace OpenSim.Region.Framework.Scenes } return ret; } - - public bool CanBeDeleted() - { - if (!ContainsScripts()) - return true; - - IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - - if (engines == null) // No engine at all - return true; - - foreach (TaskInventoryItem item in m_items.Values) - { - if (item.InvType == (int)InventoryType.LSL) - { - foreach (IScriptModule e in engines) - { - if (!e.CanBeDeleted(item.ItemID)) - return false; - } - } - } - - return true; - } } } diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index f49aea8..ae148a9 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -96,7 +96,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces UUID GetDetectID(int idx); void SaveState(string assembly); void DestroyScriptInstance(); - bool CanBeDeleted(); IScriptApi GetApi(string name); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 41b5d49..5c5d57e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -1011,10 +1011,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { get { return m_RegionID; } } - - public bool CanBeDeleted() - { - return true; - } } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 0a9af2c..b099177 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1325,6 +1325,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } + string map = String.Empty; + + if (File.Exists(fn + ".map")) + { + FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read); + StreamReader msr = new StreamReader(mfs); + + map = msr.ReadToEnd(); + + msr.Close(); + mfs.Close(); + } + XmlElement assemblyData = doc.CreateElement("", "Assembly", ""); XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", ""); @@ -1335,21 +1348,116 @@ namespace OpenSim.Region.ScriptEngine.XEngine stateData.AppendChild(assemblyData); - return doc.InnerXml; - } + XmlElement mapData = doc.CreateElement("", "LineMap", ""); + XmlAttribute mapName = doc.CreateAttribute("", "Filename", ""); - public bool CanBeDeleted(UUID itemID) - { - IScriptInstance instance = GetInstance(itemID); - if (instance == null) - return true; + mapName.Value = fn + ".map"; + mapData.Attributes.Append(mapName); - return instance.CanBeDeleted(); + mapData.InnerText = map; + + stateData.AppendChild(mapData); + return doc.InnerXml; } private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled) { return false; } + + public void SetXMLState(UUID itemID, string xml) + { + if (xml == String.Empty) + return; + + XmlDocument doc = new XmlDocument(); + + try + { + doc.LoadXml(xml); + } + catch (Exception) + { + m_log.Error("[XEngine]: Exception decoding XML data from region transfer"); + return; + } + + XmlNodeList rootL = doc.GetElementsByTagName("State"); + if (rootL.Count < 1) + return; + + XmlElement rootE = (XmlElement)rootL[0]; + + if (rootE.GetAttribute("UUID") != itemID.ToString()) + return; + + string assetID = rootE.GetAttribute("Asset"); + + XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState"); + + if (stateL.Count != 1) + return; + + XmlElement stateE = (XmlElement)stateL[0]; + + if (World.m_trustBinaries) + { + XmlNodeList assemL = rootE.GetElementsByTagName("Assembly"); + + if (assemL.Count != 1) + return; + + XmlElement assemE = (XmlElement)assemL[0]; + + string fn = assemE.GetAttribute("Filename"); + string base64 = assemE.InnerText; + + string path = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); + path = Path.Combine(path, fn); + + if (!File.Exists(path)) + { + Byte[] filedata = Convert.FromBase64String(base64); + + FileStream fs = File.Create(path); + fs.Write(filedata, 0, filedata.Length); + fs.Close(); + + fs = File.Create(path + ".text"); + StreamWriter sw = new StreamWriter(fs); + + sw.Write(base64); + + sw.Close(); + fs.Close(); + } + } + + string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); + statepath = Path.Combine(statepath, itemID.ToString() + ".state"); + + FileStream sfs = File.Create(statepath); + StreamWriter ssw = new StreamWriter(sfs); + + ssw.Write(stateE.OuterXml); + + ssw.Close(); + sfs.Close(); + + XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); + + XmlElement mapE = (XmlElement)mapL[0]; + + string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString()); + mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); + + FileStream mfs = File.Create(mappath); + StreamWriter msw = new StreamWriter(sfs); + + msw.Write(mapE.InnerText); + + msw.Close(); + mfs.Close(); + } } } -- cgit v1.1 From c6bfecccaa3b1128c6d670bdedc13275732e738b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 26 Nov 2009 17:16:02 +0000 Subject: Fix a small bug. Trusted script crossings now work again --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b099177..5584f87 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1452,7 +1452,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine mappath = Path.Combine(mappath, mapE.GetAttribute("Filename")); FileStream mfs = File.Create(mappath); - StreamWriter msw = new StreamWriter(sfs); + StreamWriter msw = new StreamWriter(mfs); msw.Write(mapE.InnerText); -- cgit v1.1 From d39c300d11109553b75ca761d26dda278c0ad7dd Mon Sep 17 00:00:00 2001 From: Jeff Lee Date: Sun, 22 Nov 2009 18:10:46 -0500 Subject: Added osGetRegionStats() function, to return a number of sim statistics --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 +++++ .../Region/Framework/Scenes/SimStatsReporter.cs | 11 +++++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 1 + .../Shared/Api/Implementation/OSSL_Api.cs | 15 ++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../Shared/Api/Runtime/LSL_Constants.cs | 23 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 7 files changed, 61 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eb8567f..2558757 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -387,6 +387,11 @@ namespace OpenSim.Region.Framework.Scenes { get { return StatsReporter.getLastReportedSimFPS(); } } + + public float[] SimulatorStats + { + get { return StatsReporter.getLastReportedSimStats(); } + } public string DefaultScriptEngine { diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index ee288b3..56c6ed6 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -82,6 +82,7 @@ namespace OpenSim.Region.Framework.Scenes private int m_fps = 0; // saved last reported value so there is something available for llGetRegionFPS private float lastReportedSimFPS = 0; + private float[] lastReportedSimStats = new float[21]; private float m_pfps = 0; private int m_agentUpdates = 0; @@ -259,6 +260,11 @@ namespace OpenSim.Region.Framework.Scenes sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; + + for (int i = 0; i < 21; i++) + { + lastReportedSimStats[i] = sb[i].StatValue; + } SimStats simStats = new SimStats( @@ -438,6 +444,11 @@ namespace OpenSim.Region.Framework.Scenes { return lastReportedSimFPS; } + + public float[] getLastReportedSimStats() + { + return lastReportedSimStats; + } public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fbbbfdc..5de23ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5784,6 +5784,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); return World.SimulatorFPS; } + /* particle system rules should be coming into this routine as doubles, that is rule[0] should be an integer from this list and rule[1] should be the arg diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index e72fa70..482bfbc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1948,5 +1948,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return key.ToString(); } + + public LSL_List osGetRegionStats() + { + CheckThreatLevel(ThreatLevel.High, "osGetRegionStats"); + m_host.AddScriptLPS(1); + LSL_List ret = new LSL_List(); + float[] stats = World.SimulatorStats; + + for (int i = 0; i < 21; i++) + { + ret.Add(new LSL_Float( stats[i] )); + } + return ret; + } + } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 470946a..0b0dc00 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -162,5 +162,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces key osGetMapTexture(); key osGetRegionMapTexture(string regionName); + LSL_List osGetRegionStats(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 753ca55..acff8fb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -515,6 +515,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const string TEXTURE_PLYWOOD = "89556747-24cb-43ed-920b-47caed15465f"; public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903"; public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361"; + + // Constants for osGetRegionStats + public const int STATS_TIME_DILATION = 0; + public const int STATS_SIM_FPS = 1; + public const int STATS_PHYSICS_FPS = 2; + public const int STATS_AGENT_UPDATES = 3; + public const int STATS_ROOT_AGENTS = 4; + public const int STATS_CHILD_AGENTS = 5; + public const int STATS_TOTAL_PRIMS = 6; + public const int STATS_ACTIVE_PRIMS = 7; + public const int STATS_FRAME_MS = 8; + public const int STATS_NET_MS = 9; + public const int STATS_PHYSICS_MS = 10; + public const int STATS_IMAGE_MS = 11; + public const int STATS_OTHER_MS = 12; + public const int STATS_IN_PACKETS_PER_SECOND = 13; + public const int STATS_OUT_PACKETS_PER_SECOND = 14; + public const int STATS_UNACKED_BYTES = 15; + public const int STATS_AGENT_MS = 16; + public const int STATS_PENDING_DOWNLOADS = 17; + public const int STATS_PENDING_UPLOADS = 18; + public const int STATS_ACTIVE_SCRIPTS = 19; + public const int STATS_SCRIPT_LPS = 20; } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 6b88834..519463e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -632,5 +632,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osGetRegionMapTexture(regionName); } + + public LSL_List osGetRegionStats() + { + return m_OSSL_Functions.osGetRegionStats(); + } } } -- cgit v1.1 From 9d05962029fe864408d287d5fa7ef81f312e098a Mon Sep 17 00:00:00 2001 From: Jeff Lee Date: Mon, 23 Nov 2009 11:53:37 -0500 Subject: Added osGetRegionStats() function, to return a number of sim statistics --- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 482bfbc..5501679 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1949,9 +1949,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return key.ToString(); } + /// + /// Return information regarding various simulator statistics (sim fps, physics fps, time + /// dilation, total number of prims, total number of active scripts, script lps, various + /// timing data, packets in/out, etc. Basically much the information that's shown in the + /// client's Statistics Bar (Ctrl-Shift-1) + /// + /// List of floats public LSL_List osGetRegionStats() { - CheckThreatLevel(ThreatLevel.High, "osGetRegionStats"); + CheckThreatLevel(ThreatLevel.Moderate, "osGetRegionStats"); m_host.AddScriptLPS(1); LSL_List ret = new LSL_List(); float[] stats = World.SimulatorStats; -- cgit v1.1