Terrain changes done via osTerrainSetHeight aren't shown immediately to the clients in

that region. I decided against sending the terrain on every call to osTerrainSetHeight
(which makes it abysmally slow), and added a osTerrainFlush instead, which should be
called after all the terrain-changes have been done. Changed some return types to
LSL types, too, and removed some end-of-line spaces.
0.6.5-rc1
Homer Horwitz 2009-04-19 13:34:28 +00:00
parent 9c3ec87b97
commit 33e1316ced
3 changed files with 56 additions and 36 deletions

View File

@ -270,7 +270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// //
// OpenSim functions // OpenSim functions
// //
public int osTerrainSetHeight(int x, int y, double val) public LSL_Integer osTerrainSetHeight(int x, int y, double val)
{ {
CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
@ -289,7 +289,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
public double osTerrainGetHeight(int x, int y) public LSL_Float osTerrainGetHeight(int x, int y)
{ {
CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight");
@ -300,6 +300,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return World.Heightmap[x, y]; return World.Heightmap[x, y];
} }
public void osTerrainFlush()
{
CheckThreatLevel(ThreatLevel.VeryLow, "osTerrainFlush");
ITerrainModule terrainModule = World.RequestModuleInterface<ITerrainModule>();
if (terrainModule != null) terrainModule.TaintTerrain();
}
public int osRegionRestart(double seconds) public int osRegionRestart(double seconds)
{ {
// This is High here because region restart is not reliable // This is High here because region restart is not reliable
@ -504,23 +512,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (presence != null) if (presence != null)
{ {
// agent must be over owners land to avoid abuse // agent must be over owners land to avoid abuse
if (m_host.OwnerID if (m_host.OwnerID
== World.LandChannel.GetLandObject( == World.LandChannel.GetLandObject(
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).landData.OwnerID) presence.AbsolutePosition.X, presence.AbsolutePosition.Y).landData.OwnerID)
{ {
// Check for hostname , attempt to make a hglink // Check for hostname , attempt to make a hglink
// and convert the regionName to the target region // and convert the regionName to the target region
if ( regionName.Contains(".") && regionName.Contains(":")) if ( regionName.Contains(".") && regionName.Contains(":"))
{ {
// Try to link the region // Try to link the region
RegionInfo regInfo = HGHyperlink.TryLinkRegion(World, RegionInfo regInfo = HGHyperlink.TryLinkRegion(World,
presence.ControllingClient, presence.ControllingClient,
regionName); regionName);
// Get the region name // Get the region name
if (regInfo != null) if (regInfo != null)
{ {
regionName = regInfo.RegionName; regionName = regInfo.RegionName;
} }
else else
{ {
@ -531,7 +539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
World.RequestTeleportLocation(presence.ControllingClient, regionName, World.RequestTeleportLocation(presence.ControllingClient, regionName,
new Vector3((float)position.x, (float)position.y, (float)position.z), new Vector3((float)position.x, (float)position.y, (float)position.z),
new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation); new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation);
ScriptSleep(5000); ScriptSleep(5000);
} }
} }
@ -555,9 +563,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (presence != null) if (presence != null)
{ {
// agent must be over owners land to avoid abuse // agent must be over owners land to avoid abuse
if (m_host.OwnerID if (m_host.OwnerID
== World.LandChannel.GetLandObject( == World.LandChannel.GetLandObject(
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).landData.OwnerID) presence.AbsolutePosition.X, presence.AbsolutePosition.Y).landData.OwnerID)
{ {
presence.ControllingClient.SendTeleportLocationStart(); presence.ControllingClient.SendTeleportLocationStart();
World.RequestTeleportLocation(presence.ControllingClient, regionHandle, World.RequestTeleportLocation(presence.ControllingClient, regionHandle,
@ -592,7 +600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
ScenePresence target = (ScenePresence)World.Entities[avatarID]; ScenePresence target = (ScenePresence)World.Entities[avatarID];
EndPoint ep = target.ControllingClient.GetClientInfo().userEP; EndPoint ep = target.ControllingClient.GetClientInfo().userEP;
if (ep is IPEndPoint) if (ep is IPEndPoint)
{ {
IPEndPoint ip = (IPEndPoint)ep; IPEndPoint ip = (IPEndPoint)ep;
return ip.Address.ToString(); return ip.Address.ToString();
@ -610,12 +618,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.None, "osGetAgents"); CheckThreatLevel(ThreatLevel.None, "osGetAgents");
LSL_List result = new LSL_List(); LSL_List result = new LSL_List();
foreach (ScenePresence avatar in World.GetAvatars()) foreach (ScenePresence avatar in World.GetAvatars())
{ {
result.Add(avatar.Name); result.Add(avatar.Name);
} }
return result; return result;
} }
// Adam's super super custom animation functions // Adam's super super custom animation functions
public void osAvatarPlayAnimation(string avatar, string animation) public void osAvatarPlayAnimation(string avatar, string animation)
@ -791,7 +799,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector vec = new LSL_Vector(0,0,0); LSL_Vector vec = new LSL_Vector(0,0,0);
IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>(); IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
if (textureManager != null) if (textureManager != null)
{ {
double xSize, ySize; double xSize, ySize;
textureManager.GetDrawStringSize(contentType, text, fontName, fontSize, textureManager.GetDrawStringSize(contentType, text, fontName, fontSize,
@ -847,7 +855,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
while (sunHour < 0) while (sunHour < 0)
sunHour += 24.0; sunHour += 24.0;
World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
@ -1014,8 +1022,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
ILandObject land ILandObject land
= World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
if (land.landData.OwnerID != m_host.ObjectOwner) if (land.landData.OwnerID != m_host.ObjectOwner)
@ -1350,12 +1358,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key");
CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(firstname, lastname); CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(firstname, lastname);
if (null == userInfo) if (null == userInfo)
{ {
return UUID.Zero.ToString(); return UUID.Zero.ToString();
} }
else else
{ {
return userInfo.UserProfile.ID.ToString(); return userInfo.UserProfile.ID.ToString();
} }
@ -1370,15 +1378,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(key); CachedUserInfo userInfo = World.CommsManager.UserProfileCacheService.GetUserDetails(key);
if (null == userInfo) if (null == userInfo)
{ {
return ""; return "";
} }
else else
{ {
return userInfo.UserProfile.Name; return userInfo.UserProfile.Name;
} }
} }
else else
{ {
return ""; return "";
@ -1391,7 +1399,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// for instance in a HG scenario, are a distinct possibility. /// for instance in a HG scenario, are a distinct possibility.
/// ///
/// Use value from the config file and return it. /// Use value from the config file and return it.
/// ///
public string osGetGridNick() public string osGetGridNick()
{ {
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
@ -1454,15 +1462,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
return result; // empty list return result; // empty list
} }
// Find matches beginning at start position // Find matches beginning at start position
Regex matcher = new Regex(pattern); Regex matcher = new Regex(pattern);
Match match = matcher.Match(src, start); Match match = matcher.Match(src, start);
if (match.Success) if (match.Success)
{ {
foreach (System.Text.RegularExpressions.Group g in match.Groups) foreach (System.Text.RegularExpressions.Group g in match.Groups)
{ {
if (g.Success) if (g.Success)
{ {
result.Add(g.Value); result.Add(g.Value);
result.Add(g.Index); result.Add(g.Index);

View File

@ -33,6 +33,8 @@ using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{ {
@ -59,8 +61,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer); string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer);
string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams, string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
int timer, int alpha); int timer, int alpha);
double osTerrainGetHeight(int x, int y);
int osTerrainSetHeight(int x, int y, double val); LSL_Float osTerrainGetHeight(int x, int y);
LSL_Integer osTerrainSetHeight(int x, int y, double val);
void osTerrainFlush();
int osRegionRestart(double seconds); int osRegionRestart(double seconds);
void osRegionNotice(string msg); void osRegionNotice(string msg);
bool osConsoleCommand(string Command); bool osConsoleCommand(string Command);

View File

@ -40,6 +40,8 @@ using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{ {
@ -132,16 +134,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha); return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha);
} }
public double osTerrainGetHeight(int x, int y) public LSL_Float osTerrainGetHeight(int x, int y)
{ {
return m_OSSL_Functions.osTerrainGetHeight(x, y); return m_OSSL_Functions.osTerrainGetHeight(x, y);
} }
public int osTerrainSetHeight(int x, int y, double val) public LSL_Integer osTerrainSetHeight(int x, int y, double val)
{ {
return m_OSSL_Functions.osTerrainSetHeight(x, y, val); return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
} }
public void osTerrainFlush()
{
m_OSSL_Functions.osTerrainFlush();
}
public int osRegionRestart(double seconds) public int osRegionRestart(double seconds)
{ {
return m_OSSL_Functions.osRegionRestart(seconds); return m_OSSL_Functions.osRegionRestart(seconds);