From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 181 +++++++++++++++++---- .../Region/OptionalModules/World/NPC/NPCModule.cs | 99 ++++++++--- .../World/NPC/Tests/NPCModuleTests.cs | 8 +- 3 files changed, 228 insertions(+), 60 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index fb644b7..bb23f2f 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -43,9 +43,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC public class NPCAvatar : IClientAPI, INPC { public bool SenseAsAgent { get; set; } + public UUID Owner + { + get { return m_ownerID;} + } public delegate void ChatToNPC( - string message, byte type, Vector3 fromPos, string fromName, + string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible); /// @@ -61,9 +65,14 @@ namespace OpenSim.Region.OptionalModules.World.NPC private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; - private readonly UUID m_uuid; + private UUID m_uuid = UUID.Random(); private readonly Scene m_scene; private readonly UUID m_ownerID; + private UUID m_hostGroupID; + private string m_profileAbout = ""; + private UUID m_profileImage = UUID.Zero; + private string m_born; + public List SelectedObjects {get; private set;} public NPCAvatar( string firstname, string lastname, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene) @@ -75,6 +84,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_scene = scene; m_ownerID = ownerID; SenseAsAgent = senseAsAgent; + m_hostGroupID = UUID.Zero; } public NPCAvatar( @@ -87,6 +97,25 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_scene = scene; m_ownerID = ownerID; SenseAsAgent = senseAsAgent; + 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 UUID profileImage + { + get { return m_profileImage; } + set { m_profileImage = value; } } public IScene Scene @@ -94,6 +123,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC get { return m_scene; } } + public int PingTimeMS { get { return 0; } } + public UUID OwnerID { get { return m_ownerID; } @@ -187,9 +218,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - - public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, - Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) + + public void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY) + { + + } + + public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, + Quaternion SitOrientation, bool autopilot, + Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) { } @@ -248,7 +285,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC #pragma warning disable 67 public event Action OnLogout; public event ObjectPermissions OnObjectPermissions; - + public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy; public event MoneyTransferRequest OnMoneyTransferRequest; public event ParcelBuy OnParcelBuy; public event Action OnConnectionClosed; @@ -268,6 +305,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event ObjectDrop OnObjectDrop; public event StartAnim OnStartAnim; public event StopAnim OnStopAnim; + public event ChangeAnim OnChangeAnim; public event LinkObjects OnLinkObjects; public event DelinkObjects OnDelinkObjects; public event RequestMapBlocks OnRequestMapBlocks; @@ -280,6 +318,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event SetAlwaysRun OnSetAlwaysRun; public event DeRezObject OnDeRezObject; + public event RezRestoreToWorld OnRezRestoreToWorld; public event Action OnRegionHandShakeReply; public event GenericCall1 OnRequestWearables; public event Action OnCompleteMovementToRegion; @@ -318,6 +357,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event UpdatePrimTexture OnUpdatePrimTexture; public event UpdateVector OnUpdatePrimGroupPosition; public event UpdateVector OnUpdatePrimSinglePosition; + public event ClientChangeObject onClientChangeObject; public event UpdatePrimRotation OnUpdatePrimGroupRotation; public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; @@ -456,7 +496,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event ClassifiedInfoRequest OnClassifiedInfoRequest; public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; public event ClassifiedDelete OnClassifiedDelete; - public event ClassifiedDelete OnClassifiedGodDelete; + public event ClassifiedGodDelete OnClassifiedGodDelete; public event EventNotificationAddRequest OnEventNotificationAddRequest; public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; @@ -479,7 +519,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event AvatarInterestUpdate OnAvatarInterestUpdate; public event PlacesQuery OnPlacesQuery; - + public event FindAgentUpdate OnFindAgent; public event TrackAgentUpdate OnTrackAgent; public event NewUserReport OnUserReport; @@ -495,11 +535,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; public event SimWideDeletesDelegate OnSimWideDeletes; public event SendPostcard OnSendPostcard; + public event ChangeInventoryItemFlags OnChangeInventoryItemFlags; public event MuteListEntryUpdate OnUpdateMuteListEntry; public event MuteListEntryRemove OnRemoveMuteListEntry; public event GodlikeMessage onGodlikeMessage; public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; - + public event GenericCall2 OnUpdateThrottles; #pragma warning restore 67 #endregion @@ -522,6 +563,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public virtual UUID AgentId { get { return m_uuid; } + set { m_uuid = value; } } public UUID SessionId @@ -562,24 +604,40 @@ namespace OpenSim.Region.OptionalModules.World.NPC } public UUID ActiveGroupId { - get { return UUID.Zero; } + get { return m_hostGroupID; } + set { m_hostGroupID = value; } } public string ActiveGroupName { get { return String.Empty; } + set { } } public ulong ActiveGroupPowers { get { return 0; } + set { } + } + + public string Born + { + get { return m_born; } + set { m_born = value; } } public bool IsGroupMember(UUID groupID) { - return false; + return (m_hostGroupID == groupID); + } + + public Dictionary GetGroupPowers() + { + return new Dictionary(); } + public void SetGroupPowers(Dictionary powers) { } + public ulong GetGroupPowers(UUID groupID) { return 0; @@ -627,6 +685,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC public virtual void SetChildAgentThrottle(byte[] throttle) { } + + public virtual void SetChildAgentThrottle(byte[] throttle, float factor) + { + + } + + public void SetAgentThrottleSilent(int throttle, int setting) + { + + + } public byte[] GetThrottlesPacked(float multiplier) { return new byte[0]; @@ -665,6 +734,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC } + public virtual bool CanSendLayerData() + { + return false; + } + public virtual void SendLayerData(float[] map) { } @@ -676,9 +750,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public virtual void SendWindData(Vector2[] windSpeeds) { } + public virtual void SendWindData(int version, Vector2[] windSpeeds) { } - public virtual void SendCloudData(float[] cloudCover) { } + public virtual void SendCloudData(int version, float[] cloudCover) { } public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) { @@ -739,7 +813,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public void SendAvatarDataImmediate(ISceneEntity avatar) + public void SendEntityFullUpdateImmediate(ISceneEntity avatar) + { + } + + public void SendEntityTerseUpdateImmediate(ISceneEntity ent) { } @@ -772,6 +850,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId) + { + } + public virtual void SendRemoveInventoryItem(UUID itemID) { } @@ -788,7 +870,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) + public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) { } public virtual void SendAbortXferPacket(ulong xferID) @@ -833,6 +915,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void SendAlertMessage(string message, string info) + { + } + public void SendSystemAlertMessage(string message) { } @@ -849,7 +935,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC OnRegionHandShakeReply(this); } } - + public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) { } @@ -869,7 +955,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec) { } - + public void SendImageNotFound(UUID imageid) { } @@ -877,7 +963,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData) { } - + public void SendShutdownConnectionNotice() { } @@ -888,7 +974,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendObjectPropertiesFamilyData(ISceneEntity Entity, uint RequestFlags) { - + } public void SendObjectPropertiesReply(ISceneEntity entity) @@ -902,12 +988,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks) { } - + public void SendViewerTime(int phase) { } - public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember, + public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID) { @@ -933,10 +1019,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void Close() { - Close(false); + Close(true, false); } - public void Close(bool force) + public void Close(bool sendStop, bool force) { // Remove ourselves from the scene m_scene.RemoveClient(AgentId, false); @@ -947,7 +1033,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC // We never start the client, so always fail. throw new NotImplementedException(); } - + public void Stop() { } @@ -1142,11 +1228,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendJoinGroupReply(UUID groupID, bool success) { } - + public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success) { } - + public void SendLeaveGroupReply(UUID groupID, bool success) { } @@ -1155,6 +1241,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data) + { + } + public void SendTerminateFriend(UUID exFriendID) { } @@ -1208,10 +1298,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void UpdateGroupMembership(GroupMembershipData[] data) + { + } + + public void GroupMembershipRemove(UUID GroupID) + { + } + + public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers) + { + } + public void SendUseCachedMuteList() { } + public void SendEmpytMuteList() + { + } + public void SendMuteListUpdate(string filename) { } @@ -1220,7 +1326,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } #endregion - + public void SendRebakeAvatarTextures(UUID textureID) { } @@ -1228,15 +1334,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) { } - + public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt) { } - + public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier) { } - + public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt) { } @@ -1256,7 +1362,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId) { } - + public void SendAgentTerseUpdate(ISceneEntity presence) { } @@ -1265,9 +1371,22 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void SendSelectedPartsProprieties(List parts) + { + } + public void SendPartPhysicsProprieties(ISceneEntity entity) { } + public void SendPartFullUpdate(ISceneEntity ent, uint? parentID) + { + } + + public int GetAgentThrottleSilent(int throttle) + { + return 0; + } + } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 3b94dff..ced82e6 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -52,6 +52,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC private Dictionary m_avatars = new Dictionary(); + + + private NPCOptionsFlags m_NPCOptionFlags; + public NPCOptionsFlags NPCOptionFlags {get {return m_NPCOptionFlags;}} + public bool Enabled { get; private set; } public void Initialise(IConfigSource source) @@ -59,6 +64,21 @@ namespace OpenSim.Region.OptionalModules.World.NPC IConfig config = source.Configs["NPC"]; Enabled = (config != null && config.GetBoolean("Enabled", false)); + m_NPCOptionFlags = NPCOptionsFlags.None; + if(Enabled) + { + if(config.GetBoolean("AllowNotOwned", true)) + m_NPCOptionFlags |= NPCOptionsFlags.AllowNotOwned; + + if(config.GetBoolean("AllowSenseAsAvatar", true)) + m_NPCOptionFlags |= NPCOptionsFlags.AllowSenseAsAvatar; + + if(config.GetBoolean("AllowCloneOtherAvatars", true)) + m_NPCOptionFlags |= NPCOptionsFlags.AllowCloneOtherAvatars; + + if(config.GetBoolean("NoNPCGroup", true)) + m_NPCOptionFlags |= NPCOptionsFlags.NoNPCGroup; + } } public void AddRegion(Scene scene) @@ -137,17 +157,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC } public UUID CreateNPC(string firstname, string lastname, - Vector3 position, UUID owner, bool senseAsAgent, Scene scene, + Vector3 position, UUID owner, bool senseAsAgent, Scene scene, AvatarAppearance appearance) { - return CreateNPC(firstname, lastname, position, UUID.Zero, owner, senseAsAgent, scene, appearance); + return CreateNPC(firstname, lastname, position, UUID.Zero, owner, "", UUID.Zero, senseAsAgent, scene, appearance); } public UUID CreateNPC(string firstname, string lastname, - Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene, + Vector3 position, UUID agentID, UUID owner, string groupTitle, UUID groupID, bool senseAsAgent, Scene scene, AvatarAppearance appearance) { NPCAvatar npcAvatar = null; + string born = DateTime.UtcNow.ToString(); try { @@ -167,10 +188,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); - m_log.DebugFormat( - "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", - firstname, lastname, npcAvatar.AgentId, owner, - senseAsAgent, position, scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", +// firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; @@ -181,30 +201,44 @@ namespace OpenSim.Region.OptionalModules.World.NPC AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); acd.Appearance = npcAppearance; - lock (m_avatars) + /* + for (int i = 0; + i < acd.Appearance.Texture.FaceTextures.Length; i++) { - scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, - acd); - scene.AddNewAgent(npcAvatar, PresenceType.Npc); + m_log.DebugFormat( + "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", + acd.AgentID, i, + acd.Appearance.Texture.FaceTextures[i]); + } + */ - ScenePresence sp; - if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) - { - sp.CompleteMovement(npcAvatar, false); - m_avatars.Add(npcAvatar.AgentId, npcAvatar); - m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); +// ManualResetEvent ev = new ManualResetEvent(false); - return npcAvatar.AgentId; - } - else +// Util.FireAndForget(delegate(object x) { + lock (m_avatars) { - m_log.WarnFormat( - "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", - sp.Name, sp.UUID); + scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); + scene.AddNewAgent(npcAvatar, PresenceType.Npc); - return UUID.Zero; + ScenePresence sp; + if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) + { + npcAvatar.Born = born; + npcAvatar.ActiveGroupId = groupID; + sp.CompleteMovement(npcAvatar, false); + sp.Grouptitle = groupTitle; + m_avatars.Add(npcAvatar.AgentId, npcAvatar); +// m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); + } } - } +// ev.Set(); +// }); + +// ev.WaitOne(); + +// m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); + + return npcAvatar.AgentId; } public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, @@ -220,6 +254,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (sp.IsSatOnObject || sp.SitGround) return false; +// m_log.DebugFormat( +// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", +// sp.Name, pos, scene.RegionInfo.RegionName, +// noFly, landAtTarget); + sp.MoveToTarget(pos, noFly, landAtTarget); sp.SetAlwaysRun = running; @@ -382,6 +421,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.TryGetValue(agentID, out av)) { + /* + m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", + agentID, av.Name); + */ doRemove = true; } } @@ -410,9 +453,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC { NPCAvatar av; if (m_avatars.TryGetValue(npcID, out av)) + { + if (npcID == callerID) + return true; return CheckPermissions(av, callerID); + } else + { return false; + } } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 77dfd40..9a1ea73 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // ScenePresence.SendInitialData() to reset our entire appearance. m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); - m_afMod.SetAppearance(sp, originalTe, null, null); + m_afMod.SetAppearance(sp, originalTe, null, new WearableCacheItem[0] ); UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); @@ -209,10 +209,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests UserAccountHelpers.CreateUserWithInventory(m_scene, userId); ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); - InventoryItemBase att1Item + InventoryItemBase att1Item = UserInventoryHelpers.CreateInventoryItem( m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object); - InventoryItemBase att2Item + InventoryItemBase att2Item = UserInventoryHelpers.CreateInventoryItem( m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object); @@ -483,4 +483,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc.ParentID, Is.EqualTo(0)); } } -} \ No newline at end of file +} -- cgit v1.1