aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs119
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
3 files changed, 79 insertions, 46 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8776524..c87cc44 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -582,6 +582,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
582 return ""; 582 return "";
583 } 583 }
584 584
585 // Get a list of all the avatars/agents in the region
586 public LSL_List osGetAgents()
587 {
588 // threat level is None as we could get this information with an
589 // in-world script as well, just not as efficient
590 CheckThreatLevel(ThreatLevel.None, "osGetAgents");
591
592 LSL_List result = new LSL_List();
593 foreach (ScenePresence avatar in World.GetAvatars())
594 {
595 result.Add(avatar.Name);
596 }
597 return result;
598 }
599
585 // Adam's super super custom animation functions 600 // Adam's super super custom animation functions
586 public void osAvatarPlayAnimation(string avatar, string animation) 601 public void osAvatarPlayAnimation(string avatar, string animation)
587 { 602 {
@@ -595,7 +610,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
595 ScenePresence target = (ScenePresence)World.Entities[avatarID]; 610 ScenePresence target = (ScenePresence)World.Entities[avatarID];
596 if (target != null) 611 if (target != null)
597 { 612 {
598 UUID animID=UUID.Zero; 613 UUID animID=UUID.Zero;
599 lock (m_host.TaskInventory) 614 lock (m_host.TaskInventory)
600 { 615 {
601 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 616 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
@@ -626,9 +641,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
626 if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) 641 if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence)
627 { 642 {
628 ScenePresence target = (ScenePresence)World.Entities[avatarID]; 643 ScenePresence target = (ScenePresence)World.Entities[avatarID];
629 if (target != null) 644 if (target != null)
630 { 645 {
631 UUID animID=UUID.Zero; 646 UUID animID=UUID.Zero;
632 lock (m_host.TaskInventory) 647 lock (m_host.TaskInventory)
633 { 648 {
634 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 649 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
@@ -645,7 +660,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
645 target.RemoveAnimation(animation); 660 target.RemoveAnimation(animation);
646 else 661 else
647 target.RemoveAnimation(animID); 662 target.RemoveAnimation(animID);
648 } 663 }
649 } 664 }
650 } 665 }
651 666
@@ -998,16 +1013,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
998 1013
999 // see http://www.json.org/ for more details on JSON 1014 // see http://www.json.org/ for more details on JSON
1000 1015
1001 string currentKey=null; 1016 string currentKey = null;
1002 Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this 1017 Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this
1003 Hashtable jsondata = new Hashtable(); // the hashtable to be returned 1018 Hashtable jsondata = new Hashtable(); // the hashtable to be returned
1004 int i=0; 1019 int i = 0;
1005 try 1020 try
1006 { 1021 {
1007 1022
1008 // iterate through the serialised stream of tokens and store at the right depth in the hashtable 1023 // iterate through the serialised stream of tokens and store at the right depth in the hashtable
1009 // the top level hashtable may contain more nested hashtables within it each containing an objects representation 1024 // the top level hashtable may contain more nested hashtables within it each containing an objects representation
1010 for (i=0;i<JSON.Length; i++) 1025 for (i = 0; i < JSON.Length; i++)
1011 { 1026 {
1012 1027
1013 // m_log.Debug(""+JSON[i]); 1028 // m_log.Debug(""+JSON[i]);
@@ -1017,12 +1032,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1017 // create hashtable and add it to the stack or array if we are populating one, we can have a lot of nested objects in JSON 1032 // create hashtable and add it to the stack or array if we are populating one, we can have a lot of nested objects in JSON
1018 1033
1019 Hashtable currentObject = new Hashtable(); 1034 Hashtable currentObject = new Hashtable();
1020 if (objectStack.Count==0) // the stack should only be empty for the first outer object 1035 if (objectStack.Count == 0) // the stack should only be empty for the first outer object
1021 { 1036 {
1022 1037
1023 objectStack.Push(jsondata); 1038 objectStack.Push(jsondata);
1024 } 1039 }
1025 else if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 1040 else if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1026 { 1041 {
1027 // add it to the parent array 1042 // add it to the parent array
1028 ((ArrayList)objectStack.Peek()).Add(currentObject); 1043 ((ArrayList)objectStack.Peek()).Add(currentObject);
@@ -1036,26 +1051,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1036 } 1051 }
1037 1052
1038 // clear the key 1053 // clear the key
1039 currentKey=null; 1054 currentKey = null;
1040 break; 1055 break;
1056
1041 case '}': 1057 case '}':
1042 // pop the hashtable off the stack 1058 // pop the hashtable off the stack
1043 objectStack.Pop(); 1059 objectStack.Pop();
1044 break; 1060 break;
1061
1045 case '"':// string boundary 1062 case '"':// string boundary
1046 1063
1047 string tokenValue=""; 1064 string tokenValue = "";
1048 i++; // move to next char 1065 i++; // move to next char
1049 1066
1050 // just loop through until the next quote mark storing the string, ignore quotes with pre-ceding \ 1067 // just loop through until the next quote mark storing the string, ignore quotes with pre-ceding \
1051 while (JSON[i]!='"') 1068 while (JSON[i] != '"')
1052 { 1069 {
1053 tokenValue+=JSON[i]; 1070 tokenValue += JSON[i];
1054 1071
1055 // handle escaped double quotes \" 1072 // handle escaped double quotes \"
1056 if (JSON[i]=='\\' && JSON[i+1]=='"') 1073 if (JSON[i] == '\\' && JSON[i+1] == '"')
1057 { 1074 {
1058 tokenValue+=JSON[i+1]; 1075 tokenValue += JSON[i+1];
1059 i++; 1076 i++;
1060 } 1077 }
1061 i++; 1078 i++;
@@ -1063,11 +1080,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1063 } 1080 }
1064 1081
1065 // ok we've got a string, if we've got an array on the top of the stack then we store it 1082 // ok we've got a string, if we've got an array on the top of the stack then we store it
1066 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 1083 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1067 { 1084 {
1068 ((ArrayList)objectStack.Peek()).Add(tokenValue); 1085 ((ArrayList)objectStack.Peek()).Add(tokenValue);
1069 } 1086 }
1070 else if (currentKey==null) // no key stored and its not an array this must be a key so store it 1087 else if (currentKey == null) // no key stored and its not an array this must be a key so store it
1071 { 1088 {
1072 currentKey = tokenValue; 1089 currentKey = tokenValue;
1073 } 1090 }
@@ -1076,20 +1093,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1076 // we have a key so lets store this value 1093 // we have a key so lets store this value
1077 ((Hashtable)objectStack.Peek()).Add(currentKey,tokenValue); 1094 ((Hashtable)objectStack.Peek()).Add(currentKey,tokenValue);
1078 // now lets clear the key, we're done with it and moving on 1095 // now lets clear the key, we're done with it and moving on
1079 currentKey=null; 1096 currentKey = null;
1080 } 1097 }
1081 1098
1082 break; 1099 break;
1100
1083 case ':':// key : value separator 1101 case ':':// key : value separator
1084 // just ignore 1102 // just ignore
1085 break; 1103 break;
1104
1086 case ' ':// spaces 1105 case ' ':// spaces
1087 // just ignore 1106 // just ignore
1088 break; 1107 break;
1108
1089 case '[': // array start 1109 case '[': // array start
1090 ArrayList currentArray = new ArrayList(); 1110 ArrayList currentArray = new ArrayList();
1091 1111
1092 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 1112 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1093 { 1113 {
1094 ((ArrayList)objectStack.Peek()).Add(currentArray); 1114 ((ArrayList)objectStack.Peek()).Add(currentArray);
1095 } 1115 }
@@ -1097,69 +1117,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1097 { 1117 {
1098 ((Hashtable)objectStack.Peek()).Add(currentKey,currentArray); 1118 ((Hashtable)objectStack.Peek()).Add(currentKey,currentArray);
1099 // clear the key 1119 // clear the key
1100 currentKey=null; 1120 currentKey = null;
1101 } 1121 }
1102 objectStack.Push(currentArray); 1122 objectStack.Push(currentArray);
1103 1123
1104 break; 1124 break;
1125
1105 case ',':// seperator 1126 case ',':// seperator
1106 // just ignore 1127 // just ignore
1107 break; 1128 break;
1129
1108 case ']'://Array end 1130 case ']'://Array end
1109 // pop the array off the stack 1131 // pop the array off the stack
1110 objectStack.Pop(); 1132 objectStack.Pop();
1111 break; 1133 break;
1134
1112 case 't': // we've found a character start not in quotes, it must be a boolean true 1135 case 't': // we've found a character start not in quotes, it must be a boolean true
1113 1136
1114 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 1137 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1115 { 1138 {
1116 ((ArrayList)objectStack.Peek()).Add(true); 1139 ((ArrayList)objectStack.Peek()).Add(true);
1117 } 1140 }
1118 else 1141 else
1119 { 1142 {
1120 ((Hashtable)objectStack.Peek()).Add(currentKey,true); 1143 ((Hashtable)objectStack.Peek()).Add(currentKey,true);
1121 currentKey=null; 1144 currentKey = null;
1122 } 1145 }
1123 1146
1124 //advance the counter to the letter 'e' 1147 //advance the counter to the letter 'e'
1125 i = i+3; 1148 i = i + 3;
1126 break; 1149 break;
1150
1127 case 'f': // we've found a character start not in quotes, it must be a boolean false 1151 case 'f': // we've found a character start not in quotes, it must be a boolean false
1128 1152
1129 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 1153 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1130 { 1154 {
1131 ((ArrayList)objectStack.Peek()).Add(false); 1155 ((ArrayList)objectStack.Peek()).Add(false);
1132 } 1156 }
1133 else 1157 else
1134 { 1158 {
1135 ((Hashtable)objectStack.Peek()).Add(currentKey,false); 1159 ((Hashtable)objectStack.Peek()).Add(currentKey,false);
1136 currentKey=null; 1160 currentKey = null;
1137 } 1161 }
1138 //advance the counter to the letter 'e' 1162 //advance the counter to the letter 'e'
1139 i = i+4; 1163 i = i + 4;
1140 break; 1164 break;
1165
1141 case '\n':// carriage return 1166 case '\n':// carriage return
1142 // just ignore 1167 // just ignore
1143 break; 1168 break;
1169
1144 case '\r':// carriage return 1170 case '\r':// carriage return
1145 // just ignore 1171 // just ignore
1146 break; 1172 break;
1173
1147 default: 1174 default:
1148 // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately 1175 // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately
1149 // but for now we'll just do them as strings 1176 // but for now we'll just do them as strings
1150 1177
1151 string numberValue=""; 1178 string numberValue = "";
1152 1179
1153 // just loop through until the next known marker quote mark storing the string 1180 // just loop through until the next known marker quote mark storing the string
1154 while (JSON[i] != '"' && JSON[i] != ',' && JSON[i] != ']' && JSON[i] != '}' && JSON[i] != ' ') 1181 while (JSON[i] != '"' && JSON[i] != ',' && JSON[i] != ']' && JSON[i] != '}' && JSON[i] != ' ')
1155 { 1182 {
1156 numberValue+=""+JSON[i++]; 1183 numberValue += "" + JSON[i++];
1157 } 1184 }
1158 1185
1159 i--; // we want to process this caracter that marked the end of this string in the main loop 1186 i--; // we want to process this caracter that marked the end of this string in the main loop
1160 1187
1161 // ok we've got a string, if we've got an array on the top of the stack then we store it 1188 // ok we've got a string, if we've got an array on the top of the stack then we store it
1162 if (objectStack.Peek().ToString()=="System.Collections.ArrayList") 1189 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1163 { 1190 {
1164 ((ArrayList)objectStack.Peek()).Add(numberValue); 1191 ((ArrayList)objectStack.Peek()).Add(numberValue);
1165 } 1192 }
@@ -1168,10 +1195,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1168 // we have a key so lets store this value 1195 // we have a key so lets store this value
1169 ((Hashtable)objectStack.Peek()).Add(currentKey,numberValue); 1196 ((Hashtable)objectStack.Peek()).Add(currentKey,numberValue);
1170 // now lets clear the key, we're done with it and moving on 1197 // now lets clear the key, we're done with it and moving on
1171 currentKey=null; 1198 currentKey = null;
1172 } 1199 }
1173 1200
1174 break; 1201 break;
1175 } 1202 }
1176 } 1203 }
1177 } 1204 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 7a7b922..a2a0fea 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -69,6 +69,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
69 69
70 // Avatar Info Commands 70 // Avatar Info Commands
71 string osGetAgentIP(string agent); 71 string osGetAgentIP(string agent);
72 LSL_List osGetAgents();
72 73
73 // Teleport commands 74 // Teleport commands
74 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); 75 void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index a50b6f2..fa45836 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -175,6 +175,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
175 return m_OSSL_Functions.osGetAgentIP(agent); 175 return m_OSSL_Functions.osGetAgentIP(agent);
176 } 176 }
177 177
178 public LSL_List osGetAgents()
179 {
180 return m_OSSL_Functions.osGetAgents();
181 }
182
178 // Animation Functions 183 // Animation Functions
179 184
180 public void osAvatarPlayAnimation(string avatar, string animation) 185 public void osAvatarPlayAnimation(string avatar, string animation)