mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 11:33:28 +08:00
Merge branch 'master' into mantis5110
Conflicts: OpenSim/Region/Framework/Scenes/ScenePresence.cs
This commit is contained in:
@@ -124,13 +124,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
// Save avatar attachment information
|
||||
ScenePresence presence;
|
||||
if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
|
||||
if (m_scene.AvatarService != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
|
||||
{
|
||||
m_log.Info(
|
||||
"[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
|
||||
+ ", AttachmentPoint: " + AttachmentPt);
|
||||
|
||||
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,8 +382,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
item = m_scene.InventoryService.GetItem(item);
|
||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
|
||||
|
||||
if (m_scene.AvatarFactory != null)
|
||||
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
if (m_scene.AvatarService != null)
|
||||
m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,10 +405,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
presence.Appearance.DetachAttachment(itemID);
|
||||
|
||||
// Save avatar attachment information
|
||||
if (m_scene.AvatarFactory != null)
|
||||
if (m_scene.AvatarService != null)
|
||||
{
|
||||
m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
|
||||
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||
|
||||
presence.Appearance.DetachAttachment(itemID);
|
||||
|
||||
if (m_scene.AvatarFactory != null)
|
||||
if (m_scene.AvatarService != null)
|
||||
{
|
||||
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
part.ParentGroup.DetachToGround();
|
||||
|
||||
|
||||
@@ -32,58 +32,56 @@ using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
using System.Threading;
|
||||
using System.Timers;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||
{
|
||||
public class AvatarFactoryModule : IAvatarFactory, IRegionModule
|
||||
public class AvatarFactoryModule : IRegionModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
|
||||
private Scene m_scene = null;
|
||||
private static readonly AvatarAppearance def = new AvatarAppearance();
|
||||
|
||||
public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance)
|
||||
private int m_savetime = 5; // seconds to wait before saving changed appearance
|
||||
private int m_sendtime = 2; // seconds to wait before sending changed appearance
|
||||
|
||||
private int m_checkTime = 500; // milliseconds to wait between checks for appearance updates
|
||||
private System.Timers.Timer m_updateTimer = new System.Timers.Timer();
|
||||
private Dictionary<UUID,long> m_savequeue = new Dictionary<UUID,long>();
|
||||
private Dictionary<UUID,long> m_sendqueue = new Dictionary<UUID,long>();
|
||||
|
||||
#region RegionModule Members
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
AvatarData avatar = m_scene.AvatarService.GetAvatar(avatarId);
|
||||
//if ((profile != null) && (profile.RootFolder != null))
|
||||
if (avatar != null)
|
||||
{
|
||||
appearance = avatar.ToAvatarAppearance(avatarId);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId);
|
||||
appearance = CreateDefault(avatarId);
|
||||
return false;
|
||||
}
|
||||
|
||||
private AvatarAppearance CreateDefault(UUID avatarId)
|
||||
{
|
||||
AvatarAppearance appearance = null;
|
||||
AvatarWearable[] wearables;
|
||||
byte[] visualParams;
|
||||
GetDefaultAvatarAppearance(out wearables, out visualParams);
|
||||
appearance = new AvatarAppearance(avatarId, wearables, visualParams);
|
||||
|
||||
return appearance;
|
||||
}
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
scene.RegisterModuleInterface<IAvatarFactory>(this);
|
||||
scene.EventManager.OnNewClient += NewClient;
|
||||
|
||||
if (m_scene == null)
|
||||
if (config != null)
|
||||
{
|
||||
m_scene = scene;
|
||||
IConfig sconfig = config.Configs["Startup"];
|
||||
if (sconfig != null)
|
||||
{
|
||||
m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime)));
|
||||
m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_scene == null)
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
m_updateTimer.Enabled = false;
|
||||
m_updateTimer.AutoReset = true;
|
||||
m_updateTimer.Interval = m_checkTime; // 500 milliseconds wait to start async ops
|
||||
m_updateTimer.Elapsed += new ElapsedEventHandler(HandleAppearanceUpdateTimer);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
@@ -102,6 +100,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||
|
||||
public void NewClient(IClientAPI client)
|
||||
{
|
||||
client.OnRequestWearables += SendWearables;
|
||||
client.OnSetAppearance += SetAppearance;
|
||||
client.OnAvatarNowWearing += AvatarIsWearing;
|
||||
}
|
||||
|
||||
@@ -110,13 +110,263 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||
// client.OnAvatarNowWearing -= AvatarIsWearing;
|
||||
}
|
||||
|
||||
public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Set appearance data (textureentry and slider settings) received from the client
|
||||
/// </summary>
|
||||
/// <param name="texture"></param>
|
||||
/// <param name="visualParam"></param>
|
||||
public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
|
||||
{
|
||||
// DEBUG ON
|
||||
m_log.WarnFormat("[AVFACTORY] SetAppearance for {0}",client.AgentId);
|
||||
// DEBUG OFF
|
||||
|
||||
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
|
||||
if (sp == null)
|
||||
{
|
||||
m_log.WarnFormat("[AVFACTORY] SetAppearance unable to find presence for {0}",client.AgentId);
|
||||
return;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
|
||||
// Process the texture entry
|
||||
if (textureEntry != null)
|
||||
{
|
||||
changed = sp.Appearance.SetTextureEntries(textureEntry);
|
||||
|
||||
for (int i = 0; i < BAKE_INDICES.Length; i++)
|
||||
{
|
||||
int idx = BAKE_INDICES[i];
|
||||
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
|
||||
if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
|
||||
Util.FireAndForget(delegate(object o) { CheckBakedTextureAssets(client,face.TextureID,idx); });
|
||||
}
|
||||
}
|
||||
|
||||
// Process the visual params, this may change height as well
|
||||
if (visualParams != null)
|
||||
{
|
||||
if (sp.Appearance.SetVisualParams(visualParams))
|
||||
{
|
||||
changed = true;
|
||||
if (sp.Appearance.AvatarHeight > 0)
|
||||
sp.SetHeight(sp.Appearance.AvatarHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// If something changed in the appearance then queue an appearance save
|
||||
if (changed)
|
||||
QueueAppearanceSave(client.AgentId);
|
||||
|
||||
// And always queue up an appearance update to send out
|
||||
QueueAppearanceSend(client.AgentId);
|
||||
|
||||
// Send the appearance back to the avatar
|
||||
AvatarAppearance avp = sp.Appearance;
|
||||
sp.ControllingClient.SendAvatarDataImmediate(sp);
|
||||
sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks for the existance of a baked texture asset and
|
||||
/// requests the viewer rebake if the asset is not found
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="textureID"></param>
|
||||
/// <param name="idx"></param>
|
||||
private void CheckBakedTextureAssets(IClientAPI client, UUID textureID, int idx)
|
||||
{
|
||||
if (m_scene.AssetService.Get(textureID.ToString()) == null)
|
||||
{
|
||||
m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",
|
||||
textureID,idx,client.Name);
|
||||
client.SendRebakeAvatarTextures(textureID);
|
||||
}
|
||||
}
|
||||
|
||||
#region UpdateAppearanceTimer
|
||||
|
||||
public void QueueAppearanceSend(UUID agentid)
|
||||
{
|
||||
// DEBUG ON
|
||||
m_log.WarnFormat("[AVFACTORY] Queue appearance send for {0}",agentid);
|
||||
// DEBUG OFF
|
||||
|
||||
// 100 nanoseconds (ticks) we should wait
|
||||
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 10000000);
|
||||
lock (m_sendqueue)
|
||||
{
|
||||
m_sendqueue[agentid] = timestamp;
|
||||
m_updateTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void QueueAppearanceSave(UUID agentid)
|
||||
{
|
||||
// DEBUG ON
|
||||
m_log.WarnFormat("[AVFACTORY] Queue appearance save for {0}",agentid);
|
||||
// DEBUG OFF
|
||||
|
||||
// 100 nanoseconds (ticks) we should wait
|
||||
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 10000000);
|
||||
lock (m_savequeue)
|
||||
{
|
||||
m_savequeue[agentid] = timestamp;
|
||||
m_updateTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleAppearanceSend(UUID agentid)
|
||||
{
|
||||
ScenePresence sp = m_scene.GetScenePresence(agentid);
|
||||
if (sp == null)
|
||||
{
|
||||
m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid);
|
||||
return;
|
||||
}
|
||||
|
||||
// DEBUG ON
|
||||
m_log.WarnFormat("[AVFACTORY] Handle appearance send for {0}\n{1}",agentid,sp.Appearance.ToString());
|
||||
// DEBUG OFF
|
||||
|
||||
// Send the appearance to everyone in the scene
|
||||
sp.SendAppearanceToAllOtherAgents();
|
||||
|
||||
// Send the appearance back to the avatar
|
||||
AvatarAppearance avp = sp.Appearance;
|
||||
sp.ControllingClient.SendAvatarDataImmediate(sp);
|
||||
sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
|
||||
|
||||
/*
|
||||
// this needs to be fixed, the flag should be on scene presence not the region module
|
||||
// Start the animations if necessary
|
||||
if (!m_startAnimationSet)
|
||||
{
|
||||
sp.Animator.UpdateMovementAnimations();
|
||||
m_startAnimationSet = true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void HandleAppearanceSave(UUID agentid)
|
||||
{
|
||||
ScenePresence sp = m_scene.GetScenePresence(agentid);
|
||||
if (sp == null)
|
||||
{
|
||||
m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid);
|
||||
return;
|
||||
}
|
||||
|
||||
m_scene.AvatarService.SetAppearance(agentid, sp.Appearance);
|
||||
}
|
||||
|
||||
private void HandleAppearanceUpdateTimer(object sender, EventArgs ea)
|
||||
{
|
||||
long now = DateTime.Now.Ticks;
|
||||
|
||||
lock (m_sendqueue)
|
||||
{
|
||||
Dictionary<UUID,long> sends = new Dictionary<UUID,long>(m_sendqueue);
|
||||
foreach (KeyValuePair<UUID,long> kvp in sends)
|
||||
{
|
||||
if (kvp.Value < now)
|
||||
{
|
||||
Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); });
|
||||
m_sendqueue.Remove(kvp.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock (m_savequeue)
|
||||
{
|
||||
Dictionary<UUID,long> saves = new Dictionary<UUID,long>(m_savequeue);
|
||||
foreach (KeyValuePair<UUID,long> kvp in saves)
|
||||
{
|
||||
if (kvp.Value < now)
|
||||
{
|
||||
Util.FireAndForget(delegate(object o) { HandleAppearanceSave(kvp.Key); });
|
||||
m_savequeue.Remove(kvp.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_savequeue.Count == 0 && m_sendqueue.Count == 0)
|
||||
m_updateTimer.Stop();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Tell the client for this scene presence what items it should be wearing now
|
||||
/// </summary>
|
||||
public void SendWearables(IClientAPI client)
|
||||
{
|
||||
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
|
||||
if (sp == null)
|
||||
{
|
||||
m_log.WarnFormat("[AVFACTORY] SendWearables unable to find presence for {0}",client.AgentId);
|
||||
return;
|
||||
}
|
||||
|
||||
// DEBUG ON
|
||||
m_log.WarnFormat("[AVFACTORY]: Received request for wearables of {0}", client.AgentId);
|
||||
// DEBUG OFF
|
||||
client.SendWearables(sp.Appearance.Wearables,sp.Appearance.Serial++);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update what the avatar is wearing using an item from their inventory.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
|
||||
{
|
||||
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
|
||||
if (sp == null)
|
||||
{
|
||||
m_log.WarnFormat("[AVFACTORY] AvatarIsWearing unable to find presence for {0}",client.AgentId);
|
||||
return;
|
||||
}
|
||||
|
||||
// DEBUG ON
|
||||
m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}",client.AgentId);
|
||||
// DEBUG OFF
|
||||
|
||||
AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance);
|
||||
|
||||
//if (!TryGetAvatarAppearance(client.AgentId, out avatAppearance))
|
||||
//{
|
||||
// m_log.Warn("[AVFACTORY]: We didn't seem to find the appearance, falling back to ScenePresence");
|
||||
// avatAppearance = sp.Appearance;
|
||||
//}
|
||||
|
||||
//m_log.DebugFormat("[AVFACTORY]: Received wearables for {0}", client.Name);
|
||||
|
||||
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
|
||||
{
|
||||
if (wear.Type < AvatarWearable.MAX_WEARABLES)
|
||||
{
|
||||
AvatarWearable newWearable = new AvatarWearable(wear.ItemID,UUID.Zero);
|
||||
avatAppearance.SetWearable(wear.Type, newWearable);
|
||||
}
|
||||
}
|
||||
|
||||
SetAppearanceAssets(sp.UUID, ref avatAppearance);
|
||||
|
||||
m_scene.AvatarService.SetAppearance(client.AgentId, avatAppearance);
|
||||
sp.Appearance = avatAppearance;
|
||||
}
|
||||
|
||||
private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
|
||||
{
|
||||
IInventoryService invService = m_scene.InventoryService;
|
||||
|
||||
if (invService.GetRootFolder(userID) != null)
|
||||
{
|
||||
for (int i = 0; i < 13; i++)
|
||||
for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
|
||||
{
|
||||
if (appearance.Wearables[i].ItemID == UUID.Zero)
|
||||
{
|
||||
@@ -134,84 +384,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[APPEARANCE]: Can't find inventory item {0} for {1}, setting to default",
|
||||
"[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
|
||||
appearance.Wearables[i].ItemID, (WearableType)i);
|
||||
|
||||
appearance.Wearables[i].AssetID = def.Wearables[i].AssetID;
|
||||
appearance.Wearables[i].ItemID = UUID.Zero;
|
||||
appearance.Wearables[i].AssetID = UUID.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[APPEARANCE]: user {0} has no inventory, appearance isn't going to work", userID);
|
||||
m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update what the avatar is wearing using an item from their inventory.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void AvatarIsWearing(Object sender, AvatarWearingArgs e)
|
||||
{
|
||||
m_log.DebugFormat("[APPEARANCE]: AvatarIsWearing");
|
||||
|
||||
IClientAPI clientView = (IClientAPI)sender;
|
||||
ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId);
|
||||
|
||||
if (sp == null)
|
||||
{
|
||||
m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event");
|
||||
return;
|
||||
}
|
||||
|
||||
AvatarAppearance avatAppearance = sp.Appearance;
|
||||
//if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance))
|
||||
//{
|
||||
// m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence");
|
||||
// avatAppearance = sp.Appearance;
|
||||
//}
|
||||
|
||||
//m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name);
|
||||
|
||||
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
|
||||
{
|
||||
if (wear.Type < 13)
|
||||
{
|
||||
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
|
||||
}
|
||||
}
|
||||
|
||||
SetAppearanceAssets(sp.UUID, ref avatAppearance);
|
||||
AvatarData adata = new AvatarData(avatAppearance);
|
||||
m_scene.AvatarService.SetAvatar(clientView.AgentId, adata);
|
||||
|
||||
sp.Appearance = avatAppearance;
|
||||
}
|
||||
|
||||
public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)
|
||||
{
|
||||
visualParams = GetDefaultVisualParams();
|
||||
wearables = AvatarWearable.DefaultWearables;
|
||||
}
|
||||
|
||||
public void UpdateDatabase(UUID user, AvatarAppearance appearance)
|
||||
{
|
||||
//m_log.DebugFormat("[APPEARANCE]: UpdateDatabase");
|
||||
AvatarData adata = new AvatarData(appearance);
|
||||
m_scene.AvatarService.SetAvatar(user, adata);
|
||||
}
|
||||
|
||||
private static byte[] GetDefaultVisualParams()
|
||||
{
|
||||
byte[] visualParams;
|
||||
visualParams = new byte[218];
|
||||
for (int i = 0; i < 218; i++)
|
||||
{
|
||||
visualParams[i] = 100;
|
||||
}
|
||||
return visualParams;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
||||
}
|
||||
|
||||
(scene as Scene).EventManager.TriggerOnChatToClients(
|
||||
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
|
||||
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
|
||||
}
|
||||
|
||||
static private Vector3 CenterOfRegion = new Vector3(128, 128, 30);
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
|
||||
{
|
||||
LoadControlFile(filePath, data);
|
||||
}
|
||||
}
|
||||
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
||||
{
|
||||
if (LoadAsset(filePath, data))
|
||||
@@ -479,11 +479,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
/// <param name="path"></param>
|
||||
/// <param name="data"></param>
|
||||
protected void LoadControlFile(string path, byte[] data)
|
||||
{
|
||||
{
|
||||
XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data));
|
||||
XElement archiveElement = doc.Element("archive");
|
||||
int majorVersion = int.Parse(archiveElement.Attribute("major_version").Value);
|
||||
int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value);
|
||||
int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value);
|
||||
string version = string.Format("{0}.{1}", majorVersion, minorVersion);
|
||||
|
||||
if (majorVersion > MAX_MAJOR_VERSION)
|
||||
@@ -492,7 +492,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
string.Format(
|
||||
"The IAR you are trying to load has major version number of {0} but this version of OpenSim can only load IARs with major version number {1} and below",
|
||||
majorVersion, MAX_MAJOR_VERSION));
|
||||
}
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
public void Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
InventoryFolderBase inventoryFolder = null;
|
||||
InventoryItemBase inventoryItem = null;
|
||||
InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID);
|
||||
@@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||
// Write out control file. This has to be done first so that subsequent loaders will see this file first
|
||||
// XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
|
||||
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
|
||||
m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive.");
|
||||
m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive.");
|
||||
|
||||
if (inventoryFolder != null)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Server.Base;
|
||||
@@ -137,6 +138,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar
|
||||
|
||||
#region IAvatarService
|
||||
|
||||
public AvatarAppearance GetAppearance(UUID userID)
|
||||
{
|
||||
return m_AvatarService.GetAppearance(userID);
|
||||
}
|
||||
|
||||
public bool SetAppearance(UUID userID, AvatarAppearance appearance)
|
||||
{
|
||||
return m_AvatarService.SetAppearance(userID,appearance);
|
||||
}
|
||||
|
||||
public AvatarData GetAvatar(UUID userID)
|
||||
{
|
||||
return m_AvatarService.GetAvatar(userID);
|
||||
|
||||
@@ -199,13 +199,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
{
|
||||
majorVersion = 1;
|
||||
minorVersion = 0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
|
||||
// if (majorVersion == 1)
|
||||
// {
|
||||
// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
|
||||
// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
|
||||
// }
|
||||
|
||||
|
||||
@@ -232,6 +232,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
sw.Close();
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,10 +44,8 @@ namespace OpenSim.Region.CoreModules
|
||||
/// it is not based on ~06:00 == Sun Rise. Rather it is based on 00:00 being sun-rise.
|
||||
/// </summary>
|
||||
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
||||
//
|
||||
// Global Constants used to determine where in the sky the sun is
|
||||
//
|
||||
@@ -108,26 +106,25 @@ namespace OpenSim.Region.CoreModules
|
||||
private Scene m_scene = null;
|
||||
|
||||
// Calculated Once in the lifetime of a region
|
||||
private long TicksToEpoch; // Elapsed time for 1/1/1970
|
||||
private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds
|
||||
private uint SecondsPerYear; // Length of a virtual year in RW seconds
|
||||
private double SunSpeed; // Rate of passage in radians/second
|
||||
private double SeasonSpeed; // Rate of change for seasonal effects
|
||||
// private double HoursToRadians; // Rate of change for seasonal effects
|
||||
private long TicksUTCOffset = 0; // seconds offset from UTC
|
||||
private long TicksToEpoch; // Elapsed time for 1/1/1970
|
||||
private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds
|
||||
private uint SecondsPerYear; // Length of a virtual year in RW seconds
|
||||
private double SunSpeed; // Rate of passage in radians/second
|
||||
private double SeasonSpeed; // Rate of change for seasonal effects
|
||||
// private double HoursToRadians; // Rate of change for seasonal effects
|
||||
private long TicksUTCOffset = 0; // seconds offset from UTC
|
||||
// Calculated every update
|
||||
private float OrbitalPosition; // Orbital placement at a point in time
|
||||
private double HorizonShift; // Axis offset to skew day and night
|
||||
private double TotalDistanceTravelled; // Distance since beginning of time (in radians)
|
||||
private double SeasonalOffset; // Seaonal variation of tilt
|
||||
private float Magnitude; // Normal tilt
|
||||
// private double VWTimeRatio; // VW time as a ratio of real time
|
||||
private float OrbitalPosition; // Orbital placement at a point in time
|
||||
private double HorizonShift; // Axis offset to skew day and night
|
||||
private double TotalDistanceTravelled; // Distance since beginning of time (in radians)
|
||||
private double SeasonalOffset; // Seaonal variation of tilt
|
||||
private float Magnitude; // Normal tilt
|
||||
// private double VWTimeRatio; // VW time as a ratio of real time
|
||||
|
||||
// Working values
|
||||
private Vector3 Position = Vector3.Zero;
|
||||
private Vector3 Velocity = Vector3.Zero;
|
||||
private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
// Used to fix the sun in the sky so it doesn't move based on current time
|
||||
private bool m_SunFixed = false;
|
||||
@@ -135,8 +132,6 @@ namespace OpenSim.Region.CoreModules
|
||||
|
||||
private const int TICKS_PER_SECOND = 10000000;
|
||||
|
||||
|
||||
|
||||
// Current time in elapsed seconds since Jan 1st 1970
|
||||
private ulong CurrentTime
|
||||
{
|
||||
@@ -149,8 +144,6 @@ namespace OpenSim.Region.CoreModules
|
||||
// Time in seconds since UTC to use to calculate sun position.
|
||||
ulong PosTime = 0;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the sun's orbital position and its velocity.
|
||||
/// </summary>
|
||||
@@ -202,7 +195,6 @@ namespace OpenSim.Region.CoreModules
|
||||
PosTime += (ulong)(((CurDayPercentage - 0.5) / .5) * NightSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TotalDistanceTravelled = SunSpeed * PosTime; // distance measured in radians
|
||||
@@ -251,7 +243,6 @@ namespace OpenSim.Region.CoreModules
|
||||
Velocity.X = 0;
|
||||
Velocity.Y = 0;
|
||||
Velocity.Z = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -271,9 +262,7 @@ namespace OpenSim.Region.CoreModules
|
||||
private float GetCurrentTimeAsLindenSunHour()
|
||||
{
|
||||
if (m_SunFixed)
|
||||
{
|
||||
return m_SunFixedHour + 6;
|
||||
}
|
||||
|
||||
return GetCurrentSunHour() + 6.0f;
|
||||
}
|
||||
@@ -297,8 +286,6 @@ namespace OpenSim.Region.CoreModules
|
||||
m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TimeZone local = TimeZone.CurrentTimeZone;
|
||||
TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
|
||||
m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset);
|
||||
@@ -325,13 +312,11 @@ namespace OpenSim.Region.CoreModules
|
||||
// must hard code to ~.5 to match sun position in LL based viewers
|
||||
m_HorizonShift = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night);
|
||||
|
||||
|
||||
// Scales the sun hours 0...12 vs 12...24, essentially makes daylight hours longer/shorter vs nighttime hours
|
||||
m_DayTimeSunHourScale = config.Configs["Sun"].GetDouble("day_time_sun_hour_scale", d_DayTimeSunHourScale);
|
||||
|
||||
// Update frequency in frames
|
||||
m_UpdateInterval = config.Configs["Sun"].GetInt("update_interval", d_frame_mod);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -391,10 +376,8 @@ namespace OpenSim.Region.CoreModules
|
||||
}
|
||||
|
||||
scene.RegisterModuleInterface<ISunModule>(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
@@ -402,7 +385,7 @@ namespace OpenSim.Region.CoreModules
|
||||
public void Close()
|
||||
{
|
||||
ready = false;
|
||||
|
||||
|
||||
// Remove our hooks
|
||||
m_scene.EventManager.OnFrame -= SunUpdate;
|
||||
m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
|
||||
@@ -419,6 +402,7 @@ namespace OpenSim.Region.CoreModules
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EventManager Events
|
||||
@@ -446,9 +430,7 @@ namespace OpenSim.Region.CoreModules
|
||||
public void SunUpdate()
|
||||
{
|
||||
if (((m_frame++ % m_UpdateInterval) != 0) || !ready || m_SunFixed || !receivedEstateToolsSunUpdate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GenSunPos(); // Generate shared values once
|
||||
|
||||
@@ -467,7 +449,7 @@ namespace OpenSim.Region.CoreModules
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="regionHandle"></param>
|
||||
/// <param name="FixedTime">Is the sun's position fixed?</param>
|
||||
@@ -484,7 +466,6 @@ namespace OpenSim.Region.CoreModules
|
||||
while (FixedSunHour < 0)
|
||||
FixedSunHour += 24;
|
||||
|
||||
|
||||
m_SunFixedHour = FixedSunHour;
|
||||
m_SunFixed = FixedSun;
|
||||
|
||||
@@ -499,14 +480,12 @@ namespace OpenSim.Region.CoreModules
|
||||
// When sun settings are updated, we should update all clients with new settings.
|
||||
SunUpdateToAllClients();
|
||||
|
||||
|
||||
m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void SunUpdateToAllClients()
|
||||
{
|
||||
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
|
||||
@@ -553,7 +532,6 @@ namespace OpenSim.Region.CoreModules
|
||||
{
|
||||
float ticksleftover = CurrentTime % SecondsPerSunCycle;
|
||||
|
||||
|
||||
return (24.0f * (ticksleftover / SecondsPerSunCycle));
|
||||
}
|
||||
|
||||
@@ -666,7 +644,6 @@ namespace OpenSim.Region.CoreModules
|
||||
|
||||
// When sun settings are updated, we should update all clients with new settings.
|
||||
SunUpdateToAllClients();
|
||||
|
||||
}
|
||||
|
||||
return Output;
|
||||
|
||||
Reference in New Issue
Block a user