diff options
author | Charles Krinke | 2008-03-01 00:59:23 +0000 |
---|---|---|
committer | Charles Krinke | 2008-03-01 00:59:23 +0000 |
commit | 56697133d406fd7dea90e0cf4088dac611df2e6a (patch) | |
tree | e66a865be85be41be78ea8cf3d64b6b775ca66e6 | |
parent | From: Mike Pitman <pitman@us.ibm.com> (diff) | |
download | opensim-SC-56697133d406fd7dea90e0cf4088dac611df2e6a.zip opensim-SC-56697133d406fd7dea90e0cf4088dac611df2e6a.tar.gz opensim-SC-56697133d406fd7dea90e0cf4088dac611df2e6a.tar.bz2 opensim-SC-56697133d406fd7dea90e0cf4088dac611df2e6a.tar.xz |
Thank you very much, Kinoc for:
* Impelements llInstantMessage
* Reimplements llOwnerSay as llInstantMessage(llGetOWner(),msg).
* Try's to better identify the "True Name" of objects in llDetectedName
by checking for avatar name, scene Object Part name and entity name.
* Uses similar logic in the llSensor and llSensorRepeat functions.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 89 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs | 33 |
2 files changed, 101 insertions, 21 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 7b59d73..78d3a3f 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Region.Environment.Interfaces; | |||
40 | using OpenSim.Region.Environment.Scenes; | 40 | using OpenSim.Region.Environment.Scenes; |
41 | using OpenSim.Region.ScriptEngine.Common; | 41 | using OpenSim.Region.ScriptEngine.Common; |
42 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; | 42 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; |
43 | using OpenSim.Region.Environment; | ||
43 | //using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; | 44 | //using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; |
44 | 45 | ||
45 | namespace OpenSim.Region.ScriptEngine.Common | 46 | namespace OpenSim.Region.ScriptEngine.Common |
@@ -402,23 +403,43 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
402 | // NotImplemented("llSensorRemove"); | 403 | // NotImplemented("llSensorRemove"); |
403 | } | 404 | } |
404 | 405 | ||
406 | public string resolveName(LLUUID objecUUID) | ||
407 | { | ||
408 | // try avatar username surname | ||
409 | UserProfileData profile = World.CommsManager.UserService.GetUserProfile(objecUUID); | ||
410 | if (profile != null) | ||
411 | { | ||
412 | string avatarname = profile.username + " " + profile.surname; | ||
413 | return avatarname; | ||
414 | } | ||
415 | // try an scene object | ||
416 | SceneObjectPart SOP = World.GetSceneObjectPart(objecUUID); | ||
417 | if (SOP != null) | ||
418 | { | ||
419 | string objectname = SOP.Name; | ||
420 | return objectname; | ||
421 | } | ||
422 | |||
423 | EntityBase SensedObject = null; | ||
424 | lock (World.Entities) | ||
425 | { | ||
426 | World.Entities.TryGetValue(objecUUID, out SensedObject); | ||
427 | } | ||
428 | |||
429 | if (SensedObject == null) | ||
430 | return String.Empty; | ||
431 | return SensedObject.Name; | ||
432 | |||
433 | } | ||
434 | |||
405 | public string llDetectedName(int number) | 435 | public string llDetectedName(int number) |
406 | { | 436 | { |
407 | m_host.AddScriptLPS(1); | 437 | m_host.AddScriptLPS(1); |
408 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); | 438 | LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); |
409 | if ((number>0)&&(number <= SenseList.Length)) | 439 | if ((number>=0)&&(number <= SenseList.Length)) |
410 | { | 440 | { |
411 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; | 441 | LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; |
412 | //ScenePresence SensedObject = World.GetScenePresence(SensedUUID); | 442 | return resolveName(SensedUUID); |
413 | EntityBase SensedObject=null; | ||
414 | lock (World.Entities) | ||
415 | { | ||
416 | World.Entities.TryGetValue(SensedUUID, out SensedObject); | ||
417 | } | ||
418 | |||
419 | if (SensedObject == null) | ||
420 | return String.Empty; | ||
421 | return SensedObject.Name; | ||
422 | } | 443 | } |
423 | else | 444 | else |
424 | return String.Empty; | 445 | return String.Empty; |
@@ -464,6 +485,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
464 | 485 | ||
465 | public string llDetectedOwner(int number) | 486 | public string llDetectedOwner(int number) |
466 | { | 487 | { |
488 | // returns UUID of owner of object detected | ||
467 | m_host.AddScriptLPS(1); | 489 | m_host.AddScriptLPS(1); |
468 | EntityBase SensedObject = entityDetectedKey(number); | 490 | EntityBase SensedObject = entityDetectedKey(number); |
469 | if (SensedObject ==null) | 491 | if (SensedObject ==null) |
@@ -1413,16 +1435,47 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
1413 | public void llInstantMessage(string user, string message) | 1435 | public void llInstantMessage(string user, string message) |
1414 | { | 1436 | { |
1415 | m_host.AddScriptLPS(1); | 1437 | m_host.AddScriptLPS(1); |
1416 | NotImplemented("llInstantMessage"); | ||
1417 | 1438 | ||
1418 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. | 1439 | // We may be able to use ClientView.SendInstantMessage here, but we need a client instance. |
1419 | // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent, | 1440 | // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent, |
1420 | // but I don't think we have a list of scenes available from here. | 1441 | // but I don't think we have a list of scenes available from here. |
1421 | // (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.) | 1442 | // (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.) |
1443 | |||
1444 | // user is a UUID | ||
1422 | 1445 | ||
1423 | // TODO: figure out values for client, fromSession, and imSessionID | 1446 | // TODO: figure out values for client, fromSession, and imSessionID |
1424 | // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch()); | 1447 | // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch()); |
1425 | } | 1448 | LLUUID friendTransactionID = LLUUID.Random(); |
1449 | |||
1450 | //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); | ||
1451 | |||
1452 | GridInstantMessage msg = new GridInstantMessage(); | ||
1453 | msg.fromAgentID = new System.Guid(m_host.UUID.ToString()); // fromAgentID.UUID; | ||
1454 | msg.fromAgentSession = new System.Guid(friendTransactionID.ToString());// fromAgentSession.UUID; | ||
1455 | msg.toAgentID = new System.Guid(user); // toAgentID.UUID; | ||
1456 | msg.imSessionID = new System.Guid(friendTransactionID.ToString()); // This is the item we're mucking with here | ||
1457 | Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); | ||
1458 | Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); | ||
1459 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; | ||
1460 | //if (client != null) | ||
1461 | //{ | ||
1462 | msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName; | ||
1463 | //} | ||
1464 | //else | ||
1465 | //{ | ||
1466 | // msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it | ||
1467 | //} | ||
1468 | msg.message = message; | ||
1469 | msg.dialog = (byte)19; // messgage from script ??? // dialog; | ||
1470 | msg.fromGroup = false;// fromGroup; | ||
1471 | msg.offline = (byte)0; //offline; | ||
1472 | msg.ParentEstateID = 0; //ParentEstateID; | ||
1473 | msg.Position = new sLLVector3();// new sLLVector3(m_host.AbsolutePosition); | ||
1474 | msg.RegionID = World.RegionInfo.RegionID.UUID;//RegionID.UUID; | ||
1475 | msg.binaryBucket = new byte[0];// binaryBucket; | ||
1476 | World.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); | ||
1477 | // NotImplemented("llInstantMessage"); | ||
1478 | } | ||
1426 | 1479 | ||
1427 | public void llEmail(string address, string subject, string message) | 1480 | public void llEmail(string address, string subject, string message) |
1428 | { | 1481 | { |
@@ -3733,13 +3786,15 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3733 | 3786 | ||
3734 | public void llOwnerSay(string msg) | 3787 | public void llOwnerSay(string msg) |
3735 | { | 3788 | { |
3736 | m_host.AddScriptLPS(1); | 3789 | //m_host.AddScriptLPS(1); // since we reuse llInstantMessage |
3737 | //temp fix so that lsl wiki examples aren't annoying to use to test other functions | 3790 | //temp fix so that lsl wiki examples aren't annoying to use to test other functions |
3738 | //should be similar to : llInstantMessage(llGetOwner(),msg) | 3791 | //should be similar to : llInstantMessage(llGetOwner(),msg) |
3739 | // llGetOwner ==> m_host.ObjectOwner.ToString() | 3792 | // llGetOwner ==> m_host.ObjectOwner.ToString() |
3740 | World.SimChat(Helpers.StringToField(msg), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); | 3793 | llInstantMessage(m_host.ObjectOwner.ToString(),msg); |
3741 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | 3794 | |
3742 | wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Say, 0, m_host.Name, msg); | 3795 | //World.SimChat(Helpers.StringToField(msg), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); |
3796 | //IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
3797 | //wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Say, 0, m_host.Name, msg); | ||
3743 | } | 3798 | } |
3744 | 3799 | ||
3745 | public void llRequestSimulatorData(string simulator, int data) | 3800 | public void llRequestSimulatorData(string simulator, int data) |
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs index edf3fde..bff85af 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs | |||
@@ -236,7 +236,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin | |||
236 | 236 | ||
237 | // Right type too, what about the other params , key and name ? | 237 | // Right type too, what about the other params , key and name ? |
238 | bool keep = true; | 238 | bool keep = true; |
239 | if (ts.arc != Math.PI) | 239 | if (ts.arc < Math.PI) |
240 | { | 240 | { |
241 | // not omni-directional. Can you see it ? | 241 | // not omni-directional. Can you see it ? |
242 | // vec forward_dir = llRot2Fwd(llGetRot()) | 242 | // vec forward_dir = llRot2Fwd(llGetRot()) |
@@ -261,15 +261,40 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin | |||
261 | if (ang_obj > ts.arc) keep = false; | 261 | if (ang_obj > ts.arc) keep = false; |
262 | } | 262 | } |
263 | 263 | ||
264 | if (keep && (ts.name.Length > 0) && (ts.name != ent.Name)) | 264 | |
265 | if (keep && (ts.keyID != null) && (ts.keyID != LLUUID.Zero) && (ts.keyID != ent.UUID)) | ||
265 | { | 266 | { |
266 | keep = false; | 267 | keep = false; |
267 | } | 268 | } |
268 | 269 | ||
269 | if (keep && (ts.keyID != null) && (ts.keyID != LLUUID.Zero) && (ts.keyID != ent.UUID)) | 270 | if (keep&& (ts.name.Length > 0)) |
270 | { | 271 | { |
271 | keep = false; | 272 | string avatarname=null; |
273 | string objectname=null; | ||
274 | string entname =ent.Name; | ||
275 | |||
276 | // try avatar username surname | ||
277 | UserProfileData profile = m_CmdManager.m_ScriptEngine.World.CommsManager.UserService.GetUserProfile(ent.UUID); | ||
278 | if (profile != null) | ||
279 | { | ||
280 | avatarname = profile.username + " " + profile.surname; | ||
281 | } | ||
282 | // try an scene object | ||
283 | SceneObjectPart SOP = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID); | ||
284 | if (SOP != null) | ||
285 | { | ||
286 | objectname = SOP.Name; | ||
287 | } | ||
288 | |||
289 | |||
290 | if ((ts.name != entname) && (ts.name != avatarname) && (ts.name != objectname)) | ||
291 | { | ||
292 | keep = false; | ||
293 | } | ||
294 | |||
295 | |||
272 | } | 296 | } |
297 | |||
273 | if (keep == true) SensedObjects.Add(ent.UUID); | 298 | if (keep == true) SensedObjects.Add(ent.UUID); |
274 | } | 299 | } |
275 | } | 300 | } |