aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorMelanie2011-04-08 04:19:17 +0100
committerMelanie2011-04-08 04:19:17 +0100
commitabea0c74c2b092d0474880a30433d9d0a2400aa8 (patch)
tree8b4e347bcdec3ee12a3026f789a96b1ffd32762e /OpenSim/Region/ScriptEngine/Shared
parenttrivial whitespace removal to trigger a panda rebuild (diff)
downloadopensim-SC_OLD-abea0c74c2b092d0474880a30433d9d0a2400aa8.zip
opensim-SC_OLD-abea0c74c2b092d0474880a30433d9d0a2400aa8.tar.gz
opensim-SC_OLD-abea0c74c2b092d0474880a30433d9d0a2400aa8.tar.bz2
opensim-SC_OLD-abea0c74c2b092d0474880a30433d9d0a2400aa8.tar.xz
Add support for the new display name related functions in LSL. This does not
implement the display names functionality as such, but it allows scripts that are display name aware to function as if the display name were implemented and set to the avatar name.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs49
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs26
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs20
5 files changed, 97 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index e5be641..c16a985 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10268,6 +10268,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10268 m_log.Info("LSL print():" + str); 10268 m_log.Info("LSL print():" + str);
10269 } 10269 }
10270 } 10270 }
10271
10272 private string Name2Username(string name)
10273 {
10274 string[] parts = name.Split(new char[] {' '});
10275 if (parts.Length < 2)
10276 return name.ToLower();
10277 if (parts[1] == "Resident")
10278 return parts[0].ToLower();
10279
10280 return name.Replace(" ", ".").ToLower();
10281 }
10282
10283 public LSL_String llGetUsername(string id)
10284 {
10285 return Name2Username(llKey2Name(id));
10286 }
10287
10288 public LSL_String llRequestUsername(string id)
10289 {
10290 UUID rq = UUID.Random();
10291
10292 UUID tid = AsyncCommands.
10293 DataserverPlugin.RegisterRequest(m_localID,
10294 m_itemID, rq.ToString());
10295
10296 AsyncCommands.
10297 DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
10298
10299 return rq.ToString();
10300 }
10301
10302 public LSL_String llGetDisplayName(string id)
10303 {
10304 return llKey2Name(id);
10305 }
10306
10307 public LSL_String llRequestDisplayName(string id)
10308 {
10309 UUID rq = UUID.Random();
10310
10311 UUID tid = AsyncCommands.
10312 DataserverPlugin.RegisterRequest(m_localID,
10313 m_itemID, rq.ToString());
10314
10315 AsyncCommands.
10316 DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
10317
10318 return rq.ToString();
10319 }
10271 } 10320 }
10272 10321
10273 public class NotecardCache 10322 public class NotecardCache
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index fefbb35..47c7915 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -50,6 +50,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
50 private Object SenseLock = new Object(); 50 private Object SenseLock = new Object();
51 51
52 private const int AGENT = 1; 52 private const int AGENT = 1;
53 private const int AGENT_BY_USERNAME = 0x10;
53 private const int ACTIVE = 2; 54 private const int ACTIVE = 2;
54 private const int PASSIVE = 4; 55 private const int PASSIVE = 4;
55 private const int SCRIPTED = 8; 56 private const int SCRIPTED = 8;
@@ -202,7 +203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
202 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 203 List<SensedEntity> sensedEntities = new List<SensedEntity>();
203 204
204 // Is the sensor type is AGENT and not SCRIPTED then include agents 205 // Is the sensor type is AGENT and not SCRIPTED then include agents
205 if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) 206 if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0)
206 { 207 {
207 sensedEntities.AddRange(doAgentSensor(ts)); 208 sensedEntities.AddRange(doAgentSensor(ts));
208 } 209 }
@@ -493,9 +494,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
493 { 494 {
494 ScenePresence sp; 495 ScenePresence sp;
495 // Try lookup by name will return if/when found 496 // Try lookup by name will return if/when found
496 if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp)) 497 if (((ts.type & AGENT) != 0) && m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
497 return sensedEntities; 498 senseEntity(sp);
498 senseEntity(sp); 499 if ((ts.type & AGENT_BY_USERNAME) != 0)
500 {
501 m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(
502 delegate (ScenePresence ssp)
503 {
504 if (ssp.Lastname == "Resident")
505 {
506 if (ssp.Firstname.ToLower() == ts.name)
507 senseEntity(ssp);
508 return;
509 }
510 if (ssp.Name.Replace(" ", ".").ToLower() == ts.name)
511 senseEntity(ssp);
512 }
513 );
514 }
515
516 return sensedEntities;
499 } 517 }
500 else 518 else
501 { 519 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index bd6a094..654ea81 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -209,6 +209,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
209 void llInstantMessage(string user, string message); 209 void llInstantMessage(string user, string message);
210 LSL_String llIntegerToBase64(int number); 210 LSL_String llIntegerToBase64(int number);
211 LSL_String llKey2Name(string id); 211 LSL_String llKey2Name(string id);
212 LSL_String llGetUsername(string id);
213 LSL_String llRequestUsername(string id);
214 LSL_String llGetDisplayName(string id);
215 LSL_String llRequestDisplayName(string id);
212 void llLinkParticleSystem(int linknum, LSL_List rules); 216 void llLinkParticleSystem(int linknum, LSL_List rules);
213 LSL_String llList2CSV(LSL_List src); 217 LSL_String llList2CSV(LSL_List src);
214 LSL_Float llList2Float(LSL_List src, int index); 218 LSL_Float llList2Float(LSL_List src, int index);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index b3c4d95..9377cda 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -50,6 +50,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
50 public const int STATUS_CAST_SHADOWS = 512; 50 public const int STATUS_CAST_SHADOWS = 512;
51 51
52 public const int AGENT = 1; 52 public const int AGENT = 1;
53 public const int AGENT_BY_LEGACY_NAME = 1;
54 public const int AGENT_BY_USERNAME = 0x10;
53 public const int ACTIVE = 2; 55 public const int ACTIVE = 2;
54 public const int PASSIVE = 4; 56 public const int PASSIVE = 4;
55 public const int SCRIPTED = 8; 57 public const int SCRIPTED = 8;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 3b29861..303d75e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -894,6 +894,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
894 return m_LSL_Functions.llKey2Name(id); 894 return m_LSL_Functions.llKey2Name(id);
895 } 895 }
896 896
897 public LSL_String llGetUsername(string id)
898 {
899 return m_LSL_Functions.llGetUsername(id);
900 }
901
902 public LSL_String llRequestUsername(string id)
903 {
904 return m_LSL_Functions.llRequestUsername(id);
905 }
906
907 public LSL_String llGetDisplayName(string id)
908 {
909 return m_LSL_Functions.llGetDisplayName(id);
910 }
911
912 public LSL_String llRequestDisplayName(string id)
913 {
914 return m_LSL_Functions.llRequestDisplayName(id);
915 }
916
897 public void llLinkParticleSystem(int linknum, LSL_List rules) 917 public void llLinkParticleSystem(int linknum, LSL_List rules)
898 { 918 {
899 m_LSL_Functions.llLinkParticleSystem(linknum, rules); 919 m_LSL_Functions.llLinkParticleSystem(linknum, rules);