29 using System.Collections;
30 using System.Collections.Generic;
32 using System.Reflection;
33 using System.Runtime.Remoting.Lifetime;
36 using System.Threading;
40 using OpenMetaverse.StructuredData;
43 using OpenSim.Framework;
45 using OpenSim.Framework.Console;
46 using OpenSim.Region.Framework.Interfaces;
47 using OpenSim.Region.Framework.Scenes;
48 using OpenSim.Region.ScriptEngine.Shared;
49 using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
50 using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
51 using OpenSim.Region.ScriptEngine.Interfaces;
52 using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
54 using OpenSim.Services.Interfaces;
56 using System.Text.RegularExpressions;
66 using OpenSim.Services.Connectors.Hypergrid;
122 AllowedCreators =
new List<UUID>();
123 AllowedOwners =
new List<UUID>();
124 AllowedOwnerClasses =
new List<string>();
131 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
133 public const string GridInfoServiceConfigSectionName =
"GridInfoService";
139 internal bool m_OSFunctionsEnabled =
false;
140 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
141 internal float m_ScriptDelayFactor = 1.0f;
142 internal float m_ScriptDistanceFactor = 1.0f;
143 internal bool m_debuggerSafe =
false;
144 internal Dictionary<string, FunctionPerms > m_FunctionPerms =
new Dictionary<string, FunctionPerms >();
150 m_ScriptEngine = scriptEngine;
153 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean(
"DebuggerSafe",
false);
155 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<
IUrlModule>();
157 if (m_ScriptEngine.Config.GetBoolean(
"AllowOSFunctions",
false))
159 m_OSFunctionsEnabled =
true;
163 m_ScriptDelayFactor =
164 m_ScriptEngine.Config.GetFloat(
"ScriptDelayFactor", 1.0f);
165 m_ScriptDistanceFactor =
166 m_ScriptEngine.Config.GetFloat(
"ScriptDistanceLimitFactor", 1.0f);
168 string risk = m_ScriptEngine.Config.GetString(
"OSFunctionThreatLevel",
"VeryLow");
172 m_MaxThreatLevel = ThreatLevel.NoAccess;
175 m_MaxThreatLevel = ThreatLevel.None;
178 m_MaxThreatLevel = ThreatLevel.VeryLow;
181 m_MaxThreatLevel = ThreatLevel.Low;
184 m_MaxThreatLevel = ThreatLevel.Moderate;
187 m_MaxThreatLevel = ThreatLevel.High;
190 m_MaxThreatLevel = ThreatLevel.VeryHigh;
193 m_MaxThreatLevel = ThreatLevel.Severe;
202 ILease lease = (ILease)base.InitializeLifetimeService();
204 if (lease.CurrentState == LeaseState.Initial)
206 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
215 get {
return m_ScriptEngine.World; }
218 internal void OSSLError(
string msg)
238 private void InitLSL()
240 if (m_LSL_Api != null)
243 m_LSL_Api = (
ILSL_Api)m_ScriptEngine.GetApi(m_item.ItemID,
"LSL");
250 internal void OSSLShoutError(
string message)
252 if (message.Length > 1023)
253 message = message.Substring(0, 1023);
255 World.SimChat(Utils.StringToBytes(message),
259 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
265 if (!m_OSFunctionsEnabled)
266 OSSLError(
String.Format(
"{0} permission denied. All OS functions are disabled.",
function));
268 string reasonWhyNot = CheckThreatLevelTest(level,
function);
269 if (!
String.IsNullOrEmpty(reasonWhyNot))
271 OSSLError(reasonWhyNot);
277 private string CheckThreatLevelTest(
ThreatLevel level,
string function)
279 if (!m_FunctionPerms.ContainsKey(
function))
282 m_FunctionPerms[
function] = perms;
284 string ownerPerm = m_ScriptEngine.Config.GetString(
"Allow_" +
function,
"");
285 string creatorPerm = m_ScriptEngine.Config.GetString(
"Creators_" +
function,
"");
286 if (ownerPerm ==
"" && creatorPerm ==
"")
289 perms.AllowedOwners = null;
290 perms.AllowedCreators = null;
291 perms.AllowedOwnerClasses = null;
297 if (
bool.TryParse(ownerPerm, out allowed))
303 perms.AllowedOwners.Add(UUID.Zero);
308 string[] ids = ownerPerm.Split(
new char[] {
','});
309 foreach (
string id in ids)
311 string current = id.Trim();
312 if (current.ToUpper() ==
"PARCEL_GROUP_MEMBER" || current.ToUpper() ==
"PARCEL_OWNER" || current.ToUpper() ==
"ESTATE_MANAGER" || current.ToUpper() ==
"ESTATE_OWNER")
321 if (
UUID.TryParse(current, out uuid))
323 if (uuid !=
UUID.Zero)
324 perms.AllowedOwners.Add(uuid);
329 ids = creatorPerm.Split(
new char[] {
','});
330 foreach (
string id in ids)
332 string current = id.Trim();
335 if (
UUID.TryParse(current, out uuid))
337 if (uuid !=
UUID.Zero)
338 perms.AllowedCreators.Add(uuid);
354 if (m_FunctionPerms[
function].AllowedOwners == null)
357 if (level > m_MaxThreatLevel)
360 "{0} permission denied. Allowed threat level is {1} but function threat level is {2}.",
361 function, m_MaxThreatLevel, level);
365 if (!m_FunctionPerms[
function].AllowedOwners.Contains(
UUID.Zero))
368 if (m_FunctionPerms[
function].AllowedOwners.Contains(m_host.OwnerID))
374 UUID ownerID = m_item.OwnerID;
377 if (m_FunctionPerms[
function].AllowedOwnerClasses.Contains(
"PARCEL_GROUP_MEMBER"))
379 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
388 if (m_FunctionPerms[
function].AllowedOwnerClasses.Contains(
"PARCEL_OWNER"))
390 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
399 if (m_FunctionPerms[
function].AllowedOwnerClasses.Contains(
"ESTATE_MANAGER"))
402 if (
World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID)
409 if (m_FunctionPerms[
function].AllowedOwnerClasses.Contains(
"ESTATE_OWNER"))
411 if (
World.RegionInfo.EstateSettings.EstateOwner == ownerID)
417 if (!m_FunctionPerms[
function].AllowedCreators.Contains(m_item.CreatorID))
419 String.Format(
"{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
422 if (m_item.CreatorID != ownerID)
424 if ((m_item.CurrentPermissions & (uint)
PermissionMask.Modify) != 0)
425 return String.Format(
"{0} permission denied. Script permissions error.",
function);
433 internal void OSSLDeprecated(
string function,
string replacement)
435 OSSLShoutError(
string.Format(
"Use of function {0} is deprecated. Use {1} instead.",
function, replacement));
440 delay = (int)((
float)delay * m_ScriptDelayFactor);
443 System.Threading.Thread.Sleep(delay);
448 CheckThreatLevel(
ThreatLevel.High,
"osSetTerrainHeight");
450 return SetTerrainHeight(x, y, val);
455 CheckThreatLevel(
ThreatLevel.High,
"osTerrainSetHeight");
456 OSSLDeprecated(
"osTerrainSetHeight",
"osSetTerrainHeight");
458 return SetTerrainHeight(x, y, val);
461 private LSL_Integer SetTerrainHeight(
int x,
int y,
double val)
463 m_host.AddScriptLPS(1);
465 if (x > (
World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0)
466 OSSLError(
"osSetTerrainHeight: Coordinate out of bounds");
468 if (
World.Permissions.CanTerraformLand(m_host.OwnerID,
new Vector3(x, y, 0)))
470 World.Heightmap[x, y] = val;
481 CheckThreatLevel(
ThreatLevel.None,
"osGetTerrainHeight");
482 return GetTerrainHeight(x, y);
487 CheckThreatLevel(
ThreatLevel.None,
"osTerrainGetHeight");
488 OSSLDeprecated(
"osTerrainGetHeight",
"osGetTerrainHeight");
489 return GetTerrainHeight(x, y);
492 private LSL_Float GetTerrainHeight(
int x,
int y)
494 m_host.AddScriptLPS(1);
495 if (x > (
World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0)
496 OSSLError(
"osGetTerrainHeight: Coordinate out of bounds");
498 return World.Heightmap[x, y];
503 CheckThreatLevel(
ThreatLevel.VeryLow,
"osTerrainFlush");
504 m_host.AddScriptLPS(1);
507 if (terrainModule != null) terrainModule.TaintTerrain();
518 CheckThreatLevel(
ThreatLevel.High,
"osRegionRestart");
521 m_host.AddScriptLPS(1);
522 if (
World.Permissions.CanIssueEstateCommand(m_host.OwnerID,
false) && (restartModule != null))
526 restartModule.AbortRestart(
"Restart aborted");
530 List<int> times =
new List<int>();
533 times.Add((int)seconds);
536 else if (seconds > 30)
542 restartModule.ScheduleRestart(UUID.Zero,
"Region will restart in {0}", times.ToArray(),
true);
557 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osRegionNotice");
559 m_host.AddScriptLPS(1);
564 dm.SendGeneralAlert(msg);
572 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osSetRot");
574 m_host.AddScriptLPS(1);
575 if (
World.Entities.ContainsKey(target))
578 if (
World.Entities.TryGetValue(target, out entity))
581 ((SceneObjectGroup)entity).UpdateGroupRotationR(
rotation);
583 ((ScenePresence)entity).Rotation =
rotation;
588 OSSLError(
"osSetRot: Invalid target");
598 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetDynamicTextureURL");
600 m_host.AddScriptLPS(1);
601 if (dynamicID ==
String.Empty)
604 UUID createdTexture =
605 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
607 return createdTexture.ToString();
614 return UUID.Zero.ToString();
618 int timer,
int alpha)
620 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetDynamicTextureURLBlend");
622 m_host.AddScriptLPS(1);
623 if (dynamicID ==
String.Empty)
626 UUID createdTexture =
627 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
628 extraParams, timer,
true, (byte) alpha);
629 return createdTexture.ToString();
636 return UUID.Zero.ToString();
640 bool blend,
int disp,
int timer,
int alpha,
int face)
642 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetDynamicTextureURLBlendFace");
644 m_host.AddScriptLPS(1);
645 if (dynamicID ==
String.Empty)
648 UUID createdTexture =
649 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
650 extraParams, timer, blend, disp, (byte) alpha, face);
651 return createdTexture.ToString();
658 return UUID.Zero.ToString();
664 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetDynamicTextureData");
666 m_host.AddScriptLPS(1);
667 if (dynamicID ==
String.Empty)
670 if (textureManager != null)
672 if (extraParams ==
String.Empty)
676 UUID createdTexture =
677 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
679 return createdTexture.ToString();
687 return UUID.Zero.ToString();
691 int timer,
int alpha)
693 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetDynamicTextureDataBlend");
695 m_host.AddScriptLPS(1);
696 if (dynamicID ==
String.Empty)
699 if (textureManager != null)
701 if (extraParams ==
String.Empty)
705 UUID createdTexture =
706 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
707 extraParams, timer,
true, (byte) alpha);
708 return createdTexture.ToString();
716 return UUID.Zero.ToString();
720 bool blend,
int disp,
int timer,
int alpha,
int face)
722 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetDynamicTextureDataBlendFace");
724 m_host.AddScriptLPS(1);
725 if (dynamicID ==
String.Empty)
728 if (textureManager != null)
730 if (extraParams ==
String.Empty)
734 UUID createdTexture =
735 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
736 extraParams, timer, blend, disp, (byte) alpha, face);
737 return createdTexture.ToString();
745 return UUID.Zero.ToString();
750 CheckThreatLevel(
ThreatLevel.Severe,
"osConsoleCommand");
752 m_host.AddScriptLPS(1);
755 if (
World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
757 MainConsole.Instance.RunCommand(command);
766 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetPrimFloatOnWater");
768 m_host.AddScriptLPS(1);
770 m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
778 CheckThreatLevel(
ThreatLevel.Severe,
"osTeleportAgent");
780 TeleportAgent(agent, regionName, position, lookat,
false);
783 private void TeleportAgent(
string agent,
string regionName,
786 m_host.AddScriptLPS(1);
788 if (
UUID.TryParse(agent, out agentId))
791 if (presence != null)
806 o => World.RequestTeleportLocation(
807 presence.ControllingClient, regionName, position,
808 lookat, (uint)
TPFlags.ViaLocation),
809 null,
"OSSL_Api.TeleportAgentByRegionCoords");
823 CheckThreatLevel(
ThreatLevel.Severe,
"osTeleportAgent");
825 TeleportAgent(agent, regionX, regionY, position, lookat,
false);
828 private void TeleportAgent(
string agent,
int regionX,
int regionY,
831 ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY);
833 m_host.AddScriptLPS(1);
834 UUID agentId = new UUID();
835 if (UUID.TryParse(agent, out agentId))
838 if (presence != null)
853 o => World.RequestTeleportLocation(
854 presence.ControllingClient, regionHandle,
855 position, lookat, (uint)
TPFlags.ViaLocation),
856 null,
"OSSL_Api.TeleportAgentByRegionName");
868 osTeleportAgent(agent,
World.RegionInfo.RegionName, position, lookat);
874 CheckThreatLevel(
ThreatLevel.None,
"osTeleportOwner");
876 TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat,
true);
881 osTeleportOwner(
World.RegionInfo.RegionName, position, lookat);
886 CheckThreatLevel(
ThreatLevel.None,
"osTeleportOwner");
888 TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat,
true);
900 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osForceOtherSit");
902 m_host.AddScriptLPS(1);
904 ForceSit(avatar, m_host.UUID);
915 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osForceOtherSit");
917 m_host.AddScriptLPS(1);
921 ForceSit(avatar, targetID);
928 if (!
UUID.TryParse(avatar, out agentID))
935 if (presence != null &&
937 part.SitTargetAvatar ==
UUID.Zero)
938 presence.HandleAgentRequestSit(presence.ControllingClient,
941 part.SitTargetPosition);
953 CheckThreatLevel(
ThreatLevel.High,
"osGetAgentIP");
957 m_host.AddScriptLPS(1);
974 m_host.AddScriptLPS(1);
987 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osAvatarPlayAnimation");
989 AvatarPlayAnimation(avatar, animation);
992 private void AvatarPlayAnimation(
string avatar,
string animation)
994 m_host.AddScriptLPS(1);
997 if(!
UUID.TryParse(avatar, out avatarID))
1000 if(!
World.Entities.ContainsKey(avatarID))
1005 target = (ScenePresence)World.Entities[avatarID];
1010 UUID animID = UUID.Zero;
1011 m_host.TaskInventory.LockItemsForRead(
true);
1012 foreach (KeyValuePair<UUID, TaskInventoryItem> inv
in m_host.TaskInventory)
1016 if (inv.Value.Name == animation)
1018 animID = inv.Value.AssetID;
1023 m_host.TaskInventory.LockItemsForRead(
false);
1025 if (animID ==
UUID.Zero)
1026 target.Animator.AddAnimation(animation, m_host.UUID);
1028 target.Animator.AddAnimation(animID, m_host.UUID);
1033 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osAvatarStopAnimation");
1035 AvatarStopAnimation(avatar, animation);
1038 private void AvatarStopAnimation(
string avatar,
string animation)
1042 m_host.AddScriptLPS(1);
1048 if (
World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence)
1050 ScenePresence target = (ScenePresence)
World.Entities[avatarID];
1055 if (!
UUID.TryParse(animation, out animID))
1065 if (animID ==
UUID.Zero)
1066 target.Animator.RemoveAnimation(animation);
1068 target.Animator.RemoveAnimation(animID,
true);
1078 m_host.AddScriptLPS(1);
1079 drawList +=
"MoveTo " + x +
"," + y +
";";
1083 public string osDrawLine(
string drawList,
int startX,
int startY,
int endX,
int endY)
1087 m_host.AddScriptLPS(1);
1088 drawList +=
"MoveTo "+ startX+
","+ startY +
"; LineTo "+endX +
","+endY +
"; ";
1096 m_host.AddScriptLPS(1);
1097 drawList +=
"LineTo " + endX +
"," + endY +
"; ";
1105 m_host.AddScriptLPS(1);
1106 drawList +=
"Text " + text +
"; ";
1112 CheckThreatLevel(
ThreatLevel.None,
"osDrawEllipse");
1114 m_host.AddScriptLPS(1);
1115 drawList +=
"Ellipse " + width +
"," + height +
"; ";
1121 CheckThreatLevel(
ThreatLevel.None,
"osDrawRectangle");
1123 m_host.AddScriptLPS(1);
1124 drawList +=
"Rectangle " + width +
"," + height +
"; ";
1130 CheckThreatLevel(
ThreatLevel.None,
"osDrawFilledRectangle");
1132 m_host.AddScriptLPS(1);
1133 drawList +=
"FillRectangle " + width +
"," + height +
"; ";
1139 CheckThreatLevel(
ThreatLevel.None,
"osDrawFilledPolygon");
1141 m_host.AddScriptLPS(1);
1143 if (x.Length != y.Length || x.Length < 3)
1147 drawList +=
"FillPolygon " + x.GetLSLStringItem(0) +
"," + y.GetLSLStringItem(0);
1148 for (
int i = 1; i < x.Length; i++)
1150 drawList +=
"," + x.GetLSLStringItem(i) +
"," + y.GetLSLStringItem(i);
1158 CheckThreatLevel(
ThreatLevel.None,
"osDrawPolygon");
1160 m_host.AddScriptLPS(1);
1162 if (x.Length != y.Length || x.Length < 3)
1166 drawList +=
"Polygon " + x.GetLSLStringItem(0) +
"," + y.GetLSLStringItem(0);
1167 for (
int i = 1; i < x.Length; i++)
1169 drawList +=
"," + x.GetLSLStringItem(i) +
"," + y.GetLSLStringItem(i);
1177 CheckThreatLevel(
ThreatLevel.None,
"osSetFontSize");
1179 m_host.AddScriptLPS(1);
1180 drawList +=
"FontSize "+ fontSize +
"; ";
1186 CheckThreatLevel(
ThreatLevel.None,
"osSetFontName");
1188 m_host.AddScriptLPS(1);
1189 drawList +=
"FontName "+ fontName +
"; ";
1195 CheckThreatLevel(
ThreatLevel.None,
"osSetPenSize");
1197 m_host.AddScriptLPS(1);
1198 drawList +=
"PenSize " + penSize +
"; ";
1204 CheckThreatLevel(
ThreatLevel.None,
"osSetPenColor");
1206 m_host.AddScriptLPS(1);
1207 drawList +=
"PenColor " + color +
"; ";
1214 CheckThreatLevel(
ThreatLevel.None,
"osSetPenColour");
1215 OSSLDeprecated(
"osSetPenColour",
"osSetPenColor");
1217 m_host.AddScriptLPS(1);
1218 drawList +=
"PenColour " + colour +
"; ";
1222 public string osSetPenCap(
string drawList,
string direction,
string type)
1224 CheckThreatLevel(
ThreatLevel.None,
"osSetPenCap");
1226 m_host.AddScriptLPS(1);
1227 drawList +=
"PenCap " + direction +
"," + type +
"; ";
1231 public string osDrawImage(
string drawList,
int width,
int height,
string imageUrl)
1233 CheckThreatLevel(
ThreatLevel.None,
"osDrawImage");
1235 m_host.AddScriptLPS(1);
1236 drawList +=
"Image " +width +
"," + height+
","+ imageUrl +
"; " ;
1242 CheckThreatLevel(
ThreatLevel.VeryLow,
"osGetDrawStringSize");
1243 m_host.AddScriptLPS(1);
1247 if (textureManager != null)
1249 double xSize, ySize;
1250 textureManager.GetDrawStringSize(contentType, text, fontName, fontSize,
1251 out xSize, out ySize);
1265 CheckThreatLevel(
ThreatLevel.High,
"osSetStateEvents");
1266 m_host.AddScriptLPS(1);
1268 m_host.SetScriptEvents(m_item.ItemID, events);
1273 CheckThreatLevel(
ThreatLevel.High,
"osSetRegionWaterHeight");
1275 m_host.AddScriptLPS(1);
1277 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
1288 CheckThreatLevel(
ThreatLevel.High,
"osSetRegionSunSettings");
1290 m_host.AddScriptLPS(1);
1292 while (sunHour > 24.0)
1298 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
1299 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6;
1300 World.RegionInfo.RegionSettings.FixedSun = sunFixed;
1301 World.RegionInfo.RegionSettings.Save();
1303 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
1313 CheckThreatLevel(
ThreatLevel.High,
"osSetEstateSunSettings");
1315 m_host.AddScriptLPS(1);
1317 while (sunHour > 24.0)
1323 World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
1324 World.RegionInfo.EstateSettings.SunPosition = sunHour;
1325 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1326 World.EstateDataService.StoreEstateSettings(World.RegionInfo.EstateSettings);
1328 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
1337 CheckThreatLevel(
ThreatLevel.None,
"osGetCurrentSunHour");
1339 m_host.AddScriptLPS(1);
1342 double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6;
1348 sunHour = module.GetCurrentSunHour();
1356 CheckThreatLevel(
ThreatLevel.None,
"osSunGetParam");
1357 OSSLDeprecated(
"osSunGetParam",
"osGetSunParam");
1358 return GetSunParam(param);
1363 CheckThreatLevel(
ThreatLevel.None,
"osGetSunParam");
1364 return GetSunParam(param);
1367 private double GetSunParam(
string param)
1369 m_host.AddScriptLPS(1);
1376 value = module.GetSunParameter(param);
1384 CheckThreatLevel(
ThreatLevel.None,
"osSunSetParam");
1385 OSSLDeprecated(
"osSunSetParam",
"osSetSunParam");
1386 SetSunParam(param, value);
1391 CheckThreatLevel(
ThreatLevel.None,
"osSetSunParam");
1392 SetSunParam(param, value);
1395 private void SetSunParam(
string param,
double value)
1397 m_host.AddScriptLPS(1);
1402 module.SetSunParameter(param, value);
1408 CheckThreatLevel(
ThreatLevel.None,
"osWindActiveModelPluginName");
1409 m_host.AddScriptLPS(1);
1414 return module.WindActiveModelPluginName;
1417 return String.Empty;
1422 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetWindParam");
1423 m_host.AddScriptLPS(1);
1430 module.WindParamSet(plugin, param, (float)value);
1432 catch (Exception) { }
1438 CheckThreatLevel(
ThreatLevel.VeryLow,
"osGetWindParam");
1439 m_host.AddScriptLPS(1);
1444 return module.WindParamGet(plugin, param);
1453 CheckThreatLevel(
ThreatLevel.High,
"osParcelJoin");
1454 m_host.AddScriptLPS(1);
1456 int startx = (int)(pos1.x < pos2.x ? pos1.x : pos2.x);
1457 int starty = (int)(pos1.y < pos2.y ? pos1.y : pos2.y);
1458 int endx = (int)(pos1.x > pos2.x ? pos1.x : pos2.x);
1459 int endy = (int)(pos1.y > pos2.y ? pos1.y : pos2.y);
1461 World.LandChannel.Join(startx,starty,endx,endy,m_host.OwnerID);
1466 CheckThreatLevel(
ThreatLevel.High,
"osParcelSubdivide");
1467 m_host.AddScriptLPS(1);
1469 int startx = (int)(pos1.x < pos2.x ? pos1.x : pos2.x);
1470 int starty = (int)(pos1.y < pos2.y ? pos1.y : pos2.y);
1471 int endx = (int)(pos1.x > pos2.x ? pos1.x : pos2.x);
1472 int endy = (int)(pos1.y > pos2.y ? pos1.y : pos2.y);
1474 World.LandChannel.Subdivide(startx,starty,endx,endy,m_host.OwnerID);
1479 const string functionName =
"osParcelSetDetails";
1481 OSSLDeprecated(functionName,
"osSetParcelDetails");
1482 SetParcelDetails(pos, rules, functionName);
1487 const string functionName =
"osSetParcelDetails";
1489 SetParcelDetails(pos, rules, functionName);
1494 m_host.AddScriptLPS(1);
1499 ILandObject startLandObject = World.LandChannel.GetLandObject((int)pos.x, (
int)pos.y);
1500 if (startLandObject == null)
1502 OSSLShoutError(
"There is no land at that location");
1506 if (!
World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions,
false))
1508 OSSLShoutError(
"You do not have permission to modify the parcel");
1513 LandData newLand = startLandObject.LandData.Copy();
1517 for (
int idx = 0; idx < rules.Length;)
1519 int code = rules.GetLSLIntegerItem(idx++);
1520 string arg = rules.GetLSLStringItem(idx++);
1523 case ScriptBaseClass.PARCEL_DETAILS_NAME:
1527 case ScriptBaseClass.PARCEL_DETAILS_DESC:
1528 newLand.Description = arg;
1531 case ScriptBaseClass.PARCEL_DETAILS_OWNER:
1532 CheckThreatLevel(
ThreatLevel.VeryHigh, functionName);
1533 if (
UUID.TryParse(arg, out uuid))
1538 CheckThreatLevel(
ThreatLevel.VeryHigh, functionName);
1539 if (
UUID.TryParse(arg, out uuid))
1544 CheckThreatLevel(
ThreatLevel.VeryHigh, functionName);
1545 newLand.ClaimDate = Convert.ToInt32(arg);
1547 newLand.ClaimDate = Util.UnixTimeSinceEpoch();
1552 World.LandChannel.UpdateLandObject(newLand.LocalID,newLand);
1562 CheckThreatLevel(
ThreatLevel.None,
"osList2Double");
1564 m_host.AddScriptLPS(1);
1567 index = src.Length + index;
1569 if (index >= src.Length)
1573 return Convert.ToDouble(src.Data[index]);
1580 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetParcelMediaURL");
1582 m_host.AddScriptLPS(1);
1584 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
1586 if (land.LandData.OwnerID != m_host.OwnerID)
1589 land.SetMediaUrl(url);
1596 CheckThreatLevel(
ThreatLevel.VeryLow,
"osSetParcelSIPAddress");
1598 m_host.AddScriptLPS(1);
1600 ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
1602 if (land.LandData.OwnerID != m_host.OwnerID)
1604 OSSLError(
"osSetParcelSIPAddress: Sorry, you need to own the land to use this function");
1611 if (voiceModule != null)
1612 voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID);
1614 OSSLError(
"osSetParcelSIPAddress: No voice module enabled for this land");
1624 CheckThreatLevel(
ThreatLevel.High,
"osGetScriptEngineName");
1626 m_host.AddScriptLPS(1);
1628 int scriptEngineNameIndex = 0;
1630 if (!
String.IsNullOrEmpty(m_ScriptEngine.ScriptEngineName))
1633 scriptEngineNameIndex = m_ScriptEngine.ScriptEngineName.IndexOf(
".", scriptEngineNameIndex);
1634 scriptEngineNameIndex++;
1636 int scriptEngineNameLength = m_ScriptEngine.ScriptEngineName.Length - scriptEngineNameIndex;
1639 Char[] scriptEngineNameCharArray = m_ScriptEngine.ScriptEngineName.ToCharArray(scriptEngineNameIndex, scriptEngineNameLength);
1640 String scriptEngineName =
new String(scriptEngineNameCharArray);
1642 return scriptEngineName;
1646 return String.Empty;
1652 m_host.AddScriptLPS(1);
1654 if (m_ScriptEngine.World.PhysicsScene != null)
1656 string physEngine = m_ScriptEngine.World.PhysicsScene.EngineType;
1657 if (physEngine ==
"OpenDynamicsEngine")
1675 m_host.AddScriptLPS(1);
1676 string ret = String.Empty;
1677 if (
String.IsNullOrEmpty(CheckThreatLevelTest(
ThreatLevel.High,
"osGetPhysicsEngineType")))
1679 if (m_ScriptEngine.World.PhysicsScene != null)
1681 ret = m_ScriptEngine.World.PhysicsScene.EngineType;
1698 CheckThreatLevel(
ThreatLevel.High,
"osGetSimulatorVersion");
1699 m_host.AddScriptLPS(1);
1701 return m_ScriptEngine.World.GetSimulatorVersion();
1704 private Hashtable osdToHashtable(
OSDMap map)
1706 Hashtable result =
new Hashtable();
1707 foreach (KeyValuePair<string, OSD> item
in map) {
1708 result.Add(item.Key, osdToObject(item.Value));
1713 private ArrayList osdToArray(
OSDArray list)
1715 ArrayList result =
new ArrayList();
1716 foreach (
OSD item
in list ) {
1717 result.Add(osdToObject(item));
1724 if ( decoded is OSDString ) {
1725 return (
string) decoded.AsString();
1726 }
else if ( decoded is OSDInteger ) {
1727 return (
int) decoded.AsInteger();
1728 }
else if ( decoded is OSDReal ) {
1729 return (
float) decoded.AsReal();
1730 }
else if ( decoded is OSDBoolean ) {
1731 return (
bool) decoded.AsBoolean();
1732 }
else if ( decoded is
OSDMap ) {
1733 return osdToHashtable((OSDMap) decoded);
1734 }
else if ( decoded is
OSDArray ) {
1735 return osdToArray((OSDArray) decoded);
1743 CheckThreatLevel(
ThreatLevel.None,
"osParseJSONNew");
1745 m_host.AddScriptLPS(1);
1749 OSD decoded = OSDParser.DeserializeJson(JSON);
1750 return osdToObject(decoded);
1754 OSSLError(
"osParseJSONNew: Problems decoding JSON string " + JSON +
" : " + e.Message) ;
1761 CheckThreatLevel(
ThreatLevel.None,
"osParseJSON");
1763 m_host.AddScriptLPS(1);
1765 Object decoded = osParseJSONNew(JSON);
1767 if ( decoded is Hashtable ) {
1768 return (Hashtable) decoded;
1769 }
else if ( decoded is ArrayList ) {
1770 ArrayList decoded_list = (ArrayList) decoded;
1771 Hashtable fakearray =
new Hashtable();
1773 for ( i = 0; i < decoded_list.Count ; i++ ) {
1774 fakearray.Add(i, decoded_list[i]);
1778 OSSLError(
"osParseJSON: unable to parse JSON string " + JSON);
1794 CheckThreatLevel(
ThreatLevel.Low,
"osMessageObject");
1795 m_host.AddScriptLPS(1);
1798 if (!
UUID.TryParse(objectUUID, out objUUID))
1800 OSSLShoutError(
"osMessageObject() cannot send messages to objects with invalid UUIDs");
1804 MessageObject(objUUID, message);
1807 private void MessageObject(UUID objUUID,
string message)
1813 if (sceneOP == null)
1815 OSSLShoutError(
"osMessageObject() cannot send message to " + objUUID.ToString() +
", object was not found in scene.");
1819 m_ScriptEngine.PostObjectEvent(
1836 CheckThreatLevel(
ThreatLevel.High,
"osMakeNotecard");
1837 m_host.AddScriptLPS(1);
1839 StringBuilder notecardData =
new StringBuilder();
1841 for (
int i = 0; i < contents.Length; i++)
1842 notecardData.Append((
string)(contents.GetLSLStringItem(i) +
"\n"));
1844 SaveNotecard(notecardName,
"Script generated notecard", notecardData.ToString(),
false);
1861 AssetBase asset =
new AssetBase(
UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
1862 asset.Description = description;
1867 b = Util.UTF8.GetBytes(data);
1869 a = Util.UTF8.GetBytes(
1870 "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " + b.Length.ToString() +
"\n");
1872 c = Util.UTF8.GetBytes(
"}");
1874 byte[] d =
new byte[a.Length + b.Length + c.Length];
1875 Buffer.BlockCopy(a, 0, d, 0, a.Length);
1876 Buffer.BlockCopy(b, 0, d, a.Length, b.Length);
1877 Buffer.BlockCopy(c, 0, d, a.Length + b.Length, c.Length);
1880 World.AssetService.Store(asset);
1885 taskItem.ResetIDs(m_host.UUID);
1886 taskItem.ParentID = m_host.UUID;
1887 taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch();
1888 taskItem.Name = asset.Name;
1889 taskItem.Description = asset.Description;
1890 taskItem.Type = (int)AssetType.Notecard;
1891 taskItem.InvType = (
int)InventoryType.Notecard;
1892 taskItem.OwnerID = m_host.OwnerID;
1893 taskItem.CreatorID = m_host.OwnerID;
1894 taskItem.BasePermissions = (uint)
PermissionMask.All | (uint)PermissionMask.Export;
1895 taskItem.CurrentPermissions = (uint)
PermissionMask.All | (uint)PermissionMask.Export;
1896 taskItem.EveryonePermissions = 0;
1898 taskItem.GroupID = m_host.GroupID;
1899 taskItem.GroupPermissions = 0;
1901 taskItem.PermsGranter =
UUID.Zero;
1902 taskItem.PermsMask = 0;
1903 taskItem.AssetID = asset.
FullID;
1906 m_host.Inventory.AddInventoryItemExclusive(taskItem,
false);
1908 m_host.Inventory.AddInventoryItem(taskItem,
false);
1920 UUID assetID = CacheNotecard(notecardNameOrUuid);
1922 if (assetID !=
UUID.Zero)
1924 StringBuilder notecardData =
new StringBuilder();
1926 for (
int count = 0; count < NotecardCache.GetLines(assetID); count++)
1928 string line = NotecardCache.GetLine(assetID, count) +
"\n";
1932 notecardData.Append(line);
1935 return notecardData.ToString();
1951 UUID assetID = UUID.Zero;
1953 bool notecardNameIsUUID = UUID.TryParse(notecardNameOrUuid, out assetID);
1955 if (!notecardNameIsUUID)
1957 assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid);
1960 if (assetID ==
UUID.Zero)
1965 AssetBase a = World.AssetService.Get(assetID.ToString());
1971 assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid);
1972 if (assetID ==
UUID.Zero)
1977 a = World.AssetService.Get(assetID.ToString());
1986 NotecardCache.Cache(assetID, a.Data);
1993 UUID assetId = UUID.Zero;
1994 m_host.TaskInventory.LockItemsForRead(
true);
1997 if (item.
Type == 7 && item.
Name == name)
1999 assetId = item.AssetID;
2002 m_host.TaskInventory.LockItemsForRead(
false);
2021 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osGetNotecardLine");
2022 m_host.AddScriptLPS(1);
2024 UUID assetID = CacheNotecard(name);
2026 if (assetID ==
UUID.Zero)
2028 OSSLShoutError(
"Notecard '" + name +
"' could not be found.");
2032 return NotecardCache.GetLine(assetID, line);
2049 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osGetNotecard");
2050 m_host.AddScriptLPS(1);
2052 string text = LoadNotecard(name);
2056 OSSLShoutError(
"Notecard '" + name +
"' could not be found.");
2079 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osGetNumberOfNotecardLines");
2080 m_host.AddScriptLPS(1);
2082 UUID assetID = CacheNotecard(name);
2084 if (assetID ==
UUID.Zero)
2086 OSSLShoutError(
"Notecard '" + name +
"' could not be found.");
2090 return NotecardCache.GetLines(assetID);
2095 CheckThreatLevel(
ThreatLevel.Low,
"osAvatarName2Key");
2096 m_host.AddScriptLPS(1);
2099 if (userManager == null)
2101 OSSLShoutError(
"osAvatarName2Key: UserManagement module not available");
2102 return string.Empty;
2107 UUID userID = userManager.GetUserIdByName(firstname, lastname);
2108 if (userID !=
UUID.Zero)
2109 return userID.ToString();
2114 if (Util.ParseForeignAvatarName(firstname, lastname, out realFirstName, out realLastName, out serverURI))
2120 if (userConnection != null)
2122 userID = userConnection.GetUUID(realFirstName, realLastName);
2123 if (userID !=
UUID.Zero)
2125 userManager.AddUser(userID, realFirstName, realLastName, serverURI);
2126 return userID.ToString();
2137 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname);
2138 if (account != null)
2139 return account.PrincipalID.ToString();
2142 return UUID.Zero.ToString();
2148 m_host.AddScriptLPS(1);
2152 if (
UUID.TryParse(
id, out key))
2154 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID,
key);
2155 if (account != null)
2156 return account.Name;
2158 if (m_ScriptEngine.World.GridUserService != null)
2160 GridUserInfo uInfo = m_ScriptEngine.World.GridUserService.GetGridUserInfo(key.ToString());
2166 if (Util.ParseUniversalUserIdentifier(uInfo.
UserID, out userUUID, out gridURL, out firstName, out lastName, out tmp))
2168 string grid =
new Uri(gridURL).Authority;
2169 return firstName +
"." + lastName +
" @" + grid;
2178 private enum InfoType
2194 string retval = String.Empty;
2195 IConfigSource config = m_ScriptEngine.ConfigSource;
2198 IConfig gridInfoConfig = config.Configs[
"GridInfo"];
2200 if (gridInfoConfig != null)
2201 url = gridInfoConfig.GetString(
"GridInfoURI", String.Empty);
2203 if (
String.IsNullOrEmpty(url))
2204 return "Configuration Error!";
2206 string verb =
"/json_grid_info";
2207 OSDMap json =
new OSDMap();
2209 OSDMap info = WebUtil.GetFromService(String.Format(
"{0}{1}",url,verb), 3000);
2211 if (info[
"Success"] !=
true)
2212 return "Get GridInfo Failed!";
2214 json = (
OSDMap)OSDParser.DeserializeJson(info[
"_RawResult"].AsString());
2219 retval = json[
"gridnick"];
2223 retval = json[
"gridname"];
2226 case InfoType.Login:
2227 retval = json[
"login"];
2231 retval = json[
"home"];
2234 case InfoType.Custom:
2257 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetGridNick");
2258 m_host.AddScriptLPS(1);
2260 string nick = String.Empty;
2261 IConfigSource config = m_ScriptEngine.ConfigSource;
2263 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2264 nick = config.Configs[GridInfoServiceConfigSectionName].GetString(
"gridnick", nick);
2266 if (
String.IsNullOrEmpty(nick))
2274 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetGridName");
2275 m_host.AddScriptLPS(1);
2277 string name = String.Empty;
2278 IConfigSource config = m_ScriptEngine.ConfigSource;
2280 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2281 name = config.Configs[GridInfoServiceConfigSectionName].GetString(
"gridname", name);
2283 if (
String.IsNullOrEmpty(name))
2291 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetGridLoginURI");
2292 m_host.AddScriptLPS(1);
2294 string loginURI = String.Empty;
2295 IConfigSource config = m_ScriptEngine.ConfigSource;
2297 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2298 loginURI = config.Configs[GridInfoServiceConfigSectionName].GetString(
"login", loginURI);
2300 if (
String.IsNullOrEmpty(loginURI))
2308 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetGridHomeURI");
2309 m_host.AddScriptLPS(1);
2311 IConfigSource config = m_ScriptEngine.ConfigSource;
2312 string HomeURI = Util.GetConfigVarFromSections<
string>(config,
"HomeURI",
2313 new string[] {
"Startup",
"Hypergrid" }, String.Empty);
2315 if (!
string.IsNullOrEmpty(HomeURI))
2319 if (config.Configs[
"LoginService"] != null)
2320 HomeURI = config.Configs[
"LoginService"].GetString(
"SRV_HomeURI", HomeURI);
2322 if (
String.IsNullOrEmpty(HomeURI))
2330 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetGridGatekeeperURI");
2331 m_host.AddScriptLPS(1);
2333 IConfigSource config = m_ScriptEngine.ConfigSource;
2334 string gatekeeperURI = Util.GetConfigVarFromSections<
string>(config,
"GatekeeperURI",
2335 new string[] {
"Startup",
"Hypergrid" }, String.Empty);
2337 if (!
string.IsNullOrEmpty(gatekeeperURI))
2338 return gatekeeperURI;
2341 if (config.Configs[
"GridService"] != null)
2342 gatekeeperURI = config.Configs[
"GridService"].GetString(
"Gatekeeper", gatekeeperURI);
2344 return gatekeeperURI;
2349 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetGridCustom");
2350 m_host.AddScriptLPS(1);
2352 string retval = String.Empty;
2353 IConfigSource config = m_ScriptEngine.ConfigSource;
2355 if (config.Configs[GridInfoServiceConfigSectionName] != null)
2356 retval = config.Configs[GridInfoServiceConfigSectionName].GetString(
key, retval);
2358 if (
String.IsNullOrEmpty(retval))
2366 CheckThreatLevel(
ThreatLevel.Low,
"osGetAvatarHomeURI");
2367 m_host.AddScriptLPS(1);
2370 string returnValue =
"";
2372 if (userManager != null)
2374 returnValue = userManager.GetUserServerURL(
new UUID(uuid),
"HomeURI");
2377 if (returnValue ==
"")
2379 IConfigSource config = m_ScriptEngine.ConfigSource;
2380 returnValue = Util.GetConfigVarFromSections<
string>(config,
"HomeURI",
2381 new string[] {
"Startup",
"Hypergrid" }, String.Empty);
2383 if (!
string.IsNullOrEmpty(returnValue))
2387 if (config.Configs[
"LoginService"] != null)
2388 returnValue = config.Configs[
"LoginService"].GetString(
"SRV_HomeURI", returnValue);
2390 if (
String.IsNullOrEmpty(returnValue))
2399 CheckThreatLevel(
ThreatLevel.VeryLow,
"osFormatString");
2400 m_host.AddScriptLPS(1);
2402 return String.Format(str, strings.Data);
2407 CheckThreatLevel(
ThreatLevel.VeryLow,
"osMatchString");
2408 m_host.AddScriptLPS(1);
2419 start = src.Length + start;
2422 if (start < 0 || start >= src.Length)
2428 Regex matcher =
new Regex(pattern);
2429 Match match = matcher.Match(src, start);
2430 while (match.Success)
2432 foreach (System.Text.RegularExpressions.Group g in match.Groups)
2441 match = match.NextMatch();
2449 CheckThreatLevel(
ThreatLevel.VeryLow,
"osReplaceString");
2450 m_host.AddScriptLPS(1);
2459 start = src.Length + start;
2462 if (start < 0 || start >= src.Length)
2468 Regex matcher =
new Regex(pattern);
2469 return matcher.Replace(src,replace,count,start);
2474 CheckThreatLevel(
ThreatLevel.Low,
"osLoadedCreationDate");
2475 m_host.AddScriptLPS(1);
2477 return World.RegionInfo.RegionSettings.LoadedCreationDate;
2482 CheckThreatLevel(
ThreatLevel.Low,
"osLoadedCreationTime");
2483 m_host.AddScriptLPS(1);
2485 return World.RegionInfo.RegionSettings.LoadedCreationTime;
2490 CheckThreatLevel(
ThreatLevel.Low,
"osLoadedCreationID");
2491 m_host.AddScriptLPS(1);
2493 return World.RegionInfo.RegionSettings.LoadedCreationID;
2511 CheckThreatLevel(
ThreatLevel.High,
"osGetLinkPrimitiveParams");
2512 m_host.AddScriptLPS(1);
2519 List<SceneObjectPart> parts = LSL_Api.GetLinkParts(linknumber);
2522 remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
2525 while (remaining.Length > 2)
2527 linknumber = remaining.GetLSLIntegerItem(0);
2528 rules = remaining.GetSublist(1, -1);
2529 parts = LSL_Api.GetLinkParts(linknumber);
2532 remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
2539 CheckThreatLevel(
ThreatLevel.VeryLow,
"osForceCreateLink");
2541 m_host.AddScriptLPS(1);
2544 ((
LSL_Api)m_LSL_Api).CreateLink(target, parent);
2549 CheckThreatLevel(
ThreatLevel.VeryLow,
"osForceBreakLink");
2551 m_host.AddScriptLPS(1);
2554 ((
LSL_Api)m_LSL_Api).BreakLink(linknum);
2559 CheckThreatLevel(
ThreatLevel.VeryLow,
"osForceBreakAllLinks");
2561 m_host.AddScriptLPS(1);
2564 ((
LSL_Api)m_LSL_Api).BreakAllLinks();
2570 m_host.AddScriptLPS(1);
2576 if (
UUID.TryParse(npc.m_string, out npcId))
2577 if (module.IsNPC(npcId,
World))
2581 return ScriptBaseClass.FALSE;
2586 CheckThreatLevel(
ThreatLevel.High,
"osNpcCreate");
2587 m_host.AddScriptLPS(1);
2594 bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0;
2596 return NpcCreate(firstname, lastname, position, notecard, owned,
false,
false);
2601 CheckThreatLevel(
ThreatLevel.High,
"osNpcCreate");
2602 m_host.AddScriptLPS(1);
2605 firstname, lastname, position, notecard,
2612 string firstname,
string lastname,
LSL_Vector position,
string notecard,
bool owned,
bool senseAsAgent,
bool hostGroupID)
2615 if (!
World.Permissions.CanRezObject(1, m_host.OwnerID,
new Vector3((
float)position.x, (
float)position.y, (
float)position.z)))
2622 string groupTitle = String.Empty;
2623 UUID groupID = UUID.Zero;
2632 OSSLError(
"Not owned NPCs disabled");
2636 if((createFlags &
NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent)
2638 OSSLError(
"NPC allow sense as Avatar disabled");
2639 senseAsAgent =
false;
2642 if(hostGroupID && m_host.GroupID !=
UUID.Zero)
2645 if (groupsModule != null)
2647 GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID);
2650 OSSLError(
string.Format(
"osNpcCreate: the object owner is not member of the object group"));
2654 groupID = m_host.GroupID;
2658 GroupRecord grprec = groupsModule.GetGroupRecord(m_host.GroupID);
2659 if(grprec != null && grprec.
GroupName !=
"")
2660 groupTitle = grprec.GroupName;
2667 if (firstname !=
String.Empty || lastname !=
String.Empty)
2669 if (firstname !=
"Shown outfit:")
2670 groupTitle =
"- NPC -";
2677 if (
UUID.TryParse(notecard, out
id))
2679 ScenePresence clonePresence = World.GetScenePresence(id);
2680 if (clonePresence != null)
2681 appearance = clonePresence.Appearance;
2685 if (appearance == null)
2687 string appearanceSerialized = LoadNotecard(notecard);
2689 if (appearanceSerialized != null)
2693 OSDMap appearanceOsd = (
OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
2695 appearance.Unpack(appearanceOsd);
2699 OSSLError(
string.Format(
"osNpcCreate: Error processing notcard '{0}'", notecard));
2705 OSSLError(
string.Format(
"osNpcCreate: Notecard reference '{0}' not found.", notecard));
2709 UUID ownerID = UUID.Zero;
2711 ownerID = m_host.OwnerID;
2712 UUID x = module.CreateNPC(firstname,
2721 if (World.TryGetScenePresence(x, out sp))
2723 sp.Grouptitle = groupTitle;
2724 ((
INPC)(sp.ControllingClient)).ActiveGroupId = groupID;
2726 sp.SendAvatarDataToAllAgents();
2728 return new LSL_Key(x.ToString());
2739 CheckThreatLevel(
ThreatLevel.High,
"osNpcSaveAppearance");
2740 m_host.AddScriptLPS(1);
2744 if (npcModule != null)
2747 if (!
UUID.TryParse(npc.m_string, out npcId))
2750 if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
2753 return SaveAppearanceToNotecard(npcId, notecard);
2761 CheckThreatLevel(
ThreatLevel.High,
"osNpcLoadAppearance");
2762 m_host.AddScriptLPS(1);
2766 if (npcModule != null)
2769 if (!
UUID.TryParse(npc.m_string, out npcId))
2772 if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
2775 string appearanceSerialized = LoadNotecard(notecard);
2777 if (appearanceSerialized == null)
2778 OSSLError(
string.Format(
"osNpcCreate: Notecard reference '{0}' not found.", notecard));
2780 OSDMap appearanceOsd = (
OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
2785 appearance.Unpack(appearanceOsd);
2787 npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene);
2793 CheckThreatLevel(
ThreatLevel.None,
"osNpcGetOwner");
2794 m_host.AddScriptLPS(1);
2797 if (npcModule != null)
2800 if (
UUID.TryParse(npc.m_string, out npcId))
2802 UUID owner = npcModule.GetOwner(npcId);
2803 if (owner !=
UUID.Zero)
2804 return new LSL_Key(owner.ToString());
2815 CheckThreatLevel(
ThreatLevel.High,
"osNpcGetPos");
2816 m_host.AddScriptLPS(1);
2819 if (npcModule != null)
2822 if (!
UUID.TryParse(npc.m_string, out npcId))
2825 if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
2828 ScenePresence sp = World.GetScenePresence(npcId);
2834 return Vector3.Zero;
2839 CheckThreatLevel(
ThreatLevel.High,
"osNpcMoveTo");
2840 m_host.AddScriptLPS(1);
2846 if (!
UUID.TryParse(npc.m_string, out npcId))
2849 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2852 module.MoveToTarget(npcId, World, pos,
false,
true,
false);
2858 CheckThreatLevel(
ThreatLevel.High,
"osNpcMoveToTarget");
2859 m_host.AddScriptLPS(1);
2865 if (!
UUID.TryParse(npc.m_string, out npcId))
2868 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2871 module.MoveToTarget(
2872 new UUID(npc.m_string),
2875 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
2877 (options & ScriptBaseClass.OS_NPC_RUNNING) != 0);
2883 CheckThreatLevel(
ThreatLevel.High,
"osNpcGetRot");
2884 m_host.AddScriptLPS(1);
2887 if (npcModule != null)
2890 if (!
UUID.TryParse(npc.m_string, out npcId))
2893 if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
2896 ScenePresence sp = World.GetScenePresence(npcId);
2902 return Quaternion.Identity;
2907 CheckThreatLevel(
ThreatLevel.High,
"osNpcSetRot");
2908 m_host.AddScriptLPS(1);
2911 if (npcModule != null)
2914 if (!
UUID.TryParse(npc.m_string, out npcId))
2917 if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
2920 ScenePresence sp = World.GetScenePresence(npcId);
2929 CheckThreatLevel(
ThreatLevel.High,
"osNpcStopMoveToTarget");
2930 m_host.AddScriptLPS(1);
2935 UUID npcId =
new UUID(npc.m_string);
2937 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2940 module.StopMoveToTarget(npcId, World);
2946 osNpcSay(npc, 0, message);
2952 m_host.AddScriptLPS(1);
2957 UUID npcId =
new UUID(npc.m_string);
2959 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2962 module.Say(npcId, World, message, channel);
2969 m_host.AddScriptLPS(1);
2974 UUID npcId =
new UUID(npc.m_string);
2976 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2979 module.Shout(npcId, World, message, channel);
2986 m_host.AddScriptLPS(1);
2991 UUID npcId =
new UUID(npc.m_string);
2993 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2996 module.Sit(npcId,
new UUID(target.m_string), World);
3003 m_host.AddScriptLPS(1);
3008 UUID npcId =
new UUID(npc.m_string);
3010 if (!module.CheckPermissions(npcId, m_host.OwnerID))
3013 module.Stand(npcId, World);
3019 CheckThreatLevel(
ThreatLevel.High,
"osNpcRemove");
3020 m_host.AddScriptLPS(1);
3027 UUID npcId =
new UUID(npc.m_string);
3032 module.DeleteNPC(npcId, World);
3040 CheckThreatLevel(
ThreatLevel.High,
"osNpcPlayAnimation");
3041 m_host.AddScriptLPS(1);
3046 UUID npcID =
new UUID(npc.m_string);
3048 if (module.CheckPermissions(npcID, m_host.OwnerID))
3049 AvatarPlayAnimation(npcID.ToString(), animation);
3055 CheckThreatLevel(
ThreatLevel.High,
"osNpcStopAnimation");
3056 m_host.AddScriptLPS(1);
3061 UUID npcID =
new UUID(npc.m_string);
3063 if (module.CheckPermissions(npcID, m_host.OwnerID))
3064 AvatarStopAnimation(npcID.ToString(), animation);
3070 CheckThreatLevel(
ThreatLevel.High,
"osNpcWhisper");
3071 m_host.AddScriptLPS(1);
3076 UUID npcId =
new UUID(npc.m_string);
3078 if (!module.CheckPermissions(npcId, m_host.OwnerID))
3081 module.Whisper(npcId, World, message, channel);
3088 m_host.AddScriptLPS(1);
3091 int linkNum = link_num.value;
3095 if (!
UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID))
3100 if (
UUID.TryParse(
LSL_String.ToString(object_key), out objectId))
3101 part = World.GetSceneObjectPart(objectId);
3111 part = part.ParentGroup.RootPart;
3115 part = part.ParentGroup.GetLinkNumPart(linkNum);
3121 module.Touch(npcId, part.UUID);
3132 CheckThreatLevel(
ThreatLevel.High,
"osOwnerSaveAppearance");
3133 m_host.AddScriptLPS(1);
3135 return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
3140 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osAgentSaveAppearance");
3141 m_host.AddScriptLPS(1);
3143 return SaveAppearanceToNotecard(avatarId, notecard);
3150 if (appearanceModule != null)
3152 appearanceModule.SaveBakedTextures(sp.UUID);
3154 OSDMap appearancePacked = sp.Appearance.Pack(ctx);
3157 = SaveNotecard(notecard,
"Avatar Appearance", Util.GetFormattedXml(appearancePacked as
OSD),
true);
3159 return new LSL_Key(item.AssetID.ToString());
3169 ScenePresence sp = World.GetScenePresence(avatarId);
3174 return SaveAppearanceToNotecard(sp, notecard);
3180 if (!
UUID.TryParse(rawAvatarId, out avatarId))
3183 return SaveAppearanceToNotecard(avatarId, notecard);
3193 CheckThreatLevel(
ThreatLevel.None,
"osGetGender");
3194 m_host.AddScriptLPS(1);
3197 if (!
UUID.TryParse(rawAvatarId, out avatarId))
3200 ScenePresence sp = World.GetScenePresence(avatarId);
3206 int vpShapeMaleIndex = 0;
3207 bool indexFound =
false;
3208 VisualParam param =
new VisualParam();
3209 foreach(var vpEntry
in VisualParams.Params)
3211 param = vpEntry.Value;
3212 if (param.Name ==
"male" && param.Wearable ==
"shape")
3218 if (param.Group == 0)
3225 float vpShapeMale = Utils.ByteToFloat(sp.Appearance.VisualParams[vpShapeMaleIndex], param.MinValue, param.MaxValue);
3227 bool isMale = vpShapeMale > 0.5f;
3228 return new LSL_String(isMale ?
"male" :
"female");
3237 CheckThreatLevel(
ThreatLevel.None,
"osGetMapTexture");
3238 m_host.AddScriptLPS(1);
3240 return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString();
3250 CheckThreatLevel(
ThreatLevel.High,
"osGetRegionMapTexture");
3251 m_host.AddScriptLPS(1);
3253 Scene scene = m_ScriptEngine.World;
3254 UUID key = UUID.Zero;
3258 if (
UUID.TryParse(regionName, out key))
3259 region = scene.GridService.GetRegionByUUID(
UUID.Zero, key);
3261 region = scene.GridService.GetRegionByName(UUID.Zero, regionName);
3265 key = region.TerrainImage;
3269 return key.ToString();
3281 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetRegionStats");
3282 m_host.AddScriptLPS(1);
3284 float[] stats = World.StatsReporter.LastReportedSimStats;
3286 for (
int i = 0; i < 21; i++)
3295 CheckThreatLevel(
ThreatLevel.None,
"osGetRegionSize");
3296 m_host.AddScriptLPS(1);
3301 isMegaregion = rcMod.IsRootForMegaregion(World.RegionInfo.RegionID);
3303 isMegaregion =
false;
3307 Vector2 size = rcMod.GetSizeOfMegaregion(World.RegionInfo.RegionID);
3312 Scene scene = m_ScriptEngine.World;
3313 GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID);
3320 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetSimulatorMemory");
3321 m_host.AddScriptLPS(1);
3322 long pws = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
3324 if (pws > Int32.MaxValue)
3325 return Int32.MaxValue;
3334 CheckThreatLevel(
ThreatLevel.Moderate,
"osSetSpeed");
3335 m_host.AddScriptLPS(1);
3336 ScenePresence avatar = World.GetScenePresence(
new UUID(UUID));
3339 avatar.SpeedModifier = (float)SpeedModifier;
3344 CheckThreatLevel(
ThreatLevel.Severe,
"osKickAvatar");
3345 m_host.AddScriptLPS(1);
3347 World.ForEachRootScenePresence(delegate(ScenePresence sp)
3353 sp.ControllingClient.Kick(alert);
3356 sp.Scene.CloseAgent(sp.UUID,
false);
3363 CheckThreatLevel(
ThreatLevel.None,
"osGetHealth");
3364 m_host.AddScriptLPS(1);
3367 ScenePresence presence = World.GetScenePresence(
new UUID(avatar));
3368 if (presence != null) health = presence.Health;
3374 CheckThreatLevel(
ThreatLevel.High,
"osCauseDamage");
3375 m_host.AddScriptLPS(1);
3378 Vector3 pos = m_host.GetWorldPosition();
3380 ScenePresence presence = World.GetScenePresence(avatarId);
3381 if (presence != null)
3383 LandData land = World.GetLandData(pos);
3384 if ((land.
Flags & (uint)ParcelFlags.AllowDamage) == (uint)ParcelFlags.AllowDamage)
3386 float health = presence.Health;
3387 health -= (float)damage;
3388 presence.setHealthWithUpdate(health);
3391 float healthliveagain = 100;
3392 presence.ControllingClient.SendAgentAlertMessage(
"You died!",
true);
3393 presence.setHealthWithUpdate(healthliveagain);
3394 presence.Scene.TeleportClientHome(presence.UUID, presence.ControllingClient);
3402 CheckThreatLevel(
ThreatLevel.High,
"osCauseHealing");
3403 m_host.AddScriptLPS(1);
3406 ScenePresence presence = World.GetScenePresence(avatarId);
3408 if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition()))
3410 float health = presence.Health;
3411 health += (float)healing;
3416 presence.setHealthWithUpdate(health);
3422 CheckThreatLevel(
ThreatLevel.High,
"osGetPrimitiveParams");
3423 m_host.AddScriptLPS(1);
3426 return m_LSL_Api.GetPrimitiveParamsEx(prim, rules);
3431 CheckThreatLevel(
ThreatLevel.High,
"osSetPrimitiveParams");
3432 m_host.AddScriptLPS(1);
3435 m_LSL_Api.SetPrimitiveParamsEx(prim, rules,
"osSetPrimitiveParams");
3443 CheckThreatLevel(
ThreatLevel.High,
"osSetProjectionParams");
3445 osSetProjectionParams(
UUID.Zero.ToString(), projection, texture, fov, focus, amb);
3453 CheckThreatLevel(
ThreatLevel.High,
"osSetProjectionParams");
3454 m_host.AddScriptLPS(1);
3457 if (prim ==
UUID.Zero.ToString())
3463 obj = World.GetSceneObjectPart(
new UUID(prim));
3468 obj.Shape.ProjectionEntry = projection;
3469 obj.Shape.ProjectionTextureUUID =
new UUID(texture);
3470 obj.Shape.ProjectionFOV = (float)fov;
3471 obj.Shape.ProjectionFocus = (float)focus;
3472 obj.Shape.ProjectionAmbiance = (float)amb;
3474 obj.ParentGroup.HasGroupChanged =
true;
3475 obj.ScheduleFullUpdate();
3484 CheckThreatLevel(
ThreatLevel.None,
"osGetAvatarList");
3485 m_host.AddScriptLPS(1);
3488 World.ForEachRootScenePresence(delegate (ScenePresence avatar)
3490 if (avatar != null && avatar.
UUID != m_host.OwnerID)
3508 CheckThreatLevel(
ThreatLevel.VeryLow,
"osUnixTimeToTimestamp");
3509 m_host.AddScriptLPS(1);
3511 long baseTicks = 621355968000000000;
3512 long tickResolution = 10000000;
3513 long epochTicks = (time * tickResolution) + baseTicks;
3514 DateTime date =
new DateTime(epochTicks);
3516 return date.ToString(
"yyyy-MM-ddTHH:mm:ss.fffffffZ");
3526 m_host.AddScriptLPS(1);
3528 lock (m_host.TaskInventory)
3530 foreach (KeyValuePair<UUID, TaskInventoryItem> inv
in m_host.TaskInventory)
3532 if (inv.Value.Name == item)
3534 return inv.Value.Description.ToString();
3539 return String.Empty;
3549 CheckThreatLevel(
ThreatLevel.VeryLow,
"osInviteToGroup");
3550 m_host.AddScriptLPS(1);
3556 if (groupsModule == null)
return ScriptBaseClass.FALSE;
3559 if (m_host.GroupID ==
UUID.Zero || m_host.GroupID == m_host.OwnerID)
return ScriptBaseClass.FALSE;
3562 GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID);
3563 if (member == null || (member.
GroupPowers & (ulong)GroupPowers.Invite) == 0)
return ScriptBaseClass.FALSE;
3572 groupsModule.
InviteGroup(null, m_host.OwnerID, m_host.GroupID, agent,
UUID.Zero);
3574 return ScriptBaseClass.TRUE;
3584 CheckThreatLevel(
ThreatLevel.VeryLow,
"osEjectFromGroup");
3585 m_host.AddScriptLPS(1);
3591 if (groupsModule == null)
return ScriptBaseClass.FALSE;
3594 if (m_host.GroupID ==
UUID.Zero || m_host.GroupID == m_host.OwnerID)
return ScriptBaseClass.FALSE;
3597 GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID);
3598 if (member == null || (member.
GroupPowers & (ulong)GroupPowers.Eject) == 0)
return ScriptBaseClass.FALSE;
3606 groupsModule.EjectGroupMember(null, m_host.OwnerID, m_host.GroupID, agent);
3608 return ScriptBaseClass.TRUE;
3619 CheckThreatLevel(
ThreatLevel.High,
"osSetTerrainTexture");
3621 m_host.AddScriptLPS(1);
3624 if (World.Permissions.IsGod(m_host.OwnerID))
3626 if (level < 0 || level > 3)
3630 if (!
UUID.TryParse(texture, out textureID))
3636 estate.setEstateTerrainBaseTexture(level, textureID);
3649 CheckThreatLevel(
ThreatLevel.High,
"osSetTerrainTextureHeight");
3651 m_host.AddScriptLPS(1);
3654 if (World.Permissions.IsGod(m_host.OwnerID))
3656 if (corner < 0 || corner > 3)
3662 estate.setEstateTerrainTextureHeights(corner, (float)low, (
float)high);
3666 #region Attachment commands
3670 CheckThreatLevel(
ThreatLevel.High,
"osForceAttachToAvatar");
3672 m_host.AddScriptLPS(1);
3675 ((
LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3680 CheckThreatLevel(
ThreatLevel.High,
"osForceAttachToAvatarFromInventory");
3682 m_host.AddScriptLPS(1);
3684 ForceAttachToAvatarFromInventory(m_host.OwnerID, itemName, attachmentPoint);
3689 CheckThreatLevel(
ThreatLevel.VeryHigh,
"osForceAttachToOtherAvatarFromInventory");
3691 m_host.AddScriptLPS(1);
3695 if (!
UUID.TryParse(rawAvatarId, out avatarId))
3698 ForceAttachToAvatarFromInventory(avatarId, itemName, attachmentPoint);
3705 if (attachmentsModule == null)
3714 ((
LSL_Api)m_LSL_Api).llSay(0, string.Format(
"Could not find object '{0}'", itemName));
3715 throw new Exception(
String.Format(
"The inventory item '{0}' could not be found", itemName));
3718 if (item.
InvType != (
int)InventoryType.Object)
3722 if (m_LSL_Api != null)
3723 ((
LSL_Api)m_LSL_Api).llSay(0, string.Format(
"Unable to attach, item '{0}' is not an object.", itemName));
3725 throw new Exception(
String.Format(
"The inventory item '{0}' is not an object", itemName));
3728 ScenePresence sp = World.GetScenePresence(avatarId);
3734 InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID, out message);
3736 if (newItem == null)
3739 "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}: {4}",
3740 itemName, m_host.Name, attachmentPoint, World.Name, message);
3741 ((
LSL_Api)m_LSL_Api).llSay(0, message);
3745 attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint);
3750 CheckThreatLevel(
ThreatLevel.High,
"osForceDetachFromAvatar");
3752 m_host.AddScriptLPS(1);
3755 ((
LSL_Api)m_LSL_Api).DetachFromAvatar();
3760 CheckThreatLevel(
ThreatLevel.Moderate,
"osGetNumberOfAttachments");
3762 m_host.AddScriptLPS(1);
3765 ScenePresence target;
3768 if (attachmentPoints.Length >= 1 &&
UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
3770 foreach (
object point
in attachmentPoints.Data)
3773 (point is
LSL_Integer || point is
int || point is uint) ?
3786 resp.Add(
new LSL_Integer(target.GetAttachments((uint)ipoint).Count));
3796 CheckThreatLevel(
ThreatLevel.Moderate,
"osMessageAttachments");
3797 m_host.AddScriptLPS(1);
3800 ScenePresence target;
3802 if (attachmentPoints.Length >= 1 &&
UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
3804 List<int> aps =
new List<int>();
3805 foreach (
object point
in attachmentPoints.Data)
3808 if (
int.TryParse(point.ToString(), out ipoint))
3814 List<SceneObjectGroup> attachments =
new List<SceneObjectGroup>();
3816 bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL);
3817 bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;
3819 if (msgAll && invertPoints)
3823 else if (msgAll || invertPoints)
3825 attachments = target.GetAttachments();
3829 foreach (
int point
in aps)
3833 attachments.AddRange(target.GetAttachments((uint)point));
3839 if (attachments.Count == 0)
3844 List<SceneObjectGroup> ignoreThese =
new List<SceneObjectGroup>();
3852 ignoreThese.Add(attachment);
3859 attachments.Remove(attachment);
3861 ignoreThese.Clear();
3864 if (attachments.Count < 1)
3875 ignoreThese.Add(attachment);
3881 attachments.Remove(attachment);
3883 ignoreThese.Clear();
3887 if (attachments.Count == 0)
3899 ignoreThese.Add(attachment);
3905 attachments.Remove(attachment);
3907 ignoreThese.Clear();
3912 if (attachments.Count == 0)
3935 m_host.AddScriptLPS(1);
3938 return UUID.TryParse(thing, out test) ? 1 : 0;
3950 m_host.AddScriptLPS(1);
3952 return Math.Min(a, b);
3964 m_host.AddScriptLPS(1);
3966 return Math.Max(a, b);
3971 CheckThreatLevel(
ThreatLevel.None,
"osGetRezzingObject");
3972 m_host.AddScriptLPS(1);
3974 return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
3983 CheckThreatLevel(
ThreatLevel.High,
"osSetContentType");
3985 if (m_UrlModule != null)
3986 m_UrlModule.HttpContentType(
new UUID(
id),type);
3995 m_host.AddScriptLPS(1);
3997 if (m_item.PermsGranter != m_host.OwnerID)
4000 OSSLShoutError(
string.Format(
"{0}. Permissions not granted to owner.", errorPrefix));
4002 else if ((m_item.PermsMask & perms) == 0)
4005 OSSLShoutError(
string.Format(
"{0}. Permissions not granted.", errorPrefix));
4019 ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);
4021 if (attachmentsModule != null && sp != null)
4023 attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId);
4035 ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);
4037 if (attachmentsModule != null && sp != null)
4039 attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId, pos, rot);
4045 CheckThreatLevel(
ThreatLevel.Moderate,
"osDropAttachment");
4046 m_host.AddScriptLPS(1);
4048 DropAttachment(
true);
4053 CheckThreatLevel(
ThreatLevel.High,
"osForceDropAttachment");
4054 m_host.AddScriptLPS(1);
4056 DropAttachment(
false);
4061 CheckThreatLevel(
ThreatLevel.Moderate,
"osDropAttachmentAt");
4062 m_host.AddScriptLPS(1);
4064 DropAttachmentAt(
true, pos, rot);
4069 CheckThreatLevel(
ThreatLevel.High,
"osForceDropAttachmentAt");
4070 m_host.AddScriptLPS(1);
4072 DropAttachmentAt(
false, pos, rot);
4077 CheckThreatLevel(
ThreatLevel.Low,
"osListenRegex");
4078 m_host.AddScriptLPS(1);
4080 UUID.TryParse(ID, out keyID);
4087 Regex.IsMatch(
"", name);
4091 OSSLShoutError(
"Name regex is invalid.");
4101 Regex.IsMatch(
"", msg);
4105 OSSLShoutError(
"Message regex is invalid.");
4111 return (wComm == null) ? -1 : wComm.Listen(
4125 CheckThreatLevel(
ThreatLevel.Low,
"osRegexIsMatch");
4126 m_host.AddScriptLPS(1);
4129 return Regex.IsMatch(input, pattern) ? 1 : 0;
4133 OSSLShoutError(
"Possible invalid regular expression detected.");
4140 CheckThreatLevel(
ThreatLevel.Moderate,
"osRequestSecureURL");
4141 m_host.AddScriptLPS(1);
4143 Hashtable opts =
new Hashtable();
4144 for (
int i = 0 ; i < options.Length ; i++)
4146 object opt = options.Data[i];
4147 if (opt.ToString() ==
"allowXss")
4148 opts[
"allowXss"] =
true;
4151 if (m_UrlModule != null)
4152 return m_UrlModule.RequestURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, opts).ToString();
4153 return UUID.Zero.ToString();
4158 CheckThreatLevel(
ThreatLevel.Moderate,
"osRequestSecureURL");
4159 m_host.AddScriptLPS(1);
4161 Hashtable opts =
new Hashtable();
4162 for (
int i = 0 ; i < options.Length ; i++)
4164 object opt = options.Data[i];
4165 if (opt.ToString() ==
"allowXss")
4166 opts[
"allowXss"] =
true;
4169 if (m_UrlModule != null)
4170 return m_UrlModule.RequestSecureURL(m_ScriptEngine.ScriptModule, m_host, m_item.ItemID, opts).ToString();
4171 return UUID.Zero.ToString();
LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard)
void osSetParcelDetails(LSL_Vector pos, LSL_List rules)
const int OS_NPC_LAND_AT_TARGET
double osGetCurrentSunHour()
Return the current Sun Hour 0...24, with 0 being roughly sun-rise
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat LSL_Float
void osDropAttachment()
Attempts to drop an attachment to the ground
void osCauseDamage(string avatar, double damage)
LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules)
void osForceOtherSit(string avatar, string target)
Overload method of osForceOtherSit(string avatar) to allow a script NOT in the target prim to force a...
LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
Returns a strided list of the specified attachment points and the number of attachments on those poin...
IClientAPI ControllingClient
OpenSim.Region.ScriptEngine.Shared.LSL_Types.list LSL_List
void Initialize(IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item)
Initialize the API
string osGetGridNick()
Get the nickname of this grid, as set in the [GridInfo] config section.
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString LSL_Key
const int PARCEL_DETAILS_GROUP
OpenMetaverse.StructuredData.OSDArray OSDArray
Contains all LSL ll-functions. This class will be in Default AppDomain.
void DropAttachmentAt(bool checkPerms, LSL_Vector pos, LSL_Rotation rot)
LSL_Key osGetMapTexture()
Get current region's map texture UUID
const int OS_LISTEN_REGEX_NAME
process name parameter as regex
OpenSim.Framework.Constants.TeleportFlags TeleportFlags
void osForceBreakLink(int linknum)
Identical to llBreakLink() but does not require permission from the owner.
void osNpcLoadAppearance(LSL_Key npc, string notecard)
void osSetRot(UUID target, Quaternion rotation)
void osParcelSubdivide(LSL_Vector pos1, LSL_Vector pos2)
void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options)
Sends a specified message to the specified avatar's attachments on the specified attachment points...
LSL_Integer osIsUUID(string thing)
Checks if thing is a UUID.
string osSetPenColour(string drawList, string colour)
static bool IsCached(UUID assetID)
void osNpcStopMoveToTarget(LSL_Key npc)
void osNpcStopAnimation(LSL_Key npc, string animation)
string osLoadedCreationID()
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString LSL_Key
void osSetEstateSunSettings(bool sunFixed, double sunHour)
Changes the Estate Sun Settings, then Triggers a Sun Update
ThreatLevel
To permit region owners to enable the extended scripting functionality of OSSL, without allowing mali...
string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, bool blend, int disp, int timer, int alpha, int face)
void osForceCreateLink(string target, int parent)
Identical to llCreateLink() but does not require permission from the owner.
void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
Attempts to drop an attachment at the specified coordinates while bypassing the script permissions ...
int ClaimDate
Date that the current owner purchased or claimed the parcel
LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options)
void osSetWindParam(string plugin, string param, LSL_Float value)
IPEndPoint RemoteEndPoint
void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb)
Set parameters for light projection with uuid of target prim
LSL_String osGetGender(LSL_Key rawAvatarId)
Get the gender as specified in avatar appearance for a given avatar key
Hashtable osParseJSON(string JSON)
void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint)
Attach an inventory item in the object containing this script to any avatar in the region without ask...
LSL_Vector osNpcGetPos(LSL_Key npc)
Contains the Avatar's Appearance and methods to manipulate the appearance.
double osSunGetParam(string param)
LSL_String osFormatString(string str, LSL_List strings)
string osGetNotecardLine(string name, int line)
Directly get an entire notecard at once.
LSL_Vector osGetRegionSize()
string osDrawImage(string drawList, int width, int height, string imageUrl)
string osAvatarName2Key(string firstname, string lastname)
LSL_Integer osSetTerrainHeight(int x, int y, double val)
void osParcelJoin(LSL_Vector pos1, LSL_Vector pos2)
AvatarAppearance Appearance
OpenMetaverse.StructuredData.OSDMap OSDMap
TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName)
Save a notecard to prim inventory.
void osMakeNotecard(string notecardName, LSL_Types.list contents)
Write a notecard directly to the prim's inventory.
LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard)
Save the current appearance of the NPC permanently to the named notecard.
UUID CacheNotecard(string notecardNameOrUuid)
Cache a notecard's contents.
void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
string LoadNotecard(string notecardNameOrUuid)
Load the notecard data found at the given prim inventory item name or asset uuid. ...
int osRegionRestart(double seconds)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
Attach an inventory item in the object containing this script to the avatar that owns it without aski...
void osSetParcelSIPAddress(string SIPAddress)
bool CheckPermissions(UUID npcID, UUID callerID)
Check if the caller has permission to manipulate the given NPC.
void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
Represents an item in a task inventory
LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize)
void osSetSpeed(string UUID, LSL_Float SpeedModifier)
void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat LSL_Float
void osAvatarPlayAnimation(string avatar, string animation)
const int OS_LISTEN_REGEX_MESSAGE
process message parameter as regex
LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
Get the primitive parameters of a linked prim.
void osNpcSay(LSL_Key npc, int channel, string message)
void ForceSit(string avatar, UUID targetID)
void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options)
Temporary interface. More methods to come at some point to make NPCs more object oriented rather than...
string osDrawEllipse(string drawList, int width, int height)
Records user information specific to a grid but which is not part of a user's account.
void osForceDropAttachment()
Attempts to drop an attachment to the ground while bypassing the script permissions ...
string osGetGridHomeURI()
double osList2Double(LSL_Types.list src, int index)
LSL_Integer osTerrainSetHeight(int x, int y, double val)
void osSetParcelMediaURL(string url)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.list LSL_List
LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard)
void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3 LSL_Vector
string osSetPenColor(string drawList, string color)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3 LSL_Vector
string osGetAgentIP(string agent)
void osKickAvatar(string FirstName, string SurName, string alert)
string osDrawLine(string drawList, int endX, int endY)
string osGetScriptEngineName()
void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
void osSetTerrainTextureHeight(int corner, double low, double high)
Sets terrain heights of estate
int osGetSimulatorMemory()
LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard)
Asset class. All Assets are reference by this class or a class derived from this class ...
const int OS_NPC_OBJECT_GROUP
void osForceBreakAllLinks()
Identical to llBreakAllLinks() but does not require permission from the owner.
LSL_String osUnixTimeToTimestamp(long time)
Convert a unix time to a llGetTimestamp() like string
An interface for a script API module to communicate with the engine it's running under ...
LSL_Integer osIsNpc(LSL_Key npc)
Check if the given key is an npc
LSL_Float osGetTerrainHeight(int x, int y)
List< UUID > AllowedCreators
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion LSL_Rotation
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString LSL_String
bool osConsoleCommand(string command)
static readonly LSLInteger FALSE
string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer)
const int OS_ATTACH_MSG_OBJECT_CREATOR
Instructs osMessageAttachments to only send the message to attachments with a CreatorID that matches ...
OpenSim.Framework.Constants.TeleportFlags TPFlags
string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
LSL_String osGetInventoryDesc(string item)
Get the description from an inventory item
void osParcelSetDetails(LSL_Vector pos, LSL_List rules)
int osGetNumberOfNotecardLines(string name)
Get the number of lines in the given notecard.
void osNpcMoveTo(LSL_Key npc, LSL_Vector pos)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
UUID GroupID
Unique ID of the Group that owns
const int PARCEL_DETAILS_CLAIMDATE
string osSetPenCap(string drawList, string direction, string type)
string osKey2Name(string id)
void osMessageObject(LSL_Key objectUUID, string message)
Send a message to to object identified by the given UUID
string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer)
string osDrawRectangle(string drawList, int width, int height)
override Vector3 AbsolutePosition
Position of this avatar relative to the region the avatar is in
UUID SearchTaskInventoryForAssetId(string name)
uint AttachmentPoint
Attachment point of this scene object to an avatar.
void osCauseHealing(string avatar, double healing)
void osNpcRemove(LSL_Key npc)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger LSL_Integer
Inventory Item - contains all the properties associated with an individual inventory piece...
LSL_Float osMax(double a, double b)
Wraps to Math.max()
LSL_Key osOwnerSaveAppearance(string notecard)
Save the current appearance of the script owner permanently to the named notecard.
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion LSL_Rotation
string osGetGridCustom(string key)
void ForceAttachToAvatarFromInventory(UUID avatarId, string itemName, int attachmentPoint)
void osNpcStand(LSL_Key npc)
Details of a Parcel of land
LSL_Key osGetRegionMapTexture(string regionName)
Get a region's map texture UUID by region UUID or name.
void osNpcPlayAnimation(LSL_Key npc, string animation)
virtual byte[] VisualParams
void osTeleportOwner(int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
string osGetNotecard(string name)
Get an entire notecard at once.
LSL_Float osGetWindParam(string plugin, string param)
void osNpcWhisper(LSL_Key npc, int channel, string message)
void osForceOtherSit(string avatar)
OpenMetaverse.StructuredData.OSD OSD
LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
Identical to llListen except for a bitfield which indicates which string parameters should be parsed ...
LSL_Integer osInviteToGroup(LSL_Key agentId)
Invite user to the group this object is set to
void osNpcShout(LSL_Key npc, int channel, string message)
string osLoadedCreationTime()
string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, bool blend, int disp, int timer, int alpha, int face)
string osDrawPolygon(string drawList, LSL_List x, LSL_List y)
LSL_Key osNpcGetOwner(LSL_Key npc)
Get the owner of the NPC
LSL_String osRequestURL(LSL_List options)
LSL_Float osGetHealth(string avatar)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger LSL_Integer
LSL_Integer osRegexIsMatch(string input, string pattern)
Wraps to bool Regex.IsMatch(string input, string pattern)
Interactive OpenSim region server
LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard)
string osGetGridLoginURI()
const int OS_ATTACH_MSG_SCRIPT_CREATOR
Instructs osMessageAttachments to only send the message to attachments with a CreatorID that matches ...
string osWindActiveModelPluginName()
void osSetSunParam(string param, double value)
OpenSim.Framework.Animation Animation
LSL_List osGetRegionStats()
void InviteGroup(IClientAPI remoteClient, UUID agentID, UUID GroupID, UUID InviteeID, UUID RoleID)
string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, int timer, int alpha)
void osForceAttachToAvatar(int attachmentPoint)
Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATT...
string osMovePen(string drawList, int x, int y)
void osRegionNotice(string msg)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger LSLInteger
LSL_Key osGetRezzingObject()
Get the key of the object that rezzed this object.
const int OS_NPC_NOT_OWNED
const int PERMISSION_ATTACH
string osGetSimulatorVersion()
LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString LSL_String
uint Flags
Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags ...
void osAvatarStopAnimation(string avatar, string animation)
static readonly LSLInteger TRUE
void CheckThreatLevel(ThreatLevel level, string function)
string osSetFontName(string drawList, string fontName)
void ScriptSleep(int delay)
string osGetGridGatekeeperURI()
void osSetRegionWaterHeight(double height)
LSL_List osGetAvatarList()
Like osGetAgents but returns enough info for a radar
const int OS_NPC_SENSE_AS_AGENT
double osGetSunParam(string param)
void osSetStateEvents(int events)
Quaternion GetWorldRotation()
Gets the world rotation of this presence.
void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
string osSetFontSize(string drawList, int fontSize)
void osSetContentType(LSL_Key id, string type)
Sets the response type for an HTTP request/response
string osDrawText(string drawList, string text)
OpenSim.Services.Interfaces.GridRegion GridRegion
void DropAttachment(bool checkPerms)
void osNpcSay(LSL_Key npc, string message)
bool ShoutErrorOnLackingOwnerPerms(int perms, string errorPrefix)
virtual string Name
The name of this entity
Holds all the data required to execute a scripting event.
LSL_List osMatchString(string src, string pattern, int start)
string osGetAvatarHomeURI(string uuid)
LSL_Float osTerrainGetHeight(int x, int y)
void osSetTerrainTexture(int level, LSL_Key texture)
Sets terrain estate texture
This maintains the relationship between a UUID and a user name.
Object osParseJSONNew(string JSON)
void osSunSetParam(string param, double value)
override Object InitializeLifetimeService()
void osForceDetachFromAvatar()
Detach the object containing this script from the avatar it is attached to without checking for PERMI...
LSL_String osRequestSecureURL(LSL_List options)
void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
Changes the Region Sun Settings, then Triggers a Sun Update
string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams, int timer, int alpha)
void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb)
Set parameters for light projection in host prim
void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
Attempts to drop an attachment at the specified coordinates.
string osLoadedCreationDate()
void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
LSL_String osReplaceString(string src, string pattern, string replace, int count, int start)
OpenSim.Framework.PermissionMask PermissionMask
List< string > AllowedOwnerClasses
string osGetPhysicsEngineType()
LSL_Rotation osNpcGetRot(LSL_Key npc)
LSL_Float osMin(double a, double b)
Wraps to Math.Min()
List< UUID > AllowedOwners
string osDrawFilledRectangle(string drawList, int width, int height)
LSL_Integer osEjectFromGroup(LSL_Key agentId)
Eject user from the group this object is set to
string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
string osSetPenSize(string drawList, int penSize)
void osSetPrimFloatOnWater(int floatYN)
void osNpcSit(LSL_Key npc, LSL_Key target, int options)
UUID OwnerID
Owner Avatar or Group of the parcel. Naturally, all land masses must be owned by someone ...