From 240ab951b52aa87434cc02736a4ef84d95470082 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 6 Dec 2016 16:15:57 +0000 Subject: [PATCH 1/5] let NPCs have profile --- .../Avatar/UserProfiles/UserProfileModule.cs | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 61835f9d71..47914cc313 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -320,13 +320,12 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles UUID targetID; UUID.TryParse(args[0], out targetID); - // Can't handle NPC yet... - ScenePresence p = FindPresence(targetID); - if (null != p) + ScenePresence p = FindPresence(targetID); + if (p != null && p.isNPC) { - if (p.PresenceType == PresenceType.Npc) - return; + remoteClient.SendAvatarClassifiedReply(new UUID(args[0]), new Dictionary()); + return; } string serverURI = string.Empty; @@ -575,10 +574,10 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles // Can't handle NPC yet... ScenePresence p = FindPresence(targetId); - if (null != p) + if (p != null && p.isNPC) { - if (p.PresenceType == PresenceType.Npc) - return; + remoteClient.SendAvatarPicksReply(new UUID(args[0]), new Dictionary()); + return; } string serverURI = string.Empty; @@ -860,6 +859,14 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles /// public void NotesUpdate(IClientAPI remoteClient, UUID queryTargetID, string queryNotes) { + ScenePresence p = FindPresence(queryTargetID); + if (p != null && p.isNPC) + { + remoteClient.SendAgentAlertMessage( + "Notes for NPCs not avaiable", false); + return; + } + UserProfileNotes note = new UserProfileNotes(); note.UserId = remoteClient.AgentId; @@ -1000,10 +1007,14 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles // Can't handle NPC yet... ScenePresence p = FindPresence(avatarID); - if (null != p) + if (p != null && p.isNPC) { - if (p.PresenceType == PresenceType.Npc) - return; + remoteClient.SendAvatarProperties(avatarID, "im a happy NPC", "5/25/1977" , + Utils.StringToBytes("NPC"), "NPCs have no life", 0, + UUID.Zero, UUID.Zero, "", UUID.Zero); + remoteClient.SendAvatarInterestsReply(avatarID, 0, "", + 0, "Getting into trouble", "Droidspeak"); + return; } string serverURI = string.Empty; From d4e285b1a1da036220d9b3a7141ebe1b865c5d35 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 6 Dec 2016 17:05:02 +0000 Subject: [PATCH 2/5] add osNpcSetProfileAbout(LSL_Key npc, string about) to set NPCs profile About text. requires OsNpcCreate rights --- .../Avatar/UserProfiles/UserProfileModule.cs | 4 ++-- .../Region/Framework/Interfaces/INPCModule.cs | 1 + .../OptionalModules/World/NPC/NPCAvatar.cs | 13 ++++++++++++- .../Shared/Api/Implementation/OSSL_Api.cs | 19 +++++++++++++++++++ .../Shared/Api/Interface/IOSSL_Api.cs | 1 + .../Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++ 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 47914cc313..94dc5f5e23 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -863,7 +863,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles if (p != null && p.isNPC) { remoteClient.SendAgentAlertMessage( - "Notes for NPCs not avaiable", false); + "Notes for NPCs not available", false); return; } @@ -1009,7 +1009,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles if (p != null && p.isNPC) { - remoteClient.SendAvatarProperties(avatarID, "im a happy NPC", "5/25/1977" , + remoteClient.SendAvatarProperties(avatarID, ((INPC)(p.ControllingClient)).profileAbout, "5/25/1977", Utils.StringToBytes("NPC"), "NPCs have no life", 0, UUID.Zero, UUID.Zero, "", UUID.Zero); remoteClient.SendAvatarInterestsReply(avatarID, 0, "", diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index 58ea309f99..13103584e1 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs @@ -58,6 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces bool SenseAsAgent { get; } UUID ActiveGroupId { get; set; } UUID Owner { get; } + string profileAbout { get; set; } } public interface INPCModule diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 1ad71ba4cc..1096eae7b7 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -69,7 +69,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC private readonly Scene m_scene; private readonly UUID m_ownerID; private UUID m_hostGroupID; - + private string m_profileAbout = ""; public List SelectedObjects {get; private set;} public NPCAvatar( @@ -98,6 +98,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_hostGroupID = UUID.Zero; } + public string profileAbout + { + get { return m_profileAbout; } + set + { + if(value.Length > 255) + m_profileAbout = value.Substring(0,255); + else + m_profileAbout = value; + } + } public IScene Scene { get { return m_scene; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 19f2d0972b..b101cf9b44 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2999,6 +2999,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public void osNpcSetProfileAbout(LSL_Key npc, string about) + { + CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); + m_host.AddScriptLPS(1); + + INPCModule module = World.RequestModuleInterface(); + if (module != null) + { + UUID npcId = new UUID(npc.m_string); + + if (!module.CheckPermissions(npcId, m_host.OwnerID)) + return; + + ScenePresence sp = World.GetScenePresence(npcId); + if (sp != null) + ((INPC)(sp.ControllingClient)).profileAbout = about; + } + } + public void osNpcSay(LSL_Key npc, string message) { osNpcSay(npc, 0, message); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 5ce859ee36..87b09675b2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -343,6 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces rotation osNpcGetRot(key npc); void osNpcSetRot(LSL_Key npc, rotation rot); void osNpcStopMoveToTarget(LSL_Key npc); + void osNpcSetProfileAbout(LSL_Key npc, string about); void osNpcSay(key npc, string message); void osNpcSay(key npc, int channel, string message); void osNpcShout(key npc, int channel, string message); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index c5cb88e05f..5bc998e8c1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -637,6 +637,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osNpcStopMoveToTarget(npc); } + public void osNpcSetProfileAbout(LSL_Key npc, string about) + { + m_OSSL_Functions.osNpcSetProfileAbout(npc, about); + } + public void osNpcSay(key npc, string message) { m_OSSL_Functions.osNpcSay(npc, message); From de36092d23736f448f5612cbe8b1965422e13a6c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 6 Dec 2016 17:16:47 +0000 Subject: [PATCH 3/5] if we have profile then npc is online --- .../Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 94dc5f5e23..5be8556eb8 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -1010,7 +1010,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles if (p != null && p.isNPC) { remoteClient.SendAvatarProperties(avatarID, ((INPC)(p.ControllingClient)).profileAbout, "5/25/1977", - Utils.StringToBytes("NPC"), "NPCs have no life", 0, + Utils.StringToBytes("Non Player Character (NPC)"), "NPCs have no life", 16, UUID.Zero, UUID.Zero, "", UUID.Zero); remoteClient.SendAvatarInterestsReply(avatarID, 0, "", 0, "Getting into trouble", "Droidspeak"); From f1c6769ca5a2e49fcfa4aa17c27173af6b49df2f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 7 Dec 2016 02:14:26 +0000 Subject: [PATCH 4/5] set HasGridUserTried on usercache of NPCs --- .../Framework/UserManagement/UserManagementModule.cs | 4 ++-- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Services/Interfaces/IUserManagement.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 5507526310..2701912d18 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -805,7 +805,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement return !userdata.IsUnknownUser; } - public virtual void AddUser(UUID uuid, string first, string last) + public virtual void AddUser(UUID uuid, string first, string last, bool isNPC = false) { lock(m_UserCache) { @@ -816,7 +816,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement user.FirstName = first; user.LastName = last; user.IsUnknownUser = false; - user.HasGridUserTried = false; + user.HasGridUserTried = isNPC; m_UserCache.Add(uuid, user); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 09f0b19201..e44f11a54e 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3226,7 +3226,7 @@ namespace OpenSim.Region.Framework.Scenes if (sp != null && sp.PresenceType == PresenceType.Npc) { - UserManagementModule.AddUser(aCircuit.AgentID, first, last); + UserManagementModule.AddUser(aCircuit.AgentID, first, last, true); } else { diff --git a/OpenSim/Services/Interfaces/IUserManagement.cs b/OpenSim/Services/Interfaces/IUserManagement.cs index 225560e00b..91b344e0dc 100644 --- a/OpenSim/Services/Interfaces/IUserManagement.cs +++ b/OpenSim/Services/Interfaces/IUserManagement.cs @@ -79,7 +79,7 @@ namespace OpenSim.Services.Interfaces /// /// /// - void AddUser(UUID uuid, string firstName, string lastName); + void AddUser(UUID uuid, string first, string last, bool isNPC = false); /// /// Add a user. From 9042aa89683e690c42d27482964368edae9a6b84 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 7 Dec 2016 04:56:35 +0000 Subject: [PATCH 5/5] add missing sp Intransit control --- .../EntityTransfer/EntityTransferModule.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index a7105e2bb2..ad094b4b91 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -776,6 +776,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer else if (sp.Flying) teleportFlags |= (uint)TeleportFlags.IsFlying; + sp.IsInTransit = true; + if (DisableInterRegionTeleportCancellation) teleportFlags |= (uint)TeleportFlags.DisableCancel; @@ -878,7 +880,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason); sp.ControllingClient.SendTeleportFailed(reason); - + sp.IsInTransit = false; return; } @@ -889,7 +891,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after CreateAgent on client request", sp.Name, finalDestination.RegionName, sp.Scene.Name); - + sp.IsInTransit = false; return; } else if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) @@ -899,7 +901,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after CreateAgent due to previous client close.", sp.Name, finalDestination.RegionName, sp.Scene.Name); - + sp.IsInTransit = false; return; } @@ -960,7 +962,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} before UpdateAgent", sp.Name, finalDestination.RegionName, sp.Scene.Name); - + sp.IsInTransit = false; return; } @@ -977,7 +979,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after UpdateAgent due to previous client close.", sp.Name, finalDestination.RegionName, sp.Scene.Name); - + sp.IsInTransit = false; return; } @@ -986,6 +988,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Name, finalDestination.RegionName, sp.Scene.Name); Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established."); + sp.IsInTransit = false; return; } @@ -998,7 +1001,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Name, finalDestination.RegionName, sp.Scene.Name); CleanupFailedInterRegionTeleport(sp, currentAgentCircuit.SessionID.ToString(), finalDestination); - + sp.IsInTransit = false; return; } @@ -1035,7 +1038,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after WaitForAgentArrivedAtDestination due to previous client close.", sp.Name, finalDestination.RegionName, sp.Scene.Name); - + sp.IsInTransit = false; return; } @@ -1044,7 +1047,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Destination region did not signal teleport completion."); - + sp.IsInTransit = false; return; } @@ -1093,6 +1096,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Thread.Sleep(500); sp.Scene.CloseAgent(sp.UUID, false); } + sp.IsInTransit = false; } private void TransferAgent_V2(ScenePresence sp, AgentCircuitData agentCircuit, GridRegion reg, GridRegion finalDestination, @@ -1115,7 +1119,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason); sp.ControllingClient.SendTeleportFailed(reason); - + sp.IsInTransit = false; return; } @@ -1127,6 +1131,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after CreateAgent on client request", sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.IsInTransit = false; return; } else if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Aborting) @@ -1137,6 +1142,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after CreateAgent due to previous client close.", sp.Name, finalDestination.RegionName, sp.Scene.Name); + sp.IsInTransit = false; return; } @@ -1189,7 +1195,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Aborted teleport of {0} to {1} from {2} after UpdateAgent due to previous client close.", sp.Name, finalDestination.RegionName, sp.Scene.Name); - + sp.IsInTransit = false; return; } @@ -1198,6 +1204,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Name, finalDestination.RegionName, sp.Scene.Name); Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established."); + sp.IsInTransit = false; return; } @@ -1255,6 +1262,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Reset(); } */ + sp.IsInTransit = false; } ///