PixelTomsen 2012-02-24 20:46:14 +01:00 committed by Justin Clark-Casey (justincc)
parent bafef292f4
commit 7b5e42c744
3 changed files with 105 additions and 27 deletions

View File

@ -8173,23 +8173,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
ScriptSleep(1000);
return GetPrimMediaParams(m_host, face, rules);
}
public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
{
m_host.AddScriptLPS(1);
ScriptSleep(1000);
if (link == ScriptBaseClass.LINK_ROOT)
return GetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules);
else if (link == ScriptBaseClass.LINK_THIS)
return GetPrimMediaParams(m_host, face, rules);
else
{
SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
if (null != part)
return GetPrimMediaParams(part, face, rules);
}
return new LSL_List();
}
private LSL_List GetPrimMediaParams(SceneObjectPart part, int face, LSL_List rules)
{
// LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
// TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
// Assuming silently fail means give back an empty list. Ideally, need to check this.
if (face < 0 || face > m_host.GetNumberOfSides() - 1)
if (face < 0 || face > part.GetNumberOfSides() - 1)
return new LSL_List();
return GetPrimMediaParams(face, rules);
}
private LSL_List GetPrimMediaParams(int face, LSL_List rules)
{
IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
if (null == module)
throw new Exception("Media on a prim functions not available");
return new LSL_List();
MediaEntry me = module.GetMediaEntry(m_host, face);
MediaEntry me = module.GetMediaEntry(part, face);
// As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams
if (null == me)
@ -8271,33 +8288,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
res.Add(new LSL_Integer((int)me.ControlPermissions));
break;
default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS;
}
}
return res;
}
public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules)
public LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules)
{
m_host.AddScriptLPS(1);
ScriptSleep(1000);
return SetPrimMediaParams(m_host, face, rules);
}
public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
{
m_host.AddScriptLPS(1);
ScriptSleep(1000);
if (link == ScriptBaseClass.LINK_ROOT)
return SetPrimMediaParams(m_host.ParentGroup.RootPart, face, rules);
else if (link == ScriptBaseClass.LINK_THIS)
return SetPrimMediaParams(m_host, face, rules);
else
{
SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
if (null != part)
return SetPrimMediaParams(part, face, rules);
}
return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
}
private LSL_Integer SetPrimMediaParams(SceneObjectPart part, LSL_Integer face, LSL_List rules)
{
// LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid
// Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
// Don't perform the media check directly
if (face < 0 || face > m_host.GetNumberOfSides() - 1)
return ScriptBaseClass.LSL_STATUS_OK;
if (face < 0 || face > part.GetNumberOfSides() - 1)
return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
return SetPrimMediaParams(face, rules);
}
private LSL_Integer SetPrimMediaParams(int face, LSL_List rules)
{
IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
if (null == module)
throw new Exception("Media on a prim functions not available");
return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED;
MediaEntry me = module.GetMediaEntry(m_host, face);
MediaEntry me = module.GetMediaEntry(part, face);
if (null == me)
me = new MediaEntry();
@ -8376,10 +8412,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++);
break;
default: return ScriptBaseClass.LSL_STATUS_MALFORMED_PARAMS;
}
}
module.SetMediaEntry(m_host, face, me);
module.SetMediaEntry(part, face, me);
return ScriptBaseClass.LSL_STATUS_OK;
}
@ -8388,18 +8426,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
ScriptSleep(1000);
return ClearPrimMedia(m_host, face);
}
public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face)
{
m_host.AddScriptLPS(1);
ScriptSleep(1000);
if (link == ScriptBaseClass.LINK_ROOT)
return ClearPrimMedia(m_host.ParentGroup.RootPart, face);
else if (link == ScriptBaseClass.LINK_THIS)
return ClearPrimMedia(m_host, face);
else
{
SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(link);
if (null != part)
return ClearPrimMedia(part, face);
}
return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
}
private LSL_Integer ClearPrimMedia(SceneObjectPart part, LSL_Integer face)
{
// LSL Spec http://wiki.secondlife.com/wiki/LlClearPrimMedia says to fail silently if face is invalid
// Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this.
// FIXME: Don't perform the media check directly
if (face < 0 || face > m_host.GetNumberOfSides() - 1)
return ScriptBaseClass.LSL_STATUS_OK;
if (face < 0 || face > part.GetNumberOfSides() - 1)
return ScriptBaseClass.LSL_STATUS_NOT_FOUND;
IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
if (null == module)
throw new Exception("Media on a prim functions not available");
return ScriptBaseClass.LSL_STATUS_NOT_SUPPORTED;
module.ClearMediaEntry(m_host, face);
module.ClearMediaEntry(part, face);
return ScriptBaseClass.LSL_STATUS_OK;
}

View File

@ -64,6 +64,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options);
LSL_Integer llCeil(double f);
void llClearCameraParams();
LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face);
LSL_Integer llClearPrimMedia(LSL_Integer face);
void llCloseRemoteDataChannel(string channel);
LSL_Float llCloud(LSL_Vector offset);
@ -139,7 +140,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_String llGetLinkName(int linknum);
LSL_Integer llGetLinkNumber();
LSL_Integer llGetLinkNumberOfSides(int link);
LSL_List llGetLinkPrimitiveParams(int linknum, LSL_List rules);
LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules);
LSL_List llGetLinkPrimitiveParams(int linknum, LSL_List rules);
LSL_Integer llGetListEntryType(LSL_List src, int index);
LSL_Integer llGetListLength(LSL_List src);
LSL_Vector llGetLocalPos();
@ -335,6 +337,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void llSetInventoryPermMask(string item, int mask, int value);
void llSetLinkAlpha(int linknumber, double alpha, int face);
void llSetLinkColor(int linknumber, LSL_Vector color, int face);
LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules);
void llSetLinkPrimitiveParams(int linknumber, LSL_List rules);
void llSetLinkTexture(int linknumber, string texture, int face);
void llSetLinkTextureAnim(int linknum, int mode, int face, int sizex, int sizey, double start, double length, double rate);
@ -345,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void llSetParcelMusicURL(string url);
void llSetPayPrice(int price, LSL_List quick_pay_buttons);
void llSetPos(LSL_Vector pos);
LSL_Integer llSetPrimMediaParams(int face, LSL_List rules);
LSL_Integer llSetPrimMediaParams(LSL_Integer face, LSL_List rules);
void llSetPrimitiveParams(LSL_List rules);
void llSetLinkPrimitiveParamsFast(int linknum, LSL_List rules);
void llSetPrimURL(string url);

View File

@ -1887,17 +1887,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_LSL_Functions.llGetPrimMediaParams(face, rules);
}
public LSL_List llGetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
{
return m_LSL_Functions.llGetLinkMedia(link, face, rules);
}
public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules)
{
return m_LSL_Functions.llSetPrimMediaParams(face, rules);
}
public LSL_Integer llSetLinkMedia(LSL_Integer link, LSL_Integer face, LSL_List rules)
{
return m_LSL_Functions.llSetLinkMedia(link, face, rules);
}
public LSL_Integer llClearPrimMedia(LSL_Integer face)
{
return m_LSL_Functions.llClearPrimMedia(face);
}
public LSL_Integer llClearLinkMedia(LSL_Integer link, LSL_Integer face)
{
return m_LSL_Functions.llClearLinkMedia(link, face);
}
public void print(string str)
{
m_LSL_Functions.print(str);