aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
authorMelanie2012-01-06 22:35:06 +0000
committerMelanie2012-01-06 22:35:06 +0000
commit7518b075b76fea062971a9e5fb716118130ebe43 (patch)
treedf4449fdfe02de0b706cac6024603e4ebabdb256 /OpenSim/Region/OptionalModules
parenteliminate a few tabs from OpenSimDefaults.ini (diff)
downloadopensim-SC_OLD-7518b075b76fea062971a9e5fb716118130ebe43.zip
opensim-SC_OLD-7518b075b76fea062971a9e5fb716118130ebe43.tar.gz
opensim-SC_OLD-7518b075b76fea062971a9e5fb716118130ebe43.tar.bz2
opensim-SC_OLD-7518b075b76fea062971a9e5fb716118130ebe43.tar.xz
Add osNpcCreateOwned to create an owned NPC. Those can be sensed only by the owner, can be destroyed only by the owner and only the owner can save their appearance. Added "NPC" as a flag to llSensor to sense NPCs and exclude them from "AGENT" results.
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs9
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs28
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs10
3 files changed, 36 insertions, 11 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 84055cc..5f4f937 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -42,13 +42,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
42 private readonly Vector3 m_startPos; 42 private readonly Vector3 m_startPos;
43 private readonly UUID m_uuid = UUID.Random(); 43 private readonly UUID m_uuid = UUID.Random();
44 private readonly Scene m_scene; 44 private readonly Scene m_scene;
45 private readonly UUID m_ownerID;
45 46
46 public NPCAvatar(string firstname, string lastname, Vector3 position, Scene scene) 47 public NPCAvatar(string firstname, string lastname, Vector3 position, UUID ownerID, Scene scene)
47 { 48 {
48 m_firstname = firstname; 49 m_firstname = firstname;
49 m_lastname = lastname; 50 m_lastname = lastname;
50 m_startPos = position; 51 m_startPos = position;
51 m_scene = scene; 52 m_scene = scene;
53 m_ownerID = ownerID;
52 } 54 }
53 55
54 public IScene Scene 56 public IScene Scene
@@ -56,6 +58,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
56 get { return m_scene; } 58 get { return m_scene; }
57 } 59 }
58 60
61 public UUID OwnerID
62 {
63 get { return m_ownerID; }
64 }
65
59 public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } } 66 public ISceneAgent SceneAgent { get { throw new NotImplementedException(); } }
60 67
61 public void Say(string message) 68 public void Say(string message)
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 56ff367..e874417 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -91,9 +91,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
91 } 91 }
92 92
93 public UUID CreateNPC( 93 public UUID CreateNPC(
94 string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance) 94 string firstname, string lastname, Vector3 position, UUID owner, Scene scene, AvatarAppearance appearance)
95 { 95 {
96 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); 96 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, scene);
97 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); 97 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
98 98
99 m_log.DebugFormat( 99 m_log.DebugFormat(
@@ -234,12 +234,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC
234 return false; 234 return false;
235 } 235 }
236 236
237 public bool DeleteNPC(UUID agentID, Scene scene) 237 public UUID GetOwner(UUID agentID)
238 { 238 {
239 lock (m_avatars) 239 lock (m_avatars)
240 { 240 {
241 if (m_avatars.ContainsKey(agentID)) 241 NPCAvatar av;
242 if (m_avatars.TryGetValue(agentID, out av))
242 { 243 {
244 return av.OwnerID;
245 }
246 }
247
248 return UUID.Zero;
249 }
250
251 public bool DeleteNPC(UUID agentID, UUID callerID, Scene scene)
252 {
253 lock (m_avatars)
254 {
255 NPCAvatar av;
256 if (m_avatars.TryGetValue(agentID, out av))
257 {
258 if (av.OwnerID != UUID.Zero && callerID != UUID.Zero && av.OwnerID != callerID)
259 return false;
260
243 scene.RemoveClient(agentID, false); 261 scene.RemoveClient(agentID, false);
244 m_avatars.Remove(agentID); 262 m_avatars.Remove(agentID);
245 263
@@ -268,4 +286,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC
268 get { return true; } 286 get { return true; }
269 } 287 }
270 } 288 }
271} \ No newline at end of file 289}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 9c66b25..571d33d 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
109 afm.SetAppearance(sp, originalTe, null); 109 afm.SetAppearance(sp, originalTe, null);
110 110
111 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 111 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
112 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); 112 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, scene, sp.Appearance);
113 113
114 ScenePresence npc = scene.GetScenePresence(npcId); 114 ScenePresence npc = scene.GetScenePresence(npcId);
115 115
@@ -137,7 +137,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
137 am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest); 137 am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
138 138
139 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 139 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
140 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); 140 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, scene, sp.Appearance);
141 141
142 ScenePresence npc = scene.GetScenePresence(npcId); 142 ScenePresence npc = scene.GetScenePresence(npcId);
143 143
@@ -169,7 +169,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
169 169
170 Vector3 startPos = new Vector3(128, 128, 30); 170 Vector3 startPos = new Vector3(128, 128, 30);
171 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 171 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
172 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); 172 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance);
173 173
174 ScenePresence npc = scene.GetScenePresence(npcId); 174 ScenePresence npc = scene.GetScenePresence(npcId);
175 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 175 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
@@ -240,7 +240,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
240 240
241 Vector3 startPos = new Vector3(128, 128, 30); 241 Vector3 startPos = new Vector3(128, 128, 30);
242 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 242 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
243 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); 243 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance);
244 244
245 ScenePresence npc = scene.GetScenePresence(npcId); 245 ScenePresence npc = scene.GetScenePresence(npcId);
246 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 246 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
@@ -273,7 +273,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
273 Vector3 startPos = new Vector3(1, 1, 1); 273 Vector3 startPos = new Vector3(1, 1, 1);
274 274
275 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 275 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
276 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); 276 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance);
277 277
278 ScenePresence npc = scene.GetScenePresence(npcId); 278 ScenePresence npc = scene.GetScenePresence(npcId);
279 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 279 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);