diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 15 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 45 |
2 files changed, 37 insertions, 23 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index be0d56e..d0b822c 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -44,7 +44,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
44 | private readonly string m_firstname; | 44 | private readonly string m_firstname; |
45 | private readonly string m_lastname; | 45 | private readonly string m_lastname; |
46 | private readonly Vector3 m_startPos; | 46 | private readonly Vector3 m_startPos; |
47 | private readonly UUID m_uuid = UUID.Random(); | 47 | private UUID m_uuid = UUID.Random(); |
48 | private readonly Scene m_scene; | 48 | private readonly Scene m_scene; |
49 | private readonly UUID m_ownerID; | 49 | private readonly UUID m_ownerID; |
50 | 50 | ||
@@ -171,7 +171,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
171 | #pragma warning disable 67 | 171 | #pragma warning disable 67 |
172 | public event Action<IClientAPI> OnLogout; | 172 | public event Action<IClientAPI> OnLogout; |
173 | public event ObjectPermissions OnObjectPermissions; | 173 | public event ObjectPermissions OnObjectPermissions; |
174 | 174 | public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy; | |
175 | public event MoneyTransferRequest OnMoneyTransferRequest; | 175 | public event MoneyTransferRequest OnMoneyTransferRequest; |
176 | public event ParcelBuy OnParcelBuy; | 176 | public event ParcelBuy OnParcelBuy; |
177 | public event Action<IClientAPI> OnConnectionClosed; | 177 | public event Action<IClientAPI> OnConnectionClosed; |
@@ -377,7 +377,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
377 | public event ClassifiedInfoRequest OnClassifiedInfoRequest; | 377 | public event ClassifiedInfoRequest OnClassifiedInfoRequest; |
378 | public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; | 378 | public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; |
379 | public event ClassifiedDelete OnClassifiedDelete; | 379 | public event ClassifiedDelete OnClassifiedDelete; |
380 | public event ClassifiedDelete OnClassifiedGodDelete; | 380 | public event ClassifiedGodDelete OnClassifiedGodDelete; |
381 | 381 | ||
382 | public event EventNotificationAddRequest OnEventNotificationAddRequest; | 382 | public event EventNotificationAddRequest OnEventNotificationAddRequest; |
383 | public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; | 383 | public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; |
@@ -416,6 +416,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
416 | public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; | 416 | public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; |
417 | public event SimWideDeletesDelegate OnSimWideDeletes; | 417 | public event SimWideDeletesDelegate OnSimWideDeletes; |
418 | public event SendPostcard OnSendPostcard; | 418 | public event SendPostcard OnSendPostcard; |
419 | public event ChangeInventoryItemFlags OnChangeInventoryItemFlags; | ||
419 | public event MuteListEntryUpdate OnUpdateMuteListEntry; | 420 | public event MuteListEntryUpdate OnUpdateMuteListEntry; |
420 | public event MuteListEntryRemove OnRemoveMuteListEntry; | 421 | public event MuteListEntryRemove OnRemoveMuteListEntry; |
421 | public event GodlikeMessage onGodlikeMessage; | 422 | public event GodlikeMessage onGodlikeMessage; |
@@ -443,6 +444,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
443 | public virtual UUID AgentId | 444 | public virtual UUID AgentId |
444 | { | 445 | { |
445 | get { return m_uuid; } | 446 | get { return m_uuid; } |
447 | set { m_uuid = value; } | ||
446 | } | 448 | } |
447 | 449 | ||
448 | public UUID SessionId | 450 | public UUID SessionId |
@@ -851,8 +853,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
851 | 853 | ||
852 | public void Close() | 854 | public void Close() |
853 | { | 855 | { |
854 | // Remove ourselves from the scene | 856 | Close(true); |
855 | m_scene.RemoveClient(AgentId, false); | 857 | } |
858 | |||
859 | public void Close(bool sendStop) | ||
860 | { | ||
856 | } | 861 | } |
857 | 862 | ||
858 | public void Start() | 863 | public void Start() |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 2b8379d..68f21c8 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -144,29 +144,38 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
144 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | 144 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); |
145 | // } | 145 | // } |
146 | 146 | ||
147 | lock (m_avatars) | 147 | ManualResetEvent ev = new ManualResetEvent(false); |
148 | { | ||
149 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); | ||
150 | scene.AddNewClient(npcAvatar, PresenceType.Npc); | ||
151 | 148 | ||
152 | ScenePresence sp; | 149 | Util.FireAndForget(delegate(object x) { |
153 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 150 | lock (m_avatars) |
154 | { | 151 | { |
155 | // m_log.DebugFormat( | 152 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); |
156 | // "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); | 153 | scene.AddNewClient(npcAvatar, PresenceType.Npc); |
157 | 154 | ||
158 | sp.CompleteMovement(npcAvatar, false); | 155 | ScenePresence sp; |
159 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | 156 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
160 | m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); | 157 | { |
158 | m_log.DebugFormat( | ||
159 | "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); | ||
160 | |||
161 | sp.CompleteMovement(npcAvatar, false); | ||
162 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | ||
163 | } | ||
164 | else | ||
165 | { | ||
166 | m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); | ||
167 | npcAvatar.AgentId = UUID.Zero; | ||
168 | } | ||
161 | 169 | ||
162 | return npcAvatar.AgentId; | ||
163 | } | ||
164 | else | ||
165 | { | ||
166 | m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); | ||
167 | return UUID.Zero; | ||
168 | } | 170 | } |
169 | } | 171 | ev.Set(); |
172 | }); | ||
173 | |||
174 | ev.WaitOne(); | ||
175 | |||
176 | // m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); | ||
177 | |||
178 | return npcAvatar.AgentId; | ||
170 | } | 179 | } |
171 | 180 | ||
172 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) | 181 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) |