aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World/NPC
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs25
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs61
2 files changed, 53 insertions, 33 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index a8e4d90..bb3748e 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;
@@ -290,6 +291,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
290 public event UpdatePrimTexture OnUpdatePrimTexture; 291 public event UpdatePrimTexture OnUpdatePrimTexture;
291 public event UpdateVector OnUpdatePrimGroupPosition; 292 public event UpdateVector OnUpdatePrimGroupPosition;
292 public event UpdateVector OnUpdatePrimSinglePosition; 293 public event UpdateVector OnUpdatePrimSinglePosition;
294 public event ClientChangeObject onClientChangeObject;
293 public event UpdatePrimRotation OnUpdatePrimGroupRotation; 295 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
294 public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; 296 public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
295 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; 297 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
@@ -427,7 +429,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
427 public event ClassifiedInfoRequest OnClassifiedInfoRequest; 429 public event ClassifiedInfoRequest OnClassifiedInfoRequest;
428 public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; 430 public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
429 public event ClassifiedDelete OnClassifiedDelete; 431 public event ClassifiedDelete OnClassifiedDelete;
430 public event ClassifiedDelete OnClassifiedGodDelete; 432 public event ClassifiedGodDelete OnClassifiedGodDelete;
431 433
432 public event EventNotificationAddRequest OnEventNotificationAddRequest; 434 public event EventNotificationAddRequest OnEventNotificationAddRequest;
433 public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; 435 public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
@@ -466,6 +468,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
466 public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; 468 public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
467 public event SimWideDeletesDelegate OnSimWideDeletes; 469 public event SimWideDeletesDelegate OnSimWideDeletes;
468 public event SendPostcard OnSendPostcard; 470 public event SendPostcard OnSendPostcard;
471 public event ChangeInventoryItemFlags OnChangeInventoryItemFlags;
469 public event MuteListEntryUpdate OnUpdateMuteListEntry; 472 public event MuteListEntryUpdate OnUpdateMuteListEntry;
470 public event MuteListEntryRemove OnRemoveMuteListEntry; 473 public event MuteListEntryRemove OnRemoveMuteListEntry;
471 public event GodlikeMessage onGodlikeMessage; 474 public event GodlikeMessage onGodlikeMessage;
@@ -493,6 +496,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
493 public virtual UUID AgentId 496 public virtual UUID AgentId
494 { 497 {
495 get { return m_uuid; } 498 get { return m_uuid; }
499 set { m_uuid = value; }
496 } 500 }
497 501
498 public UUID SessionId 502 public UUID SessionId
@@ -735,6 +739,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
735 { 739 {
736 } 740 }
737 741
742 public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId)
743 {
744 }
745
738 public virtual void SendRemoveInventoryItem(UUID itemID) 746 public virtual void SendRemoveInventoryItem(UUID itemID)
739 { 747 {
740 } 748 }
@@ -751,7 +759,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
751 { 759 {
752 } 760 }
753 761
754 public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) 762 public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory)
755 { 763 {
756 } 764 }
757 public virtual void SendAbortXferPacket(ulong xferID) 765 public virtual void SendAbortXferPacket(ulong xferID)
@@ -901,10 +909,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
901 909
902 public void Close() 910 public void Close()
903 { 911 {
904 Close(false); 912 Close(true, false);
905 } 913 }
906 914
907 public void Close(bool force) 915 public void Close(bool sendStop, bool force)
908 { 916 {
909 // Remove ourselves from the scene 917 // Remove ourselves from the scene
910 m_scene.RemoveClient(AgentId, false); 918 m_scene.RemoveClient(AgentId, false);
@@ -1232,5 +1240,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1232 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) 1240 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
1233 { 1241 {
1234 } 1242 }
1243
1244 public void SendPartPhysicsProprieties(ISceneEntity entity)
1245 {
1246 }
1247
1235 } 1248 }
1236} 1249}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 3f25bcf..f16927c 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -124,9 +124,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
124 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); 124 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene);
125 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); 125 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
126 126
127 m_log.DebugFormat( 127// m_log.DebugFormat(
128 "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", 128// "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
129 firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); 129// firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName);
130 130
131 AgentCircuitData acd = new AgentCircuitData(); 131 AgentCircuitData acd = new AgentCircuitData();
132 acd.AgentID = npcAvatar.AgentId; 132 acd.AgentID = npcAvatar.AgentId;
@@ -144,29 +144,30 @@ 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
158 sp.CompleteMovement(npcAvatar, false);
159 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
160 m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
161 154
162 return npcAvatar.AgentId; 155 ScenePresence sp;
163 } 156 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
164 else 157 {
165 { 158 sp.CompleteMovement(npcAvatar, false);
166 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); 159 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
167 return UUID.Zero; 160// m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
161 }
168 } 162 }
169 } 163 ev.Set();
164 });
165
166 ev.WaitOne();
167
168// m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
169
170 return npcAvatar.AgentId;
170 } 171 }
171 172
172 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running) 173 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running)
@@ -178,9 +179,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
178 ScenePresence sp; 179 ScenePresence sp;
179 if (scene.TryGetScenePresence(agentID, out sp)) 180 if (scene.TryGetScenePresence(agentID, out sp))
180 { 181 {
181 m_log.DebugFormat( 182// m_log.DebugFormat(
182 "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", 183// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
183 sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); 184// sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget);
184 185
185 sp.MoveToTarget(pos, noFly, landAtTarget); 186 sp.MoveToTarget(pos, noFly, landAtTarget);
186 sp.SetAlwaysRun = running; 187 sp.SetAlwaysRun = running;
@@ -347,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
347 scene.RemoveClient(agentID, false); 348 scene.RemoveClient(agentID, false);
348 m_avatars.Remove(agentID); 349 m_avatars.Remove(agentID);
349 350
350 m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); 351// m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name);
351 return true; 352 return true;
352 } 353 }
353 } 354 }
@@ -362,9 +363,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
362 { 363 {
363 NPCAvatar av; 364 NPCAvatar av;
364 if (m_avatars.TryGetValue(npcID, out av)) 365 if (m_avatars.TryGetValue(npcID, out av))
366 {
367 if (npcID == callerID)
368 return true;
365 return CheckPermissions(av, callerID); 369 return CheckPermissions(av, callerID);
370 }
366 else 371 else
372 {
367 return false; 373 return false;
374 }
368 } 375 }
369 } 376 }
370 377
@@ -376,7 +383,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
376 /// <returns>true if they do, false if they don't.</returns> 383 /// <returns>true if they do, false if they don't.</returns>
377 private bool CheckPermissions(NPCAvatar av, UUID callerID) 384 private bool CheckPermissions(NPCAvatar av, UUID callerID)
378 { 385 {
379 return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID; 386 return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID || av.AgentId == callerID;
380 } 387 }
381 } 388 }
382} 389}