use LoadNotecard

master
Christopher 2020-07-10 17:49:14 +02:00
parent e6039c53f3
commit c5cc87e10d
1 changed files with 27 additions and 8 deletions

View File

@ -4,6 +4,7 @@ using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Modules.Appearance2Avatar.helper;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using System;
@ -19,13 +20,12 @@ namespace OpenSim.Modules.Appearance2Avatar
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "Appearance2Avatar")]
class Appearance2Avatar : INonSharedRegionModule
public class Appearance2Avatar : INonSharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IScriptModuleComms m_scriptModule = null;
private Scene m_scene = null;
public static Scene m_scene = null;
public string Name
{
@ -68,6 +68,27 @@ namespace OpenSim.Modules.Appearance2Avatar
}
protected string LoadNotecard(UUID assetID)
{
if (assetID != UUID.Zero)
{
StringBuilder notecardData = new StringBuilder();
for (int count = 0; count < NotecardCache.GetLines(assetID); count++)
{
string line = NotecardCache.GetLine(assetID, count) + "\n";
// m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line);
notecardData.Append(line);
}
return notecardData.ToString();
}
return null;
}
[ScriptInvocation]
public void osAppearance2Avatar(UUID hostID, UUID scriptID, String notecard, String targetAvatar)
{
@ -90,16 +111,14 @@ namespace OpenSim.Modules.Appearance2Avatar
}
m_log.Info("[" + Name + "] Info: Fetch asset data for notecard.");
AssetBase asset = m_scene.AssetService.Get(notecardItem.AssetID.ToString());
String asset = LoadNotecard(notecardItem.AssetID);
if (asset != null)
{
m_log.Info("[" + Name + "] Info: Convert notecard to string.");
String _appearanceNotecard = new ASCIIEncoding().GetString(asset.Data);
m_log.Info(_appearanceNotecard);
m_log.Info(asset);
m_log.Info("[" + Name + "] Info: Deserialize notecard.");
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(_appearanceNotecard);
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(asset);
AvatarAppearance appearance = new AvatarAppearance();
appearance.Unpack(appearanceOsd);