diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
3 files changed, 57 insertions, 48 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 9a61702..f2355e2 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
47 | private readonly string m_firstname; | 47 | private readonly string m_firstname; |
48 | private readonly string m_lastname; | 48 | private readonly string m_lastname; |
49 | private readonly Vector3 m_startPos; | 49 | private readonly Vector3 m_startPos; |
50 | private readonly UUID m_uuid = UUID.Random(); | 50 | private UUID m_uuid = UUID.Random(); |
51 | private readonly Scene m_scene; | 51 | private readonly Scene m_scene; |
52 | private readonly UUID m_ownerID; | 52 | private readonly UUID m_ownerID; |
53 | 53 | ||
@@ -221,7 +221,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
221 | #pragma warning disable 67 | 221 | #pragma warning disable 67 |
222 | public event Action<IClientAPI> OnLogout; | 222 | public event Action<IClientAPI> OnLogout; |
223 | public event ObjectPermissions OnObjectPermissions; | 223 | public event ObjectPermissions OnObjectPermissions; |
224 | 224 | public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy; | |
225 | public event MoneyTransferRequest OnMoneyTransferRequest; | 225 | public event MoneyTransferRequest OnMoneyTransferRequest; |
226 | public event ParcelBuy OnParcelBuy; | 226 | public event ParcelBuy OnParcelBuy; |
227 | public event Action<IClientAPI> OnConnectionClosed; | 227 | public event Action<IClientAPI> OnConnectionClosed; |
@@ -241,6 +241,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
241 | public event ObjectDrop OnObjectDrop; | 241 | public event ObjectDrop OnObjectDrop; |
242 | public event StartAnim OnStartAnim; | 242 | public event StartAnim OnStartAnim; |
243 | public event StopAnim OnStopAnim; | 243 | public event StopAnim OnStopAnim; |
244 | public event ChangeAnim OnChangeAnim; | ||
244 | public event LinkObjects OnLinkObjects; | 245 | public event LinkObjects OnLinkObjects; |
245 | public event DelinkObjects OnDelinkObjects; | 246 | public event DelinkObjects OnDelinkObjects; |
246 | public event RequestMapBlocks OnRequestMapBlocks; | 247 | public event RequestMapBlocks OnRequestMapBlocks; |
@@ -291,6 +292,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
291 | public event UpdatePrimTexture OnUpdatePrimTexture; | 292 | public event UpdatePrimTexture OnUpdatePrimTexture; |
292 | public event UpdateVector OnUpdatePrimGroupPosition; | 293 | public event UpdateVector OnUpdatePrimGroupPosition; |
293 | public event UpdateVector OnUpdatePrimSinglePosition; | 294 | public event UpdateVector OnUpdatePrimSinglePosition; |
295 | public event ClientChangeObject onClientChangeObject; | ||
294 | public event UpdatePrimRotation OnUpdatePrimGroupRotation; | 296 | public event UpdatePrimRotation OnUpdatePrimGroupRotation; |
295 | public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; | 297 | public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; |
296 | public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; | 298 | public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; |
@@ -429,7 +431,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
429 | public event ClassifiedInfoRequest OnClassifiedInfoRequest; | 431 | public event ClassifiedInfoRequest OnClassifiedInfoRequest; |
430 | public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; | 432 | public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; |
431 | public event ClassifiedDelete OnClassifiedDelete; | 433 | public event ClassifiedDelete OnClassifiedDelete; |
432 | public event ClassifiedDelete OnClassifiedGodDelete; | 434 | public event ClassifiedGodDelete OnClassifiedGodDelete; |
433 | 435 | ||
434 | public event EventNotificationAddRequest OnEventNotificationAddRequest; | 436 | public event EventNotificationAddRequest OnEventNotificationAddRequest; |
435 | public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; | 437 | public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; |
@@ -468,11 +470,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
468 | public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; | 470 | public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; |
469 | public event SimWideDeletesDelegate OnSimWideDeletes; | 471 | public event SimWideDeletesDelegate OnSimWideDeletes; |
470 | public event SendPostcard OnSendPostcard; | 472 | public event SendPostcard OnSendPostcard; |
473 | public event ChangeInventoryItemFlags OnChangeInventoryItemFlags; | ||
471 | public event MuteListEntryUpdate OnUpdateMuteListEntry; | 474 | public event MuteListEntryUpdate OnUpdateMuteListEntry; |
472 | public event MuteListEntryRemove OnRemoveMuteListEntry; | 475 | public event MuteListEntryRemove OnRemoveMuteListEntry; |
473 | public event GodlikeMessage onGodlikeMessage; | 476 | public event GodlikeMessage onGodlikeMessage; |
474 | public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; | 477 | public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; |
475 | 478 | public event GenericCall2 OnUpdateThrottles; | |
476 | #pragma warning restore 67 | 479 | #pragma warning restore 67 |
477 | 480 | ||
478 | #endregion | 481 | #endregion |
@@ -495,6 +498,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
495 | public virtual UUID AgentId | 498 | public virtual UUID AgentId |
496 | { | 499 | { |
497 | get { return m_uuid; } | 500 | get { return m_uuid; } |
501 | set { m_uuid = value; } | ||
498 | } | 502 | } |
499 | 503 | ||
500 | public UUID SessionId | 504 | public UUID SessionId |
@@ -600,6 +604,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
600 | public virtual void SetChildAgentThrottle(byte[] throttle) | 604 | public virtual void SetChildAgentThrottle(byte[] throttle) |
601 | { | 605 | { |
602 | } | 606 | } |
607 | |||
608 | public void SetAgentThrottleSilent(int throttle, int setting) | ||
609 | { | ||
610 | |||
611 | |||
612 | } | ||
603 | public byte[] GetThrottlesPacked(float multiplier) | 613 | public byte[] GetThrottlesPacked(float multiplier) |
604 | { | 614 | { |
605 | return new byte[0]; | 615 | return new byte[0]; |
@@ -744,6 +754,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
744 | { | 754 | { |
745 | } | 755 | } |
746 | 756 | ||
757 | public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId) | ||
758 | { | ||
759 | } | ||
760 | |||
747 | public virtual void SendRemoveInventoryItem(UUID itemID) | 761 | public virtual void SendRemoveInventoryItem(UUID itemID) |
748 | { | 762 | { |
749 | } | 763 | } |
@@ -760,7 +774,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
760 | { | 774 | { |
761 | } | 775 | } |
762 | 776 | ||
763 | public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) | 777 | public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory) |
764 | { | 778 | { |
765 | } | 779 | } |
766 | public virtual void SendAbortXferPacket(ulong xferID) | 780 | public virtual void SendAbortXferPacket(ulong xferID) |
@@ -905,10 +919,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
905 | 919 | ||
906 | public void Close() | 920 | public void Close() |
907 | { | 921 | { |
908 | Close(false); | 922 | Close(true, false); |
909 | } | 923 | } |
910 | 924 | ||
911 | public void Close(bool force) | 925 | public void Close(bool sendStop, bool force) |
912 | { | 926 | { |
913 | // Remove ourselves from the scene | 927 | // Remove ourselves from the scene |
914 | m_scene.RemoveClient(AgentId, false); | 928 | m_scene.RemoveClient(AgentId, false); |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 69189b3..b0a29c0 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -145,10 +145,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
145 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, | 145 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, |
146 | int.MaxValue); | 146 | int.MaxValue); |
147 | 147 | ||
148 | m_log.DebugFormat( | 148 | // m_log.DebugFormat( |
149 | "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", | 149 | // "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", |
150 | firstname, lastname, npcAvatar.AgentId, owner, | 150 | // firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); |
151 | senseAsAgent, position, scene.RegionInfo.RegionName); | ||
152 | 151 | ||
153 | AgentCircuitData acd = new AgentCircuitData(); | 152 | AgentCircuitData acd = new AgentCircuitData(); |
154 | acd.AgentID = npcAvatar.AgentId; | 153 | acd.AgentID = npcAvatar.AgentId; |
@@ -171,36 +170,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
171 | } | 170 | } |
172 | */ | 171 | */ |
173 | 172 | ||
174 | lock (m_avatars) | 173 | ManualResetEvent ev = new ManualResetEvent(false); |
175 | { | ||
176 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, | ||
177 | acd); | ||
178 | scene.AddNewClient(npcAvatar, PresenceType.Npc); | ||
179 | 174 | ||
180 | ScenePresence sp; | 175 | Util.FireAndForget(delegate(object x) { |
181 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 176 | lock (m_avatars) |
182 | { | 177 | { |
183 | /* | 178 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); |
184 | m_log.DebugFormat( | 179 | scene.AddNewClient(npcAvatar, PresenceType.Npc); |
185 | "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", | ||
186 | sp.Name, sp.UUID); | ||
187 | */ | ||
188 | |||
189 | sp.CompleteMovement(npcAvatar, false); | ||
190 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | ||
191 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", | ||
192 | npcAvatar.AgentId, sp.Name); | ||
193 | 180 | ||
194 | return npcAvatar.AgentId; | 181 | ScenePresence sp; |
195 | } | 182 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
196 | else | 183 | { |
197 | { | 184 | sp.CompleteMovement(npcAvatar, false); |
198 | m_log.WarnFormat( | 185 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); |
199 | "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", | 186 | // m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); |
200 | sp.Name, sp.UUID); | 187 | } |
201 | return UUID.Zero; | ||
202 | } | 188 | } |
203 | } | 189 | ev.Set(); |
190 | }); | ||
191 | |||
192 | ev.WaitOne(); | ||
193 | |||
194 | // m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); | ||
195 | |||
196 | return npcAvatar.AgentId; | ||
204 | } | 197 | } |
205 | 198 | ||
206 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, | 199 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, |
@@ -213,10 +206,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
213 | ScenePresence sp; | 206 | ScenePresence sp; |
214 | if (scene.TryGetScenePresence(agentID, out sp)) | 207 | if (scene.TryGetScenePresence(agentID, out sp)) |
215 | { | 208 | { |
216 | m_log.DebugFormat( | 209 | // m_log.DebugFormat( |
217 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", | 210 | // "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", |
218 | sp.Name, pos, scene.RegionInfo.RegionName, | 211 | // sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); |
219 | noFly, landAtTarget); | ||
220 | 212 | ||
221 | sp.MoveToTarget(pos, noFly, landAtTarget); | 213 | sp.MoveToTarget(pos, noFly, landAtTarget); |
222 | sp.SetAlwaysRun = running; | 214 | sp.SetAlwaysRun = running; |
@@ -387,10 +379,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
387 | */ | 379 | */ |
388 | scene.RemoveClient(agentID, false); | 380 | scene.RemoveClient(agentID, false); |
389 | m_avatars.Remove(agentID); | 381 | m_avatars.Remove(agentID); |
390 | /* | 382 | |
391 | m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", | 383 | // m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); |
392 | agentID, av.Name); | ||
393 | */ | ||
394 | return true; | 384 | return true; |
395 | } | 385 | } |
396 | } | 386 | } |
@@ -407,9 +397,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
407 | { | 397 | { |
408 | NPCAvatar av; | 398 | NPCAvatar av; |
409 | if (m_avatars.TryGetValue(npcID, out av)) | 399 | if (m_avatars.TryGetValue(npcID, out av)) |
400 | { | ||
401 | if (npcID == callerID) | ||
402 | return true; | ||
410 | return CheckPermissions(av, callerID); | 403 | return CheckPermissions(av, callerID); |
404 | } | ||
411 | else | 405 | else |
406 | { | ||
412 | return false; | 407 | return false; |
408 | } | ||
413 | } | 409 | } |
414 | } | 410 | } |
415 | 411 | ||
@@ -421,8 +417,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
421 | /// <returns>true if they do, false if they don't.</returns> | 417 | /// <returns>true if they do, false if they don't.</returns> |
422 | private bool CheckPermissions(NPCAvatar av, UUID callerID) | 418 | private bool CheckPermissions(NPCAvatar av, UUID callerID) |
423 | { | 419 | { |
424 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || | 420 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID || av.AgentId == callerID; |
425 | av.OwnerID == callerID; | ||
426 | } | 421 | } |
427 | } | 422 | } |
428 | } | 423 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index bf23040..34362af 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -110,7 +110,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
110 | // ScenePresence.SendInitialData() to reset our entire appearance. | 110 | // ScenePresence.SendInitialData() to reset our entire appearance. |
111 | m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); | 111 | m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); |
112 | 112 | ||
113 | m_afMod.SetAppearance(sp, originalTe, null); | 113 | m_afMod.SetAppearance(sp, originalTe, null, new WearableCacheItem[0] ); |
114 | 114 | ||
115 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); | 115 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); |
116 | 116 | ||